Operations Refractor

revert-70aa11f8
manoj 10 years ago
parent d0b553d26a
commit 4f4240f176

@ -70,7 +70,8 @@ public class OperationManagerImpl implements OperationManager {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("operation:[" + operation.toString() + "]"); log.debug("operation:[" + operation.toString() + "]");
for (DeviceIdentifier deviceIdentifier : devices) { for (DeviceIdentifier deviceIdentifier : devices) {
log.debug("device identifier id:["+deviceIdentifier.getId()+"] type:["+deviceIdentifier.getType()+"]"); log.debug("device identifier id:[" + deviceIdentifier.getId() + "] type:[" + deviceIdentifier.getType()
+ "]");
} }
} }
try { try {
@ -249,38 +250,42 @@ public class OperationManagerImpl implements OperationManager {
} }
@Override @Override
public Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceId, int operationId) public Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceIdentifier, int operationId)
throws OperationManagementException { throws OperationManagementException {
Device device; Device device;
Operation operation; Operation operation;
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Device Type:"+deviceId.getType()+" Id:"+deviceId.getId()); log.debug("Device Type:" + deviceIdentifier.getType() + " Id:" + deviceIdentifier.getId());
} }
try { try {
device = deviceDAO.getDevice(deviceId); device = deviceDAO.getDevice(deviceIdentifier);
if (device == null) { if (device == null) {
throw new OperationManagementException("Device not found for given device identifier:"+deviceId.getId throw new OperationManagementException(
()+" type:"+device.getDeviceType()); "Device not found for given device identifier:" + deviceIdentifier.getId
() + " type:" + deviceIdentifier.getType());
} }
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation = operationDAO org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation = operationDAO
.getOperationByDeviceAndId(device.getId(), operationId); .getOperationByDeviceAndId(device.getId(), operationId);
if (dtoOperation == null) { if (dtoOperation == null) {
throw new OperationManagementException("Operation not found for operation Id:"+ operationId +" device" + throw new OperationManagementException(
"Operation not found for operation Id:" + operationId + " device" +
" Id:" + device.getId()); " Id:" + device.getId());
} }
operation = OperationDAOUtil.convertOperation(dtoOperation); operation = OperationDAOUtil.convertOperation(dtoOperation);
} catch (DeviceManagementDAOException deviceDAOException) { } catch (DeviceManagementDAOException deviceDAOException) {
String errorMsg = "Error occurred while retrieving the device " + String errorMsg = "Error occurred while retrieving the device " +
"for device Identifier type -'" + deviceId.getType() + "' and device Id '" + deviceId.getId(); "for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '"
+ deviceIdentifier.getId();
log.error(errorMsg, deviceDAOException); log.error(errorMsg, deviceDAOException);
throw new OperationManagementException(errorMsg, deviceDAOException); throw new OperationManagementException(errorMsg, deviceDAOException);
} catch (OperationManagementDAOException e) { } catch (OperationManagementDAOException e) {
throw new OperationManagementException("Error occurred while retrieving the list of " + throw new OperationManagementException("Error occurred while retrieving the list of " +
"operations assigned for '" + deviceId.getType() + "' device '" + deviceId.getId() + "'", e); "operations assigned for '" + deviceIdentifier.getType() + "' device '" + deviceIdentifier.getId()
+ "'", e);
} }
return operation; return operation;
} }
@ -345,7 +350,8 @@ public class OperationManagerImpl implements OperationManager {
try { try {
List<Operation> operations = new ArrayList<Operation>(); List<Operation> operations = new ArrayList<Operation>();
List<? extends org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList = List<? extends org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList =
operationDAO.getOperationsForStatus(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status operationDAO
.getOperationsForStatus(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status
.valueOf(status.toString())); .valueOf(status.toString()));
Operation operation; Operation operation;
for (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation : dtoOperationList) { for (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation : dtoOperationList) {

@ -324,7 +324,7 @@ public class OperationDAOImpl implements OperationDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
Operation operation = null; Operation operation;
ByteArrayInputStream bais; ByteArrayInputStream bais;
ObjectInputStream ois; ObjectInputStream ois;

@ -119,8 +119,10 @@
</importFeatureDef> </importFeatureDef>
<importFeatureDef>org.wso2.carbon.apimgt.core:${carbon.api.mgt.version} <importFeatureDef>org.wso2.carbon.apimgt.core:${carbon.api.mgt.version}
</importFeatureDef> </importFeatureDef>
<!--
<importFeatureDef>org.wso2.carbon.transaction.manager:${carbon.commons.version} <importFeatureDef>org.wso2.carbon.transaction.manager:${carbon.commons.version}
</importFeatureDef> </importFeatureDef>
-->
</importFeatures> </importFeatures>
</configuration> </configuration>
</execution> </execution>

Loading…
Cancel
Save