|
|
@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.wso2.carbon.context.CarbonContext;
|
|
|
|
import org.wso2.carbon.context.CarbonContext;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
|
|
|
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
|
|
|
|
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;
|
|
|
@ -36,6 +37,7 @@ 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 java.sql.SQLException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
@ -70,7 +72,6 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int addOperation(Operation operation,
|
|
|
|
public int addOperation(Operation operation,
|
|
|
|
List<DeviceIdentifier> deviceIds) throws OperationManagementException {
|
|
|
|
List<DeviceIdentifier> deviceIds) throws OperationManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("operation:[" + operation.toString() + "]");
|
|
|
|
log.debug("operation:[" + operation.toString() + "]");
|
|
|
|
for (DeviceIdentifier deviceIdentifier : deviceIds) {
|
|
|
|
for (DeviceIdentifier deviceIdentifier : deviceIds) {
|
|
|
@ -101,19 +102,15 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
OperationManagementDAOFactory.commitTransaction();
|
|
|
|
OperationManagementDAOFactory.commitTransaction();
|
|
|
|
return operationId;
|
|
|
|
return operationId;
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
} catch (OperationManagementDAOException 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 (DeviceManagementDAOException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
} catch (OperationManagementDAOException e1) {
|
|
|
|
|
|
|
|
log.warn("Error occurred while roll-backing the transaction", e1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving device metadata", e);
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving device metadata", e);
|
|
|
|
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while initiating the transaction", e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -122,7 +119,7 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
int enrolmentId;
|
|
|
|
int enrolmentId;
|
|
|
|
List<Operation> operations = new ArrayList<>();
|
|
|
|
List<Operation> operations = new ArrayList<>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.getConnection();
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
|
|
|
|
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
@ -145,12 +142,10 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving metadata of '" +
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving metadata of '" +
|
|
|
|
deviceId.getType() + "' device carrying the identifier '" + deviceId.getId() + "'");
|
|
|
|
deviceId.getType() + "' device carrying the identifier '" + deviceId.getId() + "'");
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
|
|
|
|
log.warn("Error occurred while closing data source connection", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -165,7 +160,7 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
List<Operation> operations = new ArrayList<>();
|
|
|
|
List<Operation> operations = new ArrayList<>();
|
|
|
|
List<org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList = new ArrayList<>();
|
|
|
|
List<org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList = new ArrayList<>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.getConnection();
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
|
|
|
|
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
@ -202,12 +197,10 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the device " +
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the device " +
|
|
|
|
"for device Identifier type -'" + deviceId.getType() + "' and device Id '"
|
|
|
|
"for device Identifier type -'" + deviceId.getType() + "' and device Id '"
|
|
|
|
+ deviceId.getId() + "'", e);
|
|
|
|
+ deviceId.getId() + "'", e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
|
|
|
|
log.warn("Error occurred while closing data source connection", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -220,7 +213,7 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
Operation operation = null;
|
|
|
|
Operation operation = null;
|
|
|
|
int enrolmentId;
|
|
|
|
int enrolmentId;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.getConnection();
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
|
|
|
|
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
@ -258,23 +251,19 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the device " +
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the device " +
|
|
|
|
"for device Identifier type -'" + deviceId.getType() + "' and device Id '" + deviceId.getId(), e);
|
|
|
|
"for device Identifier type -'" + deviceId.getType() + "' and device Id '" + deviceId.getId(), e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
|
|
|
|
log.warn("Error occurred while closing data source connection", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void updateOperation(DeviceIdentifier deviceId, Operation operation) throws OperationManagementException {
|
|
|
|
public void updateOperation(DeviceIdentifier deviceId, Operation operation) throws OperationManagementException {
|
|
|
|
int operationId = operation.getId();
|
|
|
|
int operationId = operation.getId();
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("operation Id:" + operationId + " status:" + operation.getStatus());
|
|
|
|
log.debug("operation Id:" + operationId + " status:" + operation.getStatus());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.beginTransaction();
|
|
|
|
OperationManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
|
|
|
@ -282,65 +271,49 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
int enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
int enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
|
|
|
|
|
|
|
|
if (operation.getStatus() != null) {
|
|
|
|
if (operation.getStatus() != null) {
|
|
|
|
OperationManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
operationDAO.updateOperationStatus(enrolmentId, operationId,
|
|
|
|
operationDAO.updateOperationStatus(enrolmentId, operationId,
|
|
|
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status
|
|
|
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status
|
|
|
|
.valueOf(operation.getStatus().toString()));
|
|
|
|
.valueOf(operation.getStatus().toString()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (operation.getOperationResponse() != null) {
|
|
|
|
if (operation.getOperationResponse() != null) {
|
|
|
|
OperationManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
operationDAO.addOperationResponse(enrolmentId, operationId, operation.getOperationResponse());
|
|
|
|
operationDAO.addOperationResponse(enrolmentId, operationId, operation.getOperationResponse());
|
|
|
|
OperationManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.commitTransaction();
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
} catch (OperationManagementDAOException e1) {
|
|
|
|
|
|
|
|
log.warn("Error occurred while roll-backing the update operation transaction", e1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while updating the operation: " + operationId +
|
|
|
|
throw new OperationManagementException("Error occurred while updating the operation: " + operationId +
|
|
|
|
" status:" + operation.getStatus(), e);
|
|
|
|
" status:" + operation.getStatus(), e);
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
} catch (OperationManagementDAOException e1) {
|
|
|
|
|
|
|
|
log.warn("Error occurred while roll-backing the update operation transaction", e1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while fetching the device for device identifier: " +
|
|
|
|
throw new OperationManagementException("Error occurred while fetching the device for device identifier: " +
|
|
|
|
deviceId.getId() + "type:" + deviceId.getType(), e);
|
|
|
|
deviceId.getId() + "type:" + deviceId.getType(), e);
|
|
|
|
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while initiating a transaction", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
|
|
|
|
log.warn("Error occurred while closing data source connection", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void deleteOperation(int operationId) throws OperationManagementException {
|
|
|
|
public void deleteOperation(int operationId) throws OperationManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.beginTransaction();
|
|
|
|
OperationManagementDAOFactory.beginTransaction();
|
|
|
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operation = operationDAO.getOperation
|
|
|
|
|
|
|
|
(operationId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operation =
|
|
|
|
|
|
|
|
operationDAO.getOperation(operationId);
|
|
|
|
if (operation == null) {
|
|
|
|
if (operation == null) {
|
|
|
|
throw new OperationManagementException("Operation not found for operation id:" + operationId);
|
|
|
|
throw new OperationManagementException("Operation not found for operation id:" + operationId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lookupOperationDAO(operation).deleteOperation(operationId);
|
|
|
|
lookupOperationDAO(operation).deleteOperation(operationId);
|
|
|
|
OperationManagementDAOFactory.commitTransaction();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.commitTransaction();
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
try {
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
OperationManagementDAOFactory.rollbackTransaction();
|
|
|
|
} catch (OperationManagementDAOException e1) {
|
|
|
|
|
|
|
|
log.warn("Error occurred while roll-backing the delete operation transaction", e1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while deleting the operation: " + operationId, e);
|
|
|
|
throw new OperationManagementException("Error occurred while deleting the operation: " + operationId, e);
|
|
|
|
|
|
|
|
} catch (TransactionManagementException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while initiating a transaction", e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -349,13 +322,12 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
throws OperationManagementException {
|
|
|
|
throws OperationManagementException {
|
|
|
|
int enrolmentId;
|
|
|
|
int enrolmentId;
|
|
|
|
Operation operation;
|
|
|
|
Operation operation;
|
|
|
|
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Operation Id:" + operationId + " Device Type:" + deviceId.getType() + " Device Identifier:" +
|
|
|
|
log.debug("Operation Id:" + operationId + " Device Type:" + deviceId.getType() + " Device Identifier:" +
|
|
|
|
deviceId.getId());
|
|
|
|
deviceId.getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.getConnection();
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
|
|
|
|
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
@ -376,12 +348,11 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
} else if (dtoOperation.getType()
|
|
|
|
} else if (dtoOperation.getType()
|
|
|
|
.equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {
|
|
|
|
.equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {
|
|
|
|
dtoOperation = configOperationDAO.getOperation(dtoOperation.getId());
|
|
|
|
dtoOperation = configOperationDAO.getOperation(dtoOperation.getId());
|
|
|
|
} else if (dtoOperation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type
|
|
|
|
} else if (dtoOperation.getType().equals(
|
|
|
|
.PROFILE)) {
|
|
|
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.PROFILE)) {
|
|
|
|
dtoOperation = profileOperationDAO.getOperation(dtoOperation.getId());
|
|
|
|
dtoOperation = profileOperationDAO.getOperation(dtoOperation.getId());
|
|
|
|
} else if (dtoOperation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type
|
|
|
|
} else if (dtoOperation.getType().equals(
|
|
|
|
.POLICY)) {
|
|
|
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.POLICY)) {
|
|
|
|
|
|
|
|
|
|
|
|
dtoOperation = policyOperationDAO.getOperation(dtoOperation.getId());
|
|
|
|
dtoOperation = policyOperationDAO.getOperation(dtoOperation.getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -398,12 +369,10 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the device " +
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the device " +
|
|
|
|
"for device Identifier type -'" + deviceId.getType() + "' and device Id '" +
|
|
|
|
"for device Identifier type -'" + deviceId.getType() + "' and device Id '" +
|
|
|
|
deviceId.getId() + "'", e);
|
|
|
|
deviceId.getId() + "'", e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while opening connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
|
|
|
|
log.warn("Error occurred while closing data source connection", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return operation;
|
|
|
|
return operation;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -415,7 +384,7 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
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<>();
|
|
|
|
new ArrayList<>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.getConnection();
|
|
|
|
OperationManagementDAOFactory.openConnection();
|
|
|
|
|
|
|
|
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
|
int enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
|
@ -455,18 +424,15 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the device " +
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the device " +
|
|
|
|
"for device Identifier type -'" + deviceId.getType() + "' and device Id '" + deviceId.getId(), e);
|
|
|
|
"for device Identifier type -'" + deviceId.getType() + "' and device Id '" + deviceId.getId(), e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
|
|
|
|
log.warn("Error occurred while closing data source connection", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Operation getOperation(int operationId) throws OperationManagementException {
|
|
|
|
public Operation getOperation(int operationId) throws OperationManagementException {
|
|
|
|
|
|
|
|
|
|
|
|
Operation operation;
|
|
|
|
Operation operation;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
OperationManagementDAOFactory.getConnection();
|
|
|
|
OperationManagementDAOFactory.getConnection();
|
|
|
@ -480,8 +446,9 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
if (dtoOperation.getType()
|
|
|
|
if (dtoOperation.getType()
|
|
|
|
.equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND)) {
|
|
|
|
.equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND)) {
|
|
|
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
|
|
|
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
|
|
|
|
commandOperation = (org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO
|
|
|
|
commandOperation =
|
|
|
|
.getOperation(dtoOperation.getId());
|
|
|
|
(org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO.
|
|
|
|
|
|
|
|
getOperation(dtoOperation.getId());
|
|
|
|
dtoOperation.setEnabled(commandOperation.isEnabled());
|
|
|
|
dtoOperation.setEnabled(commandOperation.isEnabled());
|
|
|
|
} else if (dtoOperation.getType()
|
|
|
|
} else if (dtoOperation.getType()
|
|
|
|
.equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {
|
|
|
|
.equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {
|
|
|
@ -496,15 +463,12 @@ public class OperationManagerImpl implements OperationManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
operation = OperationDAOUtil.convertOperation(dtoOperation);
|
|
|
|
operation = OperationDAOUtil.convertOperation(dtoOperation);
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
String errorMsg = "Error occurred while retrieving the operation with operation Id '" + operationId;
|
|
|
|
throw new OperationManagementException("Error occurred while retrieving the operation with operation Id '" +
|
|
|
|
log.error(errorMsg, e);
|
|
|
|
operationId, e);
|
|
|
|
throw new OperationManagementException(errorMsg, e);
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
throw new OperationManagementException("Error occurred while opening a connection to the data source", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
OperationManagementDAOFactory.closeConnection();
|
|
|
|
} catch (OperationManagementDAOException e) {
|
|
|
|
|
|
|
|
log.warn("Error occurred while closing data source connection", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return operation;
|
|
|
|
return operation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|