|
|
@ -53,16 +53,32 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
|
|
|
|
|
|
|
|
|
|
|
List<TaskConfiguration.Operation> ops = taskConfiguration.getOperations();
|
|
|
|
List<TaskConfiguration.Operation> ops = taskConfiguration.getOperations();
|
|
|
|
List<TaskOperation> taskOperations = new ArrayList<>();
|
|
|
|
List<TaskOperation> taskOperations = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
for (TaskConfiguration.Operation op : ops) {
|
|
|
|
for (TaskConfiguration.Operation op : ops) {
|
|
|
|
TaskOperation taskOperation = new TaskOperation();
|
|
|
|
TaskOperation taskOperation = new TaskOperation();
|
|
|
|
taskOperation.setTaskName(op.getOperationName());
|
|
|
|
taskOperation.setTaskName(op.getOperationName());
|
|
|
|
taskOperation.setRecurrentTimes(op.getRecurrency());
|
|
|
|
taskOperation.setRecurrentTimes(op.getRecurrency());
|
|
|
|
|
|
|
|
taskOperation.setTaskPlatforms(op.getPlatforms());
|
|
|
|
taskOperations.add(taskOperation);
|
|
|
|
taskOperations.add(taskOperation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return taskOperations;
|
|
|
|
return taskOperations;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<String> getPlatformsForOperations(String opName) {
|
|
|
|
|
|
|
|
List<String> operationPlatforms = new ArrayList<>();
|
|
|
|
|
|
|
|
TaskConfiguration taskConfiguration =
|
|
|
|
|
|
|
|
DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getTaskConfiguration();
|
|
|
|
|
|
|
|
List<TaskConfiguration.Operation> ops = taskConfiguration.getOperations();
|
|
|
|
|
|
|
|
for (TaskConfiguration.Operation op : ops) {
|
|
|
|
|
|
|
|
if (op.getOperationName().equals(opName)) {
|
|
|
|
|
|
|
|
List<String> platform = op.getPlatforms();
|
|
|
|
|
|
|
|
for (String operationPlatform : platform) {
|
|
|
|
|
|
|
|
operationPlatforms.add(operationPlatform);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return operationPlatforms;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int getTaskFrequency() throws DeviceMgtTaskException {
|
|
|
|
public int getTaskFrequency() throws DeviceMgtTaskException {
|
|
|
|
return DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getTaskConfiguration().
|
|
|
|
return DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getTaskConfiguration().
|
|
|
@ -84,29 +100,32 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void addOperations() throws DeviceMgtTaskException {
|
|
|
|
public void addOperations() throws DeviceMgtTaskException {
|
|
|
|
|
|
|
|
List<String> deviceTypes;
|
|
|
|
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance().
|
|
|
|
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance().
|
|
|
|
getDeviceManagementProvider();
|
|
|
|
getDeviceManagementProvider();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
List<String> deviceTypes = deviceManagementProviderService.getAvailableDeviceTypes();
|
|
|
|
|
|
|
|
List<Device> devices;
|
|
|
|
List<Device> devices;
|
|
|
|
List<String> operations = this.getValidOperationNames();
|
|
|
|
List<String> operations = this.getValidOperationNames();
|
|
|
|
|
|
|
|
for (String taskOperation : operations) {
|
|
|
|
for (String deviceType : deviceTypes) {
|
|
|
|
deviceTypes = getPlatformsForOperations(taskOperation);
|
|
|
|
devices = deviceManagementProviderService.getAllDevices(deviceType);
|
|
|
|
for (String deviceType : deviceTypes) {
|
|
|
|
if (!devices.isEmpty()) {
|
|
|
|
devices = deviceManagementProviderService.getAllDevices(deviceType);
|
|
|
|
for (String str : operations) {
|
|
|
|
if (!devices.isEmpty()) {
|
|
|
|
CommandOperation operation = new CommandOperation();
|
|
|
|
for (String str : operations) {
|
|
|
|
operation.setEnabled(true);
|
|
|
|
CommandOperation operation = new CommandOperation();
|
|
|
|
operation.setType(Operation.Type.COMMAND);
|
|
|
|
operation.setEnabled(true);
|
|
|
|
operation.setCode(str);
|
|
|
|
operation.setType(Operation.Type.COMMAND);
|
|
|
|
deviceManagementProviderService.addOperation(deviceType, operation,
|
|
|
|
operation.setCode(str);
|
|
|
|
DeviceManagerUtil.getValidDeviceIdentifiers(devices));
|
|
|
|
deviceManagementProviderService.addOperation(deviceType, operation,
|
|
|
|
}
|
|
|
|
DeviceManagerUtil.getValidDeviceIdentifiers(devices));
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
} else {
|
|
|
|
log.debug("No devices are available to perform the operations.");
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
}
|
|
|
|
log.debug("No devices are available to perform the operations.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (InvalidDeviceException e) {
|
|
|
|
} catch (InvalidDeviceException e) {
|
|
|
|
throw new DeviceMgtTaskException("Invalid DeviceIdentifiers found.", e);
|
|
|
|
throw new DeviceMgtTaskException("Invalid DeviceIdentifiers found.", e);
|
|
|
@ -145,6 +164,8 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
|
|
|
return opNames;
|
|
|
|
return opNames;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean isTaskOperation(String opName) {
|
|
|
|
public boolean isTaskOperation(String opName) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|