From 9c0b026d52fcec0377efdb5dcc9269078cee08d9 Mon Sep 17 00:00:00 2001 From: Guylene Tandeau Date: Thu, 15 Feb 2024 11:48:00 +0100 Subject: [PATCH] refactor unused imports reorder modifiers should be declared in the correct order to comply with the Java Language specification rename fields or methods with lower case at the beginning return directly a result --- .../ToColecticaApi/controller/GetItem.java | 8 +++---- .../ToColecticaApi/controller/PostItem.java | 4 ++-- .../rmes/metadata/client/MetadataClient.java | 2 -- .../metadata/client/MetadataClientImpl.java | 1 - .../controller/MetadataController.java | 2 +- .../metadata/model/ObjectColecticaPost.java | 22 ++++++++--------- .../fr/insee/rmes/metadata/model/Options.java | 8 +++---- .../metadata/service/MetadataService.java | 1 - .../service/MetadataServiceItemImpl.java | 4 ++-- .../ddiinstance/DDIInstanceServiceImpl.java | 3 +-- .../rmes/search/controller/DDISearch.java | 2 +- .../controller/ElasticsearchController.java | 24 +++++++++---------- .../rmes/webservice/rest/RMeSEnvironment.java | 4 +--- 13 files changed, 39 insertions(+), 46 deletions(-) diff --git a/src/main/java/fr/insee/rmes/ToColecticaApi/controller/GetItem.java b/src/main/java/fr/insee/rmes/ToColecticaApi/controller/GetItem.java index 2cd2ec61..51eb50e1 100644 --- a/src/main/java/fr/insee/rmes/ToColecticaApi/controller/GetItem.java +++ b/src/main/java/fr/insee/rmes/ToColecticaApi/controller/GetItem.java @@ -20,7 +20,7 @@ @RequestMapping("/Item") @Tag(name= "DEMO-Colectica",description = "Services for upgrade Colectica-API") public class GetItem { - final static Logger logger = LogManager.getLogger(GetItem.class); + static final Logger logger = LogManager.getLogger(GetItem.class); private final ColecticaService colecticaService; @@ -32,7 +32,7 @@ public GetItem(ColecticaService colecticaService) { @GetMapping("ddiInstance/uuid") @Operation(summary = "Get ddiInstance by uuid", description = "Get an XML document for a ddi:Instance from Colectica repository.") @Produces(MediaType.APPLICATION_XML) - public ResponseEntity FindInstanceByUuidColectica ( + public ResponseEntity findInstanceByUuidColectica( @Parameter( description = "id de l'objet colectica", required = true, @@ -45,7 +45,7 @@ public ResponseEntity FindInstanceByUuidColectica ( @GetMapping("ddiFragment/uuid") @Operation(summary = "Get Fragment by uuid", description = "Get an XML document for a ddi:Fragment from Colectica repository.") @Produces(MediaType.APPLICATION_XML) - public ResponseEntity FindFragmentByUuidColectica ( + public ResponseEntity findFragmentByUuidColectica( @Parameter( description = "id de l'objet colectica", required = true, @@ -98,7 +98,7 @@ public ResponseEntity filteredSearchTextByType( @GetMapping("/filtered-search/type/") @Operation(summary = "Get list of match by type in elasticsearch database", description = "Get a JSON ") - public ResponseEntity SearchByType( + public ResponseEntity searchByType( @Parameter( description = "nom par défaut de l'index colectica", required = true, diff --git a/src/main/java/fr/insee/rmes/ToColecticaApi/controller/PostItem.java b/src/main/java/fr/insee/rmes/ToColecticaApi/controller/PostItem.java index 829ff0c3..fef69d7e 100644 --- a/src/main/java/fr/insee/rmes/ToColecticaApi/controller/PostItem.java +++ b/src/main/java/fr/insee/rmes/ToColecticaApi/controller/PostItem.java @@ -40,7 +40,7 @@ }) public class PostItem { - final static Logger log = LogManager.getLogger(PostItem.class); + static final Logger log = LogManager.getLogger(PostItem.class); private final ResourceLoader resourceLoader; private final ColecticaService colecticaService; @@ -111,7 +111,7 @@ public ResponseEntity uploadItem(@RequestParam("file") MultipartFile fil @Hidden @PostMapping("{type}/json") @Operation(summary = "Get JSON for a type of DDI item", description = "Get a JSON list of item for a type of DDI items .") - public ResponseEntity ByType ( + public ResponseEntity byType( @PathVariable("type") DDIItemType type) throws IOException, ExceptionColecticaUnreachable { diff --git a/src/main/java/fr/insee/rmes/metadata/client/MetadataClient.java b/src/main/java/fr/insee/rmes/metadata/client/MetadataClient.java index 5a044f61..e16a6a87 100644 --- a/src/main/java/fr/insee/rmes/metadata/client/MetadataClient.java +++ b/src/main/java/fr/insee/rmes/metadata/client/MetadataClient.java @@ -1,8 +1,6 @@ package fr.insee.rmes.metadata.client; import java.util.List; - -import fr.insee.rmes.metadata.exceptions.ExceptionColecticaUnreachable; import fr.insee.rmes.metadata.model.ColecticaItem; import fr.insee.rmes.metadata.model.ColecticaItemPostRef; import fr.insee.rmes.metadata.model.ColecticaItemPostRefList; diff --git a/src/main/java/fr/insee/rmes/metadata/client/MetadataClientImpl.java b/src/main/java/fr/insee/rmes/metadata/client/MetadataClientImpl.java index 9b1e7819..a71bcc78 100644 --- a/src/main/java/fr/insee/rmes/metadata/client/MetadataClientImpl.java +++ b/src/main/java/fr/insee/rmes/metadata/client/MetadataClientImpl.java @@ -11,7 +11,6 @@ import org.apache.http.entity.ContentType; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; diff --git a/src/main/java/fr/insee/rmes/metadata/controller/MetadataController.java b/src/main/java/fr/insee/rmes/metadata/controller/MetadataController.java index 329fa67f..b34fddf5 100644 --- a/src/main/java/fr/insee/rmes/metadata/controller/MetadataController.java +++ b/src/main/java/fr/insee/rmes/metadata/controller/MetadataController.java @@ -50,7 +50,7 @@ @ApiResponse(responseCode = "500", description = "Internal server error") }) public class MetadataController { - final static Logger log = LogManager.getLogger(MetadataController.class); + static final Logger log = LogManager.getLogger(MetadataController.class); @Autowired private MetadataService metadataService; diff --git a/src/main/java/fr/insee/rmes/metadata/model/ObjectColecticaPost.java b/src/main/java/fr/insee/rmes/metadata/model/ObjectColecticaPost.java index b3bfee45..aad403a9 100644 --- a/src/main/java/fr/insee/rmes/metadata/model/ObjectColecticaPost.java +++ b/src/main/java/fr/insee/rmes/metadata/model/ObjectColecticaPost.java @@ -15,23 +15,23 @@ public class ObjectColecticaPost { */ @JsonProperty("ItemTypes") - private List ItemTypes; + private List itemTypes; @JsonProperty("TargetItem") private TargetItem targetItem; @JsonProperty("UseDistinctResultItem") - private Boolean UseDistinctResultItem; + private Boolean useDistinctResultItem; @JsonProperty("UseDistinctTargetItem") - private Boolean UseDistinctTargetItem; + private Boolean useDistinctTargetItem; public List getItemTypes() { - return ItemTypes; + return itemTypes; } public void setItemTypes(List itemTypes) { - ItemTypes = itemTypes; + this.itemTypes = itemTypes; } public TargetItem getTargetItem() { @@ -43,25 +43,25 @@ public void setTargetItem(TargetItem targetItem) { } public Boolean getUseDistinctResultItem() { - return UseDistinctResultItem; + return useDistinctResultItem; } public void setUseDistinctResultItem(Boolean useDistinctResultItem) { - UseDistinctResultItem = useDistinctResultItem; + this.useDistinctResultItem = useDistinctResultItem; } public Boolean getUseDistinctTargetItem() { - return UseDistinctTargetItem; + return useDistinctTargetItem; } public void setUseDistinctTargetItem(Boolean useDistinctTargetItem) { - UseDistinctTargetItem = useDistinctTargetItem; + this.useDistinctTargetItem = useDistinctTargetItem; } @Override public String toString() { - return "RelationshipPost [ItemTypes=" + ItemTypes + ", targetItem=" + targetItem + ", UseDistinctResultItem=" - + UseDistinctResultItem + ", UseDistinctTargetItem=" + UseDistinctTargetItem + "]"; + return "RelationshipPost [ItemTypes=" + itemTypes + ", targetItem=" + targetItem + ", UseDistinctResultItem=" + + useDistinctResultItem + ", UseDistinctTargetItem=" + useDistinctTargetItem + "]"; } public String toJson() throws JsonProcessingException { diff --git a/src/main/java/fr/insee/rmes/metadata/model/Options.java b/src/main/java/fr/insee/rmes/metadata/model/Options.java index 79a699e3..66692b67 100644 --- a/src/main/java/fr/insee/rmes/metadata/model/Options.java +++ b/src/main/java/fr/insee/rmes/metadata/model/Options.java @@ -8,7 +8,7 @@ public class Options { private Object versionRationale = new Object(); @JsonProperty("SetName") - private String SetName = ""; + private String setName = ""; public Object getVersionRationale() { return versionRationale; @@ -19,16 +19,16 @@ public void setVersionRationale(Object versionReversionRationale) { } public String getSetName() { - return SetName; + return setName; } public void setSetName(String setName) { - SetName = setName; + this.setName = setName; } @Override public String toString() { - return "Options [versionReversionRationale=" + versionRationale + ", SetName=" + SetName + "]"; + return "Options [versionReversionRationale=" + versionRationale + ", SetName=" + setName + "]"; } } diff --git a/src/main/java/fr/insee/rmes/metadata/service/MetadataService.java b/src/main/java/fr/insee/rmes/metadata/service/MetadataService.java index 4afca2f7..a19069bb 100644 --- a/src/main/java/fr/insee/rmes/metadata/service/MetadataService.java +++ b/src/main/java/fr/insee/rmes/metadata/service/MetadataService.java @@ -5,7 +5,6 @@ import fr.insee.rmes.metadata.model.Relationship; import fr.insee.rmes.metadata.model.ColecticaItem; -import fr.insee.rmes.metadata.model.ColecticaItemRef; import fr.insee.rmes.metadata.model.ObjectColecticaPost; import fr.insee.rmes.metadata.model.Unit; import fr.insee.rmes.search.model.DDIItemType; diff --git a/src/main/java/fr/insee/rmes/metadata/service/MetadataServiceItemImpl.java b/src/main/java/fr/insee/rmes/metadata/service/MetadataServiceItemImpl.java index 3af0f48e..69cc5c8f 100644 --- a/src/main/java/fr/insee/rmes/metadata/service/MetadataServiceItemImpl.java +++ b/src/main/java/fr/insee/rmes/metadata/service/MetadataServiceItemImpl.java @@ -23,8 +23,8 @@ @Service @Slf4j public class MetadataServiceItemImpl implements MetadataServiceItem { - private final static String NAME_FRAGMENT = "//*[local-name()='Fragment']"; - private final static String TEXT_ID = ".//*[local-name()='ID']/text()"; + private static final String NAME_FRAGMENT = "//*[local-name()='Fragment']"; + private static final String TEXT_ID = ".//*[local-name()='ID']/text()"; @Autowired MetadataRepository metadataRepository; diff --git a/src/main/java/fr/insee/rmes/metadata/service/ddiinstance/DDIInstanceServiceImpl.java b/src/main/java/fr/insee/rmes/metadata/service/ddiinstance/DDIInstanceServiceImpl.java index fd33b787..b903f726 100644 --- a/src/main/java/fr/insee/rmes/metadata/service/ddiinstance/DDIInstanceServiceImpl.java +++ b/src/main/java/fr/insee/rmes/metadata/service/ddiinstance/DDIInstanceServiceImpl.java @@ -138,8 +138,7 @@ private String itemToString(ColecticaItem colecticaItem) throws Exception { private Node getNodeByXpath(DDIDocumentBuilder docBuilder, ColecticaItem ddiInstance, String xpathExpression) throws Exception { String fragment = xpathProcessor.queryString(ddiInstance.getItem(), xpathExpression); - Node node = DocumentBuilderUtils.getNode(fragment.trim(), docBuilder); - return node; + return DocumentBuilderUtils.getNode(fragment.trim(), docBuilder); } /** diff --git a/src/main/java/fr/insee/rmes/search/controller/DDISearch.java b/src/main/java/fr/insee/rmes/search/controller/DDISearch.java index 5421fe57..fe06439b 100644 --- a/src/main/java/fr/insee/rmes/search/controller/DDISearch.java +++ b/src/main/java/fr/insee/rmes/search/controller/DDISearch.java @@ -41,7 +41,7 @@ @ApiResponse(responseCode = "500", description = "Internal server error") }) public class DDISearch { - final static Logger log = LogManager.getLogger(DDISearch.class); + static final Logger log = LogManager.getLogger(DDISearch.class); @Autowired SearchService searchService; diff --git a/src/main/java/fr/insee/rmes/search/controller/ElasticsearchController.java b/src/main/java/fr/insee/rmes/search/controller/ElasticsearchController.java index 147c16ac..85f5f54b 100644 --- a/src/main/java/fr/insee/rmes/search/controller/ElasticsearchController.java +++ b/src/main/java/fr/insee/rmes/search/controller/ElasticsearchController.java @@ -45,16 +45,16 @@ @RestController @Hidden public class ElasticsearchController { - private final static String HTTPS = "https://"; - private final static String HTTP = "http://"; - private final static String AUTHORIZATION = "Authorization"; - private final static String BASIC = "Basic "; - private final static String KBN = "kbn-xsrf"; - private final static String REPORTING = "reporting"; - private final static String ERREUR_ES = "Une erreur s'est produite lors de la requête Elasticsearch."; - private final static String SEARCH = "/_search"; - private final static String CONTENT_TYPE = "Content-Type"; - private final static String APPLI_JSON = "application/json"; + private static final String HTTPS = "https://"; + private static final String HTTP = "http://"; + private static final String AUTHORIZATION = "Authorization"; + private static final String BASIC = "Basic "; + private static final String KBN = "kbn-xsrf"; + private static final String REPORTING = "reporting"; + private static final String ERREUR_ES = "Une erreur s'est produite lors de la requête Elasticsearch."; + private static final String SEARCH = "/_search"; + private static final String CONTENT_TYPE = "Content-Type"; + private static final String APPLI_JSON = "application/json"; @Value("${fr.insee.rmes.elasticsearch.host}") private String elasticHost; @@ -71,7 +71,7 @@ public class ElasticsearchController { private final ElasticsearchClient elasticsearchClient; - final static Logger logger = LogManager.getLogger(ElasticsearchController.class); + static final Logger logger = LogManager.getLogger(ElasticsearchController.class); @Autowired @@ -184,7 +184,7 @@ public ResponseEntity searchElastic() { } @PostMapping("/search/elastic/matchType/{type}") - public ResponseEntity ByType( + public ResponseEntity byType( @PathVariable ("type") DDIItemType type ) { try (CloseableHttpClient httpClient = HttpClients.createDefault()) { diff --git a/src/main/java/fr/insee/rmes/webservice/rest/RMeSEnvironment.java b/src/main/java/fr/insee/rmes/webservice/rest/RMeSEnvironment.java index f305e51a..4e25ebea 100644 --- a/src/main/java/fr/insee/rmes/webservice/rest/RMeSEnvironment.java +++ b/src/main/java/fr/insee/rmes/webservice/rest/RMeSEnvironment.java @@ -7,7 +7,6 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; -import jakarta.ws.rs.core.Response; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.json.JSONObject; @@ -17,14 +16,13 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.swing.text.html.parser.Entity; @RestController @RequestMapping("/env") @Tag(name = "RMeS Environment") public class RMeSEnvironment { - private final static Logger log = LogManager.getLogger(fr.insee.rmes.webservice.rest.RMeSEnvironment.class); + private static final Logger log = LogManager.getLogger(fr.insee.rmes.webservice.rest.RMeSEnvironment.class); @Autowired Environment env;