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.
*
* @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<DeviceOperationDTO> getSubscriptionOperationsByUUIDAndDeviceID(String uuid, int deviceId, int offset, int limit)
List<DeviceOperationDTO> getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid, int offset, int limit)
throws ApplicationManagementException;
/**

@ -2582,7 +2582,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
}
@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 {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
if (uuid == null || uuid.isEmpty()) {

@ -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<OperationResponseDTO> 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<OperationResponseDTO> 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;

Loading…
Cancel
Save