Fetch device according to the device identifier

revert-70aa11f8
manoj 10 years ago
parent 39b85a3b44
commit 14c6773b57

@ -59,7 +59,7 @@ public interface OperationManager {
public Operation getNextPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException; public Operation getNextPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException;
public void updateOperation(int deviceId, int operationId, Operation.Status operationStatus) throws public void updateOperation(DeviceIdentifier deviceId, int operationId, Operation.Status operationStatus) throws
OperationManagementException; OperationManagementException;
public void deleteOperation(int operationId) throws OperationManagementException; public void deleteOperation(int operationId) throws OperationManagementException;

@ -465,7 +465,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
} }
@Override @Override
public void updateOperation(int deviceId, int operationId, Operation.Status operationStatus) public void updateOperation(DeviceIdentifier deviceId, int operationId, Operation.Status operationStatus)
throws OperationManagementException { throws OperationManagementException {
DeviceManagementDataHolder.getInstance().getOperationManager().updateOperation(deviceId,operationId, DeviceManagementDataHolder.getInstance().getOperationManager().updateOperation(deviceId,operationId,
operationStatus); operationStatus);

@ -263,7 +263,7 @@ public class OperationManagerImpl implements OperationManager {
} }
@Override @Override
public void updateOperation(int deviceId, int operationId, Operation.Status operationStatus) public void updateOperation(DeviceIdentifier deviceIdentifier, int operationId, Operation.Status operationStatus)
throws OperationManagementException { throws OperationManagementException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -279,11 +279,19 @@ public class OperationManagerImpl implements OperationManager {
} }
dtoOperation.setStatus(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.valueOf dtoOperation.setStatus(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.valueOf
(operationStatus.toString())); (operationStatus.toString()));
Device device = deviceManagementService.getCoreDevice(deviceIdentifier);
OperationManagementDAOFactory.beginTransaction(); OperationManagementDAOFactory.beginTransaction();
operationDAO.updateOperation(dtoOperation); operationDAO.updateOperation(dtoOperation);
operationDAO.updateOperationStatus(deviceId,operationId, operationDAO.updateOperationStatus(device.getId(), operationId,
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.valueOf(operationStatus.toString())); org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status
.valueOf(operationStatus.toString()));
OperationManagementDAOFactory.commitTransaction(); OperationManagementDAOFactory.commitTransaction();
}catch (DeviceManagementException ex){
log.error("Error occurred while fetch the device for device identifier: " + deviceIdentifier.getId() + " " +
"type:" + deviceIdentifier.getType(), ex);
throw new OperationManagementException("Error occurred while update operation", ex);
} catch (OperationManagementDAOException ex) { } catch (OperationManagementDAOException ex) {
try { try {
OperationManagementDAOFactory.rollbackTransaction(); OperationManagementDAOFactory.rollbackTransaction();

@ -149,7 +149,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
} }
@Override @Override
public void updateOperation(int deviceId, int operationId, Operation.Status operationStatus) throws public void updateOperation(DeviceIdentifier deviceId, int operationId, Operation.Status operationStatus) throws
OperationManagementException { OperationManagementException {
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().updateOperation(deviceId, operationId, DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().updateOperation(deviceId, operationId,
operationStatus); operationStatus);

Loading…
Cancel
Save