mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
fix the EMM-1702
This commit is contained in:
parent
8740eae61a
commit
05e95e2675
@ -79,6 +79,8 @@ public class TaskConfiguration {
|
|||||||
|
|
||||||
private String operationName;
|
private String operationName;
|
||||||
private int recurrency;
|
private int recurrency;
|
||||||
|
private List<String> platforms;
|
||||||
|
|
||||||
|
|
||||||
@XmlElement(name = "Name", required = true)
|
@XmlElement(name = "Name", required = true)
|
||||||
public String getOperationName() {
|
public String getOperationName() {
|
||||||
@ -97,5 +99,16 @@ public class TaskConfiguration {
|
|||||||
public void setRecurrency(int recurrency) {
|
public void setRecurrency(int recurrency) {
|
||||||
this.recurrency = recurrency;
|
this.recurrency = recurrency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlElementWrapper(name = "Platforms")
|
||||||
|
@XmlElement(name = "platform", required = true)
|
||||||
|
public List<String> getPlatforms() {
|
||||||
|
return platforms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlatforms(List<String> platforms) {
|
||||||
|
this.platforms = platforms;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,8 @@
|
|||||||
package org.wso2.carbon.device.mgt.core.task;
|
package org.wso2.carbon.device.mgt.core.task;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the bean for the operations added by the task.
|
* This is the bean for the operations added by the task.
|
||||||
*/
|
*/
|
||||||
@ -27,6 +29,15 @@ public class TaskOperation {
|
|||||||
|
|
||||||
private String taskName;
|
private String taskName;
|
||||||
private int recurrentTimes;
|
private int recurrentTimes;
|
||||||
|
private List<String> taskPlatforms;
|
||||||
|
|
||||||
|
public List<String> getTaskPlatforms() {
|
||||||
|
return taskPlatforms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskPlatforms(List<String> taskPlatforms) {
|
||||||
|
this.taskPlatforms = taskPlatforms;
|
||||||
|
}
|
||||||
|
|
||||||
public String getTaskName() {
|
public String getTaskName() {
|
||||||
return taskName;
|
return taskName;
|
||||||
@ -43,5 +54,6 @@ public class TaskOperation {
|
|||||||
public void setRecurrentTimes(int recurrentTimes) {
|
public void setRecurrentTimes(int recurrentTimes) {
|
||||||
this.recurrentTimes = recurrentTimes;
|
this.recurrentTimes = recurrentTimes;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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,13 +100,14 @@ 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) {
|
||||||
|
deviceTypes = getPlatformsForOperations(taskOperation);
|
||||||
for (String deviceType : deviceTypes) {
|
for (String deviceType : deviceTypes) {
|
||||||
devices = deviceManagementProviderService.getAllDevices(deviceType);
|
devices = deviceManagementProviderService.getAllDevices(deviceType);
|
||||||
if (!devices.isEmpty()) {
|
if (!devices.isEmpty()) {
|
||||||
@ -107,6 +124,8 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
|||||||
log.debug("No devices are available to perform the operations.");
|
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 {
|
||||||
|
|||||||
@ -51,14 +51,26 @@
|
|||||||
<Operation>
|
<Operation>
|
||||||
<Name>DEVICE_INFO</Name>
|
<Name>DEVICE_INFO</Name>
|
||||||
<RecurrentTimes>1</RecurrentTimes>
|
<RecurrentTimes>1</RecurrentTimes>
|
||||||
|
<Platforms>
|
||||||
|
<platform>android</platform>
|
||||||
|
<platform>ios</platform>
|
||||||
|
</Platforms>
|
||||||
</Operation>
|
</Operation>
|
||||||
<Operation>
|
<Operation>
|
||||||
<Name>APPLICATION_LIST</Name>
|
<Name>APPLICATION_LIST</Name>
|
||||||
<RecurrentTimes>5</RecurrentTimes>
|
<RecurrentTimes>5</RecurrentTimes>
|
||||||
|
<Platforms>
|
||||||
|
<platform>android</platform>
|
||||||
|
<platform>ios</platform>
|
||||||
|
</Platforms>
|
||||||
</Operation>
|
</Operation>
|
||||||
<Operation>
|
<Operation>
|
||||||
<Name>DEVICE_LOCATION</Name>
|
<Name>DEVICE_LOCATION</Name>
|
||||||
<RecurrentTimes>1</RecurrentTimes>
|
<RecurrentTimes>1</RecurrentTimes>
|
||||||
|
<Platforms>
|
||||||
|
<platform>android</platform>
|
||||||
|
<platform>ios</platform>
|
||||||
|
</Platforms>
|
||||||
</Operation>
|
</Operation>
|
||||||
</Operations>
|
</Operations>
|
||||||
</TaskConfiguration>
|
</TaskConfiguration>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user