Commit 198ebe67 authored by naji's avatar naji
Browse files

changes to be in pr vitam-ui

parent 3d27d11d
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>api-pastis</artifactId>
<groupId>fr.gouv.vitamui</groupId>
<version>5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>pastis-client</artifactId>
<packaging>jar</packaging>
<name>VITAMUI Pastis Client API</name>
<dependencies>
<!-- VITAMUI -->
<dependency>
<groupId>fr.gouv.vitamui.commons</groupId>
<artifactId>commons-api</artifactId>
</dependency>
<dependency>
<groupId>fr.gouv.vitamui.commons</groupId>
<artifactId>commons-rest</artifactId>
</dependency>
<dependency>
<groupId>fr.gouv.vitamui</groupId>
<artifactId>pastis-commons</artifactId>
<version>5.0-SNAPSHOT</version>
</dependency>
<!-- JSON -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<!-- SPRING -->
<dependency>
<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>
</project>
/*
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.client;
import fr.gouv.vitamui.commons.rest.client.BaseRestClientFactory;
import fr.gouv.vitamui.commons.rest.client.configuration.HttpPoolConfiguration;
import fr.gouv.vitamui.commons.rest.client.configuration.RestClientConfiguration;
import org.springframework.boot.web.client.RestTemplateBuilder;
public class PastisRestClientFactory extends BaseRestClientFactory {
public PastisRestClientFactory(
RestClientConfiguration restClientConfiguration,
RestTemplateBuilder restTemplateBuilder) {
super(restClientConfiguration, restTemplateBuilder);
}
public PastisRestClientFactory(
RestClientConfiguration restClientConfig,
HttpPoolConfiguration httpPoolConfig,
RestTemplateBuilder restTemplateBuilder) {
super(restClientConfig, httpPoolConfig, restTemplateBuilder);
}
public PastisTransformationRestClient getPastisTransformationRestClient() {
return new PastisTransformationRestClient(getRestTemplate(), getBaseUrl());
}
}
/*
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.client;
import fr.gouv.vitamui.commons.api.domain.PaginatedValuesDto;
import fr.gouv.vitamui.commons.api.logger.VitamUILogger;
import fr.gouv.vitamui.commons.api.logger.VitamUILoggerFactory;
import fr.gouv.vitamui.commons.rest.client.BasePaginatingAndSortingRestClient;
import fr.gouv.vitamui.commons.rest.client.ExternalHttpContext;
import fr.gouv.vitamui.pastis.common.dto.ElementProperties;
import fr.gouv.vitamui.pastis.common.dto.profiles.Notice;
import fr.gouv.vitamui.pastis.common.dto.profiles.ProfileNotice;
import fr.gouv.vitamui.pastis.common.dto.profiles.ProfileResponse;
import fr.gouv.vitamui.pastis.common.rest.RestApi;
import fr.gouv.vitamui.pastis.common.util.FileSystemResource;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.util.UriComponentsBuilder;
import java.io.IOException;
import java.util.List;
public class PastisTransformationRestClient
extends BasePaginatingAndSortingRestClient<ProfileResponse, ExternalHttpContext> {
private static final VitamUILogger LOGGER =
VitamUILoggerFactory.getInstance(PastisTransformationRestClient.class);
public PastisTransformationRestClient(RestTemplate restTemplate,
String baseUrl) {
super(restTemplate, baseUrl);
}
@Override
protected Class<ProfileResponse> getDtoClass() {
return ProfileResponse.class;
}
@Override
protected ParameterizedTypeReference<List<ProfileResponse>> getDtoListClass() {
return new ParameterizedTypeReference<List<ProfileResponse>>() {
};
}
@Override
protected ParameterizedTypeReference<PaginatedValuesDto<ProfileResponse>> getDtoPaginatedClass() {
return new ParameterizedTypeReference<PaginatedValuesDto<ProfileResponse>>() {
};
}
@Override
public String getPathUrl() {
return RestApi.PASTIS;
}
public ResponseEntity<ProfileResponse> loadProfile(Notice notice, ExternalHttpContext context)
throws IOException {
LOGGER.debug("Transform profile");
MultiValueMap<String, String> headers = buildSearchHeaders(context);
final HttpEntity<Notice> request = new HttpEntity<>(notice, headers);
final ResponseEntity<ProfileResponse> response =
restTemplate.exchange(getUrl() + RestApi.PASTIS_TRANSFORM_PROFILE, HttpMethod.POST,
request, ProfileResponse.class);
return response;
}
public ResponseEntity<ProfileResponse> loadProfileFromFile(MultipartFile file, ExternalHttpContext context)
throws IOException {
LOGGER.debug("Upload profile");
final UriComponentsBuilder uriBuilder =
UriComponentsBuilder.fromHttpUrl(getUrl() + RestApi.PASTIS_UPLOAD_PROFILE);
MultiValueMap<String, Object> bodyMap = new LinkedMultiValueMap<>();
bodyMap.add("file", new FileSystemResource(file.getBytes(), file.getOriginalFilename()));
final HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity<>(bodyMap, buildHeaders(context));
return restTemplate.exchange(getUrl() + RestApi.PASTIS_UPLOAD_PROFILE,
HttpMethod.POST,
request,
ProfileResponse.class);
}
public ResponseEntity<String> getArchiveProfile(final ElementProperties json, ExternalHttpContext context)
throws IOException {
LOGGER.debug("Download archive profile");
MultiValueMap<String, String> headers = buildSearchHeaders(context);
final HttpEntity<ElementProperties> request = new HttpEntity<>(json, headers);
final ResponseEntity<String> response =
restTemplate.exchange(getUrl() + RestApi.PASTIS_DOWNLOAD_PA, HttpMethod.POST,
request, String.class);
return response;
}
public ResponseEntity<String> getArchiveUnitProfile(final ProfileNotice json, ExternalHttpContext context)
throws IOException {
LOGGER.debug("Download Arichivale unit profile");
MultiValueMap<String, String> headers = buildSearchHeaders(context);
final HttpEntity<ProfileNotice> request = new HttpEntity<>(json, headers);
final ResponseEntity<String> response =
restTemplate.exchange(getUrl() + RestApi.PASTIS_DOWNLOAD_PUA, HttpMethod.POST,
request, String.class);
return response;
}
public ResponseEntity<ElementProperties> loadProfilePA(Resource resource, ExternalHttpContext context)
throws IOException {
LOGGER.debug("Upload profile");
MultiValueMap<String, Object> bodyMap = new LinkedMultiValueMap<>();
bodyMap.add("file", new FileSystemResource(resource.getInputStream().readAllBytes(), "test_eeee.rng"));
final HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity<>(bodyMap, buildHeaders(context));
return restTemplate.exchange(getUrl() + RestApi.PASTIS_TRANSFORM_PROFILE_PA,
HttpMethod.POST,
request,
ElementProperties.class);
}
public ResponseEntity<ProfileResponse> createProfile(String profileType, ExternalHttpContext context)
throws IOException {
LOGGER.debug("Transform profile");
MultiValueMap<String, String> headers = buildSearchHeaders(context);
final HttpEntity<Notice> request = new HttpEntity<>(headers);
final ResponseEntity<ProfileResponse> response =
restTemplate.exchange(getUrl() + RestApi.PASTIS_CREATE_PROFILE + "?type=" + profileType, HttpMethod.GET,
request, ProfileResponse.class);
return response;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>api-pastis</artifactId>
<groupId>fr.gouv.vitamui</groupId>
<version>5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>pastis-commons</artifactId>
<name>VITAMUI Pastis Commons</name>
<dependencies>
<!-- VITAMUI -->
<dependency>
<groupId>fr.gouv.vitamui.commons</groupId>
<artifactId>commons-api</artifactId>
</dependency>
<dependency>
<groupId>fr.gouv.vitamui.commons</groupId>
<artifactId>commons-vitam</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>compile</scope>
</dependency>
<!--
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
-->
<!--Start of Jaxb API and it's implementation and dependencies- Java11-->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.istack</groupId>
<artifactId>istack-commons-runtime</artifactId>
<version>4.0.0-M2</version>
</dependency>
<!--End of Jaxb API and it's implementation and dependencies- Java11-->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>
<dependency>
<groupId>javax.xml.parsers</groupId>
<artifactId>jaxp-api</artifactId>
<version>1.4.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>jackson-xml-databind</artifactId>
<version>0.6.2</version>
</dependency>
<dependency>
<groupId>com.thaiopensource</groupId>
<artifactId>jing</artifactId>
<version>20091111</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
<exclusion>
<groupId>net.sf.saxon</groupId>
<artifactId>saxon</artifactId>
</exclusion>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.thaiopensource</groupId>
<artifactId>trang</artifactId>
<version>20091111</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
<exclusion>
<groupId>net.sf.saxon</groupId>
<artifactId>saxon</artifactId>
</exclusion>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.opengis.cite.xerces</groupId>
<artifactId>xercesImpl-xsd11</artifactId>
<version>2.12-beta-r1667115</version>
</dependency>
<dependency>
<groupId>xml-resolver</groupId>
<artifactId>xml-resolver</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
</dependencies>
</project>
/*
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.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
import fr.gouv.vitamui.pastis.common.util.RNGConstants;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
@Data
@NoArgsConstructor
public class ElementProperties implements Serializable {
private static final long serialVersionUID = -5093112183496503253L;
String name;
String type;
String cardinality;
String groupOrChoice;
String valueOrData;
String dataType;
String value;
String documentation;
@JsonIgnore
Object sedaData;
int level;
Long id;
Long parentId;
@JsonIgnore
ElementProperties parent;