mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Improve APPM application name validating API
This commit is contained in:
parent
831b2fa89f
commit
74050d6db5
@ -53,7 +53,6 @@ import javax.validation.Valid;
|
|||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.DELETE;
|
import javax.ws.rs.DELETE;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.HEAD;
|
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.PUT;
|
import javax.ws.rs.PUT;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
@ -716,10 +715,10 @@ public interface ApplicationManagementPublisherAPI {
|
|||||||
@Multipart(value = "screenshot3") Attachment screenshot3
|
@Multipart(value = "screenshot3") Attachment screenshot3
|
||||||
);
|
);
|
||||||
|
|
||||||
@HEAD
|
@GET
|
||||||
@Path("/device-type/{deviceType}/app-name/{appName}")
|
@Path("/device-type/{deviceType}/app-name/{appName}")
|
||||||
@ApiOperation(
|
@ApiOperation(
|
||||||
httpMethod = "HEAD",
|
httpMethod = "GET",
|
||||||
value = "Check the application existence",
|
value = "Check the application existence",
|
||||||
notes = "This API is responsible to check whether application exist or not for the given device type and "
|
notes = "This API is responsible to check whether application exist or not for the given device type and "
|
||||||
+ "application name.",
|
+ "application name.",
|
||||||
@ -734,11 +733,10 @@ public interface ApplicationManagementPublisherAPI {
|
|||||||
value = {
|
value = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 200,
|
code = 200,
|
||||||
message = "OK. \n Application exists."),
|
message = "OK. \n Application doesn't exists."),
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 404,
|
code = 409,
|
||||||
message = "NOT FOUND. \n Could.t find an application for given device type and application "
|
message = "CONFLICT. \n Application exists"),
|
||||||
+ "name."),
|
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
code = 400,
|
code = 400,
|
||||||
message = "Bad Request. \n Found invalid device type with the request."),
|
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.Consumes;
|
||||||
import javax.ws.rs.DELETE;
|
import javax.ws.rs.DELETE;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.HEAD;
|
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.PUT;
|
import javax.ws.rs.PUT;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
@ -386,7 +385,7 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@HEAD
|
@GET
|
||||||
@Path("/device-type/{deviceType}/app-name/{appName}")
|
@Path("/device-type/{deviceType}/app-name/{appName}")
|
||||||
public Response isExistingApplication(
|
public Response isExistingApplication(
|
||||||
@PathParam("deviceType") String deviceType,
|
@PathParam("deviceType") String deviceType,
|
||||||
@ -394,9 +393,9 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem
|
|||||||
try {
|
try {
|
||||||
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
||||||
if (applicationManager.isExistingAppName(appName, deviceType)) {
|
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) {
|
} catch (BadRequestException e) {
|
||||||
log.error("Found invalid device type to check application existence.", e);
|
log.error("Found invalid device type to check application existence.", e);
|
||||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||||
|
|||||||
@ -254,7 +254,8 @@ 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(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())) {
|
if (StringUtils.isNotEmpty(req.getQueryString())) {
|
||||||
urlBuilder.append("?").append(req.getQueryString());
|
urlBuilder.append("?").append(req.getQueryString());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user