adding separate tasks for each device type

revert-70aa11f8
madhawap 8 years ago
parent 78bef05e11
commit b889f6e384

@ -30,10 +30,8 @@ import java.util.List;
@XmlRootElement(name = "TaskConfiguration")
public class TaskConfiguration {
private boolean enabled;
private int frequency;
private String taskClazz;
private List<Operation> operations;
@XmlElement(name = "Enable", required = true)
@ -54,15 +52,6 @@ public class TaskConfiguration {
this.frequency = frequency;
}
@XmlElement(name = "TaskClass", required = true)
public String getTaskClazz() {
return taskClazz;
}
public void setTaskClazz(String taskClazz) {
this.taskClazz = taskClazz;
}
@XmlElementWrapper(name="Operations")
@XmlElement(name = "Operation", required = true)
public List<Operation> getOperations() {

@ -22,8 +22,9 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceManager;
import org.wso2.carbon.device.mgt.common.MonitoringOperation;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.TaskOperation;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
@ -51,7 +52,8 @@ public class DeviceTypeManagerService implements DeviceManagementService {
private PushNotificationConfig pushNotificationConfig;
private ProvisioningConfig provisioningConfig;
private String type;
private List<TaskOperation> taskOperations;
private OperationMonitoringTaskConfig operationMonitoringConfigs;
private List<MonitoringOperation> monitoringOperations;
public DeviceTypeManagerService(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier,
DeviceTypeConfiguration deviceTypeConfiguration) {
@ -59,7 +61,8 @@ public class DeviceTypeManagerService implements DeviceManagementService {
this.deviceManager = new DeviceTypeManager(deviceTypeConfigIdentifier, deviceTypeConfiguration);
this.setType(deviceTypeConfiguration.getName());
this.populatePushNotificationConfig(deviceTypeConfiguration.getPushNotificationProvider());
this.setTask(deviceTypeConfiguration);
this.operationMonitoringConfigs = new OperationMonitoringTaskConfig();
this.setOperationMonitoringConfig(deviceTypeConfiguration);
}
@Override
@ -68,24 +71,27 @@ public class DeviceTypeManagerService implements DeviceManagementService {
}
@Override
public List<TaskOperation> getTasksForPlatform(){
return taskOperations;
public OperationMonitoringTaskConfig getOperationMonitoringConfig(){
return operationMonitoringConfigs;
}
private void setTask(DeviceTypeConfiguration deviceTypeConfiguration) {
private void setOperationMonitoringConfig(DeviceTypeConfiguration deviceTypeConfiguration) {
//Read the config file and take the list of operations there in the config
TaskConfiguration taskConfiguration = deviceTypeConfiguration.getTaskConfiguration();
if (taskConfiguration != null) {
operationMonitoringConfigs.setEnabled(taskConfiguration.isEnabled());
operationMonitoringConfigs.setFrequency(taskConfiguration.getFrequency());
List<TaskConfiguration.Operation> ops = taskConfiguration.getOperations();
if (ops != null && !ops.isEmpty()) {
taskOperations = new ArrayList<>();
monitoringOperations = new ArrayList<>();
for (TaskConfiguration.Operation op : ops) {
TaskOperation taskOperation = new TaskOperation();
taskOperation.setTaskName(op.getOperationName());
taskOperation.setRecurrentTimes(op.getRecurrency());
taskOperations.add(taskOperation);
MonitoringOperation monitoringOperation = new MonitoringOperation();
monitoringOperation.setTaskName(op.getOperationName());
monitoringOperation.setRecurrentTimes(op.getRecurrency());
monitoringOperations.add(monitoringOperation);
}
}
operationMonitoringConfigs.setMonitoringOperation(monitoringOperations);
}
}

@ -102,6 +102,8 @@
</tableConfig>
</DataSource>
<TaskConfiguration>
<Enable>true</Enable>
<Frequency>600000</Frequency>
<Operations>
<Operation>
<Name>DEVICE_INFO</Name>

@ -21,7 +21,7 @@ package org.wso2.carbon.device.mgt.common;
/**
*
*/
public class TaskOperation {
public class MonitoringOperation {
private String taskName;
private int recurrentTimes;
@ -42,5 +42,6 @@ public class TaskOperation {
this.recurrentTimes = recurrentTimes;
}
}

@ -0,0 +1,40 @@
package org.wso2.carbon.device.mgt.common;
import java.util.List;
/**
*
*/
public class OperationMonitoringTaskConfig {
private boolean isEnabled;
private int frequency;
private List<MonitoringOperation> monitoringOperation;
public boolean isEnabled() {
return isEnabled;
}
public void setEnabled(boolean enabled) {
isEnabled = enabled;
}
public int getFrequency() {
return frequency;
}
public void setFrequency(int frequency) {
this.frequency = frequency;
}
public List<MonitoringOperation> getMonitoringOperation() {
return monitoringOperation;
}
public void setMonitoringOperation(List<MonitoringOperation> monitoringOperation) {
this.monitoringOperation = monitoringOperation;
}
}

@ -20,13 +20,11 @@ package org.wso2.carbon.device.mgt.common.spi;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceManager;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.TaskOperation;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
import java.util.List;
/**
* Composite interface that acts as the SPI exposing all device management as well as application management
* functionalities.
@ -37,7 +35,7 @@ public interface DeviceManagementService {
String getType();
List<TaskOperation> getTasksForPlatform();//getTasksConfiguraitons
OperationMonitoringTaskConfig getOperationMonitoringConfig();
DeviceManager getDeviceManager();

@ -22,6 +22,7 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceTypeIdentifier;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
@ -31,8 +32,11 @@ import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagerStartupListener;
import org.wso2.carbon.device.mgt.core.internal.DeviceMonitoringOperationDataHolder;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerRepository;
import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException;
import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import java.util.Collections;
@ -72,6 +76,7 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
provider.getDeviceManager()
.requireDeviceAuthorization());
registerPushNotificationStrategy(provider);
registerMonitoringTask(provider);
}
} catch (DeviceManagementException e) {
throw new DeviceManagementException("Error occurred while adding device management provider '" +
@ -87,7 +92,8 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
}
}
public void removeDeviceManagementProvider(DeviceManagementService provider) throws DeviceManagementException {
public void removeDeviceManagementProvider(DeviceManagementService provider)
throws DeviceManagementException {
String deviceTypeName = provider.getType().toLowerCase();
DeviceTypeIdentifier deviceTypeIdentifier;
ProvisioningConfig provisioningConfig = provider.getProvisioningConfig();
@ -99,7 +105,13 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
deviceTypeIdentifier = new DeviceTypeIdentifier(deviceTypeName, providerTenantId);
providers.remove(deviceTypeIdentifier);
}
OperationManager operationManager = operationManagerRepository.getOperationManager(deviceTypeIdentifier);
unregisterPushNotificationStrategy(deviceTypeIdentifier);
unregisterMonitoringTask(provider);
}
private void unregisterPushNotificationStrategy(DeviceTypeIdentifier deviceTypeIdentifier) {
OperationManager operationManager = operationManagerRepository.getOperationManager(
deviceTypeIdentifier);
if (operationManager != null) {
NotificationStrategy notificationStrategy = operationManager.getNotificationStrategy();
if (notificationStrategy != null) {
@ -155,16 +167,60 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
pushNoteConfig.getType() + "'.");
}
NotificationStrategy notificationStrategy = provider.getNotificationStrategy(pushNoteConfig);
operationManagerRepository.addOperationManager(deviceTypeIdentifier, new OperationManagerImpl(
notificationStrategy));
operationManagerRepository.addOperationManager(deviceTypeIdentifier,
new OperationManagerImpl(deviceTypeIdentifier.getDeviceType(), notificationStrategy));
} else {
operationManagerRepository.addOperationManager(deviceTypeIdentifier, new OperationManagerImpl());
operationManagerRepository.addOperationManager(deviceTypeIdentifier,
new OperationManagerImpl(deviceTypeIdentifier.getDeviceType()));
}
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
}
private void registerMonitoringTask(DeviceManagementService deviceManagementService)
throws DeviceManagementException {
try {
DeviceTaskManagerService deviceTaskManagerService = DeviceManagementDataHolder.getInstance()
.getDeviceTaskManagerService();
OperationMonitoringTaskConfig operationMonitoringTaskConfig = deviceManagementService
.getOperationMonitoringConfig();
if (operationMonitoringTaskConfig != null && operationMonitoringTaskConfig.isEnabled()) {
if (deviceTaskManagerService == null) {
DeviceMonitoringOperationDataHolder.getInstance().addOperationMonitoringConfigToMap(
deviceManagementService.getType(), operationMonitoringTaskConfig);
} else {
deviceTaskManagerService.startTask(deviceManagementService.getType(),
operationMonitoringTaskConfig);
// TODO: In here a race condition can arise. Need to handle it.
}
}
} catch (DeviceMgtTaskException e) {
throw new DeviceManagementException("Error occurred while adding task service for '" +
deviceManagementService.getType() + "'", e);
}
}
private void unregisterMonitoringTask(DeviceManagementService deviceManagementService)
throws DeviceManagementException {
try {
DeviceTaskManagerService deviceTaskManagerService = DeviceManagementDataHolder.getInstance()
.getDeviceTaskManagerService();
OperationMonitoringTaskConfig operationMonitoringTaskConfig = deviceManagementService
.getOperationMonitoringConfig();
if (operationMonitoringTaskConfig != null) {
deviceTaskManagerService.stopTask(deviceManagementService.getType(),
deviceManagementService.getOperationMonitoringConfig());
}
} catch (DeviceMgtTaskException e) {
throw new DeviceManagementException("Error occurred while removing task service for '" +
deviceManagementService.getType() + "'", e);
}
}
public OperationManager getOperationManager(String deviceType, int tenantId) {
//Priority need to be given to the tenant before public.
DeviceTypeIdentifier deviceTypeIdentifier = new DeviceTypeIdentifier(deviceType.toLowerCase(), tenantId);
@ -189,6 +245,7 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
DeviceManagerUtil.registerDeviceType(deviceTypeName, tenantId,
provisioningConfig.isSharedWithAllTenants());
registerPushNotificationStrategy(provider);
registerMonitoringTask(provider);
//TODO:
//This is a temporory fix.
//windows and IOS cannot resolve user info by extracting certs
@ -207,5 +264,4 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
this.isInited = true;
}
}
}

@ -19,6 +19,7 @@
package org.wso2.carbon.device.mgt.core.internal;
import org.wso2.carbon.apimgt.impl.APIManagerConfiguration;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
@ -28,6 +29,7 @@ import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig;
import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService;
import org.wso2.carbon.email.sender.core.service.EmailSenderService;
import org.wso2.carbon.ntask.core.service.TaskService;
import org.wso2.carbon.registry.core.service.RegistryService;
@ -36,6 +38,7 @@ import org.wso2.carbon.user.core.tenant.TenantManager;
import org.wso2.carbon.utils.ConfigurationContextService;
import java.util.HashMap;
import java.util.Map;
public class DeviceManagementDataHolder {
@ -56,6 +59,18 @@ public class DeviceManagementDataHolder {
private TaskService taskService;
private EmailSenderService emailSenderService;
private PushNotificationProviderRepository pushNotificationProviderRepository;
private DeviceTaskManagerService deviceTaskManagerService;
private Map<String, OperationMonitoringTaskConfig> map = new HashMap<>();
public void addToMap(OperationMonitoringTaskConfig taskConfig) {
this.map.put("aa", taskConfig);
}
public Map<String, OperationMonitoringTaskConfig> getMap(){
return this.map;
}
private APIManagerConfiguration apiManagerConfiguration;
@ -210,4 +225,11 @@ public class DeviceManagementDataHolder {
return pushNotificationProviderRepository;
}
public DeviceTaskManagerService getDeviceTaskManagerService() {
return deviceTaskManagerService;
}
public void setDeviceTaskManagerService(DeviceTaskManagerService deviceTaskManagerService) {
this.deviceTaskManagerService = deviceTaskManagerService;
}
}

@ -53,6 +53,7 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderServiceImpl;
import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService;
import org.wso2.carbon.device.mgt.core.util.DeviceManagementSchemaInitializer;
import org.wso2.carbon.email.sender.core.service.EmailSenderService;
import org.wso2.carbon.ndatasource.core.DataSourceService;
@ -402,4 +403,18 @@ public class DeviceManagementServiceComponent {
DeviceManagementDataHolder.getInstance().setEmailSenderService(null);
}
protected void setDeviceTaskManagerService(DeviceTaskManagerService emailSenderService) {
if (log.isDebugEnabled()) {
}
DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(emailSenderService);
}
protected void unsetDeviceTaskManagerService(DeviceTaskManagerService emailSenderService) {
if (log.isDebugEnabled()) {
}
DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(null);
}
}

@ -0,0 +1,48 @@
/*
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.internal;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
*
*/
public class DeviceMonitoringOperationDataHolder {
private static DeviceMonitoringOperationDataHolder thisInstance = new DeviceMonitoringOperationDataHolder();
private Map<String, OperationMonitoringTaskConfig> OperationConfigMap = Collections.synchronizedMap(
new HashMap<String, OperationMonitoringTaskConfig>());
public static DeviceMonitoringOperationDataHolder getInstance() {
return thisInstance;
}
public void addOperationMonitoringConfigToMap(String deviceType, OperationMonitoringTaskConfig OperationConfig) {
this.OperationConfigMap.put(deviceType, OperationConfig);
}
public Map<String, OperationMonitoringTaskConfig> getOperationMonitoringConfigFromMap(){
return this.OperationConfigMap;
}
}

@ -22,15 +22,19 @@ package org.wso2.carbon.device.mgt.core.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
import org.wso2.carbon.device.mgt.core.device.details.mgt.impl.DeviceInformationManagerImpl;
import org.wso2.carbon.device.mgt.core.search.mgt.SearchManagerService;
import org.wso2.carbon.device.mgt.core.search.mgt.impl.SearchManagerServiceImpl;
import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException;
import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService;
import org.wso2.carbon.device.mgt.core.task.impl.DeviceTaskManagerServiceImpl;
import org.wso2.carbon.ntask.core.service.TaskService;
import java.util.ArrayList;
import java.util.Map;
/**
* @scr.component name="org.wso2.carbon.device.task.manager" immediate="true"
* @scr.reference name="device.ntask.component"
@ -45,6 +49,8 @@ public class DeviceTaskManagerServiceComponent {
private static Log log = LogFactory.getLog(DeviceManagementServiceComponent.class);
@SuppressWarnings("unused")
protected void activate(ComponentContext componentContext) {
try {
@ -52,13 +58,14 @@ public class DeviceTaskManagerServiceComponent {
log.debug("Initializing device details retrieving task manager bundle.");
}
// This will start the device details retrieving task.
boolean taskEnable =
DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getTaskConfiguration().
isEnabled();
if (taskEnable) {
DeviceTaskManagerService taskManagerService = new DeviceTaskManagerServiceImpl();
taskManagerService.startTask();
}
// DeviceTaskManagerService deviceTaskManagerService = new DeviceTaskManagerServiceImpl();
// DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(
// deviceTaskManagerService);
// componentContext.getBundleContext().registerService(DeviceTaskManagerService.class,
// deviceTaskManagerService, null);
getDeviceOperationMonitoringConfig(componentContext);
componentContext.getBundleContext().registerService(DeviceInformationManager.class,
new DeviceInformationManagerImpl(), null);
@ -69,6 +76,26 @@ public class DeviceTaskManagerServiceComponent {
}
}
private void getDeviceOperationMonitoringConfig(ComponentContext componentContext) throws DeviceMgtTaskException {
DeviceTaskManagerService deviceTaskManagerService = new DeviceTaskManagerServiceImpl();
DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(
deviceTaskManagerService);
componentContext.getBundleContext().registerService(DeviceTaskManagerService.class,
deviceTaskManagerService, null);
Map<String, OperationMonitoringTaskConfig> deviceConfigMap = DeviceMonitoringOperationDataHolder
.getInstance().getOperationMonitoringConfigFromMap();
for (String platformType : new ArrayList<String>(deviceConfigMap.keySet())) {
deviceTaskManagerService.startTask(platformType, deviceConfigMap.get(platformType));
deviceConfigMap.remove(platformType);
}
}
@SuppressWarnings("unused")
protected void deactivate(ComponentContext componentContext) {
try {

@ -25,9 +25,9 @@ import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
import org.wso2.carbon.device.mgt.common.MonitoringOperation;
import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.common.TaskOperation;
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants;
@ -61,9 +61,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* This class implements all the functionality exposed as part of the OperationManager. Any transaction initiated
@ -83,6 +81,7 @@ public class OperationManagerImpl implements OperationManager {
private DeviceDAO deviceDAO;
private EnrollmentDAO enrollmentDAO;
private NotificationStrategy notificationStrategy;
private String deviceType;
public OperationManagerImpl() {
commandOperationDAO = OperationManagementDAOFactory.getCommandOperationDAO();
@ -95,6 +94,11 @@ public class OperationManagerImpl implements OperationManager {
enrollmentDAO = DeviceManagementDAOFactory.getEnrollmentDAO();
}
public OperationManagerImpl(String deviceType) {
this();
this.deviceType = deviceType;
}
public NotificationStrategy getNotificationStrategy() {
return notificationStrategy;
}
@ -103,8 +107,8 @@ public class OperationManagerImpl implements OperationManager {
this.notificationStrategy = notificationStrategy;
}
public OperationManagerImpl(NotificationStrategy notificationStrategy) {
this();
public OperationManagerImpl(String deviceType, NotificationStrategy notificationStrategy) {
this(deviceType);
this.notificationStrategy = notificationStrategy;
}
@ -243,7 +247,7 @@ public class OperationManagerImpl implements OperationManager {
List<String> unAuthorizedDeviceList = new ArrayList<>();
DeviceIDHolder deviceIDHolder = new DeviceIDHolder();
try {
if (operation != null && isAuthenticationSkippedOperation(operation, deviceIds)) {
if (operation != null && isAuthenticationSkippedOperation(operation)) {
authorizedDeviceList = deviceIds;
} else {
boolean isAuthorized;
@ -885,11 +889,11 @@ public class OperationManagerImpl implements OperationManager {
return CarbonContext.getThreadLocalCarbonContext().getUsername();
}
private boolean isAuthenticationSkippedOperation(Operation operation, List<DeviceIdentifier> deviceIds) {
private boolean isAuthenticationSkippedOperation(Operation operation) {
//This is to check weather operations are coming from the task related to retrieving device information.
DeviceTaskManager taskManager = new DeviceTaskManagerImpl();
if (taskManager.isTaskOperation(operation.getCode(), deviceIds)) {
DeviceTaskManager taskManager = new DeviceTaskManagerImpl(deviceType);
if (taskManager.isTaskOperation(operation.getCode())) {
return true;
}
@ -1034,28 +1038,30 @@ public class OperationManagerImpl implements OperationManager {
}
private boolean isTaskScheduledOperation(Operation operation, List<DeviceIdentifier> deviceIds) {
List<TaskOperation> taskOperations = new ArrayList<>();
Map<String, List<TaskOperation>> deviceTypeSpecificTasks = new HashMap<>();
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance().
getDeviceManagementProvider();
deviceTypeSpecificTasks = deviceManagementProviderService.getTaskList();//Get task list from each device type
List<MonitoringOperation> monitoringOperations = deviceManagementProviderService.getMonitoringOperationList(deviceType);//Get task list from each device type
for(DeviceIdentifier deviceIdentifier : deviceIds){
String deviceType = deviceIdentifier.getType();
for(String dti : deviceTypeSpecificTasks.keySet()){
if (dti.equals(deviceType)) {
taskOperations = deviceTypeSpecificTasks.get(dti);
for(TaskOperation op : taskOperations){
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();

@ -17,17 +17,24 @@
*/
package org.wso2.carbon.device.mgt.core.service;
import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.FeatureManager;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
import org.wso2.carbon.device.mgt.common.MonitoringOperation;
import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import java.util.HashMap;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Proxy class for all Device Management related operations that take the corresponding plugin type in
@ -282,6 +289,10 @@ public interface DeviceManagementProviderService {
int getActivityCountUpdatedAfter(long timestamp) throws OperationManagementException;
Map<String, List<TaskOperation>> getTaskList();
List<MonitoringOperation> getMonitoringOperationList(String deviceType);
int getDeviceMonitoringFrequency(String deviceType);
boolean isDeviceMonitoringEnabled(String deviceType);
}

@ -31,9 +31,10 @@ import org.wso2.carbon.device.mgt.common.DeviceTypeIdentifier;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.FeatureManager;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
import org.wso2.carbon.device.mgt.common.MonitoringOperation;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.common.TaskOperation;
import org.wso2.carbon.device.mgt.common.TransactionManagementException;
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
@ -1217,24 +1218,37 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
}
@Override
public Map<String, List<TaskOperation>> getTaskList() {
public List<MonitoringOperation> getMonitoringOperationList(String deviceType) {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
Map<DeviceTypeIdentifier, DeviceManagementService> deviceManagementServiceMap =
pluginRepository.getAllDeviceManagementServices(tenantId);
DeviceManagementService dms;
String deviceType;
List<TaskOperation> taskOperations;
Map<String, List<TaskOperation>> deviceTypeSpecificTasks = new HashMap<>();
for(DeviceTypeIdentifier dti : deviceManagementServiceMap.keySet()){
dms = deviceManagementServiceMap.get(dti);
taskOperations = dms.getTasksForPlatform();
if (taskOperations != null) {
deviceType = dms.getType();
deviceTypeSpecificTasks.put(deviceType, taskOperations);
// Map<DeviceTypeIdentifier, DeviceManagementService> deviceManagementServiceMap =
// pluginRepository.getAllDeviceManagementServices(tenantId);
DeviceManagementService dms = pluginRepository.getDeviceManagementService(deviceType, tenantId);
// ;
// OperationMonitoringTaskConfig operationMonitoringTaskConfig;
//Map<String, List<MonitoringOperation>> deviceTypeSpecificMonitoringOperations = new HashMap<>();
// for(DeviceTypeIdentifier dti : deviceManagementServiceMap.keySet()){
// dms = deviceManagementServiceMap.get(dti);
//
// }
OperationMonitoringTaskConfig operationMonitoringTaskConfig = dms.getOperationMonitoringConfig();
return operationMonitoringTaskConfig.getMonitoringOperation();
}
@Override
public int getDeviceMonitoringFrequency(String deviceType) {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
DeviceManagementService dms = pluginRepository.getDeviceManagementService(deviceType, tenantId);
OperationMonitoringTaskConfig operationMonitoringTaskConfig = dms.getOperationMonitoringConfig();
return operationMonitoringTaskConfig.getFrequency();
}
return deviceTypeSpecificTasks;
@Override
public boolean isDeviceMonitoringEnabled(String deviceType) {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
DeviceManagementService dms = pluginRepository.getDeviceManagementService(deviceType, tenantId);
OperationMonitoringTaskConfig operationMonitoringTaskConfig = dms.getOperationMonitoringConfig();
return operationMonitoringTaskConfig.isEnabled();
}
@Override

@ -19,20 +19,16 @@
package org.wso2.carbon.device.mgt.core.task;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import java.util.List;
public interface DeviceTaskManager {
/**
* This method will get the operation list from configurations.
*
* @return - list of Task Operations.
* @throws DeviceMgtTaskException
*/
List<org.wso2.carbon.device.mgt.common.TaskOperation> getOperationList(String deviceType)
throws DeviceMgtTaskException;
// /**
// * This method will get the operation list from configurations.
// *
// * @return - list of Task Operations.
// * @throws DeviceMgtTaskException
// */
// List<MonitoringOperation> getOperationList(String deviceType)
// throws DeviceMgtTaskException;
/**
* This method will take the monitoring frequency.
@ -41,12 +37,12 @@ public interface DeviceTaskManager {
*/
int getTaskFrequency() throws DeviceMgtTaskException;
/**
* This method will return the task clazz from configurations.
* @return - Fully qualified class name.
* @throws DeviceMgtTaskException
*/
String getTaskImplementedClazz() throws DeviceMgtTaskException;
// /**
// * This method will return the task clazz from configurations.
// * @return - Fully qualified class name.
// * @throws DeviceMgtTaskException
// */
// String getTaskImplementedClazz() throws DeviceMgtTaskException;
/**
* This method checks wheather task is enabled in config file.
@ -63,12 +59,12 @@ public interface DeviceTaskManager {
void addOperations() throws DeviceMgtTaskException;
/**
* This method will return the operation names which should be added in each iterations.
* @return
* @throws DeviceMgtTaskException
*/
List<String> getValidOperationNames(String deviceType) throws DeviceMgtTaskException;
// /**
// * This method will return the operation names which should be added in each iterations.
// * @return
// * @throws DeviceMgtTaskException
// */
// List<String> getValidOperationNames(String deviceType) throws DeviceMgtTaskException;
/**
* This method will check wheather give operation is added by the task.
@ -76,6 +72,6 @@ public interface DeviceTaskManager {
* @return - true or false
* @throws DeviceMgtTaskException
*/
boolean isTaskOperation(String opName, List<DeviceIdentifier> deviceIds);
boolean isTaskOperation(String opName);
}

@ -19,26 +19,33 @@
package org.wso2.carbon.device.mgt.core.task;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
public interface DeviceTaskManagerService {
/**
* This method will stop the task.
* This method will start the task.
* @param operationMonitoringTaskConfig - OperationMonitoringTaskConfig
* @throws DeviceMgtTaskException
*/
void startTask() throws DeviceMgtTaskException;
void startTask(String deviceType, OperationMonitoringTaskConfig operationMonitoringTaskConfig)
throws DeviceMgtTaskException;
/**
* This method will start the task.
* This method will stop the task.
* @param operationMonitoringTaskConfig - OperationMonitoringTaskConfig
* @throws DeviceMgtTaskException
*/
void stopTask() throws DeviceMgtTaskException;
void stopTask(String deviceType, OperationMonitoringTaskConfig operationMonitoringTaskConfig)
throws DeviceMgtTaskException;
/**
* This will update the task frequency which it runs.
* @param frequency - integer
* @param operationMonitoringTaskConfig - OperationMonitoringTaskConfig
* @throws DeviceMgtTaskException
*/
void updateTask(int frequency) throws DeviceMgtTaskException;
void updateTask(String deviceType, OperationMonitoringTaskConfig operationMonitoringTaskConfig)
throws DeviceMgtTaskException;
}

@ -31,15 +31,15 @@ public class DeviceDetailsRetrieverTask implements Task {
private static Log log = LogFactory.getLog(DeviceDetailsRetrieverTask.class);
// private DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl();
private String deviceType;
@Override
public void setProperties(Map<String, String> map) {
deviceType = map.get("DEVICE_TYPE");
}
@Override
public void init() {
}
@Override
@ -49,7 +49,7 @@ public class DeviceDetailsRetrieverTask implements Task {
log.debug("Device details retrieving task started to run.");
}
DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl();
DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(deviceType);
try {
deviceTaskManager.addOperations();

@ -22,13 +22,11 @@ package org.wso2.carbon.device.mgt.core.task.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
import org.wso2.carbon.device.mgt.common.TaskOperation;
import org.wso2.carbon.device.mgt.common.MonitoringOperation;
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.core.config.DeviceConfigurationManager;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
@ -42,65 +40,51 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class DeviceTaskManagerImpl implements DeviceTaskManager {
private static Log log = LogFactory.getLog(DeviceTaskManagerImpl.class);
private String deviceType;
private static Map<Integer, Map<String, Long>> map = new HashMap<>();
public DeviceTaskManagerImpl(String deviceType) {
this.deviceType = deviceType;
}
@Override
//get device type specific operations
public List<TaskOperation> getOperationList(String deviceType) throws DeviceMgtTaskException {
public List<MonitoringOperation> getOperationList() throws DeviceMgtTaskException {
List<TaskOperation> taskOperations = new ArrayList<>();
Map<String, List<TaskOperation>> deviceTypeSpecificTasks;
//This Map contains task list against device type
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance().
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder
.getInstance().
getDeviceManagementProvider();
deviceTypeSpecificTasks = deviceManagementProviderService.getTaskList();//Get task list from each device type
for(String dti : deviceTypeSpecificTasks.keySet()){
if (dti.equals(deviceType)) {
taskOperations = deviceTypeSpecificTasks.get(dti);
}
}
return taskOperations;
return deviceManagementProviderService.getMonitoringOperationList(
deviceType);//Get task list from each device type
}
private List<String> getDeviceTypes() {
List<String> operationPlatforms = new ArrayList<>();
Map<String, List<TaskOperation>> deviceTypeSpecificTasks;
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance().
@Override
public int getTaskFrequency() throws DeviceMgtTaskException {
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder
.getInstance().
getDeviceManagementProvider();
deviceTypeSpecificTasks = deviceManagementProviderService.getTaskList();
Set<String> platformTypes = deviceTypeSpecificTasks.keySet();
for(String platformType : platformTypes ){
operationPlatforms.add(platformType);
}
return operationPlatforms;
}
return deviceManagementProviderService.getDeviceMonitoringFrequency(deviceType);
@Override
public int getTaskFrequency() throws DeviceMgtTaskException {
return DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getTaskConfiguration().
getFrequency();
}
@Override
public String getTaskImplementedClazz() throws DeviceMgtTaskException {
return DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getTaskConfiguration().
getTaskClazz();
}
// @Override
// public String getTaskImplementedClazz() throws DeviceMgtTaskException {
// return DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getTaskConfiguration().
// getTaskClazz();
// }
@Override
public boolean isTaskEnabled() throws DeviceMgtTaskException {
return DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getTaskConfiguration().
isEnabled();
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder
.getInstance().
getDeviceManagementProvider();
return deviceManagementProviderService.isDeviceMonitoringEnabled(deviceType);
}
@ -111,10 +95,8 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
try {
List<Device> devices;
List<String> operations;
List<String> deviceTypes = this.getDeviceTypes();//list available device types
for(String deviceType : deviceTypes){
operations = this.getValidOperationNames(deviceType); //list operations for each device type
operations = this.getValidOperationNames(); //list operations for each device type
devices = deviceManagementProviderService.getAllDevices(deviceType);//list devices for each type
if (!devices.isEmpty()) {
for (String str : operations) {
@ -130,8 +112,6 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
log.debug("No devices are available to perform the operations.");
}
}
}
} catch (InvalidDeviceException e) {
throw new DeviceMgtTaskException("Invalid DeviceIdentifiers found.", e);
} catch (DeviceManagementException e) {
@ -141,16 +121,15 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
}
}
@Override
public List<String> getValidOperationNames(String deviceType) throws DeviceMgtTaskException {
private List<String> getValidOperationNames() throws DeviceMgtTaskException {
List<TaskOperation> taskOperations = this.getOperationList(deviceType);
List<MonitoringOperation> monitoringOperations = this.getOperationList();
List<String> opNames = new ArrayList<>();
Long milliseconds = System.currentTimeMillis();
int frequency = this.getTaskFrequency();
Map<String, Long> mp = Utils.getTenantedTaskOperationMap(map);
for (TaskOperation top : taskOperations) {
for (MonitoringOperation top : monitoringOperations) {
if (!mp.containsKey(top.getTaskName())) {
opNames.add(top.getTaskName());
mp.put(top.getTaskName(), milliseconds);
@ -173,13 +152,11 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
@Override
public boolean isTaskOperation(String opName, List<DeviceIdentifier> deviceIds) {
public boolean isTaskOperation(String opName) {
for(DeviceIdentifier deviceIdentifier : deviceIds){
String deviceType = deviceIdentifier.getType();
try {
List<TaskOperation> taskOperations = this.getOperationList(deviceType);
for (TaskOperation taop : taskOperations) {
List<MonitoringOperation> monitoringOperations = this.getOperationList();
for (MonitoringOperation taop : monitoringOperations) {
if (taop.getTaskName().equalsIgnoreCase(opName)) {
return true;
}
@ -187,7 +164,6 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
} catch (DeviceMgtTaskException e) {
// ignoring the error, no need to throw, If error occurs, return value will be false.
}
}
return false;

@ -22,9 +22,9 @@ package org.wso2.carbon.device.mgt.core.task.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException;
import org.wso2.carbon.device.mgt.core.task.DeviceTaskManager;
import org.wso2.carbon.device.mgt.core.task.DeviceTaskManagerService;
import org.wso2.carbon.ntask.common.TaskException;
import org.wso2.carbon.ntask.core.TaskInfo;
@ -36,23 +36,21 @@ import java.util.Map;
public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
public static final String TASK_TYPE = "DEVICE_DETAILS";
public static final String TASK_NAME = "DEVICE_DETAILS_TASK";
public static final String TASK_TYPE = "DEVICE_MONITORING";
public static final String TENANT_ID = "TENANT_ID";
private static String TASK_CLASS = "org.wso2.carbon.device.mgt.core.task.impl.DeviceDetailsRetrieverTask";
private DeviceTaskManager deviceTaskManager;
// private DeviceTaskManager deviceTaskManager;
private static Log log = LogFactory.getLog(DeviceTaskManagerServiceImpl.class);
@Override
public void startTask() throws DeviceMgtTaskException {
public void startTask(String deviceType, OperationMonitoringTaskConfig operationMonitoringTaskConfig) throws DeviceMgtTaskException {
deviceTaskManager = new DeviceTaskManagerImpl();
if (!deviceTaskManager.isTaskEnabled()) {
throw new DeviceMgtTaskException("Task cannot be started, Please enable the task in cdm-config.xml file.");
}
// String TASK_NAME = deviceType;
log.info("Task adding for " + deviceType);
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
@ -62,23 +60,27 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
if (log.isDebugEnabled()) {
log.debug("Device details retrieving task is started for the tenant id " + tenantId);
log.debug("Device details retrieving task is at frequency of : " + deviceTaskManager.getTaskFrequency());
// log.debug("Device details retrieving task is at frequency of : " + deviceTaskManager
// .getTaskFrequency());
log.debug("Device details retrieving task is at frequency of : " + operationMonitoringTaskConfig
.getFrequency());
}
TaskManager taskManager = taskService.getTaskManager(TASK_TYPE);
TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo();
triggerInfo.setIntervalMillis(deviceTaskManager.getTaskFrequency());
// triggerInfo.setIntervalMillis(deviceTaskManager.getTaskFrequency());
triggerInfo.setIntervalMillis(operationMonitoringTaskConfig.getFrequency());
triggerInfo.setRepeatCount(-1);
Map<String, String> properties = new HashMap<>();
properties.put(TENANT_ID, String.valueOf(tenantId));
properties.put("DEVICE_TYPE", deviceType);
if (!taskManager.isTaskScheduled(TASK_NAME)) {
if (!taskManager.isTaskScheduled(deviceType)) {
TaskInfo taskInfo = new TaskInfo(TASK_NAME, TASK_CLASS,
properties, triggerInfo);
TaskInfo taskInfo = new TaskInfo(deviceType, TASK_CLASS, properties, triggerInfo);
taskManager.registerTask(taskInfo);
taskManager.rescheduleTask(taskInfo.getName());
@ -94,13 +96,15 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
}
@Override
public void stopTask() throws DeviceMgtTaskException {
public void stopTask(String deviceType, OperationMonitoringTaskConfig operationMonitoringTaskConfig) throws DeviceMgtTaskException {
// String TASK_NAME = deviceType;
try {
TaskService taskService = DeviceManagementDataHolder.getInstance().getTaskService();
if (taskService.isServerInit()) {
TaskManager taskManager = taskService.getTaskManager(TASK_TYPE);
taskManager.deleteTask(TASK_NAME);
taskManager.deleteTask(deviceType);
}
} catch (TaskException e) {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
@ -110,29 +114,27 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
}
@Override
public void updateTask(int frequency) throws DeviceMgtTaskException {
public void updateTask(String deviceType, OperationMonitoringTaskConfig operationMonitoringTaskConfig) throws DeviceMgtTaskException {
if (!deviceTaskManager.isTaskEnabled()) {
throw new DeviceMgtTaskException("Task cannot be updated, Please enable the task in cdm-config.xml file.");
}
// String TASK_NAME = deviceType;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
deviceTaskManager = new DeviceTaskManagerImpl();
// deviceTaskManager = new DeviceTaskManagerImpl();
try {
TaskService taskService = DeviceManagementDataHolder.getInstance().getTaskService();
TaskManager taskManager = taskService.getTaskManager(TASK_TYPE);
if (taskManager.isTaskScheduled(TASK_NAME)) {
if (taskManager.isTaskScheduled(deviceType)) {
taskManager.deleteTask(TASK_NAME);
taskManager.deleteTask(deviceType);
TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo();
triggerInfo.setIntervalMillis(frequency);
triggerInfo.setIntervalMillis(operationMonitoringTaskConfig.getFrequency());
triggerInfo.setRepeatCount(-1);
Map<String, String> properties = new HashMap<>();
properties.put(TENANT_ID, String.valueOf(tenantId));
TaskInfo taskInfo = new TaskInfo(TASK_NAME, TASK_CLASS, properties,
TaskInfo taskInfo = new TaskInfo(deviceType, TASK_CLASS, properties,
triggerInfo);
taskManager.registerTask(taskInfo);

@ -19,14 +19,12 @@ package org.wso2.carbon.device.mgt.core;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceManager;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.TaskOperation;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import java.util.List;
public class TestDeviceManagementService implements DeviceManagementService {
private String providerType;
@ -42,7 +40,7 @@ public class TestDeviceManagementService implements DeviceManagementService {
}
@Override
public List<TaskOperation> getTasksForPlatform(){
public OperationMonitoringTaskConfig getOperationMonitoringConfig(){
return null;
}

@ -48,10 +48,10 @@
<Platform>windows</Platform>
</Platforms>
</PolicyConfiguration>
<TaskConfiguration>
<Enable>true</Enable>
<Frequency>600000</Frequency>
</TaskConfiguration>
<!--<TaskConfiguration>-->
<!--<Enable>true</Enable>-->
<!--<Frequency>600000</Frequency>-->
<!--</TaskConfiguration>-->
<!-- Default Page size configuration for paginated DM APIs-->
<PaginationConfiguration>
<DeviceListPageSize>20</DeviceListPageSize>

Loading…
Cancel
Save