From 340d28c03beff18b618f9cdd5ac479e06de7675e Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Fri, 21 Jun 2019 18:29:07 +0530 Subject: [PATCH] Improve UI intercepter response --- ...ailureCallback.java => ErrorCallback.java} | 2 +- .../mgt/common/config/LoginResponse.java | 27 ------------------- .../mgt/common/config/UIConfiguration.java | 12 +++------ .../ui/request/interceptor/LoginHandler.java | 3 +-- .../interceptor/util/HandlerConstants.java | 3 +-- .../request/interceptor/util/HandlerUtil.java | 4 +-- .../main/resources/conf/application-mgt.xml | 26 ++++++++---------- 7 files changed, 20 insertions(+), 57 deletions(-) rename components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/{FailureCallback.java => ErrorCallback.java} (98%) delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/LoginResponse.java diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/FailureCallback.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/ErrorCallback.java similarity index 98% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/FailureCallback.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/ErrorCallback.java index 46bb9e02aa..1a073c7059 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/FailureCallback.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/ErrorCallback.java @@ -2,7 +2,7 @@ package org.wso2.carbon.device.application.mgt.common.config; import javax.xml.bind.annotation.XmlElement; -public class FailureCallback { +public class ErrorCallback { private String badRequest; private String unauthorized; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/LoginResponse.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/LoginResponse.java deleted file mode 100644 index a76e892b3e..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/LoginResponse.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.wso2.carbon.device.application.mgt.common.config; - -import javax.xml.bind.annotation.XmlElement; - -public class LoginResponse { - - private String successCallback; - private FailureCallback failureCallback; - - @XmlElement(name = "SuccessCallback", required=true) - public String getSuccessCallback() { - return successCallback; - } - - public void setSuccessCallback(String successCallback) { - this.successCallback = successCallback; - } - - @XmlElement(name = "FailureCallback", required=true) - public FailureCallback getFailureCallback() { - return failureCallback; - } - - public void setFailureCallback(FailureCallback failureCallback) { - this.failureCallback = failureCallback; - } -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/UIConfiguration.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/UIConfiguration.java index 8c5115926e..040c63465d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/UIConfiguration.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/config/UIConfiguration.java @@ -9,7 +9,7 @@ public class UIConfiguration { private AppRegistration appRegistration; private List scopes; private boolean isSsoEnable; - private LoginResponse loginResponse; + private ErrorCallback errorCallback; @XmlElement(name = "AppRegistration", required=true) public AppRegistration getAppRegistration() { @@ -39,12 +39,8 @@ public class UIConfiguration { isSsoEnable = ssoEnable; } - public LoginResponse getLoginResponse() { - return loginResponse; - } + @XmlElement(name = "ErrorCallback", required=true) + public ErrorCallback getErrorCallback() { return errorCallback; } - @XmlElement(name = "LoginResponse", required=true) - public void setLoginResponse(LoginResponse loginResponse) { - this.loginResponse = loginResponse; - } + public void setErrorCallback(ErrorCallback errorCallback) { this.errorCallback = errorCallback; } } diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java index f35f0151e1..f7ed47811e 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/LoginHandler.java @@ -131,8 +131,7 @@ public class LoginHandler extends HttpServlet { clientAppResponse.getData(), scopes)) { ProxyResponse proxyResponse = new ProxyResponse(); proxyResponse.setCode(HttpStatus.SC_OK); - proxyResponse.setUrl(serverUrl + "/" + platform + uiConfigJsonObject.get(HandlerConstants.LOGIN_RESPONSE_KEY) - .getAsJsonObject().get("successCallback").getAsString()); + proxyResponse.setUrl(serverUrl + "/" + platform); HandlerUtil.handleSuccess(req, resp, serverUrl, platform, proxyResponse); return; } 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 cf2cb4db60..f82fbe7677 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 @@ -32,8 +32,7 @@ public class HandlerConstants { public static final String UI_CONFIG_KEY = "ui-config"; public static final String PLATFORM = "platform"; public static final String DEFAULT_ERROR_CALLBACK = "/pages/error/default"; - public static final String LOGIN_RESPONSE_KEY = "loginResponse"; - public static final String FAILURE_CALLBACK_KEY = "failureCallback"; + public static final String ERROR_CALLBACK_KEY = "errorCallback"; public static final String API_COMMON_CONTEXT = "/api"; public static final String EXECUTOR_EXCEPTION_PREFIX = "ExecutorException-"; public static final String TOKEN_IS_EXPIRED = "ACCESS_TOKEN_IS_EXPIRED"; diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java index 399655ae0a..4093902327 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java @@ -20,6 +20,7 @@ package io.entgra.ui.request.interceptor.util; import com.google.gson.Gson; import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -171,8 +172,7 @@ public class HandlerUtil { if (uiConfig == null){ proxyResponse.setUrl(serverUrl + "/" + platform + HandlerConstants.DEFAULT_ERROR_CALLBACK); } else{ - proxyResponse.setUrl(serverUrl + uiConfig.get(HandlerConstants.LOGIN_RESPONSE_KEY).getAsJsonObject() - .get(HandlerConstants.FAILURE_CALLBACK_KEY).getAsJsonObject() + proxyResponse.setUrl(serverUrl + uiConfig.get(HandlerConstants.ERROR_CALLBACK_KEY).getAsJsonObject() .get(proxyResponse.getExecutorResponse().split(HandlerConstants.EXECUTOR_EXCEPTION_PREFIX)[1]) .getAsString()); } diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml index 2e58edcc37..001c06ecbe 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml @@ -135,7 +135,6 @@ true false - false application_management @@ -160,20 +159,17 @@ app-mgt - - /apps - - /pages/error/client-errors/400 - /pages/error/client-errors/401 - /pages/error/client-errors/403 - /pages/error/client-errors/404 - /pages/error/client-errors/405 - /pages/error/client-errors/406 - /pages/error/client-errors/415 - /pages/error/server-errors/500 - /pages/error/default - - + + /pages/error/client-errors/400 + /pages/error/client-errors/401 + /pages/error/client-errors/403 + /pages/error/client-errors/404 + /pages/error/client-errors/405 + /pages/error/client-errors/406 + /pages/error/client-errors/415 + /pages/error/server-errors/500 + /pages/error/default + https://localhost:9443/api/application-mgt/v1.0/artifact