Merge branch 'master' into 'master'

Remove policy-ui config from android.xml

See merge request entgra/carbon-device-mgt!531
4.x.x
Dharmakeerthi Lasantha 5 years ago
commit 112e550de5

@ -327,67 +327,6 @@ public interface DeviceTypeManagementService {
@HeaderParam("If-Modified-Since") @HeaderParam("If-Modified-Since")
String ifModifiedSince); String ifModifiedSince);
@GET
@Path("/{type}/ui-policy-configurations")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET",
value = "Get Policy details of a Device Type",
notes = "Get the json object to generate policy configuration form from xml in plugin",
tags = "Device Type Management",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:policies:get-details")
})
}
)
@ApiResponses(
value = {
@ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the policy configurations.",
response = DeviceTypeList.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description =
"Date and time the resource was last modified.\n" +
"Used by caches, or in conditional requests."),
}
),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request.",
response = ErrorResponse.class),
@ApiResponse(
code = 404,
message = "Not Found. \n Policy Configurations data for the specified device type was not found.",
response = ErrorResponse.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the " +
"list of supported device types.",
response = ErrorResponse.class)
}
)
Response getPolicies(
@ApiParam(
name = "type",
value = "The device type name, such as ios, android, windows or fire-alarm.",
required = true)
@PathParam("type")
@Size(min = 2, max = 45)
String type
);
@GET @GET
@Path("/{type}/configs") @Path("/{type}/configs")
@ApiOperation( @ApiOperation(

@ -38,11 +38,9 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
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.ui.policy.mgt.PolicyConfigurationManager;
import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceTypeNotFoundException; import org.wso2.carbon.device.mgt.common.exceptions.DeviceTypeNotFoundException;
import org.wso2.carbon.device.mgt.common.ui.policy.mgt.Policy;
import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.FeatureManager; import org.wso2.carbon.device.mgt.common.FeatureManager;
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
@ -132,46 +130,6 @@ public class DeviceTypeManagementServiceImpl implements DeviceTypeManagementServ
} }
} }
@GET
@Override
@Path("/{type}/ui-policy-configurations")
public Response getPolicies(@PathParam("type") @Size(min = 2, max = 45) String type){
List<Policy> policies;
DeviceManagementProviderService dms;
try {
if (StringUtils.isEmpty(type)) {
String msg = "Device Type cannot be empty.";
log.error(msg);
return Response.status(Response.Status.BAD_REQUEST).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
}
dms = DeviceMgtAPIUtils.getDeviceManagementService();
PolicyConfigurationManager pm = dms.getPolicyUIConfigurationManager(type);
if (pm == null) {
String msg = "No policy manager is registered with the given device type '" + type + "'";
log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
}
policies = pm.getPolicies();
} catch (DeviceManagementException e) {
String msg = "Error occurred while retrieving the [" + type + "] policy details.";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
} catch (DeviceTypeNotFoundException e) {
String msg = "No device type found with name '" + type + "'";
log.error(msg, e);
return Response.status(Response.Status.NOT_FOUND).entity(
new ErrorResponse.ErrorResponseBuilder()
.setMessage(msg).build()).build();
}
return Response.status(Response.Status.OK).entity(policies).build();
}
@GET @GET
@Override @Override
@Path("/{type}/features") @Path("/{type}/features")

