diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManager.java index 111b7a3be2f..0843a05606b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManager.java @@ -17,6 +17,8 @@ */ package org.wso2.carbon.device.mgt.common; +import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; + import java.util.List; /** @@ -31,6 +33,20 @@ public interface DeviceManager { */ FeatureManager getFeatureManager(); + /** + * Method to save platform specific Configuration. + * + * @return Returns the status of the operation + */ + boolean saveConfiguration(TenantConfiguration configuration) throws DeviceManagementException; + + /** + * Method to get platform specific Configuration. + * + * @return Returns the platform specific tenant configurations + */ + TenantConfiguration getConfiguration() throws DeviceManagementException; + /** * Method to enrolling a particular device of type mobile, IoT, etc within CDM. * diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/configuration/mgt/ConfigurationEntry.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/configuration/mgt/ConfigurationEntry.java new file mode 100644 index 00000000000..cafc157452e --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/configuration/mgt/ConfigurationEntry.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2015, 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.common.configuration.mgt; + +/** + * Represents an individual configuration entry. + */ +public class ConfigurationEntry { + + private String name; + private String contentType; + private Object value; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getContentType() { + return contentType; + } + + public void setContentType(String contentType) { + this.contentType = contentType; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/configuration/mgt/TenantConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/configuration/mgt/TenantConfiguration.java new file mode 100644 index 00000000000..ee7a01536b4 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/configuration/mgt/TenantConfiguration.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2015, 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.common.configuration.mgt; + +import java.util.List; + +/** + * Represents the tenant configuration for a device platform. + */ +public class TenantConfiguration { + + private String type; + private List configuration; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public List getConfiguration() { + return configuration; + } + + public void setConfiguration(List configuration) { + this.configuration = configuration; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java index 941d51c4731..053de06aed1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceManagementService.java @@ -24,7 +24,7 @@ import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; /** * Composite interface that acts as the SPI exposing all device management as well as application management - * functionalities + * functionalities. */ public interface DeviceManagementService extends ApplicationManager { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/sender/EmailServiceProviderImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/sender/EmailServiceProviderImpl.java index c7e5d76d752..4d450c139a1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/sender/EmailServiceProviderImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/sender/EmailServiceProviderImpl.java @@ -97,6 +97,7 @@ public class EmailServiceProviderImpl implements EmailService { if (configContext != null) { serviceClient = new ServiceClient(configContext, null); } else { + serviceClient = new ServiceClient(); } Options options = new Options(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java index 345838a1e50..e480329905c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java @@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.core.service; import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.DeviceManager; import org.wso2.carbon.device.mgt.common.app.mgt.Application; +import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; import java.util.List; @@ -40,6 +41,16 @@ public interface DeviceManagementProviderService extends DeviceManager, LicenseM FeatureManager getFeatureManager(String type) throws DeviceManagementException; + /** + * Proxy method to get the tenant configuration of a given platform. + * + * @param type Device platform + * @return Tenant configuration settings of the particular tenant and platform. + * @throws DeviceManagementException If some unusual behaviour is observed while fetching the + * configuration. + */ + TenantConfiguration getConfiguration(String type) throws DeviceManagementException; + /** * Method to get the list of devices owned by an user. * diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index b5b65069d88..6314451cd76 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.device.mgt.common.*; +import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; @@ -89,6 +90,26 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return null; } + @Override + public boolean saveConfiguration(TenantConfiguration configuration) + throws DeviceManagementException { + DeviceManager dms = + this.getPluginRepository().getDeviceManagementService(configuration.getType()).getDeviceManager(); + return dms.saveConfiguration(configuration); + } + + @Override + public TenantConfiguration getConfiguration() throws DeviceManagementException { + return null; + } + + @Override + public TenantConfiguration getConfiguration(String type) throws DeviceManagementException { + DeviceManager dms = + this.getPluginRepository().getDeviceManagementService(type).getDeviceManager(); + return dms.getConfiguration(); + } + @Override public FeatureManager getFeatureManager(String type) { DeviceManager dms = diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java index b6840351fdd..f639f30076c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java @@ -16,8 +16,11 @@ package org.wso2.carbon.device.mgt.core; import org.wso2.carbon.device.mgt.common.*; +import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; +import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; import java.util.List; +import java.util.Map; public class TestDeviceManager implements DeviceManager { @@ -26,6 +29,16 @@ public class TestDeviceManager implements DeviceManager { return null; } + @Override + public boolean saveConfiguration(TenantConfiguration configuration) + throws DeviceManagementException { + return false; + } + + @Override public TenantConfiguration getConfiguration() throws DeviceManagementException { + return null; + } + @Override public boolean enrollDevice(Device device) throws DeviceManagementException { return true;