mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fixed conflicts and merged
This commit is contained in:
commit
228848075c
@ -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.APIResourceConfiguration;
|
||||||
import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig;
|
import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig;
|
||||||
import org.wso2.carbon.base.MultitenantConstants;
|
import org.wso2.carbon.base.MultitenantConstants;
|
||||||
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.core.util.Utils;
|
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 javax.servlet.ServletContext;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -42,7 +45,6 @@ public class APIPublisherUtil {
|
|||||||
private static final String DEFAULT_API_VERSION = "1.0.0";
|
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 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_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_TRANSPORTS = "managed-api-transports";
|
||||||
private static final String PARAM_MANAGED_API_POLICY = "managed-api-policy";
|
private static final String PARAM_MANAGED_API_POLICY = "managed-api-policy";
|
||||||
private static final String PARAM_MANAGED_API_IS_SECURED = "managed-api-isSecured";
|
private static final String PARAM_MANAGED_API_IS_SECURED = "managed-api-isSecured";
|
||||||
@ -193,7 +195,8 @@ public class APIPublisherUtil {
|
|||||||
* @param apiDef
|
* @param apiDef
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static APIConfig buildApiConfig(ServletContext servletContext, APIResourceConfiguration apiDef) {
|
public static APIConfig buildApiConfig(ServletContext servletContext, APIResourceConfiguration apiDef)
|
||||||
|
throws UserStoreException {
|
||||||
APIConfig apiConfig = new APIConfig();
|
APIConfig apiConfig = new APIConfig();
|
||||||
|
|
||||||
String name = apiDef.getName();
|
String name = apiDef.getName();
|
||||||
@ -233,7 +236,8 @@ public class APIPublisherUtil {
|
|||||||
apiConfig.setTags(tags);
|
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 :
|
tenantDomain = (tenantDomain != null && !tenantDomain.isEmpty()) ? tenantDomain :
|
||||||
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
|
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
|
||||||
apiConfig.setTenantDomain(tenantDomain);
|
apiConfig.setTenantDomain(tenantDomain);
|
||||||
@ -253,7 +257,11 @@ public class APIPublisherUtil {
|
|||||||
}
|
}
|
||||||
apiConfig.setEndpoint(endpoint);
|
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 (owner == null || owner.isEmpty()) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("'managed-api-owner' attribute is not configured");
|
log.debug("'managed-api-owner' attribute is not configured");
|
||||||
@ -275,6 +283,9 @@ public class APIPublisherUtil {
|
|||||||
|
|
||||||
String sharingValueParam = servletContext.getInitParameter(PARAM_SHARED_WITH_ALL_TENANTS);
|
String sharingValueParam = servletContext.getInitParameter(PARAM_SHARED_WITH_ALL_TENANTS);
|
||||||
boolean isSharedWithAllTenants = Boolean.parseBoolean(sharingValueParam);
|
boolean isSharedWithAllTenants = Boolean.parseBoolean(sharingValueParam);
|
||||||
|
if (isSharedWithAllTenants && !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
|
||||||
|
isSharedWithAllTenants = false;
|
||||||
|
}
|
||||||
apiConfig.setSharedWithAllTenants(isSharedWithAllTenants);
|
apiConfig.setSharedWithAllTenants(isSharedWithAllTenants);
|
||||||
|
|
||||||
Set<URITemplate> uriTemplates = new LinkedHashSet<>();
|
Set<URITemplate> uriTemplates = new LinkedHashSet<>();
|
||||||
|
|||||||
@ -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.config.WebappPublisherConfig;
|
||||||
import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder;
|
import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder;
|
||||||
import org.wso2.carbon.apimgt.webapp.publisher.lifecycle.util.AnnotationProcessor;
|
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 javax.servlet.ServletContext;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -106,6 +108,9 @@ public class APIPublisherLifecycleListener implements LifecycleListener {
|
|||||||
log.error("Error encountered while discovering annotated classes", e);
|
log.error("Error encountered while discovering annotated classes", e);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
log.error("Error while scanning class for annotations", 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,6 +66,10 @@
|
|||||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
|
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.application.deployer</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -109,9 +113,13 @@
|
|||||||
org.wso2.carbon.registry.core,
|
org.wso2.carbon.registry.core,
|
||||||
org.wso2.carbon.registry.core.*,
|
org.wso2.carbon.registry.core.*,
|
||||||
org.wso2.carbon.utils.*,
|
org.wso2.carbon.utils.*,
|
||||||
javax.xml.namespace
|
javax.xml.namespace,
|
||||||
|
org.apache.commons.io,
|
||||||
|
org.wso2.carbon.application.deployer.*,
|
||||||
|
org.apache.axis2.engine
|
||||||
</Import-Package>
|
</Import-Package>
|
||||||
<Axis2Deployer>DeviceTypeDeployer</Axis2Deployer>
|
<Axis2Deployer>DeviceTypeDeployer</Axis2Deployer>
|
||||||
|
<!--<WSO2-Application-Deployer>Device Type Capp Deployer</WSO2-Application-Deployer>-->
|
||||||
</instructions>
|
</instructions>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|||||||
@ -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<Artifact> deviceTypePlugins = new ArrayList<Artifact>();
|
||||||
|
private List<Artifact> deviceTypeUIs = new ArrayList<Artifact>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deployArtifacts(CarbonApplication carbonApplication, AxisConfiguration axisConfig)
|
||||||
|
throws DeploymentException {
|
||||||
|
List<Artifact.Dependency> 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<Artifact> 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<Artifact.Dependency> 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<Artifact> 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<CappFile> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -44,12 +44,12 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
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.
|
* 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;
|
private ConfigurationContext configurationContext;
|
||||||
protected Map<String, ServiceRegistration> deviceTypeServiceRegistrations = new ConcurrentHashMap();
|
protected Map<String, ServiceRegistration> deviceTypeServiceRegistrations = new ConcurrentHashMap();
|
||||||
protected Map<String, DeviceTypeConfigIdentifier> deviceTypeConfigurationDataMap = new ConcurrentHashMap();
|
protected Map<String, DeviceTypeConfigIdentifier> deviceTypeConfigurationDataMap = new ConcurrentHashMap();
|
||||||
@ -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<String, String> deviceTypeDeployedUIMap = new ConcurrentHashMap<String, String>();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -41,6 +41,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
* <element name="PushNotificationProvider" type="{}PushNotificationProvider"/>
|
* <element name="PushNotificationProvider" type="{}PushNotificationProvider"/>
|
||||||
* <element name="License" type="{}License"/>
|
* <element name="License" type="{}License"/>
|
||||||
* <element name="DataSource" type="{}DataSource"/>
|
* <element name="DataSource" type="{}DataSource"/>
|
||||||
|
* <element name="PolicyMonitoring" type="{}PolicyMonitoring"/>
|
||||||
* <element name="DeviceAuthorizationConfig" type="{}DeviceAuthorizationConfig"/>
|
* <element name="DeviceAuthorizationConfig" type="{}DeviceAuthorizationConfig"/>
|
||||||
* </sequence>
|
* </sequence>
|
||||||
* <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
|
* <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
|
||||||
@ -71,6 +72,8 @@ public class DeviceTypeConfiguration {
|
|||||||
protected DeviceAuthorizationConfig deviceAuthorizationConfig;
|
protected DeviceAuthorizationConfig deviceAuthorizationConfig;
|
||||||
@XmlAttribute(name = "name")
|
@XmlAttribute(name = "name")
|
||||||
protected String name;
|
protected String name;
|
||||||
|
@XmlElement(name = "PolicyMonitoring", required = true)
|
||||||
|
protected PolicyMonitoring policyMonitoring;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the taskConfiguration property.
|
* Gets the value of the taskConfiguration property.
|
||||||
@ -116,6 +119,26 @@ public class DeviceTypeConfiguration {
|
|||||||
this.deviceDetails = value;
|
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.
|
* Gets the value of the features property.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Java class for PolicyMonitoring complex type.
|
||||||
|
*
|
||||||
|
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* <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>
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.osgi.service.component.ComponentContext;
|
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.registry.core.service.RegistryService;
|
||||||
import org.wso2.carbon.utils.ConfigurationContextService;
|
import org.wso2.carbon.utils.ConfigurationContextService;
|
||||||
|
|
||||||
@ -45,6 +47,7 @@ public class DeviceTypeManagementServiceComponent {
|
|||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Activating DeviceType Deployer Service Component");
|
log.debug("Activating DeviceType Deployer Service Component");
|
||||||
}
|
}
|
||||||
|
// ctx.getBundleContext().registerService(AppDeploymentHandler.class.getName(), new DeviceTypeCAppDeployer(), null);
|
||||||
DeviceTypeManagementDataHolder.getInstance().setBundleContext(ctx.getBundleContext());
|
DeviceTypeManagementDataHolder.getInstance().setBundleContext(ctx.getBundleContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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.app.mgt.ApplicationManager;
|
||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||||
|
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.push.notification.PushNotificationConfig;
|
||||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
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.DeviceTypeConfiguration;
|
||||||
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Property;
|
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.PushNotificationProvider;
|
||||||
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.TaskConfiguration;
|
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.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -54,6 +56,7 @@ public class DeviceTypeManagerService implements DeviceManagementService {
|
|||||||
private String type;
|
private String type;
|
||||||
private OperationMonitoringTaskConfig operationMonitoringConfigs;
|
private OperationMonitoringTaskConfig operationMonitoringConfigs;
|
||||||
private List<MonitoringOperation> monitoringOperations;
|
private List<MonitoringOperation> monitoringOperations;
|
||||||
|
private PolicyMonitoringManager policyMonitoringManager;
|
||||||
|
|
||||||
public DeviceTypeManagerService(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier,
|
public DeviceTypeManagerService(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier,
|
||||||
DeviceTypeConfiguration deviceTypeConfiguration) {
|
DeviceTypeConfiguration deviceTypeConfiguration) {
|
||||||
@ -63,6 +66,10 @@ public class DeviceTypeManagerService implements DeviceManagementService {
|
|||||||
this.populatePushNotificationConfig(deviceTypeConfiguration.getPushNotificationProvider());
|
this.populatePushNotificationConfig(deviceTypeConfiguration.getPushNotificationProvider());
|
||||||
this.operationMonitoringConfigs = new OperationMonitoringTaskConfig();
|
this.operationMonitoringConfigs = new OperationMonitoringTaskConfig();
|
||||||
this.setOperationMonitoringConfig(deviceTypeConfiguration);
|
this.setOperationMonitoringConfig(deviceTypeConfiguration);
|
||||||
|
if (deviceTypeConfiguration.getPolicyMonitoring() != null && deviceTypeConfiguration.getPolicyMonitoring()
|
||||||
|
.isEnabled()) {
|
||||||
|
this.policyMonitoringManager = new DefaultPolicyMonitoringManager();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -145,6 +152,11 @@ public class DeviceTypeManagerService implements DeviceManagementService {
|
|||||||
return pushNotificationConfig;
|
return pushNotificationConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PolicyMonitoringManager getPolicyMonitoringManager() {
|
||||||
|
return policyMonitoringManager;
|
||||||
|
}
|
||||||
|
|
||||||
private void setProvisioningConfig(String tenantDomain, DeviceTypeConfiguration deviceTypeConfiguration) {
|
private void setProvisioningConfig(String tenantDomain, DeviceTypeConfiguration deviceTypeConfiguration) {
|
||||||
if (deviceTypeConfiguration.getProvisioningConfig() != null) {
|
if (deviceTypeConfiguration.getProvisioningConfig() != null) {
|
||||||
boolean sharedWithAllTenants = deviceTypeConfiguration.getProvisioningConfig().isSharedWithAllTenants();
|
boolean sharedWithAllTenants = deviceTypeConfiguration.getProvisioningConfig().isSharedWithAllTenants();
|
||||||
|
|||||||
@ -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<ComplianceFeature> complianceFeatures = (List<ComplianceFeature>) response;
|
||||||
|
List<ComplianceFeature> nonComplianceFeatures = new ArrayList<>();
|
||||||
|
|
||||||
|
for (ComplianceFeature complianceFeature : complianceFeatures) {
|
||||||
|
if (!complianceFeature.isCompliant()) {
|
||||||
|
nonComplianceFeatures.add(complianceFeature);
|
||||||
|
nonComplianceData.setStatus(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nonComplianceData.setComplianceFeatures(nonComplianceFeatures);
|
||||||
|
|
||||||
|
return nonComplianceData;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -25,4 +25,11 @@ public class DeviceTypePluginConstants {
|
|||||||
public static final String MEDIA_TYPE_XML = "application/xml";
|
public static final String MEDIA_TYPE_XML = "application/xml";
|
||||||
public static final String CHARSET_UTF8 = "UTF8";
|
public static final String CHARSET_UTF8 = "UTF8";
|
||||||
public static final String LANGUAGE_CODE_ENGLISH_US = "en_US";
|
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";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,11 @@
|
|||||||
<deployer>
|
<deployer>
|
||||||
<directory>devicetypes</directory>
|
<directory>devicetypes</directory>
|
||||||
<extension>xml</extension>
|
<extension>xml</extension>
|
||||||
<class>org.wso2.carbon.device.mgt.extensions.device.type.deployer.DeviceTypeDeployer</class>
|
<class>org.wso2.carbon.device.mgt.extensions.device.type.deployer.DeviceTypePluginDeployer</class>
|
||||||
</deployer>
|
</deployer>
|
||||||
|
<!--<deployer>-->
|
||||||
|
<!--<directory>devicetypes-ui</directory>-->
|
||||||
|
<!--<class>org.wso2.carbon.device.mgt.extensions.device.type.deployer.DeviceTypeUIDeployer</class>-->
|
||||||
|
<!--</deployer>-->
|
||||||
</deployers>
|
</deployers>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@ -81,12 +81,33 @@
|
|||||||
</ConfigProperties>
|
</ConfigProperties>
|
||||||
</PushNotificationProvider>
|
</PushNotificationProvider>
|
||||||
|
|
||||||
|
<PolicyMonitoring enabled="true"/>
|
||||||
|
|
||||||
<License>
|
<License>
|
||||||
<Language>en_US</Language>
|
<Language>en_US</Language>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
<Text>This is license text</Text>
|
<Text>This is license text</Text>
|
||||||
</License>
|
</License>
|
||||||
|
|
||||||
|
<TaskConfiguration>
|
||||||
|
<Enable>true</Enable>
|
||||||
|
<Frequency>600000</Frequency>
|
||||||
|
<Operations>
|
||||||
|
<Operation>
|
||||||
|
<Name>DEVICE_INFO</Name>
|
||||||
|
<RecurrentTimes>1</RecurrentTimes>
|
||||||
|
</Operation>
|
||||||
|
<Operation>
|
||||||
|
<Name>APPLICATION_LIST</Name>
|
||||||
|
<RecurrentTimes>5</RecurrentTimes>
|
||||||
|
</Operation>
|
||||||
|
<Operation>
|
||||||
|
<Name>DEVICE_LOCATION</Name>
|
||||||
|
<RecurrentTimes>1</RecurrentTimes>
|
||||||
|
</Operation>
|
||||||
|
</Operations>
|
||||||
|
</TaskConfiguration>
|
||||||
|
|
||||||
<DataSource>
|
<DataSource>
|
||||||
<jndiConfig>
|
<jndiConfig>
|
||||||
<name>jdbc/SampleDM_DB</name>
|
<name>jdbc/SampleDM_DB</name>
|
||||||
@ -101,22 +122,5 @@
|
|||||||
</Table>
|
</Table>
|
||||||
</tableConfig>
|
</tableConfig>
|
||||||
</DataSource>
|
</DataSource>
|
||||||
<TaskConfiguration>
|
|
||||||
<Enable>true</Enable>
|
|
||||||
<Frequency>600000</Frequency>
|
|
||||||
<Operations>
|
|
||||||
<Operation>
|
|
||||||
<Name>DEVICE_INFO</Name>
|
|
||||||
<RecurrentTimes>1</RecurrentTimes>
|
|
||||||
</Operation>
|
|
||||||
<Operation>
|
|
||||||
<Name>APPLICATION_LIST</Name>
|
|
||||||
<RecurrentTimes>5</RecurrentTimes>
|
|
||||||
</Operation>
|
|
||||||
<Operation>
|
|
||||||
<Name>DEVICE_LOCATION</Name>
|
|
||||||
<RecurrentTimes>1</RecurrentTimes>
|
|
||||||
</Operation>
|
|
||||||
</Operations>
|
|
||||||
</TaskConfiguration>
|
|
||||||
</DeviceTypeConfiguration>
|
</DeviceTypeConfiguration>
|
||||||
@ -85,7 +85,7 @@ public class MQTTNotificationStrategy implements NotificationStrategy {
|
|||||||
} else {
|
} else {
|
||||||
String topic = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true) + "/"
|
String topic = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true) + "/"
|
||||||
+ ctx.getDeviceId().getType() + "/" + ctx.getDeviceId().getId() + "/" + operation.getType()
|
+ ctx.getDeviceId().getType() + "/" + ctx.getDeviceId().getId() + "/" + operation.getType()
|
||||||
+ "/" + operation.getCode();
|
.toString().toLowerCase() + "/" + operation.getCode();
|
||||||
dynamicProperties.put("topic", topic);
|
dynamicProperties.put("topic", topic);
|
||||||
if (operation.getPayLoad() == null) {
|
if (operation.getPayLoad() == null) {
|
||||||
operation.setPayLoad("");
|
operation.setPayLoad("");
|
||||||
|
|||||||
@ -143,7 +143,8 @@
|
|||||||
org.wso2.carbon.event.output.adapter.core,
|
org.wso2.carbon.event.output.adapter.core,
|
||||||
org.wso2.carbon.event.output.adapter.core.exception,
|
org.wso2.carbon.event.output.adapter.core.exception,
|
||||||
org.osgi.framework,
|
org.osgi.framework,
|
||||||
org.wso2.carbon.core
|
org.wso2.carbon.core,
|
||||||
|
org.wso2.carbon.device.mgt.common.*
|
||||||
</Import-Package>
|
</Import-Package>
|
||||||
</instructions>
|
</instructions>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@ -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_JID = "xmpp.client.jid";
|
||||||
private static final String XMPP_CLIENT_SUBJECT = "xmpp.client.subject";
|
private static final String XMPP_CLIENT_SUBJECT = "xmpp.client.subject";
|
||||||
public static final String XMPP_CLIENT_MESSAGE_TYPE = "xmpp.client.messageType";
|
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 String xmppAdapterName;
|
||||||
private static final Log log = LogFactory.getLog(XMPPNotificationStrategy.class);
|
private static final Log log = LogFactory.getLog(XMPPNotificationStrategy.class);
|
||||||
|
private String subDomain;
|
||||||
|
|
||||||
|
|
||||||
public XMPPNotificationStrategy(PushNotificationConfig config) {
|
public XMPPNotificationStrategy(PushNotificationConfig config) {
|
||||||
|
|
||||||
@ -61,6 +66,7 @@ public class XMPPNotificationStrategy implements NotificationStrategy {
|
|||||||
xmppAdapterProperties.put(XMPPAdapterConstants.XMPP_ADAPTER_PROPERTY_JID, config.getProperty(
|
xmppAdapterProperties.put(XMPPAdapterConstants.XMPP_ADAPTER_PROPERTY_JID, config.getProperty(
|
||||||
XMPPAdapterConstants.XMPP_ADAPTER_PROPERTY_JID));
|
XMPPAdapterConstants.XMPP_ADAPTER_PROPERTY_JID));
|
||||||
outputEventAdapterConfiguration.setStaticProperties(xmppAdapterProperties);
|
outputEventAdapterConfiguration.setStaticProperties(xmppAdapterProperties);
|
||||||
|
subDomain = config.getProperty(XMPPAdapterConstants.XMPP_ADAPTER_PROPERTY_SUBDOMAIN);
|
||||||
try {
|
try {
|
||||||
XMPPDataHolder.getInstance().getOutputEventAdapterService().create(outputEventAdapterConfiguration);
|
XMPPDataHolder.getInstance().getOutputEventAdapterService().create(outputEventAdapterConfiguration);
|
||||||
} catch (OutputEventAdapterException e) {
|
} catch (OutputEventAdapterException e) {
|
||||||
@ -77,9 +83,15 @@ public class XMPPNotificationStrategy implements NotificationStrategy {
|
|||||||
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
|
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
|
||||||
Map<String, String> dynamicProperties = new HashMap<>();
|
Map<String, String> dynamicProperties = new HashMap<>();
|
||||||
Properties properties = ctx.getOperation().getProperties();
|
Properties properties = ctx.getOperation().getProperties();
|
||||||
dynamicProperties.put("jid", properties.getProperty(XMPP_CLIENT_JID));
|
if (properties != null & properties.size() > 0) {
|
||||||
dynamicProperties.put("subject", properties.getProperty(XMPP_CLIENT_SUBJECT));
|
dynamicProperties.put(DYNAMIC_PROPERTY_JID, properties.getProperty(XMPP_CLIENT_JID));
|
||||||
dynamicProperties.put("messageType", properties.getProperty(XMPP_CLIENT_MESSAGE_TYPE));
|
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,
|
XMPPDataHolder.getInstance().getOutputEventAdapterService().publish(xmppAdapterName, dynamicProperties,
|
||||||
ctx.getOperation().getPayLoad());
|
ctx.getOperation().getPayLoad());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,7 @@ public final class XMPPAdapterConstants {
|
|||||||
public static final String SUBJECT_PROPERTY_KEY = "subject";
|
public static final String SUBJECT_PROPERTY_KEY = "subject";
|
||||||
public static final String MESSAGE_TYPE_PROPERTY_KEY = "messageType";
|
public static final String MESSAGE_TYPE_PROPERTY_KEY = "messageType";
|
||||||
public static final String CHAT_PROPERTY_KEY = "chat";
|
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_HOST = "host";
|
||||||
public static final String XMPP_ADAPTER_PROPERTY_PORT = "port";
|
public static final String XMPP_ADAPTER_PROPERTY_PORT = "port";
|
||||||
public static final String XMPP_ADAPTER_PROPERTY_USERNAME = "username";
|
public static final String XMPP_ADAPTER_PROPERTY_USERNAME = "username";
|
||||||
|
|||||||
@ -19,20 +19,20 @@
|
|||||||
package org.wso2.carbon.device.mgt.jaxrs.beans;
|
package org.wso2.carbon.device.mgt.jaxrs.beans;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
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")
|
@ApiModel(value = "DeviceCompliance", description = "Device's policy compliance status")
|
||||||
public class DeviceCompliance {
|
public class DeviceCompliance {
|
||||||
|
|
||||||
private String deviceID;
|
private String deviceID;
|
||||||
private ComplianceData complianceData;
|
private NonComplianceData complianceData;
|
||||||
private Long code;
|
private Long code;
|
||||||
|
|
||||||
public ComplianceData getComplianceData() {
|
public NonComplianceData getComplianceData() {
|
||||||
return complianceData;
|
return complianceData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setComplianceData(ComplianceData complianceData) {
|
public void setComplianceData(NonComplianceData complianceData) {
|
||||||
this.complianceData = complianceData;
|
this.complianceData = complianceData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ package org.wso2.carbon.device.mgt.jaxrs.beans;
|
|||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ package org.wso2.carbon.device.mgt.jaxrs.beans;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
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 javax.validation.constraints.Size;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -39,8 +39,8 @@ 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.DeviceList;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
||||||
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.monitor.ComplianceData;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
|
||||||
|
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
@ -892,7 +892,7 @@ public interface DeviceManagementService {
|
|||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 200,
|
code = 200,
|
||||||
message = "OK",
|
message = "OK",
|
||||||
response = ComplianceData.class),
|
response = NonComplianceData.class),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 400,
|
code = 400,
|
||||||
message = "Bad Request. \n Invalid request or validation error.",
|
message = "Bad Request. \n Invalid request or validation error.",
|
||||||
|
|||||||
@ -35,7 +35,7 @@ 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.PolicyWrapper;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.PriorityUpdatedPolicyWrapper;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.PriorityUpdatedPolicyWrapper;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
||||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
|
|||||||
@ -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.api.DeviceManagementService;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
|
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.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.PolicyManagementException;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
|
||||||
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.PolicyManagerService;
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||||
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
|
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
|
||||||
|
|
||||||
@ -442,7 +442,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|||||||
RequestValidationUtil.validateDeviceIdentifier(type, id);
|
RequestValidationUtil.validateDeviceIdentifier(type, id);
|
||||||
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
|
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
|
||||||
Policy policy;
|
Policy policy;
|
||||||
ComplianceData complianceData = null;
|
NonComplianceData complianceData = null;
|
||||||
DeviceCompliance deviceCompliance = new DeviceCompliance();
|
DeviceCompliance deviceCompliance = new DeviceCompliance();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -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.service.impl.util.RequestValidationUtil;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtUtil;
|
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.PolicyAdministratorPoint;
|
||||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||||
@ -168,7 +168,7 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
|||||||
@Override
|
@Override
|
||||||
public Response getPolicy(@PathParam("id") int id, @HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
public Response getPolicy(@PathParam("id") int id, @HeaderParam("If-Modified-Since") String ifModifiedSince) {
|
||||||
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
|
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
|
||||||
final org.wso2.carbon.policy.mgt.common.Policy policy;
|
final Policy policy;
|
||||||
try {
|
try {
|
||||||
PolicyAdministratorPoint policyAdministratorPoint = policyManagementService.getPAP();
|
PolicyAdministratorPoint policyAdministratorPoint = policyManagementService.getPAP();
|
||||||
policy = policyAdministratorPoint.getPolicy(id);
|
policy = policyAdministratorPoint.getPolicy(id);
|
||||||
@ -378,7 +378,7 @@ public class PolicyManagementServiceImpl implements PolicyManagementService {
|
|||||||
@Override
|
@Override
|
||||||
public Response getEffectivePolicy(@PathParam("deviceId") String deviceId, @PathParam("deviceType") String deviceType) {
|
public Response getEffectivePolicy(@PathParam("deviceId") String deviceId, @PathParam("deviceType") String deviceType) {
|
||||||
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
|
PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService();
|
||||||
final org.wso2.carbon.policy.mgt.common.Policy policy;
|
final Policy policy;
|
||||||
try {
|
try {
|
||||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||||
deviceIdentifier.setId(deviceId);
|
deviceIdentifier.setId(deviceId);
|
||||||
|
|||||||
@ -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.ErrorResponse;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ProfileFeature;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ProfileFeature;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.exception.BadRequestException;
|
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 javax.validation.ConstraintViolation;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -38,9 +38,8 @@ public class DeviceMgtUtil {
|
|||||||
profile.setCreatedDate(mdmProfile.getCreatedDate());
|
profile.setCreatedDate(mdmProfile.getCreatedDate());
|
||||||
profile.setDeviceType(mdmProfile.getDeviceType());
|
profile.setDeviceType(mdmProfile.getDeviceType());
|
||||||
|
|
||||||
List<org.wso2.carbon.policy.mgt.common.ProfileFeature> profileFeatures =
|
List<org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature> profileFeatures =
|
||||||
new ArrayList<org.wso2.carbon.policy.
|
new ArrayList<org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature>(mdmProfile.getProfileFeaturesList().size());
|
||||||
mgt.common.ProfileFeature>(mdmProfile.getProfileFeaturesList().size());
|
|
||||||
for (ProfileFeature mdmProfileFeature : mdmProfile.getProfileFeaturesList()) {
|
for (ProfileFeature mdmProfileFeature : mdmProfile.getProfileFeaturesList()) {
|
||||||
profileFeatures.add(convertProfileFeature(mdmProfileFeature));
|
profileFeatures.add(convertProfileFeature(mdmProfileFeature));
|
||||||
}
|
}
|
||||||
@ -51,11 +50,11 @@ public class DeviceMgtUtil {
|
|||||||
return profile;
|
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) {
|
mdmProfileFeature) {
|
||||||
|
|
||||||
org.wso2.carbon.policy.mgt.common.ProfileFeature profileFeature =
|
org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature profileFeature =
|
||||||
new org.wso2.carbon.policy.mgt.common.ProfileFeature();
|
new org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature();
|
||||||
profileFeature.setProfileId(mdmProfileFeature.getProfileId());
|
profileFeature.setProfileId(mdmProfileFeature.getProfileId());
|
||||||
profileFeature.setContent(mdmProfileFeature.getPayLoad());
|
profileFeature.setContent(mdmProfileFeature.getPayLoad());
|
||||||
profileFeature.setDeviceType(mdmProfileFeature.getDeviceTypeId());
|
profileFeature.setDeviceType(mdmProfileFeature.getDeviceTypeId());
|
||||||
|
|||||||
@ -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.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@ -15,7 +15,7 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* 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.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@ -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.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
@ -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.device.mgt.common.DeviceIdentifier;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
|
|
||||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface PolicyMonitoringService {
|
public interface PolicyMonitoringManager {
|
||||||
|
|
||||||
void notifyDevices(List<Device> devices) throws PolicyComplianceException;
|
NonComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object response)
|
||||||
|
|
||||||
ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object response)
|
|
||||||
throws PolicyComplianceException;
|
throws PolicyComplianceException;
|
||||||
|
|
||||||
String getType();
|
|
||||||
}
|
}
|
||||||
@ -16,11 +16,10 @@
|
|||||||
* under the License.
|
* 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.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
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.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
@ -16,7 +16,7 @@
|
|||||||
* under the License.
|
* 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.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@ -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 {
|
public class ComplianceFeature {
|
||||||
|
|
||||||
@ -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.sql.Timestamp;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ComplianceData {
|
public class NonComplianceData {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private int deviceId;
|
private int deviceId;
|
||||||
@ -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 {
|
public class PolicyComplianceException extends Exception {
|
||||||
|
|
||||||
@ -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.OperationMonitoringTaskConfig;
|
||||||
import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
|
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.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.push.notification.PushNotificationConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,4 +46,6 @@ public interface DeviceManagementService {
|
|||||||
|
|
||||||
PushNotificationConfig getPushNotificationConfig();
|
PushNotificationConfig getPushNotificationConfig();
|
||||||
|
|
||||||
|
PolicyMonitoringManager getPolicyMonitoringManager();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.Activity;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -304,4 +305,6 @@ public interface DeviceManagementProviderService {
|
|||||||
|
|
||||||
boolean isDeviceMonitoringEnabled(String deviceType);
|
boolean isDeviceMonitoringEnabled(String deviceType);
|
||||||
|
|
||||||
|
PolicyMonitoringManager getPolicyMonitoringManager(String deviceType);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.Activity;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
|
||||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||||
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
||||||
import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository;
|
import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository;
|
||||||
@ -1255,6 +1256,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
return operationMonitoringTaskConfig.isEnabled();
|
return operationMonitoringTaskConfig.isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PolicyMonitoringManager getPolicyMonitoringManager(String deviceType) {
|
||||||
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
|
DeviceManagementService dms = pluginRepository.getDeviceManagementService(deviceType, tenantId);
|
||||||
|
return dms.getPolicyMonitoringManager();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Device> getDevicesOfUser(String username) throws DeviceManagementException {
|
public List<Device> getDevicesOfUser(String username) throws DeviceManagementException {
|
||||||
List<Device> devices = new ArrayList<>();
|
List<Device> devices = new ArrayList<>();
|
||||||
|
|||||||
@ -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.OperationMonitoringTaskConfig;
|
||||||
import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
|
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.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.push.notification.PushNotificationConfig;
|
||||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||||
|
|
||||||
@ -69,4 +70,9 @@ public class TestDeviceManagementService implements DeviceManagementService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PolicyMonitoringManager getPolicyMonitoringManager() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -102,7 +102,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr role="row" class="even">
|
<tr role="row" class="even">
|
||||||
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Owner</td>
|
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Owner</td>
|
||||||
<td style="padding:10px 15px;">{{group.owner}}</td>
|
<td id="group_owner" style="padding:10px 15px;">{{group.owner}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr role="row" class="odd">
|
<tr role="row" class="odd">
|
||||||
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Shared with roles</td>
|
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Shared with roles</td>
|
||||||
@ -175,19 +175,42 @@
|
|||||||
<th data-for="By Ownership" class="select-filter"></th>
|
<th data-for="By Ownership" class="select-filter"></th>
|
||||||
<th class="no-sort"></th>
|
<th class="no-sort"></th>
|
||||||
</tr>
|
</tr>
|
||||||
<!--TODO: Enable bulk action row after gain compatibility with iot operation bar-->
|
<tr class="bulk-action-row">
|
||||||
<!--<tr class="bulk-action-row">-->
|
<th colspan="7">
|
||||||
<!--<th colspan="7">-->
|
<ul class="tiles">
|
||||||
<!--<div id="operation-bar" class="hidden">-->
|
{{#unless group}}
|
||||||
<!--{{!unit "mdm.unit.device.operation-bar"}}-->
|
<li>
|
||||||
<!--</div>-->
|
<a href="#" style="width: 100px;height: 80px;;"
|
||||||
<!--<div id="operation-guide" class="bs-callout bs-callout-info">-->
|
data-click-event="remove-form"
|
||||||
<!--<h4>Enabling Device Operations</h4>-->
|
class="btn square-element add-devices-to-group-link"
|
||||||
<!--<p>To enable device operations, select the desired platform from above-->
|
data-toggle="modal" data-target="#modalDemo">
|
||||||
<!--filter.</p>-->
|
<span class="icon fw-stack">
|
||||||
<!--</div>-->
|
<i class="fw fw-ring fw-stack-2x"></i>
|
||||||
<!--</th>-->
|
<i class="fw fw-grouping fw-stack-1x"></i>
|
||||||
<!--</tr>-->
|
</span>
|
||||||
|
Add to Group
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{{/unless}}
|
||||||
|
<li>
|
||||||
|
<a href="#" style="width: 100px;height: 80px;"
|
||||||
|
data-click-event="remove-form"
|
||||||
|
class="btn square-element remove-device-link"
|
||||||
|
data-toggle="modal" data-target="#modalDemo">
|
||||||
|
<span class="icon fw-stack">
|
||||||
|
<i class="fw fw-ring fw-stack-2x"></i>
|
||||||
|
<i class="fw fw-delete fw-stack-1x"></i>
|
||||||
|
</span>
|
||||||
|
{{#if group}}
|
||||||
|
Remove from group
|
||||||
|
{{else}}
|
||||||
|
Remove Device
|
||||||
|
{{/if}}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="ast-container">
|
<tbody id="ast-container">
|
||||||
|
|
||||||
@ -272,7 +295,10 @@
|
|||||||
<a href="{{@app.context}}/group/add" id="group-add-link" class="btn-operations">
|
<a href="{{@app.context}}/group/add" id="group-add-link" class="btn-operations">
|
||||||
Add device group
|
Add device group
|
||||||
</a>
|
</a>
|
||||||
<a href="#" id="group-device-yes-link" class="btn-operations">
|
<a href="#" id="group-device-add-link" class="btn-operations">
|
||||||
|
Add devices to group
|
||||||
|
</a>
|
||||||
|
<a href="#" id="group-device-update-link" class="btn-operations">
|
||||||
Update assignment
|
Update assignment
|
||||||
</a>
|
</a>
|
||||||
<a href="#" id="group-device-cancel-link" class="btn-operations btn-default">
|
<a href="#" id="group-device-cancel-link" class="btn-operations btn-default">
|
||||||
@ -295,7 +321,11 @@
|
|||||||
<div id="remove-device-modal-content" class="hide">
|
<div id="remove-device-modal-content" class="hide">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h3 class="pull-left modal-title">
|
<h3 class="pull-left modal-title">
|
||||||
Do you really want to remove this device from your Devices List?
|
{{#if group}}
|
||||||
|
Do you really want to remove this device(s) from '{{group.name}}' group?
|
||||||
|
{{else}}
|
||||||
|
Do you really want to remove this device(s) from your Devices?
|
||||||
|
{{/if}}
|
||||||
</h3>
|
</h3>
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
|
||||||
class="fw fw-cancel"></i>
|
class="fw fw-cancel"></i>
|
||||||
@ -320,26 +350,11 @@
|
|||||||
<div id="remove-device-200-content" class="hide">
|
<div id="remove-device-200-content" class="hide">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h3 class="pull-left modal-title">
|
<h3 class="pull-left modal-title">
|
||||||
Device was successfully removed.
|
{{#if group}}
|
||||||
</h3>
|
Successfully removed from '{{group.name}}' group.
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
|
{{else}}
|
||||||
class="fw fw-cancel"></i>
|
Successfully removed.
|
||||||
</button>
|
{{/if}}
|
||||||
</div>
|
|
||||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<div class="buttons">
|
|
||||||
<a href="javascript:hidePopup()" class="btn-operations">Ok</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="remove-device-from-group-200-content" class="hide">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h3 class="pull-left modal-title">
|
|
||||||
Device was successfully removed from group.
|
|
||||||
</h3>
|
</h3>
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
|
||||||
class="fw fw-cancel"></i>
|
class="fw fw-cancel"></i>
|
||||||
@ -475,6 +490,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="no-device-selected" class="hide">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-5 col-md-6 col-centered">
|
||||||
|
<h3>Please select one ore more devices in order to perform this
|
||||||
|
operation.</h3>
|
||||||
|
<br/>
|
||||||
|
<div class="buttons">
|
||||||
|
<a href="#" id="no-device-selected-link" class="btn-operations">
|
||||||
|
Ok
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -488,3 +521,19 @@
|
|||||||
type="text/x-handlebars-template"></script>
|
type="text/x-handlebars-template"></script>
|
||||||
{{js "js/listing.js"}}
|
{{js "js/listing.js"}}
|
||||||
{{/zone}}
|
{{/zone}}
|
||||||
|
|
||||||
|
{{#zone "topCss"}}
|
||||||
|
<style>
|
||||||
|
.select2-dropdown {
|
||||||
|
z-index: 999999999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wr-input-control {
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.select2-selection__choice {
|
||||||
|
font-size: medium;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{{/zone}}
|
||||||
|
|||||||
@ -22,7 +22,8 @@
|
|||||||
* initial mode and with out select mode.
|
* initial mode and with out select mode.
|
||||||
*/
|
*/
|
||||||
function InitiateViewOption(url) {
|
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);
|
$(location).attr('href', url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,18 +85,6 @@ $(document).ready(function () {
|
|||||||
return $("#content-filter-types").html();
|
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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -166,7 +155,7 @@ function loadDevices(searchType, searchParam) {
|
|||||||
serviceURL = "/api/device-mgt/v1.0/devices";
|
serviceURL = "/api/device-mgt/v1.0/devices";
|
||||||
} else if (permissionsUtil.hasPermission("LIST_OWN_DEVICES")) {
|
} else if (permissionsUtil.hasPermission("LIST_OWN_DEVICES")) {
|
||||||
//Get authenticated users 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 {
|
} else {
|
||||||
$("#loading-content").remove();
|
$("#loading-content").remove();
|
||||||
$('#device-table').addClass('hidden');
|
$('#device-table').addClass('hidden');
|
||||||
@ -255,18 +244,16 @@ function loadDevices(searchType, searchParam) {
|
|||||||
{
|
{
|
||||||
targets: 0,
|
targets: 0,
|
||||||
data: 'name',
|
data: 'name',
|
||||||
class: 'remove-padding icon-only content-fill',
|
class: 'remove-padding icon-only content-fill viewEnabledIcon',
|
||||||
render: function (data, type, row, meta) {
|
render: function (data, type, row, meta) {
|
||||||
return '<a href="' + context + '/device/' + row.deviceType + '?id=' + row.deviceIdentifier
|
return '<div class="thumbnail icon"><img class="square-element text fw " src="'
|
||||||
+ '"><div class="thumbnail icon"><img class="square-element text fw " src="'
|
+ getDeviceTypeThumb(row.deviceType) + '"/></div>';
|
||||||
+ getDeviceTypeThumb(
|
|
||||||
row.deviceType) + '"/></div></a>';
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
targets: 1,
|
targets: 1,
|
||||||
data: 'name',
|
data: 'name',
|
||||||
class: '',
|
class: 'viewEnabledIcon',
|
||||||
render: function (name, type, row, meta) {
|
render: function (name, type, row, meta) {
|
||||||
var model = getPropertyValue(row.properties, 'DEVICE_MODEL');
|
var model = getPropertyValue(row.properties, 'DEVICE_MODEL');
|
||||||
var vendor = getPropertyValue(row.properties, 'VENDOR');
|
var vendor = getPropertyValue(row.properties, 'VENDOR');
|
||||||
@ -280,12 +267,12 @@ function loadDevices(searchType, searchParam) {
|
|||||||
{
|
{
|
||||||
targets: 2,
|
targets: 2,
|
||||||
data: 'user',
|
data: 'user',
|
||||||
class: 'remove-padding-top',
|
class: 'remove-padding-top viewEnabledIcon'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
targets: 3,
|
targets: 3,
|
||||||
data: 'status',
|
data: 'status',
|
||||||
class: 'remove-padding-top',
|
class: 'remove-padding-top viewEnabledIcon',
|
||||||
render: function (status, type, row, meta) {
|
render: function (status, type, row, meta) {
|
||||||
var html;
|
var html;
|
||||||
switch (status) {
|
switch (status) {
|
||||||
@ -308,7 +295,7 @@ function loadDevices(searchType, searchParam) {
|
|||||||
{
|
{
|
||||||
targets: 4,
|
targets: 4,
|
||||||
data: 'deviceType',
|
data: 'deviceType',
|
||||||
class: 'remove-padding-top',
|
class: 'remove-padding-top viewEnabledIcon',
|
||||||
render: function (status, type, row, meta) {
|
render: function (status, type, row, meta) {
|
||||||
return getDeviceTypeLabel(row.deviceType);
|
return getDeviceTypeLabel(row.deviceType);
|
||||||
}
|
}
|
||||||
@ -316,7 +303,7 @@ function loadDevices(searchType, searchParam) {
|
|||||||
{
|
{
|
||||||
targets: 5,
|
targets: 5,
|
||||||
data: 'ownership',
|
data: 'ownership',
|
||||||
class: 'remove-padding-top',
|
class: 'remove-padding-top viewEnabledIcon',
|
||||||
render: function (status, type, row, meta) {
|
render: function (status, type, row, meta) {
|
||||||
if (getDeviceTypeCategory(row.deviceType) == 'mobile') {
|
if (getDeviceTypeCategory(row.deviceType) == 'mobile') {
|
||||||
return row.ownership;
|
return row.ownership;
|
||||||
@ -357,20 +344,29 @@ function loadDevices(searchType, searchParam) {
|
|||||||
|
|
||||||
html +=
|
html +=
|
||||||
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view edit-device-link" '
|
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view edit-device-link" '
|
||||||
+
|
+ 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
|
||||||
'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
|
+ '" data-devicename="' + row.name + '">'
|
||||||
+ '" data-devicename="' + row.name + '">' +
|
+ '<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>'
|
||||||
'<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>' +
|
+ '<i class="fw fw-edit fw-stack-1x"></i></span>'
|
||||||
'<i class="fw fw-edit fw-stack-1x"></i></span>' +
|
+ '<span class="hidden-xs hidden-on-grid-view">Edit</span></a>';
|
||||||
'<span class="hidden-xs hidden-on-grid-view">Edit</span></a>';
|
var groupOwner = $('#group_owner').text();
|
||||||
html +=
|
if (groupId && groupOwner != "wso2.system.user") {
|
||||||
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-device-link" '
|
html +=
|
||||||
+
|
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-device-link" '
|
||||||
'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
|
+ 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
|
||||||
+ '" data-devicename="' + row.name + '">' +
|
+ '" data-devicename="' + row.name + '">'
|
||||||
'<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>' +
|
+ '<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>'
|
||||||
'<i class="fw fw-delete fw-stack-1x"></i></span>' +
|
+ '<i class="fw fw-delete fw-stack-1x"></i></span>'
|
||||||
'<span class="hidden-xs hidden-on-grid-view">Delete</span>';
|
+ '<span class="hidden-xs hidden-on-grid-view">Remove from group</span>';
|
||||||
|
} else {
|
||||||
|
html +=
|
||||||
|
'<a href="#" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-device-link" '
|
||||||
|
+ 'data-deviceid="' + deviceIdentifier + '" data-devicetype="' + deviceType
|
||||||
|
+ '" data-devicename="' + row.name + '">'
|
||||||
|
+ '<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i>'
|
||||||
|
+ '<i class="fw fw-delete fw-stack-1x"></i></span>'
|
||||||
|
+ '<span class="hidden-xs hidden-on-grid-view">Delete</span>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
@ -380,13 +376,14 @@ function loadDevices(searchType, searchParam) {
|
|||||||
var fnCreatedRow = function (row, data, dataIndex) {
|
var fnCreatedRow = function (row, data, dataIndex) {
|
||||||
$(row).attr('data-type', 'selectable');
|
$(row).attr('data-type', 'selectable');
|
||||||
$(row).attr('data-deviceid', data.deviceIdentifier);
|
$(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 model = getPropertyValue(data.properties, 'DEVICE_MODEL');
|
||||||
var vendor = getPropertyValue(data.properties, 'VENDOR');
|
var vendor = getPropertyValue(data.properties, 'VENDOR');
|
||||||
var owner = data.user;
|
var owner = data.user;
|
||||||
var status = data.status;
|
var status = data.status;
|
||||||
var ownership = data.ownership;
|
var ownership = data.ownership;
|
||||||
var deviceType = data.type;
|
var deviceType = data.deviceType;
|
||||||
var category = getDeviceTypeCategory(deviceType);
|
var category = getDeviceTypeCategory(deviceType);
|
||||||
$.each($('td', row), function (colIndex) {
|
$.each($('td', row), function (colIndex) {
|
||||||
switch (colIndex) {
|
switch (colIndex) {
|
||||||
@ -560,17 +557,13 @@ function markAlreadyAssignedGroups(deviceId, deviceType) {
|
|||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
if (xhr.status == 200) {
|
if (xhr.status == 200) {
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
|
var selectedValues = [];
|
||||||
for (var i = 0; i < data.length; i++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
$('.groupCheckBoxes').each(
|
if (data[i].owner != "wso2.system.user") {
|
||||||
function () {
|
selectedValues.push(data[i].id);
|
||||||
if (data[i].id == $(this).data('groupid')) {
|
}
|
||||||
$(this).attr('checked', true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
$("#groups").val(selectedValues).trigger("change");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
displayErrors(xhr);
|
displayErrors(xhr);
|
||||||
@ -600,7 +593,7 @@ function attachDeviceEvents() {
|
|||||||
$(modalPopupContent).html($('#group-device-modal-content').html());
|
$(modalPopupContent).html($('#group-device-modal-content').html());
|
||||||
$('#user-groups').html(
|
$('#user-groups').html(
|
||||||
'<div style="height:100px" data-state="loading" data-loading-text="Loading..." data-loading-style="icon-only" data-loading-inverse="true"></div>');
|
'<div style="height:100px" data-state="loading" data-loading-text="Loading..." data-loading-style="icon-only" data-loading-inverse="true"></div>');
|
||||||
$("a#group-device-yes-link").hide();
|
$("a#group-device-update-link").hide();
|
||||||
showPopup();
|
showPopup();
|
||||||
|
|
||||||
var serviceURL;
|
var serviceURL;
|
||||||
@ -612,39 +605,39 @@ function attachDeviceEvents() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
invokerUtil.get(serviceURL, function (data) {
|
invokerUtil.get(serviceURL, function (data) {
|
||||||
|
$("a#group-device-add-link").hide();
|
||||||
var groups = JSON.parse(data);
|
var groups = JSON.parse(data);
|
||||||
var html = '';
|
var html = '';
|
||||||
var hasGroups = false;
|
var hasGroups = false;
|
||||||
for (var i = 0; i < groups.deviceGroups.length; i++) {
|
for (var i = 0; i < groups.deviceGroups.length; i++) {
|
||||||
if (groups.deviceGroups[i].owner != "wso2.system.user") {
|
if (groups.deviceGroups[i].owner != "wso2.system.user") {
|
||||||
html += '<div class="wr-input-control"><label class="wr-input-control checkbox">' +
|
html += '<option value="' + groups.deviceGroups[i].id + '">' + groups.deviceGroups[i].name + '</option>';
|
||||||
'<input class="groupCheckBoxes" type="checkbox" data-groupid="' + groups.deviceGroups[i].id + '" />' +
|
|
||||||
'<span class="helper" title="' + groups.deviceGroups[i].name + '">' + groups.deviceGroups[i].name +
|
|
||||||
'</span></label></div>';
|
|
||||||
hasGroups = true;
|
hasGroups = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasGroups) {
|
if (hasGroups) {
|
||||||
html = '<br/><h4>Please select device group(s)</h4><br/>' + html;
|
html = '<br/><h4>Please select device group(s)</h4><br/>' +
|
||||||
|
'<div class="wr-input-control">' +
|
||||||
|
'<select id="groups" class="form-control select2" multiple="multiple">' +
|
||||||
|
html + '</select></div>';
|
||||||
markAlreadyAssignedGroups(deviceId, deviceType);
|
markAlreadyAssignedGroups(deviceId, deviceType);
|
||||||
$("a#group-device-yes-link").show();
|
$("a#group-device-update-link").show();
|
||||||
$("a#group-add-link").hide();
|
$("a#group-add-link").hide();
|
||||||
} else {
|
} else {
|
||||||
$("a#group-device-yes-link").hide();
|
$("a#group-device-update-link").hide();
|
||||||
$("a#group-add-link").show();
|
$("a#group-add-link").show();
|
||||||
html += '<br/><h4>You don\'t have any existing device groups. Please add new device group first.</h4>'
|
html += '<br/><h4>You don\'t have any existing device groups. Please add new device group first.</h4>'
|
||||||
}
|
}
|
||||||
$('#user-groups').html(html);
|
$('#user-groups').html(html);
|
||||||
$("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 deviceIdentifier = {"id": deviceId, "type": deviceType};
|
||||||
var deviceGroupIds = [];
|
var deviceGroupIds = $("#groups").val();
|
||||||
$('.modal .groupCheckBoxes').each(
|
if (!deviceGroupIds) {
|
||||||
function () {
|
deviceGroupIds = [];
|
||||||
if ($(this).is(':checked')) {
|
}
|
||||||
deviceGroupIds.push($(this).data('groupid'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
var deviceToGroupsAssignment = {
|
var deviceToGroupsAssignment = {
|
||||||
deviceIdentifier: deviceIdentifier,
|
deviceIdentifier: deviceIdentifier,
|
||||||
deviceGroupIds: deviceGroupIds
|
deviceGroupIds: deviceGroupIds
|
||||||
@ -684,36 +677,42 @@ function attachDeviceEvents() {
|
|||||||
* on Device Management page in WSO2 MDM Console.
|
* on Device Management page in WSO2 MDM Console.
|
||||||
*/
|
*/
|
||||||
$("a.remove-device-link").click(function () {
|
$("a.remove-device-link").click(function () {
|
||||||
|
var deviceIdentifiers = [];
|
||||||
var deviceId = $(this).data("deviceid");
|
var deviceId = $(this).data("deviceid");
|
||||||
var deviceType = $(this).data("devicetype");
|
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());
|
$(modalPopupContent).html($('#remove-device-modal-content').html());
|
||||||
showPopup();
|
showPopup();
|
||||||
|
|
||||||
$("a#remove-device-yes-link").click(function () {
|
$("a#remove-device-yes-link").click(function () {
|
||||||
if (groupId) {
|
if (groupId) {
|
||||||
var deviceIdentifiers = [{"id": deviceId, "type": deviceType}];
|
var serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices/remove";
|
||||||
serviceURL = "/api/device-mgt/v1.0/groups/id/" + groupId + "/devices/remove";
|
|
||||||
invokerUtil.post(serviceURL, deviceIdentifiers, function (message) {
|
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());
|
$(modalPopupContent).html($('#remove-device-200-content').html());
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
hidePopup();
|
hidePopup();
|
||||||
location.reload(false);
|
location.reload(false);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}, function (message) {
|
}, function (jqXHR) {
|
||||||
displayDeviceErrors(jqXHR);
|
displayDeviceErrors(jqXHR);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
removeDevices(deviceIdentifiers);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -745,7 +744,7 @@ function attachDeviceEvents() {
|
|||||||
hidePopup();
|
hidePopup();
|
||||||
location.reload(false);
|
location.reload(false);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}, function (message) {
|
}, function (jqXHR) {
|
||||||
displayDeviceErrors(jqXHR);
|
displayDeviceErrors(jqXHR);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -754,6 +753,106 @@ function attachDeviceEvents() {
|
|||||||
hidePopup();
|
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(
|
||||||
|
'<div style="height:100px" data-state="loading" data-loading-text="Loading..." data-loading-style="icon-only" data-loading-inverse="true"></div>');
|
||||||
|
$("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 += '<option value="' + groups.deviceGroups[i].id + '">' +
|
||||||
|
groups.deviceGroups[i].name + '</option>';
|
||||||
|
hasGroups = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasGroups) {
|
||||||
|
html = '<br /><select id="assign-group-selector" style="color:#3f3f3f;padding:5px;width:250px;">' +
|
||||||
|
html + '</select>';
|
||||||
|
$("a#group-add-link").hide();
|
||||||
|
$("a#group-device-add-link").show();
|
||||||
|
} else {
|
||||||
|
html += '<br/><h4>You don\'t have any existing device groups. Please add new device group first.</h4>';
|
||||||
|
$("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) {
|
function displayDeviceErrors(jqXHR) {
|
||||||
@ -788,3 +887,23 @@ function getParameterByName(name) {
|
|||||||
results = regex.exec(location.search);
|
results = regex.exec(location.search);
|
||||||
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
|
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;
|
||||||
|
}
|
||||||
@ -23,6 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
function InitiateViewOption(url) {
|
function InitiateViewOption(url) {
|
||||||
if ($(".select-enable-btn").text() == "Select") {
|
if ($(".select-enable-btn").text() == "Select") {
|
||||||
|
url = $(this).parent().data("url");
|
||||||
$(location).attr('href', url);
|
$(location).attr('href', url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,35 +148,30 @@ function loadGroups() {
|
|||||||
return JSON.stringify(json);
|
return JSON.stringify(json);
|
||||||
};
|
};
|
||||||
|
|
||||||
var columns = [{
|
var columns = [
|
||||||
targets: 0,
|
{
|
||||||
data: 'id',
|
targets: 0,
|
||||||
class: 'remove-padding icon-only content-fill',
|
data: 'id',
|
||||||
render: function (data, type, row, meta) {
|
class: 'remove-padding icon-only content-fill viewEnabledIcon',
|
||||||
if ($.hasPermission("VIEW_GROUP_DEVICES")) {
|
render: function (data, type, row, meta) {
|
||||||
return '<a href="devices?groupId=' + row.groupId + '&groupName=' + row.name
|
|
||||||
+ '"><div class="thumbnail icon"><img class="square-element text fw " '
|
|
||||||
+ 'src="public/cdmf.page.groups/images/group-icon.png"/></div></a>';
|
|
||||||
} else {
|
|
||||||
return '<div class="thumbnail icon"><img class="square-element text fw " ' +
|
return '<div class="thumbnail icon"><img class="square-element text fw " ' +
|
||||||
'src="public/cdmf.page.groups/images/group-icon.png"/></div>';
|
'src="public/cdmf.page.groups/images/group-icon.png"/></div>';
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
|
||||||
{
|
{
|
||||||
targets: 1,
|
targets: 1,
|
||||||
data: 'name',
|
data: 'name',
|
||||||
class: ''
|
class: 'viewEnabledIcon'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
targets: 2,
|
targets: 2,
|
||||||
data: 'owner',
|
data: 'owner',
|
||||||
class: 'remove-padding-top',
|
class: 'remove-padding-top viewEnabledIcon'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
targets: 3,
|
targets: 3,
|
||||||
data: 'description',
|
data: 'description',
|
||||||
class: 'remove-padding-top',
|
class: 'remove-padding-top viewEnabledIcon'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
targets: 4,
|
targets: 4,
|
||||||
@ -226,7 +222,9 @@ function loadGroups() {
|
|||||||
|
|
||||||
var fnCreatedRow = function (row, data) {
|
var fnCreatedRow = function (row, data) {
|
||||||
$(row).attr('data-type', 'selectable');
|
$(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) {
|
$.each($('td', row), function (colIndex) {
|
||||||
switch (colIndex) {
|
switch (colIndex) {
|
||||||
case 1:
|
case 1:
|
||||||
|
|||||||
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.policy.evaluator;
|
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 org.wso2.carbon.policy.mgt.common.ProfileFeature;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@ -19,8 +19,8 @@
|
|||||||
package org.wso2.carbon.policy.evaluator;
|
package org.wso2.carbon.policy.evaluator;
|
||||||
|
|
||||||
import org.wso2.carbon.policy.evaluator.utils.Constants;
|
import org.wso2.carbon.policy.evaluator.utils.Constants;
|
||||||
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.ProfileFeature;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -20,7 +20,7 @@ package org.wso2.carbon.policy.evaluator;
|
|||||||
|
|
||||||
import org.wso2.carbon.policy.evaluator.spi.PDPService;
|
import org.wso2.carbon.policy.evaluator.spi.PDPService;
|
||||||
import org.wso2.carbon.policy.mgt.common.Feature;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.policy.evaluator;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.policy.evaluator;
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -21,7 +21,7 @@ package org.wso2.carbon.policy.evaluator.spi;
|
|||||||
|
|
||||||
import org.wso2.carbon.policy.evaluator.FeatureRules;
|
import org.wso2.carbon.policy.evaluator.FeatureRules;
|
||||||
import org.wso2.carbon.policy.mgt.common.Feature;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,9 @@ import org.apache.commons.logging.Log;
|
|||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
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.common.*;
|
||||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||||
import org.wso2.carbon.policy.decision.point.internal.PolicyDecisionPointDataHolder;
|
import org.wso2.carbon.policy.decision.point.internal.PolicyDecisionPointDataHolder;
|
||||||
|
|||||||
@ -19,10 +19,10 @@
|
|||||||
package org.wso2.carbon.policy.decision.point.simple;
|
package org.wso2.carbon.policy.decision.point.simple;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
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.PolicyEvaluationException;
|
||||||
import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
package org.wso2.carbon.policy.decision.point.simple;
|
package org.wso2.carbon.policy.decision.point.simple;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
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.PolicyEvaluationException;
|
||||||
|
|
||||||
public interface SimpleEvaluation {
|
public interface SimpleEvaluation {
|
||||||
|
|||||||
@ -21,6 +21,7 @@ package org.wso2.carbon.policy.decision.point.simple;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
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.decision.point.internal.PolicyDecisionPointDataHolder;
|
||||||
import org.wso2.carbon.policy.mgt.common.*;
|
import org.wso2.carbon.policy.mgt.common.*;
|
||||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||||
|
|||||||
@ -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.DeviceIdentifier;
|
||||||
import org.wso2.carbon.device.mgt.common.Feature;
|
import org.wso2.carbon.device.mgt.common.Feature;
|
||||||
import org.wso2.carbon.policy.mgt.common.PIPDevice;
|
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 org.wso2.carbon.policy.mgt.common.PolicyInformationPoint;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -17,8 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.common;
|
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.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;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,8 @@
|
|||||||
package org.wso2.carbon.policy.mgt.common;
|
package org.wso2.carbon.policy.mgt.common;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
package org.wso2.carbon.policy.mgt.common;
|
package org.wso2.carbon.policy.mgt.common;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
|
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.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|||||||
@ -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.DeviceIdentifier;
|
||||||
import org.wso2.carbon.device.mgt.common.Feature;
|
import org.wso2.carbon.device.mgt.common.Feature;
|
||||||
|
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@ -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.Device;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
@ -38,7 +40,7 @@ public interface ComplianceDecisionPoint {
|
|||||||
|
|
||||||
void setDeviceAsReachable(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException;
|
void setDeviceAsReachable(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException;
|
||||||
|
|
||||||
void reEnforcePolicy(DeviceIdentifier deviceIdentifier, ComplianceData complianceData) throws
|
void reEnforcePolicy(DeviceIdentifier deviceIdentifier, NonComplianceData complianceData) throws
|
||||||
PolicyComplianceException;
|
PolicyComplianceException;
|
||||||
|
|
||||||
void markDeviceAsNoneCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException;
|
void markDeviceAsNoneCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException;
|
||||||
@ -49,7 +51,7 @@ public interface ComplianceDecisionPoint {
|
|||||||
|
|
||||||
void activateDevice(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException;
|
void activateDevice(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException;
|
||||||
|
|
||||||
void validateDevicePolicyCompliance(DeviceIdentifier deviceIdentifier, ComplianceData complianceData) throws
|
void validateDevicePolicyCompliance(DeviceIdentifier deviceIdentifier, NonComplianceData complianceData) throws
|
||||||
PolicyComplianceException;
|
PolicyComplianceException;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -20,8 +20,8 @@ package org.wos2.carbon.policy.mgt.common.utils;
|
|||||||
|
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.Feature;
|
import org.wso2.carbon.device.mgt.common.Feature;
|
||||||
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.Profile;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.Profile;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -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.DeviceIdentifier;
|
||||||
import org.wso2.carbon.device.mgt.common.Feature;
|
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.*;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
|
||||||
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.task.TaskScheduleService;
|
import org.wso2.carbon.policy.mgt.core.task.TaskScheduleService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -75,7 +78,7 @@ public interface PolicyManagerService {
|
|||||||
|
|
||||||
boolean checkCompliance(DeviceIdentifier deviceIdentifier, Object response) throws PolicyComplianceException;
|
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;
|
boolean isCompliant(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.Feature;
|
||||||
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
|
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.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.*;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
|
||||||
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.impl.PolicyAdministratorPointImpl;
|
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.impl.PolicyInformationPointImpl;
|
||||||
import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder;
|
import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder;
|
||||||
@ -210,7 +213,7 @@ public class PolicyManagerServiceImpl implements PolicyManagerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ComplianceData getDeviceCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException {
|
public NonComplianceData getDeviceCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException {
|
||||||
return monitoringManager.getDevicePolicyCompliance(deviceIdentifier);
|
return monitoringManager.getDevicePolicyCompliance(deviceIdentifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.cache;
|
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 org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -21,7 +21,7 @@ package org.wso2.carbon.policy.mgt.core.cache.impl;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.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.PolicyManagementException;
|
||||||
import org.wso2.carbon.policy.mgt.core.cache.PolicyCacheManager;
|
import org.wso2.carbon.policy.mgt.core.cache.PolicyCacheManager;
|
||||||
import org.wso2.carbon.policy.mgt.core.mgt.PolicyManager;
|
import org.wso2.carbon.policy.mgt.core.mgt.PolicyManager;
|
||||||
|
|||||||
@ -20,8 +20,8 @@
|
|||||||
package org.wso2.carbon.policy.mgt.core.dao;
|
package org.wso2.carbon.policy.mgt.core.dao;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.Feature;
|
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.policy.mgt.common.ProfileFeature;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@ -19,11 +19,10 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.dao;
|
package org.wso2.carbon.policy.mgt.core.dao;
|
||||||
|
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
|
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.common.monitor.PolicyDeviceWrapper;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -50,11 +49,11 @@ public interface MonitoringDAO {
|
|||||||
complianceFeatures)
|
complianceFeatures)
|
||||||
throws MonitoringDAOException;
|
throws MonitoringDAOException;
|
||||||
|
|
||||||
ComplianceData getCompliance(int deviceId, int enrolmentId) throws MonitoringDAOException;
|
NonComplianceData getCompliance(int deviceId, int enrolmentId) throws MonitoringDAOException;
|
||||||
|
|
||||||
List<ComplianceData> getCompliance(List<Integer> deviceIds) throws MonitoringDAOException;
|
List<NonComplianceData> getCompliance(List<Integer> deviceIds) throws MonitoringDAOException;
|
||||||
|
|
||||||
List<ComplianceData> getCompliance() throws MonitoringDAOException;
|
List<NonComplianceData> getCompliance() throws MonitoringDAOException;
|
||||||
|
|
||||||
List<ComplianceFeature> getNoneComplianceFeatures(int policyComplianceStatusId) throws MonitoringDAOException;
|
List<ComplianceFeature> getNoneComplianceFeatures(int policyComplianceStatusId) throws MonitoringDAOException;
|
||||||
|
|
||||||
|
|||||||
@ -20,9 +20,9 @@ package org.wso2.carbon.policy.mgt.core.dao;
|
|||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
import org.wso2.carbon.policy.mgt.common.Criterion;
|
import org.wso2.carbon.policy.mgt.common.Criterion;
|
||||||
import org.wso2.carbon.policy.mgt.common.DeviceGroupWrapper;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.DeviceGroupWrapper;
|
||||||
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.PolicyCriterion;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyCriterion;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -19,8 +19,7 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.dao;
|
package org.wso2.carbon.policy.mgt.core.dao;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.Profile;
|
||||||
import org.wso2.carbon.policy.mgt.common.Profile;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@ -22,13 +22,12 @@ package org.wso2.carbon.policy.mgt.core.dao.impl;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
|
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.common.monitor.PolicyDeviceWrapper;
|
||||||
import org.wso2.carbon.policy.mgt.core.dao.MonitoringDAO;
|
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.MonitoringDAOException;
|
||||||
import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory;
|
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.dao.util.PolicyManagementDAOUtil;
|
||||||
import org.wso2.carbon.policy.mgt.core.util.PolicyManagerUtil;
|
import org.wso2.carbon.policy.mgt.core.util.PolicyManagerUtil;
|
||||||
|
|
||||||
@ -237,12 +236,12 @@ public class MonitoringDAOImpl implements MonitoringDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ComplianceData getCompliance(int deviceId, int enrolmentId) throws MonitoringDAOException {
|
public NonComplianceData getCompliance(int deviceId, int enrolmentId) throws MonitoringDAOException {
|
||||||
|
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
ComplianceData complianceData = new ComplianceData();
|
NonComplianceData complianceData = new NonComplianceData();
|
||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -275,11 +274,11 @@ public class MonitoringDAOImpl implements MonitoringDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ComplianceData> getCompliance(List<Integer> deviceIds) throws MonitoringDAOException {
|
public List<NonComplianceData> getCompliance(List<Integer> deviceIds) throws MonitoringDAOException {
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
List<ComplianceData> complianceDataList = new ArrayList<>();
|
List<NonComplianceData> complianceDataList = new ArrayList<>();
|
||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
@ -290,7 +289,7 @@ public class MonitoringDAOImpl implements MonitoringDAO {
|
|||||||
|
|
||||||
resultSet = stmt.executeQuery();
|
resultSet = stmt.executeQuery();
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
ComplianceData complianceData = new ComplianceData();
|
NonComplianceData complianceData = new NonComplianceData();
|
||||||
complianceData.setId(resultSet.getInt("ID"));
|
complianceData.setId(resultSet.getInt("ID"));
|
||||||
complianceData.setDeviceId(resultSet.getInt("DEVICE_ID"));
|
complianceData.setDeviceId(resultSet.getInt("DEVICE_ID"));
|
||||||
complianceData.setEnrolmentId(resultSet.getInt("ENROLMENT_ID"));
|
complianceData.setEnrolmentId(resultSet.getInt("ENROLMENT_ID"));
|
||||||
@ -312,11 +311,11 @@ public class MonitoringDAOImpl implements MonitoringDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ComplianceData> getCompliance() throws MonitoringDAOException {
|
public List<NonComplianceData> getCompliance() throws MonitoringDAOException {
|
||||||
Connection conn;
|
Connection conn;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
List<ComplianceData> complianceDataList = new ArrayList<>();
|
List<NonComplianceData> complianceDataList = new ArrayList<>();
|
||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
@ -326,7 +325,7 @@ public class MonitoringDAOImpl implements MonitoringDAO {
|
|||||||
|
|
||||||
resultSet = stmt.executeQuery();
|
resultSet = stmt.executeQuery();
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
ComplianceData complianceData = new ComplianceData();
|
NonComplianceData complianceData = new NonComplianceData();
|
||||||
complianceData.setId(resultSet.getInt("ID"));
|
complianceData.setId(resultSet.getInt("ID"));
|
||||||
complianceData.setDeviceId(resultSet.getInt("DEVICE_ID"));
|
complianceData.setDeviceId(resultSet.getInt("DEVICE_ID"));
|
||||||
complianceData.setEnrolmentId(resultSet.getInt("ENROLMENT_ID"));
|
complianceData.setEnrolmentId(resultSet.getInt("ENROLMENT_ID"));
|
||||||
|
|||||||
@ -23,9 +23,9 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
import org.wso2.carbon.policy.mgt.common.Criterion;
|
import org.wso2.carbon.policy.mgt.common.Criterion;
|
||||||
import org.wso2.carbon.policy.mgt.common.DeviceGroupWrapper;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.DeviceGroupWrapper;
|
||||||
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.PolicyCriterion;
|
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.PolicyDAO;
|
||||||
import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory;
|
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.PolicyManagerDAOException;
|
||||||
|
|||||||
@ -21,10 +21,8 @@ package org.wso2.carbon.policy.mgt.core.dao.impl;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.Profile;
|
||||||
import org.wso2.carbon.policy.mgt.common.Profile;
|
|
||||||
import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory;
|
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.ProfileDAO;
|
||||||
import org.wso2.carbon.policy.mgt.core.dao.ProfileManagerDAOException;
|
import org.wso2.carbon.policy.mgt.core.dao.ProfileManagerDAOException;
|
||||||
import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil;
|
import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil;
|
||||||
|
|||||||
@ -22,8 +22,8 @@ import org.apache.commons.logging.Log;
|
|||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.mgt.common.Feature;
|
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.policy.mgt.common.ProfileFeature;
|
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.FeatureDAO;
|
||||||
import org.wso2.carbon.policy.mgt.core.dao.FeatureManagerDAOException;
|
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.PolicyManagementDAOFactory;
|
||||||
|
|||||||
@ -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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
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.FeatureManagerDAOException;
|
||||||
import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory;
|
import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory;
|
||||||
import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil;
|
import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil;
|
||||||
|
|||||||
@ -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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
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.FeatureManagerDAOException;
|
||||||
import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory;
|
import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory;
|
||||||
import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil;
|
import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil;
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
package org.wso2.carbon.policy.mgt.core.enforcement;
|
package org.wso2.carbon.policy.mgt.core.enforcement;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@ -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.InvalidDeviceException;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
|
||||||
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
|
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
|
||||||
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
|
|
||||||
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationMgtConstants;
|
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.PolicyAdministratorPoint;
|
||||||
import org.wso2.carbon.policy.mgt.common.PolicyEvaluationException;
|
import org.wso2.carbon.policy.mgt.common.PolicyEvaluationException;
|
||||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||||
|
|||||||
@ -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.PolicyOperation;
|
||||||
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
|
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
|
||||||
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.ComplianceData;
|
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.ComplianceDecisionPoint;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
|
||||||
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.internal.PolicyManagementDataHolder;
|
||||||
import org.wso2.carbon.policy.mgt.core.util.PolicyManagementConstants;
|
import org.wso2.carbon.policy.mgt.core.util.PolicyManagementConstants;
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reEnforcePolicy(DeviceIdentifier deviceIdentifier, ComplianceData complianceData) throws
|
public void reEnforcePolicy(DeviceIdentifier deviceIdentifier, NonComplianceData complianceData) throws
|
||||||
PolicyComplianceException {
|
PolicyComplianceException {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -261,7 +261,7 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void validateDevicePolicyCompliance(DeviceIdentifier deviceIdentifier, ComplianceData complianceData) throws
|
public void validateDevicePolicyCompliance(DeviceIdentifier deviceIdentifier, NonComplianceData complianceData) throws
|
||||||
PolicyComplianceException {
|
PolicyComplianceException {
|
||||||
|
|
||||||
Policy policy = complianceData.getPolicy();
|
Policy policy = complianceData.getPolicy();
|
||||||
|
|||||||
@ -22,6 +22,8 @@ import org.apache.commons.logging.Log;
|
|||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
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.common.TaskException;
|
||||||
import org.wso2.carbon.ntask.core.TaskInfo;
|
import org.wso2.carbon.ntask.core.TaskInfo;
|
||||||
import org.wso2.carbon.ntask.core.TaskManager;
|
import org.wso2.carbon.ntask.core.TaskManager;
|
||||||
|
|||||||
@ -22,8 +22,8 @@ package org.wso2.carbon.policy.mgt.core.impl;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
|
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
|
||||||
import org.wso2.carbon.policy.mgt.common.DeviceGroupWrapper;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.DeviceGroupWrapper;
|
||||||
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.PolicyFilter;
|
import org.wso2.carbon.policy.mgt.common.PolicyFilter;
|
||||||
import org.wso2.carbon.policy.mgt.core.util.PolicyManagementConstants;
|
import org.wso2.carbon.policy.mgt.core.util.PolicyManagementConstants;
|
||||||
|
|
||||||
|
|||||||
@ -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.DeviceManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
|
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.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.dto.DeviceType;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
import org.wso2.carbon.device.mgt.common.Feature;
|
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.policy.mgt.core.mgt.impl.PolicyManagerImpl;
|
||||||
import org.wso2.carbon.user.api.UserRealm;
|
import org.wso2.carbon.user.api.UserRealm;
|
||||||
import org.wso2.carbon.user.api.UserStoreException;
|
import org.wso2.carbon.user.api.UserStoreException;
|
||||||
import org.wso2.carbon.user.api.UserStoreManager;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|||||||
@ -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.ntask.core.service.TaskService;
|
||||||
import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint;
|
import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint;
|
||||||
import org.wso2.carbon.policy.mgt.common.PolicyInformationPoint;
|
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.MonitoringManager;
|
||||||
import org.wso2.carbon.policy.mgt.core.mgt.PolicyManager;
|
import org.wso2.carbon.policy.mgt.core.mgt.PolicyManager;
|
||||||
import org.wso2.carbon.user.core.service.RealmService;
|
import org.wso2.carbon.user.core.service.RealmService;
|
||||||
@ -43,7 +42,6 @@ public class PolicyManagementDataHolder {
|
|||||||
private DeviceManagementProviderService deviceManagementService;
|
private DeviceManagementProviderService deviceManagementService;
|
||||||
private MonitoringManager monitoringManager;
|
private MonitoringManager monitoringManager;
|
||||||
private PolicyManager policyManager;
|
private PolicyManager policyManager;
|
||||||
private Map<String, PolicyMonitoringService> policyMonitoringServiceMap = new HashMap<>();
|
|
||||||
private TaskService taskService;
|
private TaskService taskService;
|
||||||
|
|
||||||
private static PolicyManagementDataHolder thisInstance = new PolicyManagementDataHolder();
|
private static PolicyManagementDataHolder thisInstance = new PolicyManagementDataHolder();
|
||||||
@ -122,18 +120,6 @@ public class PolicyManagementDataHolder {
|
|||||||
this.deviceManagementService = deviceManagementService;
|
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() {
|
public TaskService getTaskService() {
|
||||||
return taskService;
|
return taskService;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
import org.wso2.carbon.ntask.core.service.TaskService;
|
import org.wso2.carbon.ntask.core.service.TaskService;
|
||||||
import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint;
|
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.PolicyManagerService;
|
||||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerServiceImpl;
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerServiceImpl;
|
||||||
import org.wso2.carbon.policy.mgt.core.config.PolicyConfigurationManager;
|
import org.wso2.carbon.policy.mgt.core.config.PolicyConfigurationManager;
|
||||||
@ -58,12 +57,6 @@ import org.wso2.carbon.user.core.service.RealmService;
|
|||||||
* policy="dynamic"
|
* policy="dynamic"
|
||||||
* bind="setDeviceManagementService"
|
* bind="setDeviceManagementService"
|
||||||
* unbind="unsetDeviceManagementService"
|
* 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"
|
* @scr.reference name="ntask.component"
|
||||||
* interface="org.wso2.carbon.ntask.core.service.TaskService"
|
* interface="org.wso2.carbon.ntask.core.service.TaskService"
|
||||||
* cardinality="1..1"
|
* cardinality="1..1"
|
||||||
@ -183,24 +176,6 @@ public class PolicyManagementServiceComponent {
|
|||||||
PolicyManagementDataHolder.getInstance().setDeviceManagementService(null);
|
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) {
|
protected void setTaskService(TaskService taskService) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Setting the task service.");
|
log.debug("Setting the task service.");
|
||||||
|
|||||||
@ -22,8 +22,8 @@ package org.wso2.carbon.policy.mgt.core.mgt;
|
|||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.Feature;
|
import org.wso2.carbon.device.mgt.common.Feature;
|
||||||
import org.wso2.carbon.policy.mgt.common.FeatureManagementException;
|
import org.wso2.carbon.policy.mgt.common.FeatureManagementException;
|
||||||
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.ProfileFeature;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@ -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.Device;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public interface MonitoringManager {
|
|||||||
|
|
||||||
boolean isCompliant(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException;
|
boolean isCompliant(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException;
|
||||||
|
|
||||||
ComplianceData getDevicePolicyCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException;
|
NonComplianceData getDevicePolicyCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException;
|
||||||
|
|
||||||
void addMonitoringOperation(List<Device> devices) throws PolicyComplianceException;
|
void addMonitoringOperation(List<Device> devices) throws PolicyComplianceException;
|
||||||
|
|
||||||
|
|||||||
@ -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.Device;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
|
||||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
|
||||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.mgt;
|
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 org.wso2.carbon.policy.mgt.common.ProfileManagementException;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -21,10 +21,9 @@ package org.wso2.carbon.policy.mgt.core.mgt.impl;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.common.Feature;
|
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.FeatureManagementException;
|
||||||
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.ProfileFeature;
|
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.FeatureDAO;
|
||||||
import org.wso2.carbon.policy.mgt.core.dao.FeatureManagerDAOException;
|
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.PolicyManagementDAOFactory;
|
||||||
|
|||||||
@ -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.InvalidDeviceException;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.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.DeviceConfigurationManager;
|
||||||
import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration;
|
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.operation.mgt.CommandOperation;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
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.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.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.dao.*;
|
||||||
import org.wso2.carbon.policy.mgt.core.impl.ComplianceDecisionPointImpl;
|
import org.wso2.carbon.policy.mgt.core.impl.ComplianceDecisionPointImpl;
|
||||||
import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder;
|
import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder;
|
||||||
@ -80,15 +83,15 @@ public class MonitoringManagerImpl implements MonitoringManager {
|
|||||||
Device device = service.getDevice(deviceIdentifier);
|
Device device = service.getDevice(deviceIdentifier);
|
||||||
Policy policy = manager.getAppliedPolicyToDevice(deviceIdentifier);
|
Policy policy = manager.getAppliedPolicyToDevice(deviceIdentifier);
|
||||||
if (policy != null) {
|
if (policy != null) {
|
||||||
PolicyMonitoringService monitoringService = PolicyManagementDataHolder.getInstance().
|
PolicyMonitoringManager monitoringService = PolicyManagementDataHolder.getInstance().
|
||||||
getPolicyMonitoringService(deviceIdentifier.getType());
|
getDeviceManagementService().getPolicyMonitoringManager(deviceIdentifier.getType());
|
||||||
|
|
||||||
ComplianceData complianceData;
|
NonComplianceData complianceData;
|
||||||
// This was retrieved from database because compliance id must be present for other dao operations to
|
// This was retrieved from database because compliance id must be present for other dao operations to
|
||||||
// run.
|
// run.
|
||||||
try {
|
try {
|
||||||
PolicyManagementDAOFactory.openConnection();
|
PolicyManagementDAOFactory.openConnection();
|
||||||
ComplianceData cmd = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo().getId());
|
NonComplianceData cmd = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo().getId());
|
||||||
complianceData = monitoringService.checkPolicyCompliance(deviceIdentifier,
|
complianceData = monitoringService.checkPolicyCompliance(deviceIdentifier,
|
||||||
policy, deviceResponse);
|
policy, deviceResponse);
|
||||||
|
|
||||||
@ -177,7 +180,7 @@ public class MonitoringManagerImpl implements MonitoringManager {
|
|||||||
PolicyManagementDataHolder.getInstance().getDeviceManagementService();
|
PolicyManagementDataHolder.getInstance().getDeviceManagementService();
|
||||||
Device device = service.getDevice(deviceIdentifier);
|
Device device = service.getDevice(deviceIdentifier);
|
||||||
PolicyManagementDAOFactory.openConnection();
|
PolicyManagementDAOFactory.openConnection();
|
||||||
ComplianceData complianceData = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo()
|
NonComplianceData complianceData = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo()
|
||||||
.getId());
|
.getId());
|
||||||
if (complianceData == null || !complianceData.isStatus()) {
|
if (complianceData == null || !complianceData.isStatus()) {
|
||||||
return false;
|
return false;
|
||||||
@ -198,9 +201,9 @@ public class MonitoringManagerImpl implements MonitoringManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ComplianceData getDevicePolicyCompliance(DeviceIdentifier deviceIdentifier) throws
|
public NonComplianceData getDevicePolicyCompliance(DeviceIdentifier deviceIdentifier) throws
|
||||||
PolicyComplianceException {
|
PolicyComplianceException {
|
||||||
ComplianceData complianceData;
|
NonComplianceData complianceData;
|
||||||
try {
|
try {
|
||||||
PolicyManagementDAOFactory.openConnection();
|
PolicyManagementDAOFactory.openConnection();
|
||||||
DeviceManagementProviderService service =
|
DeviceManagementProviderService service =
|
||||||
@ -231,18 +234,18 @@ public class MonitoringManagerImpl implements MonitoringManager {
|
|||||||
|
|
||||||
//int tenantId = PolicyManagerUtil.getTenantId();
|
//int tenantId = PolicyManagerUtil.getTenantId();
|
||||||
Map<Integer, Device> deviceIds = new HashMap<>();
|
Map<Integer, Device> deviceIds = new HashMap<>();
|
||||||
List<ComplianceData> complianceDatas = new ArrayList<>();
|
List<NonComplianceData> complianceDatas = new ArrayList<>();
|
||||||
HashMap<Integer, Integer> devicePolicyIdMap = new HashMap<>();
|
HashMap<Integer, Integer> devicePolicyIdMap = new HashMap<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PolicyManagementDAOFactory.openConnection();
|
PolicyManagementDAOFactory.openConnection();
|
||||||
//TODO: Return a map from getCompliance to reduce O(n^2) -> O(n)
|
//TODO: Return a map from getCompliance to reduce O(n^2) -> O(n)
|
||||||
List<ComplianceData> cd = monitoringDAO.getCompliance();
|
List<NonComplianceData> cd = monitoringDAO.getCompliance();
|
||||||
|
|
||||||
for (Device device : devices) {
|
for (Device device : devices) {
|
||||||
deviceIds.put(device.getId(), device);
|
deviceIds.put(device.getId(), device);
|
||||||
|
|
||||||
for (ComplianceData data : cd) {
|
for (NonComplianceData data : cd) {
|
||||||
if (device.getId() == data.getDeviceId() && device.getEnrolmentInfo().getId() == data
|
if (device.getId() == data.getDeviceId() && device.getEnrolmentInfo().getId() == data
|
||||||
.getEnrolmentId()) {
|
.getEnrolmentId()) {
|
||||||
complianceDatas.add(data);
|
complianceDatas.add(data);
|
||||||
@ -276,11 +279,11 @@ public class MonitoringManagerImpl implements MonitoringManager {
|
|||||||
|
|
||||||
List<PolicyDeviceWrapper> firstTimeDevices = new ArrayList<>();
|
List<PolicyDeviceWrapper> firstTimeDevices = new ArrayList<>();
|
||||||
|
|
||||||
Map<Integer, ComplianceData> tempMap = new HashMap<>();
|
Map<Integer, NonComplianceData> tempMap = new HashMap<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (complianceDatas != null || !complianceDatas.isEmpty()) {
|
if (complianceDatas != null || !complianceDatas.isEmpty()) {
|
||||||
for (ComplianceData complianceData : complianceDatas) {
|
for (NonComplianceData complianceData : complianceDatas) {
|
||||||
|
|
||||||
tempMap.put(complianceData.getDeviceId(), complianceData);
|
tempMap.put(complianceData.getDeviceId(), complianceData);
|
||||||
|
|
||||||
|
|||||||
@ -20,12 +20,16 @@ package org.wso2.carbon.policy.mgt.core.mgt.impl;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.context.CarbonContext;
|
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
|
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.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.DeviceManagementProviderService;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
|
||||||
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
||||||
|
|||||||
@ -20,14 +20,10 @@ package org.wso2.carbon.policy.mgt.core.mgt.impl;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.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.DeviceManagementDAOFactory;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
||||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.Profile;
|
||||||
import org.wso2.carbon.policy.mgt.common.Profile;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
|
||||||
import org.wso2.carbon.policy.mgt.common.ProfileFeature;
|
|
||||||
import org.wso2.carbon.policy.mgt.common.ProfileManagementException;
|
import org.wso2.carbon.policy.mgt.common.ProfileManagementException;
|
||||||
import org.wso2.carbon.policy.mgt.core.dao.*;
|
import org.wso2.carbon.policy.mgt.core.dao.*;
|
||||||
import org.wso2.carbon.policy.mgt.core.mgt.ProfileManager;
|
import org.wso2.carbon.policy.mgt.core.mgt.ProfileManager;
|
||||||
|
|||||||
@ -23,12 +23,12 @@ import org.apache.commons.logging.Log;
|
|||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
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.DeviceConfigurationManager;
|
||||||
import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration;
|
import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
import org.wso2.carbon.ntask.core.Task;
|
import org.wso2.carbon.ntask.core.Task;
|
||||||
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.common.spi.PolicyMonitoringService;
|
|
||||||
import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder;
|
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.MonitoringManager;
|
||||||
|
|
||||||
@ -80,8 +80,9 @@ public class MonitoringTask implements Task {
|
|||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Running task for device type : " + deviceType);
|
log.debug("Running task for device type : " + deviceType);
|
||||||
}
|
}
|
||||||
PolicyMonitoringService monitoringService =
|
PolicyMonitoringManager monitoringService =
|
||||||
PolicyManagementDataHolder.getInstance().getPolicyMonitoringService(deviceType);
|
PolicyManagementDataHolder.getInstance().getDeviceManagementService()
|
||||||
|
.getPolicyMonitoringManager(deviceType);
|
||||||
List<Device> devices = deviceManagementProviderService.getAllDevices(deviceType);
|
List<Device> devices = deviceManagementProviderService.getAllDevices(deviceType);
|
||||||
if (monitoringService != null && !devices.isEmpty()) {
|
if (monitoringService != null && !devices.isEmpty()) {
|
||||||
List<Device> notifiableDevices = new ArrayList<>();
|
List<Device> notifiableDevices = new ArrayList<>();
|
||||||
@ -110,7 +111,6 @@ public class MonitoringTask implements Task {
|
|||||||
}
|
}
|
||||||
if (!notifiableDevices.isEmpty()) {
|
if (!notifiableDevices.isEmpty()) {
|
||||||
monitoringManager.addMonitoringOperation(notifiableDevices);
|
monitoringManager.addMonitoringOperation(notifiableDevices);
|
||||||
monitoringService.notifyDevices(notifiableDevices);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,8 +135,11 @@ public class MonitoringTask implements Task {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
private boolean isPlatformExist(String deviceType) {
|
private boolean isPlatformExist(String deviceType) {
|
||||||
PolicyConfiguration policyConfiguration =
|
PolicyMonitoringManager policyMonitoringManager = PolicyManagementDataHolder.getInstance()
|
||||||
DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getPolicyConfiguration();
|
.getDeviceManagementService().getPolicyMonitoringManager(deviceType);
|
||||||
return (policyConfiguration.getPlatforms().contains(deviceType));
|
if (policyMonitoringManager != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,6 @@ import org.apache.commons.logging.Log;
|
|||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
|
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.ConfigurationManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
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.config.tenant.PlatformConfigurationManagementServiceImpl;
|
||||||
import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation;
|
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.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.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.DataSourceConfig;
|
||||||
import org.wso2.carbon.policy.mgt.core.config.datasource.JNDILookupDefinition;
|
import org.wso2.carbon.policy.mgt.core.config.datasource.JNDILookupDefinition;
|
||||||
import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil;
|
import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil;
|
||||||
|
|||||||
@ -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.operation.mgt.OperationManagerImpl;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
|
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.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.internal.PolicyManagementDataHolder;
|
||||||
import org.wso2.carbon.policy.mgt.core.mgt.MonitoringManager;
|
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.PolicyManager;
|
||||||
import org.wso2.carbon.policy.mgt.core.mgt.impl.MonitoringManagerImpl;
|
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.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;
|
import java.util.List;
|
||||||
|
|
||||||
@ -154,9 +154,10 @@ public class MonitoringTestCase extends BasePolicyManagementDAOTest {
|
|||||||
PolicyComplianceException {
|
PolicyComplianceException {
|
||||||
|
|
||||||
|
|
||||||
PolicyMonitoringServiceTest monitoringServiceTest = new PolicyMonitoringServiceTest();
|
PolicyMonitoringManagerTest monitoringServiceTest = new PolicyMonitoringManagerTest();
|
||||||
PolicyManagementDataHolder.getInstance().setPolicyMonitoringService(monitoringServiceTest.getType(),
|
TestDeviceManagementProviderService deviceManagementProviderService = new TestDeviceManagementProviderService();
|
||||||
monitoringServiceTest);
|
deviceManagementProviderService.setPolicyMonitoringManager(monitoringServiceTest);
|
||||||
|
PolicyManagementDataHolder.getInstance().setDeviceManagementService(deviceManagementProviderService);
|
||||||
|
|
||||||
DeviceManagementProviderService adminService = new DeviceManagementProviderServiceImpl();
|
DeviceManagementProviderService adminService = new DeviceManagementProviderServiceImpl();
|
||||||
|
|
||||||
@ -170,8 +171,6 @@ public class MonitoringTestCase extends BasePolicyManagementDAOTest {
|
|||||||
log.debug(device.getName());
|
log.debug(device.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
monitoringServiceTest.notifyDevices(devices);
|
|
||||||
|
|
||||||
PolicyManager manager = new PolicyManagerImpl();
|
PolicyManager manager = new PolicyManagerImpl();
|
||||||
Policy policy = null;
|
Policy policy = null;
|
||||||
|
|
||||||
@ -189,15 +188,15 @@ public class MonitoringTestCase extends BasePolicyManagementDAOTest {
|
|||||||
public void checkCompliance() throws DeviceManagementException, PolicyComplianceException,
|
public void checkCompliance() throws DeviceManagementException, PolicyComplianceException,
|
||||||
PolicyManagementException {
|
PolicyManagementException {
|
||||||
|
|
||||||
PolicyMonitoringServiceTest monitoringServiceTest = new PolicyMonitoringServiceTest();
|
PolicyMonitoringManagerTest monitoringServiceTest = new PolicyMonitoringManagerTest();
|
||||||
PolicyManagementDataHolder.getInstance().setPolicyMonitoringService(monitoringServiceTest.getType(),
|
TestDeviceManagementProviderService deviceManagementProviderService = new TestDeviceManagementProviderService();
|
||||||
monitoringServiceTest);
|
deviceManagementProviderService.setPolicyMonitoringManager(monitoringServiceTest);
|
||||||
|
PolicyManagementDataHolder.getInstance().setDeviceManagementService(deviceManagementProviderService);
|
||||||
|
|
||||||
DeviceManagementProviderService adminService = new DeviceManagementProviderServiceImpl();
|
DeviceManagementProviderService adminService = new DeviceManagementProviderServiceImpl();
|
||||||
|
|
||||||
|
|
||||||
List<Device> devices = adminService.getAllDevices();
|
List<Device> devices = adminService.getAllDevices();
|
||||||
|
|
||||||
|
|
||||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||||
deviceIdentifier.setId(devices.get(0).getDeviceIdentifier());
|
deviceIdentifier.setId(devices.get(0).getDeviceIdentifier());
|
||||||
deviceIdentifier.setType(devices.get(0).getType());
|
deviceIdentifier.setType(devices.get(0).getType());
|
||||||
|
|||||||
@ -24,6 +24,10 @@ import org.testng.annotations.BeforeClass;
|
|||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.wso2.carbon.device.mgt.common.*;
|
import org.wso2.carbon.device.mgt.common.*;
|
||||||
import org.wso2.carbon.device.mgt.common.Feature;
|
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.dao.*;
|
||||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import org.testng.annotations.Test;
|
|||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
|
||||||
import org.wso2.carbon.ntask.common.TaskException;
|
import org.wso2.carbon.ntask.common.TaskException;
|
||||||
|
|||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -21,30 +21,24 @@ package org.wso2.carbon.policy.mgt.core.services;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
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.ProfileFeature;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.ProfileFeature;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.NonComplianceData;
|
||||||
import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.ComplianceFeature;
|
||||||
import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.monitor.PolicyComplianceException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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
|
@Override
|
||||||
public void notifyDevices(List<Device> devices) throws PolicyComplianceException {
|
public NonComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object response)
|
||||||
|
|
||||||
log.debug("Device notifying is called by the task.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ComplianceData checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object response)
|
|
||||||
throws PolicyComplianceException {
|
throws PolicyComplianceException {
|
||||||
|
|
||||||
log.debug("Check compliance is called.");
|
log.debug("Check compliance is called.");
|
||||||
@ -55,7 +49,7 @@ public class PolicyMonitoringServiceTest implements PolicyMonitoringService {
|
|||||||
log.debug(deviceIdentifier.getId());
|
log.debug(deviceIdentifier.getId());
|
||||||
log.debug(deviceIdentifier.getType());
|
log.debug(deviceIdentifier.getType());
|
||||||
|
|
||||||
ComplianceData data = new ComplianceData();
|
NonComplianceData data = new NonComplianceData();
|
||||||
|
|
||||||
List<ComplianceFeature> complianceFeatures = new ArrayList<>();
|
List<ComplianceFeature> complianceFeatures = new ArrayList<>();
|
||||||
|
|
||||||
@ -76,9 +70,4 @@ public class PolicyMonitoringServiceTest implements PolicyMonitoringService {
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getType() {
|
|
||||||
return "android";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -22,6 +22,8 @@ package org.wso2.carbon.policy.mgt.core.services;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
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.common.*;
|
||||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerServiceImpl;
|
import org.wso2.carbon.policy.mgt.core.PolicyManagerServiceImpl;
|
||||||
|
|||||||
@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.util;
|
package org.wso2.carbon.policy.mgt.core.util;
|
||||||
|
|
||||||
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.PolicyCriterion;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyCriterion;
|
||||||
import org.wso2.carbon.policy.mgt.common.Profile;
|
import org.wso2.carbon.device.mgt.common.policy.mgt.Profile;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -18,9 +18,8 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.util;
|
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.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 org.wso2.carbon.utils.multitenancy.MultitenantConstants;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
package org.wso2.carbon.policy.mgt.core.util;
|
package org.wso2.carbon.policy.mgt.core.util;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.Feature;
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user