Commit 1117657d authored by granier's avatar granier
Browse files

Suppression de vieux code

parent 34b7b4dc
<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">
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>fr.gouv.vitam.worker.core.plugin</groupId>
......@@ -6,7 +8,7 @@
<version>1.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>format-validator</name>
<name>format-validator-plugin</name>
<url>http://maven.apache.org</url>
<properties>
......@@ -19,6 +21,7 @@
<jdk.version.debian>openjdk-11-jre-headless</jdk.version.debian>
<jackson.version>2.9.9</jackson.version>
<slf4j.version>1.7.25</slf4j.version>
<format-validator.version>3.6.4</format-validator.version>
<junit.version>4.12</junit.version>
<assertj.version>3.11.1</assertj.version>
<mockito.version>2.23.4</mockito.version>
......@@ -28,44 +31,20 @@
<maven.resources.version>3.1.0</maven.resources.version>
<maven.exec.version>1.6.0</maven.exec.version>
<maven.dependency.version>3.1.1</maven.dependency.version>
<unix.user>vitam</unix.user>
<unix.group>vitam</unix.group>
<unix.name>formatvalidator-griffin</unix.name>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<vitam.version>3.0.2</vitam.version>
</properties>
<profiles>
<profile>
<id>rpm</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
<configuration>
<disabled>false</disabled>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.4</version>
</extension>
</extensions>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.4</version>
</extension>
</extensions>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
......@@ -105,18 +84,18 @@
<dependency>
<groupId>fr.cines.validator</groupId>
<artifactId>format-validator</artifactId>
<version>3.5.11</version>
<version>${format-validator.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>fr.gouv.vitam</groupId>
<artifactId>common-plugin</artifactId>
<version>${vitam.version}</version>
</dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>fr.gouv.vitam</groupId>
<artifactId>common-plugin</artifactId>
<version>${vitam.version}</version>
</dependency>
</dependencies>
<repositories>
......@@ -124,22 +103,22 @@
<id>cines-repo</id>
<url>http://maven.cines.fr/maven</url>
</repository>
<repository>
<id>vitam</id>
<url>http://download.programmevitam.fr/vitam_repository/3.0.2/mvn_repo/</url>
</repository>
<repository>
<id>vitam</id>
<url>http://download.programmevitam.fr/vitam_repository/3.0.2/mvn_repo/</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>cines-repo</id>
<name>cines-repository</name>
<url>sftp://maven.cines.fr/opt/maven/repo</url>
</repository>
</distributionManagement>
<scm>
<distributionManagement>
<repository>
<id>cines-repo</id>
<name>cines-repository</name>
<url>sftp://maven.cines.fr/opt/maven/repo</url>
</repository>
</distributionManagement>
<scm>
<url>scm:git:https://dci-gitlab.cines.fr/dad/cines-vitam-plugins/format-validator-plugin.git</url>
<connection>scm:git:https://dci-gitlab.cines.fr/dad/cines-vitam-plugins/format-validator-plugin.git</connection>
<developerConnection>scm:git:https://dci-gitlab.cines.fr/dad/cines-vitam-plugins/format-validator-plugin.git</developerConnection>
<tag>format-validator-plugin-1.0</tag>
</scm>
<tag>format-validator-plugin-1.0</tag>
</scm>
</project>
/*
* Copyright CINES, 2020
*
* Ce logiciel est régi par la licence CeCILL-C soumise au
* droit français et respectant les principes de diffusion des logiciels libres. Vous pouvez
* utiliser, modifier et/ou redistribuer ce programme sous les conditions de la licence CeCILL-C
* telle que diffusée par le CEA, le CNRS et l'INRIA sur le site "http://www.cecill.info". En
* contrepartie de l'accessibilité au code source et des droits de copie, de modification et de
* redistribution accordés par cette licence, il n'est offert aux utilisateurs qu'une garantie
* limitée. Pour les mêmes raisons, seule une responsabilité restreinte pèse sur l'auteur du
* programme, le titulaire des droits patrimoniaux et les concédants successifs. A cet égard
* l'attention de l'utilisateur est attirée sur les risques associés au chargement, à l'utilisation,
* à la modification et/ou au développement et à la reproduction du logiciel par l'utilisateur étant
* donné sa spécificité de logiciel libre, qui peut le rendre complexe à manipuler et qui le réserve
* donc à des développeurs et des professionnels avertis possédant des connaissances informatiques
* approfondies. Les utilisateurs sont donc invités à charger et tester l'adéquation du logiciel à
* leurs besoins dans des conditions permettant d'assurer la sécurité de leurs systèmes et ou de
* leurs données et, plus généralement, à l'utiliser et l'exploiter dans les mêmes conditions de
* sécurité. Le fait que vous puissiez accéder à cet en-tête signifie que vous avez pris
* connaissance de la licence CeCILL-C, et que vous en avez accepté les termes.
*/
package fr.cines.vitam.griffins.formatvalidator;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import fr.cines.vitam.griffins.formatvalidator.pojo.BatchStatus;
import fr.cines.vitam.griffins.formatvalidator.pojo.Input;
/**
* @author Alexandre Granier <granier@cines.fr> <granier.alexandre@free.fr>
*/
public class BatchProcessor {
/**
* Repertoire ou se trouve les fichiers a valider
*/
private final Path batchDirectory;
public static final String outputFilesDirName = "output-files";
public static final String parametersFileName = "parameters.json";
public static final String resultFileName = "result.json";
public static final String inputFilesDirName = "input-files";
public BatchProcessor(Path batchDirectory) {
this.batchDirectory = batchDirectory;
}
public BatchStatus execute() {
long startTime = System.currentTimeMillis();
String batchProcessingId = batchDirectory.getFileName().toString();
getInputs()
.stream()
.forEach(System.out::println);
return BatchStatus.ok(batchProcessingId, startTime);
}
/**
* Retourne la liste des fichiers a traiter
* @return List<Input> La liste
*/
private List<Input> getInputs() {
try (Stream<Path> stream = Files.walk(Paths.get(batchDirectory.toString(),inputFilesDirName), 1)) {
return stream
.filter(file -> !Files.isDirectory(file))
.map(file -> {
return new Input(file.getFileName().toString(), "");
})
.collect(Collectors.toList());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
/*
* Copyright CINES, 2020
*
* Ce logiciel est régi par la licence CeCILL-C soumise au
* droit français et respectant les principes de diffusion des logiciels libres. Vous pouvez
* utiliser, modifier et/ou redistribuer ce programme sous les conditions de la licence CeCILL-C
* telle que diffusée par le CEA, le CNRS et l'INRIA sur le site "http://www.cecill.info". En
* contrepartie de l'accessibilité au code source et des droits de copie, de modification et de
* redistribution accordés par cette licence, il n'est offert aux utilisateurs qu'une garantie
* limitée. Pour les mêmes raisons, seule une responsabilité restreinte pèse sur l'auteur du
* programme, le titulaire des droits patrimoniaux et les concédants successifs. A cet égard
* l'attention de l'utilisateur est attirée sur les risques associés au chargement, à l'utilisation,
* à la modification et/ou au développement et à la reproduction du logiciel par l'utilisateur étant
* donné sa spécificité de logiciel libre, qui peut le rendre complexe à manipuler et qui le réserve
* donc à des développeurs et des professionnels avertis possédant des connaissances informatiques
* approfondies. Les utilisateurs sont donc invités à charger et tester l'adéquation du logiciel à
* leurs besoins dans des conditions permettant d'assurer la sécurité de leurs systèmes et ou de
* leurs données et, plus généralement, à l'utiliser et l'exploiter dans les mêmes conditions de
* sécurité. Le fait que vous puissiez accéder à cet en-tête signifie que vous avez pris
* connaissance de la licence CeCILL-C, et que vous en avez accepté les termes.
*/
package fr.cines.vitam.griffins.formatvalidator;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.cines.vitam.griffins.formatvalidator.pojo.BatchStatus;
public class Main {
private static final Logger logger = LoggerFactory.getLogger(Main.class);
public static final String ID = "griffin-format-validator";
public static void main( String[] args )
{
if (args.length != 1 || args[0].isEmpty() || Files.notExists(Paths.get(args[0]))) {
throw new RuntimeException(String.format("Need a batch directory in argument here: %s.", Arrays.toString(args)));
}
Path batchDirectory = Paths.get(args[0]);
logger.info("Start {} on batch {}.", ID, batchDirectory);
BatchProcessor processor = new BatchProcessor(batchDirectory);
BatchStatus batch = processor.execute();
logger.info("Griffin {} ends with status {}", ID, batch);
System.exit(batch.status.code);
}
}
/*******************************************************************************
* Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2019)
*
* contact.vitam@culture.gouv.fr
*
* This software is a computer program whose purpose is to implement a digital archiving back-office system managing
* high volumetry securely and efficiently.
*
* This software is governed by the CeCILL 2.1 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 2.1 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 2.1 license and that you
* accept its terms.
*******************************************************************************/
package fr.cines.vitam.griffins.formatvalidator.pojo;
import com.fasterxml.jackson.annotation.JsonProperty;
import fr.cines.vitam.griffins.formatvalidator.status.ActionType;
public class Action {
@JsonProperty("Type")
private ActionType type;
@JsonProperty("Values")
private Values values;
public Action() {
}
public Action(ActionType type, Values values) {
this.type = type;
this.values = values;
}
public Action(ActionType type) {
this.type = type;
}
public ActionType getType() {
return type;
}
public void setType(ActionType type) {
this.type = type;
}
public Values getValues() {
return values;
}
public void setValues(Values values) {
this.values = values;
}
@Override
public String toString() {
return "Action{" +
"Type=" + type +
", Values=" + values +
'}';
}
}
/*******************************************************************************
* Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2019)
*
* contact.vitam@culture.gouv.fr
*
* This software is a computer program whose purpose is to implement a digital archiving back-office system managing
* high volumetry securely and efficiently.
*
* This software is governed by the CeCILL 2.1 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 2.1 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 2.1 license and that you
* accept its terms.
*******************************************************************************/
package fr.cines.vitam.griffins.formatvalidator.pojo;
import fr.cines.vitam.griffins.formatvalidator.status.GriffinStatus;
import static fr.cines.vitam.griffins.formatvalidator.status.GriffinStatus.KO;
import static fr.cines.vitam.griffins.formatvalidator.status.GriffinStatus.WARNING;
import static fr.cines.vitam.griffins.formatvalidator.status.GriffinStatus.OK;
public class BatchStatus {
public final String batchId;
public final long startTime;
public final long endTime;
public final GriffinStatus status;
public final String error;
private BatchStatus(String batchId, long startTime, long endTime, GriffinStatus status, String error) {
this.batchId = batchId;
this.startTime = startTime;
this.endTime = endTime;
this.status = status;
this.error = error;
}
public static BatchStatus warning(String batchId, long start, String error) {
return new BatchStatus(batchId, start, System.currentTimeMillis(), WARNING, error);
}
public static BatchStatus ok(String batchId, long start) {
return new BatchStatus(batchId, start, System.currentTimeMillis(), OK, "");
}
public static BatchStatus error(String batchId, long start, Throwable error) {
return new BatchStatus(batchId, start, System.currentTimeMillis(), KO, error.getMessage());
}
@Override
public String toString() {
return "BatchStatus{" +
"batchId='" + batchId + '\'' +
", startTime=" + startTime +
", endTime=" + endTime +
", status=" + status +
", error='" + error + '\'' +
'}';
}
}
\ No newline at end of file
/*******************************************************************************
* Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2019)
*
* contact.vitam@culture.gouv.fr
*
* This software is a computer program whose purpose is to implement a digital archiving back-office system managing
* high volumetry securely and efficiently.
*
* This software is governed by the CeCILL 2.1 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 2.1 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 2.1 license and that you
* accept its terms.
*******************************************************************************/
package fr.cines.vitam.griffins.formatvalidator.pojo;
import com.fasterxml.jackson.annotation.JsonProperty;
public class Input {
@JsonProperty("Name")
private String name;
@JsonProperty("FormatId")
private String formatId;
public Input() {
}
public Input(String name, String formatId) {
this.name = name;
this.formatId = formatId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFormatId() {
return formatId;
}
public void setFormatId(String formatId) {
this.formatId = formatId;
}
@Override
public String toString() {
return "Input{" +
"Name='" + name + '\'' +
", FormatId='" + formatId + '\'' +
'}';
}
}
/*******************************************************************************
* Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2019)
*
* contact.vitam@culture.gouv.fr
*
* This software is a computer program whose purpose is to implement a digital archiving back-office system managing
* high volumetry securely and efficiently.
*
* This software is governed by the CeCILL 2.1 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 2.1 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 2.1 license and that you
* accept its terms.
*******************************************************************************/
package fr.cines.vitam.griffins.formatvalidator.pojo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import fr.cines.vitam.griffins.formatvalidator.status.AnalyseResult;
import fr.cines.vitam.griffins.formatvalidator.status.GriffinStatus;
import fr.cines.vitam.griffins.formatvalidator.status.ActionType;
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
@JsonInclude(NON_NULL)
public class Output {
@JsonProperty("Result")
private String result;
@JsonProperty("Error")
private String error;
@JsonProperty("Executed")
private String executed;
@JsonProperty("Input")
private Input input;
@JsonProperty("OutputName")
private String outputName;
@JsonProperty("Status")
private GriffinStatus status;
@JsonProperty("AnalyseResult")
private AnalyseResult analyseResult;
@JsonProperty("Action")
private ActionType action;
public Output() {
}
public static Output error(Input input, ActionType action) {
Output output = new Output();
output.setInput(input);
output.setStatus(GriffinStatus.KO);
output.setAction(action);
return output;
}
public static Output error(Input input, ActionType action, String error, String executed) {
Output output = new Output();
output.setInput(input);
output.setStatus(GriffinStatus.KO);
output.setAction(action);
output.setError(error);
output.setExecuted(executed);
return output;
}
public static Output warning(Input input, String outputName, ActionType action) {
Output output = new Output();
output.setInput(input);
output.setOutputName(outputName);
output.setStatus(GriffinStatus.WARNING);
output.setAction(action);
return output;
}
public static Output warning(Input input, String outputName, ActionType action, String stderr, String stdout, String executed) {
Output output = new Output();
output.setInput(input);
output.setOutputName(outputName);
output.setStatus(GriffinStatus.WARNING);
output.setAction(action);
output.setError(stderr);