@ -38,7 +38,6 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
import org.wso2.carbon.device.mgt.common.ui.policy.mgt.PolicyConfigurationManager;
import java.util.List; import java.util.List;
@ -54,13 +53,6 @@ public interface DeviceManager {
*/ */
FeatureManager getFeatureManager(); FeatureManager getFeatureManager();
/**
* Method to return policy manager implementation associated with a particular platform-specific plugin.
*
* @return Returns an instance of policy configuration manager
*/
PolicyConfigurationManager getPolicyUIConfigurationManager();
/** /**
* Method to save platform specific Configuration. * Method to save platform specific Configuration.
* @param configuration - A Platform configuration object which needs to save * @param configuration - A Platform configuration object which needs to save

@ -2,7 +2,6 @@ package org.wso2.carbon.device.mgt.common.type.mgt;
import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.InitialOperationConfig; import org.wso2.carbon.device.mgt.common.InitialOperationConfig;
import org.wso2.carbon.device.mgt.common.ui.policy.mgt.Policy;
import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
@ -12,7 +11,6 @@ public class DeviceTypeMetaDefinition {
private List<String> properties; private List<String> properties;
private List<Feature> features; private List<Feature> features;
private List<Policy> policies;
private boolean claimable; private boolean claimable;
private PushNotificationConfig pushNotificationConfig; private PushNotificationConfig pushNotificationConfig;
private boolean policyMonitoringEnabled; private boolean policyMonitoringEnabled;
@ -45,14 +43,6 @@ public class DeviceTypeMetaDefinition {
this.features = features; this.features = features;
} }
public List<Policy> getPolicies() {
return policies;
}
public void setPolicies(List<Policy> policies) {
this.policies = policies;
}
public boolean isClaimable() { public boolean isClaimable() {
return claimable; return claimable;
} }

@ -1,110 +0,0 @@
/*
* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.common.ui.policy.mgt;
import javax.xml.bind.annotation.XmlElement;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
@ApiModel(
value = "Policy",
description = "This class carries all information related to a policies."
)
public class Policy implements Serializable {
private static final long serialVersionUID = -2884635400482180628L;
@ApiModelProperty(
name = "id",
value = "Policy Id.",
required = true
)
private int id;
@ApiModelProperty(
name = "name",
value = "A name that describes a policy.",
required = true
)
private String name;
@ApiModelProperty(
name = "description",
value = "Provides a description of the policy.",
required = true
)
private String description;
@ApiModelProperty(
name = "panels",
value = "Properties related to policy.",
required = true
)
private List<DataPanels> panels;
@XmlElement
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@XmlElement
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlElement
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<DataPanels> getPanels() {
return panels;
}
public void setPanels(List<DataPanels> panels) {
this.panels = panels;
}
public static class DataPanels implements Serializable {
private Object panel;
public Object getPanel() {
return panel;
}
public void setPanel(Object value) {
this.panel = value;
}
}
}

@ -1,33 +0,0 @@
/*
* Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.common.ui.policy.mgt;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.ui.policy.mgt.Policy;
import java.util.List;
public interface PolicyConfigurationManager {
/**
* @return Json which include Policies UI configuration details.
*/
List<Policy> getPolicies() throws DeviceManagementException;
}

