Fix MsSQL and Oracle syntax issues

feature/appm-store/pbac
lasanthaDLPDS 5 years ago
parent 6ee1fa6eb1
commit 00526352da

@ -81,7 +81,7 @@ public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl {
+ "FROM AP_APP " + "FROM AP_APP "
+ "INNER JOIN AP_APP_RELEASE ON " + "INNER JOIN AP_APP_RELEASE ON "
+ "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID " + "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID "
+ "INNER JOIN (SELECT ID FROM AP_APP OFFSET ? ROWS FETCH NEXT ? ROWS ONLY) AS app_data ON app_data.ID = AP_APP.ID " + "INNER JOIN (SELECT ID FROM AP_APP ORDER BY ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY) AS app_data ON app_data.ID = AP_APP.ID "
+ "WHERE AP_APP.TENANT_ID = ?"; + "WHERE AP_APP.TENANT_ID = ?";
if (filter == null) { if (filter == null) {

@ -79,7 +79,7 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl {
+ "FROM AP_APP " + "FROM AP_APP "
+ "INNER JOIN AP_APP_RELEASE ON " + "INNER JOIN AP_APP_RELEASE ON "
+ "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID " + "AP_APP.ID = AP_APP_RELEASE.AP_APP_ID "
+ "INNER JOIN (SELECT ID FROM AP_APP OFFSET ? ROWS FETCH NEXT ? ROWS ONLY) AS app_data ON app_data.ID = AP_APP.ID " + "INNER JOIN (SELECT ID FROM AP_APP ORDER BY ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY) AS app_data ON app_data.ID = AP_APP.ID "
+ "WHERE AP_APP.TENANT_ID = ?"; + "WHERE AP_APP.TENANT_ID = ?";
if (filter == null) { if (filter == null) {

@ -63,7 +63,7 @@ public class OracleReviewDAOImpl extends GenericReviewDAOImpl {
+ "WHERE AP_APP_REVIEW.AP_APP_RELEASE_ID = ? AND " + "WHERE AP_APP_REVIEW.AP_APP_RELEASE_ID = ? AND "
+ "AP_APP_REVIEW.ROOT_PARENT_ID = ? AND " + "AP_APP_REVIEW.ROOT_PARENT_ID = ? AND "
+ "AP_APP_REVIEW.TENANT_ID = ? " + "AP_APP_REVIEW.TENANT_ID = ? "
+ "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + "ORDER BY AP_APP_REVIEW.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try { try {
Connection conn = this.getDBConnection(); Connection conn = this.getDBConnection();
try (PreparedStatement statement = conn.prepareStatement(sql)) { try (PreparedStatement statement = conn.prepareStatement(sql)) {
@ -114,7 +114,7 @@ public class OracleReviewDAOImpl extends GenericReviewDAOImpl {
") AND AP_APP_REVIEW.ROOT_PARENT_ID = ? AND " ") AND AP_APP_REVIEW.ROOT_PARENT_ID = ? AND "
+ "AP_APP_REVIEW.ACTIVE_REVIEW = true AND " + "AP_APP_REVIEW.ACTIVE_REVIEW = true AND "
+ "AP_APP_REVIEW.TENANT_ID = ? " + "AP_APP_REVIEW.TENANT_ID = ? "
+ "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"); + "ORDER BY AP_APP_REVIEW.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY");
releaseIds.stream().map(ignored -> "?").forEach(joiner::add); releaseIds.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString(); String query = joiner.toString();
try (PreparedStatement ps = conn.prepareStatement(query)) { try (PreparedStatement ps = conn.prepareStatement(query)) {
@ -169,7 +169,7 @@ public class OracleReviewDAOImpl extends GenericReviewDAOImpl {
+ "AP_APP_REVIEW.ACTIVE_REVIEW = true AND " + "AP_APP_REVIEW.ACTIVE_REVIEW = true AND "
+ "AP_APP_REVIEW.USERNAME = ? AND " + "AP_APP_REVIEW.USERNAME = ? AND "
+ "AP_APP_REVIEW.TENANT_ID = ? " + "AP_APP_REVIEW.TENANT_ID = ? "
+ "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"); + "ORDER BY AP_APP_REVIEW.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY");
releaseIds.stream().map(ignored -> "?").forEach(joiner::add); releaseIds.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString(); String query = joiner.toString();
try (PreparedStatement ps = conn.prepareStatement(query)) { try (PreparedStatement ps = conn.prepareStatement(query)) {

@ -63,7 +63,7 @@ public class SQLServerReviewDAOImpl extends GenericReviewDAOImpl {
+ "WHERE AP_APP_REVIEW.AP_APP_RELEASE_ID = ? AND " + "WHERE AP_APP_REVIEW.AP_APP_RELEASE_ID = ? AND "
+ "AP_APP_REVIEW.ROOT_PARENT_ID = ? AND " + "AP_APP_REVIEW.ROOT_PARENT_ID = ? AND "
+ "AP_APP_REVIEW.TENANT_ID = ? " + "AP_APP_REVIEW.TENANT_ID = ? "
+ "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + "ORDER BY AP_APP_REVIEW.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try { try {
Connection conn = this.getDBConnection(); Connection conn = this.getDBConnection();
try (PreparedStatement statement = conn.prepareStatement(sql)) { try (PreparedStatement statement = conn.prepareStatement(sql)) {
@ -114,7 +114,7 @@ public class SQLServerReviewDAOImpl extends GenericReviewDAOImpl {
") AND AP_APP_REVIEW.ROOT_PARENT_ID = ? AND " ") AND AP_APP_REVIEW.ROOT_PARENT_ID = ? AND "
+ "AP_APP_REVIEW.ACTIVE_REVIEW = true AND " + "AP_APP_REVIEW.ACTIVE_REVIEW = true AND "
+ "AP_APP_REVIEW.TENANT_ID = ? " + "AP_APP_REVIEW.TENANT_ID = ? "
+ "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"); + "ORDER BY AP_APP_REVIEW.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY");
releaseIds.stream().map(ignored -> "?").forEach(joiner::add); releaseIds.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString(); String query = joiner.toString();
try (PreparedStatement ps = conn.prepareStatement(query)) { try (PreparedStatement ps = conn.prepareStatement(query)) {
@ -169,7 +169,7 @@ public class SQLServerReviewDAOImpl extends GenericReviewDAOImpl {
+ "AP_APP_REVIEW.ACTIVE_REVIEW = true AND " + "AP_APP_REVIEW.ACTIVE_REVIEW = true AND "
+ "AP_APP_REVIEW.USERNAME = ? AND " + "AP_APP_REVIEW.USERNAME = ? AND "
+ "AP_APP_REVIEW.TENANT_ID = ? " + "AP_APP_REVIEW.TENANT_ID = ? "
+ "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"); + "ORDER BY AP_APP_REVIEW.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY");
releaseIds.stream().map(ignored -> "?").forEach(joiner::add); releaseIds.stream().map(ignored -> "?").forEach(joiner::add);
String query = joiner.toString(); String query = joiner.toString();
try (PreparedStatement ps = conn.prepareStatement(query)) { try (PreparedStatement ps = conn.prepareStatement(query)) {

@ -971,8 +971,8 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
Connection conn = this.getDBConnection(); Connection conn = this.getDBConnection();
List<String> subscribedRoles = new ArrayList<>(); List<String> subscribedRoles = new ArrayList<>();
String sql = "SELECT " String sql = "SELECT "
+ "US.ROLE_NAME AS ROLE " + "RS.ROLE_NAME AS ROLE "
+ "FROM AP_ROLE_SUBSCRIPTION US " + "FROM AP_ROLE_SUBSCRIPTION RS "
+ "WHERE " + "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? LIMIT ? OFFSET ?"; + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? LIMIT ? OFFSET ?";
try (PreparedStatement ps = conn.prepareStatement(sql)) { try (PreparedStatement ps = conn.prepareStatement(sql)) {

@ -51,7 +51,7 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
+ "US.USER_NAME AS USER " + "US.USER_NAME AS USER "
+ "FROM AP_USER_SUBSCRIPTION US " + "FROM AP_USER_SUBSCRIPTION US "
+ "WHERE " + "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY US.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, appReleaseId); stmt.setInt(1, appReleaseId);
stmt.setInt(2, tenantId); stmt.setInt(2, tenantId);
@ -88,10 +88,10 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
Connection conn = this.getDBConnection(); Connection conn = this.getDBConnection();
List<String> subscribedRoles = new ArrayList<>(); List<String> subscribedRoles = new ArrayList<>();
String sql = "SELECT " String sql = "SELECT "
+ "US.ROLE_NAME AS ROLE " + "RS.ROLE_NAME AS ROLE "
+ "FROM AP_ROLE_SUBSCRIPTION US " + "FROM AP_ROLE_SUBSCRIPTION RS "
+ "WHERE " + "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY RS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try (PreparedStatement ps = conn.prepareStatement(sql)) { try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, appReleaseId); ps.setInt(1, appReleaseId);
ps.setInt(2, tenantId); ps.setInt(2, tenantId);
@ -131,7 +131,7 @@ public class OracleSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
+ "GS.GROUP_NAME AS GROUPS " + "GS.GROUP_NAME AS GROUPS "
+ "FROM AP_GROUP_SUBSCRIPTION GS " + "FROM AP_GROUP_SUBSCRIPTION GS "
+ "WHERE " + "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY GS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try (PreparedStatement ps = conn.prepareStatement(sql)) { try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, appReleaseId); ps.setInt(1, appReleaseId);
ps.setInt(2, tenantId); ps.setInt(2, tenantId);

@ -51,7 +51,7 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
+ "US.USER_NAME AS USER " + "US.USER_NAME AS USER "
+ "FROM AP_USER_SUBSCRIPTION US " + "FROM AP_USER_SUBSCRIPTION US "
+ "WHERE " + "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY US.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, appReleaseId); stmt.setInt(1, appReleaseId);
stmt.setInt(2, tenantId); stmt.setInt(2, tenantId);
@ -88,10 +88,10 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
Connection conn = this.getDBConnection(); Connection conn = this.getDBConnection();
List<String> subscribedRoles = new ArrayList<>(); List<String> subscribedRoles = new ArrayList<>();
String sql = "SELECT " String sql = "SELECT "
+ "US.ROLE_NAME AS ROLE " + "RS.ROLE_NAME AS ROLE "
+ "FROM AP_ROLE_SUBSCRIPTION US " + "FROM AP_ROLE_SUBSCRIPTION RS "
+ "WHERE " + "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY RS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try (PreparedStatement ps = conn.prepareStatement(sql)) { try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, appReleaseId); ps.setInt(1, appReleaseId);
ps.setInt(2, tenantId); ps.setInt(2, tenantId);
@ -131,7 +131,7 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl {
+ "GS.GROUP_NAME AS GROUPS " + "GS.GROUP_NAME AS GROUPS "
+ "FROM AP_GROUP_SUBSCRIPTION GS " + "FROM AP_GROUP_SUBSCRIPTION GS "
+ "WHERE " + "WHERE "
+ "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY GS.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
try (PreparedStatement ps = conn.prepareStatement(sql)) { try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, appReleaseId); ps.setInt(1, appReleaseId);
ps.setInt(2, tenantId); ps.setInt(2, tenantId);

@ -1276,7 +1276,7 @@ public interface ApplicationManagementPublisherAPI {
); );
@PUT @PUT
@Path("/tags/{oldTagName}") @Path("/tags/rename")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ApiOperation( @ApiOperation(
consumes = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,

@ -230,12 +230,12 @@ public interface ApplicationManagementPublisherAdminAPI {
); );
@PUT @PUT
@Path("/tags/{tagName}") @Path("/categories/rename")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@ApiOperation( @ApiOperation(
consumes = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", httpMethod = "PUT",
value = "Update application category", value = "Update application category",
notes = "This will update application category.", notes = "This will update application category.",
tags = "Application Management", tags = "Application Management",

@ -48,7 +48,6 @@ import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManage
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException; import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException;
import java.beans.Customizer;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
@ -748,7 +747,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@DELETE @DELETE
@Override @Override
@Consumes("application/json") @Consumes(MediaType.WILDCARD)
@Path("/{appId}/tags/{tagName}") @Path("/{appId}/tags/{tagName}")
public Response deleteApplicationTag( public Response deleteApplicationTag(
@PathParam("appId") int appId, @PathParam("appId") int appId,
@ -775,7 +774,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
@DELETE @DELETE
@Override @Override
@Consumes("application/json") @Consumes(MediaType.WILDCARD)
@Path("/tags/{tagName}") @Path("/tags/{tagName}")
public Response deleteUnusedTag( public Response deleteUnusedTag(
@PathParam("tagName") String tagName) { @PathParam("tagName") String tagName) {

@ -36,6 +36,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
@ -49,6 +50,7 @@ public class ApplicationManagementPublisherAdminAPIImpl implements ApplicationMa
private static Log log = LogFactory.getLog(ApplicationManagementPublisherAdminAPIImpl.class); private static Log log = LogFactory.getLog(ApplicationManagementPublisherAdminAPIImpl.class);
@DELETE @DELETE
@Consumes(MediaType.WILDCARD)
@Path("/release/{uuid}") @Path("/release/{uuid}")
public Response deleteApplicationRelease( public Response deleteApplicationRelease(
@PathParam("uuid") String releaseUuid) { @PathParam("uuid") String releaseUuid) {
@ -76,6 +78,7 @@ public class ApplicationManagementPublisherAdminAPIImpl implements ApplicationMa
} }
@DELETE @DELETE
@Consumes(MediaType.WILDCARD)
@Path("/{appId}") @Path("/{appId}")
public Response deleteApplication( public Response deleteApplication(
@PathParam("appId") int applicationId) { @PathParam("appId") int applicationId) {
@ -102,7 +105,7 @@ public class ApplicationManagementPublisherAdminAPIImpl implements ApplicationMa
@DELETE @DELETE
@Override @Override
@Consumes("application/json") @Consumes(MediaType.WILDCARD)
@Path("/tags/{tagName}") @Path("/tags/{tagName}")
public Response deleteTag( public Response deleteTag(
@PathParam("tagName") String tagName) { @PathParam("tagName") String tagName) {
@ -168,7 +171,7 @@ public class ApplicationManagementPublisherAdminAPIImpl implements ApplicationMa
@DELETE @DELETE
@Override @Override
@Consumes("application/json") @Consumes(MediaType.WILDCARD)
@Path("/categories/{categoryName}") @Path("/categories/{categoryName}")
public Response deleteCategory( public Response deleteCategory(
@PathParam("categoryName") String categoryName) { @PathParam("categoryName") String categoryName) {

@ -70,10 +70,9 @@ import java.util.List;
public class InvokerHandler extends HttpServlet { public class InvokerHandler extends HttpServlet {
private static final Log log = LogFactory.getLog(InvokerHandler.class); private static final Log log = LogFactory.getLog(InvokerHandler.class);
private static final long serialVersionUID = -6508020875358160165L; private static final long serialVersionUID = -6508020875358160165L;
private AuthData authData; private static AuthData authData;
private String apiEndpoint; private static String serverUrl;
private String serverUrl; private static String platform;
private String platform;
@Override @Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) { protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
@ -229,7 +228,7 @@ public class InvokerHandler extends HttpServlet {
*/ */
private String generateBackendRequestURL(HttpServletRequest req) { private String generateBackendRequestURL(HttpServletRequest req) {
StringBuilder urlBuilder = new StringBuilder(); StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(serverUrl).append(HandlerConstants.API_COMMON_CONTEXT).append(apiEndpoint); urlBuilder.append(serverUrl).append(HandlerConstants.API_COMMON_CONTEXT).append(req.getPathInfo());
if (StringUtils.isNotEmpty(req.getQueryString())) { if (StringUtils.isNotEmpty(req.getQueryString())) {
urlBuilder.append("?").append(req.getQueryString()); urlBuilder.append("?").append(req.getQueryString());
} }
@ -269,10 +268,9 @@ public class InvokerHandler extends HttpServlet {
* @return If request is a valid one, returns TRUE, otherwise return FALSE * @return If request is a valid one, returns TRUE, otherwise return FALSE
* @throws IOException If and error occurs while witting error response to client side * @throws IOException If and error occurs while witting error response to client side
*/ */
private boolean validateRequest(HttpServletRequest req, HttpServletResponse resp) private static boolean validateRequest(HttpServletRequest req, HttpServletResponse resp)
throws IOException { throws IOException {
serverUrl = req.getScheme() + "://" + req.getServerName() + ":" + System.getProperty("iot.gateway.https.port"); serverUrl = req.getScheme() + "://" + req.getServerName() + ":" + System.getProperty("iot.gateway.https.port");
apiEndpoint = req.getPathInfo();
HttpSession session = req.getSession(false); HttpSession session = req.getSession(false);
if (session == null) { if (session == null) {
@ -289,8 +287,8 @@ public class InvokerHandler extends HttpServlet {
return false; return false;
} }
if (apiEndpoint == null || req.getMethod() == null) { if (req.getMethod() == null) {
log.error("Bad Request, Either destination api-endpoint or method is empty"); log.error("Bad Request, Request method is empty");
handleError(req, resp, HttpStatus.SC_BAD_REQUEST); handleError(req, resp, HttpStatus.SC_BAD_REQUEST);
return false; return false;
} }
@ -322,13 +320,14 @@ public class InvokerHandler extends HttpServlet {
} }
/*** /***
* This method is responsible to get the refresh token
* *
* @param req {@link HttpServletRequest} * @param req {@link HttpServletRequest}
* @param resp {@link HttpServletResponse} * @param resp {@link HttpServletResponse}
* @return If successfully renew tokens, returns TRUE otherwise return FALSE * @return If successfully renew tokens, returns TRUE otherwise return FALSE
* @throws IOException If an error occurs while witting error response to client side or invoke token renewal API * @throws IOException If an error occurs while witting error response to client side or invoke token renewal API
*/ */
private boolean refreshToken(HttpServletRequest req, HttpServletResponse resp) private static boolean refreshToken(HttpServletRequest req, HttpServletResponse resp)
throws IOException { throws IOException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("refreshing the token"); log.debug("refreshing the token");
@ -391,7 +390,7 @@ public class InvokerHandler extends HttpServlet {
* @param errorCode HTTP error status code * @param errorCode HTTP error status code
* @throws IOException If error occurred when trying to send the error response. * @throws IOException If error occurred when trying to send the error response.
*/ */
private void handleError(HttpServletRequest req, HttpServletResponse resp, int errorCode) private static void handleError(HttpServletRequest req, HttpServletResponse resp, int errorCode)
throws IOException { throws IOException {
ProxyResponse proxyResponse = new ProxyResponse(); ProxyResponse proxyResponse = new ProxyResponse();
proxyResponse.setCode(errorCode); proxyResponse.setCode(errorCode);

@ -115,6 +115,7 @@ public class UserHandler extends HttpServlet {
/** /**
* Send UnAuthorized Response to the user * Send UnAuthorized Response to the user
*
* @param req HttpServletRequest object * @param req HttpServletRequest object
* @param resp HttpServletResponse object * @param resp HttpServletResponse object
* @param serverUrl Url of the server * @param serverUrl Url of the server
@ -124,6 +125,8 @@ public class UserHandler extends HttpServlet {
throws IOException { throws IOException {
ProxyResponse proxyResponse = new ProxyResponse(); ProxyResponse proxyResponse = new ProxyResponse();
proxyResponse.setCode(HttpStatus.SC_UNAUTHORIZED); proxyResponse.setCode(HttpStatus.SC_UNAUTHORIZED);
proxyResponse.setExecutorResponse(
HandlerConstants.EXECUTOR_EXCEPTION_PREFIX + HandlerUtil.getStatusKey(HttpStatus.SC_UNAUTHORIZED));
HandlerUtil.handleError(req, resp, serverUrl, platform, proxyResponse); HandlerUtil.handleError(req, resp, serverUrl, platform, proxyResponse);
} }
} }

Loading…
Cancel
Save