Merge branch 'master' into 'master'

Handle StartupOperationConfig in task manager

Closes product-iots#99

See merge request entgra/carbon-device-mgt!116
revert-70aa11f8
Ruwan Yatawara 6 years ago
commit c7232bba86

@ -0,0 +1,33 @@
/*
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. 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.common;
import java.util.List;
public class StartupOperationConfig {
private List<String> startupOperations;
public List<String> getStartupOperations() {
return startupOperations;
}
public void setStartupOperations(List<String> startupOperations) {
this.startupOperations = startupOperations;
}
}

@ -15,6 +15,22 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
* *
*
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. 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.common.spi; package org.wso2.carbon.device.mgt.common.spi;
@ -49,6 +65,8 @@ public interface DeviceManagementService {
InitialOperationConfig getInitialOperationConfig(); InitialOperationConfig getInitialOperationConfig();
StartupOperationConfig getStartupOperationConfig();
PullNotificationSubscriber getPullNotificationSubscriber(); PullNotificationSubscriber getPullNotificationSubscriber();
DeviceStatusTaskPluginConfig getDeviceStatusTaskPluginConfig(); DeviceStatusTaskPluginConfig getDeviceStatusTaskPluginConfig();

@ -46,6 +46,7 @@ import org.wso2.carbon.device.mgt.common.MonitoringOperation;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.common.StartupOperationConfig;
import org.wso2.carbon.device.mgt.common.UserNotFoundException; import org.wso2.carbon.device.mgt.common.UserNotFoundException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
@ -654,10 +655,14 @@ public interface DeviceManagementProviderService {
List<MonitoringOperation> getMonitoringOperationList(String deviceType); List<MonitoringOperation> getMonitoringOperationList(String deviceType);
List<String> getStartupOperations(String deviceType);
int getDeviceMonitoringFrequency(String deviceType); int getDeviceMonitoringFrequency(String deviceType);
OperationMonitoringTaskConfig getDeviceMonitoringConfig(String deviceType); OperationMonitoringTaskConfig getDeviceMonitoringConfig(String deviceType);
StartupOperationConfig getStartupOperationConfig(String deviceType);
boolean isDeviceMonitoringEnabled(String deviceType); boolean isDeviceMonitoringEnabled(String deviceType);
PolicyMonitoringManager getPolicyMonitoringManager(String deviceType); PolicyMonitoringManager getPolicyMonitoringManager(String deviceType);

@ -65,6 +65,7 @@ import org.wso2.carbon.device.mgt.common.MonitoringOperation;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.common.StartupOperationConfig;
import org.wso2.carbon.device.mgt.common.TransactionManagementException; import org.wso2.carbon.device.mgt.common.TransactionManagementException;
import org.wso2.carbon.device.mgt.common.UserNotFoundException; import org.wso2.carbon.device.mgt.common.UserNotFoundException;
import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.app.mgt.Application;
@ -1733,6 +1734,19 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
return operationMonitoringTaskConfig.getMonitoringOperation(); return operationMonitoringTaskConfig.getMonitoringOperation();
} }
@Override
public List<String> getStartupOperations(String deviceType) {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
DeviceManagementService dms = pluginRepository.getDeviceManagementService(deviceType, tenantId);
StartupOperationConfig startupOperationConfig = dms.getStartupOperationConfig();
if (startupOperationConfig != null) {
return startupOperationConfig.getStartupOperations();
}
return null;
}
@Override @Override
public int getDeviceMonitoringFrequency(String deviceType) { public int getDeviceMonitoringFrequency(String deviceType) {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
@ -1748,6 +1762,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
return dms.getOperationMonitoringConfig(); return dms.getOperationMonitoringConfig();
} }
@Override
public StartupOperationConfig getStartupOperationConfig(String deviceType) {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
DeviceManagementService dms = pluginRepository.getDeviceManagementService(deviceType, tenantId);
return dms.getStartupOperationConfig();
}
@Override @Override
public boolean isDeviceMonitoringEnabled(String deviceType) { public boolean isDeviceMonitoringEnabled(String deviceType) {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();

@ -14,6 +14,23 @@
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*
*
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. 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.
*/ */
@ -21,7 +38,9 @@ package org.wso2.carbon.device.mgt.core.task;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
public class Utils { public class Utils {
@ -46,5 +65,25 @@ public class Utils {
} }
} }
public static boolean getIsTenantedStartupConfig(Map<Integer, List<String>> map, String deviceType) {
List<String> deviceTypes;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
if (map.containsKey(tenantId)) {
if (map.get(tenantId).contains(deviceType)) {
return false;
} else {
deviceTypes = map.get(tenantId);
deviceTypes.add(deviceType);
map.put(tenantId, deviceTypes);
return true;
}
} else {
deviceTypes = new ArrayList<>();
deviceTypes.add(deviceType);
map.put(tenantId, deviceTypes);
return true;
}
}
} }

