diff --git a/api/api-pastis/pastis-client/pom.xml b/api/api-pastis/pastis-client/pom.xml index 99c62d1e522d1468e77eafe7b4e74fd2047261e3..b47c4acff498ac91429eaff6e2a745c3fda9d78f 100644 --- a/api/api-pastis/pastis-client/pom.xml +++ b/api/api-pastis/pastis-client/pom.xml @@ -17,11 +17,6 @@ <!-- VITAMUI --> - <dependency> - <groupId>fr.gouv.vitamui.commons</groupId> - <artifactId>commons-api</artifactId> - </dependency> - <dependency> <groupId>fr.gouv.vitamui.commons</groupId> <artifactId>commons-rest</artifactId> @@ -50,54 +45,6 @@ <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-webflux</artifactId> - </dependency> - - <!-- TEST --> - - <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter-engine</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.easymock</groupId> - <artifactId>easymock</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-api-easymock</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-module-junit4</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-test</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>fr.gouv.vitamui.commons</groupId> - <artifactId>commons-test</artifactId> - <type>test-jar</type> - <scope>test</scope> - </dependency> </dependencies> diff --git a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/dto/factory/CardinalityTagFactory.java b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/dto/factory/CardinalityTagFactory.java index fc08412ecc2001bf8892c50da028a763d51ef083..a79ce0c59d2cbf91a57f518712761d0053193f62 100644 --- a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/dto/factory/CardinalityTagFactory.java +++ b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/dto/factory/CardinalityTagFactory.java @@ -57,19 +57,5 @@ public class CardinalityTagFactory implements AbstractTagFactory<CardinalityTag> return cardinality; } - public RNGConstants.Cardinality checkCardinalityType(String cardinalityType) { - RNGConstants.Cardinality enumerationRngConstantsCardinality= null; - if (cardinalityType.equals("ZeroOrMoreTag")) { - enumerationRngConstantsCardinality = RNGConstants.Cardinality.ZERO_OR_MORE; - } - if (cardinalityType.equals("OneOrMoreTag")) { - enumerationRngConstantsCardinality = RNGConstants.Cardinality.ONE_OR_MORE; - } - if (cardinalityType.equals("OptionalTag")) { - enumerationRngConstantsCardinality = RNGConstants.Cardinality.OPTIONAL; - } - return enumerationRngConstantsCardinality; - } - } diff --git a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/dto/pua/PuaMetadata.java b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/dto/pua/PuaMetadata.java index 054a8a36dbcd089b01a948c23f44df3c8f92a1b8..fb1781922fbbc002c36c19be6e6163bd9dcf7ebc 100644 --- a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/dto/pua/PuaMetadata.java +++ b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/dto/pua/PuaMetadata.java @@ -47,14 +47,6 @@ public class PuaMetadata extends JsonElement { private Map<String, PuaMetadataDetails> puaDetails = new HashMap<>(); - public Map<String, PuaMetadataDetails> getPuaDetails() { - return puaDetails; - } - - public void setPuaDetails(Map<String, PuaMetadataDetails> puaDetails) { - this.puaDetails = puaDetails; - } - @Override public JsonElement deepCopy() { return null; diff --git a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/service/PuaDefinitions.java b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/service/PuaDefinitions.java deleted file mode 100644 index fcf96af10279057c7fb3c247e28075c31870b226..0000000000000000000000000000000000000000 --- a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/service/PuaDefinitions.java +++ /dev/null @@ -1,75 +0,0 @@ -/* -Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2021) - -[dad@cines.fr] - -This software is a computer program whose purpose is to provide -a web application to create, edit, import and export archive -profiles based on the french SEDA standard -(https://redirect.francearchives.fr/seda/). - - -This software is governed by the CeCILL-C license under French law and -abiding by the rules of distribution of free software. You can use, -modify and/ or redistribute the software under the terms of the CeCILL-C -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -As a counterpart to the access to the source code and rights to copy, -modify and redistribute granted by the license, users are provided only -with a limited warranty and the software's author, the holder of the -economic rights, and the successive licensors have only limited -liability. - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. - -The fact that you are presently reading this means that you have had -knowledge of the CeCILL-C license and that you accept its terms. -*/ - -package fr.gouv.vitamui.pastis.common.service; - -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; - -import java.util.HashMap; -import java.util.Map; - -@Service -public class PuaDefinitions { - - protected Map<String, Object> definitions; - @Value("${pua.definitions.file}") - private String defintionsFile; - - @JsonAnyGetter - public Map<String, Object> getDefinitions() { - return definitions; - } - - @JsonAnySetter - public void setDefinitions(String key, Object value) { - if (definitions == null) { - definitions = new HashMap<>(); - } - if (key != null) { - if (value != null) { - definitions.put(key, value); - } else { - definitions.remove(key); - } - } - - } -} diff --git a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/service/PuaFromJSON.java b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/service/PuaFromJSON.java index 04acf626bbe10c462cc042b304ff9ee655ab2792..7aa04668e9986dfcd9b1e26600e7c89d9430553f 100644 --- a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/service/PuaFromJSON.java +++ b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/service/PuaFromJSON.java @@ -54,8 +54,12 @@ public class PuaFromJSON { private static final String SCHEMA = "http://json-schema.org/draft-04/schema"; private static final String TYPE = "object"; private static final Boolean ADDITIONALPROPERTIES = false; + private final PuaPastisValidator puaPastisValidator; + @Autowired - private PuaPastisValidator puaPastisValidator; + public PuaFromJSON(final PuaPastisValidator puaPastisValidator){ + this.puaPastisValidator = puaPastisValidator; + } public String getControlSchemaFromElementProperties(ElementProperties elementProperties) throws IOException { // We use a JSONObject instead of POJO, since Jackson and Gson will add unnecessary diff --git a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/FileSystemResource.java b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/FileSystemResource.java index 66056b8dfe1e3b8b1e1394a4fef48db310a4eea4..dc93ed28335a9376d82efdb399b9f4f798ee8949 100644 --- a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/FileSystemResource.java +++ b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/FileSystemResource.java @@ -38,9 +38,12 @@ knowledge of the CeCILL-C license and that you accept its terms. package fr.gouv.vitamui.pastis.common.util; +import lombok.Getter; +import lombok.Setter; import org.springframework.core.io.ByteArrayResource; import org.springframework.lang.Nullable; +@Getter@Setter public final class FileSystemResource extends ByteArrayResource { private String fileName; @@ -50,11 +53,6 @@ public final class FileSystemResource extends ByteArrayResource { this.fileName = filename; } - @Override - public String getFilename() { - return fileName; - } - @Override public int hashCode() { return super.hashCode(); @@ -65,8 +63,4 @@ public final class FileSystemResource extends ByteArrayResource { return super.equals(other); } - public void setFilename(String fileName) { - this.fileName = fileName; - } - } diff --git a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/OrderedJSONObjectFactory.java b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/OrderedJSONObjectFactory.java deleted file mode 100644 index d3ce752cd0be194bbf77264e9a033111d0033476..0000000000000000000000000000000000000000 --- a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/OrderedJSONObjectFactory.java +++ /dev/null @@ -1,79 +0,0 @@ -/* -Copyright © CINES - Centre Informatique National pour l'Enseignement Supérieur (2021) - -[dad@cines.fr] - -This software is a computer program whose purpose is to provide -a web application to create, edit, import and export archive -profiles based on the french SEDA standard -(https://redirect.francearchives.fr/seda/). - - -This software is governed by the CeCILL-C license under French law and -abiding by the rules of distribution of free software. You can use, -modify and/ or redistribute the software under the terms of the CeCILL-C -license as circulated by CEA, CNRS and INRIA at the following URL -"http://www.cecill.info". - -As a counterpart to the access to the source code and rights to copy, -modify and redistribute granted by the license, users are provided only -with a limited warranty and the software's author, the holder of the -economic rights, and the successive licensors have only limited -liability. - -In this respect, the user's attention is drawn to the risks associated -with loading, using, modifying and/or developing or reproducing the -software by the user in light of its specific status of free software, -that may mean that it is complicated to manipulate, and that also -therefore means that it is reserved for developers and experienced -professionals having in-depth computer knowledge. Users are therefore -encouraged to load and test the software's suitability as regards their -requirements in conditions enabling the security of their systems and/or -data to be ensured and, more generally, to use and operate it in the -same conditions as regards security. - -The fact that you are presently reading this means that you have had -knowledge of the CeCILL-C license and that you accept its terms. -*/ - -package fr.gouv.vitamui.pastis.common.util; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.json.JSONObject; - -import java.lang.reflect.Field; -import java.util.LinkedHashMap; - -public class OrderedJSONObjectFactory { - private static final Logger LOGGER = LoggerFactory.getLogger(OrderedJSONObjectFactory.class); - private static boolean setupDone = false; - private static Field jsonObjectMapField = null; - - private OrderedJSONObjectFactory() {} - - public static void setupFieldAccessor() { - if (!setupDone) { - setupDone = true; - try { - jsonObjectMapField = JSONObject.class.getDeclaredField("map"); - jsonObjectMapField.setAccessible(true); - } catch (NoSuchFieldException ignored) { - LOGGER.warn("JSONObject implementation has changed, returning unmodified instance"); - } - } - } - - public static JSONObject create() { - setupFieldAccessor(); - JSONObject result = new JSONObject(); - try { - if (jsonObjectMapField != null) { - jsonObjectMapField.set(result, new LinkedHashMap<>()); - } - } catch (IllegalAccessException e) { - LOGGER.info(e.getMessage()); - } - return result; - } -} diff --git a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/PastisGetXmlJsonTree.java b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/PastisGetXmlJsonTree.java index 24ba3b31559db3e3d1e1b8200817e4ac3cf7e1b6..ec5b15cba5edd714db34d9cde870d561023911ce 100644 --- a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/PastisGetXmlJsonTree.java +++ b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/PastisGetXmlJsonTree.java @@ -65,60 +65,4 @@ public class PastisGetXmlJsonTree { return ElementRNG.getElementStaticRoot(); } - // Test an xml to json and a json to xml. - public String getJsonParsedTreeTest(ElementRNG elementRNGRoot) throws JAXBException, FileNotFoundException { - - //vWhen the handler is called, the proprities tree (json) is build - // using its ElementRNG(elementRngRoot) object. - // The elementRngRoot is filled when the xml file is read, by passing - // it to the contentHanler of the Xml reader. - // The methods used are the 5 main methods of a DefaultHandler type - // See methods bellow - ElementRNG.buildElementPropertiesTree(elementRNGRoot, 0, null); - ElementProperties eparent = ElementRNG.getElementStaticRoot(); - - - // The eparentRng is an object of type BalizeXML. It is built using the - // object eparent (of type ElementProperties) that, in fact, represent the json - // prouced during the parser's first call. - BaliseXML.buildBaliseXMLTree(eparent, 0, null); - BaliseXML eparentRng = BaliseXML.getBaliseXMLStatic(); - - - // Transforms java objects to Xml file (Marshalling) - JAXBContext contextObj = - JAXBContext.newInstance(AttributeXML.class, ElementXML.class, DataXML.class, ValueXML.class, - OptionalXML.class, OneOrMoreXML.class, - ZeroOrMoreXML.class, AnnotationXML.class, DocumentationXML.class, ChoiceXml.class); - Marshaller marshallerObj = contextObj.createMarshaller(); - marshallerObj.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); - marshallerObj.setProperty("com.sun.xml.bind.marshaller.CharacterEscapeHandler", - new PastisCustomCharacterEscapeHandler()); - - marshallerObj.marshal(eparentRng, new FileOutputStream("generated_test.xml")); - - - ObjectMapper mapper = new ObjectMapper(); - String jsonString = ""; - try { - jsonString = mapper.writeValueAsString(eparent); - } catch (JsonGenerationException e1) { - LOGGER.info("JsonGenerationException", e1); - } catch (JsonMappingException e1) { - LOGGER.info("JsonMappingException", e1); - } catch (IOException e1) { - LOGGER.info("IOException", e1); - } - return "[" + jsonString + "]"; - } - - - public String getXmlParsedTree(String jsonString) throws IOException { - - ObjectMapper objectMapper = new ObjectMapper(); - ObjectMapper xmlMapper = new ObjectMapper(); - JsonNode tree = objectMapper.readTree(jsonString); - return xmlMapper.writeValueAsString(tree); - } - } diff --git a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/PastisSAX2Handler.java b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/PastisSAX2Handler.java index d1205b82f256c806f20c245ef41376553e2b3fc1..433a58eb00146e1fccc4571ed5ead1a633cf6d58 100644 --- a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/PastisSAX2Handler.java +++ b/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/PastisSAX2Handler.java @@ -43,15 +43,14 @@ import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; -import java.util.ArrayDeque; -import java.util.Deque; +import java.util.Stack; public class PastisSAX2Handler extends DefaultHandler { @Getter private ElementRNG elementRNGRoot; boolean isValue; - private Deque<ElementRNG> stackRNG = new ArrayDeque<>(); + private Stack<ElementRNG> stackRNG = new Stack<>(); private boolean isInDocumentationTag; private StringBuilder documentationContent; @@ -81,7 +80,7 @@ public class PastisSAX2Handler extends DefaultHandler { elementRNG.setType(localName); elementRNG.setDataType(attr.getValue("type")); if (!stackRNG.isEmpty()) { - ElementRNG e = stackRNG.getLast(); + ElementRNG e = stackRNG.lastElement(); elementRNG.setParent(e); e.getChildren().add(elementRNG); } @@ -129,11 +128,11 @@ public class PastisSAX2Handler extends DefaultHandler { public void characters(char[] caracteres, int start, int length) throws SAXException { if (isInDocumentationTag) { documentationContent.append(new String(caracteres, start, length)); - stackRNG.getLast().setValue(documentationContent.toString()); + stackRNG.lastElement().setValue(documentationContent.toString()); } if (isValue) { String valueContent = new String(caracteres, start, length); - stackRNG.getLast().setValue(valueContent); + stackRNG.lastElement().setValue(valueContent); this.isValue = false; } } diff --git a/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/ManifestValidatorTest.java b/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/ManifestValidatorTest.java index 71c0fe9151c8dca782510530fa7e20a33d30603f..0407073c954cbbde298d426957a67d6be1aaf7f3 100644 --- a/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/ManifestValidatorTest.java +++ b/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/ManifestValidatorTest.java @@ -54,15 +54,12 @@ import fr.gouv.vitamui.pastis.common.dto.jaxb.ValueXML; import fr.gouv.vitamui.pastis.common.dto.jaxb.ZeroOrMoreXML; import fr.gouv.vitamui.pastis.common.util.ManifestValidator; import fr.gouv.vitamui.pastis.common.util.PastisCustomCharacterEscapeHandler; -import fr.gouv.vitamui.pastis.common.util.PropertiesUtils; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; diff --git a/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/PastisGetJsonTree.java b/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/PastisGetJsonTree.java new file mode 100644 index 0000000000000000000000000000000000000000..24c1fbe9274942df045da941ed437fcfabf6a5df --- /dev/null +++ b/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/PastisGetJsonTree.java @@ -0,0 +1,70 @@ +package fr.gouv.vitamui.pastis.common.service; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import fr.gouv.vitamui.pastis.common.dto.ElementProperties; +import fr.gouv.vitamui.pastis.common.dto.ElementRNG; +import fr.gouv.vitamui.pastis.common.dto.jaxb.*; +import fr.gouv.vitamui.pastis.common.util.PastisCustomCharacterEscapeHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; + +public class PastisGetJsonTree { + + private static final Logger LOGGER = LoggerFactory.getLogger(PastisGetJsonTree.class); + + // Test an xml to json and a json to xml. + public String getJsonParsedTree(ElementRNG elementRNGRoot) throws JAXBException, FileNotFoundException { + + //vWhen the handler is called, the proprities tree (json) is build + // using its ElementRNG(elementRngRoot) object. + // The elementRngRoot is filled when the xml file is read, by passing + // it to the contentHanler of the Xml reader. + // The methods used are the 5 main methods of a DefaultHandler type + // See methods bellow + ElementRNG.buildElementPropertiesTree(elementRNGRoot, 0, null); + ElementProperties eparent = ElementRNG.getElementStaticRoot(); + + + // The eparentRng is an object of type BalizeXML. It is built using the + // object eparent (of type ElementProperties) that, in fact, represent the json + // prouced during the parser's first call. + BaliseXML.buildBaliseXMLTree(eparent, 0, null); + BaliseXML eparentRng = BaliseXML.getBaliseXMLStatic(); + + + // Transforms java objects to Xml file (Marshalling) + JAXBContext contextObj = + JAXBContext.newInstance(AttributeXML.class, ElementXML.class, DataXML.class, ValueXML.class, + OptionalXML.class, OneOrMoreXML.class, + ZeroOrMoreXML.class, AnnotationXML.class, DocumentationXML.class, ChoiceXml.class); + Marshaller marshallerObj = contextObj.createMarshaller(); + marshallerObj.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + marshallerObj.setProperty("com.sun.xml.bind.marshaller.CharacterEscapeHandler", + new PastisCustomCharacterEscapeHandler()); + + marshallerObj.marshal(eparentRng, new FileOutputStream("generated_test.xml")); + + + ObjectMapper mapper = new ObjectMapper(); + String jsonString = ""; + try { + jsonString = mapper.writeValueAsString(eparent); + } catch (JsonGenerationException e1) { + LOGGER.debug("JsonGenerationException", e1); + } catch (JsonMappingException e1) { + LOGGER.debug("JsonMappingException", e1); + } catch (IOException e1) { + LOGGER.debug("IOException", e1); + } + return "[" + jsonString + "]"; + } +} diff --git a/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/PastisTest.java b/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/PastisTest.java index fb1fe52ea754859122bd9b281c356007f0460ba3..b2e1b0a6e825d6bd9d34ae1048e1f3220aa25b96 100644 --- a/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/PastisTest.java +++ b/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/PastisTest.java @@ -38,11 +38,7 @@ knowledge of the CeCILL-C license and that you accept its terms. package fr.gouv.vitamui.pastis.common.service; import com.fasterxml.jackson.databind.ObjectMapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import fr.gouv.vitamui.pastis.common.dto.ElementProperties; -import fr.gouv.vitamui.pastis.common.dto.ElementRNG; -import fr.gouv.vitamui.pastis.common.util.PastisGetXmlJsonTree; import fr.gouv.vitamui.pastis.common.util.PastisMarshaller; import fr.gouv.vitamui.pastis.common.util.PastisSAX2Handler; import org.junit.Assert; @@ -65,8 +61,6 @@ import java.net.URISyntaxException; @TestPropertySource(locations = "/application-test.yml") public class PastisTest { - private static final Logger LOGGER = LoggerFactory.getLogger(ElementRNG.class); - public PastisMarshaller pastisMarshaller = new PastisMarshaller(); @Value("${rng.base.file}") @@ -96,7 +90,7 @@ public class PastisTest { public void testIfJSONCanBeGenerated() throws IOException, JAXBException, URISyntaxException, SAXException { PastisSAX2Handler handler = new PastisSAX2Handler(); - PastisGetXmlJsonTree getJson = new PastisGetXmlJsonTree(); + PastisGetJsonTree getJson = new PastisGetJsonTree(); XMLReader xmlReader = XMLReaderFactory.createXMLReader(); xmlReader.setContentHandler(handler); @@ -104,7 +98,7 @@ public class PastisTest { ClassLoader loader = ClassLoader.getSystemClassLoader(); xmlReader.parse(loader.getResource(this.rngFileName).toURI().toString()); - String jsonTree = getJson.getJsonParsedTreeTest(handler.getElementRNGRoot()); + String jsonTree = getJson.getJsonParsedTree(handler.getElementRNGRoot()); Assert.assertNotNull("JSON profile generated successfully", jsonTree); diff --git a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/PropertiesUtils.java b/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/PropertiesUtils.java similarity index 93% rename from api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/PropertiesUtils.java rename to api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/PropertiesUtils.java index 7eef2129b8d03ac4e21f291755feccb2cfee269a..80aceb8c37a916122c3d040c513633e0288ddca7 100644 --- a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/PropertiesUtils.java +++ b/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/PropertiesUtils.java @@ -35,7 +35,7 @@ same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL-C license and that you accept its terms. */ -package fr.gouv.vitamui.pastis.common.util; +package fr.gouv.vitamui.pastis.common.service; import java.io.File; import java.io.FileNotFoundException; @@ -69,10 +69,11 @@ public final class PropertiesUtils { throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); } if (url == null) { - url = Thread.currentThread().getContextClassLoader().getResource(resourcesFile); - } - if (url == null) { - throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); + try { + url = Thread.currentThread().getContextClassLoader().getResource(resourcesFile); + } catch (Exception e) { + throw new FileNotFoundException(FILE_NOT_FOUND_IN_RESOURCES + resourcesFile); + } } File file; try { diff --git a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/RNGProfileValidator.java b/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/RNGProfileValidator.java similarity index 97% rename from api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/RNGProfileValidator.java rename to api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/RNGProfileValidator.java index 28ed3fa60091d97d91ec20d89dca99f4e2770db7..5d077de05c111b9a46938a7c9d8a738830c735a1 100644 --- a/api/api-pastis/pastis-commons/src/main/java/fr/gouv/vitamui/pastis/common/util/RNGProfileValidator.java +++ b/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/RNGProfileValidator.java @@ -35,8 +35,9 @@ same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL-C license and that you accept its terms. */ -package fr.gouv.vitamui.pastis.common.util; +package fr.gouv.vitamui.pastis.common.service; +import fr.gouv.vitamui.pastis.common.util.XMLInputFactoryUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xml.sax.SAXException; diff --git a/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/RNGProfileValidatorTest.java b/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/RNGProfileValidatorTest.java index adb426a19c18a87c51210e863637257328ad1af4..149c185545f76f173c227037fc8d78870162efb0 100644 --- a/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/RNGProfileValidatorTest.java +++ b/api/api-pastis/pastis-commons/src/test/java/fr/gouv/vitamui/pastis/common/service/RNGProfileValidatorTest.java @@ -41,8 +41,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import fr.gouv.vitamui.pastis.common.dto.ElementProperties; import fr.gouv.vitamui.pastis.common.dto.jaxb.*; import fr.gouv.vitamui.pastis.common.util.PastisCustomCharacterEscapeHandler; -import fr.gouv.vitamui.pastis.common.util.PropertiesUtils; -import fr.gouv.vitamui.pastis.common.util.RNGProfileValidator; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; diff --git a/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/config/PastisConfiguration.java b/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/config/PastisConfiguration.java index 879bd71a5de8751112a783f5a7b2bd296083ddee..0d405eeba15b52ecd67a296c1640c52b3b33b758 100644 --- a/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/config/PastisConfiguration.java +++ b/api/api-pastis/pastis-standalone/src/main/java/fr/gouv/vitamui/pastis/standalone/config/PastisConfiguration.java @@ -90,7 +90,7 @@ public class PastisConfiguration { @Bean public PuaFromJSON puaFromJSON() { - return new PuaFromJSON(); + return new PuaFromJSON(puaPastisValidator()); } @Bean diff --git a/api/api-pastis/pastis/pom.xml b/api/api-pastis/pastis/pom.xml index a99cceaa5d4e3e4c2986a29fde6cd0d631b9a6ea..fc98433657065d03c0f0206d89ffa0836449adb1 100644 --- a/api/api-pastis/pastis/pom.xml +++ b/api/api-pastis/pastis/pom.xml @@ -317,110 +317,4 @@ </plugins> </build> - <profiles> - <!-- Start of standalone profile --> - <profile> - <id>standalone</id> - <build> - <!-- Start of stadalone profile plugins --> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <dependencies> - <dependency> - <groupId>fr.gouv.vitamui</groupId> - <artifactId>pastis-client</artifactId> - <version>5.0-SNAPSHOT</version> - <exclusions> - <exclusion> - <groupId>*</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>fr.gouv.vitamui.commons</groupId> - <artifactId>commons-api</artifactId> - <version>5.0-SNAPSHOT</version> - <exclusions> - <exclusion> - <groupId>*</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>fr.gouv.vitamui.commons</groupId> - <artifactId>commons-rest</artifactId> - <version>5.0-SNAPSHOT</version> - <exclusions> - <exclusion> - <groupId>*</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>fr.gouv.vitamui.commons</groupId> - <artifactId>commons-vitam</artifactId> - <version>5.0-SNAPSHOT</version> - <exclusions> - <exclusion> - <groupId>*</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>fr.gouv.vitamui</groupId> - <artifactId>security-client</artifactId> - <version>5.0-SNAPSHOT</version> - <exclusions> - <exclusion> - <groupId>*</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>fr.gouv.vitamui</groupId> - <artifactId>iam-internal-client</artifactId> - <version>5.0-SNAPSHOT</version> - <exclusions> - <exclusion> - <groupId>*</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - </dependencies> - <executions> - <execution> - <id>build-info</id> - <goals> - <goal>build-info</goal> - </goals> - </execution> - <execution> - <goals> - <goal>repackage</goal> - </goals> - </execution> - </executions> - <configuration> - <executable>true</executable> - <attach>false</attach> <!-- Need to use the original jar for integration-tests --> - <mainClass>fr.gouv.vitamui.pastis.server.ApiPastisServerApplication</mainClass> - <arguments> - <argument>--spring.profiles.active=dev</argument> - </arguments> - </configuration> - </plugin> - </plugins> - </build> - </profile> - - </profiles> - </project> diff --git a/api/api-pastis/pastis/src/main/java/fr/gouv/vitamui/pastis/server/config/ApiPastisServerConfig.java b/api/api-pastis/pastis/src/main/java/fr/gouv/vitamui/pastis/server/config/ApiPastisServerConfig.java index 308be5115cbe48e7579a2095e92a06a670379ad6..96c74ffb87c22c85edef46c63c7f9dd08d7931e6 100644 --- a/api/api-pastis/pastis/src/main/java/fr/gouv/vitamui/pastis/server/config/ApiPastisServerConfig.java +++ b/api/api-pastis/pastis/src/main/java/fr/gouv/vitamui/pastis/server/config/ApiPastisServerConfig.java @@ -129,7 +129,7 @@ public class ApiPastisServerConfig extends AbstractContextConfiguration { @Bean public PuaFromJSON puaFromJSON() { - return new PuaFromJSON(); + return new PuaFromJSON(puaPastisValidator()); } @Bean diff --git a/api/api-pastis/pastis/src/test/java/fr/gouv/vitamui/pastis/server/config/ApiPastisServerConfigTest.java b/api/api-pastis/pastis/src/test/java/fr/gouv/vitamui/pastis/server/config/ApiPastisServerConfigTest.java index e5b01d86201bff58ace61888813c798e29b6dfb2..72f6d7e7ec5a8838fee4ea4d8c331e6ba06a1ab9 100644 --- a/api/api-pastis/pastis/src/test/java/fr/gouv/vitamui/pastis/server/config/ApiPastisServerConfigTest.java +++ b/api/api-pastis/pastis/src/test/java/fr/gouv/vitamui/pastis/server/config/ApiPastisServerConfigTest.java @@ -41,7 +41,6 @@ import fr.gouv.vitam.access.external.client.AccessExternalClient; import fr.gouv.vitam.access.external.client.AdminExternalClient; import fr.gouv.vitamui.commons.api.application.AbstractContextConfiguration; import fr.gouv.vitamui.pastis.common.service.JsonFromPUA; -import fr.gouv.vitamui.pastis.common.service.PuaDefinitions; import fr.gouv.vitamui.pastis.common.service.PuaFromJSON; import fr.gouv.vitamui.pastis.common.service.PuaPastisValidator; import fr.gouv.vitamui.pastis.common.util.NoticeUtils; @@ -75,9 +74,6 @@ public class ApiPastisServerConfigTest extends AbstractContextConfiguration { @MockBean private NoticeUtils noticeFromPUA; - @MockBean - private PuaDefinitions puaDefinitions; - @MockBean private PuaFromJSON puaFromJSON; diff --git a/api/api-pastis/pastis/src/test/resources/application.yml b/api/api-pastis/pastis/src/test/resources/application.yml index 6f219d9d46ec8584117d4b211a29fb0a7c0503ea..38d8490a40ddcc929eab1e5d59a59c14f10196cf 100644 --- a/api/api-pastis/pastis/src/test/resources/application.yml +++ b/api/api-pastis/pastis/src/test/resources/application.yml @@ -25,12 +25,4 @@ server-identity: identityName: vitamui-test identityRole: pastis-external identityServerId: 1 -json.template.file: rng/AUP_default_PASTIS.json -rng.base.directory: rng/ -rng.base.file: rng/Profil_seda_pastis_mvp.rng -json.base.file: rng/ProfileJson.json -pua.definitions.file: pua_validation/ProfileJson.json - - - logbook.scheduling.sendEventToVitamTasks.enabled: false