diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java index 6c537c05d0..1cbeda5f08 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/services/SubscriptionManager.java @@ -291,14 +291,14 @@ public interface SubscriptionManager { /** * This method is responsible for retrieving device subscription details related to the given UUID. * - * @param uuid the UUID of the application release. * @param deviceId the deviceId of the device that need to get operation details. + * @param uuid the UUID of the application release. * @param offset the offset for the data set * @param limit the limit for the data set * @return {@link DeviceOperationDTO} which contains the details of device subscriptions. * @throws SubscriptionManagementException if there is an error while fetching the details. */ - List getSubscriptionOperationsByUUIDAndDeviceID(String uuid, int deviceId, int offset, int limit) + List getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid, int offset, int limit) throws ApplicationManagementException; /** diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 028d122ab5..0ade616d52 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -2582,7 +2582,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } @Override - public List getSubscriptionOperationsByUUIDAndDeviceID(String uuid, int deviceId, int offset, int limit) + public List getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid, int offset, int limit) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); if (uuid == null || uuid.isEmpty()) { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java index 0387dc9e5f..50ec3f1071 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java @@ -2796,43 +2796,46 @@ public class GenericOperationDAOImpl implements OperationDAO { "WHERE o.ID = ? " + "AND o.TENANT_ID = ?"; - try (Connection conn = OperationManagementDAOFactory.getConnection(); - PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setInt(1, operationId); - stmt.setInt(2, tenantId); + try { + Connection conn = OperationManagementDAOFactory.getConnection(); + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setInt(1, operationId); + stmt.setInt(2, tenantId); - try (ResultSet rs = stmt.executeQuery()) { - List responses = new ArrayList<>(); - while (rs.next()) { - if (operationDetails.getOperationId() == 0) { - operationDetails.setOperationId(rs.getInt("ID")); - operationDetails.setOperationCode(rs.getString("OPERATION_CODE")); - Blob detailsBlob = rs.getBlob("OPERATION_DETAILS"); - if (detailsBlob != null) { - JSONObject operationDetailsJson = OperationDAOUtil.convertBlobToJsonObject(detailsBlob); - operationDetails.setOperationDetails(operationDetailsJson); - } - Blob propertiesBlob = rs.getBlob("OPERATION_PROPERTIES"); - if (propertiesBlob != null) { - JSONObject operationPropertiesJson = OperationDAOUtil.convertBlobToJsonObject(propertiesBlob); - operationDetails.setOperationProperties(operationPropertiesJson); + try (ResultSet rs = stmt.executeQuery()) { + List responses = new ArrayList<>(); + while (rs.next()) { + if (operationDetails.getOperationId() == 0) { + operationDetails.setOperationId(rs.getInt("ID")); + operationDetails.setOperationCode(rs.getString("OPERATION_CODE")); + Blob detailsBlob = rs.getBlob("OPERATION_DETAILS"); + if (detailsBlob != null) { + JSONObject operationDetailsJson = OperationDAOUtil.convertBlobToJsonObject(detailsBlob); + operationDetails.setOperationDetails(operationDetailsJson); + } + Blob propertiesBlob = rs.getBlob("OPERATION_PROPERTIES"); + if (propertiesBlob != null) { + JSONObject operationPropertiesJson = OperationDAOUtil.convertBlobToJsonObject(propertiesBlob); + operationDetails.setOperationProperties(operationPropertiesJson); + } } - } - String response = rs.getString("OPERATION_RESPONSE"); - Timestamp responseTimestamp = rs.getTimestamp("RECEIVED_TIMESTAMP"); - if (response != null && responseTimestamp != null) { - OperationResponseDTO operationResponse = new OperationResponseDTO(); - operationResponse.setOperationResponse(response); - operationResponse.setResponseTimeStamp(responseTimestamp); - responses.add(operationResponse); + String response = rs.getString("OPERATION_RESPONSE"); + Timestamp responseTimestamp = rs.getTimestamp("RECEIVED_TIMESTAMP"); + if (response != null && responseTimestamp != null) { + OperationResponseDTO operationResponse = new OperationResponseDTO(); + operationResponse.setOperationResponse(response); + operationResponse.setResponseTimeStamp(responseTimestamp); + responses.add(operationResponse); + } } + operationDetails.setOperationResponses(responses); } - operationDetails.setOperationResponses(responses); } } catch (SQLException e) { - throw new OperationManagementDAOException("Error occurred while retrieving operation details for operation ID: " - + operationId, e); + String msg = "Error occurred while retrieving operation details for operation ID: " + operationId; + log.error(msg, e); + throw new OperationManagementDAOException(msg, e); } return operationDetails;