mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Cleaning up code.
This commit is contained in:
parent
7832956439
commit
09bbb35a24
@ -141,7 +141,7 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto =
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto =
|
||||||
OperationDAOUtil.convertOperation(operation);
|
OperationDAOUtil.convertOperation(operation);
|
||||||
int operationId = this.lookupOperationDAO(operation).addOperation(operationDto);
|
int operationId = this.lookupOperationDAO(operation).addOperation(operationDto);
|
||||||
boolean isScheduledOperation = this.isTaskScheduledOperation(operation, deviceIds);
|
boolean isScheduledOperation = this.isTaskScheduledOperation(operation);
|
||||||
boolean isNotRepeated = false;
|
boolean isNotRepeated = false;
|
||||||
boolean isScheduled = false;
|
boolean isScheduled = false;
|
||||||
|
|
||||||
@ -534,9 +534,8 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
try {
|
try {
|
||||||
int enrolmentId = enrolmentInfo.getId();
|
int enrolmentId = enrolmentInfo.getId();
|
||||||
OperationManagementDAOFactory.beginTransaction();
|
OperationManagementDAOFactory.beginTransaction();
|
||||||
boolean isUpdated = false;
|
|
||||||
if (operation.getStatus() != null) {
|
if (operation.getStatus() != null) {
|
||||||
isUpdated = operationDAO.updateOperationStatus(enrolmentId, operationId,
|
operationDAO.updateOperationStatus(enrolmentId, operationId,
|
||||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.
|
||||||
Operation.Status.valueOf(operation.getStatus().
|
Operation.Status.valueOf(operation.getStatus().
|
||||||
toString()));
|
toString()));
|
||||||
@ -810,25 +809,6 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private OperationDAO lookupOperationDAO(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operation) {
|
|
||||||
|
|
||||||
if (operation instanceof org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation ||
|
|
||||||
operation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND)) {
|
|
||||||
return commandOperationDAO;
|
|
||||||
} else if (operation instanceof org.wso2.carbon.device.mgt.core.dto.operation.mgt.ProfileOperation ||
|
|
||||||
operation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.PROFILE)) {
|
|
||||||
return profileOperationDAO;
|
|
||||||
} else if (operation instanceof org.wso2.carbon.device.mgt.core.dto.operation.mgt.ConfigOperation ||
|
|
||||||
operation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {
|
|
||||||
return configOperationDAO;
|
|
||||||
} else if (operation instanceof org.wso2.carbon.device.mgt.core.dto.operation.mgt.PolicyOperation ||
|
|
||||||
operation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.POLICY)) {
|
|
||||||
return policyOperationDAO;
|
|
||||||
} else {
|
|
||||||
return operationDAO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getUser() {
|
private String getUser() {
|
||||||
return CarbonContext.getThreadLocalCarbonContext().getUsername();
|
return CarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||||
}
|
}
|
||||||
@ -871,26 +851,6 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
return isUserAuthorized;
|
return isUserAuthorized;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getEnrolmentByStatus(DeviceIdentifier deviceId,
|
|
||||||
EnrolmentInfo.Status status) throws OperationManagementException {
|
|
||||||
int enrolmentId;
|
|
||||||
try {
|
|
||||||
DeviceManagementDAOFactory.openConnection();
|
|
||||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
||||||
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, status, tenantId);
|
|
||||||
} catch (DeviceManagementDAOException e) {
|
|
||||||
throw new OperationManagementException("Error occurred while retrieving metadata of '" +
|
|
||||||
deviceId.getType() + "' device carrying the identifier '" +
|
|
||||||
deviceId.getId() + "'", e);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new OperationManagementException(
|
|
||||||
"Error occurred while opening a connection to the data source", e);
|
|
||||||
} finally {
|
|
||||||
DeviceManagementDAOFactory.closeConnection();
|
|
||||||
}
|
|
||||||
return enrolmentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
private EnrolmentInfo getEnrolmentInfo(DeviceIdentifier deviceId, String owner) throws OperationManagementException {
|
private EnrolmentInfo getEnrolmentInfo(DeviceIdentifier deviceId, String owner) throws OperationManagementException {
|
||||||
EnrolmentInfo enrolmentInfo = null;
|
EnrolmentInfo enrolmentInfo = null;
|
||||||
try {
|
try {
|
||||||
@ -963,39 +923,15 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
return updateStatus;
|
return updateStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isTaskScheduledOperation(Operation operation, List<DeviceIdentifier> deviceIds) {
|
private boolean isTaskScheduledOperation(Operation operation) {
|
||||||
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance().
|
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance().
|
||||||
getDeviceManagementProvider();
|
getDeviceManagementProvider();
|
||||||
|
|
||||||
List<MonitoringOperation> monitoringOperations = deviceManagementProviderService.getMonitoringOperationList(deviceType);//Get task list from each device type
|
List<MonitoringOperation> monitoringOperations = deviceManagementProviderService.getMonitoringOperationList(deviceType);//Get task list from each device type
|
||||||
|
|
||||||
for (MonitoringOperation op : monitoringOperations) {
|
for (MonitoringOperation op : monitoringOperations) {
|
||||||
if (operation.getCode().equals(op.getTaskName())) {
|
if (operation.getCode().equals(op.getTaskName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for(String dti : taskOperation){
|
|
||||||
// if (dti.equals(deviceType)) {
|
|
||||||
// monitoringOperations = deviceTypeSpecificTasks.get(dti);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for(DeviceIdentifier deviceIdentifier : deviceIds){
|
|
||||||
// String deviceType = deviceIdentifier.getType();
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
// TaskConfiguration taskConfiguration = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().
|
|
||||||
// getTaskConfiguration();
|
|
||||||
// for (TaskConfiguration.Operation op : taskConfiguration.getOperations()) {
|
|
||||||
// if (operation.getCode().equals(op.getOperationName())) {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user