|
|
@ -20,20 +20,21 @@ package org.wso2.carbon.device.mgt.core.operation.mgt;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.wso2.carbon.device.mgt.common.Device;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.dto.Device;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationMappingDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationMappingDAO;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.util.OperationDAOUtil;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.util.OperationCreateTimeComparator;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.util.OperationCreateTimeComparator;
|
|
|
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementServiceImpl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Collections;
|
|
|
@ -54,7 +55,7 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
private OperationDAO policyOperationDAO;
|
|
|
|
private OperationDAO policyOperationDAO;
|
|
|
|
private OperationMappingDAO operationMappingDAO;
|
|
|
|
private OperationMappingDAO operationMappingDAO;
|
|
|
|
private OperationDAO operationDAO;
|
|
|
|
private OperationDAO operationDAO;
|
|
|
|
private DeviceManagementService deviceManagementService;
|
|
|
|
private DeviceDAO deviceDAO;
|
|
|
|
|
|
|
|
|
|
|
|
public OperationManagerImpl() {
|
|
|
|
public OperationManagerImpl() {
|
|
|
|
commandOperationDAO = OperationManagementDAOFactory.getCommandOperationDAO();
|
|
|
|
commandOperationDAO = OperationManagementDAOFactory.getCommandOperationDAO();
|
|
|
@ -63,16 +64,16 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
policyOperationDAO = OperationManagementDAOFactory.getPolicyOperationDAO();
|
|
|
|
policyOperationDAO = OperationManagementDAOFactory.getPolicyOperationDAO();
|
|
|
|
operationMappingDAO = OperationManagementDAOFactory.getOperationMappingDAO();
|
|
|
|
operationMappingDAO = OperationManagementDAOFactory.getOperationMappingDAO();
|
|
|
|
operationDAO = OperationManagementDAOFactory.getOperationDAO();
|
|
|
|
operationDAO = OperationManagementDAOFactory.getOperationDAO();
|
|
|
|
deviceManagementService = new DeviceManagementServiceImpl();
|
|
|
|
deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean addOperation(Operation operation, List<DeviceIdentifier> devices) throws
|
|
|
|
public boolean addOperation(Operation operation,
|
|
|
|
OperationManagementException {
|
|
|
|
List<DeviceIdentifier> deviceIdentifiers) throws OperationManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("operation:[" + operation.toString() + "]");
|
|
|
|
log.debug("operation:[" + operation.toString() + "]");
|
|
|
|
for (DeviceIdentifier deviceIdentifier : devices) {
|
|
|
|
for (DeviceIdentifier deviceIdentifier : deviceIdentifiers) {
|
|
|
|
log.debug("device identifier id:[" + deviceIdentifier.getId() + "] type:[" + deviceIdentifier.getType()
|
|
|
|
log.debug("device identifier id:[" + deviceIdentifier.getId() + "] type:[" + deviceIdentifier.getType()
|
|
|
|
+ "]");
|
|
|
|
+ "]");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -83,10 +84,10 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
OperationDAOUtil.convertOperation(operation);
|
|
|
|
OperationDAOUtil.convertOperation(operation);
|
|
|
|
|
|
|
|
|
|
|
|
int operationId = this.lookupOperationDAO(operation).addOperation(operationDto);
|
|
|
|
int operationId = this.lookupOperationDAO(operation).addOperation(operationDto);
|
|
|
|
org.wso2.carbon.device.mgt.common.Device device;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (DeviceIdentifier deviceIdentifier : devices) {
|
|
|
|
Device device;
|
|
|
|
device = deviceManagementService.getCoreDevice(deviceIdentifier);
|
|
|
|
for (DeviceIdentifier deviceIdentifier : deviceIdentifiers) {
|
|
|
|
|
|
|
|
device = deviceDAO.getDevice(deviceIdentifier);
|
|
|
|
if (device == null) {
|
|
|
|
if (device == null) {
|
|
|
|
String errorMsg = "The operation not added for device.The device not found for " +
|
|
|
|
String errorMsg = "The operation not added for device.The device not found for " +
|
|
|
|
"device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '" +
|
|
|
|
"device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '" +
|
|
|
@ -99,22 +100,19 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
OperationManagementDAOFactory.commitTransaction();
|
|
|
|
OperationManagementDAOFactory.commitTransaction();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
log.error("Error occurred while adding operation: ", e);
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
} catch (OperationManagementDAOException e1) {
|
|
|
|
} catch (OperationManagementDAOException e1) {
|
|
|
|
log.warn("Error occurred while roll-backing the transaction", e1);
|
|
|
|
log.warn("Error occurred while roll-backing the transaction", e1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new OperationManagementException("Error occurred while adding operation", e);
|
|
|
|
throw new OperationManagementException("Error occurred while adding operation", e);
|
|
|
|
} catch (DeviceManagementException deviceMgtEx) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
} catch (OperationManagementDAOException e1) {
|
|
|
|
} catch (OperationManagementDAOException e1) {
|
|
|
|
log.warn("Error occurred while roll-backing the transaction", e1);
|
|
|
|
log.warn("Error occurred while roll-backing the transaction", e1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String errorMsg = "Error occurred fetching devices ";
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving device metadata", e);
|
|
|
|
log.error(deviceMgtEx.getErrorMessage(), deviceMgtEx);
|
|
|
|
|
|
|
|
throw new OperationManagementException(errorMsg, deviceMgtEx);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -124,16 +122,12 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
List<Operation> operations = new ArrayList<Operation>();
|
|
|
|
List<Operation> operations = new ArrayList<Operation>();
|
|
|
|
org.wso2.carbon.device.mgt.common.Device device;
|
|
|
|
Device device = null;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
device = deviceManagementService.getCoreDevice(deviceIdentifier);
|
|
|
|
device = deviceDAO.getDevice(deviceIdentifier);
|
|
|
|
} catch (DeviceManagementException deviceMgtEx) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
String errorMsg = "Error occurred while retrieving the device " +
|
|
|
|
e.printStackTrace();
|
|
|
|
"for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '" +
|
|
|
|
|
|
|
|
deviceIdentifier.getId();
|
|
|
|
|
|
|
|
log.error(errorMsg, deviceMgtEx);
|
|
|
|
|
|
|
|
throw new OperationManagementException(errorMsg, deviceMgtEx);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (device == null) {
|
|
|
|
if (device == null) {
|
|
|
|
throw new OperationManagementException("Device not found for given device " +
|
|
|
|
throw new OperationManagementException("Device not found for given device " +
|
|
|
@ -163,7 +157,7 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
+ "]");
|
|
|
|
+ "]");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
org.wso2.carbon.device.mgt.common.Device device;
|
|
|
|
Device device;
|
|
|
|
List<Operation> operations = new ArrayList<Operation>();
|
|
|
|
List<Operation> operations = new ArrayList<Operation>();
|
|
|
|
|
|
|
|
|
|
|
|
List<org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList =
|
|
|
|
List<org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList =
|
|
|
@ -171,7 +165,7 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
device = deviceManagementService.getCoreDevice(deviceIdentifier);
|
|
|
|
device = deviceDAO.getDevice(deviceIdentifier);
|
|
|
|
|
|
|
|
|
|
|
|
if (device == null) {
|
|
|
|
if (device == null) {
|
|
|
|
throw new OperationManagementException("Device not found for given device " +
|
|
|
|
throw new OperationManagementException("Device not found for given device " +
|
|
|
@ -197,16 +191,16 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Collections.sort(operations, new OperationCreateTimeComparator());
|
|
|
|
Collections.sort(operations, new OperationCreateTimeComparator());
|
|
|
|
return operations;
|
|
|
|
return operations;
|
|
|
|
} catch (DeviceManagementException deviceMgtException) {
|
|
|
|
|
|
|
|
String errorMsg = "Error occurred while retrieving the device " +
|
|
|
|
|
|
|
|
"for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '"
|
|
|
|
|
|
|
|
+ deviceIdentifier.getId();
|
|
|
|
|
|
|
|
log.error(errorMsg, deviceMgtException);
|
|
|
|
|
|
|
|
throw new OperationManagementException(errorMsg, deviceMgtException);
|
|
|
|
|
|
|
|
} 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 " +
|
|
|
|
"pending operations assigned for '" + deviceIdentifier.getType() + "' device '" +
|
|
|
|
"pending operations assigned for '" + deviceIdentifier.getType() + "' device '" +
|
|
|
|
deviceIdentifier.getId() + "'", e);
|
|
|
|
deviceIdentifier.getId() + "'", e);
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
String errorMsg = "Error occurred while retrieving the device " +
|
|
|
|
|
|
|
|
"for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '"
|
|
|
|
|
|
|
|
+ deviceIdentifier.getId();
|
|
|
|
|
|
|
|
log.error(errorMsg, e);
|
|
|
|
|
|
|
|
throw new OperationManagementException(errorMsg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -220,7 +214,7 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
Operation operation = null;
|
|
|
|
Operation operation = null;
|
|
|
|
Device device;
|
|
|
|
Device device;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
device = deviceManagementService.getCoreDevice(deviceIdentifier);
|
|
|
|
device = deviceDAO.getDevice(deviceIdentifier);
|
|
|
|
|
|
|
|
|
|
|
|
if (device == null) {
|
|
|
|
if (device == null) {
|
|
|
|
throw new OperationManagementException("Device not found for given device " +
|
|
|
|
throw new OperationManagementException("Device not found for given device " +
|
|
|
@ -234,7 +228,7 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
|
|
|
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
|
|
|
|
commandOperation =
|
|
|
|
commandOperation =
|
|
|
|
(org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO
|
|
|
|
(org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO
|
|
|
|
.getOperation(dtoOperation.getId());
|
|
|
|
.getOperation(dtoOperation.getId());
|
|
|
|
dtoOperation.setEnabled(commandOperation.isEnabled());
|
|
|
|
dtoOperation.setEnabled(commandOperation.isEnabled());
|
|
|
|
} else if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG
|
|
|
|
} else if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG
|
|
|
|
.equals(dtoOperation.getType())) {
|
|
|
|
.equals(dtoOperation.getType())) {
|
|
|
@ -249,14 +243,14 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
operation = OperationDAOUtil.convertOperation(dtoOperation);
|
|
|
|
operation = OperationDAOUtil.convertOperation(dtoOperation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return operation;
|
|
|
|
return operation;
|
|
|
|
} catch (DeviceManagementException deviceMgtException) {
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving next pending operation", e);
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
String errorMsg = "Error occurred while retrieving the device " +
|
|
|
|
String errorMsg = "Error occurred while retrieving the device " +
|
|
|
|
"for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '"
|
|
|
|
"for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '"
|
|
|
|
+ deviceIdentifier.getId();
|
|
|
|
+ deviceIdentifier.getId();
|
|
|
|
log.error(errorMsg, deviceMgtException);
|
|
|
|
log.error(errorMsg, e);
|
|
|
|
throw new OperationManagementException(errorMsg, deviceMgtException);
|
|
|
|
throw new OperationManagementException(errorMsg, e);
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving next pending operation", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -277,7 +271,7 @@ 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);
|
|
|
|
Device device = deviceDAO.getDevice(deviceIdentifier);
|
|
|
|
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.beginTransaction();
|
|
|
|
OperationManagementDAOFactory.beginTransaction();
|
|
|
|
operationDAO.updateOperation(dtoOperation);
|
|
|
|
operationDAO.updateOperation(dtoOperation);
|
|
|
@ -285,11 +279,6 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status
|
|
|
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status
|
|
|
|
.valueOf(operationStatus.toString()));
|
|
|
|
.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();
|
|
|
@ -298,6 +287,10 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.error("Error occurred while updating the operation: " + operationId + " status:" + operationStatus, ex);
|
|
|
|
log.error("Error occurred while updating the operation: " + operationId + " status:" + operationStatus, ex);
|
|
|
|
throw new OperationManagementException("Error occurred while update operation", ex);
|
|
|
|
throw new OperationManagementException("Error occurred while update operation", ex);
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
log.error("Error occurred while fetch the device for device identifier: " + deviceIdentifier.getId() + " " +
|
|
|
|
|
|
|
|
"type:" + deviceIdentifier.getType(), e);
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while update operation", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -331,7 +324,7 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
public Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceIdentifier, int operationId)
|
|
|
|
public Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceIdentifier, int operationId)
|
|
|
|
throws OperationManagementException {
|
|
|
|
throws OperationManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
org.wso2.carbon.device.mgt.common.Device device;
|
|
|
|
Device device;
|
|
|
|
Operation operation;
|
|
|
|
Operation operation;
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
@ -342,7 +335,7 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
device = deviceManagementService.getCoreDevice(deviceIdentifier);
|
|
|
|
device = deviceDAO.getDevice(deviceIdentifier);
|
|
|
|
if (device == null) {
|
|
|
|
if (device == null) {
|
|
|
|
throw new OperationManagementException("Device not found for given device identifier:" +
|
|
|
|
throw new OperationManagementException("Device not found for given device identifier:" +
|
|
|
|
deviceIdentifier.getId() + " type:" + deviceIdentifier.getType());
|
|
|
|
deviceIdentifier.getId() + " type:" + deviceIdentifier.getType());
|
|
|
@ -373,30 +366,30 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
" device" + " Id:" + device.getId());
|
|
|
|
" device" + " Id:" + device.getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
operation = OperationDAOUtil.convertOperation(dtoOperation);
|
|
|
|
operation = OperationDAOUtil.convertOperation(dtoOperation);
|
|
|
|
} catch (DeviceManagementException deviceMgtException) {
|
|
|
|
|
|
|
|
String errorMsg = "Error occurred while retrieving the device " +
|
|
|
|
|
|
|
|
"for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '"
|
|
|
|
|
|
|
|
+ deviceIdentifier.getId();
|
|
|
|
|
|
|
|
log.error(errorMsg, deviceMgtException);
|
|
|
|
|
|
|
|
throw new OperationManagementException(errorMsg, deviceMgtException);
|
|
|
|
|
|
|
|
} 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 '" + deviceIdentifier.getType() + "' device '" + deviceIdentifier.getId()
|
|
|
|
"operations assigned for '" + deviceIdentifier.getType() + "' device '" + deviceIdentifier.getId()
|
|
|
|
+ "'", e);
|
|
|
|
+ "'", e);
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
String errorMsg = "Error occurred while retrieving the device " +
|
|
|
|
|
|
|
|
"for device Identifier type -'" + deviceIdentifier.getType() + "' and device Id '"
|
|
|
|
|
|
|
|
+ deviceIdentifier.getId();
|
|
|
|
|
|
|
|
log.error(errorMsg, e);
|
|
|
|
|
|
|
|
throw new OperationManagementException(errorMsg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return operation;
|
|
|
|
return operation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<? extends Operation> getOperationsByDeviceAndStatus(DeviceIdentifier identifier,
|
|
|
|
public List<? extends Operation> getOperationsByDeviceAndStatus(DeviceIdentifier identifier,
|
|
|
|
Operation.Status status) throws OperationManagementException, DeviceManagementException {
|
|
|
|
Operation.Status status) throws OperationManagementException, DeviceManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
List<Operation> operations = new ArrayList<Operation>();
|
|
|
|
List<Operation> operations = new ArrayList<Operation>();
|
|
|
|
List<org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList =
|
|
|
|
List<org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList =
|
|
|
|
new ArrayList<org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation>();
|
|
|
|
new ArrayList<org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation>();
|
|
|
|
|
|
|
|
|
|
|
|
org.wso2.carbon.device.mgt.common.Device device = deviceManagementService.getCoreDevice(identifier);
|
|
|
|
Device device = deviceDAO.getDevice(identifier);
|
|
|
|
|
|
|
|
|
|
|
|
if (device == null) {
|
|
|
|
if (device == null) {
|
|
|
|
throw new DeviceManagementException("Device not found for device id:" + identifier.getId() + " " +
|
|
|
|
throw new DeviceManagementException("Device not found for device id:" + identifier.getId() + " " +
|
|
|
@ -423,15 +416,15 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
operations.add(operation);
|
|
|
|
operations.add(operation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return operations;
|
|
|
|
return operations;
|
|
|
|
} catch (DeviceManagementException deviceMgtException) {
|
|
|
|
|
|
|
|
String errorMsg = "Error occurred while retrieving the device " +
|
|
|
|
|
|
|
|
"for device Identifier type -'" + identifier.getType() + "' and device Id '" + identifier.getId();
|
|
|
|
|
|
|
|
log.error(errorMsg, deviceMgtException);
|
|
|
|
|
|
|
|
throw new OperationManagementException(errorMsg, deviceMgtException);
|
|
|
|
|
|
|
|
} 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 '" + identifier.getType() + "' device '" +
|
|
|
|
"operations assigned for '" + identifier.getType() + "' device '" +
|
|
|
|
identifier.getId() + "' and status:" + status.toString(), e);
|
|
|
|
identifier.getId() + "' and status:" + status.toString(), e);
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
|
|
|
|
String errorMsg = "Error occurred while retrieving the device " +
|
|
|
|
|
|
|
|
"for device Identifier type -'" + identifier.getType() + "' and device Id '" + identifier.getId();
|
|
|
|
|
|
|
|
log.error(errorMsg, e);
|
|
|
|
|
|
|
|
throw new OperationManagementException(errorMsg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|