From 1dcc907ec601692e52bd6e537f78103ff28a803b Mon Sep 17 00:00:00 2001 From: "tcdlpds@gmail.com" Date: Mon, 6 Apr 2020 11:13:16 +0530 Subject: [PATCH] Move device-mgt UI config retrieving API into config-mgt API --- .../DeviceManagementConfigService.java | 26 ++++++++++++++++++ .../DeviceManagementConfigServiceImpl.java | 22 +++++++++++++++ .../src/main/webapp/WEB-INF/web.xml | 3 ++- .../api/ConfigurationManagementService.java | 27 ------------------- .../impl/ConfigurationServiceImpl.java | 20 -------------- .../src/main/webapp/WEB-INF/web.xml | 3 +-- .../interceptor/util/HandlerConstants.java | 2 +- 7 files changed, 52 insertions(+), 51 deletions(-) diff --git a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/java/io/entgra/carbon/device/mgt/config/jaxrs/service/DeviceManagementConfigService.java b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/java/io/entgra/carbon/device/mgt/config/jaxrs/service/DeviceManagementConfigService.java index 14e0e1ded1f..2cf90d46593 100644 --- a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/java/io/entgra/carbon/device/mgt/config/jaxrs/service/DeviceManagementConfigService.java +++ b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/java/io/entgra/carbon/device/mgt/config/jaxrs/service/DeviceManagementConfigService.java @@ -194,4 +194,30 @@ public interface DeviceManagementConfigService { value = "The device transfer request", required = true) DeviceTransferRequest deviceTransferRequest); + + @GET + @Path("/ui-config") + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation( + consumes = MediaType.APPLICATION_JSON, + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "get application management UI configuration", + notes = "This will get all UI configuration of application management" + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully got UI config."), + @ApiResponse( + code = 404, + message = "Not Found. There doesn't have an defined UI config." + + "query."), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Error occurred while getting the UI config.", + response = ErrorResponse.class) + }) + Response getUiConfig(); } diff --git a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/java/io/entgra/carbon/device/mgt/config/jaxrs/service/impl/DeviceManagementConfigServiceImpl.java b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/java/io/entgra/carbon/device/mgt/config/jaxrs/service/impl/DeviceManagementConfigServiceImpl.java index 6fac3b8d8d6..11fc0a2677a 100644 --- a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/java/io/entgra/carbon/device/mgt/config/jaxrs/service/impl/DeviceManagementConfigServiceImpl.java +++ b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/java/io/entgra/carbon/device/mgt/config/jaxrs/service/impl/DeviceManagementConfigServiceImpl.java @@ -38,6 +38,8 @@ import org.wso2.carbon.device.mgt.core.DeviceManagementConstants; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig; import org.wso2.carbon.device.mgt.core.config.keymanager.KeyManagerConfigurations; +import org.wso2.carbon.device.mgt.core.config.ui.UIConfiguration; +import org.wso2.carbon.device.mgt.core.config.ui.UIConfigurationManager; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; @@ -157,6 +159,26 @@ public class DeviceManagementConfigServiceImpl implements DeviceManagementConfig } } + @GET + @Override + @Consumes("application/json") + @Path("/ui-config") + public Response getUiConfig() { + UIConfigurationManager uiConfigurationManager = UIConfigurationManager.getInstance(); + if (uiConfigurationManager == null) { + String msg = "IoTS UI configuration manager is not initialized."; + log.error(msg); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + UIConfiguration uiConfiguration = uiConfigurationManager.getUIConfig(); + if (uiConfiguration == null) { + String msg = "IoTS UI configuration is not defined."; + log.error(msg); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + return Response.status(Response.Status.OK).entity(uiConfiguration).build(); + } + private String parseUriParamsToJSON(String uriParams) { uriParams = uriParams.replaceAll("=", "\":\""); uriParams = uriParams.replaceAll("&", "\",\""); diff --git a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/webapp/WEB-INF/web.xml b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/webapp/WEB-INF/web.xml index 0c2afe4a6f5..6b397c9fbec 100644 --- a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/webapp/WEB-INF/web.xml +++ b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/src/main/webapp/WEB-INF/web.xml @@ -48,7 +48,8 @@ nonSecuredEndPoints - /api/device-mgt-config/v1.0/configurations + /api/device-mgt-config/v1.0/configurations, + /api/device-mgt-config/v1.0/configurations/ui-config diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ConfigurationManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ConfigurationManagementService.java index 868ae6f1694..ce744e42bb9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ConfigurationManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ConfigurationManagementService.java @@ -191,31 +191,4 @@ public interface ConfigurationManagementService { value = "The properties required to update the platform configurations.", required = true) PlatformConfiguration configuration); - - @GET - @Path("/ui-config") - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation( - consumes = MediaType.APPLICATION_JSON, - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "get application management UI configuration", - notes = "This will get all UI configuration of application management" - ) - @ApiResponses( - value = { - @ApiResponse( - code = 200, - message = "OK. \n Successfully got UI config."), - @ApiResponse( - code = 404, - message = "Not Found. There doesn't have an defined UI config." + - "query."), - @ApiResponse( - code = 500, - message = "Internal Server Error. \n Error occurred while getting the UI config.", - response = ErrorResponse.class) - }) - Response getUiConfig(); - } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/ConfigurationServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/ConfigurationServiceImpl.java index d13946498b9..3953c535148 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/ConfigurationServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/ConfigurationServiceImpl.java @@ -93,24 +93,4 @@ public class ConfigurationServiceImpl implements ConfigurationManagementService new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } } - - @GET - @Override - @Consumes("application/json") - @Path("/ui-config") - public Response getUiConfig() { - UIConfigurationManager uiConfigurationManager = UIConfigurationManager.getInstance(); - if (uiConfigurationManager == null) { - String msg = "IoTS UI configuration manager is not initialized."; - log.error(msg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - UIConfiguration uiConfiguration = uiConfigurationManager.getUIConfig(); - if (uiConfiguration == null) { - String msg = "IoTS UI configuration is not defined."; - log.error(msg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - return Response.status(Response.Status.OK).entity(uiConfiguration).build(); - } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/web.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/web.xml index 4c08378ea63..fffbfbdb24e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/web.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/web.xml @@ -48,8 +48,7 @@ nonSecuredEndPoints - /api/device-mgt/v1.0/users/validate, - /api/device-mgt/v1.0/configuration/ui-config + /api/device-mgt/v1.0/users/validate diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java index 7cb242ff767..e4ff7fb5bf9 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java @@ -21,7 +21,7 @@ package io.entgra.ui.request.interceptor.util; public class HandlerConstants { public static final String PUBLISHER_APPLICATION_NAME = "application-mgt-publisher"; public static final String APP_REG_ENDPOINT = "/api-application-registration/register"; - public static final String UI_CONFIG_ENDPOINT = "/api/device-mgt/v1.0/configuration/ui-config"; + public static final String UI_CONFIG_ENDPOINT = "/api/device-mgt-config/v1.0/configurations/ui-config"; public static final String TOKEN_ENDPOINT = "/token"; public static final String INTROSPECT_ENDPOINT = "/oauth2/introspect"; public static final String LOGIN_PAGE = "/login";