Improve APPM application name validating API

reporting
Shamalka Navod 5 years ago committed by Dharmakeerthi Lasantha
parent 831b2fa89f
commit 74050d6db5

@ -53,7 +53,6 @@ import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HEAD;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
@ -716,10 +715,10 @@ public interface ApplicationManagementPublisherAPI {
@Multipart(value = "screenshot3") Attachment screenshot3
);
@HEAD
@GET
@Path("/device-type/{deviceType}/app-name/{appName}")
@ApiOperation(
httpMethod = "HEAD",
httpMethod = "GET",
value = "Check the application existence",
notes = "This API is responsible to check whether application exist or not for the given device type and "
+ "application name.",
@ -734,11 +733,10 @@ public interface ApplicationManagementPublisherAPI {
value = {
@ApiResponse(
code = 200,
message = "OK. \n Application exists."),
message = "OK. \n Application doesn't exists."),
@ApiResponse(
code = 404,
message = "NOT FOUND. \n Could.t find an application for given device type and application "
+ "name."),
code = 409,
message = "CONFLICT. \n Application exists"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Found invalid device type with the request."),

@ -59,7 +59,6 @@ import javax.validation.Valid;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HEAD;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
@ -386,7 +385,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
}
@Override
@HEAD
@GET
@Path("/device-type/{deviceType}/app-name/{appName}")
public Response isExistingApplication(
@PathParam("deviceType") String deviceType,
@ -394,9 +393,9 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
try {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
if (applicationManager.isExistingAppName(appName, deviceType)) {
return Response.status(Response.Status.OK).build();
return Response.status(Response.Status.CONFLICT).build();
}
return Response.status(Response.Status.NOT_FOUND).build();
return Response.status(Response.Status.OK).build();
} catch (BadRequestException e) {
log.error("Found invalid device type to check application existence.", e);
return Response.status(Response.Status.BAD_REQUEST).build();

@ -254,7 +254,8 @@ public class InvokerHandler extends HttpServlet {
*/
private String generateBackendRequestURL(HttpServletRequest req) {
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(apiEndpoint).append(HandlerConstants.API_COMMON_CONTEXT).append(req.getPathInfo());
urlBuilder.append(apiEndpoint).append(HandlerConstants.API_COMMON_CONTEXT)
.append(req.getPathInfo().replace(" ", "%20"));
if (StringUtils.isNotEmpty(req.getQueryString())) {
urlBuilder.append("?").append(req.getQueryString());
}

Loading…
Cancel
Save