@ -14,6 +14,23 @@
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*
*
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. 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.task.impl; package org.wso2.carbon.device.mgt.core.task.impl;
@ -23,6 +40,7 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.StartupOperationConfig;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException; import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException;
@ -56,17 +74,20 @@ public class DeviceDetailsRetrieverTask implements Task {
.getDeviceManagementProvider(); .getDeviceManagementProvider();
OperationMonitoringTaskConfig operationMonitoringTaskConfig = deviceManagementProviderService OperationMonitoringTaskConfig operationMonitoringTaskConfig = deviceManagementProviderService
.getDeviceMonitoringConfig(deviceType); .getDeviceMonitoringConfig(deviceType);
StartupOperationConfig startupOperationConfig = deviceManagementProviderService
.getStartupOperationConfig(deviceType);
if (System.getProperty(IS_CLOUD) != null && Boolean.parseBoolean(System.getProperty(IS_CLOUD))) { if (System.getProperty(IS_CLOUD) != null && Boolean.parseBoolean(System.getProperty(IS_CLOUD))) {
executeForTenants = true; executeForTenants = true;
} }
if (executeForTenants) { if (executeForTenants) {
this.executeForAllTenants(operationMonitoringTaskConfig); this.executeForAllTenants(operationMonitoringTaskConfig, startupOperationConfig);
} else { } else {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Device details retrieving task started to run."); log.debug("Device details retrieving task started to run.");
} }
DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(deviceType, operationMonitoringTaskConfig); DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(deviceType, operationMonitoringTaskConfig,
startupOperationConfig);
//pass the configurations also from here, monitoring tasks //pass the configurations also from here, monitoring tasks
try { try {
if (deviceManagementProviderService.isDeviceMonitoringEnabled(deviceType)) { if (deviceManagementProviderService.isDeviceMonitoringEnabled(deviceType)) {
@ -78,7 +99,8 @@ public class DeviceDetailsRetrieverTask implements Task {
} }
} }
private void executeForAllTenants(OperationMonitoringTaskConfig operationMonitoringTaskConfig) { private void executeForAllTenants(OperationMonitoringTaskConfig operationMonitoringTaskConfig,
StartupOperationConfig startupOperationConfig) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Device details retrieving task started to run for all tenants."); log.debug("Device details retrieving task started to run for all tenants.");
@ -98,7 +120,8 @@ public class DeviceDetailsRetrieverTask implements Task {
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenant); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenant);
DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(deviceType, DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(deviceType,
operationMonitoringTaskConfig); operationMonitoringTaskConfig,
startupOperationConfig);
//pass the configurations also from here, monitoring tasks //pass the configurations also from here, monitoring tasks
try { try {
if (deviceManagementProviderService.isDeviceMonitoringEnabled(deviceType)) { if (deviceManagementProviderService.isDeviceMonitoringEnabled(deviceType)) {

@ -14,6 +14,22 @@
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. 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.
*/ */
@ -21,16 +37,19 @@ package org.wso2.carbon.device.mgt.core.task.impl;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
import org.wso2.carbon.device.mgt.common.MonitoringOperation; import org.wso2.carbon.device.mgt.common.MonitoringOperation;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.StartupOperationConfig;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; 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.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; 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.operation.mgt.CommandOperation;
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException; 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.DeviceTaskManager;
@ -44,7 +63,17 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
private static Log log = LogFactory.getLog(DeviceTaskManagerImpl.class); private static Log log = LogFactory.getLog(DeviceTaskManagerImpl.class);
private String deviceType; private String deviceType;
static volatile Map<Integer, Map<String, Map<String, Long>>> map = new HashMap<>(); static volatile Map<Integer, Map<String, Map<String, Long>>> map = new HashMap<>();
private static volatile Map<Integer, List<String>> startupConfigMap = new HashMap<>();
private OperationMonitoringTaskConfig operationMonitoringTaskConfig; private OperationMonitoringTaskConfig operationMonitoringTaskConfig;
private StartupOperationConfig startupOperationConfig;
public DeviceTaskManagerImpl(String deviceType,
OperationMonitoringTaskConfig operationMonitoringTaskConfig,
StartupOperationConfig startupOperationConfig) {
this.deviceType = deviceType;
this.operationMonitoringTaskConfig = operationMonitoringTaskConfig;
this.startupOperationConfig = startupOperationConfig;
}
public DeviceTaskManagerImpl(String deviceType, public DeviceTaskManagerImpl(String deviceType,
OperationMonitoringTaskConfig operationMonitoringTaskConfig) { OperationMonitoringTaskConfig operationMonitoringTaskConfig) {
@ -61,6 +90,13 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
return operationMonitoringTaskConfig.getMonitoringOperation(); return operationMonitoringTaskConfig.getMonitoringOperation();
} }
private List<String> getStartupOperations() {
if (startupOperationConfig != null) {
return startupOperationConfig.getStartupOperations();
}
return null;
}
@Override @Override
public int getTaskFrequency() throws DeviceMgtTaskException { public int getTaskFrequency() throws DeviceMgtTaskException {
return operationMonitoringTaskConfig.getFrequency(); return operationMonitoringTaskConfig.getFrequency();
@ -86,6 +122,7 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
List<Device> devices; List<Device> devices;
List<String> operations; List<String> operations;
List<DeviceIdentifier> validDeviceIdentifiers; List<DeviceIdentifier> validDeviceIdentifiers;
List<String> startupOperations;
operations = this.getValidOperationNames(); //list operations for each device type operations = this.getValidOperationNames(); //list operations for each device type
devices = deviceManagementProviderService.getAllDevices(deviceType, false);//list devices for each type devices = deviceManagementProviderService.getAllDevices(deviceType, false);//list devices for each type
@ -106,6 +143,11 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
operation.setCode(str); operation.setCode(str);
deviceManagementProviderService.addOperation(deviceType, operation, validDeviceIdentifiers); deviceManagementProviderService.addOperation(deviceType, operation, validDeviceIdentifiers);
} }
startupOperations = getStartupOperations();
if (startupOperations != null && !startupOperations.isEmpty()) {
addStartupOperations(startupOperations, validDeviceIdentifiers,
deviceManagementProviderService);
}
} else { } else {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("No operations are available."); log.debug("No operations are available.");
@ -153,6 +195,32 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
return opNames; return opNames;
} }
private void addStartupOperations(List<String> startupOperations, List<DeviceIdentifier> validDeviceIdentifiers
, DeviceManagementProviderService deviceManagementProviderService) throws DeviceMgtTaskException {
boolean isStartupConfig = Utils.getIsTenantedStartupConfig(startupConfigMap, deviceType);
if (isStartupConfig) {
try {
Operation operation;
for (String startupOp : startupOperations) {
if ("SERVER_VERSION".equals(startupOp)) {
operation = new ProfileOperation();
operation.setPayLoad(ServerConfiguration.getInstance().getFirstProperty("Version"));
} else {
operation = new CommandOperation();
}
operation.setType(Operation.Type.COMMAND);
operation.setEnabled(true);
operation.setCode(startupOp);
deviceManagementProviderService.addOperation(deviceType, operation, validDeviceIdentifiers);
}
} catch (InvalidDeviceException e) {
throw new DeviceMgtTaskException("Invalid DeviceIdentifiers found.", e);
} catch (OperationManagementException e) {
throw new DeviceMgtTaskException("Error occurred while adding the operations to devices", e);
}
}
}
private List<MonitoringOperation> getOperationListforTask() throws DeviceMgtTaskException { private List<MonitoringOperation> getOperationListforTask() throws DeviceMgtTaskException {
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder
@ -163,17 +231,31 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
deviceType);//Get task list from each device type deviceType);//Get task list from each device type
} }
private List<String> getStartupOperationListForTask() {
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance()
.getDeviceManagementProvider();
return deviceManagementProviderService.getStartupOperations(deviceType);
}
@Override @Override
public boolean isTaskOperation(String opName) { public boolean isTaskOperation(String opName) {
try { try {
List<MonitoringOperation> monitoringOperations = this.getOperationListforTask(); List<MonitoringOperation> monitoringOperations = this.getOperationListforTask();
List<String> startupOperations = this.getStartupOperationListForTask();
for (MonitoringOperation taop : monitoringOperations) { for (MonitoringOperation taop : monitoringOperations) {
if (taop.getTaskName().equalsIgnoreCase(opName)) { if (taop.getTaskName().equalsIgnoreCase(opName)) {
return true; return true;
} }
} }
if (startupOperations != null && !startupOperations.isEmpty()) {
for (String operation : startupOperations) {
if (opName.equalsIgnoreCase(operation)) {
return true;
}
}
}
} catch (DeviceMgtTaskException e) { } catch (DeviceMgtTaskException e) {
// ignoring the error, no need to throw, If error occurs, return value will be false. // ignoring the error, no need to throw, If error occurs, return value will be false.
} }

@ -14,6 +14,22 @@
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. 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; package org.wso2.carbon.device.mgt.core;
@ -100,6 +116,11 @@ public class TestDeviceManagementService implements DeviceManagementService {
return null; return null;
} }
@Override
public StartupOperationConfig getStartupOperationConfig() {
return null;
}
@Override @Override
public PullNotificationSubscriber getPullNotificationSubscriber() { public PullNotificationSubscriber getPullNotificationSubscriber() {
return null; return null;

@ -15,6 +15,22 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
* *
*
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. 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.extensions.device.type.template; package org.wso2.carbon.device.mgt.extensions.device.type.template;
@ -27,6 +43,7 @@ import org.wso2.carbon.device.mgt.common.InitialOperationConfig;
import org.wso2.carbon.device.mgt.common.MonitoringOperation; import org.wso2.carbon.device.mgt.common.MonitoringOperation;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.ProvisioningConfig; import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.StartupOperationConfig;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; 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.ConfigurationEntry;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
@ -70,6 +87,7 @@ public class DeviceTypeManagerService implements DeviceManagementService {
private List<MonitoringOperation> monitoringOperations; private List<MonitoringOperation> monitoringOperations;
private PolicyMonitoringManager policyMonitoringManager; private PolicyMonitoringManager policyMonitoringManager;
private InitialOperationConfig initialOperationConfig; private InitialOperationConfig initialOperationConfig;
private StartupOperationConfig startupOperationConfig;
private PullNotificationSubscriber pullNotificationSubscriber; private PullNotificationSubscriber pullNotificationSubscriber;
private DeviceStatusTaskPluginConfig deviceStatusTaskPluginConfig; private DeviceStatusTaskPluginConfig deviceStatusTaskPluginConfig;
private GeneralConfig generalConfig; private GeneralConfig generalConfig;
@ -87,6 +105,8 @@ public class DeviceTypeManagerService implements DeviceManagementService {
this.setOperationMonitoringConfig(deviceTypeConfiguration); this.setOperationMonitoringConfig(deviceTypeConfiguration);
this.initialOperationConfig = new InitialOperationConfig(); this.initialOperationConfig = new InitialOperationConfig();
this.setInitialOperationConfig(deviceTypeConfiguration); this.setInitialOperationConfig(deviceTypeConfiguration);
this.startupOperationConfig = new StartupOperationConfig();
this.setStartupOperationConfig(deviceTypeConfiguration);
this.deviceStatusTaskPluginConfig = new DeviceStatusTaskPluginConfig(); this.deviceStatusTaskPluginConfig = new DeviceStatusTaskPluginConfig();
this.setDeviceStatusTaskPluginConfig(deviceTypeConfiguration.getDeviceStatusTaskConfiguration()); this.setDeviceStatusTaskPluginConfig(deviceTypeConfiguration.getDeviceStatusTaskConfiguration());
this.setPolicyMonitoringManager(deviceTypeConfiguration.getPolicyMonitoring()); this.setPolicyMonitoringManager(deviceTypeConfiguration.getPolicyMonitoring());
@ -210,6 +230,11 @@ public class DeviceTypeManagerService implements DeviceManagementService {
return initialOperationConfig; return initialOperationConfig;
} }
@Override
public StartupOperationConfig getStartupOperationConfig() {
return startupOperationConfig;
}
@Override @Override
public PullNotificationSubscriber getPullNotificationSubscriber() { public PullNotificationSubscriber getPullNotificationSubscriber() {
return pullNotificationSubscriber; return pullNotificationSubscriber;
@ -267,6 +292,15 @@ public class DeviceTypeManagerService implements DeviceManagementService {
} }
} }
private void setStartupOperationConfig(DeviceTypeConfiguration deviceTypeConfiguration) {
if (deviceTypeConfiguration.getOperations() != null) {
List<String> startupOperations = deviceTypeConfiguration.getStartupOperations();
if (startupOperations != null && !startupOperations.isEmpty()) {
startupOperationConfig.setStartupOperations(startupOperations);
}
}
}
private void setType(String type) { private void setType(String type) {
this.type = type; this.type = type;
} }

@ -15,6 +15,22 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
* *
*
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. 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.extensions.device.type.template.config; package org.wso2.carbon.device.mgt.extensions.device.type.template.config;
@ -86,6 +102,9 @@ public class DeviceTypeConfiguration {
@XmlElementWrapper(name = "InitialOperationConfig") @XmlElementWrapper(name = "InitialOperationConfig")
@XmlElement(name = "Operation", required = true) @XmlElement(name = "Operation", required = true)
protected List<String> operations; protected List<String> operations;
@XmlElementWrapper(name = "StartupOperationConfig")
@XmlElement(name = "Operation", required = true)
protected List<String> startupOperations;
public List<String> getOperations() { public List<String> getOperations() {
return operations; return operations;
@ -363,4 +382,24 @@ public class DeviceTypeConfiguration {
public void setDeviceAuthorizationConfig(DeviceAuthorizationConfig value) { public void setDeviceAuthorizationConfig(DeviceAuthorizationConfig value) {
this.deviceAuthorizationConfig = value; this.deviceAuthorizationConfig = value;
} }
/**
* Gets the value of startup operation config
*
* @return possible object is
* {@link List<String>}
*/
public List<String> getStartupOperations() {
return startupOperations;
}
/**
* Sets the value for startup operation config
*
* @param startupOperations possible object is
* {@link List<String>}
*/
public void setStartupOperations(List<String> startupOperations) {
this.startupOperations = startupOperations;
}
} }

@ -14,6 +14,23 @@
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*
*
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. 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.policy.mgt.core.mock; package org.wso2.carbon.policy.mgt.core.mock;
@ -24,6 +41,7 @@ import org.wso2.carbon.device.mgt.common.InitialOperationConfig;
import org.wso2.carbon.device.mgt.common.MonitoringOperation; import org.wso2.carbon.device.mgt.common.MonitoringOperation;
import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig; import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
import org.wso2.carbon.device.mgt.common.ProvisioningConfig; import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
import org.wso2.carbon.device.mgt.common.StartupOperationConfig;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.general.GeneralConfig; import org.wso2.carbon.device.mgt.common.general.GeneralConfig;
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
@ -88,6 +106,11 @@ public class TypeXDeviceManagementService implements DeviceManagementService {
return null; return null;
} }
@Override
public StartupOperationConfig getStartupOperationConfig() {
return null;
}
@Override @Override
public PullNotificationSubscriber getPullNotificationSubscriber() { public PullNotificationSubscriber getPullNotificationSubscriber() {
return null; return null;

Loading…
Cancel
Save