diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/filter/ApiPermissionFilter.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/filter/ApiPermissionFilter.java index bc7dab7053..9c1dfac4bd 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/filter/ApiPermissionFilter.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/filter/ApiPermissionFilter.java @@ -119,7 +119,7 @@ public class ApiPermissionFilter implements Filter { .getThreadLocalCarbonContext().getTenantId()); return userRealm.getAuthorizationManager().isUserAuthorized(username, permission, action); } catch (UserStoreException e) { - String errorMsg = String.format("Unable to authorize the user : %s", username, e); + String errorMsg = String.format("Unable to authorize the user : %s", username); log.error(errorMsg, e); return false; } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java index 6d1bc7695b..c1719f2296 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java @@ -29,7 +29,10 @@ import org.wso2.carbon.apimgt.webapp.publisher.config.APIResource; import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration; import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig; import org.wso2.carbon.base.MultitenantConstants; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.util.Utils; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; import javax.servlet.ServletContext; import java.util.*; @@ -42,7 +45,6 @@ public class APIPublisherUtil { private static final String DEFAULT_API_VERSION = "1.0.0"; private static final String API_CONFIG_DEFAULT_VERSION = "1.0.0"; private static final String PARAM_MANAGED_API_ENDPOINT = "managed-api-endpoint"; - private static final String PARAM_MANAGED_API_OWNER = "managed-api-owner"; private static final String PARAM_MANAGED_API_TRANSPORTS = "managed-api-transports"; private static final String PARAM_MANAGED_API_POLICY = "managed-api-policy"; private static final String PARAM_MANAGED_API_IS_SECURED = "managed-api-isSecured"; @@ -75,7 +77,7 @@ public class APIPublisherUtil { api.setUrl(config.getEndpoint()); api.addAvailableTiers(provider.getTiers()); - api.setEndpointSecured(true); + api.setEndpointSecured(false); api.setStatus(APIStatus.CREATED); api.setTransports(config.getTransports()); api.setApiLevelPolicy(config.getPolicy()); @@ -193,7 +195,8 @@ public class APIPublisherUtil { * @param apiDef * @return */ - public static APIConfig buildApiConfig(ServletContext servletContext, APIResourceConfiguration apiDef) { + public static APIConfig buildApiConfig(ServletContext servletContext, APIResourceConfiguration apiDef) + throws UserStoreException { APIConfig apiConfig = new APIConfig(); String name = apiDef.getName(); @@ -233,7 +236,8 @@ public class APIPublisherUtil { apiConfig.setTags(tags); } - String tenantDomain = servletContext.getInitParameter(PARAM_PROVIDER_TENANT_DOMAIN); + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + servletContext.setAttribute(PARAM_PROVIDER_TENANT_DOMAIN, tenantDomain); tenantDomain = (tenantDomain != null && !tenantDomain.isEmpty()) ? tenantDomain : MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; apiConfig.setTenantDomain(tenantDomain); @@ -253,7 +257,11 @@ public class APIPublisherUtil { } apiConfig.setEndpoint(endpoint); - String owner = servletContext.getInitParameter(PARAM_MANAGED_API_OWNER); + String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration() + .getAdminUserName(); + if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { + owner = owner + "@" + tenantDomain; + } if (owner == null || owner.isEmpty()) { if (log.isDebugEnabled()) { log.debug("'managed-api-owner' attribute is not configured"); @@ -280,12 +288,15 @@ public class APIPublisherUtil { log.debug("'managed-api-transports' attribute is not configured. Therefore using the default, " + "which is 'https'"); } - transports = "https"; + transports = "https,http"; } apiConfig.setTransports(transports); String sharingValueParam = servletContext.getInitParameter(PARAM_SHARED_WITH_ALL_TENANTS); boolean isSharedWithAllTenants = Boolean.parseBoolean(sharingValueParam); + if (isSharedWithAllTenants && !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { + isSharedWithAllTenants = false; + } apiConfig.setSharedWithAllTenants(isSharedWithAllTenants); Set uriTemplates = new LinkedHashSet<>(); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java index 436580978c..f9a28ee41d 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/listener/APIPublisherLifecycleListener.java @@ -32,6 +32,8 @@ import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration; import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig; import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder; import org.wso2.carbon.apimgt.webapp.publisher.lifecycle.util.AnnotationProcessor; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.user.api.UserStoreException; import javax.servlet.ServletContext; import java.io.IOException; @@ -106,6 +108,9 @@ public class APIPublisherLifecycleListener implements LifecycleListener { log.error("Error encountered while discovering annotated classes", e); } catch (ClassNotFoundException e) { log.error("Error while scanning class for annotations", e); + } catch (UserStoreException e) { + log.error("Error while retrieving tenant admin user for the tenant domain" + + PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(), e); } } } diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/src/main/java/org/wso2/carbon/certificate/mgt/jaxrs/api/common/GsonMessageBodyHandler.java b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/src/main/java/org/wso2/carbon/certificate/mgt/jaxrs/api/common/GsonMessageBodyHandler.java index 9cd6c3190a..91b3283e68 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/src/main/java/org/wso2/carbon/certificate/mgt/jaxrs/api/common/GsonMessageBodyHandler.java +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/src/main/java/org/wso2/carbon/certificate/mgt/jaxrs/api/common/GsonMessageBodyHandler.java @@ -83,11 +83,7 @@ public class GsonMessageBodyHandler implements MessageBodyWriter, Messag OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8); try { - Type jsonType = null; - if (type.equals(type)) { - jsonType = type; - } - getGson().toJson(object, jsonType, writer); + getGson().toJson(object, type, writer); } finally { writer.close(); } diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/common/GsonMessageBodyHandler.java b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/common/GsonMessageBodyHandler.java index 6abb296c17..7ca13eb59f 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/common/GsonMessageBodyHandler.java +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/common/GsonMessageBodyHandler.java @@ -83,11 +83,7 @@ public class GsonMessageBodyHandler implements MessageBodyWriter, Messag OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8); try { - Type jsonType = null; - if (type.equals(type)) { - jsonType = type; - } - getGson().toJson(object, jsonType, writer); + getGson().toJson(object, type, writer); } finally { writer.close(); } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml index df0314173c..7a12b14cca 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml @@ -66,6 +66,10 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.mgt.extensions + + org.wso2.carbon + org.wso2.carbon.application.deployer + @@ -91,6 +95,7 @@ javax.naming, javax.sql, + javax.xml, javax.xml.bind, javax.xml.bind.annotation, javax.xml.parsers; version="${javax.xml.parsers.import.pkg.version}", @@ -108,9 +113,13 @@ org.wso2.carbon.registry.core, org.wso2.carbon.registry.core.*, org.wso2.carbon.utils.*, - javax.xml.namespace + javax.xml.namespace, + org.apache.commons.io, + org.wso2.carbon.application.deployer.*, + org.apache.axis2.engine DeviceTypeDeployer + diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/DeviceTypeCAppDeployer.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/DeviceTypeCAppDeployer.java new file mode 100644 index 0000000000..435e3cad3b --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/DeviceTypeCAppDeployer.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2016, 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.extensions.device.type.deployer; + +import org.apache.axis2.deployment.Deployer; +import org.apache.axis2.deployment.DeploymentException; +import org.apache.axis2.deployment.repository.util.DeploymentFileData; +import org.apache.axis2.engine.AxisConfiguration; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.application.deployer.AppDeployerConstants; +import org.wso2.carbon.application.deployer.AppDeployerUtils; +import org.wso2.carbon.application.deployer.CarbonApplication; +import org.wso2.carbon.application.deployer.config.Artifact; +import org.wso2.carbon.application.deployer.config.CappFile; +import org.wso2.carbon.application.deployer.handler.AppDeploymentHandler; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.util.DeviceTypePluginConstants; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * This is the device deployer that will read and deploy the device type files from + * "deployment/server/carbonapps" + * directory. + */ +public class DeviceTypeCAppDeployer implements AppDeploymentHandler { + + + private static Log log = LogFactory.getLog(DeviceTypeCAppDeployer.class); + private List deviceTypePlugins = new ArrayList(); + private List deviceTypeUIs = new ArrayList(); + + @Override + public void deployArtifacts(CarbonApplication carbonApplication, AxisConfiguration axisConfig) + throws DeploymentException { + List artifacts = + carbonApplication.getAppConfig().getApplicationArtifact().getDependencies(); + + for (Artifact.Dependency dep : artifacts) { + Artifact artifact = dep.getArtifact(); + if (!validateArtifact(artifact)) { + continue; + } + addArtifact(artifact); + } + + try { + deployTypeSpecifiedArtifacts(deviceTypeUIs, axisConfig, null, + DeviceTypePluginConstants.CDMF_UI_TYPE_DIR); + deployTypeSpecifiedArtifacts(deviceTypePlugins, axisConfig, + DeviceTypePluginConstants.CDMF_PLUGIN_TYPE_EXTENSION, + DeviceTypePluginConstants.CDMF_PLUGIN_TYPE_DIR); + + } catch (Exception e) { + throw new DeploymentException(e.getMessage(), e); + } finally { + deviceTypePlugins.clear(); + deviceTypeUIs.clear(); + } + + } + + private void deployTypeSpecifiedArtifacts(List artifacts, AxisConfiguration axisConfig, + String fileType, String directory) throws DeploymentException { + for (Artifact artifact : artifacts) { + Deployer deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, directory, fileType); + if (deployer != null) { + deploy(deployer, artifact); + } + } + } + + @Override + public void undeployArtifacts(CarbonApplication carbonApplication, AxisConfiguration axisConfig) + throws DeploymentException { + List artifacts = + carbonApplication.getAppConfig().getApplicationArtifact().getDependencies(); + + deviceTypePlugins.clear(); + deviceTypeUIs.clear(); + + for (Artifact.Dependency dep : artifacts) { + Artifact artifact = dep.getArtifact(); + if (!validateArtifact(artifact)) { + continue; + } + addArtifact(artifact); + } + + try { + undeployTypeSpecifiedArtifacts(deviceTypeUIs, axisConfig, null, + DeviceTypePluginConstants.CDMF_UI_TYPE_DIR); + undeployTypeSpecifiedArtifacts(deviceTypePlugins, axisConfig, + DeviceTypePluginConstants.CDMF_PLUGIN_TYPE_EXTENSION, + DeviceTypePluginConstants.CDMF_PLUGIN_TYPE_DIR); + } finally { + deviceTypePlugins.clear(); + deviceTypeUIs.clear(); + } + + } + + private void undeployTypeSpecifiedArtifacts(List artifacts, AxisConfiguration axisConfig, String fileType + , String directory) throws DeploymentException { + for (Artifact artifact : artifacts) { + Deployer deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, directory, fileType); + if (deployer != null && + AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED.equals(artifact.getDeploymentStatus())) { + undeploy(deployer, artifact); + } + } + } + + private boolean validateArtifact(Artifact artifact) { + if (artifact == null) { + return false; + } + List files = artifact.getFiles(); + if (files.size() != 1) { + log.error("Synapse artifact types must have a single file to " + + "be deployed. But " + files.size() + " files found."); + return false; + } + return true; + } + + private void addArtifact(Artifact artifact) { + if (DeviceTypePluginConstants.CDMF_PLUGIN_TYPE.equals(artifact.getType())) { + deviceTypePlugins.add(artifact); + } else if (DeviceTypePluginConstants.CDMF_UI_TYPE.equals(artifact.getType())) { + deviceTypeUIs.add(artifact); + } + } + + void deploy(Deployer deployer, Artifact artifact) throws DeploymentException { + String fileName = artifact.getFiles().get(0).getName(); + String artifactPath = artifact.getExtractedPath() + File.separator + fileName; + try { + deployer.deploy(new DeploymentFileData(new File(artifactPath))); + artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED); + } catch (Exception e) { + artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED); + log.error("Deployment is failed due to " + e.getMessage(), e); + throw new DeploymentException(e.getMessage(), e); + } + } + + private void undeploy(Deployer deployer, Artifact artifact) throws DeploymentException { + String fileName = artifact.getFiles().get(0).getName(); + String artifactPath = artifact.getExtractedPath() + File.separator + fileName; + try { + deployer.undeploy(new DeploymentFileData(new File(artifactPath), deployer).getAbsolutePath()); + artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_PENDING); + } catch (Exception e) { + artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED); + log.error("Undeployment is failed due to " + e.getMessage(), e); + throw new DeploymentException(e.getMessage(), e); + } + } +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/DeviceTypeDeployer.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/DeviceTypePluginDeployer.java similarity index 97% rename from components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/DeviceTypeDeployer.java rename to components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/DeviceTypePluginDeployer.java index ff74abb0a3..5dfa895f39 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/DeviceTypeDeployer.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/DeviceTypePluginDeployer.java @@ -44,12 +44,12 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** - * This is the device deployer that will read and deploy the device type files from "deployment/server/devicetypes" + * This is the device deployer that will read and deploy the device type plugin files from "deployment/server/devicetypes" * directory. */ -public class DeviceTypeDeployer extends AbstractDeployer { +public class DeviceTypePluginDeployer extends AbstractDeployer { - private static Log log = LogFactory.getLog(DeviceTypeDeployer.class); + private static Log log = LogFactory.getLog(DeviceTypePluginDeployer.class); private ConfigurationContext configurationContext; protected Map deviceTypeServiceRegistrations = new ConcurrentHashMap(); protected Map deviceTypeConfigurationDataMap = new ConcurrentHashMap(); diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/DeviceTypeUIDeployer.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/DeviceTypeUIDeployer.java new file mode 100644 index 0000000000..5ee352751e --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/DeviceTypeUIDeployer.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2016, 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.extensions.device.type.deployer; + +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.deployment.AbstractDeployer; +import org.apache.axis2.deployment.DeploymentException; +import org.apache.axis2.deployment.repository.util.DeploymentFileData; +import org.apache.commons.io.FileUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.utils.CarbonUtils; + +import java.io.File; +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * This is the device deployer that will read and deploy the device type ui files from + * "deployment/server/devicetypes-ui" + * directory. + */ +public class DeviceTypeUIDeployer extends AbstractDeployer { + + private static Log log = LogFactory.getLog(DeviceTypeUIDeployer.class); + protected Map deviceTypeDeployedUIMap = new ConcurrentHashMap(); + private static final String DEVICEMGT_JAGGERY_APP_PATH = CarbonUtils.getCarbonRepository() + File.separator + + "jaggeryapps" + File.separator + "devicemgt" + File.separator + "app" + File.separator + "units" + + File.separator; + + private static final String UNIT_PREFIX = "cdmf.unit.device.type"; + + @Override + public void init(ConfigurationContext configurationContext) { + } + + @Override + public void setDirectory(String s) { + + } + + @Override + public void setExtension(String s) { + + } + + @Override + public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException { + if (!deploymentFileData.getFile().isDirectory()) { + return; + } + String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true); + if (tenantDomain != null && !tenantDomain.isEmpty()) { + File jaggeryAppPath = new File( + DEVICEMGT_JAGGERY_APP_PATH + tenantDomain + "." + deploymentFileData.getName()); + try { + if (!jaggeryAppPath.exists()) { + FileUtils.forceMkdir(jaggeryAppPath); + FileUtils.copyDirectory(deploymentFileData.getFile(), jaggeryAppPath); + File[] listOfFiles = jaggeryAppPath.listFiles(); + + for (int i = 0; i < listOfFiles.length; i++) { + if (listOfFiles[i].isFile()) { + String content = FileUtils.readFileToString(listOfFiles[i]); + FileUtils.writeStringToFile(listOfFiles[i], content.replaceAll(UNIT_PREFIX + , tenantDomain + "." + UNIT_PREFIX)); + } + } + } else { + log.debug("units already exists " + deploymentFileData.getName()); + } + this.deviceTypeDeployedUIMap.put(deploymentFileData.getAbsolutePath(), + jaggeryAppPath.getAbsolutePath()); + } catch (IOException e) { + if (jaggeryAppPath.exists()) { + try { + FileUtils.deleteDirectory(jaggeryAppPath); + } catch (IOException e1) { + log.error("Failed to delete directory " + jaggeryAppPath.getAbsolutePath()); + } + } + log.error("Cannot deploy deviceType ui : " + deploymentFileData.getName(), e); + throw new DeploymentException( + "Device type ui file " + deploymentFileData.getName() + " is not deployed ", e); + } + + } else { + log.error("Cannot deploy deviceType ui: " + deploymentFileData.getName()); + } + + + } + + @Override + public void undeploy(String filePath) throws DeploymentException { + try { + String jaggeryUnitPath = this.deviceTypeDeployedUIMap.remove(filePath); + FileUtils.deleteDirectory(new File(jaggeryUnitPath)); + log.info("Device Type units un deployed successfully."); + } catch (IOException e) { + throw new DeploymentException("Failed to remove the units: " + filePath); + } + } + +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceTypeConfiguration.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceTypeConfiguration.java index 867e0a377d..2a43797e9d 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceTypeConfiguration.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/DeviceTypeConfiguration.java @@ -41,6 +41,7 @@ import javax.xml.bind.annotation.XmlRootElement; * <element name="PushNotificationProvider" type="{}PushNotificationProvider"/> * <element name="License" type="{}License"/> * <element name="DataSource" type="{}DataSource"/> + * <element name="PolicyMonitoring" type="{}PolicyMonitoring"/> * <element name="DeviceAuthorizationConfig" type="{}DeviceAuthorizationConfig"/> * </sequence> * <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" /> @@ -71,6 +72,8 @@ public class DeviceTypeConfiguration { protected DeviceAuthorizationConfig deviceAuthorizationConfig; @XmlAttribute(name = "name") protected String name; + @XmlElement(name = "PolicyMonitoring", required = true) + protected PolicyMonitoring policyMonitoring; /** * Gets the value of the taskConfiguration property. @@ -116,6 +119,26 @@ public class DeviceTypeConfiguration { this.deviceDetails = value; } + /** + * Gets the value of the policyMonitoring property. + * + * @return possible object is + * {@link DeviceDetails } + */ + public PolicyMonitoring getPolicyMonitoring() { + return policyMonitoring; + } + + /** + * Sets the value of the policyMonitoring property. + * + * @param value allowed object is + * {@link DeviceDetails } + */ + public void setDeviceDetails(PolicyMonitoring value) { + this.policyMonitoring = value; + } + /** * Gets the value of the features property. * diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/PolicyMonitoring.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/PolicyMonitoring.java new file mode 100644 index 0000000000..12947c161e --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/config/PolicyMonitoring.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2016, 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.extensions.device.type.deployer.config; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; + + +/** + *

Java class for PolicyMonitoring complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="PolicyMonitoring">
+ *   <simpleContent>
+ *     <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ *       <attribute name="enabled" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *     </extension>
+ *   </simpleContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "PolicyMonitoring", propOrder = { + "value" +}) +public class PolicyMonitoring { + + @XmlValue + protected String value; + @XmlAttribute(name = "enabled") + protected boolean enabled; + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Gets the value of the enabled property. + * + * @return + * possible object is + * {@link String } + * + */ + public boolean isEnabled() { + return enabled; + } + + /** + * Sets the value of the enabled property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setEnabled(boolean value) { + this.enabled = value; + } + +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/internal/DeviceTypeManagementServiceComponent.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/internal/DeviceTypeManagementServiceComponent.java index 9da156f3e0..05679c0a5c 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/internal/DeviceTypeManagementServiceComponent.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/internal/DeviceTypeManagementServiceComponent.java @@ -21,6 +21,8 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.internal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.application.deployer.handler.AppDeploymentHandler; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.DeviceTypeCAppDeployer; import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.utils.ConfigurationContextService; @@ -45,6 +47,7 @@ public class DeviceTypeManagementServiceComponent { if (log.isDebugEnabled()) { log.debug("Activating DeviceType Deployer Service Component"); } +// ctx.getBundleContext().registerService(AppDeploymentHandler.class.getName(), new DeviceTypeCAppDeployer(), null); DeviceTypeManagementDataHolder.getInstance().setBundleContext(ctx.getBundleContext()); } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java index 62d03ffeb5..c7720093a6 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/DeviceTypeManagerService.java @@ -28,12 +28,14 @@ import org.wso2.carbon.device.mgt.common.ProvisioningConfig; 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; +import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceTypeConfiguration; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Property; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.PushNotificationProvider; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.TaskConfiguration; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.policy.mgt.DefaultPolicyMonitoringManager; import java.util.ArrayList; import java.util.HashMap; @@ -54,6 +56,7 @@ public class DeviceTypeManagerService implements DeviceManagementService { private String type; private OperationMonitoringTaskConfig operationMonitoringConfigs; private List monitoringOperations; + private PolicyMonitoringManager policyMonitoringManager; public DeviceTypeManagerService(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier, DeviceTypeConfiguration deviceTypeConfiguration) { @@ -63,6 +66,10 @@ public class DeviceTypeManagerService implements DeviceManagementService { this.populatePushNotificationConfig(deviceTypeConfiguration.getPushNotificationProvider()); this.operationMonitoringConfigs = new OperationMonitoringTaskConfig(); this.setOperationMonitoringConfig(deviceTypeConfiguration); + if (deviceTypeConfiguration.getPolicyMonitoring() != null && deviceTypeConfiguration.getPolicyMonitoring() + .isEnabled()) { + this.policyMonitoringManager = new DefaultPolicyMonitoringManager(); + } } @Override @@ -145,6 +152,11 @@ public class DeviceTypeManagerService implements DeviceManagementService { return pushNotificationConfig; } + @Override + public PolicyMonitoringManager getPolicyMonitoringManager() { + return policyMonitoringManager; + } + private void setProvisioningConfig(String tenantDomain, DeviceTypeConfiguration deviceTypeConfiguration) { if (deviceTypeConfiguration.getProvisioningConfig() != null) { boolean sharedWithAllTenants = deviceTypeConfiguration.getProvisioningConfig().isSharedWithAllTenants(); diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/policy/mgt/DefaultPolicyMonitoringManager.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/policy/mgt/DefaultPolicyMonitoringManager.java new file mode 100644 index 0000000000..634482db4e --- /dev/null +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/template/policy/mgt/DefaultPolicyMonitoringManager.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2016, 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.extensions.device.type.deployer.template.policy.mgt; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.Feature; +import org.wso2.carbon.device.mgt.common.FeatureManager; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; +import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Operation; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * This implementation policy monitoring manager. + */ +public class DefaultPolicyMonitoringManager implements PolicyMonitoringManager { + + private static Log log = LogFactory.getLog(DefaultPolicyMonitoringManager.class); + @Override + public NonComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object response) + throws PolicyComplianceException { + if (log.isDebugEnabled()) { + log.debug("Checking policy compliance status of device '" + deviceIdentifier.getId() + "'"); + } + NonComplianceData nonComplianceData = new NonComplianceData(); + if (response == null || policy == null) { + return nonComplianceData; + } + + List complianceFeatures = (List) response; + List nonComplianceFeatures = new ArrayList<>(); + + for (ComplianceFeature complianceFeature : complianceFeatures) { + if (!complianceFeature.isCompliant()) { + nonComplianceFeatures.add(complianceFeature); + nonComplianceData.setStatus(false); + break; + } + } + nonComplianceData.setComplianceFeatures(nonComplianceFeatures); + + return nonComplianceData; + } +} diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/util/DeviceTypeConfigUtil.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/util/DeviceTypeConfigUtil.java index bdf3bd861e..495a72b48d 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/util/DeviceTypeConfigUtil.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/util/DeviceTypeConfigUtil.java @@ -21,8 +21,10 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.util; import org.w3c.dom.Document; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.exception.DeviceTypeConfigurationException; +import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; import java.io.File; /** @@ -34,8 +36,12 @@ public class DeviceTypeConfigUtil { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); try { + factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); DocumentBuilder docBuilder = factory.newDocumentBuilder(); return docBuilder.parse(file); + } catch (ParserConfigurationException e) { + e.printStackTrace(); + return null; } catch (Exception e) { throw new DeviceTypeConfigurationException("Error occurred while parsing file, while converting " + "to a org.w3c.dom.Document", e); diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/util/DeviceTypePluginConstants.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/util/DeviceTypePluginConstants.java index 6058f10fc2..290fe93b7b 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/util/DeviceTypePluginConstants.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/deployer/util/DeviceTypePluginConstants.java @@ -25,4 +25,11 @@ public class DeviceTypePluginConstants { public static final String MEDIA_TYPE_XML = "application/xml"; public static final String CHARSET_UTF8 = "UTF8"; public static final String LANGUAGE_CODE_ENGLISH_US = "en_US"; + + public static final String CDMF_UI_TYPE = "devicetype/ui"; + public static final String CDMF_UI_TYPE_DIR = "devicetypes-ui"; + + public static final String CDMF_PLUGIN_TYPE = "devicetype/plugin"; + public static final String CDMF_PLUGIN_TYPE_DIR = "devicetypes"; + public static final String CDMF_PLUGIN_TYPE_EXTENSION = "xml"; } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/resources/META-INF/component.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/resources/META-INF/component.xml index c1c5f52048..7cdcead989 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/resources/META-INF/component.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/main/resources/META-INF/component.xml @@ -17,7 +17,11 @@ devicetypes xml - org.wso2.carbon.device.mgt.extensions.device.type.deployer.DeviceTypeDeployer + org.wso2.carbon.device.mgt.extensions.device.type.deployer.DeviceTypePluginDeployer + + + + diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml index 31b54ec20a..26a911db1f 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/src/test/resources/sample.xml @@ -81,12 +81,33 @@ + + en_US 1.0.0 This is license text + + true + 600000 + + + DEVICE_INFO + 1 + + + APPLICATION_LIST + 5 + + + DEVICE_LOCATION + 1 + + + + jdbc/SampleDM_DB @@ -101,22 +122,5 @@ - - true - 600000 - - - DEVICE_INFO - 1 - - - APPLICATION_LIST - 5 - - - DEVICE_LOCATION - 1 - - - + \ No newline at end of file diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategy.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategy.java index 4229bc5337..1f707aafa5 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategy.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/mqtt/MQTTNotificationStrategy.java @@ -85,7 +85,7 @@ public class MQTTNotificationStrategy implements NotificationStrategy { } else { String topic = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true) + "/" + ctx.getDeviceId().getType() + "/" + ctx.getDeviceId().getId() + "/" + operation.getType() - + "/" + operation.getCode(); + .toString().toLowerCase() + "/" + operation.getCode(); dynamicProperties.put("topic", topic); if (operation.getPayLoad() == null) { operation.setPayLoad(""); diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 4d283f80b7..5844654123 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -143,7 +143,8 @@ org.wso2.carbon.event.output.adapter.core, org.wso2.carbon.event.output.adapter.core.exception, org.osgi.framework, - org.wso2.carbon.core + org.wso2.carbon.core, + org.wso2.carbon.device.mgt.common.* diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/XMPPNotificationStrategy.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/XMPPNotificationStrategy.java index 0e82bec7ce..0d7229a193 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/XMPPNotificationStrategy.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/XMPPNotificationStrategy.java @@ -39,8 +39,13 @@ public class XMPPNotificationStrategy implements NotificationStrategy { private static final String XMPP_CLIENT_JID = "xmpp.client.jid"; private static final String XMPP_CLIENT_SUBJECT = "xmpp.client.subject"; public static final String XMPP_CLIENT_MESSAGE_TYPE = "xmpp.client.messageType"; + private static final String DYNAMIC_PROPERTY_JID = "jid"; + private static final String DYNAMIC_PROPERTY_SUBJECT = "subject"; + private static final String DYNAMIC_PROPERTY_MSGTYPE = "messageType"; private String xmppAdapterName; private static final Log log = LogFactory.getLog(XMPPNotificationStrategy.class); + private String subDomain; + public XMPPNotificationStrategy(PushNotificationConfig config) { @@ -61,6 +66,7 @@ public class XMPPNotificationStrategy implements NotificationStrategy { xmppAdapterProperties.put(XMPPAdapterConstants.XMPP_ADAPTER_PROPERTY_JID, config.getProperty( XMPPAdapterConstants.XMPP_ADAPTER_PROPERTY_JID)); outputEventAdapterConfiguration.setStaticProperties(xmppAdapterProperties); + subDomain = config.getProperty(XMPPAdapterConstants.XMPP_ADAPTER_PROPERTY_SUBDOMAIN); try { XMPPDataHolder.getInstance().getOutputEventAdapterService().create(outputEventAdapterConfiguration); } catch (OutputEventAdapterException e) { @@ -77,9 +83,15 @@ public class XMPPNotificationStrategy implements NotificationStrategy { public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException { Map dynamicProperties = new HashMap<>(); Properties properties = ctx.getOperation().getProperties(); - dynamicProperties.put("jid", properties.getProperty(XMPP_CLIENT_JID)); - dynamicProperties.put("subject", properties.getProperty(XMPP_CLIENT_SUBJECT)); - dynamicProperties.put("messageType", properties.getProperty(XMPP_CLIENT_MESSAGE_TYPE)); + if (properties != null & properties.size() > 0) { + dynamicProperties.put(DYNAMIC_PROPERTY_JID, properties.getProperty(XMPP_CLIENT_JID)); + dynamicProperties.put(DYNAMIC_PROPERTY_SUBJECT, properties.getProperty(XMPP_CLIENT_SUBJECT)); + dynamicProperties.put(DYNAMIC_PROPERTY_MSGTYPE, properties.getProperty(XMPP_CLIENT_MESSAGE_TYPE)); + } else { + dynamicProperties.put(DYNAMIC_PROPERTY_JID, ctx.getDeviceId().getId() + subDomain); + dynamicProperties.put(DYNAMIC_PROPERTY_SUBJECT, ctx.getOperation().getType().toString()); + dynamicProperties.put(DYNAMIC_PROPERTY_MSGTYPE, XMPPAdapterConstants.CHAT_PROPERTY_KEY); + } XMPPDataHolder.getInstance().getOutputEventAdapterService().publish(xmppAdapterName, dynamicProperties, ctx.getOperation().getPayLoad()); } diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/internal/util/XMPPAdapterConstants.java b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/internal/util/XMPPAdapterConstants.java index db08e7ae8b..8c4cf7740b 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/internal/util/XMPPAdapterConstants.java +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/src/main/java/org/wso2/carbon/device/mgt/extensions/push/notification/provider/xmpp/internal/util/XMPPAdapterConstants.java @@ -30,6 +30,7 @@ public final class XMPPAdapterConstants { public static final String SUBJECT_PROPERTY_KEY = "subject"; public static final String MESSAGE_TYPE_PROPERTY_KEY = "messageType"; public static final String CHAT_PROPERTY_KEY = "chat"; + public static final String XMPP_ADAPTER_PROPERTY_SUBDOMAIN = "subDomain"; public static final String XMPP_ADAPTER_PROPERTY_HOST = "host"; public static final String XMPP_ADAPTER_PROPERTY_PORT = "port"; public static final String XMPP_ADAPTER_PROPERTY_USERNAME = "username"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceCompliance.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceCompliance.java index 6f74422514..270d01bf76 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceCompliance.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceCompliance.java @@ -19,20 +19,20 @@ package org.wso2.carbon.device.mgt.jaxrs.beans; import io.swagger.annotations.ApiModel; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; @ApiModel(value = "DeviceCompliance", description = "Device's policy compliance status") public class DeviceCompliance { private String deviceID; - private ComplianceData complianceData; + private NonComplianceData complianceData; private Long code; - public ComplianceData getComplianceData() { + public NonComplianceData getComplianceData() { return complianceData; } - public void setComplianceData(ComplianceData complianceData) { + public void setComplianceData(NonComplianceData complianceData) { this.complianceData = complianceData; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyList.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyList.java index 5087fc81b5..714bcd09c7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyList.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyList.java @@ -21,7 +21,7 @@ package org.wso2.carbon.device.mgt.jaxrs.beans; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import java.util.List; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyWrapper.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyWrapper.java index e7ef0c0e6e..1028a334be 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyWrapper.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyWrapper.java @@ -21,7 +21,7 @@ package org.wso2.carbon.device.mgt.jaxrs.beans; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.policy.mgt.common.DeviceGroupWrapper; +import org.wso2.carbon.device.mgt.common.policy.mgt.DeviceGroupWrapper; import javax.validation.constraints.Size; import java.util.List; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/common/GsonMessageBodyHandler.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/common/GsonMessageBodyHandler.java index f069edee75..a25fb84833 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/common/GsonMessageBodyHandler.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/common/GsonMessageBodyHandler.java @@ -83,11 +83,7 @@ public class GsonMessageBodyHandler implements MessageBodyWriter, Messag OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8); try { - Type jsonType = null; - if (type.equals(type)) { - jsonType = type; - } - getGson().toJson(object, jsonType, writer); + getGson().toJson(object, type, writer); } finally { writer.close(); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java index 650ae34f7b..5a196d8fd9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java @@ -38,8 +38,8 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.search.SearchContext; import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; -import org.wso2.carbon.policy.mgt.common.Policy; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; import javax.validation.constraints.Size; import javax.ws.rs.*; @@ -850,7 +850,7 @@ public interface DeviceManagementService { @ApiResponse( code = 200, message = "OK", - response = ComplianceData.class), + response = NonComplianceData.class), @ApiResponse( code = 400, message = "Bad Request. \n Invalid request or validation error.", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java index c4c3d60294..1097e2e1ef 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java @@ -35,7 +35,7 @@ import org.wso2.carbon.apimgt.annotations.api.Permission; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.PriorityUpdatedPolicyWrapper; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import javax.validation.Valid; import javax.ws.rs.*; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java index 846fbbb69b..013a04c350 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -40,10 +40,10 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.OperationList; import org.wso2.carbon.device.mgt.jaxrs.service.api.DeviceManagementService; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; @@ -442,7 +442,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { RequestValidationUtil.validateDeviceIdentifier(type, id); PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService(); Policy policy; - ComplianceData complianceData = null; + NonComplianceData complianceData = null; DeviceCompliance deviceCompliance = new DeviceCompliance(); try { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java index 73ed8523a2..76718d6381 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java @@ -36,7 +36,7 @@ import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.FilteringUtil; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtUtil; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.policy.mgt.common.PolicyAdministratorPoint; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; @@ -168,7 +168,7 @@ public class PolicyManagementServiceImpl implements PolicyManagementService { @Override public Response getPolicy(@PathParam("id") int id, @HeaderParam("If-Modified-Since") String ifModifiedSince) { PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService(); - final org.wso2.carbon.policy.mgt.common.Policy policy; + final Policy policy; try { PolicyAdministratorPoint policyAdministratorPoint = policyManagementService.getPAP(); policy = policyAdministratorPoint.getPolicy(id); @@ -378,7 +378,7 @@ public class PolicyManagementServiceImpl implements PolicyManagementService { @Override public Response getEffectivePolicy(@PathParam("deviceId") String deviceId, @PathParam("deviceType") String deviceType) { PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService(); - final org.wso2.carbon.policy.mgt.common.Policy policy; + final Policy policy; try { DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); deviceIdentifier.setId(deviceId); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtUtil.java index 403f836990..0ffb728f0c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtUtil.java @@ -23,7 +23,7 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorListItem; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.ProfileFeature; import org.wso2.carbon.device.mgt.jaxrs.exception.BadRequestException; -import org.wso2.carbon.policy.mgt.common.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; import javax.validation.ConstraintViolation; import java.util.ArrayList; @@ -38,9 +38,8 @@ public class DeviceMgtUtil { profile.setCreatedDate(mdmProfile.getCreatedDate()); profile.setDeviceType(mdmProfile.getDeviceType()); - List profileFeatures = - new ArrayList(mdmProfile.getProfileFeaturesList().size()); + List profileFeatures = + new ArrayList(mdmProfile.getProfileFeaturesList().size()); for (ProfileFeature mdmProfileFeature : mdmProfile.getProfileFeaturesList()) { profileFeatures.add(convertProfileFeature(mdmProfileFeature)); } @@ -51,11 +50,11 @@ public class DeviceMgtUtil { return profile; } - public static org.wso2.carbon.policy.mgt.common.ProfileFeature convertProfileFeature(ProfileFeature + public static org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature convertProfileFeature(ProfileFeature mdmProfileFeature) { - org.wso2.carbon.policy.mgt.common.ProfileFeature profileFeature = - new org.wso2.carbon.policy.mgt.common.ProfileFeature(); + org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature profileFeature = + new org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature(); profileFeature.setProfileId(mdmProfileFeature.getProfileId()); profileFeature.setContent(mdmProfileFeature.getPayLoad()); profileFeature.setDeviceType(mdmProfileFeature.getDeviceTypeId()); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/device/details/DeviceInfo.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/device/details/DeviceInfo.java index 343add988e..b7f5a5b14c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/device/details/DeviceInfo.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/device/details/DeviceInfo.java @@ -370,7 +370,7 @@ public class DeviceInfo implements Serializable { } public Date getUpdatedTime() { - if(updatedTime.equals(null)){ + if(updatedTime == null){ updatedTime = new Date(); } return updatedTime; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/device/details/DeviceLocation.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/device/details/DeviceLocation.java index 5223b0f047..f1107091b0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/device/details/DeviceLocation.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/device/details/DeviceLocation.java @@ -137,7 +137,7 @@ public class DeviceLocation implements Serializable { } public Date getUpdatedTime() { - if(updatedTime.equals(null)){ + if(updatedTime == null ){ updatedTime = new Date(); } return updatedTime; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/DeviceGroupWrapper.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/DeviceGroupWrapper.java similarity index 97% rename from components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/DeviceGroupWrapper.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/DeviceGroupWrapper.java index dc30981603..a29fbc8575 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/DeviceGroupWrapper.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/DeviceGroupWrapper.java @@ -17,7 +17,7 @@ */ -package org.wso2.carbon.policy.mgt.common; +package org.wso2.carbon.device.mgt.common.policy.mgt; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/Policy.java similarity index 99% rename from components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/Policy.java index d62fbbc0c1..54d21f1f81 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Policy.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/Policy.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.policy.mgt.common; +package org.wso2.carbon.device.mgt.common.policy.mgt; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyCriterion.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/PolicyCriterion.java similarity index 96% rename from components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyCriterion.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/PolicyCriterion.java index c1a8481414..d76c0d6d80 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyCriterion.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/PolicyCriterion.java @@ -17,7 +17,7 @@ */ -package org.wso2.carbon.policy.mgt.common; +package org.wso2.carbon.device.mgt.common.policy.mgt; import java.util.Map; import java.util.Properties; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/spi/PolicyMonitoringService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/PolicyMonitoringManager.java similarity index 55% rename from components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/spi/PolicyMonitoringService.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/PolicyMonitoringManager.java index 5494c0a942..9b65c94933 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/spi/PolicyMonitoringService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/PolicyMonitoringManager.java @@ -17,23 +17,15 @@ */ -package org.wso2.carbon.policy.mgt.common.spi; +package org.wso2.carbon.device.mgt.common.policy.mgt; -import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; -import java.util.List; -public interface PolicyMonitoringService { +public interface PolicyMonitoringManager { - void notifyDevices(List devices) throws PolicyComplianceException; - - ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object response) + NonComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object response) throws PolicyComplianceException; - - String getType(); } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Profile.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/Profile.java similarity index 97% rename from components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Profile.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/Profile.java index ddc1411330..8f81eb002b 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Profile.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/Profile.java @@ -16,11 +16,10 @@ * under the License. */ -package org.wso2.carbon.policy.mgt.common; +package org.wso2.carbon.device.mgt.common.policy.mgt; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.device.mgt.core.dto.DeviceType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/ProfileFeature.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/ProfileFeature.java similarity index 98% rename from components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/ProfileFeature.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/ProfileFeature.java index e5e353adc2..638814b63d 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/ProfileFeature.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/ProfileFeature.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.policy.mgt.common; +package org.wso2.carbon.device.mgt.common.policy.mgt; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/ComplianceFeature.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/monitor/ComplianceFeature.java similarity index 91% rename from components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/ComplianceFeature.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/monitor/ComplianceFeature.java index ddc238c1ff..451172ff50 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/ComplianceFeature.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/monitor/ComplianceFeature.java @@ -17,9 +17,9 @@ */ -package org.wso2.carbon.policy.mgt.common.monitor; +package org.wso2.carbon.device.mgt.common.policy.mgt.monitor; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; public class ComplianceFeature { diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/ComplianceData.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/monitor/NonComplianceData.java similarity index 95% rename from components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/ComplianceData.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/monitor/NonComplianceData.java index cb41b1ed9d..ffbe36cb8d 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/ComplianceData.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/monitor/NonComplianceData.java @@ -17,14 +17,14 @@ */ -package org.wso2.carbon.policy.mgt.common.monitor; +package org.wso2.carbon.device.mgt.common.policy.mgt.monitor; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import java.sql.Timestamp; import java.util.List; -public class ComplianceData { +public class NonComplianceData { private int id; private int deviceId; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/PolicyComplianceException.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/monitor/PolicyComplianceException.java similarity index 96% rename from components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/PolicyComplianceException.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/monitor/PolicyComplianceException.java index 8d846eb49c..b95df9abc1 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/PolicyComplianceException.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/policy/mgt/monitor/PolicyComplianceException.java @@ -17,7 +17,7 @@ */ -package org.wso2.carbon.policy.mgt.common.monitor; +package org.wso2.carbon.device.mgt.common.policy.mgt.monitor; public class PolicyComplianceException extends Exception { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/push/notification/NotificationContext.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/push/notification/NotificationContext.java index 546e4fcf29..617525c579 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/push/notification/NotificationContext.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/push/notification/NotificationContext.java @@ -48,6 +48,10 @@ public class NotificationContext { return properties; } + public void setProperties(Map propertiesMap) { + properties = propertiesMap; + } + public Operation getOperation() { return operation; } 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 5870436678..197275600e 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 @@ -23,6 +23,7 @@ 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.app.mgt.ApplicationManager; +import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; /** @@ -45,4 +46,6 @@ public interface DeviceManagementService { PushNotificationConfig getPushNotificationConfig(); + PolicyMonitoringManager getPolicyMonitoringManager(); + } 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 ed1e9abec3..082b155658 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 @@ -31,6 +31,7 @@ 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 org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; import java.util.Date; import java.util.HashMap; @@ -304,4 +305,6 @@ public interface DeviceManagementProviderService { boolean isDeviceMonitoringEnabled(String deviceType); + PolicyMonitoringManager getPolicyMonitoringManager(String deviceType); + } 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 521bcefdf6..39389ee879 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 @@ -49,6 +49,7 @@ import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; 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 org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository; @@ -1255,6 +1256,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv return operationMonitoringTaskConfig.isEnabled(); } + @Override + public PolicyMonitoringManager getPolicyMonitoringManager(String deviceType) { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + DeviceManagementService dms = pluginRepository.getDeviceManagementService(deviceType, tenantId); + return dms.getPolicyMonitoringManager(); + } + @Override public List getDevicesOfUser(String username) throws DeviceManagementException { List devices = new ArrayList<>(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java index 86433ce141..e30cdf4389 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManagementService.java @@ -22,6 +22,7 @@ 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.app.mgt.ApplicationManager; +import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; @@ -69,4 +70,9 @@ public class TestDeviceManagementService implements DeviceManagementService { return null; } + @Override + public PolicyMonitoringManager getPolicyMonitoringManager() { + return null; + } + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag index 7303a5ee8c..9d12aa9360 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag @@ -121,9 +121,9 @@ if (uriMatcher.match("/{context}/api/user/authenticate")) { } else { userRoles = String(addUserFormData.userRoles).split(","); } - if (username.length < devicemgtProps.usernameLength) { - log.error("Username Must be between 1 and " + devicemgtProps.usernameLength + " characters long"); - result = "Username Must be between 1 and " + devicemgtProps.usernameLength + " characters long"; + if (username.length < devicemgtProps.userValidationConfig.usernameLength) { + log.error("Username Must be between 1 and " + devicemgtProps.userValidationConfig.usernameLength + " characters long"); + result = "Username Must be between 1 and " + devicemgtProps.userValidationConfig.usernameLength + " characters long"; } else { try { result = userModule.addUser(username, firstname, lastname, emailAddress, userRoles); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 6c11194110..e9e1d99ce6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -1,7 +1,5 @@ { "appContext": "/devicemgt/", - "webAgentContext" : "/emm-web-agent/", - "apiContext": "api", "httpsURL" : "%https.ip%", "httpURL" : "%http.ip%", "httpsWebURL" : "%https.ip%", @@ -15,7 +13,7 @@ "iOSConfigRoot" : "%https.ip%/ios-enrollment/", "iOSAPIRoot" : "%https.ip%/ios/", "adminService": "%https.ip%", - "apimgt-gateway": false, + "gatewayEnabled": false, "oauthProvider": { "appRegistration": { "appType": "webapp", @@ -32,19 +30,8 @@ "adminUser":"admin@carbon.super", "adminUserTenantId":"-1234", "adminRole":"admin", - "usernameLength":30, - "pageSize":10, - "ssoConfiguration" : { - "enabled" : false, - "issuer" : "devicemgt", - "appName" : "devicemgt", - "identityProviderURL" : "%https.ip%/sso/samlsso.jag", - "responseSigningEnabled" : "true", - "keyStorePassword" : "wso2carbon", - "identityAlias" : "wso2carbon", - "keyStoreName" : "/repository/resources/security/wso2carbon.jks" - }, "userValidationConfig" : { + "usernameLength":30, "usernameJSRegEx" : "^[\\S]{3,30}$", "usernameRegExViolationErrorMsg" : "Provided username is invalid.", "usernameHelpMsg" : "Should be in minimum 3 characters long and do not include any whitespaces.", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js index fefd73bd0b..de20da586d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js @@ -105,4 +105,33 @@ var groupModule = {}; ); }; + groupModule.getGroup = function (groupId) { + return serviceInvokers.XMLHttp.get( + deviceServiceEndpoint + "/groups/id/" + groupId, function (responsePayload) { + return JSON.parse(responsePayload.responseText); + }, + function (responsePayload) { + log.error(responsePayload); + return -1; + } + ); + }; + + groupModule.getRolesOfGroup = function (groupId) { + return serviceInvokers.XMLHttp.get( + deviceServiceEndpoint + "/groups/id/" + groupId + "/roles", function (responsePayload) { + var data = JSON.parse(responsePayload.responseText); + if(data) { + return data.roles; + } else { + return []; + } + }, + function (responsePayload) { + log.error(responsePayload); + return -1; + } + ); + }; + }(groupModule)); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js index 9c969f4ab1..d9d51101c1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js @@ -138,7 +138,7 @@ var handlers = function () { "client credentials to session context. No username of logged in user is found as " + "input - setUpEncodedTenantBasedClientAppCredentials(x)"); } else { - if (devicemgtProps["apimgt-gateway"]) { + if (devicemgtProps["gatewayEnabled"]) { var tenantBasedClientAppCredentials = tokenUtil.getTenantBasedClientAppCredentials(username); if (!tenantBasedClientAppCredentials) { throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant " + @@ -176,7 +176,7 @@ var handlers = function () { "client credentials to session context. No username of logged in user is found as " + "input - setUpEncodedTenantBasedWebSocketClientAppCredentials(x)"); } else { - if (devicemgtProps["apimgt-gateway"]) { + if (devicemgtProps["gatewayEnabled"]) { var tenantBasedWebSocketClientAppCredentials = tokenUtil.getTenantBasedWebSocketClientAppCredentials(username); if (!tenantBasedWebSocketClientAppCredentials) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.js index 6099b8a845..32f427090a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.js @@ -33,7 +33,7 @@ function onRequest(context) { viewModel["roles"] = response["content"]; } - viewModel["charLimit"] = mdmProps["usernameLength"]; + viewModel["charLimit"] = mdmProps["userValidationConfig"]["usernameLength"]; viewModel["usernameJSRegEx"] = mdmProps["userValidationConfig"]["usernameJSRegEx"]; viewModel["usernameHelpText"] = mdmProps["userValidationConfig"]["usernameHelpMsg"]; viewModel["usernameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["usernameRegExViolationErrorMsg"]; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.hbs index 6b466d90a3..a294732b26 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.hbs @@ -171,7 +171,7 @@ {{/if}} - + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs index 863c85842f..e585fea5fe 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.hbs @@ -26,7 +26,7 @@ - {{#if groupName}} + {{#if group}}
  • Groups @@ -34,7 +34,7 @@
  • - {{groupName}} + {{group.name}}
  • {{else}} @@ -47,7 +47,7 @@ {{/zone}} {{#zone "navbarActions"}} - {{#if groupName}} + {{#if group}}
  • @@ -57,6 +57,15 @@ Assign from My Devices
  • +
  • + + + + + + View Analytics + +
  • {{else}} {{#if permissions.enroll}}
  • @@ -73,6 +82,55 @@ {{/zone}} {{#zone "content"}} + {{#if group}} +

    + {{group.name}} group +

    +
    +
    +
    +
    +
    + +
    +
    +
    +
    + Overview +
    + + + + + + + + + + + + + + + + + + + +
    Owner{{group.owner}}
    Shared with roles + {{#each roles}} + {{this}}
    + {{/each}} +
    Device Count{{deviceCount}}
    Description{{group.description}}
    +
    +
    +
    +
    +
    +

    + Devices in {{group.name}} group +

    + {{/if}}
    @@ -82,7 +140,6 @@ {{#if deviceCount}}
    - Loading devices . . .
    @@ -118,19 +175,42 @@ - - - - - - - - - - - - - + + + + + @@ -157,7 +237,7 @@

    You don't have any device - {{#if groupName}} + {{#if group}} assigned to this group {{else}} enrolled @@ -165,7 +245,7 @@ at the moment.

    - {{#if groupName}} + {{#if group}} @@ -208,20 +288,19 @@ -
    -

    - Please select group -
    -
    Loading...
    -

    -
    +
    Loading...

    @@ -435,3 +521,19 @@ type="text/x-handlebars-template"> {{js "js/listing.js"}} {{/zone}} + +{{#zone "topCss"}} + +{{/zone}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js index 1c2d01b26b..0f3f8066fd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/devices.js @@ -20,15 +20,19 @@ function onRequest(context) { var constants = require("/app/modules/constants.js"); var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; - - var groupName = request.getParameter("groupName"); + var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; + var groupId = request.getParameter("groupId"); var viewModel = {}; var title = "Devices"; - if (groupName) { - title = groupName + " " + title; - viewModel.groupName = groupName; + if (groupId) { + var group = groupModule.getGroup(groupId); + if (group) { + title = group.name + " " + title; + viewModel.roles = groupModule.getRolesOfGroup(groupId); + viewModel.group = group; + } } viewModel.title = title; var currentUser = session.get(constants.USER_SESSION_KEY); @@ -42,7 +46,6 @@ function onRequest(context) { viewModel.currentUser = currentUser; var deviceCount = 0; if (groupId) { - var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; deviceCount = groupModule.getGroupDeviceCount(groupId); } else { deviceCount = deviceModule.getDevicesCount(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js index d5457db01f..978d85e804 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js @@ -22,7 +22,8 @@ * initial mode and with out select mode. */ function InitiateViewOption(url) { - if ($(".select-enable-btn").text() == "Select") { + if ($(".select-enable-btn").text() == "Select" && !$(this).hasClass("btn")) { + url = $(this).parent().data("url"); $(location).attr('href', url); } } @@ -51,7 +52,7 @@ function InitiateViewOption(url) { var deviceCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']"; var assetContainer = "#ast-container"; -var deviceListing, currentUser, groupName, groupId; +var deviceListing, currentUser, groupId; /* * DOM ready functions. @@ -69,8 +70,7 @@ $(document).ready(function () { deviceListing = $("#device-listing"); currentUser = deviceListing.data("current-user"); - - groupName = getParameterByName("groupName"); + groupId = getParameterByName("groupId"); /* Adding selected class for selected devices */ @@ -85,18 +85,6 @@ $(document).ready(function () { return $("#content-filter-types").html(); } }); - - $(".ast-container").on("click", ".claim-btn", function (e) { - e.stopPropagation(); - var deviceId = $(this).data("deviceid"); - var serviceURL = "/temp-controller-agent/enrollment/claim?username=" + currentUser; - var deviceIdentifier = {id: deviceId, type: "TemperatureController"}; - invokerUtil.put(serviceURL, deviceIdentifier, function (message) { - console.log(message); - }, function (message) { - console.log(message.content); - }); - }); }); /* @@ -161,13 +149,13 @@ function toTitleCase(str) { function loadDevices(searchType, searchParam) { var serviceURL; - if (groupName && groupId && $.hasPermission("LIST_OWN_DEVICES")) { + if (groupId && $.hasPermission("LIST_OWN_DEVICES")) { serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices"; } else if ($.hasPermission("LIST_DEVICES")) { serviceURL = "/api/device-mgt/v1.0/devices"; } else if (permissionsUtil.hasPermission("LIST_OWN_DEVICES")) { //Get authenticated users devices - serviceURL = "/api/device-mgt/v1.0/users/devices?username=" + currentUser; + serviceURL = "/api/device-mgt/v1.0/devices?username=" + currentUser; } else { $("#loading-content").remove(); $('#device-table').addClass('hidden'); @@ -256,18 +244,16 @@ function loadDevices(searchType, searchParam) { { targets: 0, data: 'name', - class: 'remove-padding icon-only content-fill', + class: 'remove-padding icon-only content-fill viewEnabledIcon', render: function (data, type, row, meta) { - return '
    '; + return '
    '; } }, { targets: 1, data: 'name', - class: '', + class: 'viewEnabledIcon', render: function (name, type, row, meta) { var model = getPropertyValue(row.properties, 'DEVICE_MODEL'); var vendor = getPropertyValue(row.properties, 'VENDOR'); @@ -281,12 +267,12 @@ function loadDevices(searchType, searchParam) { { targets: 2, data: 'user', - class: 'remove-padding-top', + class: 'remove-padding-top viewEnabledIcon' }, { targets: 3, data: 'status', - class: 'remove-padding-top', + class: 'remove-padding-top viewEnabledIcon', render: function (status, type, row, meta) { var html; switch (status) { @@ -309,7 +295,7 @@ function loadDevices(searchType, searchParam) { { targets: 4, data: 'deviceType', - class: 'remove-padding-top', + class: 'remove-padding-top viewEnabledIcon', render: function (status, type, row, meta) { return getDeviceTypeLabel(row.deviceType); } @@ -317,7 +303,7 @@ function loadDevices(searchType, searchParam) { { targets: 5, data: 'ownership', - class: 'remove-padding-top', + class: 'remove-padding-top viewEnabledIcon', render: function (status, type, row, meta) { if (getDeviceTypeCategory(row.deviceType) == 'mobile') { return row.ownership; @@ -345,7 +331,7 @@ function loadDevices(searchType, searchParam) { ''; } - if ((!groupName || !groupId) && groupingEnabled(row.deviceType)) { + if (!groupId && groupingEnabled(row.deviceType)) { html += '' + - '' + - '' + - ''; - html += - '' + - '' + - '' + - ''; + + 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType + + '" data-devicename="' + row.name + '">' + + '' + + '' + + ''; + var groupOwner = $('#group_owner').text(); + if (groupId && groupOwner != "wso2.system.user") { + html += + '' + + '' + + '' + + ''; + } else { + html += + '' + + '' + + '' + + ''; + } } return html; } @@ -381,13 +376,14 @@ function loadDevices(searchType, searchParam) { var fnCreatedRow = function (row, data, dataIndex) { $(row).attr('data-type', 'selectable'); $(row).attr('data-deviceid', data.deviceIdentifier); - $(row).attr('data-devicetype', data.type); + $(row).attr('data-devicetype', data.deviceType); + $(row).attr('data-url', context + '/device/' + data.deviceType + '?id=' + data.deviceIdentifier); var model = getPropertyValue(data.properties, 'DEVICE_MODEL'); var vendor = getPropertyValue(data.properties, 'VENDOR'); var owner = data.user; var status = data.status; var ownership = data.ownership; - var deviceType = data.type; + var deviceType = data.deviceType; var category = getDeviceTypeCategory(deviceType); $.each($('td', row), function (colIndex) { switch (colIndex) { @@ -561,17 +557,13 @@ function markAlreadyAssignedGroups(deviceId, deviceType) { data = JSON.parse(data); if (xhr.status == 200) { if (data.length > 0) { + var selectedValues = []; for (var i = 0; i < data.length; i++) { - $('.groupCheckBoxes').each( - function () { - if (data[i].id == $(this).data('groupid')) { - $(this).attr('checked', true); - } - } - ); + if (data[i].owner != "wso2.system.user") { + selectedValues.push(data[i].id); + } } - } else { - return; + $("#groups").val(selectedValues).trigger("change"); } } else { displayErrors(xhr); @@ -601,7 +593,7 @@ function attachDeviceEvents() { $(modalPopupContent).html($('#group-device-modal-content').html()); $('#user-groups').html( '
    '); - $("a#group-device-yes-link").hide(); + $("a#group-device-update-link").hide(); showPopup(); var serviceURL; @@ -613,29 +605,39 @@ function attachDeviceEvents() { } invokerUtil.get(serviceURL, function (data) { + $("a#group-device-add-link").hide(); var groups = JSON.parse(data); - var html = '
    '; + var html = ''; + var hasGroups = false; for (var i = 0; i < groups.deviceGroups.length; i++) { if (groups.deviceGroups[i].owner != "wso2.system.user") { - html += '
    '; + html += ''; + hasGroups = true; } } + if (hasGroups) { + html = '

    Please select device group(s)


    ' + + '
    ' + + '
    '; + markAlreadyAssignedGroups(deviceId, deviceType); + $("a#group-device-update-link").show(); + $("a#group-add-link").hide(); + } else { + $("a#group-device-update-link").hide(); + $("a#group-add-link").show(); + html += '

    You don\'t have any existing device groups. Please add new device group first.

    ' + } $('#user-groups').html(html); - markAlreadyAssignedGroups(deviceId, deviceType); - $("a#group-device-yes-link").show(); - $("a#group-device-yes-link").click(function () { + $("select.select2[multiple=multiple]").select2({ + tags: false + }); + $("a#group-device-update-link").click(function () { var deviceIdentifier = {"id": deviceId, "type": deviceType}; - var deviceGroupIds = []; - $('.modal .groupCheckBoxes').each( - function () { - if ($(this).is(':checked')) { - deviceGroupIds.push($(this).data('groupid')); - } - } - ); + var deviceGroupIds = $("#groups").val(); + if (!deviceGroupIds) { + deviceGroupIds = []; + } var deviceToGroupsAssignment = { deviceIdentifier: deviceIdentifier, deviceGroupIds: deviceGroupIds @@ -675,36 +677,42 @@ function attachDeviceEvents() { * on Device Management page in WSO2 MDM Console. */ $("a.remove-device-link").click(function () { + var deviceIdentifiers = []; var deviceId = $(this).data("deviceid"); var deviceType = $(this).data("devicetype"); - var serviceURL = "/api/device-mgt/v1.0/devices/type/" + deviceType + "/id/" + deviceId; + + if (deviceId && deviceType) { + deviceIdentifiers = [{"id": deviceId, "type": deviceType}]; + } else { + deviceIdentifiers = getSelectedDevices(); + } + + if (deviceIdentifiers.length == 0) { + $(modalPopupContent).html($('#no-device-selected').html()); + $("a#no-device-selected-link").click(function () { + hidePopup(); + }); + showPopup(); + return; + } $(modalPopupContent).html($('#remove-device-modal-content').html()); showPopup(); $("a#remove-device-yes-link").click(function () { - if (groupId && groupName) { - var deviceIdentifiers = [{"id": deviceId, "type": deviceType}]; - serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices/remove"; + if (groupId) { + var serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices/remove"; invokerUtil.post(serviceURL, deviceIdentifiers, function (message) { - $(modalPopupContent).html($('#remove-device-from-group-200-content').html()); - setTimeout(function () { - hidePopup(); - location.reload(false); - }, 2000); - }, function (message) { - displayDeviceErrors(message); - }); - } else { - invokerUtil.delete(serviceURL, function (message) { $(modalPopupContent).html($('#remove-device-200-content').html()); setTimeout(function () { hidePopup(); location.reload(false); }, 2000); - }, function (message) { + }, function (jqXHR) { displayDeviceErrors(jqXHR); }); + } else { + removeDevices(deviceIdentifiers); } }); @@ -736,7 +744,7 @@ function attachDeviceEvents() { hidePopup(); location.reload(false); }, 2000); - }, function (message) { + }, function (jqXHR) { displayDeviceErrors(jqXHR); }); }); @@ -745,6 +753,106 @@ function attachDeviceEvents() { hidePopup(); }); }); + + /** + * Following click function would execute + * when a user clicks on "Add to Group" link + * on Device Management page in WSO2 devicemgt Console. + */ + $("a.add-devices-to-group-link").click(function () { + $("a#group-device-update-link").hide(); + var deviceIdentifiers = getSelectedDevices(); + if (deviceIdentifiers.length == 0) { + $(modalPopupContent).html($('#no-device-selected').html()); + $("a#no-device-selected-link").click(function () { + hidePopup(); + }); + showPopup(); + return; + } + + $(modalPopupContent).html($('#group-device-modal-content').html()); + $('#user-groups').html( + '
    '); + $("a#group-device-add-link").hide(); + showPopup(); + + var serviceURL; + if ($.hasPermission("LIST_ALL_GROUPS")) { + serviceURL = "/api/device-mgt/v1.0/admin/groups?limit=100"; + } else if ($.hasPermission("LIST_GROUPS")) { + //Get authenticated users groups + serviceURL = "/api/device-mgt/v1.0/groups?limit=100"; + } + + invokerUtil.get(serviceURL, function (data) { + var groups = JSON.parse(data); + var html = ''; + var hasGroups = false; + for (var i = 0; i < groups.deviceGroups.length; i++) { + if (groups.deviceGroups[i].owner != "wso2.system.user") { + html += ''; + hasGroups = true; + } + } + if (hasGroups) { + html = '
    '; + $("a#group-add-link").hide(); + $("a#group-device-add-link").show(); + } else { + html += '

    You don\'t have any existing device groups. Please add new device group first.

    '; + $("a#group-add-link").show(); + $("a#group-device-add-link").hide(); + } + $('#user-groups').html(html); + $("a#group-device-add-link").click(function () { + var selectedGroup = $('#assign-group-selector').val(); + serviceURL = "/api/device-mgt/v1.0/groups/id/" + selectedGroup + "/devices/add"; + invokerUtil.post(serviceURL, deviceIdentifiers, function (data) { + $(modalPopupContent).html($('#group-associate-device-200-content').html()); + setTimeout(function () { + hidePopup(); + location.reload(false); + }, 2000); + }, function (jqXHR) { + displayDeviceErrors(jqXHR); + }); + }); + }, function (jqXHR) { + if (jqXHR.status == 404) { + $(modalPopupContent).html($('#group-404-content').html()); + $("a#cancel-link").click(function () { + hidePopup(); + }); + } else { + displayDeviceErrors(jqXHR); + } + }); + + $("a#group-device-cancel-link").click(function () { + hidePopup(); + }); + }); +} + +function removeDevices(deviceIdentifiers) { + var serviceURL = "/api/device-mgt/v1.0/devices/type/" + deviceIdentifiers[0].type + "/id/" + deviceIdentifiers[0].id; + invokerUtil.delete(serviceURL, function (message) { + if (deviceIdentifiers.length > 1) { + deviceIdentifiers.slice(1, deviceIdentifiers.length); + removeDevices(deviceIdentifiers); + } else { + $(modalPopupContent).html($('#remove-device-200-content').html()); + setTimeout(function () { + hidePopup(); + location.reload(false); + }, 2000); + } + }, function (jqXHR) { + displayDeviceErrors(jqXHR); + }); } function displayDeviceErrors(jqXHR) { @@ -779,3 +887,23 @@ function getParameterByName(name) { results = regex.exec(location.search); return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } + +/* + * Function to get selected devices. + */ +function getSelectedDevices() { + var deviceList = []; + var thisTable = $(".DTTT_selected").closest('.dataTables_wrapper').find('.dataTable').dataTable(); + thisTable.api().rows().every(function () { + if ($(this.node()).hasClass('DTTT_selected')) { + deviceList.push( + { + "id": $(thisTable.api().row(this).node()).data('deviceid'), + "type": $(thisTable.api().row(this).node()).data('devicetype') + } + ); + } + }); + + return deviceList; +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.hbs index 24d69f8ce4..c7cfdffad3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.hbs @@ -37,7 +37,7 @@
  • - + {{groupName}}
  • diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js index 19f783ed56..6a34a26b0c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js @@ -19,8 +19,8 @@ function onRequest(context) { var utility = require("/app/modules/utility.js").utility; var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; - var groupName = context.uriParams.name; var groupId = context.uriParams.id; + var group = groupModule.getGroup(groupId); var devices = []; var deviceResponse = groupModule.getGroupDevices(groupId).responseText; @@ -29,8 +29,9 @@ function onRequest(context) { devices = deviceResponseObj.devices; } var page = { - "groupName": groupName, - "title": groupName + " Analytics" + "groupId": groupId, + "groupName": group.name, + "title": group.name + " Analytics" }; if (devices) { var deviceTypes = []; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.json index 2e2fea333e..8535dab982 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.json @@ -1,5 +1,5 @@ { "version": "1.0.0", - "uri": "/group/{name}/{id}/analytics", + "uri": "/group/{id}/analytics", "layout": "cdmf.layout.default" } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js index 4597a71297..a229215b57 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js @@ -16,18 +16,42 @@ * under the License. */ +/** + * Following function would execute + * when a user clicks on the list item + * initial mode and with out select mode. + */ +function InitiateViewOption(url) { + if ($(".select-enable-btn").text() == "Select") { + url = $(this).parent().data("url"); + $(location).attr('href', url); + } +} + +(function () { + var cache = {}; + var validateAndReturn = function (value) { + return (value == undefined || value == null) ? "Unspecified" : value; + }; + Handlebars.registerHelper("deviceMap", function (device) { + device.owner = validateAndReturn(device.owner); + device.ownership = validateAndReturn(device.ownership); + var arr = device.properties; + if (arr) { + device.properties = arr.reduce(function (total, current) { + total[current.name] = validateAndReturn(current.value); + return total; + }, {}); + } + }); +})(); + /* * Setting-up global variables. */ var groupCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']"; var assetContainer = "#ast-container"; -function InitiateViewOption() { - if ($(".select-enable-btn").text() == "Select") { - $(location).attr('href', $(this).data("url")); - } -} - /* * On Select All Groups button click function. * @@ -118,34 +142,36 @@ function loadGroups() { }); var json = { "recordsTotal": data.count, + "recordsFiltered": data.count, "data": objects - } - + }; return JSON.stringify(json); }; - var columns = [{ - targets: 0, - data: 'id', - class: 'remove-padding icon-only content-fill', - render: function (data, type, row, meta) { - return '
    '; - } - }, + var columns = [ + { + targets: 0, + data: 'id', + class: 'remove-padding icon-only content-fill viewEnabledIcon', + render: function (data, type, row, meta) { + return '
    '; + } + }, { targets: 1, data: 'name', - class: '' + class: 'viewEnabledIcon' }, { targets: 2, data: 'owner', - class: 'remove-padding-top', + class: 'remove-padding-top viewEnabledIcon' }, { targets: 3, data: 'description', - class: 'remove-padding-top', + class: 'remove-padding-top viewEnabledIcon' }, { targets: 4, @@ -154,13 +180,7 @@ function loadGroups() { render: function (id, type, row, meta) { var html = ''; if ($.hasPermission("VIEW_GROUP_DEVICES")) { - html = '' + - '' - + - ''; - - html += '' + '' + @@ -202,7 +222,9 @@ function loadGroups() { var fnCreatedRow = function (row, data) { $(row).attr('data-type', 'selectable'); - $(row).attr('data-groupid', data.id); + if ($.hasPermission("VIEW_GROUP_DEVICES")) { + $(row).attr('data-url', 'devices?groupId=' + data.groupId + '&groupName=' + data.name); + } $.each($('td', row), function (colIndex) { switch (colIndex) { case 1: @@ -224,21 +246,23 @@ function loadGroups() { }); }; - $('#group-grid').datatables_extended_serverside_paging( - null, - serviceURL, - dataFilter, - columns, - fnCreatedRow, - function (oSettings) { - $(".icon .text").res_text(0.2); - attachEvents(); - }, - { - "placeholder": "Search By Group Name", - "searchKey": "name" - }); + null, + serviceURL, + dataFilter, + columns, + fnCreatedRow, + function (oSettings) { + $(".icon .text").res_text(0.2); + attachEvents(); + var thisTable = $(this).closest('.dataTables_wrapper').find('.dataTable').dataTable(); + thisTable.removeClass("table-selectable"); + }, + { + "placeholder": "Search By Group Name", + "searchKey": "name" + } + ); $(groupCheckbox).click(function () { addGroupSelectedClass(this); }); @@ -257,6 +281,11 @@ function openCollapsedNav() { * DOM ready functions. */ $(document).ready(function () { + /* Adding selected class for selected devices */ + $(groupCheckbox).each(function () { + addGroupSelectedClass(this); + }); + var permissionSet = {}; //This method is used to setup permission for device listing @@ -278,11 +307,6 @@ $(document).ready(function () { loadGroups(); //$('#device-grid').datatables_extended(); - /* Adding selected class for selected devices */ - $(groupCheckbox).each(function () { - addGroupSelectedClass(this); - }); - /* for device list sorting drop down */ $(".ctrl-filter-type-switcher").popover( { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js index e1c4b583bd..a05bcc6e7f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js @@ -40,7 +40,7 @@ function onRequest() { } var userStores = userModule.getSecondaryUserStores(); page["userStores"] = userStores; - page["charLimit"] = devicemgtProps["usernameLength"]; + page["charLimit"] = devicemgtProps["userValidationConfig"]["usernameLength"]; page["usernameJSRegEx"] = devicemgtProps["userValidationConfig"]["usernameJSRegEx"]; page["usernameHelpMsg"] = devicemgtProps["userValidationConfig"]["usernameHelpMsg"]; page["usernameRegExViolationErrorMsg"] = devicemgtProps["userValidationConfig"]["usernameRegExViolationErrorMsg"]; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.logo/logo.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.logo/logo.hbs index ae5febf40f..070ed3088a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.logo/logo.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.logo/logo.hbs @@ -15,4 +15,5 @@ specific language governing permissions and limitations under the License. }} -{{#zone "productName"}}WSO2 IoT{{/zone}} \ No newline at end of file +{{#zone "productName"}}WSO2 IoT Server{{/zone}} +{{#zone "productNameResponsive"}}WSO2 IoT Server{{/zone}} \ No newline at end of file diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilter.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilter.java index 2144b60cd6..a2dcd69002 100644 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilter.java +++ b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilter.java @@ -19,8 +19,8 @@ package org.wso2.carbon.policy.evaluator; -import org.wso2.carbon.policy.mgt.common.Policy; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java index 9857c8f753..8fbbd855a3 100644 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java +++ b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java @@ -19,8 +19,8 @@ package org.wso2.carbon.policy.evaluator; import org.wso2.carbon.policy.evaluator.utils.Constants; -import org.wso2.carbon.policy.mgt.common.Policy; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import java.util.ArrayList; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PDPServiceImpl.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PDPServiceImpl.java index 04c9b47288..457c3a18b5 100644 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PDPServiceImpl.java +++ b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PDPServiceImpl.java @@ -20,7 +20,7 @@ package org.wso2.carbon.policy.evaluator; import org.wso2.carbon.policy.evaluator.spi.PDPService; import org.wso2.carbon.policy.mgt.common.Feature; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilter.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilter.java index 6a32448793..e57cc192bc 100644 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilter.java +++ b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilter.java @@ -19,7 +19,7 @@ package org.wso2.carbon.policy.evaluator; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilterImpl.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilterImpl.java index 0cbcdb8dd2..90ae4f68b3 100644 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilterImpl.java +++ b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/PolicyFilterImpl.java @@ -18,7 +18,7 @@ package org.wso2.carbon.policy.evaluator; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import java.util.ArrayList; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java index 0b2b65d444..52765763bc 100644 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java +++ b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/spi/PDPService.java @@ -21,7 +21,7 @@ package org.wso2.carbon.policy.evaluator.spi; import org.wso2.carbon.policy.evaluator.FeatureRules; import org.wso2.carbon.policy.mgt.common.Feature; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/merged/MergedEvaluationPoint.java b/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/merged/MergedEvaluationPoint.java index 07fd0b68d3..35edab3271 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/merged/MergedEvaluationPoint.java +++ b/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/merged/MergedEvaluationPoint.java @@ -22,6 +22,9 @@ 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.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import org.wso2.carbon.policy.mgt.common.*; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import org.wso2.carbon.policy.decision.point.internal.PolicyDecisionPointDataHolder; diff --git a/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/PolicyEvaluationServiceImpl.java b/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/PolicyEvaluationServiceImpl.java index d737cbaa3f..6bc2113e81 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/PolicyEvaluationServiceImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/PolicyEvaluationServiceImpl.java @@ -19,10 +19,10 @@ package org.wso2.carbon.policy.decision.point.simple; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.policy.mgt.common.PolicyEvaluationException; import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/SimpleEvaluation.java b/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/SimpleEvaluation.java index f8fd2a7bb7..de11299c68 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/SimpleEvaluation.java +++ b/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/SimpleEvaluation.java @@ -20,7 +20,7 @@ package org.wso2.carbon.policy.decision.point.simple; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.policy.mgt.common.PolicyEvaluationException; public interface SimpleEvaluation { diff --git a/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/SimpleEvaluationImpl.java b/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/SimpleEvaluationImpl.java index f8c75e3105..9d2a997b74 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/SimpleEvaluationImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/simple/SimpleEvaluationImpl.java @@ -21,6 +21,7 @@ package org.wso2.carbon.policy.decision.point.simple; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.policy.decision.point.internal.PolicyDecisionPointDataHolder; import org.wso2.carbon.policy.mgt.common.*; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; diff --git a/components/policy-mgt/org.wso2.carbon.policy.information.point/src/main/java/org/wso2/carbon/policy/information/point/PolicyInformationServiceImpl.java b/components/policy-mgt/org.wso2.carbon.policy.information.point/src/main/java/org/wso2/carbon/policy/information/point/PolicyInformationServiceImpl.java index 788acdcdd8..a36605fe0f 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.information.point/src/main/java/org/wso2/carbon/policy/information/point/PolicyInformationServiceImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.information.point/src/main/java/org/wso2/carbon/policy/information/point/PolicyInformationServiceImpl.java @@ -21,7 +21,7 @@ package org.wso2.carbon.policy.information.point; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.policy.mgt.common.PIPDevice; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.policy.mgt.common.PolicyInformationPoint; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyAdministratorPoint.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyAdministratorPoint.java index 358ee5ef66..91e1eff05c 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyAdministratorPoint.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyAdministratorPoint.java @@ -17,8 +17,9 @@ */ package org.wso2.carbon.policy.mgt.common; -import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyEvaluationPoint.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyEvaluationPoint.java index 74ce2adf1a..86cbb46a4a 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyEvaluationPoint.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyEvaluationPoint.java @@ -20,6 +20,8 @@ package org.wso2.carbon.policy.mgt.common; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyFilter.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyFilter.java index f82e252bf6..3a7d4a50af 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyFilter.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyFilter.java @@ -20,6 +20,7 @@ package org.wso2.carbon.policy.mgt.common; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import java.util.List; import java.util.Map; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyInformationPoint.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyInformationPoint.java index 5d74dc5663..9b85907634 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyInformationPoint.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/PolicyInformationPoint.java @@ -21,6 +21,7 @@ package org.wso2.carbon.policy.mgt.common; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.Feature; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/ComplianceDecisionPoint.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/ComplianceDecisionPoint.java index 57f52e8fc0..4ce802fe65 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/ComplianceDecisionPoint.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/monitor/ComplianceDecisionPoint.java @@ -22,7 +22,9 @@ package org.wso2.carbon.policy.mgt.common.monitor; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import java.util.List; @@ -38,7 +40,7 @@ public interface ComplianceDecisionPoint { void setDeviceAsReachable(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; - void reEnforcePolicy(DeviceIdentifier deviceIdentifier, ComplianceData complianceData) throws + void reEnforcePolicy(DeviceIdentifier deviceIdentifier, NonComplianceData complianceData) throws PolicyComplianceException; void markDeviceAsNoneCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; @@ -49,7 +51,7 @@ public interface ComplianceDecisionPoint { void activateDevice(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; - void validateDevicePolicyCompliance(DeviceIdentifier deviceIdentifier, ComplianceData complianceData) throws + void validateDevicePolicyCompliance(DeviceIdentifier deviceIdentifier, NonComplianceData complianceData) throws PolicyComplianceException; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/utils/PolicyCreator.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/utils/PolicyCreator.java index 00fc404ae3..b42801896d 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/utils/PolicyCreator.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/test/java/org/wos2/carbon/policy/mgt/common/utils/PolicyCreator.java @@ -20,8 +20,8 @@ package org.wos2.carbon.policy.mgt.common.utils; import org.wso2.carbon.device.mgt.common.Feature; -import org.wso2.carbon.policy.mgt.common.Policy; -import org.wso2.carbon.policy.mgt.common.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; import java.util.ArrayList; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerService.java index 96d7aac4d2..08fb6b4e5b 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerService.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerService.java @@ -21,10 +21,13 @@ package org.wso2.carbon.policy.mgt.core; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.Feature; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import org.wso2.carbon.policy.mgt.common.*; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.core.task.TaskScheduleService; import java.util.List; @@ -75,7 +78,7 @@ public interface PolicyManagerService { boolean checkCompliance(DeviceIdentifier deviceIdentifier, Object response) throws PolicyComplianceException; - ComplianceData getDeviceCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + NonComplianceData getDeviceCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; boolean isCompliant(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerServiceImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerServiceImpl.java index 7f00319052..7b6eb4bb24 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerServiceImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerServiceImpl.java @@ -24,10 +24,13 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.InvalidDeviceException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import org.wso2.carbon.policy.mgt.common.*; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.core.impl.PolicyAdministratorPointImpl; import org.wso2.carbon.policy.mgt.core.impl.PolicyInformationPointImpl; import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder; @@ -210,7 +213,7 @@ public class PolicyManagerServiceImpl implements PolicyManagerService { } @Override - public ComplianceData getDeviceCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + public NonComplianceData getDeviceCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { return monitoringManager.getDevicePolicyCompliance(deviceIdentifier); } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/cache/PolicyCacheManager.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/cache/PolicyCacheManager.java index 3ecbab54c3..8a4db21d7b 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/cache/PolicyCacheManager.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/cache/PolicyCacheManager.java @@ -19,7 +19,7 @@ package org.wso2.carbon.policy.mgt.core.cache; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/cache/impl/PolicyCacheManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/cache/impl/PolicyCacheManagerImpl.java index 2e95546910..8b0bb71c1c 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/cache/impl/PolicyCacheManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/cache/impl/PolicyCacheManagerImpl.java @@ -21,7 +21,7 @@ package org.wso2.carbon.policy.mgt.core.cache.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; import org.wso2.carbon.policy.mgt.core.cache.PolicyCacheManager; import org.wso2.carbon.policy.mgt.core.mgt.PolicyManager; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/FeatureDAO.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/FeatureDAO.java index b299fdd121..e64b8214df 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/FeatureDAO.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/FeatureDAO.java @@ -20,8 +20,8 @@ package org.wso2.carbon.policy.mgt.core.dao; import org.wso2.carbon.device.mgt.common.Feature; -import org.wso2.carbon.policy.mgt.common.Profile; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/MonitoringDAO.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/MonitoringDAO.java index c097494d2a..b1a6584378 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/MonitoringDAO.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/MonitoringDAO.java @@ -19,11 +19,10 @@ package org.wso2.carbon.policy.mgt.core.dao; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature; import org.wso2.carbon.policy.mgt.common.monitor.PolicyDeviceWrapper; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -50,11 +49,11 @@ public interface MonitoringDAO { complianceFeatures) throws MonitoringDAOException; - ComplianceData getCompliance(int deviceId, int enrolmentId) throws MonitoringDAOException; + NonComplianceData getCompliance(int deviceId, int enrolmentId) throws MonitoringDAOException; - List getCompliance(List deviceIds) throws MonitoringDAOException; + List getCompliance(List deviceIds) throws MonitoringDAOException; - List getCompliance() throws MonitoringDAOException; + List getCompliance() throws MonitoringDAOException; List getNoneComplianceFeatures(int policyComplianceStatusId) throws MonitoringDAOException; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java index 609be0a533..bda6bb88c4 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/PolicyDAO.java @@ -20,9 +20,9 @@ package org.wso2.carbon.policy.mgt.core.dao; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.policy.mgt.common.Criterion; -import org.wso2.carbon.policy.mgt.common.DeviceGroupWrapper; -import org.wso2.carbon.policy.mgt.common.Policy; -import org.wso2.carbon.policy.mgt.common.PolicyCriterion; +import org.wso2.carbon.device.mgt.common.policy.mgt.DeviceGroupWrapper; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyCriterion; import java.util.HashMap; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/ProfileDAO.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/ProfileDAO.java index c5fe41a945..01dd9f8443 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/ProfileDAO.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/ProfileDAO.java @@ -19,8 +19,7 @@ package org.wso2.carbon.policy.mgt.core.dao; -import org.wso2.carbon.device.mgt.core.dto.DeviceType; -import org.wso2.carbon.policy.mgt.common.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/MonitoringDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/MonitoringDAOImpl.java index 4a5d0e0bb9..edc064b6d0 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/MonitoringDAOImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/MonitoringDAOImpl.java @@ -22,13 +22,12 @@ package org.wso2.carbon.policy.mgt.core.dao.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature; import org.wso2.carbon.policy.mgt.common.monitor.PolicyDeviceWrapper; import org.wso2.carbon.policy.mgt.core.dao.MonitoringDAO; import org.wso2.carbon.policy.mgt.core.dao.MonitoringDAOException; import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory; -import org.wso2.carbon.policy.mgt.core.dao.PolicyManagerDAOException; import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil; import org.wso2.carbon.policy.mgt.core.util.PolicyManagerUtil; @@ -237,12 +236,12 @@ public class MonitoringDAOImpl implements MonitoringDAO { } @Override - public ComplianceData getCompliance(int deviceId, int enrolmentId) throws MonitoringDAOException { + public NonComplianceData getCompliance(int deviceId, int enrolmentId) throws MonitoringDAOException { Connection conn; PreparedStatement stmt = null; ResultSet resultSet = null; - ComplianceData complianceData = new ComplianceData(); + NonComplianceData complianceData = new NonComplianceData(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); try { @@ -275,11 +274,11 @@ public class MonitoringDAOImpl implements MonitoringDAO { } @Override - public List getCompliance(List deviceIds) throws MonitoringDAOException { + public List getCompliance(List deviceIds) throws MonitoringDAOException { Connection conn; PreparedStatement stmt = null; ResultSet resultSet = null; - List complianceDataList = new ArrayList<>(); + List complianceDataList = new ArrayList<>(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); try { conn = this.getConnection(); @@ -290,7 +289,7 @@ public class MonitoringDAOImpl implements MonitoringDAO { resultSet = stmt.executeQuery(); while (resultSet.next()) { - ComplianceData complianceData = new ComplianceData(); + NonComplianceData complianceData = new NonComplianceData(); complianceData.setId(resultSet.getInt("ID")); complianceData.setDeviceId(resultSet.getInt("DEVICE_ID")); complianceData.setEnrolmentId(resultSet.getInt("ENROLMENT_ID")); @@ -312,11 +311,11 @@ public class MonitoringDAOImpl implements MonitoringDAO { } @Override - public List getCompliance() throws MonitoringDAOException { + public List getCompliance() throws MonitoringDAOException { Connection conn; PreparedStatement stmt = null; ResultSet resultSet = null; - List complianceDataList = new ArrayList<>(); + List complianceDataList = new ArrayList<>(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); try { conn = this.getConnection(); @@ -326,7 +325,7 @@ public class MonitoringDAOImpl implements MonitoringDAO { resultSet = stmt.executeQuery(); while (resultSet.next()) { - ComplianceData complianceData = new ComplianceData(); + NonComplianceData complianceData = new NonComplianceData(); complianceData.setId(resultSet.getInt("ID")); complianceData.setDeviceId(resultSet.getInt("DEVICE_ID")); complianceData.setEnrolmentId(resultSet.getInt("ENROLMENT_ID")); diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java index 700768fb0a..580c89ecc3 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/PolicyDAOImpl.java @@ -23,9 +23,9 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.policy.mgt.common.Criterion; -import org.wso2.carbon.policy.mgt.common.DeviceGroupWrapper; -import org.wso2.carbon.policy.mgt.common.Policy; -import org.wso2.carbon.policy.mgt.common.PolicyCriterion; +import org.wso2.carbon.device.mgt.common.policy.mgt.DeviceGroupWrapper; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyCriterion; import org.wso2.carbon.policy.mgt.core.dao.PolicyDAO; import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory; import org.wso2.carbon.policy.mgt.core.dao.PolicyManagerDAOException; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/ProfileDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/ProfileDAOImpl.java index 253cc27a3a..32e00c03c4 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/ProfileDAOImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/ProfileDAOImpl.java @@ -21,10 +21,8 @@ package org.wso2.carbon.policy.mgt.core.dao.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.core.dto.DeviceType; -import org.wso2.carbon.policy.mgt.common.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory; -import org.wso2.carbon.policy.mgt.core.dao.PolicyManagerDAOException; import org.wso2.carbon.policy.mgt.core.dao.ProfileDAO; import org.wso2.carbon.policy.mgt.core.dao.ProfileManagerDAOException; import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/feature/AbstractFeatureDAO.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/feature/AbstractFeatureDAO.java index c94cf48b2a..2c3da0e30c 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/feature/AbstractFeatureDAO.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/feature/AbstractFeatureDAO.java @@ -22,8 +22,8 @@ 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.Feature; -import org.wso2.carbon.policy.mgt.common.Profile; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import org.wso2.carbon.policy.mgt.core.dao.FeatureDAO; import org.wso2.carbon.policy.mgt.core.dao.FeatureManagerDAOException; import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/feature/GenericFeatureDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/feature/GenericFeatureDAOImpl.java index 520e5da8a1..371fe39a9d 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/feature/GenericFeatureDAOImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/feature/GenericFeatureDAOImpl.java @@ -21,7 +21,7 @@ package org.wso2.carbon.policy.mgt.core.dao.impl.feature; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import org.wso2.carbon.policy.mgt.core.dao.FeatureManagerDAOException; import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory; import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/feature/SQLServerFeatureDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/feature/SQLServerFeatureDAOImpl.java index ea5c538003..ed8d90e328 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/feature/SQLServerFeatureDAOImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/feature/SQLServerFeatureDAOImpl.java @@ -21,7 +21,7 @@ package org.wso2.carbon.policy.mgt.core.dao.impl.feature; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import org.wso2.carbon.policy.mgt.core.dao.FeatureManagerDAOException; import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory; import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegator.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegator.java index e782308c06..aac07ce600 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegator.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegator.java @@ -19,7 +19,7 @@ package org.wso2.carbon.policy.mgt.core.enforcement; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java index 2d681cf93c..9a3bcfa894 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java @@ -25,11 +25,9 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.InvalidDeviceException; 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.OperationManager; import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; -import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl; import org.wso2.carbon.device.mgt.core.operation.mgt.OperationMgtConstants; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.policy.mgt.common.PolicyAdministratorPoint; import org.wso2.carbon.policy.mgt.common.PolicyEvaluationException; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java index 7baf29bf79..a9add947bf 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java @@ -27,12 +27,12 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementExcept import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; -import org.wso2.carbon.policy.mgt.common.Policy; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; import org.wso2.carbon.policy.mgt.common.monitor.ComplianceDecisionPoint; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder; import org.wso2.carbon.policy.mgt.core.util.PolicyManagementConstants; @@ -120,7 +120,7 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint { } @Override - public void reEnforcePolicy(DeviceIdentifier deviceIdentifier, ComplianceData complianceData) throws + public void reEnforcePolicy(DeviceIdentifier deviceIdentifier, NonComplianceData complianceData) throws PolicyComplianceException { try { @@ -261,7 +261,7 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint { } @Override - public void validateDevicePolicyCompliance(DeviceIdentifier deviceIdentifier, ComplianceData complianceData) throws + public void validateDevicePolicyCompliance(DeviceIdentifier deviceIdentifier, NonComplianceData complianceData) throws PolicyComplianceException { Policy policy = complianceData.getPolicy(); diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyAdministratorPointImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyAdministratorPointImpl.java index 871b490b73..73e21e0303 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyAdministratorPointImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyAdministratorPointImpl.java @@ -22,6 +22,8 @@ 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.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; import org.wso2.carbon.ntask.common.TaskException; import org.wso2.carbon.ntask.core.TaskInfo; import org.wso2.carbon.ntask.core.TaskManager; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyFilterImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyFilterImpl.java index f589d5bfd2..a78caa995b 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyFilterImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyFilterImpl.java @@ -22,8 +22,8 @@ package org.wso2.carbon.policy.mgt.core.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; -import org.wso2.carbon.policy.mgt.common.DeviceGroupWrapper; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.DeviceGroupWrapper; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.policy.mgt.common.PolicyFilter; import org.wso2.carbon.policy.mgt.core.util.PolicyManagementConstants; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyInformationPointImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyInformationPointImpl.java index d39822cb2c..da1146f780 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyInformationPointImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyInformationPointImpl.java @@ -26,6 +26,7 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.common.Feature; @@ -40,7 +41,6 @@ import org.wso2.carbon.policy.mgt.core.mgt.impl.FeatureManagerImpl; import org.wso2.carbon.policy.mgt.core.mgt.impl.PolicyManagerImpl; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; -import org.wso2.carbon.user.api.UserStoreManager; import java.util.ArrayList; import java.util.HashMap; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java index 27f9487ac6..15b394442d 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java @@ -24,7 +24,6 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.ntask.core.service.TaskService; import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint; import org.wso2.carbon.policy.mgt.common.PolicyInformationPoint; -import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; import org.wso2.carbon.policy.mgt.core.mgt.MonitoringManager; import org.wso2.carbon.policy.mgt.core.mgt.PolicyManager; import org.wso2.carbon.user.core.service.RealmService; @@ -43,7 +42,6 @@ public class PolicyManagementDataHolder { private DeviceManagementProviderService deviceManagementService; private MonitoringManager monitoringManager; private PolicyManager policyManager; - private Map policyMonitoringServiceMap = new HashMap<>(); private TaskService taskService; private static PolicyManagementDataHolder thisInstance = new PolicyManagementDataHolder(); @@ -122,18 +120,6 @@ public class PolicyManagementDataHolder { this.deviceManagementService = deviceManagementService; } - public PolicyMonitoringService getPolicyMonitoringService(String deviceType) { - return policyMonitoringServiceMap.get(deviceType); - } - - public void setPolicyMonitoringService(String deviceType, PolicyMonitoringService policyMonitoringService) { - this.policyMonitoringServiceMap.put(deviceType, policyMonitoringService); - } - - public void unsetPolicyMonitoringService(String deviceType) { - this.policyMonitoringServiceMap.remove(deviceType); - } - public TaskService getTaskService() { return taskService; } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java index 85bce85332..7d14db6972 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementServiceComponent.java @@ -26,7 +26,6 @@ import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.ntask.core.service.TaskService; import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint; -import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import org.wso2.carbon.policy.mgt.core.PolicyManagerServiceImpl; import org.wso2.carbon.policy.mgt.core.config.PolicyConfigurationManager; @@ -58,12 +57,6 @@ import org.wso2.carbon.user.core.service.RealmService; * policy="dynamic" * bind="setDeviceManagementService" * unbind="unsetDeviceManagementService" - * @scr.reference name="org.wso2.carbon.policy.mgt.common.policy.monitor" - * interface="org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService" - * cardinality="0..n" - * policy="dynamic" - * bind="setPolicyMonitoringService" - * unbind="unsetPolicyMonitoringService" * @scr.reference name="ntask.component" * interface="org.wso2.carbon.ntask.core.service.TaskService" * cardinality="1..1" @@ -183,24 +176,6 @@ public class PolicyManagementServiceComponent { PolicyManagementDataHolder.getInstance().setDeviceManagementService(null); } - - protected void setPolicyMonitoringService(PolicyMonitoringService policyMonitoringService) { - if (log.isDebugEnabled()) { - log.debug("Setting Policy Monitoring Service for " + policyMonitoringService.getType()); - } - // TODO: FIX THE device type by taking from properties - PolicyManagementDataHolder.getInstance().setPolicyMonitoringService(policyMonitoringService.getType(), - policyMonitoringService); - } - - protected void unsetPolicyMonitoringService(PolicyMonitoringService policyMonitoringService) { - if (log.isDebugEnabled()) { - log.debug("Removing the Policy Monitoring Service for " + policyMonitoringService.getType()); - } - // TODO: FIX THE device type by taking from properties - PolicyManagementDataHolder.getInstance().unsetPolicyMonitoringService(policyMonitoringService.getType()); - } - protected void setTaskService(TaskService taskService) { if (log.isDebugEnabled()) { log.debug("Setting the task service."); diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/FeatureManager.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/FeatureManager.java index 8ccab296e5..9c4673a84a 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/FeatureManager.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/FeatureManager.java @@ -22,8 +22,8 @@ package org.wso2.carbon.policy.mgt.core.mgt; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.policy.mgt.common.FeatureManagementException; -import org.wso2.carbon.policy.mgt.common.Profile; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/MonitoringManager.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/MonitoringManager.java index 3eb809d2ae..4843689c22 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/MonitoringManager.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/MonitoringManager.java @@ -21,9 +21,9 @@ package org.wso2.carbon.policy.mgt.core.mgt; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import java.util.List; @@ -35,7 +35,7 @@ public interface MonitoringManager { boolean isCompliant(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; - ComplianceData getDevicePolicyCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + NonComplianceData getDevicePolicyCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; void addMonitoringOperation(List devices) throws PolicyComplianceException; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/PolicyManager.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/PolicyManager.java index b9cfe358ae..8f18a89ffd 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/PolicyManager.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/PolicyManager.java @@ -19,8 +19,7 @@ package org.wso2.carbon.policy.mgt.core.mgt; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.core.dto.DeviceType; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; import java.util.HashMap; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/ProfileManager.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/ProfileManager.java index 11d1ffd882..43a83b6b33 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/ProfileManager.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/ProfileManager.java @@ -19,7 +19,7 @@ package org.wso2.carbon.policy.mgt.core.mgt; -import org.wso2.carbon.policy.mgt.common.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; import org.wso2.carbon.policy.mgt.common.ProfileManagementException; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/FeatureManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/FeatureManagerImpl.java index ee4102bfc9..edaceae3f8 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/FeatureManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/FeatureManagerImpl.java @@ -21,10 +21,9 @@ package org.wso2.carbon.policy.mgt.core.mgt.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.Feature; -import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.policy.mgt.common.FeatureManagementException; -import org.wso2.carbon.policy.mgt.common.Profile; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import org.wso2.carbon.policy.mgt.core.dao.FeatureDAO; import org.wso2.carbon.policy.mgt.core.dao.FeatureManagerDAOException; import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java index 58783e97fb..edab86d1ce 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java @@ -26,15 +26,18 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.InvalidDeviceException; 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.policy.mgt.PolicyMonitoringManager; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration; import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import org.wso2.carbon.policy.mgt.common.monitor.*; -import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; import org.wso2.carbon.policy.mgt.core.dao.*; import org.wso2.carbon.policy.mgt.core.impl.ComplianceDecisionPointImpl; import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder; @@ -80,15 +83,15 @@ public class MonitoringManagerImpl implements MonitoringManager { Device device = service.getDevice(deviceIdentifier); Policy policy = manager.getAppliedPolicyToDevice(deviceIdentifier); if (policy != null) { - PolicyMonitoringService monitoringService = PolicyManagementDataHolder.getInstance(). - getPolicyMonitoringService(deviceIdentifier.getType()); + PolicyMonitoringManager monitoringService = PolicyManagementDataHolder.getInstance(). + getDeviceManagementService().getPolicyMonitoringManager(deviceIdentifier.getType()); - ComplianceData complianceData; + NonComplianceData complianceData; // This was retrieved from database because compliance id must be present for other dao operations to // run. try { PolicyManagementDAOFactory.openConnection(); - ComplianceData cmd = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo().getId()); + NonComplianceData cmd = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo().getId()); complianceData = monitoringService.checkPolicyCompliance(deviceIdentifier, policy, deviceResponse); @@ -177,7 +180,7 @@ public class MonitoringManagerImpl implements MonitoringManager { PolicyManagementDataHolder.getInstance().getDeviceManagementService(); Device device = service.getDevice(deviceIdentifier); PolicyManagementDAOFactory.openConnection(); - ComplianceData complianceData = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo() + NonComplianceData complianceData = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo() .getId()); if (complianceData == null || !complianceData.isStatus()) { return false; @@ -198,9 +201,9 @@ public class MonitoringManagerImpl implements MonitoringManager { } @Override - public ComplianceData getDevicePolicyCompliance(DeviceIdentifier deviceIdentifier) throws + public NonComplianceData getDevicePolicyCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { - ComplianceData complianceData; + NonComplianceData complianceData; try { PolicyManagementDAOFactory.openConnection(); DeviceManagementProviderService service = @@ -231,18 +234,18 @@ public class MonitoringManagerImpl implements MonitoringManager { //int tenantId = PolicyManagerUtil.getTenantId(); Map deviceIds = new HashMap<>(); - List complianceDatas = new ArrayList<>(); + List complianceDatas = new ArrayList<>(); HashMap devicePolicyIdMap = new HashMap<>(); try { PolicyManagementDAOFactory.openConnection(); //TODO: Return a map from getCompliance to reduce O(n^2) -> O(n) - List cd = monitoringDAO.getCompliance(); + List cd = monitoringDAO.getCompliance(); for (Device device : devices) { deviceIds.put(device.getId(), device); - for (ComplianceData data : cd) { + for (NonComplianceData data : cd) { if (device.getId() == data.getDeviceId() && device.getEnrolmentInfo().getId() == data .getEnrolmentId()) { complianceDatas.add(data); @@ -276,11 +279,11 @@ public class MonitoringManagerImpl implements MonitoringManager { List firstTimeDevices = new ArrayList<>(); - Map tempMap = new HashMap<>(); + Map tempMap = new HashMap<>(); try { if (complianceDatas != null || !complianceDatas.isEmpty()) { - for (ComplianceData complianceData : complianceDatas) { + for (NonComplianceData complianceData : complianceDatas) { tempMap.put(complianceData.getDeviceId(), complianceData); diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index 23b1a29420..3614f75697 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -20,12 +20,16 @@ package org.wso2.carbon.policy.mgt.core.mgt.impl; 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.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException; +import org.wso2.carbon.device.mgt.common.policy.mgt.DeviceGroupWrapper; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyCriterion; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; 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; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/ProfileManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/ProfileManagerImpl.java index f99de9bc95..ada8b58763 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/ProfileManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/ProfileManagerImpl.java @@ -20,14 +20,10 @@ package org.wso2.carbon.policy.mgt.core.mgt.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.core.dao.DeviceDAO; -import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO; -import org.wso2.carbon.device.mgt.core.dto.DeviceType; -import org.wso2.carbon.policy.mgt.common.Profile; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import org.wso2.carbon.policy.mgt.common.ProfileManagementException; import org.wso2.carbon.policy.mgt.core.dao.*; import org.wso2.carbon.policy.mgt.core.mgt.ProfileManager; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java index 17b314865e..eb28b9e7d8 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java @@ -23,12 +23,12 @@ 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.EnrolmentInfo; +import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.ntask.core.Task; -import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; -import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder; import org.wso2.carbon.policy.mgt.core.mgt.MonitoringManager; @@ -80,8 +80,9 @@ public class MonitoringTask implements Task { if (log.isDebugEnabled()) { log.debug("Running task for device type : " + deviceType); } - PolicyMonitoringService monitoringService = - PolicyManagementDataHolder.getInstance().getPolicyMonitoringService(deviceType); + PolicyMonitoringManager monitoringService = + PolicyManagementDataHolder.getInstance().getDeviceManagementService() + .getPolicyMonitoringManager(deviceType); List devices = deviceManagementProviderService.getAllDevices(deviceType); if (monitoringService != null && !devices.isEmpty()) { List notifiableDevices = new ArrayList<>(); @@ -110,7 +111,6 @@ public class MonitoringTask implements Task { } if (!notifiableDevices.isEmpty()) { monitoringManager.addMonitoringOperation(notifiableDevices); - monitoringService.notifyDevices(notifiableDevices); } } } @@ -135,8 +135,11 @@ public class MonitoringTask implements Task { */ private boolean isPlatformExist(String deviceType) { - PolicyConfiguration policyConfiguration = - DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getPolicyConfiguration(); - return (policyConfiguration.getPlatforms().contains(deviceType)); + PolicyMonitoringManager policyMonitoringManager = PolicyManagementDataHolder.getInstance() + .getDeviceManagementService().getPolicyMonitoringManager(deviceType); + if (policyMonitoringManager != null) { + return true; + } + return false; } } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java index 7f96729c7e..80358fa86c 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java @@ -22,7 +22,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; import org.wso2.carbon.device.mgt.common.Device; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationManagementException; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; @@ -34,9 +33,9 @@ import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration; import org.wso2.carbon.device.mgt.core.config.tenant.PlatformConfigurationManagementServiceImpl; import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig; import org.wso2.carbon.policy.mgt.core.config.datasource.JNDILookupDefinition; import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/MonitoringTestCase.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/MonitoringTestCase.java index 5f58374020..889a29415a 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/MonitoringTestCase.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/MonitoringTestCase.java @@ -32,15 +32,15 @@ import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; -import org.wso2.carbon.policy.mgt.common.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; import org.wso2.carbon.policy.mgt.common.PolicyManagementException; -import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder; import org.wso2.carbon.policy.mgt.core.mgt.MonitoringManager; import org.wso2.carbon.policy.mgt.core.mgt.PolicyManager; import org.wso2.carbon.policy.mgt.core.mgt.impl.MonitoringManagerImpl; import org.wso2.carbon.policy.mgt.core.mgt.impl.PolicyManagerImpl; -import org.wso2.carbon.policy.mgt.core.services.PolicyMonitoringServiceTest; +import org.wso2.carbon.policy.mgt.core.services.PolicyMonitoringManagerTest; import java.util.List; @@ -154,9 +154,10 @@ public class MonitoringTestCase extends BasePolicyManagementDAOTest { PolicyComplianceException { - PolicyMonitoringServiceTest monitoringServiceTest = new PolicyMonitoringServiceTest(); - PolicyManagementDataHolder.getInstance().setPolicyMonitoringService(monitoringServiceTest.getType(), - monitoringServiceTest); + PolicyMonitoringManagerTest monitoringServiceTest = new PolicyMonitoringManagerTest(); + TestDeviceManagementProviderService deviceManagementProviderService = new TestDeviceManagementProviderService(); + deviceManagementProviderService.setPolicyMonitoringManager(monitoringServiceTest); + PolicyManagementDataHolder.getInstance().setDeviceManagementService(deviceManagementProviderService); DeviceManagementProviderService adminService = new DeviceManagementProviderServiceImpl(); @@ -170,8 +171,6 @@ public class MonitoringTestCase extends BasePolicyManagementDAOTest { log.debug(device.getName()); } - monitoringServiceTest.notifyDevices(devices); - PolicyManager manager = new PolicyManagerImpl(); Policy policy = null; @@ -189,15 +188,15 @@ public class MonitoringTestCase extends BasePolicyManagementDAOTest { public void checkCompliance() throws DeviceManagementException, PolicyComplianceException, PolicyManagementException { - PolicyMonitoringServiceTest monitoringServiceTest = new PolicyMonitoringServiceTest(); - PolicyManagementDataHolder.getInstance().setPolicyMonitoringService(monitoringServiceTest.getType(), - monitoringServiceTest); + PolicyMonitoringManagerTest monitoringServiceTest = new PolicyMonitoringManagerTest(); + TestDeviceManagementProviderService deviceManagementProviderService = new TestDeviceManagementProviderService(); + deviceManagementProviderService.setPolicyMonitoringManager(monitoringServiceTest); + PolicyManagementDataHolder.getInstance().setDeviceManagementService(deviceManagementProviderService); + DeviceManagementProviderService adminService = new DeviceManagementProviderServiceImpl(); - List devices = adminService.getAllDevices(); - DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); deviceIdentifier.setId(devices.get(0).getDeviceIdentifier()); deviceIdentifier.setType(devices.get(0).getType()); diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyDAOTestCase.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyDAOTestCase.java index b323735b69..04d4cfdf43 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyDAOTestCase.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyDAOTestCase.java @@ -24,6 +24,10 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.Feature; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyCriterion; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import org.wso2.carbon.device.mgt.core.dao.*; import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyEvaluationTestCase.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyEvaluationTestCase.java index e97030301d..e60bb6deaf 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyEvaluationTestCase.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyEvaluationTestCase.java @@ -27,6 +27,7 @@ import org.testng.annotations.Test; 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.policy.mgt.Policy; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; import org.wso2.carbon.ntask.common.TaskException; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/TestDeviceManagementProviderService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/TestDeviceManagementProviderService.java new file mode 100644 index 0000000000..8ec457307c --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/TestDeviceManagementProviderService.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2016, 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.policy.mgt.core; + +import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; +import org.wso2.carbon.policy.mgt.core.services.PolicyMonitoringManagerTest; + +public class TestDeviceManagementProviderService extends DeviceManagementProviderServiceImpl { + private PolicyMonitoringManager policyMonitoringManager; + + @Override + public PolicyMonitoringManager getPolicyMonitoringManager(String deviceType) { + return policyMonitoringManager; + } + + public void setPolicyMonitoringManager(PolicyMonitoringManager policyMonitoringManager) { + this.policyMonitoringManager = policyMonitoringManager; + } +} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/services/PolicyMonitoringServiceTest.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/services/PolicyMonitoringManagerTest.java similarity index 66% rename from components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/services/PolicyMonitoringServiceTest.java rename to components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/services/PolicyMonitoringManagerTest.java index f22cb94b7d..2954fc1fa8 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/services/PolicyMonitoringServiceTest.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/services/PolicyMonitoringManagerTest.java @@ -21,30 +21,24 @@ package org.wso2.carbon.policy.mgt.core.services; 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.policy.mgt.common.Policy; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; -import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException; import java.util.ArrayList; import java.util.List; -public class PolicyMonitoringServiceTest implements PolicyMonitoringService { +public class PolicyMonitoringManagerTest implements PolicyMonitoringManager { + + private static final Log log = LogFactory.getLog(PolicyMonitoringManagerTest.class); - private static final Log log = LogFactory.getLog(PolicyMonitoringServiceTest.class); @Override - public void notifyDevices(List devices) throws PolicyComplianceException { - - log.debug("Device notifying is called by the task."); - } - - @Override - public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object response) + public NonComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object response) throws PolicyComplianceException { log.debug("Check compliance is called."); @@ -55,7 +49,7 @@ public class PolicyMonitoringServiceTest implements PolicyMonitoringService { log.debug(deviceIdentifier.getId()); log.debug(deviceIdentifier.getType()); - ComplianceData data = new ComplianceData(); + NonComplianceData data = new NonComplianceData(); List complianceFeatures = new ArrayList<>(); @@ -76,9 +70,4 @@ public class PolicyMonitoringServiceTest implements PolicyMonitoringService { return data; } - - @Override - public String getType() { - return "android"; - } } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/services/SimplePolicyEvaluationTest.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/services/SimplePolicyEvaluationTest.java index 32f4efc212..0d22f62e49 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/services/SimplePolicyEvaluationTest.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/services/SimplePolicyEvaluationTest.java @@ -22,6 +22,8 @@ package org.wso2.carbon.policy.mgt.core.services; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import org.wso2.carbon.policy.mgt.common.*; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import org.wso2.carbon.policy.mgt.core.PolicyManagerServiceImpl; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/util/PolicyCreator.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/util/PolicyCreator.java index 2b86282aaf..9dc81df195 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/util/PolicyCreator.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/util/PolicyCreator.java @@ -18,9 +18,9 @@ package org.wso2.carbon.policy.mgt.core.util; -import org.wso2.carbon.policy.mgt.common.Policy; -import org.wso2.carbon.policy.mgt.common.PolicyCriterion; -import org.wso2.carbon.policy.mgt.common.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.Policy; +import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyCriterion; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; import java.util.ArrayList; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/util/ProfileCreator.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/util/ProfileCreator.java index 9e92c6b7f9..b1d05d969f 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/util/ProfileCreator.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/util/ProfileCreator.java @@ -18,9 +18,8 @@ package org.wso2.carbon.policy.mgt.core.util; -import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.common.Feature; -import org.wso2.carbon.policy.mgt.common.Profile; +import org.wso2.carbon.device.mgt.common.policy.mgt.Profile; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/util/ProfileFeatureCreator.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/util/ProfileFeatureCreator.java index d36d069eb2..ba5d09b37c 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/util/ProfileFeatureCreator.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/util/ProfileFeatureCreator.java @@ -19,7 +19,7 @@ package org.wso2.carbon.policy.mgt.core.util; import org.wso2.carbon.device.mgt.common.Feature; -import org.wso2.carbon.policy.mgt.common.ProfileFeature; +import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature; import java.util.ArrayList; import java.util.List; diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/JWTAuthenticator.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/JWTAuthenticator.java index 9184682d3a..b269f7c285 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/JWTAuthenticator.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/JWTAuthenticator.java @@ -90,6 +90,9 @@ public class JWTAuthenticator implements WebappAuthenticator { if (requestUri == null || "".equals(requestUri)) { authenticationInfo.setStatus(Status.CONTINUE); } + if (requestUri == null) { + requestUri = ""; + } StringTokenizer tokenizer = new StringTokenizer(requestUri, "/"); String context = tokenizer.nextToken(); if (context == null || "".equals(context)) { diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authorizer/WebappTenantAuthorizer.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authorizer/WebappTenantAuthorizer.java index e6a55eba89..26d8ff995d 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authorizer/WebappTenantAuthorizer.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authorizer/WebappTenantAuthorizer.java @@ -43,7 +43,11 @@ public class WebappTenantAuthorizer { } private static boolean isProviderTenant(Request request, String requestTenantDomain) { - String param = request.getContext().findParameter(PROVIDER_TENANT_DOMAIN_PARAM_NAME); + Object tenantDoamin = request.getServletContext().getAttribute(PROVIDER_TENANT_DOMAIN_PARAM_NAME); + String param = null; + if (tenantDoamin != null) { + param = (String)request.getServletContext().getAttribute(PROVIDER_TENANT_DOMAIN_PARAM_NAME); + } return (param == null || requestTenantDomain.equals(param)); } } diff --git a/pom.xml b/pom.xml index ce3c0141a0..25606f6ba1 100644 --- a/pom.xml +++ b/pom.xml @@ -338,6 +338,11 @@ + + org.wso2.carbon + org.wso2.carbon.application.deployer + ${carbon.kernel.version} + org.wso2.carbon org.wso2.carbon.registry.core