From 09bbb35a24272a145b0ba5fa0efd0b7d4e3a41c0 Mon Sep 17 00:00:00 2001 From: sinthuja Date: Thu, 28 Sep 2017 17:30:07 +0530 Subject: [PATCH] Cleaning up code. --- .../operation/mgt/OperationManagerImpl.java | 70 +------------------ 1 file changed, 3 insertions(+), 67 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java index fda94e3111..ccb69a1e0b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -141,7 +141,7 @@ public class OperationManagerImpl implements OperationManager { org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto = OperationDAOUtil.convertOperation(operation); int operationId = this.lookupOperationDAO(operation).addOperation(operationDto); - boolean isScheduledOperation = this.isTaskScheduledOperation(operation, deviceIds); + boolean isScheduledOperation = this.isTaskScheduledOperation(operation); boolean isNotRepeated = false; boolean isScheduled = false; @@ -534,9 +534,8 @@ public class OperationManagerImpl implements OperationManager { try { int enrolmentId = enrolmentInfo.getId(); OperationManagementDAOFactory.beginTransaction(); - boolean isUpdated = false; if (operation.getStatus() != null) { - isUpdated = operationDAO.updateOperationStatus(enrolmentId, operationId, + operationDAO.updateOperationStatus(enrolmentId, operationId, org.wso2.carbon.device.mgt.core.dto.operation.mgt. Operation.Status.valueOf(operation.getStatus(). 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() { return CarbonContext.getThreadLocalCarbonContext().getUsername(); } @@ -871,26 +851,6 @@ public class OperationManagerImpl implements OperationManager { 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 { EnrolmentInfo enrolmentInfo = null; try { @@ -963,39 +923,15 @@ public class OperationManagerImpl implements OperationManager { return updateStatus; } - private boolean isTaskScheduledOperation(Operation operation, List deviceIds) { + private boolean isTaskScheduledOperation(Operation operation) { DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance(). getDeviceManagementProvider(); - List monitoringOperations = deviceManagementProviderService.getMonitoringOperationList(deviceType);//Get task list from each device type - for (MonitoringOperation op : monitoringOperations) { if (operation.getCode().equals(op.getTaskName())) { 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; }