@ -84,7 +84,6 @@ import org.wso2.carbon.device.mgt.common.policy.mgt.PolicyMonitoringManager;
import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationExecutionFailedException; import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationExecutionFailedException;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.common.ui.policy.mgt.PolicyConfigurationManager;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
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.dto.DeviceTypeVersion; import org.wso2.carbon.device.mgt.core.dto.DeviceTypeVersion;
@ -603,15 +602,6 @@ public interface DeviceManagementProviderService {
FeatureManager getFeatureManager(String deviceType) throws DeviceTypeNotFoundException; FeatureManager getFeatureManager(String deviceType) throws DeviceTypeNotFoundException;
/**
* Proxy method to get the UI configurations of Policies.
*
* @param deviceType Device platform
* @return Policies UI configurations of the particular device type.
* @throws DeviceTypeNotFoundException If device type is not registered.
*/
PolicyConfigurationManager getPolicyUIConfigurationManager(String deviceType) throws DeviceTypeNotFoundException;
/** /**
* Proxy method to get the tenant configuration of a given platform. * Proxy method to get the tenant configuration of a given platform.
* *

@ -122,7 +122,6 @@ import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypePlatformDetails; import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypePlatformDetails;
import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypePlatformVersion; import org.wso2.carbon.device.mgt.common.type.mgt.DeviceTypePlatformVersion;
import org.wso2.carbon.device.mgt.common.ui.policy.mgt.PolicyConfigurationManager;
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;
import org.wso2.carbon.device.mgt.core.cache.DeviceCacheKey; import org.wso2.carbon.device.mgt.core.cache.DeviceCacheKey;
@ -244,17 +243,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
return deviceManager.getFeatureManager(); return deviceManager.getFeatureManager();
} }
@Override
public PolicyConfigurationManager getPolicyUIConfigurationManager(String deviceType) throws DeviceTypeNotFoundException {
DeviceManager deviceManager = this.getDeviceManager(deviceType);
if (deviceManager == null) {
String msg = "Device type '" + deviceType + "' not found.";
log.error(msg);
throw new DeviceTypeNotFoundException(msg);
}
return deviceManager.getPolicyUIConfigurationManager();
}
@Override @Override
public boolean enrollDevice(Device device) throws DeviceManagementException { public boolean enrollDevice(Device device) throws DeviceManagementException {
if (device == null) { if (device == null) {

@ -25,7 +25,6 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
import org.wso2.carbon.device.mgt.common.ui.policy.mgt.PolicyConfigurationManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -40,11 +39,6 @@ public class TestDeviceManager implements DeviceManager {
return null; return null;
} }
@Override
public PolicyConfigurationManager getPolicyUIConfigurationManager() {
return null;
}
@Override @Override
public boolean saveConfiguration(PlatformConfiguration configuration) public boolean saveConfiguration(PlatformConfiguration configuration)
throws DeviceManagementException { throws DeviceManagementException {

@ -49,21 +49,18 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration
import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
import org.wso2.carbon.device.mgt.common.ui.policy.mgt.PolicyConfigurationManager;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.DeviceTypeConfiguration; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.DeviceTypeConfiguration;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.DeviceDetails; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.DeviceDetails;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.DataSource; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.DataSource;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.TableConfig; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.TableConfig;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Table; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Table;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Feature; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Feature;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Policy;
import org.wso2.carbon.device.mgt.extensions.device.type.template.dao.DeviceDAODefinition; import org.wso2.carbon.device.mgt.extensions.device.type.template.dao.DeviceDAODefinition;
import org.wso2.carbon.device.mgt.extensions.device.type.template.dao.DeviceTypePluginDAOManager; import org.wso2.carbon.device.mgt.extensions.device.type.template.dao.DeviceTypePluginDAOManager;
import org.wso2.carbon.device.mgt.extensions.device.type.template.exception.DeviceTypeDeployerPayloadException; import org.wso2.carbon.device.mgt.extensions.device.type.template.exception.DeviceTypeDeployerPayloadException;
import org.wso2.carbon.device.mgt.extensions.device.type.template.exception.DeviceTypeMgtPluginException; import org.wso2.carbon.device.mgt.extensions.device.type.template.exception.DeviceTypeMgtPluginException;
import org.wso2.carbon.device.mgt.extensions.device.type.template.exception.DeviceTypePluginExtensionException; import org.wso2.carbon.device.mgt.extensions.device.type.template.exception.DeviceTypePluginExtensionException;
import org.wso2.carbon.device.mgt.extensions.device.type.template.feature.ConfigurationBasedFeatureManager; import org.wso2.carbon.device.mgt.extensions.device.type.template.feature.ConfigurationBasedFeatureManager;
import org.wso2.carbon.device.mgt.extensions.device.type.template.policy.mgt.ConfigurationBasedPolicyManager;
import org.wso2.carbon.device.mgt.extensions.device.type.template.util.DeviceTypePluginConstants; import org.wso2.carbon.device.mgt.extensions.device.type.template.util.DeviceTypePluginConstants;
import org.wso2.carbon.device.mgt.extensions.device.type.template.util.DeviceTypeUtils; import org.wso2.carbon.device.mgt.extensions.device.type.template.util.DeviceTypeUtils;
import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager; import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager;
@ -106,7 +103,6 @@ public class DeviceTypeManager implements DeviceManager {
+ "mobile"; + "mobile";
private FeatureManager featureManager; private FeatureManager featureManager;
private PolicyConfigurationManager policyManager;
public DeviceTypeManager(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier, public DeviceTypeManager(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier,
DeviceTypeConfiguration deviceTypeConfiguration) { DeviceTypeConfiguration deviceTypeConfiguration) {
@ -116,12 +112,6 @@ public class DeviceTypeManager implements DeviceManager {
List<Feature> features = deviceTypeConfiguration.getFeatures().getFeature(); List<Feature> features = deviceTypeConfiguration.getFeatures().getFeature();
featureManager = new ConfigurationBasedFeatureManager(features); featureManager = new ConfigurationBasedFeatureManager(features);
} }
if (deviceTypeConfiguration.getPolicyUIConfigurations() != null && deviceTypeConfiguration.getPolicyUIConfigurations().
getPolicies() != null) {
List<Policy> policies = deviceTypeConfiguration.getPolicyUIConfigurations().getPolicies();
policyManager = new ConfigurationBasedPolicyManager(policies);
}
if (deviceTypeConfiguration.getDeviceAuthorizationConfig() != null) { if (deviceTypeConfiguration.getDeviceAuthorizationConfig() != null) {
requiredDeviceTypeAuthorization = deviceTypeConfiguration.getDeviceAuthorizationConfig(). requiredDeviceTypeAuthorization = deviceTypeConfiguration.getDeviceAuthorizationConfig().
isAuthorizationRequired(); isAuthorizationRequired();
@ -262,11 +252,6 @@ public class DeviceTypeManager implements DeviceManager {
return featureManager; return featureManager;
} }
@Override
public PolicyConfigurationManager getPolicyUIConfigurationManager(){
return policyManager;
}
@Override @Override
public boolean saveConfiguration(PlatformConfiguration tenantConfiguration) public boolean saveConfiguration(PlatformConfiguration tenantConfiguration)
throws DeviceManagementException { throws DeviceManagementException {

@ -29,8 +29,6 @@ import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Claimab
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.DeviceDetails; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.DeviceDetails;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Properties; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Properties;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Features; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Features;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.PolicyUIConfigurations;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.Policy;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.PolicyMonitoring; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.PolicyMonitoring;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.ProvisioningConfig; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.ProvisioningConfig;
import org.wso2.carbon.device.mgt.extensions.device.type.template.config.PushNotificationProvider; import org.wso2.carbon.device.mgt.extensions.device.type.template.config.PushNotificationProvider;
@ -99,25 +97,6 @@ public class HTTPDeviceTypeManagerService extends DeviceTypeManagerService imple
deviceTypeConfiguration.setFeatures(features); deviceTypeConfiguration.setFeatures(features);
} }
if (deviceTypeMetaDefinition.getPolicies() != null && !deviceTypeMetaDefinition.getPolicies().isEmpty()) {
PolicyUIConfigurations policyUIConfigurations = new PolicyUIConfigurations();
List<org.wso2.carbon.device.mgt.extensions.device.type.template.config.Policy> policyList
= new ArrayList<>();
deviceTypeMetaDefinition.getPolicies().forEach(policy -> {
Policy policyUIconfig = new Policy();
if(policy.getName() != null){
policyUIconfig.setName(policy.getName());
List<String> panelValues = new ArrayList<>();
policy.getPanels().forEach(panelData ->{
panelValues.add(panelData.getPanel().toString());
});
policyList.add(policyUIconfig);
}
});
policyUIConfigurations.addPolicies(policyList);
deviceTypeConfiguration.setPolicyUIConfigurations(policyUIConfigurations);
}
deviceTypeConfiguration.setName(deviceTypeName); deviceTypeConfiguration.setName(deviceTypeName);
//TODO: Add it to the license management service. //TODO: Add it to the license management service.
// if (deviceTypeMetaDefinition.getLicense() != null) { // if (deviceTypeMetaDefinition.getLicense() != null) {

@ -1,51 +0,0 @@
/*
* Copyright (c) 2020, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
*
* Entgra (pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.extensions.device.type.template.policy.mgt;
import org.wso2.carbon.device.mgt.common.ui.policy.mgt.Policy;
import org.wso2.carbon.device.mgt.common.ui.policy.mgt.PolicyConfigurationManager;
import java.util.ArrayList;
import java.util.List;
public class ConfigurationBasedPolicyManager implements PolicyConfigurationManager {
private List<Policy> policies = new ArrayList<>();
public ConfigurationBasedPolicyManager(List<org.wso2.carbon.device.mgt.extensions.device.type.template.config.Policy> policies){
policies.forEach(policy -> {
Policy policyConfiguration = new Policy();
policyConfiguration.setName(policy.getName());
if(policy.getPanels() != null){
List<Policy.DataPanels> panel = new ArrayList<>();
policy.getPanels().parallelStream().forEach(panelData -> {
Policy.DataPanels panelDataEntry = new Policy.DataPanels();
panelDataEntry.setPanel(panelData);
panel.add(panelDataEntry);
});
policyConfiguration.setPanels(panel);
}
this.policies.add(policyConfiguration);
});
}
@Override
public List<Policy> getPolicies() {
return policies;
}
}

@ -22,7 +22,6 @@ import org.testng.Assert;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; 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.ui.policy.mgt.Policy;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;

@ -43,7 +43,6 @@ import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
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.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
import org.wso2.carbon.device.mgt.common.ui.policy.mgt.PolicyConfigurationManager;
import java.util.List; import java.util.List;
@ -54,11 +53,6 @@ public class TypeXDeviceManager implements DeviceManager {
return null; return null;
} }
@Override
public PolicyConfigurationManager getPolicyUIConfigurationManager() {
return null;
}
@Override @Override
public boolean saveConfiguration(PlatformConfiguration configuration) public boolean saveConfiguration(PlatformConfiguration configuration)
throws DeviceManagementException { throws DeviceManagementException {

Loading…
Cancel
Save