diff --git a/src/main/java/org/gcube/gcat/rest/Configuration.java b/src/main/java/org/gcube/gcat/rest/Configuration.java index 552377d..004babf 100644 --- a/src/main/java/org/gcube/gcat/rest/Configuration.java +++ b/src/main/java/org/gcube/gcat/rest/Configuration.java @@ -107,7 +107,7 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf @GET @Produces(GCatConstants.APPLICATION_JSON_CHARSET_UTF_8) - public String read(String context) throws WebServiceException { + public Response read(String context) throws WebServiceException { try { checkContext(context); return read(); @@ -119,12 +119,16 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf } @Override - public String read() throws WebServiceException { + public Response read() throws WebServiceException { try { ServiceCatalogueConfiguration catalogueConfiguration = CatalogueConfigurationFactory.getInstance(); String configuration = catalogueConfiguration.toJsonString(); logger.debug("Configuration in context {} is {}", catalogueConfiguration.getContext(), configuration); - return configuration; + ResponseBuilder responseBuilder = Response.status(Status.OK); + if(configuration!=null) { + responseBuilder.entity(configuration).type(GCatConstants.APPLICATION_JSON_CHARSET_UTF_8); + } + return responseBuilder.build(); }catch (WebServiceException e) { throw e; }catch (Exception e) { @@ -148,14 +152,18 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf } @Override - public String update(String json) throws WebServiceException { + public Response update(String json) throws WebServiceException { try { ServiceCatalogueConfiguration catalogueConfiguration = ServiceCatalogueConfiguration.getServiceCatalogueConfiguration(json); checkContext(CURRENT_CONTEXT_PATH_PARAMETER); catalogueConfiguration = CatalogueConfigurationFactory.createOrUpdate(catalogueConfiguration); String configuration = catalogueConfiguration.toJsonString(); logger.debug("Configuration in context {} has been updated to {}", catalogueConfiguration.getContext(), configuration); - return configuration; + ResponseBuilder responseBuilder = Response.status(Status.OK); + if(configuration!=null) { + responseBuilder.entity(configuration).type(GCatConstants.APPLICATION_JSON_CHARSET_UTF_8); + } + return responseBuilder.build(); }catch (WebServiceException e) { throw e; }catch (Exception e) { @@ -166,7 +174,7 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf @PATCH @Consumes(GCatConstants.APPLICATION_JSON_CHARSET_UTF_8) @Produces(GCatConstants.APPLICATION_JSON_CHARSET_UTF_8) - public String patch(String context, String json) throws WebServiceException { + public Response patch(String context, String json) throws WebServiceException { try { checkContext(context); return patch(json); @@ -178,7 +186,7 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf } @Override - public String patch(String json) throws WebServiceException { + public Response patch(String json) throws WebServiceException { try { ServiceCatalogueConfiguration catalogueConfiguration = CatalogueConfigurationFactory.getInstance(); ObjectMapper mapper = new ObjectMapper(); @@ -205,7 +213,11 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf newCatalogueConfiguration = CatalogueConfigurationFactory.createOrUpdate(newCatalogueConfiguration); String ret = newCatalogueConfiguration.toJsonString(); logger.debug("Configuration in context {} has been patched to {}", catalogueConfiguration.getContext(), ret); - return ret; + ResponseBuilder responseBuilder = Response.status(Status.OK); + if(ret!=null) { + responseBuilder.entity(ret).type(GCatConstants.APPLICATION_JSON_CHARSET_UTF_8); + } + return responseBuilder.build(); }catch (WebServiceException e) { throw e; }catch (Exception e) {