From d2a4fe70b833ec3294200cecc3dc2ec25dd9d9f9 Mon Sep 17 00:00:00 2001 From: "tcdlpds@gmail.com" Date: Fri, 1 May 2020 22:40:12 +0530 Subject: [PATCH] Remove policy-ui config retrieving API from android.xml --- .../api/DeviceTypeManagementService.java | 61 ---------- .../impl/DeviceTypeManagementServiceImpl.java | 42 ------- .../device/mgt/common/DeviceManager.java | 8 -- .../type/mgt/DeviceTypeMetaDefinition.java | 10 -- .../mgt/common/ui/policy/mgt/Policy.java | 110 ------------------ .../mgt/PolicyConfigurationManager.java | 33 ------ .../DeviceManagementProviderService.java | 10 -- .../DeviceManagementProviderServiceImpl.java | 12 -- .../device/mgt/core/TestDeviceManager.java | 6 - .../type/template/DeviceTypeManager.java | 15 --- .../HTTPDeviceTypeManagerService.java | 21 ---- .../mgt/ConfigurationBasedPolicyManager.java | 51 -------- ...rviceAndDeviceTypeGeneratorServceTest.java | 1 - .../mgt/core/mock/TypeXDeviceManager.java | 6 - 14 files changed, 386 deletions(-) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/ui/policy/mgt/Policy.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/ui/policy/mgt/PolicyConfigurationManager.java delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/policy/mgt/ConfigurationBasedPolicyManager.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceTypeManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceTypeManagementService.java index 6981393587..c328433596 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceTypeManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceTypeManagementService.java @@ -327,67 +327,6 @@ public interface DeviceTypeManagementService { @HeaderParam("If-Modified-Since") 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 @Path("/{type}/configs") @ApiOperation( diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceTypeManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceTypeManagementServiceImpl.java index ec8570a7da..393fd31ff5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceTypeManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceTypeManagementServiceImpl.java @@ -38,11 +38,9 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; 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.exceptions.DeviceManagementException; 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.FeatureManager; 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 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 @Override @Path("/{type}/features") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManager.java index aba25cef32..2c7336144f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/DeviceManager.java @@ -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.license.mgt.License; 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; @@ -54,13 +53,6 @@ public interface DeviceManager { */ 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. * @param configuration - A Platform configuration object which needs to save diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java index b4b4027a4f..c49d030e7e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java @@ -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.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.push.notification.PushNotificationConfig; @@ -12,7 +11,6 @@ public class DeviceTypeMetaDefinition { private List properties; private List features; - private List policies; private boolean claimable; private PushNotificationConfig pushNotificationConfig; private boolean policyMonitoringEnabled; @@ -45,14 +43,6 @@ public class DeviceTypeMetaDefinition { this.features = features; } - public List getPolicies() { - return policies; - } - - public void setPolicies(List policies) { - this.policies = policies; - } - public boolean isClaimable() { return claimable; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/ui/policy/mgt/Policy.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/ui/policy/mgt/Policy.java deleted file mode 100644 index bb114d5687..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/ui/policy/mgt/Policy.java +++ /dev/null @@ -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 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 getPanels() { - return panels; - } - - public void setPanels(List 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; - } - - } -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/ui/policy/mgt/PolicyConfigurationManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/ui/policy/mgt/PolicyConfigurationManager.java deleted file mode 100644 index b277028f7a..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/ui/policy/mgt/PolicyConfigurationManager.java +++ /dev/null @@ -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 getPolicies() throws DeviceManagementException; - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java index 86f6c74f75..7c806b7ac5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java @@ -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.push.notification.NotificationStrategy; 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.dto.DeviceType; import org.wso2.carbon.device.mgt.core.dto.DeviceTypeVersion; @@ -603,15 +602,6 @@ public interface DeviceManagementProviderService { 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. * diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 443ff08dca..3726819bb0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -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.type.mgt.DeviceTypePlatformDetails; 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.DeviceManagementPluginRepository; import org.wso2.carbon.device.mgt.core.cache.DeviceCacheKey; @@ -244,17 +243,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv 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 public boolean enrollDevice(Device device) throws DeviceManagementException { if (device == null) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java index 3bb8348621..d9931fd2ca 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/TestDeviceManager.java @@ -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.license.mgt.License; 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.List; @@ -40,11 +39,6 @@ public class TestDeviceManager implements DeviceManager { return null; } - @Override - public PolicyConfigurationManager getPolicyUIConfigurationManager() { - return null; - } - @Override public boolean saveConfiguration(PlatformConfiguration configuration) throws DeviceManagementException { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManager.java index 429ce77454..2a142cdc83 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManager.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/DeviceTypeManager.java @@ -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.LicenseManagementException; 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.DeviceDetails; 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.Table; 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.DeviceTypePluginDAOManager; 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.DeviceTypePluginExtensionException; 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.DeviceTypeUtils; import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager; @@ -106,7 +103,6 @@ public class DeviceTypeManager implements DeviceManager { + "mobile"; private FeatureManager featureManager; - private PolicyConfigurationManager policyManager; public DeviceTypeManager(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier, DeviceTypeConfiguration deviceTypeConfiguration) { @@ -116,12 +112,6 @@ public class DeviceTypeManager implements DeviceManager { List features = deviceTypeConfiguration.getFeatures().getFeature(); featureManager = new ConfigurationBasedFeatureManager(features); } - if (deviceTypeConfiguration.getPolicyUIConfigurations() != null && deviceTypeConfiguration.getPolicyUIConfigurations(). - getPolicies() != null) { - List policies = deviceTypeConfiguration.getPolicyUIConfigurations().getPolicies(); - policyManager = new ConfigurationBasedPolicyManager(policies); - } - if (deviceTypeConfiguration.getDeviceAuthorizationConfig() != null) { requiredDeviceTypeAuthorization = deviceTypeConfiguration.getDeviceAuthorizationConfig(). isAuthorizationRequired(); @@ -262,11 +252,6 @@ public class DeviceTypeManager implements DeviceManager { return featureManager; } - @Override - public PolicyConfigurationManager getPolicyUIConfigurationManager(){ - return policyManager; - } - @Override public boolean saveConfiguration(PlatformConfiguration tenantConfiguration) throws DeviceManagementException { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java index d8c4bdb514..510b03a65b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/HTTPDeviceTypeManagerService.java @@ -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.Properties; 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.ProvisioningConfig; 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); } - if (deviceTypeMetaDefinition.getPolicies() != null && !deviceTypeMetaDefinition.getPolicies().isEmpty()) { - PolicyUIConfigurations policyUIConfigurations = new PolicyUIConfigurations(); - List policyList - = new ArrayList<>(); - deviceTypeMetaDefinition.getPolicies().forEach(policy -> { - Policy policyUIconfig = new Policy(); - if(policy.getName() != null){ - policyUIconfig.setName(policy.getName()); - List panelValues = new ArrayList<>(); - policy.getPanels().forEach(panelData ->{ - panelValues.add(panelData.getPanel().toString()); - }); - policyList.add(policyUIconfig); - } - }); - policyUIConfigurations.addPolicies(policyList); - deviceTypeConfiguration.setPolicyUIConfigurations(policyUIConfigurations); - } - deviceTypeConfiguration.setName(deviceTypeName); //TODO: Add it to the license management service. // if (deviceTypeMetaDefinition.getLicense() != null) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/policy/mgt/ConfigurationBasedPolicyManager.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/policy/mgt/ConfigurationBasedPolicyManager.java deleted file mode 100644 index 0fd311cae1..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/main/java/org/wso2/carbon/device/mgt/extensions/device/type/template/policy/mgt/ConfigurationBasedPolicyManager.java +++ /dev/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 policies = new ArrayList<>(); - - public ConfigurationBasedPolicyManager(List policies){ - policies.forEach(policy -> { - Policy policyConfiguration = new Policy(); - policyConfiguration.setName(policy.getName()); - if(policy.getPanels() != null){ - List 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 getPolicies() { - return policies; - } -} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/java/org/wso2/carbon/device/mgt/extensions/device/type/template/HttpDeviceTypeManagerServiceAndDeviceTypeGeneratorServceTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/java/org/wso2/carbon/device/mgt/extensions/device/type/template/HttpDeviceTypeManagerServiceAndDeviceTypeGeneratorServceTest.java index a7d339ed99..7e7e14efd2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/java/org/wso2/carbon/device/mgt/extensions/device/type/template/HttpDeviceTypeManagerServiceAndDeviceTypeGeneratorServceTest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/java/org/wso2/carbon/device/mgt/extensions/device/type/template/HttpDeviceTypeManagerServiceAndDeviceTypeGeneratorServceTest.java @@ -22,7 +22,6 @@ import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; 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.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/mock/TypeXDeviceManager.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/mock/TypeXDeviceManager.java index cd80192408..d38eb9e881 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/mock/TypeXDeviceManager.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/mock/TypeXDeviceManager.java @@ -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.license.mgt.License; 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; @@ -54,11 +53,6 @@ public class TypeXDeviceManager implements DeviceManager { return null; } - @Override - public PolicyConfigurationManager getPolicyUIConfigurationManager() { - return null; - } - @Override public boolean saveConfiguration(PlatformConfiguration configuration) throws DeviceManagementException {