Address review comments

#11311
Nipuni Kavindya 5 months ago
parent 98d05785c3
commit 28cf9fc403

@ -291,14 +291,14 @@ public interface SubscriptionManager {
/** /**
* This method is responsible for retrieving device subscription details related to the given UUID. * 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 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 offset the offset for the data set
* @param limit the limit for the data set * @param limit the limit for the data set
* @return {@link DeviceOperationDTO} which contains the details of device subscriptions. * @return {@link DeviceOperationDTO} which contains the details of device subscriptions.
* @throws SubscriptionManagementException if there is an error while fetching the details. * @throws SubscriptionManagementException if there is an error while fetching the details.
*/ */
List<DeviceOperationDTO> getSubscriptionOperationsByUUIDAndDeviceID(String uuid, int deviceId, int offset, int limit) List<DeviceOperationDTO> getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid, int offset, int limit)
throws ApplicationManagementException; throws ApplicationManagementException;
/** /**

@ -2582,7 +2582,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
} }
@Override @Override
public List<DeviceOperationDTO> getSubscriptionOperationsByUUIDAndDeviceID(String uuid, int deviceId, int offset, int limit) public List<DeviceOperationDTO> getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid, int offset, int limit)
throws ApplicationManagementException { throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
if (uuid == null || uuid.isEmpty()) { if (uuid == null || uuid.isEmpty()) {

@ -2796,43 +2796,46 @@ public class GenericOperationDAOImpl implements OperationDAO {
"WHERE o.ID = ? " + "WHERE o.ID = ? " +
"AND o.TENANT_ID = ?"; "AND o.TENANT_ID = ?";
try (Connection conn = OperationManagementDAOFactory.getConnection(); try {
PreparedStatement stmt = conn.prepareStatement(sql)) { Connection conn = OperationManagementDAOFactory.getConnection();
stmt.setInt(1, operationId); try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(2, tenantId); stmt.setInt(1, operationId);
stmt.setInt(2, tenantId);
try (ResultSet rs = stmt.executeQuery()) { try (ResultSet rs = stmt.executeQuery()) {
List<OperationResponseDTO> responses = new ArrayList<>(); List<OperationResponseDTO> responses = new ArrayList<>();
while (rs.next()) { while (rs.next()) {
if (operationDetails.getOperationId() == 0) { if (operationDetails.getOperationId() == 0) {
operationDetails.setOperationId(rs.getInt("ID")); operationDetails.setOperationId(rs.getInt("ID"));
operationDetails.setOperationCode(rs.getString("OPERATION_CODE")); operationDetails.setOperationCode(rs.getString("OPERATION_CODE"));
Blob detailsBlob = rs.getBlob("OPERATION_DETAILS"); Blob detailsBlob = rs.getBlob("OPERATION_DETAILS");
if (detailsBlob != null) { if (detailsBlob != null) {
JSONObject operationDetailsJson = OperationDAOUtil.convertBlobToJsonObject(detailsBlob); JSONObject operationDetailsJson = OperationDAOUtil.convertBlobToJsonObject(detailsBlob);
operationDetails.setOperationDetails(operationDetailsJson); operationDetails.setOperationDetails(operationDetailsJson);
} }
Blob propertiesBlob = rs.getBlob("OPERATION_PROPERTIES"); Blob propertiesBlob = rs.getBlob("OPERATION_PROPERTIES");
if (propertiesBlob != null) { if (propertiesBlob != null) {
JSONObject operationPropertiesJson = OperationDAOUtil.convertBlobToJsonObject(propertiesBlob); JSONObject operationPropertiesJson = OperationDAOUtil.convertBlobToJsonObject(propertiesBlob);
operationDetails.setOperationProperties(operationPropertiesJson); operationDetails.setOperationProperties(operationPropertiesJson);
}
} }
}
String response = rs.getString("OPERATION_RESPONSE"); String response = rs.getString("OPERATION_RESPONSE");
Timestamp responseTimestamp = rs.getTimestamp("RECEIVED_TIMESTAMP"); Timestamp responseTimestamp = rs.getTimestamp("RECEIVED_TIMESTAMP");
if (response != null && responseTimestamp != null) { if (response != null && responseTimestamp != null) {
OperationResponseDTO operationResponse = new OperationResponseDTO(); OperationResponseDTO operationResponse = new OperationResponseDTO();
operationResponse.setOperationResponse(response); operationResponse.setOperationResponse(response);
operationResponse.setResponseTimeStamp(responseTimestamp); operationResponse.setResponseTimeStamp(responseTimestamp);
responses.add(operationResponse); responses.add(operationResponse);
}
} }
operationDetails.setOperationResponses(responses);
} }
operationDetails.setOperationResponses(responses);
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new OperationManagementDAOException("Error occurred while retrieving operation details for operation ID: " String msg = "Error occurred while retrieving operation details for operation ID: " + operationId;
+ operationId, e); log.error(msg, e);
throw new OperationManagementDAOException(msg, e);
} }
return operationDetails; return operationDetails;

Loading…
Cancel
Save