fixed produces to MediaType.APPLICATION_JSON
This commit is contained in:
parent
8cea8b9aea
commit
9e3549e410
|
@ -43,7 +43,7 @@ public class GeoportalHealth {
|
|||
|
||||
@GET
|
||||
@Path("/mongo")
|
||||
@Produces({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response databaseCheck(@QueryParam("context") String context) throws JsonProcessingException {
|
||||
log.debug("databaseCheck called in the context {}", context);
|
||||
if (context == null) {
|
||||
|
@ -62,7 +62,8 @@ public class GeoportalHealth {
|
|||
}
|
||||
|
||||
private String healthCheckSerializer(HealthCheckResponse response) throws JsonProcessingException {
|
||||
// Serializes HealthCheckResponse in JSON with custom HealthCheckResponseSerializer
|
||||
// Serializes HealthCheckResponse in JSON with custom
|
||||
// HealthCheckResponseSerializer
|
||||
return mapper.writeValueAsString(response);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,18 +19,15 @@ import lombok.extern.slf4j.Slf4j;
|
|||
@Slf4j
|
||||
public abstract class GuardedMethod<T> {
|
||||
|
||||
private static List<Runnable> preoperations=new ArrayList<>();
|
||||
private static List<Runnable> preoperations = new ArrayList<>();
|
||||
|
||||
public static void addPreoperation(Runnable preoperation){
|
||||
public static void addPreoperation(Runnable preoperation) {
|
||||
preoperations.add(preoperation);
|
||||
}
|
||||
|
||||
private T result = null;
|
||||
|
||||
|
||||
|
||||
private T result=null;
|
||||
|
||||
public GuardedMethod<T> execute() throws WebApplicationException{
|
||||
public GuardedMethod<T> execute() throws WebApplicationException {
|
||||
try {
|
||||
if (!preoperations.isEmpty()) {
|
||||
log.trace("Running preops (size : {} )", preoperations.size());
|
||||
|
@ -40,33 +37,34 @@ public abstract class GuardedMethod<T> {
|
|||
log.trace("Executing actual method..");
|
||||
result = run();
|
||||
return this;
|
||||
}catch (InvalidUserRoleException e){
|
||||
log.error("Returning exception ",e);
|
||||
throw new WebApplicationException("Invalid Step ID ", e,Status.FORBIDDEN);
|
||||
}catch (UnrecognizedStepException e){
|
||||
log.error("Returning exception ",e);
|
||||
throw new WebApplicationException("Invalid Step ID ", e,Status.BAD_REQUEST);
|
||||
}catch (ConfigurationException e){
|
||||
log.error("Returning exception ",e);
|
||||
throw new WebApplicationException("Environment is not properly configured", e,Status.EXPECTATION_FAILED);
|
||||
}catch (InsufficientPrivileges e){
|
||||
log.error("Returning exception ",e);
|
||||
throw new WebApplicationException("User has insufficient privileges for requested action", e,Status.FORBIDDEN);
|
||||
}catch(WebApplicationException e) {
|
||||
} catch (InvalidUserRoleException e) {
|
||||
log.error("Returning exception ", e);
|
||||
throw new WebApplicationException("Invalid Step ID ", e, Status.FORBIDDEN);
|
||||
} catch (UnrecognizedStepException e) {
|
||||
log.error("Returning exception ", e);
|
||||
throw new WebApplicationException("Invalid Step ID ", e, Status.BAD_REQUEST);
|
||||
} catch (ConfigurationException e) {
|
||||
log.error("Returning exception ", e);
|
||||
throw new WebApplicationException("Environment is not properly configured", e, Status.EXPECTATION_FAILED);
|
||||
} catch (InsufficientPrivileges e) {
|
||||
log.error("Returning exception ", e);
|
||||
throw new WebApplicationException("User has insufficient privileges for requested action", e,
|
||||
Status.FORBIDDEN);
|
||||
} catch (WebApplicationException e) {
|
||||
log.error("Throwing Web Application Exception ", e);
|
||||
throw e;
|
||||
}catch(ProjectNotFoundException e){
|
||||
log.error("Returning exception ",e);
|
||||
throw new WebApplicationException("Project not found", e,Status.NOT_FOUND);
|
||||
}catch(ProjectLockedException e){
|
||||
log.error("Returning exception ",e);
|
||||
throw new WebApplicationException("Project is currently locked", e,Status.PRECONDITION_FAILED);
|
||||
}catch(InvalidLockException e){
|
||||
log.error("Lock exception ",e);
|
||||
throw new WebApplicationException("Conflicts found in locks", e,Status.CONFLICT);
|
||||
}catch(Throwable t) {
|
||||
log.error("Unexpected error ",t);
|
||||
throw new WebApplicationException("Unexpected internal error", t,Status.INTERNAL_SERVER_ERROR);
|
||||
} catch (ProjectNotFoundException e) {
|
||||
log.error("Returning exception ", e);
|
||||
throw new WebApplicationException("Project not found", e, Status.NOT_FOUND);
|
||||
} catch (ProjectLockedException e) {
|
||||
log.error("Returning exception ", e);
|
||||
throw new WebApplicationException("Project is currently locked", e, Status.PRECONDITION_FAILED);
|
||||
} catch (InvalidLockException e) {
|
||||
log.error("Lock exception ", e);
|
||||
throw new WebApplicationException("Conflicts found in locks", e, Status.CONFLICT);
|
||||
} catch (Throwable t) {
|
||||
log.error("Unexpected error ", t);
|
||||
throw new WebApplicationException("Unexpected internal error", t, Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -75,6 +73,5 @@ public abstract class GuardedMethod<T> {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
protected abstract T run() throws Exception,WebApplicationException;
|
||||
protected abstract T run() throws Exception, WebApplicationException;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue