mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Handle StartupOperationConfig which runs only once after the server is started
This commit is contained in:
parent
c1177a26b2
commit
b68cc62bc7
@ -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
|
||||
* 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;
|
||||
|
||||
@ -49,6 +65,8 @@ public interface DeviceManagementService {
|
||||
|
||||
InitialOperationConfig getInitialOperationConfig();
|
||||
|
||||
StartupOperationConfig getStartupOperationConfig();
|
||||
|
||||
PullNotificationSubscriber getPullNotificationSubscriber();
|
||||
|
||||
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.PaginationRequest;
|
||||
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.configuration.mgt.ConfigurationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||
@ -654,10 +655,14 @@ public interface DeviceManagementProviderService {
|
||||
|
||||
List<MonitoringOperation> getMonitoringOperationList(String deviceType);
|
||||
|
||||
List<String> getStartupOperations(String deviceType);
|
||||
|
||||
int getDeviceMonitoringFrequency(String deviceType);
|
||||
|
||||
OperationMonitoringTaskConfig getDeviceMonitoringConfig(String deviceType);
|
||||
|
||||
StartupOperationConfig getStartupOperationConfig(String deviceType);
|
||||
|
||||
boolean isDeviceMonitoringEnabled(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.PaginationRequest;
|
||||
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.UserNotFoundException;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
||||
@ -1733,6 +1734,19 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
||||
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
|
||||
public int getDeviceMonitoringFrequency(String deviceType) {
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
@ -1748,6 +1762,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
||||
return dms.getOperationMonitoringConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartupOperationConfig getStartupOperationConfig(String deviceType) {
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
DeviceManagementService dms = pluginRepository.getDeviceManagementService(deviceType, tenantId);
|
||||
return dms.getStartupOperationConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeviceMonitoringEnabled(String deviceType) {
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
|
||||
@ -14,6 +14,23 @@
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* 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 java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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
|
||||
* specific language governing permissions and limitations
|
||||
* 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;
|
||||
@ -23,6 +40,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.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.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.device.mgt.core.task.DeviceMgtTaskException;
|
||||
@ -56,17 +74,20 @@ public class DeviceDetailsRetrieverTask implements Task {
|
||||
.getDeviceManagementProvider();
|
||||
OperationMonitoringTaskConfig operationMonitoringTaskConfig = deviceManagementProviderService
|
||||
.getDeviceMonitoringConfig(deviceType);
|
||||
StartupOperationConfig startupOperationConfig = deviceManagementProviderService
|
||||
.getStartupOperationConfig(deviceType);
|
||||
|
||||
if (System.getProperty(IS_CLOUD) != null && Boolean.parseBoolean(System.getProperty(IS_CLOUD))) {
|
||||
executeForTenants = true;
|
||||
}
|
||||
if (executeForTenants) {
|
||||
this.executeForAllTenants(operationMonitoringTaskConfig);
|
||||
this.executeForAllTenants(operationMonitoringTaskConfig, startupOperationConfig);
|
||||
} else {
|
||||
if (log.isDebugEnabled()) {
|
||||
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
|
||||
try {
|
||||
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()) {
|
||||
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().setTenantId(tenant);
|
||||
DeviceTaskManager deviceTaskManager = new DeviceTaskManagerImpl(deviceType,
|
||||
operationMonitoringTaskConfig);
|
||||
operationMonitoringTaskConfig,
|
||||
startupOperationConfig);
|
||||
//pass the configurations also from here, monitoring tasks
|
||||
try {
|
||||
if (deviceManagementProviderService.isDeviceMonitoringEnabled(deviceType)) {
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
*
|
||||
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* 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
|
||||
@ -44,6 +44,7 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
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.StartupOperationConfig;
|
||||
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.internal.DeviceManagementDataHolder;
|
||||
@ -62,7 +63,17 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
||||
private static Log log = LogFactory.getLog(DeviceTaskManagerImpl.class);
|
||||
private String deviceType;
|
||||
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 StartupOperationConfig startupOperationConfig;
|
||||
|
||||
public DeviceTaskManagerImpl(String deviceType,
|
||||
OperationMonitoringTaskConfig operationMonitoringTaskConfig,
|
||||
StartupOperationConfig startupOperationConfig) {
|
||||
this.deviceType = deviceType;
|
||||
this.operationMonitoringTaskConfig = operationMonitoringTaskConfig;
|
||||
this.startupOperationConfig = startupOperationConfig;
|
||||
}
|
||||
|
||||
public DeviceTaskManagerImpl(String deviceType,
|
||||
OperationMonitoringTaskConfig operationMonitoringTaskConfig) {
|
||||
@ -79,6 +90,13 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
||||
return operationMonitoringTaskConfig.getMonitoringOperation();
|
||||
}
|
||||
|
||||
private List<String> getStartupOperations() {
|
||||
if (startupOperationConfig != null) {
|
||||
return startupOperationConfig.getStartupOperations();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTaskFrequency() throws DeviceMgtTaskException {
|
||||
return operationMonitoringTaskConfig.getFrequency();
|
||||
@ -104,6 +122,7 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
||||
List<Device> devices;
|
||||
List<String> operations;
|
||||
List<DeviceIdentifier> validDeviceIdentifiers;
|
||||
List<String> startupOperations;
|
||||
operations = this.getValidOperationNames(); //list operations for each device type
|
||||
devices = deviceManagementProviderService.getAllDevices(deviceType, false);//list devices for each type
|
||||
|
||||
@ -118,18 +137,17 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
||||
.size());
|
||||
}
|
||||
for (String str : operations) {
|
||||
Operation operation;
|
||||
if ("SERVER_VERSION".equals(str)) {
|
||||
operation = new ProfileOperation();
|
||||
operation.setPayLoad(ServerConfiguration.getInstance().getFirstProperty("Version"));
|
||||
} else {
|
||||
operation = new CommandOperation();
|
||||
}
|
||||
operation.setType(Operation.Type.COMMAND);
|
||||
CommandOperation operation = new CommandOperation();
|
||||
operation.setEnabled(true);
|
||||
operation.setType(Operation.Type.COMMAND);
|
||||
operation.setCode(str);
|
||||
deviceManagementProviderService.addOperation(deviceType, operation, validDeviceIdentifiers);
|
||||
}
|
||||
startupOperations = getStartupOperations();
|
||||
if (startupOperations != null && !startupOperations.isEmpty()) {
|
||||
addStartupOperations(startupOperations, validDeviceIdentifiers,
|
||||
deviceManagementProviderService);
|
||||
}
|
||||
} else {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("No operations are available.");
|
||||
@ -177,6 +195,32 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
||||
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 {
|
||||
|
||||
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder
|
||||
@ -187,17 +231,31 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
||||
deviceType);//Get task list from each device type
|
||||
}
|
||||
|
||||
private List<String> getStartupOperationListForTask() {
|
||||
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementDataHolder.getInstance()
|
||||
.getDeviceManagementProvider();
|
||||
return deviceManagementProviderService.getStartupOperations(deviceType);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isTaskOperation(String opName) {
|
||||
|
||||
try {
|
||||
List<MonitoringOperation> monitoringOperations = this.getOperationListforTask();
|
||||
List<String> startupOperations = this.getStartupOperationListForTask();
|
||||
for (MonitoringOperation taop : monitoringOperations) {
|
||||
if (taop.getTaskName().equalsIgnoreCase(opName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (startupOperations != null && !startupOperations.isEmpty()) {
|
||||
for (String operation : startupOperations) {
|
||||
if (opName.equalsIgnoreCase(operation)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (DeviceMgtTaskException e) {
|
||||
// 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
|
||||
* specific language governing permissions and limitations
|
||||
* 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;
|
||||
|
||||
@ -100,6 +116,11 @@ public class TestDeviceManagementService implements DeviceManagementService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartupOperationConfig getStartupOperationConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PullNotificationSubscriber getPullNotificationSubscriber() {
|
||||
return null;
|
||||
|
||||
@ -15,6 +15,22 @@
|
||||
* specific language governing permissions and limitations
|
||||
* 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;
|
||||
|
||||
@ -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.OperationMonitoringTaskConfig;
|
||||
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.configuration.mgt.ConfigurationEntry;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||
@ -70,6 +87,7 @@ public class DeviceTypeManagerService implements DeviceManagementService {
|
||||
private List<MonitoringOperation> monitoringOperations;
|
||||
private PolicyMonitoringManager policyMonitoringManager;
|
||||
private InitialOperationConfig initialOperationConfig;
|
||||
private StartupOperationConfig startupOperationConfig;
|
||||
private PullNotificationSubscriber pullNotificationSubscriber;
|
||||
private DeviceStatusTaskPluginConfig deviceStatusTaskPluginConfig;
|
||||
private GeneralConfig generalConfig;
|
||||
@ -87,6 +105,8 @@ public class DeviceTypeManagerService implements DeviceManagementService {
|
||||
this.setOperationMonitoringConfig(deviceTypeConfiguration);
|
||||
this.initialOperationConfig = new InitialOperationConfig();
|
||||
this.setInitialOperationConfig(deviceTypeConfiguration);
|
||||
this.startupOperationConfig = new StartupOperationConfig();
|
||||
this.setStartupOperationConfig(deviceTypeConfiguration);
|
||||
this.deviceStatusTaskPluginConfig = new DeviceStatusTaskPluginConfig();
|
||||
this.setDeviceStatusTaskPluginConfig(deviceTypeConfiguration.getDeviceStatusTaskConfiguration());
|
||||
this.setPolicyMonitoringManager(deviceTypeConfiguration.getPolicyMonitoring());
|
||||
@ -210,6 +230,11 @@ public class DeviceTypeManagerService implements DeviceManagementService {
|
||||
return initialOperationConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartupOperationConfig getStartupOperationConfig() {
|
||||
return startupOperationConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PullNotificationSubscriber getPullNotificationSubscriber() {
|
||||
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) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@ -15,6 +15,22 @@
|
||||
* specific language governing permissions and limitations
|
||||
* 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;
|
||||
|
||||
@ -86,6 +102,9 @@ public class DeviceTypeConfiguration {
|
||||
@XmlElementWrapper(name = "InitialOperationConfig")
|
||||
@XmlElement(name = "Operation", required = true)
|
||||
protected List<String> operations;
|
||||
@XmlElementWrapper(name = "StartupOperationConfig")
|
||||
@XmlElement(name = "Operation", required = true)
|
||||
protected List<String> startupOperations;
|
||||
|
||||
public List<String> getOperations() {
|
||||
return operations;
|
||||
@ -363,4 +382,24 @@ public class DeviceTypeConfiguration {
|
||||
public void setDeviceAuthorizationConfig(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
|
||||
* specific language governing permissions and limitations
|
||||
* 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;
|
||||
|
||||
@ -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.OperationMonitoringTaskConfig;
|
||||
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.general.GeneralConfig;
|
||||
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
|
||||
@ -88,6 +106,11 @@ public class TypeXDeviceManagementService implements DeviceManagementService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartupOperationConfig getStartupOperationConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PullNotificationSubscriber getPullNotificationSubscriber() {
|
||||
return null;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user