From ff2646a9ae4ea64ec89a5964588b86dcc0dee4ec Mon Sep 17 00:00:00 2001 From: lpapadopoulos <lpapadopoulos@ubitech.eu> Date: Tue, 9 Apr 2024 17:41:24 +0300 Subject: [PATCH] refactor code --- .../SwaggerDocumentationConfig.java | 4 +- .../api/GeographicSiteManagementApi.java | 54 +------------------ 2 files changed, 3 insertions(+), 55 deletions(-) diff --git a/src/main/java/org/etsi/osl/tmf/configuration/SwaggerDocumentationConfig.java b/src/main/java/org/etsi/osl/tmf/configuration/SwaggerDocumentationConfig.java index 9cd05ca..239be29 100644 --- a/src/main/java/org/etsi/osl/tmf/configuration/SwaggerDocumentationConfig.java +++ b/src/main/java/org/etsi/osl/tmf/configuration/SwaggerDocumentationConfig.java @@ -740,7 +740,7 @@ public class SwaggerDocumentationConfig { .specVersion( SpecVersion.V30 ).addSecurityItem(new SecurityRequirement().addList("security_auth")) .info(new Info() .title("TMF 674 Geographic Site Management") - .description("## TMF API Reference: TMF674 - Geographic Site Management ### Release : 20.0 - April 2020 ") + .description("## TMF API Reference: TMF674 - Geographic Site Management ") .version("4.0.0") .license(new License() .name("Apache 2.0") @@ -758,7 +758,7 @@ public class SwaggerDocumentationConfig { return GroupedOpenApi.builder() .group("tmf-api-674-Geographic Site Management-v4.0.0") - .addOpenApiCustomizer( this.stm653OpenAPI() ) + .addOpenApiCustomizer( this.gsm674OpenAPI() ) .packagesToScan("org.etsi.osl.tmf.gsm674.api") .build(); diff --git a/src/main/java/org/etsi/osl/tmf/gsm674/api/GeographicSiteManagementApi.java b/src/main/java/org/etsi/osl/tmf/gsm674/api/GeographicSiteManagementApi.java index c50b604..4dc6258 100644 --- a/src/main/java/org/etsi/osl/tmf/gsm674/api/GeographicSiteManagementApi.java +++ b/src/main/java/org/etsi/osl/tmf/gsm674/api/GeographicSiteManagementApi.java @@ -56,18 +56,6 @@ public interface GeographicSiteManagementApi { consumes = { "application/json" }, method = RequestMethod.POST) default ResponseEntity<GeographicSite> createGeographicSite(@Parameter(description = "The geographic site to be created" ,required=true ) @Valid @RequestBody GeographicSite geographicSite) { - if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { - if (getAcceptHeader().get().contains("application/json")) { - try { - return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"objective\" : [ { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" } ]}", GeographicSite.class), HttpStatus.NOT_IMPLEMENTED); - } catch (IOException e) { - log.error("Couldn't serialize response for content type application/json", e); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - } else { - log.warn("ObjectMapper or HttpServletRequest not configured in default GeographicSiteManagementApi interface so no example is generated"); - } return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -86,10 +74,6 @@ public interface GeographicSiteManagementApi { consumes = { "application/json" }, method = RequestMethod.DELETE) default ResponseEntity<Void> deleteGeographicSite(@Parameter(description = "Identifier of the Geographic site",required=true) @PathVariable("id") String id) { - if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { - } else { - log.warn("ObjectMapper or HttpServletRequest not configured in default GeographicSiteManagementApi interface so no example is generated"); - } return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -109,19 +93,7 @@ public interface GeographicSiteManagementApi { consumes = { "application/json" }, method = RequestMethod.GET) default ResponseEntity<List<GeographicSite>> listGeographicSite() { - if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { - if (getAcceptHeader().get().contains("application/json")) { - try { - return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"objective\" : [ { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" } ]}, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"objective\" : [ { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" } ]} ]", List.class), HttpStatus.NOT_IMPLEMENTED); - } catch (IOException e) { - log.error("Couldn't serialize response for content type application/json", e); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - } else { - log.warn("ObjectMapper or HttpServletRequest not configured in default GeographicSiteManagementApi interface so no example is generated"); - } - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -140,18 +112,6 @@ public interface GeographicSiteManagementApi { consumes = { "application/json" }, method = RequestMethod.PATCH) default ResponseEntity<GeographicSite> patchGeographicalSite(@Parameter(description = "Identifier of the Geographic site",required=true) @PathVariable("id") String id,@Parameter(description = "The Service Level Specification to be updated" ,required=true ) @Valid @RequestBody GeographicSite geographicSite) { - if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { - if (getAcceptHeader().get().contains("application/json")) { - try { - return new ResponseEntity<>(getObjectMapper().get().readValue("{ \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"objective\" : [ { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" } ]}", GeographicSite.class), HttpStatus.NOT_IMPLEMENTED); - } catch (IOException e) { - log.error("Couldn't serialize response for content type application/json", e); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - } else { - log.warn("ObjectMapper or HttpServletRequest not configured in default GeographicSiteManagementApi interface so no example is generated"); - } return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } @@ -171,18 +131,6 @@ public interface GeographicSiteManagementApi { consumes = { "application/json" }, method = RequestMethod.GET) default ResponseEntity<GeographicSite> retrieveGeographicSite(@Parameter(description = "Identifier of the Geographic site",required=true) @PathVariable("id") String id) { - if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { - if (getAcceptHeader().get().contains("application/json")) { - try { - return new ResponseEntity<>(getObjectMapper().get().readValue("[ { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"objective\" : [ { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" } ]}, { \"@baseType\" : \"@baseType\", \"validFor\" : { \"startDateTime\" : \"2000-01-23T04:56:07.000+00:00\", \"endDateTime\" : \"2000-01-23T04:56:07.000+00:00\" }, \"@type\" : \"@type\", \"name\" : \"name\", \"description\" : \"description\", \"href\" : \"href\", \"id\" : \"id\", \"@schemaLocation\" : \"@schemaLocation\", \"objective\" : [ { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" }, { \"@referredType\" : \"@referredType\", \"href\" : \"href\", \"id\" : \"id\" } ]} ]", GeographicSite.class), HttpStatus.NOT_IMPLEMENTED); - } catch (IOException e) { - log.error("Couldn't serialize response for content type application/json", e); - return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - } else { - log.warn("ObjectMapper or HttpServletRequest not configured in default GeographicSiteManagementApi interface so no example is generated"); - } return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } -- GitLab