- * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - *
- * http://www.apache.org/licenses/LICENSE-2.0 - *
- * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *
- * --- - *
- * This file is part of javalibpst. - *
- * javalibpst is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - *
- * javalibpst is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - *
- * You should have received a copy of the GNU Lesser General Public License
- * along with javalibpst. If not, see
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * ---
- *
- * This file is part of javalibpst.
- *
- * javalibpst is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * javalibpst is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with javalibpst. If not, see
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * ---
- *
- * This file is part of javalibpst.
- *
- * javalibpst is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * javalibpst is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with javalibpst. If not, see
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * ---
- *
- * This file is part of javalibpst.
- *
- * javalibpst is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * javalibpst is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with javalibpst. If not, see
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * ---
- *
- * This file is part of javalibpst.
- *
- * javalibpst is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * javalibpst is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with javalibpst. If not, see
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * ---
- *
- * This file is part of javalibpst.
- *
- * javalibpst is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * javalibpst is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with javalibpst. If not, see
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * ---
- *
- * This file is part of javalibpst.
- *
- * javalibpst is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * javalibpst is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with javalibpst. If not, see
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextract;
@@ -104,97 +115,141 @@ private static Options createOptions() {
Option help = new Option("h", "help", false, "help");
options.addOption(help);
- Option type = new Option("t", "type", true,
- "type of local container to extract (thunderbird|pst|eml|mbox|msg) or protocol for server access (imap|imaps|pop3...) [default pst]");
+ Option type = new Option(
+ "t",
+ "type",
+ true,
+ "type of local container to extract (thunderbird|pst|eml|mbox|msg) or protocol for server access (imap|imaps|pop3...) [default pst]"
+ );
options.addOption(type);
- Option user = new Option("u", "username", true,
- "user account name (also used for destination extraction naming)");
+ Option user = new Option(
+ "u",
+ "username",
+ true,
+ "user account name (also used for destination extraction naming)"
+ );
options.addOption(user);
- Option password = new Option("p", "password", true,
- "password");
+ Option password = new Option("p", "password", true, "password");
options.addOption(password);
- Option server = new Option("s", "server", true,
- "mail server [HostName|IP](:port)");
+ Option server = new Option("s", "server", true, "mail server [HostName|IP](:port)");
options.addOption(server);
- Option container = new Option("c", "container", true,
- "local container directory or file to extract");
+ Option container = new Option("c", "container", true, "local container directory or file to extract");
options.addOption(container);
Option folder = new Option("f", "folder", true, "specific mail folder to extract [default root]");
options.addOption(folder);
- Option rootpath = new Option("r", "rootpath", true,
- "path for output directory [default current directory]");
+ Option rootpath = new Option("r", "rootpath", true, "path for output directory [default current directory]");
options.addOption(rootpath);
- Option outputname = new Option("o", "outputname", true,
- "name for output [default no name, extraction in rootpath directly, and log file is .log]");
+ Option outputname = new Option(
+ "o",
+ "outputname",
+ true,
+ "name for output [default no name, extraction in rootpath directly, and log file is .log]"
+ );
options.addOption(outputname);
- Option dropemptyfolders = new Option("d", "dropemptyfolders [default false]", false,
- "drop empty folders");
+ Option dropemptyfolders = new Option("d", "dropemptyfolders [default false]", false, "drop empty folders");
options.addOption(dropemptyfolders);
- Option keeponlydeep = new Option("k", "keeponlydeep [default false]", false,
- "keep only empty folders not at root level");
+ Option keeponlydeep = new Option(
+ "k",
+ "keeponlydeep [default false]",
+ false,
+ "keep only empty folders not at root level"
+ );
options.addOption(keeponlydeep);
- Option nameslength = new Option("n", "nameslength", true,
- "length limit for directories and files generated names [default 12]");
+ Option nameslength = new Option(
+ "n",
+ "nameslength",
+ true,
+ "length limit for directories and files generated names [default 12]"
+ );
options.addOption(nameslength);
- Option setchar = new Option("cs", "charset", true,
- "used charset in extraction [default UTF-8]");
+ Option setchar = new Option("cs", "charset", true, "used charset in extraction [default UTF-8]");
options.addOption(setchar);
- Option extractchoices = new Option("e", "extractchoices", true,
- "which elements are extracted with m for mails, c for contacts and a for appointment [default mca]");
+ Option extractchoices = new Option(
+ "e",
+ "extractchoices",
+ true,
+ "which elements are extracted with m for mails, c for contacts and a for appointment [default mca]"
+ );
options.addOption(extractchoices);
- Option extractmode = new Option("ml", "extractmode", true,
- "which form of extraction with c for content and l for lists [default cl]");
+ Option extractmode = new Option(
+ "ml",
+ "extractmode",
+ true,
+ "which form of extraction with c for content and l for lists [default cl]"
+ );
options.addOption(extractmode);
- Option extracttextmetadata = new Option("tm", "extracttextmetadata", true,
- "extract text and add to metadata with m for message and a for attachments [default nothing]");
+ Option extracttextmetadata = new Option(
+ "tm",
+ "extracttextmetadata",
+ true,
+ "extract text and add to metadata with m for message and a for attachments [default nothing]"
+ );
options.addOption(extracttextmetadata);
- Option extracttextfile = new Option("tf", "extracttextfile", true,
- "extract text and add a text file with m for message and a for attachments [default nothing]");
+ Option extracttextfile = new Option(
+ "tf",
+ "extracttextfile",
+ true,
+ "extract text and add a text file with m for message and a for attachments [default nothing]"
+ );
options.addOption(extracttextfile);
- Option model = new Option("model", "model", true,
- "model of metadata extraction on disk 1 or 2 (default 2)");
+ Option model = new Option("model", "model", true, "model of metadata extraction on disk 1 or 2 (default 2)");
options.addOption(model);
- Option warning = new Option("w", "warning", false,
- "generate warning when there's a problem on a message whatever log level except OFF (otherwise log only at MESSAGE_DETAILS level) [default false]");
+ Option warning = new Option(
+ "w",
+ "warning",
+ false,
+ "generate warning when there's a problem on a message whatever log level except OFF (otherwise log only at MESSAGE_DETAILS level) [default false]"
+ );
options.addOption(warning);
Option debug = new Option("b", "debug", false, "activate debug log [default false]");
options.addOption(debug);
- Option verbatim = new Option("v", "verbatim", true,
- "event level to log (OFF|GLOBAL|WARNING|FOLDER|MESSAGE_GROUP|MESSAGE|MESSAGE_DETAILS) [default OFF]");
+ Option verbatim = new Option(
+ "v",
+ "verbatim",
+ true,
+ "event level to log (OFF|GLOBAL|WARNING|FOLDER|MESSAGE_GROUP|MESSAGE|MESSAGE_DETAILS) [default OFF]"
+ );
options.addOption(verbatim);
- Option english = new Option("u", "english", true,
- "english version GUI");
+ Option english = new Option("u", "english", true, "english version GUI");
options.addOption(english);
Option extract = new Option("x", "doextract", false, "extract all informations action");
options.addOption(extract);
- Option list = new Option("l", "dolist", false,
- "process all informations and list folders action (no drop options)");
+ Option list = new Option(
+ "l",
+ "dolist",
+ false,
+ "process all informations and list folders action (no drop options)"
+ );
options.addOption(list);
- Option stats = new Option("z", "dostats", false,
- "process all informations and list folders and there statistics action (no drop options)");
+ Option stats = new Option(
+ "z",
+ "dostats",
+ false,
+ "process all informations and list folders and there statistics action (no drop options)"
+ );
options.addOption(stats);
return options;
@@ -210,8 +265,8 @@ private static Options createOptions() {
* @throws UnsupportedLookAndFeelException the unsupported look and feel
* exception
*/
- public static void main(String[] args) throws ClassNotFoundException, InstantiationException,
- IllegalAccessException, UnsupportedLookAndFeelException {
+ public static void main(String[] args)
+ throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
// params
@@ -225,7 +280,7 @@ public static void main(String[] args) throws ClassNotFoundException, Instantiat
String charset;
String extractChoices, extractMode, extractTextMetadata, extractTextFile;
int model;
- boolean warning , debug ;
+ boolean warning, debug;
String verbatim;
boolean english;
@@ -240,7 +295,8 @@ public static void main(String[] args) throws ClassNotFoundException, Instantiat
HelpFormatter formatter = new HelpFormatter();
// Texte personnalisé pour l'introduction
- String header = "Mail extraction application (pst|thundebird|mbox|eml|msg files and distant mail servers)\n\nOptions :";
+ String header =
+ "Mail extraction application (pst|thundebird|mbox|eml|msg files and distant mail servers)\n\nOptions :";
// Texte personnalisé pour la conclusion
String footer = "\nwhen no x, l or z action is given the GUI is launched";
@@ -249,17 +305,14 @@ public static void main(String[] args) throws ClassNotFoundException, Instantiat
formatter.printHelp("MailExtract", header, options, footer);
System.exit(0);
}
-
} catch (ParseException e) {
System.out.println("Can't analyze options : " + e.getMessage());
System.exit(1);
}
// get all options and arguments verifying them when possible
- if (cmd.hasOption("type"))
- type = noNullString(cmd.getOptionValue("type"));
- else
- type = "pst";
+ if (cmd.hasOption("type")) type = noNullString(cmd.getOptionValue("type"));
+ else type = "pst";
user = noNullString(cmd.getOptionValue("user"));
@@ -268,26 +321,22 @@ public static void main(String[] args) throws ClassNotFoundException, Instantiat
String server = cmd.getOptionValue("server");
hostname = "";
port = -1;
- if (server != null)
- try {
- if (server.indexOf(':') >= 0) {
- hostname = server.substring(0, server.indexOf(':'));
- port = Integer.parseInt(server.substring(server.indexOf(':') + 1));
- } else
- hostname = server;
- } catch (NumberFormatException e) {
- System.out.println("Wrong server format must be
- * contact.vitam@programmevitam.fr
- *
- * This software is developed as a validation helper tool, for constructing Submission Information Packages (archives
- * sets) in the Vitam 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 archiveTransfer 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextract;
@@ -82,8 +92,12 @@ public MailExtractException(String message, Throwable cause) {
* @param enableSuppression the enable suppression
* @param writableStackTrace the writable stack trace
*/
- public MailExtractException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ public MailExtractException(
+ String message,
+ Throwable cause,
+ boolean enableSuppression,
+ boolean writableStackTrace
+ ) {
super(message, cause, enableSuppression, writableStackTrace);
}
-
}
diff --git a/mailextract/src/main/java/fr/gouv/vitam/tools/mailextract/MailExtractGraphicApp.java b/mailextract/src/main/java/fr/gouv/vitam/tools/mailextract/MailExtractGraphicApp.java
index 4fa84b67..e79ffda1 100644
--- a/mailextract/src/main/java/fr/gouv/vitam/tools/mailextract/MailExtractGraphicApp.java
+++ b/mailextract/src/main/java/fr/gouv/vitam/tools/mailextract/MailExtractGraphicApp.java
@@ -1,28 +1,39 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextract;
@@ -52,9 +63,9 @@ public class MailExtractGraphicApp implements ActionListener, Runnable {
int port;
private String container, folder;
private String rootpath, outputname;
-
+
StoreExtractorOptions storeExtractorOptions;
-
+
private boolean debug = false;
private String verbatim;
private boolean english;
@@ -76,9 +87,21 @@ public class MailExtractGraphicApp implements ActionListener, Runnable {
* @param verbatim the verbosity level for logging
* @param english the flag indicating if English language is used
*/
- MailExtractGraphicApp(String type, String user, String password, String hostname, int port, String container, String folder,
- String rootpath, String outputname, StoreExtractorOptions storeExtractorOptions,
- boolean debug, String verbatim, boolean english) {
+ MailExtractGraphicApp(
+ String type,
+ String user,
+ String password,
+ String hostname,
+ int port,
+ String container,
+ String folder,
+ String rootpath,
+ String outputname,
+ StoreExtractorOptions storeExtractorOptions,
+ boolean debug,
+ String verbatim,
+ boolean english
+ ) {
this.type = type;
this.user = user;
this.password = password;
@@ -238,20 +261,14 @@ public void actionPerformed(ActionEvent e) {
mainWindow.passwordField.setEnabled(true);
} else if (command.equals("container")) {
String filename = selectPath(mainWindow.containerField.getText(), false);
- if (filename != null)
- mainWindow.containerField.setText(filename);
+ if (filename != null) mainWindow.containerField.setText(filename);
} else if (command.equals("savedir")) {
String dirname = selectPath(mainWindow.savedirField.getText(), true);
- if (dirname != null)
- mainWindow.savedirField.setText(dirname);
- } else if (command.equals("list"))
- doAction(LIST_ACTION);
- else if (command.equals("stat"))
- doAction(STAT_ACTION);
- else if (command.equals("extract"))
- doAction(EXTRACT_ACTION);
- else if (command.equals("empty"))
- doAction(EMPTY_LOG);
+ if (dirname != null) mainWindow.savedirField.setText(dirname);
+ } else if (command.equals("list")) doAction(LIST_ACTION);
+ else if (command.equals("stat")) doAction(STAT_ACTION);
+ else if (command.equals("extract")) doAction(EXTRACT_ACTION);
+ else if (command.equals("empty")) doAction(EMPTY_LOG);
}
// get a file and/or directory from a standard selection dialog
@@ -260,19 +277,18 @@ private String selectPath(String folder, boolean dirBool) {
File file;
JFileChooser fileChooser = new JFileChooser();
- fileChooser
- .setFileSelectionMode((dirBool ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_AND_DIRECTORIES));
+ fileChooser.setFileSelectionMode(
+ (dirBool ? JFileChooser.DIRECTORIES_ONLY : JFileChooser.FILES_AND_DIRECTORIES)
+ );
fileChooser.setFileHidingEnabled(false);
file = new File(folder);
- if (file.exists())
- fileChooser.setSelectedFile(file);
+ if (file.exists()) fileChooser.setSelectedFile(file);
int returnVal = fileChooser.showOpenDialog(this.mainWindow);
if (returnVal == JFileChooser.APPROVE_OPTION) {
file = fileChooser.getSelectedFile();
return (file.getAbsolutePath());
- } else
- return null;
+ } else return null;
}
/**
@@ -301,44 +317,49 @@ private void doAction(int actionNumber) {
if (actionNumber == EMPTY_LOG) {
mainWindow.consoleTextArea.setText("");
- } else
- new MailExtractThread(mainWindow, actionNumber, type, hostname, port, user, password, container, folder, rootpath,
- outputname, storeExtractorOptions, verbatim, debug).start();
+ } else new MailExtractThread(
+ mainWindow,
+ actionNumber,
+ type,
+ hostname,
+ port,
+ user,
+ password,
+ container,
+ folder,
+ rootpath,
+ outputname,
+ storeExtractorOptions,
+ verbatim,
+ debug
+ ).start();
}
/**
* The loglevel strings.
*/
- String[] loglevelStrings = {"OFF", "GLOBAL", "WARNING", "FOLDER", "MESSAGE_GROUP", "MESSAGE", "MESSAGE_DETAILS"};
+ String[] loglevelStrings = { "OFF", "GLOBAL", "WARNING", "FOLDER", "MESSAGE_GROUP", "MESSAGE", "MESSAGE_DETAILS" };
// get the global parameters from the graphic fields
private void parseParams() {
// local
if (mainWindow.localRadioButton.isSelected()) {
- if (mainWindow.thunderbirdRadioButton.isSelected())
- type = "thunderbird";
- else if (mainWindow.emlRadioButton.isSelected())
- type = "eml";
- else if (mainWindow.msgRadioButton.isSelected())
- type = "msg";
- else if (mainWindow.mboxRadioButton.isSelected())
- type = "mbox";
- else if (mainWindow.pstRadioButton.isSelected())
- type = "pst";
+ if (mainWindow.thunderbirdRadioButton.isSelected()) type = "thunderbird";
+ else if (mainWindow.emlRadioButton.isSelected()) type = "eml";
+ else if (mainWindow.msgRadioButton.isSelected()) type = "msg";
+ else if (mainWindow.mboxRadioButton.isSelected()) type = "mbox";
+ else if (mainWindow.pstRadioButton.isSelected()) type = "pst";
container = mainWindow.containerField.getText();
}
// server
else {
- if (mainWindow.imapsRadioButton.isSelected())
- type = "imaps";
- else
- type = "imap";
+ if (mainWindow.imapsRadioButton.isSelected()) type = "imaps";
+ else type = "imap";
String server = mainWindow.serverField.getText();
if (server.indexOf(':') >= 0) {
hostname = server.substring(0, server.indexOf(':'));
port = Integer.parseInt(server.substring(server.indexOf(':') + 1));
- } else
- hostname = server;
+ } else hostname = server;
user = mainWindow.userField.getText();
password = mainWindow.passwordField.getText();
}
diff --git a/mailextract/src/main/java/fr/gouv/vitam/tools/mailextract/MailExtractLogger.java b/mailextract/src/main/java/fr/gouv/vitam/tools/mailextract/MailExtractLogger.java
index 51897100..f0531a62 100644
--- a/mailextract/src/main/java/fr/gouv/vitam/tools/mailextract/MailExtractLogger.java
+++ b/mailextract/src/main/java/fr/gouv/vitam/tools/mailextract/MailExtractLogger.java
@@ -1,29 +1,39 @@
/**
- * Copyright French Prime minister Office/DINSIC/Vitam Program (2015-2019)
- *
- * contact.vitam@programmevitam.fr
- *
- * This software is developed as a validation helper tool, for constructing Submission Information Packages (archives
- * sets) in the Vitam 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 archiveTransfer 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextract;
@@ -57,7 +67,6 @@ public class MailExtractLogger {
public static final int MESSAGE_DETAILS = 60;
public static final Marker MESSAGE_DETAILS_MARKER = MarkerFactory.getMarker("MESSAGE_DETAILS");
-
/**
* The global logger.
*/
@@ -79,8 +88,10 @@ public class MailExtractLogger {
* @return the app logger
*/
public static MailExtractLogger getGlobalLogger() {
- if (globalLogger == null)
- globalLogger = new MailExtractLogger(LoggerFactory.getLogger(MailExtractApp.class.getSimpleName()), GLOBAL);
+ if (globalLogger == null) globalLogger = new MailExtractLogger(
+ LoggerFactory.getLogger(MailExtractApp.class.getSimpleName()),
+ GLOBAL
+ );
return globalLogger;
}
@@ -94,11 +105,13 @@ public MailExtractLogger(String logPath, int progressLogLevel) {
PatternLayoutEncoder consoleEncoder = new PatternLayoutEncoder();
consoleEncoder.setContext(logCtx);
- consoleEncoder.setPattern("%d{HH:mm:ss.SSS} [" + MailExtractApp.class.getSimpleName() + "] %-5level %marker - %msg%n");
- if (System.getProperty("os.name").toLowerCase().contains("win"))
- consoleEncoder.setCharset(Charset.forName("cp850"));
- else
- consoleEncoder.setCharset(Charset.forName("UTF-8"));
+ consoleEncoder.setPattern(
+ "%d{HH:mm:ss.SSS} [" + MailExtractApp.class.getSimpleName() + "] %-5level %marker - %msg%n"
+ );
+ if (System.getProperty("os.name").toLowerCase().contains("win")) consoleEncoder.setCharset(
+ Charset.forName("cp850")
+ );
+ else consoleEncoder.setCharset(Charset.forName("UTF-8"));
consoleEncoder.start();
ConsoleAppender
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextract;
@@ -239,7 +250,6 @@ public class MailExtractMainWindow extends JFrame {
*/
JCheckBox debugCheckBox;
-
/**
* The english check box.
*/
@@ -248,9 +258,7 @@ public class MailExtractMainWindow extends JFrame {
/**
* Other labels
*/
- JLabel lblExtractElementsLabel,
- lblExtractTextLabel, lblExtractTextToFileLabel, lblExtractTextToMetadataLabel, loglevelLabel,
- namesLengthLabel, savedirLabel, folderLabel, charsetLabel;
+ JLabel lblExtractElementsLabel, lblExtractTextLabel, lblExtractTextToFileLabel, lblExtractTextToMetadataLabel, loglevelLabel, namesLengthLabel, savedirLabel, folderLabel, charsetLabel;
/**
* Other buttons
@@ -265,11 +273,44 @@ public class MailExtractMainWindow extends JFrame {
/**
* The proposed charsets.
*/
- String[] charsetGraphicStrings = {"windows-1252", "ISO-8859-1", "UTF-8", "CESU-8", "IBM00858", "IBM437", "IBM775",
- "IBM850", "IBM852", "IBM855", "IBM857", "IBM862", "IBM866", "ISO-8859-2", "ISO-8859-4", "ISO-8859-5",
- "ISO-8859-7", "ISO-8859-9", "ISO-8859-13", "ISO-8859-15", "KOI8-R", "KOI8-U", "US-ASCII", "UTF-16",
- "UTF-16BE", "UTF-16LE", "UTF-32", "UTF-32BE", "UTF-32LE", "x-UTF-32BE-BOM", "x-UTF-32LE-BOM",
- "windows-1250", "windows-1251", "windows-1253", "windows-1254", "windows-1257"};
+ String[] charsetGraphicStrings = {
+ "windows-1252",
+ "ISO-8859-1",
+ "UTF-8",
+ "CESU-8",
+ "IBM00858",
+ "IBM437",
+ "IBM775",
+ "IBM850",
+ "IBM852",
+ "IBM855",
+ "IBM857",
+ "IBM862",
+ "IBM866",
+ "ISO-8859-2",
+ "ISO-8859-4",
+ "ISO-8859-5",
+ "ISO-8859-7",
+ "ISO-8859-9",
+ "ISO-8859-13",
+ "ISO-8859-15",
+ "KOI8-R",
+ "KOI8-U",
+ "US-ASCII",
+ "UTF-16",
+ "UTF-16BE",
+ "UTF-16LE",
+ "UTF-32",
+ "UTF-32BE",
+ "UTF-32LE",
+ "x-UTF-32BE-BOM",
+ "x-UTF-32LE-BOM",
+ "windows-1250",
+ "windows-1251",
+ "windows-1253",
+ "windows-1254",
+ "windows-1257",
+ };
private JPanel panel;
@@ -300,7 +341,7 @@ public MailExtractMainWindow(MailExtractGraphicApp app) {
}
// Initialize the contents of the frame.
- @SuppressWarnings({"unchecked", "rawtypes"})
+ @SuppressWarnings({ "unchecked", "rawtypes" })
private void initialize() {
URL imageURL = getClass().getClassLoader().getResource("VitamIcon96.png");
if (imageURL != null) {
@@ -314,8 +355,8 @@ private void initialize() {
setBounds(0, 0, 800, 800);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridBagLayout gridBagLayout = new GridBagLayout();
- gridBagLayout.columnWeights = new double[]{1.0, 1, 1, 1};
- gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ gridBagLayout.columnWeights = new double[] { 1.0, 1, 1, 1 };
+ gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
getContentPane().setLayout(gridBagLayout);
// Panel de condition d'extraction
@@ -331,8 +372,8 @@ private void initialize() {
gbc_extractChoicePanel.gridy = 9;
getContentPane().add(extractChoicePanel, gbc_extractChoicePanel);
GridBagLayout gbl_extractChoicePanel = new GridBagLayout();
- gbl_extractChoicePanel.rowWeights = new double[]{1.0, 1.0};
- gbl_extractChoicePanel.columnWeights = new double[]{1.0, 1, 1};
+ gbl_extractChoicePanel.rowWeights = new double[] { 1.0, 1.0 };
+ gbl_extractChoicePanel.columnWeights = new double[] { 1.0, 1, 1 };
extractChoicePanel.setLayout(gbl_extractChoicePanel);
lblExtractElementsLabel = new JLabel(MESSAGES.getString("label.extractElements"));
@@ -379,7 +420,6 @@ private void initialize() {
gbc_extractListsCheckBox.gridy = 1;
extractChoicePanel.add(extractListCheckBox, gbc_extractListsCheckBox);
-
// Panel d'extraction du texte
JPanel extractTextPanel = new JPanel();
extractTextPanel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
@@ -393,8 +433,8 @@ private void initialize() {
gbc_extractTextPanel.gridy = 10;
getContentPane().add(extractTextPanel, gbc_extractTextPanel);
GridBagLayout gbl_extractTextPanel = new GridBagLayout();
- gbl_extractTextPanel.rowWeights = new double[]{1.0, 1.0};
- gbl_extractTextPanel.columnWeights = new double[]{1.0, 1, 1};
+ gbl_extractTextPanel.rowWeights = new double[] { 1.0, 1.0 };
+ gbl_extractTextPanel.columnWeights = new double[] { 1.0, 1, 1 };
extractTextPanel.setLayout(gbl_extractTextPanel);
lblExtractTextLabel = new JLabel(MESSAGES.getString("label.extractText"));
@@ -916,11 +956,10 @@ private void initialize() {
private void SetLabels(ResourceBundle messages) {
setTitle(messages.getString("mainWindow.title"));
- int index=loglevelComboBox.getSelectedIndex();
+ int index = loglevelComboBox.getSelectedIndex();
DefaultComboBoxModel
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextract;
@@ -94,17 +105,41 @@ public class MailExtractThread extends Thread {
* @param logLevel the log level
* @param debugFlag the debug flag
*/
- public MailExtractThread(MailExtractMainWindow mainWindow, int actionNumber, String protocol, String host, int port, String user, String password,
- String container, String folder, String destRootPath, String destName,
- StoreExtractorOptions storeExtractorOptions, String logLevel, boolean debugFlag) {
+ public MailExtractThread(
+ MailExtractMainWindow mainWindow,
+ int actionNumber,
+ String protocol,
+ String host,
+ int port,
+ String user,
+ String password,
+ String container,
+ String folder,
+ String destRootPath,
+ String destName,
+ StoreExtractorOptions storeExtractorOptions,
+ String logLevel,
+ boolean debugFlag
+ ) {
this.mainWindow = mainWindow;
try {
- mel = new MailExtractLogger(destRootPath + File.separator + destName + ".log", MailExtractLogger.getLevel(logLevel));
- logger = new MailExtractProgressLogger(mel.getProgressLogger(), MailExtractLogger.getLevel(logLevel), (count, log) -> {
- String newLog = mainWindow.consoleTextArea.getText() + "\n" + log;
- mainWindow.consoleTextArea.setText(newLog);
- mainWindow.consoleTextArea.setCaretPosition(newLog.length());
- }, 1000,2,MailExtractProgressLogger.MESSAGE_GROUP,1000);
+ mel = new MailExtractLogger(
+ destRootPath + File.separator + destName + ".log",
+ MailExtractLogger.getLevel(logLevel)
+ );
+ logger = new MailExtractProgressLogger(
+ mel.getProgressLogger(),
+ MailExtractLogger.getLevel(logLevel),
+ (count, log) -> {
+ String newLog = mainWindow.consoleTextArea.getText() + "\n" + log;
+ mainWindow.consoleTextArea.setText(newLog);
+ mainWindow.consoleTextArea.setCaretPosition(newLog.length());
+ },
+ 1000,
+ 2,
+ MailExtractProgressLogger.MESSAGE_GROUP,
+ 1000
+ );
logger.setDebugFlag(debugFlag);
} catch (Exception e) {
System.out.println(e.getMessage());
@@ -113,8 +148,13 @@ public MailExtractThread(MailExtractMainWindow mainWindow, int actionNumber, Str
// do the job, creating a store extractor and running the extraction
try {
String urlString = StoreExtractor.composeStoreURL(protocol, host, user, password, container);
- this.storeExtractor = StoreExtractor.createStoreExtractor(urlString, folder,
- Paths.get(destRootPath, destName).toString(), storeExtractorOptions, logger);
+ this.storeExtractor = StoreExtractor.createStoreExtractor(
+ urlString,
+ folder,
+ Paths.get(destRootPath, destName).toString(),
+ storeExtractorOptions,
+ logger
+ );
this.actionNumber = actionNumber;
} catch (MailExtractLibException ee) {
doProgressLogWithoutInterruption(logger, GLOBAL, "mailextract: erreur d'extraction", ee);
@@ -139,12 +179,9 @@ public void run() {
storeExtractor.listAllFolders(true);
break;
case MailExtractGraphicApp.EXTRACT_ACTION:
- if (storeExtractor.hasDestName())
- storeExtractor.extractAllFolders();
- else
- throw new MailExtractLibException("mailextract: no destination name for extraction", null);
+ if (storeExtractor.hasDestName()) storeExtractor.extractAllFolders();
+ else throw new MailExtractLibException("mailextract: no destination name for extraction", null);
break;
-
}
} catch (MailExtractLibException ee) {
doProgressLogWithoutInterruption(logger, GLOBAL, "mailextract: extraction error", ee);
@@ -155,20 +192,17 @@ public void run() {
System.out.println(getPrintStackTrace(e));
} finally {
try {
- if (storeExtractor != null)
- storeExtractor.endStoreExtractor();
+ if (storeExtractor != null) storeExtractor.endStoreExtractor();
} catch (MailExtractLibException e) {
doProgressLogWithoutInterruption(logger, GLOBAL, "mailextract: closing error", e);
}
- if (logger != null)
- logger.close();
- if (mel != null)
- mel.close();
+ if (logger != null) logger.close();
+ if (mel != null) mel.close();
}
}
// make a String from the stack trace
- private final static String getPrintStackTrace(Exception e) {
+ private static final String getPrintStackTrace(Exception e) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter p = new PrintWriter(baos);
@@ -176,5 +210,4 @@ private final static String getPrintStackTrace(Exception e) {
p.close();
return baos.toString();
}
-
}
diff --git a/mailextract/src/main/java/fr/gouv/vitam/tools/mailextract/package-info.java b/mailextract/src/main/java/fr/gouv/vitam/tools/mailextract/package-info.java
index b94167d0..8eed570d 100644
--- a/mailextract/src/main/java/fr/gouv/vitam/tools/mailextract/package-info.java
+++ b/mailextract/src/main/java/fr/gouv/vitam/tools/mailextract/package-info.java
@@ -1,4 +1,41 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.
+ */
/**
* Provides the class for the simple command and graphic application.
*/
-package fr.gouv.vitam.tools.mailextract;
\ No newline at end of file
+package fr.gouv.vitam.tools.mailextract;
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/EmbeddedStoreExtractor.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/EmbeddedStoreExtractor.java
index aa509040..dfefd4aa 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/EmbeddedStoreExtractor.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/EmbeddedStoreExtractor.java
@@ -1,37 +1,46 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.core;
/**
* The Interface EmbeddedStoreExtractor.
*/
public interface EmbeddedStoreExtractor {
-
/**
* Gets the attachment in which is the embedded object.
*
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreAppointment.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreAppointment.java
index bc38f695..d96f6917 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreAppointment.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreAppointment.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.core;
import fr.gouv.vitam.tools.mailextractlib.nodes.ArchiveUnit;
@@ -94,7 +104,14 @@ public abstract class StoreAppointment extends StoreElement {
* Human-readable text for the statuses defined in {@link #MESSAGE_STATUS_UNKNOWN},
* {@link #MESSAGE_STATUS_LOCAL}, etc.
*/
- public static final String[] MESSAGE_STATUS_TEXT = {"Unknown", "Local", "Request", "Resp.Yes", "Resp.May", "Resp.No"};
+ public static final String[] MESSAGE_STATUS_TEXT = {
+ "Unknown",
+ "Local",
+ "Request",
+ "Resp.Yes",
+ "Resp.May",
+ "Resp.No",
+ };
/**
* A unique identifier for the appointment (used to differentiate it from other elements).
@@ -213,10 +230,8 @@ protected StoreAppointment(StoreFolder storeFolder) {
@Override
public String getLogDescription() {
String result = "appointment " + listLineId;
- if (subject != null)
- result += " [" + subject + "/";
- else
- result += " [no subject/";
+ if (subject != null) result += " [" + subject + "/";
+ else result += " [no subject/";
result += getDateInDefinedTimeZone(startTime) + " - " + getDateInDefinedTimeZone(endTime) + "]";
return result;
}
@@ -250,10 +265,12 @@ public static String getElementName() {
*/
public static void printGlobalListCSVHeader(PrintStream ps) {
synchronized (ps) {
- ps.println("ID;Subject;Location;From;ToAttendees;CcAttendees;StartTime;EndTime;" +
- "MiscNotes;uniqID;SequenceNumber;ModificationTime;Folder;MessageStatus;" +
- "isRecurrent;RecurrencePattern;StartRecurrenceTime;EndRecurrenceTime;" +
- "ExceptionFromId;ExceptionDate;isDeletion;hasAttachment");
+ ps.println(
+ "ID;Subject;Location;From;ToAttendees;CcAttendees;StartTime;EndTime;" +
+ "MiscNotes;uniqID;SequenceNumber;ModificationTime;Folder;MessageStatus;" +
+ "isRecurrent;RecurrencePattern;StartRecurrenceTime;EndRecurrenceTime;" +
+ "ExceptionFromId;ExceptionDate;isDeletion;hasAttachment"
+ );
}
}
@@ -265,44 +282,49 @@ public static void printGlobalListCSVHeader(PrintStream ps) {
* @throws InterruptedException the interrupted exception
* @throws MailExtractLibException the mail extract lib exception
*/
- public void extractAppointment(boolean writeFlag, StoreAppointment father) throws InterruptedException, MailExtractLibException {
+ public void extractAppointment(boolean writeFlag, StoreAppointment father)
+ throws InterruptedException, MailExtractLibException {
if (writeFlag) {
- if (storeFolder.getStoreExtractor().getOptions().extractElementsList)
- writeToAppointmentsList(father);
+ if (storeFolder.getStoreExtractor().getOptions().extractElementsList) writeToAppointmentsList(father);
if (storeFolder.getStoreExtractor().getOptions().extractElementsContent) {
if ((attachments != null) && (!attachments.isEmpty())) {
- ArchiveUnit attachmentNode = new ArchiveUnit(storeFolder.storeExtractor, storeFolder.storeExtractor.destRootPath +
- File.separator + storeFolder.storeExtractor.destName + File.separator + "appointments", "AppointmentAttachments#" + listLineId);
+ ArchiveUnit attachmentNode = new ArchiveUnit(
+ storeFolder.storeExtractor,
+ storeFolder.storeExtractor.destRootPath +
+ File.separator +
+ storeFolder.storeExtractor.destName +
+ File.separator +
+ "appointments",
+ "AppointmentAttachments#" + listLineId
+ );
attachmentNode.addMetadata("DescriptionLevel", "RecordGrp", true);
attachmentNode.addMetadata("Title", "Appointment Attachments #" + listLineId, true);
- attachmentNode.addMetadata("Description", "Appointment attachments extracted for " + subject + "[" + startTime + "-" + endTime + "]", true);
+ attachmentNode.addMetadata(
+ "Description",
+ "Appointment attachments extracted for " + subject + "[" + startTime + "-" + endTime + "]",
+ true
+ );
attachmentNode.addMetadata("StartDate", getDateInUTCTimeZone(startTime), true);
attachmentNode.addMetadata("EndDate", getDateInUTCTimeZone(endTime), true);
attachmentNode.write();
StoreAttachment.extractAttachments(attachments, attachmentNode, writeFlag);
}
}
- if (exceptions != null)
- for (StoreAppointment a : exceptions)
- a.extractAppointment(writeFlag, this);
+ if (exceptions != null) for (StoreAppointment a : exceptions) a.extractAppointment(writeFlag, this);
}
}
private String getDateInUTCTimeZone(ZonedDateTime date) {
String result;
- if (date != null)
- result = date.withZoneSameInstant(ZoneId.of("UTC")).format(ISO_8601);
- else
- result = "";
+ if (date != null) result = date.withZoneSameInstant(ZoneId.of("UTC")).format(ISO_8601);
+ else result = "";
return result;
}
private String getDateInDefinedTimeZone(ZonedDateTime date) {
String result;
- if (date != null)
- result = date.format(ISO_8601);
- else
- result = "";
+ if (date != null) result = date.format(ISO_8601);
+ else result = "";
return result;
}
@@ -349,7 +371,10 @@ private void writeToAppointmentsList(StoreAppointment father) {
ps.format("\"%s\";", (father != null ? father.listLineId : ""));
ps.format("\"%s\";", getDateInDefinedTimeZone(exceptionDate));
ps.format("\"%s\";", (isRecurrenceDeletion ? "X" : ""));
- ps.format("\"%s\"", ((attachments != null) && (!attachments.isEmpty()) ? Integer.toString(attachments.size()) : ""));
+ ps.format(
+ "\"%s\"",
+ ((attachments != null) && (!attachments.isEmpty()) ? Integer.toString(attachments.size()) : "")
+ );
ps.println("");
ps.flush();
}
@@ -370,8 +395,7 @@ public void listElement(boolean statsFlag) throws InterruptedException, MailExtr
if (storeFolder.getStoreExtractor().getOptions().extractAppointments) {
listLineId = storeFolder.getStoreExtractor().incElementCounter(this.getClass());
analyzeAppointment();
- if (statsFlag)
- extractAppointment(false, null);
+ if (statsFlag) extractAppointment(false, null);
}
}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreAttachment.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreAttachment.java
index f4bfcf23..5effd4d8 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreAttachment.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreAttachment.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.core;
import fr.gouv.vitam.tools.mailextractlib.formattools.TikaExtractor;
@@ -32,7 +42,6 @@
import fr.gouv.vitam.tools.mailextractlib.utils.DateRange;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractLibException;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractProgressLogger;
-
import jakarta.activation.MimeType;
import jakarta.activation.MimeTypeParseException;
@@ -122,8 +131,17 @@ public class StoreAttachment {
* @param contentID Mime multipart content ID useful for inline
* @param attachmentType Type of attachment (inline, simple file, another store...)
*/
- public StoreAttachment(StoreElement fatherElement, Object storeContent, String attachmentStoreScheme, String name, Date creationDate,
- Date modificationDate, String mimeType, String contentID, int attachmentType) {
+ public StoreAttachment(
+ StoreElement fatherElement,
+ Object storeContent,
+ String attachmentStoreScheme,
+ String name,
+ Date creationDate,
+ Date modificationDate,
+ String mimeType,
+ String contentID,
+ int attachmentType
+ ) {
this.fatherElement = fatherElement;
this.attachmentContent = storeContent;
this.attachmentStoreScheme = attachmentStoreScheme;
@@ -142,10 +160,8 @@ public StoreAttachment(StoreElement fatherElement, Object storeContent, String a
* @throws MailExtractLibException the extraction exception
*/
public byte[] getRawAttachmentContent() throws MailExtractLibException {
- if (attachmentContent instanceof byte[])
- return (byte[]) attachmentContent;
- else
- throw new MailExtractLibException("mailextractlib: this attachment has no binary form", null);
+ if (attachmentContent instanceof byte[]) return (byte[]) attachmentContent;
+ else throw new MailExtractLibException("mailextractlib: this attachment has no binary form", null);
}
/**
@@ -205,10 +221,8 @@ public void setMimeType(String mimeType) {
this.mimeType = mimeType;
} catch (MimeTypeParseException e) {
int i = mimeType.lastIndexOf('/');
- if ((i != -1) && (i < mimeType.length()))
- this.mimeType = "application/" + mimeType.substring(i + 1);
- else
- this.mimeType = "application/octet-stream";
+ if ((i != -1) && (i < mimeType.length())) this.mimeType = "application/" + mimeType.substring(i + 1);
+ else this.mimeType = "application/octet-stream";
}
}
@@ -234,21 +248,22 @@ public void setStoreScheme(String scheme) {
*
* @param attachments the attachments
*/
- static protected void detectStoreAttachments(List
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.core;
import fr.gouv.vitam.tools.mailextractlib.nodes.ArchiveUnit;
@@ -92,12 +102,14 @@ protected StoreContact(StoreFolder storeFolder) {
@Override
public String getLogDescription() {
String result = "contact " + listLineId;
- if (fullName != null)
- result += " [" + fullName + "]";
- else if ((givenName != null) || (lastName != null))
- result += " [" + (givenName != null ? givenName : "NoGivenName") + " " + (lastName != null ? lastName : "NoLastName") + "]";
- else
- result += " [no name]";
+ if (fullName != null) result += " [" + fullName + "]";
+ else if ((givenName != null) || (lastName != null)) result +=
+ " [" +
+ (givenName != null ? givenName : "NoGivenName") +
+ " " +
+ (lastName != null ? lastName : "NoLastName") +
+ "]";
+ else result += " [no name]";
return result;
}
@@ -112,7 +124,7 @@ else if ((givenName != null) || (lastName != null))
* @throws MailExtractLibException Any unrecoverable extraction exception (access trouble, major format problems...)
* @throws InterruptedException the interrupted exception
*/
- abstract public void analyzeAllContactInformations() throws MailExtractLibException, InterruptedException;
+ public abstract void analyzeAllContactInformations() throws MailExtractLibException, InterruptedException;
/**
* Analyze contact to collect contact picture if any.
@@ -124,7 +136,7 @@ else if ((givenName != null) || (lastName != null))
* @throws MailExtractLibException Any unrecoverable extraction exception (access trouble, major format problems...)
* @throws InterruptedException the interrupted exception
*/
- abstract public void analyzeContactPicture() throws MailExtractLibException, InterruptedException;
+ public abstract void analyzeContactPicture() throws MailExtractLibException, InterruptedException;
/**
* Analyze contact to collect contact information and optionally picture.
@@ -136,8 +148,7 @@ public void analyzeContact() throws MailExtractLibException, InterruptedExceptio
analyzeAllContactInformations();
try {
analyzeContactPicture();
- } catch (MailExtractLibException ignored) {
- }
+ } catch (MailExtractLibException ignored) {}
}
/**
@@ -145,7 +156,7 @@ public void analyzeContact() throws MailExtractLibException, InterruptedExceptio
*
* @return the element name
*/
- static public String getElementName() {
+ public static String getElementName() {
return "contacts";
}
@@ -154,13 +165,15 @@ static public String getElementName() {
*
* @param ps the dedicated print stream
*/
- static public void printGlobalListCSVHeader(PrintStream ps) {
+ public static void printGlobalListCSVHeader(PrintStream ps) {
synchronized (ps) {
- ps.println("ID;Full Name;Given Name;Last Name;Misc Notes;Company;Department;Title;Default Address;" +
- "SMTP Mail Address;Default Telephone Number;Mobile Telephone Number;Business HomePage;Business Location;" +
- "Business Telephone Number;Business Address;RefID;" +
- "Other Mail Addresses;Other Telephone Numbers;Assistant Name;Assistant Telephone Number;Personal HomePage;" +
- "Home Location;Home Telephone Number;Home Address;Nickname");
+ ps.println(
+ "ID;Full Name;Given Name;Last Name;Misc Notes;Company;Department;Title;Default Address;" +
+ "SMTP Mail Address;Default Telephone Number;Mobile Telephone Number;Business HomePage;Business Location;" +
+ "Business Telephone Number;Business Address;RefID;" +
+ "Other Mail Addresses;Other Telephone Numbers;Assistant Name;Assistant Telephone Number;Personal HomePage;" +
+ "Home Location;Home Telephone Number;Home Address;Nickname"
+ );
}
}
@@ -175,11 +188,10 @@ static public void printGlobalListCSVHeader(PrintStream ps) {
*/
public void extractContact(boolean writeFlag) throws InterruptedException, MailExtractLibException {
if (writeFlag) {
- if (storeFolder.getStoreExtractor().getOptions().extractElementsList)
- writeToContactsList();
- if ((pictureData != null)
- && storeFolder.getStoreExtractor().getOptions().extractElementsContent)
- extractPicture();
+ if (storeFolder.getStoreExtractor().getOptions().extractElementsList) writeToContactsList();
+ if (
+ (pictureData != null) && storeFolder.getStoreExtractor().getOptions().extractElementsContent
+ ) extractPicture();
}
}
@@ -218,12 +230,23 @@ private void writeToContactsList() {
}
private void extractPicture() throws InterruptedException, MailExtractLibException {
- ArchiveUnit attachmentNode = new ArchiveUnit(storeFolder.storeExtractor, storeFolder.storeExtractor.destRootPath +
- File.separator + storeFolder.storeExtractor.destName + File.separator + "contacts", "ContactPicture#" + listLineId);
+ ArchiveUnit attachmentNode = new ArchiveUnit(
+ storeFolder.storeExtractor,
+ storeFolder.storeExtractor.destRootPath +
+ File.separator +
+ storeFolder.storeExtractor.destName +
+ File.separator +
+ "contacts",
+ "ContactPicture#" + listLineId
+ );
attachmentNode.addMetadata("DescriptionLevel", "Item", true);
attachmentNode.addMetadata("Title", "Contact Picture #" + listLineId, true);
attachmentNode.addMetadata("Description", "Contact picture extracted for " + fullName, true);
- attachmentNode.addPersonMetadata("Recipient", fullName + (smtpAddress.isEmpty() ? "" : "<" + smtpAddress + ">"), false);
+ attachmentNode.addPersonMetadata(
+ "Recipient",
+ fullName + (smtpAddress.isEmpty() ? "" : "<" + smtpAddress + ">"),
+ false
+ );
attachmentNode.addObject(pictureData, pictureFileName, "BinaryMaster", 1);
attachmentNode.write();
}
@@ -239,7 +262,8 @@ public void processElement(boolean writeFlag) throws InterruptedException, MailE
@Override
public void listElement(boolean statsFlag) throws InterruptedException, MailExtractLibException {
- if (storeFolder.getStoreExtractor().getOptions().extractContacts)
- listLineId = storeFolder.getStoreExtractor().incElementCounter(this.getClass());
+ if (storeFolder.getStoreExtractor().getOptions().extractContacts) listLineId = storeFolder
+ .getStoreExtractor()
+ .incElementCounter(this.getClass());
}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreElement.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreElement.java
index 2d3486c0..2c047625 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreElement.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreElement.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.core;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractLibException;
@@ -54,7 +64,7 @@ public abstract class StoreElement {
*/
public StoreElement(StoreFolder storeFolder) {
this.storeFolder = storeFolder;
- this.listLineId=-1;
+ this.listLineId = -1;
}
/**
@@ -90,21 +100,23 @@ public StoreExtractor getStoreExtractor() {
* @throws InterruptedException the interrupted exception
*/
public void logMessageWarning(String msg, Throwable t) throws InterruptedException {
- msg+= " for "+ getLogDescription();
- StoreElement fatherElement=getStoreExtractor().getFatherElement();
- while (fatherElement!=null) {
- msg+=" in "+ fatherElement.getLogDescription();
- fatherElement=fatherElement.getStoreExtractor().getFatherElement();
+ msg += " for " + getLogDescription();
+ StoreElement fatherElement = getStoreExtractor().getFatherElement();
+ while (fatherElement != null) {
+ msg += " in " + fatherElement.getLogDescription();
+ fatherElement = fatherElement.getStoreExtractor().getFatherElement();
}
Exception ex = null;
- if (t instanceof Exception)
- ex = (Exception) t;
-
- if (storeFolder.getStoreExtractor().options.warningMsgProblem)
- doProgressLog(getProgressLogger(), MailExtractProgressLogger.WARNING, msg, ex);
- else
- doProgressLog(getProgressLogger(), MailExtractProgressLogger.MESSAGE_DETAILS, msg, ex);
+ if (t instanceof Exception) ex = (Exception) t;
+
+ if (storeFolder.getStoreExtractor().options.warningMsgProblem) doProgressLog(
+ getProgressLogger(),
+ MailExtractProgressLogger.WARNING,
+ msg,
+ ex
+ );
+ else doProgressLog(getProgressLogger(), MailExtractProgressLogger.MESSAGE_DETAILS, msg, ex);
}
/**
@@ -112,7 +124,7 @@ public void logMessageWarning(String msg, Throwable t) throws InterruptedExcepti
*
* @return the log description
*/
- abstract public String getLogDescription();
+ public abstract String getLogDescription();
/**
* Whole process of extraction on one element (analysis, extraction, count...).
@@ -121,7 +133,7 @@ public void logMessageWarning(String msg, Throwable t) throws InterruptedExcepti
* @throws InterruptedException the interrupted exception
* @throws MailExtractLibException the mail extract lib exception
*/
- abstract public void processElement(boolean writeFlag) throws InterruptedException, MailExtractLibException;
+ public abstract void processElement(boolean writeFlag) throws InterruptedException, MailExtractLibException;
/**
* Limited process of listing on one element (analysis, count...).
@@ -130,7 +142,7 @@ public void logMessageWarning(String msg, Throwable t) throws InterruptedExcepti
* @throws InterruptedException the interrupted exception
* @throws MailExtractLibException the mail extract lib exception
*/
- abstract public void listElement(boolean statsFlag) throws InterruptedException, MailExtractLibException;
+ public abstract void listElement(boolean statsFlag) throws InterruptedException, MailExtractLibException;
/**
* Filter hyphen for csv string.
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreExtractor.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreExtractor.java
index 35099309..3c3900c9 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreExtractor.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreExtractor.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.core;
import fr.gouv.vitam.tools.mailextractlib.nodes.ArchiveUnit;
@@ -35,9 +45,8 @@
import fr.gouv.vitam.tools.mailextractlib.utils.DateRange;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractLibException;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractProgressLogger;
-import org.apache.poi.util.IOUtils;
-
import jakarta.mail.URLName;
+import org.apache.poi.util.IOUtils;
import java.io.File;
import java.io.IOException;
@@ -57,7 +66,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
-import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
@@ -174,11 +182,11 @@ public abstract class StoreExtractor {
* The formatter used for zoned date conversion to String
*/
public static final DateTimeFormatter ISO_8601 = new DateTimeFormatterBuilder()
- .append(ISO_LOCAL_DATE_TIME)
- .optionalStart()
- .appendOffsetId()
- .optionalStart()
- .toFormatter();
+ .append(ISO_LOCAL_DATE_TIME)
+ .optionalStart()
+ .appendOffsetId()
+ .optionalStart()
+ .toFormatter();
/**
* The map of mimetypes/scheme known relations.
@@ -217,14 +225,14 @@ public abstract class StoreExtractor {
* - PstStoreExtractor
* - PstEmbeddedStoreExtractor
*
- * 3. Sets the maximum allowed size for byte arrays in Apache POI to prevent extraction
- * failures when handling large attachments in TNEF files. This change overrides
+ * 3. Sets the maximum allowed size for byte arrays in Apache POI to prevent extraction
+ * failures when handling large attachments in TNEF files. This change overrides
* the default 1 MB limit with a maximum value of 2 GB.
*
* 4. Configures Jakarta Mail properties to handle malformed MIME messages:
* - Enables fallback for unknown content-transfer-encoding values, which allows
* the parsing of messages with invalid encoding values (e.g., "iso-8859-1").
- * - Disables strict decoding of MIME-encoded headers, allowing the library
+ * - Disables strict decoding of MIME-encoded headers, allowing the library
* to tolerate malformed headers and return raw, undecoded text instead of throwing exceptions.
* - Enables lenient Base64 decoding to tolerate malformed or corrupted Base64 encoded data,
* avoiding exceptions during data extraction.
@@ -232,7 +240,6 @@ public abstract class StoreExtractor {
* 4. Sets the default time zone for the application to UTC.
*/
public static void initDefaultExtractors(boolean allowsExternalToolsForTextExtraction) {
-
if (!allowsExternalToolsForTextExtraction) {
preventExternalToolsForTextExtractionInTika();
}
@@ -404,8 +411,12 @@ private static void preventExternalToolsForTextExtractionInTika() {
/**
* The accumulated elements classes
*/
- static Class[] accumulatedElements = {StoreFolder.class, StoreMessage.class,
- StoreAppointment.class, StoreContact.class};
+ static Class[] accumulatedElements = {
+ StoreFolder.class,
+ StoreMessage.class,
+ StoreAppointment.class,
+ StoreContact.class,
+ };
/**
* The extracted elements counters map.
@@ -432,8 +443,7 @@ private static void preventExternalToolsForTextExtractionInTika() {
* Useful only for testing purposes.
*/
private static final double THREAD_MULTIPLIER = Double.parseDouble(System.getProperty("thread.factor", "1.5"));
- private int maxParallelThreads = (int) Math.round(
- Runtime.getRuntime().availableProcessors() * THREAD_MULTIPLIER);
+ private int maxParallelThreads = (int) Math.round(Runtime.getRuntime().availableProcessors() * THREAD_MULTIPLIER);
/**
* Add mimetypes, scheme, isContainer, store extractor known relation.
@@ -450,12 +460,16 @@ private static void preventExternalToolsForTextExtractionInTika() {
* @param extractor the extractor
*/
@SuppressWarnings("rawtypes")
- public static void addExtractionRelation(String mimeType, String droidFormat, String scheme, boolean isContainer, Class extractor) {
+ public static void addExtractionRelation(
+ String mimeType,
+ String droidFormat,
+ String scheme,
+ boolean isContainer,
+ Class extractor
+ ) {
// if there is a file mimetype for this scheme
- if (mimeType != null)
- mimeTypeSchemeMap.put(mimeType, scheme);
- if (droidFormat != null)
- droidFormatSchemeMap.put(droidFormat, scheme);
+ if (mimeType != null) mimeTypeSchemeMap.put(mimeType, scheme);
+ if (droidFormat != null) droidFormatSchemeMap.put(droidFormat, scheme);
schemeStoreExtractorClassMap.put(scheme, extractor);
schemeContainerMap.put(scheme, isContainer);
}
@@ -487,16 +501,12 @@ public static String composeStoreURL(String scheme, String authority, String use
result = scheme + "://";
if (user != null && !user.isEmpty()) {
result += URLEncoder.encode(user, "UTF-8");
- if (password != null && !password.isEmpty())
- result += ":" + URLEncoder.encode(password, "UTF-8");
+ if (password != null && !password.isEmpty()) result += ":" + URLEncoder.encode(password, "UTF-8");
result += "@";
}
- if (authority != null && !authority.isEmpty())
- result += authority;
- else
- result += "localhost";
- if (path != null && !path.isEmpty())
- result += "/" + URLEncoder.encode(path, "UTF-8");
+ if (authority != null && !authority.isEmpty()) result += authority;
+ else result += "localhost";
+ if (path != null && !path.isEmpty()) result += "/" + URLEncoder.encode(path, "UTF-8");
} catch (UnsupportedEncodingException e) {
// impossible case with UTF-8
}
@@ -512,24 +522,33 @@ public static String composeStoreURL(String scheme, String authority, String use
* @return the initialized global list ps
*/
@SuppressWarnings("unchecked")
- synchronized public PrintStream getGlobalListPS(Class listClass) {
+ public synchronized PrintStream getGlobalListPS(Class listClass) {
String globalListName = null;
PrintStream result = null;
try {
globalListName = (String) listClass.getMethod("getElementName").invoke(null);
result = globalListsPSMap.get(globalListName);
if (result == null) {
- String dirname = this.destRootPath
- + File.separator + this.destName + File.separator;
+ String dirname = this.destRootPath + File.separator + this.destName + File.separator;
Files.createDirectories(Paths.get(dirname));
result = new PrintStream(dirname + listClass.getMethod("getElementName").invoke(null) + ".csv");
globalListsPSMap.put(globalListName, result);
listClass.getMethod("printGlobalListCSVHeader", PrintStream.class).invoke(null, result);
}
} catch (IOException | NoSuchMethodException | IllegalAccessException e) {
- doProgressLogWithoutInterruption(logger, MailExtractProgressLogger.GLOBAL, "mailextractlib: can't create global list for [" + globalListName + "] csv file", e);
+ doProgressLogWithoutInterruption(
+ logger,
+ MailExtractProgressLogger.GLOBAL,
+ "mailextractlib: can't create global list for [" + globalListName + "] csv file",
+ e
+ );
} catch (InvocationTargetException te) {
- doProgressLogWithoutInterruption(logger, MailExtractProgressLogger.GLOBAL, "mailextractlib: can't create global list for [" + globalListName + "] csv file", te.getTargetException());
+ doProgressLogWithoutInterruption(
+ logger,
+ MailExtractProgressLogger.GLOBAL,
+ "mailextractlib: can't create global list for [" + globalListName + "] csv file",
+ te.getTargetException()
+ );
}
return result;
}
@@ -545,7 +564,7 @@ synchronized public PrintStream getGlobalListPS(Class listClass) {
* @return the initialized global list counter
*/
@SuppressWarnings("unchecked")
- synchronized public int getElementCounter(Class listClass, boolean subFlag) {
+ public synchronized int getElementCounter(Class listClass, boolean subFlag) {
String elementName = null;
Integer result = 0;
try {
@@ -556,14 +575,31 @@ synchronized public int getElementCounter(Class listClass, boolean subFlag) {
result = 0;
}
} catch (NoSuchMethodException | IllegalAccessException e) {
- doProgressLogWithoutInterruption(logger, MailExtractProgressLogger.GLOBAL, "mailextractlib: can't create counter for " + (subFlag ? "sub " : "") + "[" + elementName + "] csv file", e);
+ doProgressLogWithoutInterruption(
+ logger,
+ MailExtractProgressLogger.GLOBAL,
+ "mailextractlib: can't create counter for " +
+ (subFlag ? "sub " : "") +
+ "[" +
+ elementName +
+ "] csv file",
+ e
+ );
} catch (InvocationTargetException te) {
- doProgressLogWithoutInterruption(logger, MailExtractProgressLogger.GLOBAL, "mailextractlib: can't create counter for " + (subFlag ? "sub " : "") + "[" + elementName + "] csv file", te.getTargetException());
+ doProgressLogWithoutInterruption(
+ logger,
+ MailExtractProgressLogger.GLOBAL,
+ "mailextractlib: can't create counter for " +
+ (subFlag ? "sub " : "") +
+ "[" +
+ elementName +
+ "] csv file",
+ te.getTargetException()
+ );
}
return result;
}
-
/**
* Adds a value to the counter for a specific type of extracted element (e.g., message, folder, appointment, contact...) and returns the updated counter.
* If the counter does not exist, it is initialized with the provided value and then returned.
@@ -576,26 +612,41 @@ synchronized public int getElementCounter(Class listClass, boolean subFlag) {
* @return the updated counter value
*/
@SuppressWarnings("unchecked")
- synchronized public int addElementCounter(int value, Class listClass, boolean subFlag) {
+ public synchronized int addElementCounter(int value, Class listClass, boolean subFlag) {
String elementName = null;
Integer result = 0;
try {
elementName = (String) listClass.getMethod("getElementName").invoke(null);
result = (subFlag ? subElementsCounterMap : elementsCounterMap).get(elementName);
- if (result == null)
- result = value;
- else
- result += value;
+ if (result == null) result = value;
+ else result += value;
(subFlag ? subElementsCounterMap : elementsCounterMap).put(elementName, result);
} catch (NoSuchMethodException | IllegalAccessException e) {
- doProgressLogWithoutInterruption(logger, MailExtractProgressLogger.GLOBAL, "mailextractlib: can't create counter for " + (subFlag ? "sub " : "") + "[" + elementName + "] csv file", e);
+ doProgressLogWithoutInterruption(
+ logger,
+ MailExtractProgressLogger.GLOBAL,
+ "mailextractlib: can't create counter for " +
+ (subFlag ? "sub " : "") +
+ "[" +
+ elementName +
+ "] csv file",
+ e
+ );
} catch (InvocationTargetException te) {
- doProgressLogWithoutInterruption(logger, MailExtractProgressLogger.GLOBAL, "mailextractlib: can't create counter for " + (subFlag ? "sub " : "") + "[" + elementName + "] csv file", te.getTargetException());
+ doProgressLogWithoutInterruption(
+ logger,
+ MailExtractProgressLogger.GLOBAL,
+ "mailextractlib: can't create counter for " +
+ (subFlag ? "sub " : "") +
+ "[" +
+ elementName +
+ "] csv file",
+ te.getTargetException()
+ );
}
return result;
}
-
/**
* Increment the counter for a certain type of extracted element (message, folder, appointment, contact...), and return the counter if it exists.
* If not init the counter to 1, and return the counter.
@@ -614,12 +665,10 @@ public int incElementCounter(Class listClass) {
*
* @param subExtractor the sub extractor
*/
- synchronized public void accumulateSubElements(StoreExtractor subExtractor) {
+ public synchronized void accumulateSubElements(StoreExtractor subExtractor) {
for (Class c : accumulatedElements) {
- int value = subExtractor.getElementCounter(c, false) +
- subExtractor.getElementCounter(c, true);
- if (value > 0)
- addElementCounter(value, c, true);
+ int value = subExtractor.getElementCounter(c, false) + subExtractor.getElementCounter(c, true);
+ if (value > 0) addElementCounter(value, c, true);
}
}
@@ -644,9 +693,15 @@ protected void closeGlobalListsPSMap() {
* @param logger logger used
* @throws MailExtractLibException Any unrecoverable extraction exception (access trouble, major format problems...)
*/
- protected StoreExtractor(String urlString, String rootStoreFolderName, String destPathString, StoreExtractorOptions options,
- StoreExtractor fatherStoreExtractor, StoreElement fatherElement, MailExtractProgressLogger logger) throws MailExtractLibException {
-
+ protected StoreExtractor(
+ String urlString,
+ String rootStoreFolderName,
+ String destPathString,
+ StoreExtractorOptions options,
+ StoreExtractor fatherStoreExtractor,
+ StoreElement fatherElement,
+ MailExtractProgressLogger logger
+ ) throws MailExtractLibException {
URLName url;
url = new URLName(urlString);
@@ -658,12 +713,9 @@ protected StoreExtractor(String urlString, String rootStoreFolderName, String de
String tempPassword = null;
String tempPath = null;
try {
- if (url.getUsername() != null)
- tempUser = URLDecoder.decode(url.getUsername(), "UTF-8");
- if (url.getPassword() != null)
- tempPassword = URLDecoder.decode(url.getPassword(), "UTF-8");
- if (url.getFile() != null)
- tempPath = URLDecoder.decode(url.getFile(), "UTF-8");
+ if (url.getUsername() != null) tempUser = URLDecoder.decode(url.getUsername(), "UTF-8");
+ if (url.getPassword() != null) tempPassword = URLDecoder.decode(url.getPassword(), "UTF-8");
+ if (url.getFile() != null) tempPath = URLDecoder.decode(url.getFile(), "UTF-8");
} catch (UnsupportedEncodingException ignored) {
// not possible
}
@@ -674,19 +726,15 @@ protected StoreExtractor(String urlString, String rootStoreFolderName, String de
this.rootStoreFolderName = rootStoreFolderName;
this.destRootPath = Paths.get(destPathString).toAbsolutePath().normalize().getParent().toString();
this.destName = Paths.get(destPathString).toAbsolutePath().normalize().getFileName().toString();
- if (options == null)
- this.options = new StoreExtractorOptions();
- else
- this.options = options;
+ if (options == null) this.options = new StoreExtractorOptions();
+ else this.options = options;
this.totalRawSize = new AtomicLong(0);
this.fatherStoreExtractor = fatherStoreExtractor;
this.fatherElement = fatherElement;
- if (fatherStoreExtractor == null)
- this.rootStoreExtractor = this;
- else
- this.rootStoreExtractor = fatherStoreExtractor.rootStoreExtractor;
+ if (fatherStoreExtractor == null) this.rootStoreExtractor = this;
+ else this.rootStoreExtractor = fatherStoreExtractor.rootStoreExtractor;
this.logger = logger;
this.description = ":p:" + scheme + ":u:" + user;
@@ -697,8 +745,20 @@ protected StoreExtractor(String urlString, String rootStoreFolderName, String de
uniqID = new AtomicInteger(0);
- doProgressLogIfDebug(logger, "StoreExtractor [" + this + "] created with url=" + urlString +
- " rootFolder=" + rootStoreFolderName + " destPath=" + destPathString + " rootExtractor=" + fatherStoreExtractor, null);
+ doProgressLogIfDebug(
+ logger,
+ "StoreExtractor [" +
+ this +
+ "] created with url=" +
+ urlString +
+ " rootFolder=" +
+ rootStoreFolderName +
+ " destPath=" +
+ destPathString +
+ " rootExtractor=" +
+ fatherStoreExtractor,
+ null
+ );
}
/**
@@ -707,19 +767,35 @@ protected StoreExtractor(String urlString, String rootStoreFolderName, String de
* @throws InterruptedException the interrupted exception
*/
public void writeTargetLog() throws InterruptedException {
-
// if root extractor log extraction context
if (fatherStoreExtractor == null) {
- doProgressLog(logger, MailExtractProgressLogger.GLOBAL,
- "mailextract :target store with scheme=" + scheme + (host == null || host.isEmpty() ? "" : " server=" + host)
- + (port == -1 ? "" : ":" + Integer.toString(port))
- + (user == null || user.isEmpty() ? "" : " user=" + user)
- + (password == null || password.isEmpty() ? "" : " password=" + password)
- + (path == null || path.isEmpty() ? "" : " path=" + path)
- + (rootStoreFolderName == null || rootStoreFolderName.isEmpty() ? "" : " store folder=" + rootStoreFolderName), null);
- doProgressLog(logger, MailExtractProgressLogger.GLOBAL, "to " + destRootPath + " in " + destName + " directory", null);
- if ((logger != null) && logger.getDebugFlag())
- doProgressLog(logger, MailExtractProgressLogger.GLOBAL, "DEBUG MODE", null);
+ doProgressLog(
+ logger,
+ MailExtractProgressLogger.GLOBAL,
+ "mailextract :target store with scheme=" +
+ scheme +
+ (host == null || host.isEmpty() ? "" : " server=" + host) +
+ (port == -1 ? "" : ":" + Integer.toString(port)) +
+ (user == null || user.isEmpty() ? "" : " user=" + user) +
+ (password == null || password.isEmpty() ? "" : " password=" + password) +
+ (path == null || path.isEmpty() ? "" : " path=" + path) +
+ (rootStoreFolderName == null || rootStoreFolderName.isEmpty()
+ ? ""
+ : " store folder=" + rootStoreFolderName),
+ null
+ );
+ doProgressLog(
+ logger,
+ MailExtractProgressLogger.GLOBAL,
+ "to " + destRootPath + " in " + destName + " directory",
+ null
+ );
+ if ((logger != null) && logger.getDebugFlag()) doProgressLog(
+ logger,
+ MailExtractProgressLogger.GLOBAL,
+ "DEBUG MODE",
+ null
+ );
boolean first = true;
String optionsLog = "";
@@ -728,19 +804,16 @@ public void writeTargetLog() throws InterruptedException {
first = false;
}
if (options.dropEmptyFolders) {
- if (!first)
- optionsLog += ", ";
+ if (!first) optionsLog += ", ";
optionsLog += "droping all empty folders";
first = false;
}
if (options.warningMsgProblem) {
- if (!first)
- optionsLog += ", ";
+ if (!first) optionsLog += ", ";
optionsLog += "generate warning when there's a problem on a message (otherwise log at FINEST level)";
first = false;
}
- if (!first)
- optionsLog += ", ";
+ if (!first) optionsLog += ", ";
optionsLog += "with names length=" + Integer.toString(options.namesLength);
optionsLog += ", ";
optionsLog += "with log level " + getProgressLogger().getLevelName();
@@ -783,12 +856,10 @@ public boolean hasDestName() {
* @return a unique ID
*/
- synchronized public int getNewUniqID() {
+ public synchronized int getNewUniqID() {
int id;
- if (fatherStoreExtractor == null)
- id = uniqID.addAndGet(1);
- else
- id = rootStoreExtractor.getNewUniqID();
+ if (fatherStoreExtractor == null) id = uniqID.addAndGet(1);
+ else id = rootStoreExtractor.getNewUniqID();
return id;
}
@@ -880,11 +951,23 @@ public StoreElement getFatherElement() {
* @return the store extractor, constructed as a non abstract subclass
* @throws MailExtractLibException Any unrecoverable extraction exception (access trouble, major format problems...)
*/
- public static StoreExtractor createStoreExtractor(String urlString, String rootStoreFolderName, String destPathString,
- StoreExtractorOptions options, MailExtractProgressLogger logger) throws MailExtractLibException {
+ public static StoreExtractor createStoreExtractor(
+ String urlString,
+ String rootStoreFolderName,
+ String destPathString,
+ StoreExtractorOptions options,
+ MailExtractProgressLogger logger
+ ) throws MailExtractLibException {
StoreExtractor storeExtractor;
- storeExtractor = createInternalStoreExtractor(urlString, rootStoreFolderName, destPathString, options, null, logger);
+ storeExtractor = createInternalStoreExtractor(
+ urlString,
+ rootStoreFolderName,
+ destPathString,
+ options,
+ null,
+ logger
+ );
return storeExtractor;
}
@@ -892,20 +975,26 @@ public static StoreExtractor createStoreExtractor(String urlString, String rootS
/**
* Create an internal depth store extractor as a factory creator.
*/
- @SuppressWarnings({"unchecked", "rawtypes"})
- private static StoreExtractor createInternalStoreExtractor(String urlString, String rootStoreFolderName,
- String destPathString, StoreExtractorOptions options, StoreExtractor
- rootStoreExtractor, MailExtractProgressLogger logger
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private static StoreExtractor createInternalStoreExtractor(
+ String urlString,
+ String rootStoreFolderName,
+ String destPathString,
+ StoreExtractorOptions options,
+ StoreExtractor rootStoreExtractor,
+ MailExtractProgressLogger logger
) throws MailExtractLibException {
-
StoreExtractor store;
URLName url;
url = new URLName(urlString);
// get read of leading file separator in folder
- if ((rootStoreFolderName != null) && (!rootStoreFolderName.isEmpty()) && (rootStoreFolderName.substring(0, 1).equals(File.separator)))
- rootStoreFolderName = rootStoreFolderName.substring(1);
+ if (
+ (rootStoreFolderName != null) &&
+ (!rootStoreFolderName.isEmpty()) &&
+ (rootStoreFolderName.substring(0, 1).equals(File.separator))
+ ) rootStoreFolderName = rootStoreFolderName.substring(1);
// find the store extractor constructor for scheme in URL
Class storeExtractorClass = StoreExtractor.schemeStoreExtractorClassMap.get(url.getProtocol());
@@ -913,11 +1002,23 @@ private static StoreExtractor createInternalStoreExtractor(String urlString, Str
throw new MailExtractLibException("mailextractlib: unknown store type=" + url.getProtocol(), null);
} else {
try {
- store = (StoreExtractor) storeExtractorClass.getConstructor(String.class, String.class, String.class,
- StoreExtractorOptions.class, StoreExtractor.class, MailExtractProgressLogger.class)
- .newInstance(urlString, rootStoreFolderName, destPathString, options, rootStoreExtractor, logger);
- } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException
- | SecurityException e) {
+ store = (StoreExtractor) storeExtractorClass
+ .getConstructor(
+ String.class,
+ String.class,
+ String.class,
+ StoreExtractorOptions.class,
+ StoreExtractor.class,
+ MailExtractProgressLogger.class
+ )
+ .newInstance(urlString, rootStoreFolderName, destPathString, options, rootStoreExtractor, logger);
+ } catch (
+ InstantiationException
+ | IllegalAccessException
+ | IllegalArgumentException
+ | NoSuchMethodException
+ | SecurityException e
+ ) {
throw new MailExtractLibException("mailextractlib: dysfonctional store type=" + url.getProtocol(), e);
} catch (InvocationTargetException e) {
Throwable te = e.getCause();
@@ -928,9 +1029,8 @@ private static StoreExtractor createInternalStoreExtractor(String urlString, Str
}
private static String readableFileSize(long size) {
- if (size <= 0)
- return "0";
- final String[] units = new String[]{"B", "kB", "MB", "GB", "TB"};
+ if (size <= 0) return "0";
+ final String[] units = new String[] { "B", "kB", "MB", "GB", "TB" };
int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups];
}
@@ -952,15 +1052,12 @@ public String getSummary() {
}
Integer count = elementsCounterMap.get(elementName);
if ((count != null) && (count > 0)) {
- if (!elementSummary.isEmpty())
- elementSummary += ",";
+ if (!elementSummary.isEmpty()) elementSummary += ",";
elementSummary += " " + count + " " + elementName;
}
}
- if (elementSummary.isEmpty())
- summary += " empty extraction";
- else
- summary += " writing" + elementSummary;
+ if (elementSummary.isEmpty()) summary += " empty extraction";
+ else summary += " writing" + elementSummary;
String subElementSummary = "";
for (Class elementClass : accumulatedElements) {
String elementName = null;
@@ -971,15 +1068,12 @@ public String getSummary() {
}
Integer count = subElementsCounterMap.get(elementName);
if ((count != null) && (count > 0)) {
- if (!subElementSummary.isEmpty())
- subElementSummary += ",";
+ if (!subElementSummary.isEmpty()) subElementSummary += ",";
subElementSummary += " " + count + " " + elementName;
}
}
- if (subElementSummary.isEmpty())
- summary += " without embedded elements";
- else
- summary += " with" + subElementSummary + " embedded";
+ if (subElementSummary.isEmpty()) summary += " without embedded elements";
+ else summary += " with" + subElementSummary + " embedded";
summary += " for a total size of " + readableFileSize(getTotalRawSize());
return summary;
}
@@ -1010,19 +1104,23 @@ public void extractAllFolders() throws MailExtractLibException, InterruptedExcep
rootNode.addMetadata("DescriptionLevel", "RecordGrp", true);
// title generation from context
- if ((user != null) && (!user.isEmpty()))
- title = "Ensemble des messages électroniques et informations associées (contacts, rendez-vous...) envoyés et reçus par le compte " + user;
- else if ((path != null) && (!path.isEmpty()))
- title = "Ensemble des messages électroniques et informations associées (contacts, rendez-vous...) du container " + path;
- else
- title = "Ensemble de messages électroniques et informations associées (contacts, rendez-vous...)";
- if ((host != null) && (!host.isEmpty()) && (!host.equals("localhost")))
- title += " sur le serveur " + host + (port == -1 ? "" : ":" + Integer.toString(port));
+ if ((user != null) && (!user.isEmpty())) title =
+ "Ensemble des messages électroniques et informations associées (contacts, rendez-vous...) envoyés et reçus par le compte " +
+ user;
+ else if ((path != null) && (!path.isEmpty())) title =
+ "Ensemble des messages électroniques et informations associées (contacts, rendez-vous...) du container " +
+ path;
+ else title = "Ensemble de messages électroniques et informations associées (contacts, rendez-vous...)";
+ if ((host != null) && (!host.isEmpty()) && (!host.equals("localhost"))) title +=
+ " sur le serveur " + host + (port == -1 ? "" : ":" + Integer.toString(port));
title += " à la date du " + start;
rootNode.addMetadata("Title", title, true);
if (rootStoreFolder.getDateRange().isDefined()) {
- rootNode.addMetadata("StartDate", DateRange.getISODateString(rootStoreFolder.getDateRange().getStart()),
- true);
+ rootNode.addMetadata(
+ "StartDate",
+ DateRange.getISODateString(rootStoreFolder.getDateRange().getStart()),
+ true
+ );
rootNode.addMetadata("EndDate", DateRange.getISODateString(rootStoreFolder.getDateRange().getEnd()), true);
}
rootNode.write();
@@ -1053,7 +1151,7 @@ public void listAllFolders(boolean stats) throws MailExtractLibException, Interr
start = Instant.now();
- int memProgressLogLevel=logger.getProgressLogLevel();
+ int memProgressLogLevel = logger.getProgressLogLevel();
logger.setProgressLogLevel(GLOBAL);
writeTargetLog();
doProgressLog(logger, MailExtractProgressLogger.GLOBAL, "mailextractlib: listing begin", null);
@@ -1096,11 +1194,9 @@ public static boolean hasMagicNumber(byte[] content, byte[] magicNumber) {
* @return true, if successful
*/
public static boolean hasMagicNumber(byte[] content, byte[] magicNumber, int offset) {
- if (content.length < magicNumber.length + offset)
- return false;
+ if (content.length < magicNumber.length + offset) return false;
for (int i = 0; i < magicNumber.length; i++) {
- if (content[i + offset] != magicNumber[i])
- return false;
+ if (content[i + offset] != magicNumber[i]) return false;
}
return true;
}
@@ -1158,5 +1254,4 @@ public void setMaxParallelThreads(int maxParallelThreads) {
public StoreExtractor getRootStoreExtractor() {
return rootStoreExtractor;
}
-
-}
\ No newline at end of file
+}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreExtractorOptions.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreExtractorOptions.java
index daafd8a4..150b7e8d 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreExtractorOptions.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreExtractorOptions.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.core;
/**
@@ -116,10 +126,19 @@ public StoreExtractorOptions() {
* @param extractFileTextMetadata the extract file text metadata flag
* @param model the model version (1 or 2)
*/
- public StoreExtractorOptions(boolean keepOnlyDeepEmptyFolders, boolean dropEmptyFolders, boolean warningMsgProblem,
- int namesLength, String defaultCharsetName, boolean extractElementsList, boolean extractMessageTextFile,
- boolean extractMessageTextMetadata,
- boolean extractFileTextFile, boolean extractFileTextMetadata, int model) {
+ public StoreExtractorOptions(
+ boolean keepOnlyDeepEmptyFolders,
+ boolean dropEmptyFolders,
+ boolean warningMsgProblem,
+ int namesLength,
+ String defaultCharsetName,
+ boolean extractElementsList,
+ boolean extractMessageTextFile,
+ boolean extractMessageTextMetadata,
+ boolean extractFileTextFile,
+ boolean extractFileTextMetadata,
+ int model
+ ) {
this.keepOnlyDeepEmptyFolders = keepOnlyDeepEmptyFolders;
this.dropEmptyFolders = dropEmptyFolders;
this.warningMsgProblem = warningMsgProblem;
@@ -156,14 +175,23 @@ public StoreExtractorOptions(boolean keepOnlyDeepEmptyFolders, boolean dropEmpty
* @param extractFileTextMetadata the extract file text metadata flag
* @param model the model version (1 or 2)
*/
- public StoreExtractorOptions(boolean keepOnlyDeepEmptyFolders, boolean dropEmptyFolders, boolean warningMsgProblem,
- int namesLength, String defaultCharsetName,
- boolean extractMessages, boolean extractContacts, boolean extractAppointments,
- boolean extractElementsContent,
- boolean extractElementsList,
- boolean extractMessageTextFile,
- boolean extractMessageTextMetadata,
- boolean extractFileTextFile, boolean extractFileTextMetadata, int model) {
+ public StoreExtractorOptions(
+ boolean keepOnlyDeepEmptyFolders,
+ boolean dropEmptyFolders,
+ boolean warningMsgProblem,
+ int namesLength,
+ String defaultCharsetName,
+ boolean extractMessages,
+ boolean extractContacts,
+ boolean extractAppointments,
+ boolean extractElementsContent,
+ boolean extractElementsList,
+ boolean extractMessageTextFile,
+ boolean extractMessageTextMetadata,
+ boolean extractFileTextFile,
+ boolean extractFileTextMetadata,
+ int model
+ ) {
this.keepOnlyDeepEmptyFolders = keepOnlyDeepEmptyFolders;
this.dropEmptyFolders = dropEmptyFolders;
this.warningMsgProblem = warningMsgProblem;
@@ -180,5 +208,4 @@ public StoreExtractorOptions(boolean keepOnlyDeepEmptyFolders, boolean dropEmpty
this.extractFileTextMetadata = extractFileTextMetadata;
this.model = model;
}
-
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreFolder.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreFolder.java
index 912dc66f..3ceefe79 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreFolder.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreFolder.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.core;
import fr.gouv.vitam.tools.mailextractlib.nodes.ArchiveUnit;
@@ -104,7 +114,7 @@ protected StoreFolder(StoreExtractor storeExtractor) {
*
* @return the element name
*/
- static public String getElementName() {
+ public static String getElementName() {
return "folders";
}
@@ -119,7 +129,6 @@ static public String getElementName() {
*/
protected void finalizeStoreFolder(StoreFolder father) {
folderArchiveUnit = new ArchiveUnit(storeExtractor, father.folderArchiveUnit, "Folder", getName());
-
}
/**
@@ -138,10 +147,13 @@ public MailExtractProgressLogger getProgressLogger() {
// log at the folder level considering storeExtractor depth
private void logFolder(String msg) throws InterruptedException {
- if (storeExtractor.isRoot())
- doProgressLog(storeExtractor.getProgressLogger(), MailExtractProgressLogger.FOLDER, msg, null);
- else
- doProgressLog(storeExtractor.getProgressLogger(), MailExtractProgressLogger.MESSAGE_DETAILS, msg, null);
+ if (storeExtractor.isRoot()) doProgressLog(
+ storeExtractor.getProgressLogger(),
+ MailExtractProgressLogger.FOLDER,
+ msg,
+ null
+ );
+ else doProgressLog(storeExtractor.getProgressLogger(), MailExtractProgressLogger.MESSAGE_DETAILS, msg, null);
}
/**
@@ -157,7 +169,7 @@ public StoreExtractor getStoreExtractor() {
* Extends the date range with the extra date range.
* This method is thread-safe, enabling non-abstract Folders and Elements to work on dateRange in parallel.
**/
- synchronized public void extendDateRange(DateRange extraDateRange) {
+ public synchronized void extendDateRange(DateRange extraDateRange) {
dateRange.extendRange(extraDateRange);
}
@@ -165,7 +177,7 @@ synchronized public void extendDateRange(DateRange extraDateRange) {
* Extends the date range with the extra date.
* This method is thread-safe, enabling non-abstract Folders and Elements to work on dateRange in parallel.
*/
- synchronized public void extendDateRange(Date extraDate) {
+ public synchronized void extendDateRange(Date extraDate) {
dateRange.extendRange(extraDate);
}
@@ -175,7 +187,7 @@ synchronized public void extendDateRange(Date extraDate) {
*
* @return the date range
*/
- synchronized public DateRange getDateRange() {
+ public synchronized DateRange getDateRange() {
return dateRange;
}
@@ -299,11 +311,11 @@ public void extractFolderAsRoot(boolean writeFlag) throws MailExtractLibExceptio
if (folderElementsCount.get() + folderSubFoldersCount.get() != 0) {
// accumulate in store extractor statistics out of recursion
// if the scheme is not a container one but an embedded message folder counter is not used
- if (StoreExtractor.schemeContainerMap.get(storeExtractor.scheme))
- storeExtractor.incElementCounter(this.getClass());
+ if (StoreExtractor.schemeContainerMap.get(storeExtractor.scheme)) storeExtractor.incElementCounter(
+ this.getClass()
+ );
storeExtractor.addTotalRawSize(getFolderElementsRawSize());
- } else
- logFolder("mailextractlib: empty extraction");
+ } else logFolder("mailextractlib: empty extraction");
}
/**
@@ -333,8 +345,11 @@ public boolean extractFolder(int level, boolean writeFlag) throws MailExtractLib
extractFolderElements(writeFlag);
// extract all subfolders in the folder to the unit directory
extractSubFolders(level, writeFlag);
- if ((folderElementsCount.get() + folderSubFoldersCount.get() != 0) || ((!storeExtractor.options.dropEmptyFolders)
- && !(level == 1 && storeExtractor.options.keepOnlyDeepEmptyFolders))) {
+ if (
+ (folderElementsCount.get() + folderSubFoldersCount.get() != 0) ||
+ ((!storeExtractor.options.dropEmptyFolders) &&
+ !(level == 1 && storeExtractor.options.keepOnlyDeepEmptyFolders))
+ ) {
// get specific folder metadata to the unit
// compute and add to the folder ArchiveUnit the expected folder
// metadata
@@ -344,13 +359,13 @@ public boolean extractFolder(int level, boolean writeFlag) throws MailExtractLib
folderArchiveUnit.addMetadata("StartDate", DateRange.getISODateString(dateRange.getStart()), true);
folderArchiveUnit.addMetadata("EndDate", DateRange.getISODateString(dateRange.getEnd()), true);
}
- if (writeFlag)
- folderArchiveUnit.write();
+ if (writeFlag) folderArchiveUnit.write();
result = true;
storeExtractor.incElementCounter(this.getClass());
storeExtractor.addTotalRawSize(getFolderElementsRawSize());
- } else
- logFolder("mailextractlib: empty folder " + FileSystems.getDefault().getSeparator() + getFullName() + " is droped");
+ } else logFolder(
+ "mailextractlib: empty folder " + FileSystems.getDefault().getSeparator() + getFullName() + " is droped"
+ );
// accumulate in store extractor statistics out of recursion
return result;
@@ -360,8 +375,7 @@ public boolean extractFolder(int level, boolean writeFlag) throws MailExtractLib
private void extractFolderElements(boolean writeFlag) throws MailExtractLibException, InterruptedException {
folderElementsCount.set(0);
folderElementsRawSize.set(0);
- if (hasElements())
- doExtractFolderElements(writeFlag);
+ if (hasElements()) doExtractFolderElements(writeFlag);
}
/**
@@ -375,13 +389,13 @@ private void extractFolderElements(boolean writeFlag) throws MailExtractLibExcep
* @throws MailExtractLibException Any unrecoverable extraction exception (access trouble, major format problems...)
* @throws InterruptedException the interrupted exception
*/
- protected abstract void doExtractFolderElements(boolean writeFlag) throws MailExtractLibException, InterruptedException;
+ protected abstract void doExtractFolderElements(boolean writeFlag)
+ throws MailExtractLibException, InterruptedException;
// encapsulate the subclasses real processing method
private void extractSubFolders(int level, boolean writeFlag) throws MailExtractLibException, InterruptedException {
folderSubFoldersCount.set(0);
- if (hasSubfolders())
- doExtractSubFolders(level, writeFlag);
+ if (hasSubfolders()) doExtractSubFolders(level, writeFlag);
}
/**
@@ -396,7 +410,8 @@ private void extractSubFolders(int level, boolean writeFlag) throws MailExtractL
* @throws MailExtractLibException Any unrecoverable extraction exception (access trouble, major format problems...)
* @throws InterruptedException the interrupted exception
*/
- protected abstract void doExtractSubFolders(int level, boolean writeFlag) throws MailExtractLibException, InterruptedException;
+ protected abstract void doExtractSubFolders(int level, boolean writeFlag)
+ throws MailExtractLibException, InterruptedException;
/**
* List all folders with or without statistics.
@@ -415,18 +430,26 @@ public void listFolder(boolean stats) throws MailExtractLibException, Interrupte
String fullName, tmp;
fullName = getFullName();
- if (fullName == null || fullName.isEmpty())
- fullName = "";
+ if (fullName == null || fullName.isEmpty()) fullName = "";
// log process on folder
if (stats) {
// inspect all elements in the folder for statistics
listFolderElements(stats);
// expose this folder statistics
- tmp = String.format("%5d éléments %7.2f MBytes " + FileSystems.getDefault().getSeparator() + "%s", folderElementsCount.get(),
- ((double) folderElementsRawSize.get()) / (1024.0 * 1024.0), fullName);
+ tmp = String.format(
+ "%5d éléments %7.2f MBytes " + FileSystems.getDefault().getSeparator() + "%s",
+ folderElementsCount.get(),
+ ((double) folderElementsRawSize.get()) / (1024.0 * 1024.0),
+ fullName
+ );
doProgressLog(storeExtractor.getProgressLogger(), MailExtractProgressLogger.GLOBAL, tmp, null);
} else {
- doProgressLog(storeExtractor.getProgressLogger(), MailExtractProgressLogger.GLOBAL, FileSystems.getDefault().getSeparator() + fullName, null);
+ doProgressLog(
+ storeExtractor.getProgressLogger(),
+ MailExtractProgressLogger.GLOBAL,
+ FileSystems.getDefault().getSeparator() + fullName,
+ null
+ );
}
// extract all subfolders in the folder to the unit directory
listSubFolders(stats);
@@ -442,8 +465,7 @@ public void listFolder(boolean stats) throws MailExtractLibException, Interrupte
private void listFolderElements(boolean stats) throws MailExtractLibException, InterruptedException {
folderElementsCount.set(0);
folderElementsRawSize.set(0);
- if (hasElements())
- doListFolderElements(stats);
+ if (hasElements()) doListFolderElements(stats);
}
/**
@@ -463,8 +485,7 @@ private void listFolderElements(boolean stats) throws MailExtractLibException, I
// encapsulate the subclasses real processing method
private void listSubFolders(boolean stats) throws MailExtractLibException, InterruptedException {
folderSubFoldersCount.set(0);
- if (hasSubfolders())
- doListSubFolders(stats);
+ if (hasSubfolders()) doListSubFolders(stats);
}
/**
@@ -478,5 +499,4 @@ private void listSubFolders(boolean stats) throws MailExtractLibException, Inter
* @throws InterruptedException the interrupted exception
*/
protected abstract void doListSubFolders(boolean stats) throws MailExtractLibException, InterruptedException;
-
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreMessage.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreMessage.java
index 24780516..054b7955 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreMessage.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/core/StoreMessage.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.core;
import fr.gouv.vitam.tools.mailextractlib.formattools.HTMLTextExtractor;
@@ -36,9 +46,6 @@
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractLibException;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractProgressLogger;
import fr.gouv.vitam.tools.mailextractlib.utils.RawDataSource;
-import org.apache.poi.hmef.Attachment;
-import org.apache.poi.hmef.HMEFMessage;
-
import jakarta.activation.DataHandler;
import jakarta.mail.MessagingException;
import jakarta.mail.Session;
@@ -46,10 +53,11 @@
import jakarta.mail.internet.MimeMessage;
import jakarta.mail.internet.MimeMultipart;
import jakarta.mail.internet.MimeUtility;
+import org.apache.poi.hmef.Attachment;
+import org.apache.poi.hmef.HMEFMessage;
import java.io.*;
import java.nio.charset.StandardCharsets;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -117,22 +125,22 @@ public abstract class StoreMessage extends StoreElement {
/**
* The Constant TEXT_BODY.
*/
- static public final int TEXT_BODY = 0;
+ public static final int TEXT_BODY = 0;
/**
* The Constant HTML_BODY.
*/
- static public final int HTML_BODY = 1;
+ public static final int HTML_BODY = 1;
/**
* The Constant RTF_BODY.
*/
- static public final int RTF_BODY = 2;
+ public static final int RTF_BODY = 2;
/**
* The Constant OUT_OF_BODY.
*/
- static public final int OUT_OF_BODY = 3;
+ public static final int OUT_OF_BODY = 3;
/**
* Complete mail header from original smtp format, if any.
@@ -276,10 +284,8 @@ public byte[] getMimeContent() {
@Override
public String getLogDescription() {
String result = "message " + listLineId;
- if (subject != null)
- result += " [" + subject + "]";
- else
- result += " [no subject]";
+ if (subject != null) result += " [" + subject + "]";
+ else result += " [no subject]";
return result;
}
@@ -390,10 +396,12 @@ protected void detectTNEFAttachment() throws InterruptedException {
List
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.formattools;
import org.jsoup.Jsoup;
@@ -52,12 +62,12 @@
* @author Jonathan Hedley, jonathan@hedley.net
*/
public class HTMLTextExtractor {
+
/** Singleton instance **/
private static HTMLTextExtractor INSTANCE = new HTMLTextExtractor();
/** Private constructor */
- private HTMLTextExtractor() {
- }
+ private HTMLTextExtractor() {}
/**
* Get the HTMLTextExtractor singleton.
@@ -79,8 +89,7 @@ public String act(String html) {
String result;
Element element;
- if (html == null)
- return "";
+ if (html == null) return "";
element = Jsoup.parse(html);
@@ -102,8 +111,7 @@ public String act(String html) {
public String htmlStringtoString(String in) {
String result;
- if (in == null)
- result = "";
+ if (in == null) result = "";
else {
// unescape all HTML entities, multiple times if needed
result = in;
@@ -111,59 +119,52 @@ public String htmlStringtoString(String in) {
in = result;
result = Parser.unescapeEntities(in, true);
} while (!result.equals(in));
-
}
return result;
}
-
}
// the formatting rules, implemented in a breadth-first DOM traverse
final class FormattingVisitor implements NodeVisitor {
+
private static final int maxWidth = 80;
private int width = 0;
private StringBuilder accum = new StringBuilder(); // holds the
+
// accumulated text
// hit when the node is first seen
public void head(Node node, int depth) {
String name = node.nodeName();
- if (node instanceof TextNode)
- append(((TextNode) node).text()); // TextNodes carry all
- // user-readable text in the
- // DOM.
- else if (name.equals("li"))
- append("\n * ");
- else if (name.equals("dt"))
- append(" ");
- else if (StringUtil.in(name, "p", "h1", "h2", "h3", "h4", "h5", "tr"))
- append("\n");
+ if (node instanceof TextNode) append(((TextNode) node).text()); // TextNodes carry all
+ // user-readable text in the
+ // DOM.
+ else if (name.equals("li")) append("\n * ");
+ else if (name.equals("dt")) append(" ");
+ else if (StringUtil.in(name, "p", "h1", "h2", "h3", "h4", "h5", "tr")) append("\n");
}
// hit when all of the node's children (if any) have been visited
public void tail(Node node, int depth) {
String name = node.nodeName();
- if (StringUtil.in(name, "br", "dd", "dt", "p", "h1", "h2", "h3", "h4", "h5"))
- append("\n");
- else if (name.equals("a"))
- append(String.format("<%s>", node.absUrl("href")));
+ if (StringUtil.in(name, "br", "dd", "dt", "p", "h1", "h2", "h3", "h4", "h5")) append("\n");
+ else if (name.equals("a")) append(String.format("<%s>", node.absUrl("href")));
}
// appends text to the string builder with a simple word wrap method
private void append(String text) {
- if (text.startsWith("\n"))
- width = 0; // reset counter if starts with a newline. only from
+ if (text.startsWith("\n")) width = 0; // reset counter if starts with a newline. only from
// formats above, not in natural text
- if (text.equals(" ") && (accum.length() == 0 || StringUtil.in(accum.substring(accum.length() - 1), " ", "\n")))
- return; // don't accumulate long runs of empty spaces
+ if (
+ text.equals(" ") && (accum.length() == 0 || StringUtil.in(accum.substring(accum.length() - 1), " ", "\n"))
+ ) return; // don't accumulate long runs of empty spaces
if (text.length() + width > maxWidth) { // won't fit, needs to wrap
String words[] = text.split("\\s+");
for (int i = 0; i < words.length; i++) {
String word = words[i];
boolean last = i == words.length - 1;
- if (!last) // insert a space if not the last word
- word = word + " ";
+ if (!last) word = word + " "; // insert a space if not the last word
if (word.length() + width > maxWidth) { // wrap and reset
// counter
accum.append("\n").append(word);
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/formattools/TikaExtractor.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/formattools/TikaExtractor.java
index 5cd88a1c..888bb060 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/formattools/TikaExtractor.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/formattools/TikaExtractor.java
@@ -1,28 +1,39 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.formattools;
@@ -51,8 +62,7 @@ public TikaExtractor() {
logger = Logger.getGlobal();
memLevel = logger.getLevel();
- if (memLevel != Level.FINEST)
- logger.setLevel(Level.OFF);
+ if (memLevel != Level.FINEST) logger.setLevel(Level.OFF);
tika = new Tika();
logger.setLevel(memLevel);
}
@@ -63,8 +73,7 @@ public TikaExtractor() {
* @return single instance of FileTextExtractor
*/
public static TikaExtractor getInstance() {
- if (INSTANCE==null)
- INSTANCE=new TikaExtractor();
+ if (INSTANCE == null) INSTANCE = new TikaExtractor();
return INSTANCE;
}
@@ -84,11 +93,9 @@ public String extractTextFromBinary(byte[] rawContent) throws MailExtractLibExce
logger = Logger.getGlobal();
memLevel = logger.getLevel();
- if (memLevel != Level.FINEST)
- logger.setLevel(Level.OFF);
+ if (memLevel != Level.FINEST) logger.setLevel(Level.OFF);
try {
- if (rawContent.length > 0)
- s = tika.parseToString(new ByteArrayInputStream(rawContent));
+ if (rawContent.length > 0) s = tika.parseToString(new ByteArrayInputStream(rawContent));
} catch (Throwable e) {
throw new MailExtractLibException("mailextractlib.formattools: can't extract text content", e);
} finally {
@@ -115,8 +122,7 @@ public String getMimeType(byte[] rawContent) throws MailExtractLibException {
if (rawContent.length > 0) {
logger = Logger.getGlobal();
memLevel = logger.getLevel();
- if (memLevel != Level.FINEST)
- logger.setLevel(Level.OFF);
+ if (memLevel != Level.FINEST) logger.setLevel(Level.OFF);
try {
result = tika.detect(rawContent);
} catch (Exception e) {
@@ -127,5 +133,4 @@ public String getMimeType(byte[] rawContent) throws MailExtractLibException {
}
return result;
}
-
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/formattools/package-info.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/formattools/package-info.java
index bd6ba8da..c898d04f 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/formattools/package-info.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/formattools/package-info.java
@@ -1,7 +1,44 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.
+ */
/**
* Provides all classes and methods to deal with identification and format
* conversion tools.
*
* Use Tika library (https://tika.apache.org/)
*/
-package fr.gouv.vitam.tools.mailextractlib.formattools;
\ No newline at end of file
+package fr.gouv.vitam.tools.mailextractlib.formattools;
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/formattools/rtf/CharsetUtils.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/formattools/rtf/CharsetUtils.java
index 12851b74..94f325e7 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/formattools/rtf/CharsetUtils.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/formattools/rtf/CharsetUtils.java
@@ -1,36 +1,40 @@
/**
- * 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.
- *
- * This is copied from Tika 1.17
- * under http://www.apache.org/licenses/LICENSE-2.0
- *
- * Conform with MSDN directives to de-encapsulate HTML from RTF
- * https://msdn.microsoft.com/en-us/library/ee159984(v=exchg.80).aspx
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.
*/
-
/**
* This is copied from Tika 1.17
* under http://www.apache.org/licenses/LICENSE-2.0
@@ -57,20 +61,15 @@
*/
public class CharsetUtils {
- private static final Pattern CHARSET_NAME_PATTERN =
- Pattern.compile("[ \\\"]*([^ >,;\\\"]+).*");
+ private static final Pattern CHARSET_NAME_PATTERN = Pattern.compile("[ \\\"]*([^ >,;\\\"]+).*");
- private static final Pattern ISO_NAME_PATTERN =
- Pattern.compile(".*8859-(\\d+)");
+ private static final Pattern ISO_NAME_PATTERN = Pattern.compile(".*8859-(\\d+)");
- private static final Pattern CP_NAME_PATTERN =
- Pattern.compile("cp-(\\d+)");
+ private static final Pattern CP_NAME_PATTERN = Pattern.compile("cp-(\\d+)");
- private static final Pattern WIN_NAME_PATTERN =
- Pattern.compile("win-?(\\d+)");
+ private static final Pattern WIN_NAME_PATTERN = Pattern.compile("win-?(\\d+)");
- private static final Map
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.formattools.rtf;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractLibException;
@@ -386,13 +396,11 @@ private void processGroupStart() throws IOException {
// Pop current GroupState
private void processGroupEnd() {
// delete any output till in header
- if (globalInHeader)
- resultBuilder.setLength(0);
+ if (globalInHeader) resultBuilder.setLength(0);
globalAnsiSkip = 0;
// Restore group state:
globalGroupState = globalGroupState.getPreviousGroupState();
-
}
// Parse a rtf control token (\...)
@@ -436,40 +444,36 @@ private void parseHexChar() throws IOException {
// escape:
globalAnsiSkip--;
} else {
- if (!globalGroupState.ignore)
- // Unescape:
- addOutputByte(16 * hexValue(hex1) + hexValue(hex2));
+ if (!globalGroupState.ignore) addOutputByte(16 * hexValue(hex1) + hexValue(hex2)); // Unescape:
}
}
// Parse a rtf control word (\... not escaped character)
private void parseControlWord(int firstChar) throws IOException {
StringBuilder controlWord = new StringBuilder();
- ;
-
controlWord.append((char) firstChar);
+
int b = pbis.read();
while (isAlpha(b)) {
controlWord.append((char) b);
b = pbis.read();
}
-
boolean hasParam = false;
+
boolean negParam = false;
if (b == '-') {
negParam = true;
hasParam = true;
b = pbis.read();
}
-
int param = 0;
+
while (isDigit(b)) {
param *= 10;
param += (b - '0');
hasParam = true;
b = pbis.read();
}
-
// space is consumed as part of the
// control word, but is not added to the control word
if (b != ' ') {
@@ -481,9 +485,7 @@ private void parseControlWord(int firstChar) throws IOException {
param = -param;
}
processControlWord(controlWord.toString(), param);
- } else
- processNoParamControlWord(controlWord.toString());
-
+ } else processNoParamControlWord(controlWord.toString());
}
// Handle non-parameter control word
@@ -507,8 +509,8 @@ private void processNoParamControlWord(String controlWord) {
case "sect":
case "sectd":
case "plain":
- //case "ltrch":
- //case "rtlch":
+ //case "ltrch":
+ //case "rtlch":
globalInHeader = false;
default:
// ignore others colortbl stylesheet fonttbl listtable
@@ -579,10 +581,8 @@ private void processControlWord(String controlWord, int param) {
break;
case "htmlrtf":
pushText();
- if (param == 0)
- globalGroupState.setInHtmlrtf(false);
- else
- globalGroupState.setInHtmlrtf(true);
+ if (param == 0) globalGroupState.setInHtmlrtf(false);
+ else globalGroupState.setInHtmlrtf(true);
break;
case "f":
// Change current font
@@ -720,7 +720,6 @@ private void addOutputChar(char ch) {
// else appends the characters to the pendingBuffer
private void pushPendingBytes() {
if (pendingByteCount > 0 && !globalGroupState.ignore) {
-
final CharsetDecoder decoder = getDecoder();
pendingByteBuffer.limit(pendingByteCount);
assert pendingByteBuffer.position() == 0;
@@ -824,8 +823,7 @@ private boolean detectEncapsulatedHTMLorTEXTinRTF() {
try {
while (len < 100) {
inc = pbis.read(buf, len, 100 - len);
- if (inc == -1)
- return false;
+ if (inc == -1) return false;
len += inc;
}
test = new String(buf);
@@ -841,8 +839,7 @@ private boolean detectEncapsulatedHTMLorTEXTinRTF() {
if (test.indexOf("\\fromtext") >= 0) {
isText = true;
return true;
- } else
- return false;
+ } else return false;
}
// public functions
@@ -886,15 +883,14 @@ public String getDeEncapsulateHTMLFromRTF() throws MailExtractLibException {
if (m.find()) {
// add a meta tag to say it's UTF-8 just after
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.formattools.rtf;
import java.nio.charset.Charset;
@@ -131,5 +141,4 @@ public void setInHtmlrtf(boolean b) {
public RTFGroupState getPreviousGroupState() {
return previous;
}
-
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/formattools/rtf/package-info.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/formattools/rtf/package-info.java
index 90d92505..a2a3a6b7 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/formattools/rtf/package-info.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/formattools/rtf/package-info.java
@@ -1,7 +1,44 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.
+ */
/**
* Provides all classes and methods to de-encapsulate HTML and text from RTF.
*
* Conform with MSDN directives to de-encapsulate HTML from RTF
* https://msdn.microsoft.com/en-us/library/ee159984(v=exchg.80).aspx
*/
-package fr.gouv.vitam.tools.mailextractlib.formattools.rtf;
\ No newline at end of file
+package fr.gouv.vitam.tools.mailextractlib.formattools.rtf;
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/ArchiveUnit.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/ArchiveUnit.java
index 47108a72..769432f8 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/ArchiveUnit.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/ArchiveUnit.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.nodes;
import fr.gouv.vitam.tools.mailextractlib.core.StoreExtractor;
@@ -53,6 +63,7 @@
* All the files, if not pure binary, are UTF-8 encoded, as the file names.
*/
public class ArchiveUnit {
+
private StoreExtractor storeExtractor;
private String rootPath;
private String name;
@@ -62,6 +73,7 @@ public class ArchiveUnit {
// Utility class containing one Object of the ObjectGroup
private class ArchiveObject {
+
/**
* The Filename.
*/
@@ -124,12 +136,10 @@ public ArchiveUnit(StoreExtractor storeExtractor, String rootPath, String name)
*/
public ArchiveUnit(StoreExtractor storeExtractor, ArchiveUnit father, String unitType, String name) {
this.storeExtractor = storeExtractor;
- if (unitType == null)
- this.name = name;
+ if (unitType == null) this.name = name;
else {
this.name = this.normalizeUniqUnitname(unitType, name);
- if (unitType.equals("Message"))
- forceMessageUnit = true;
+ if (unitType.equals("Message")) forceMessageUnit = true;
}
this.rootPath = father.getFullName();
}
@@ -181,13 +191,10 @@ public void setObjectUnit(boolean b) {
* @return Name of Archive Unit in directory name
*/
public String getName() {
- if (!forceMessageUnit && (objects.isEmpty()))
- return name;
+ if (!forceMessageUnit && (objects.isEmpty())) return name;
else {
- if (storeExtractor.getOptions().model == StoreExtractorOptions.MODEL_V1)
- return "__" + name + "__";
- else
- return name;
+ if (storeExtractor.getOptions().model == StoreExtractorOptions.MODEL_V1) return "__" + name + "__";
+ else return name;
}
}
@@ -204,11 +211,19 @@ public String getName() {
* @throws InterruptedException the interrupted exception
*/
public void addMetadata(String key, String value, boolean mandatory) throws InterruptedException {
- if (value != null && !value.isEmpty())
- contentmetadatalist.addMetadataXMLNode(new MetadataXMLNode(key, value));
- else if (mandatory)
- doProgressLog(getProgressLogger(), MailExtractProgressLogger.MESSAGE_DETAILS, "mailextractlib: mandatory metadata '" + key + "' empty in unit '" + name + "' in folder '"
- + rootPath + "'", null);
+ if (value != null && !value.isEmpty()) contentmetadatalist.addMetadataXMLNode(new MetadataXMLNode(key, value));
+ else if (mandatory) doProgressLog(
+ getProgressLogger(),
+ MailExtractProgressLogger.MESSAGE_DETAILS,
+ "mailextractlib: mandatory metadata '" +
+ key +
+ "' empty in unit '" +
+ name +
+ "' in folder '" +
+ rootPath +
+ "'",
+ null
+ );
}
/**
@@ -228,9 +243,18 @@ else if (mandatory)
public void addLongMetadata(String key, String value, boolean mandatory) throws InterruptedException {
if (value != null && !value.isEmpty()) {
contentmetadatalist.addMetadataXMLNode(new MetadataXMLSplittedNode(key, value));
- } else if (mandatory)
- doProgressLog(getProgressLogger(),MailExtractProgressLogger.MESSAGE_DETAILS, "mailextractlib: mandatory metadata '" + key + "' empty in unit '" + name + "' in folder '"
- + rootPath + "'", null);
+ } else if (mandatory) doProgressLog(
+ getProgressLogger(),
+ MailExtractProgressLogger.MESSAGE_DETAILS,
+ "mailextractlib: mandatory metadata '" +
+ key +
+ "' empty in unit '" +
+ name +
+ "' in folder '" +
+ rootPath +
+ "'",
+ null
+ );
}
/**
@@ -247,12 +271,24 @@ public void addLongMetadata(String key, String value, boolean mandatory) throws
* @param mandatory Mandatory flag
* @throws InterruptedException the interrupted exception
*/
- public void addMetadata(String key, String attributename, String attributevalue, String value, boolean mandatory) throws InterruptedException {
- if (value != null && !value.isEmpty())
- contentmetadatalist.addMetadataXMLNode(new MetadataXMLNode(key, attributename, attributevalue, value));
+ public void addMetadata(String key, String attributename, String attributevalue, String value, boolean mandatory)
+ throws InterruptedException {
+ if (value != null && !value.isEmpty()) contentmetadatalist.addMetadataXMLNode(
+ new MetadataXMLNode(key, attributename, attributevalue, value)
+ );
else if (mandatory) {
- doProgressLog(getProgressLogger(),MailExtractProgressLogger.MESSAGE_DETAILS, "mailextractlib: mandatory metadata '" + key + "' is not defined in unit '" + name
- + "' in folder '" + rootPath + "'", null);
+ doProgressLog(
+ getProgressLogger(),
+ MailExtractProgressLogger.MESSAGE_DETAILS,
+ "mailextractlib: mandatory metadata '" +
+ key +
+ "' is not defined in unit '" +
+ name +
+ "' in folder '" +
+ rootPath +
+ "'",
+ null
+ );
}
}
@@ -265,10 +301,10 @@ else if (mandatory) {
* @param defaultValue Default metadata value
*/
public void addDefaultValuedMetadata(String key, String value, String defaultValue) {
- if ((value != null) && !value.isEmpty())
- contentmetadatalist.addMetadataXMLNode(new MetadataXMLNode(key, value));
- else
- contentmetadatalist.addMetadataXMLNode(new MetadataXMLNode(key, defaultValue));
+ if ((value != null) && !value.isEmpty()) contentmetadatalist.addMetadataXMLNode(
+ new MetadataXMLNode(key, value)
+ );
+ else contentmetadatalist.addMetadataXMLNode(new MetadataXMLNode(key, defaultValue));
}
/**
@@ -285,14 +321,24 @@ public void addDefaultValuedMetadata(String key, String value, String defaultVal
* @param mandatory Mandatory flag
* @throws InterruptedException the interrupted exception
*/
- public void addSameMetadataList(String key, List
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.nodes;
import jakarta.mail.internet.MimeUtility;
+
import java.io.UnsupportedEncodingException;
/**
@@ -66,26 +77,21 @@ public MetadataPerson(String s) {
if (((beg = s.lastIndexOf('<')) != -1) && ((end = s.lastIndexOf('>')) != -1) && (beg < end)) {
identifier = s.substring(beg + 1, end).trim();
- if (identifier.isEmpty())
- identifier = "[Vide]";
- } else
- identifier = s.trim();
+ if (identifier.isEmpty()) identifier = "[Vide]";
+ } else identifier = s.trim();
- if ((end = identifier.indexOf('@')) > 1)
- name = identifier.substring(0, end);
- else
- name = "[Vide]";
+ if ((end = identifier.indexOf('@')) > 1) name = identifier.substring(0, end);
+ else name = "[Vide]";
+
+ if (name.startsWith("=?")) try {
+ name = MimeUtility.decodeText(name);
+ } catch (UnsupportedEncodingException e) {
+ // Don't care
+ }
- if (name.startsWith("=?"))
- try {
- name = MimeUtility.decodeText(name);
- } catch (UnsupportedEncodingException e) {
- // Don't care
- }
+ if ((name.charAt(0) == '"') && (name.charAt(name.length() - 1) == '"') && name.length() > 1) name =
+ name.substring(1, name.length() - 1);
- if ((name.charAt(0) == '"') && (name.charAt(name.length() - 1) == '"') && name.length() > 1)
- name = name.substring(1, name.length() - 1);
-
fullName = name.replaceAll("\\.", " ");
}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXML.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXML.java
index 567f8b63..4bcd113f 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXML.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXML.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.nodes;
/**
@@ -41,7 +51,7 @@ public abstract class MetadataXML {
*
* @return true, if is empty
*/
- abstract public boolean isEmpty();
+ public abstract boolean isEmpty();
/**
* Write the metadata in XML with pretty print format.
@@ -50,7 +60,7 @@ public abstract class MetadataXML {
* Depth used for tabulation
* @return the string
*/
- abstract protected String writeXML(int depth);
+ protected abstract String writeXML(int depth);
/**
* Generate a depth long repetition of tabs.
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXMLList.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXMLList.java
index a9816503..47b834fa 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXMLList.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXMLList.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.nodes;
import java.util.ArrayList;
@@ -85,8 +95,6 @@ protected String writeXML(int depth) {
* the metadata xml node
*/
public void addMetadataXMLNode(MetadataXMLNode metadataxmlnode) {
- if ((metadataxmlnode != null) && !metadataxmlnode.isEmpty())
- nodelist.add(metadataxmlnode);
+ if ((metadataxmlnode != null) && !metadataxmlnode.isEmpty()) nodelist.add(metadataxmlnode);
}
-
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXMLNode.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXMLNode.java
index ffde282e..253d098b 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXMLNode.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXMLNode.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.nodes;
/**
@@ -58,15 +68,10 @@ protected String writeXML(int depth) {
StringBuilder sb = new StringBuilder();
String tabs = depthTabs(depth);
- sb.append(tabs)
- .append('<').append(tag);
+ sb.append(tabs).append('<').append(tag);
if (attributename != null) {
- sb.append(' ')
- .append(attributename)
- .append("=\"")
- .append(attributevalue)
- .append('"');
+ sb.append(' ').append(attributename).append("=\"").append(attributevalue).append('"');
}
sb.append('>');
@@ -74,15 +79,10 @@ protected String writeXML(int depth) {
if (value instanceof MetadataXMLString) {
sb.append(value.writeXML(depth + 1));
} else {
- sb.append('\n')
- .append(value.writeXML(depth + 1))
- .append('\n')
- .append(tabs);
+ sb.append('\n').append(value.writeXML(depth + 1)).append('\n').append(tabs);
}
- sb.append("")
- .append(tag)
- .append('>');
+ sb.append("").append(tag).append('>');
return sb.toString();
}
@@ -186,5 +186,4 @@ public MetadataXMLNode(String tag, String attributename, String attributevalue,
public String writeXML() {
return writeXML(0);
}
-
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXMLSplittedNode.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXMLSplittedNode.java
index 0e9a8efc..b353bb99 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXMLSplittedNode.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXMLSplittedNode.java
@@ -1,33 +1,42 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.nodes;
-
import fr.gouv.vitam.tools.mailextractlib.utils.HtmlAndXmlEscape;
import java.util.regex.Pattern;
@@ -75,7 +84,7 @@ private static String normaliseXMLLongString(String value) {
// remove all forbidden and invisible characters
String normalized = FORBIDDEN_PATTERN.matcher(value).replaceAll("");
// unescape all HMTL characters
- normalized= HtmlAndXmlEscape.unescapeHtmlAndXMLEntities(normalized);
+ normalized = HtmlAndXmlEscape.unescapeHtmlAndXMLEntities(normalized);
// break HTML tags in metadata if any
normalized = normalized.replace("<", "< ");
// break left HTML escape after unescape
@@ -114,27 +123,17 @@ protected String writeXML(int depth) {
String subValue = normalisedValue.substring(chunkBeg, chunkEnd);
// Build the XML output for this chunk
- result.append(tabs)
- .append('<').append(tag);
+ result.append(tabs).append('<').append(tag);
if (attributename != null) {
- result.append(' ')
- .append(attributename)
- .append("=\"")
- .append(attributevalue)
- .append("\"");
+ result.append(' ').append(attributename).append("=\"").append(attributevalue).append("\"");
}
- result.append('>')
- .append(subValue)
- .append("")
- .append(tag)
- .append(">\n");
+ result.append('>').append(subValue).append("").append(tag).append(">\n");
// Advance to the next segment
chunkBeg = chunkEnd;
}
return result.toString();
-
}
/**
@@ -184,8 +183,7 @@ private static int findCutPosition(String s, int beg, int maxBytesLength) {
int lastSpace = -1;
int lastReturn = -1;
- if ((length - beg) * 3 < maxBytesLength)
- return s.length();
+ if ((length - beg) * 3 < maxBytesLength) return s.length();
while (i < length) {
char c = s.charAt(i);
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXMLString.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXMLString.java
index 75ce21f4..2b91a44f 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXMLString.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/MetadataXMLString.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.nodes;
import fr.gouv.vitam.tools.mailextractlib.utils.HtmlAndXmlEscape;
@@ -63,19 +73,17 @@ public boolean isEmpty() {
return (value == null) || value.isEmpty();
}
-
// Vitam XML value sanity check
private static final String TAG_START =
- "\\<\\w+((\\s+\\w+(\\s*\\=\\s*(?:\".*?\"|'.*?'|[^'\"\\>\\s]+))?)+\\s*|\\s*)\\>";
- private static final String TAG_END =
- "\\\\w+\\>";
+ "\\<\\w+((\\s+\\w+(\\s*\\=\\s*(?:\".*?\"|'.*?'|[^'\"\\>\\s]+))?)+\\s*|\\s*)\\>";
+ private static final String TAG_END = "\\\\w+\\>";
private static final String TAG_SELF_CLOSING =
- "\\<\\w+((\\s+\\w+(\\s*\\=\\s*(?:\".*?\"|'.*?'|[^'\"\\>\\s]+))?)+\\s*|\\s*)/\\>";
- private static final String HTML_ENTITY =
- "&[a-zA-Z][a-zA-Z0-9]+;";
+ "\\<\\w+((\\s+\\w+(\\s*\\=\\s*(?:\".*?\"|'.*?'|[^'\"\\>\\s]+))?)+\\s*|\\s*)/\\>";
+ private static final String HTML_ENTITY = "&[a-zA-Z][a-zA-Z0-9]+;";
public static final Pattern HTML_PATTERN = Pattern.compile(
- "(" + TAG_START + ".*" + TAG_END + ")|(" + TAG_SELF_CLOSING + ")|(" + HTML_ENTITY + ")",
- Pattern.DOTALL);
+ "(" + TAG_START + ".*" + TAG_END + ")|(" + TAG_SELF_CLOSING + ")|(" + HTML_ENTITY + ")",
+ Pattern.DOTALL
+ );
private static final Pattern FORBIDDEN_PATTERN = Pattern.compile("[\\p{C}&&[^\\r\\n\\t]]");
@@ -95,10 +103,10 @@ public static String normaliseXMLString(String value) {
// remove all forbidden and invisible characters
String normalized = FORBIDDEN_PATTERN.matcher(value).replaceAll("");
// unescape all HMTL characters
- normalized= HtmlAndXmlEscape.unescapeHtmlAndXMLEntities(normalized);
+ normalized = HtmlAndXmlEscape.unescapeHtmlAndXMLEntities(normalized);
// break XML tags in metadata if any, based on Vitam sanity check
Matcher m = HTML_PATTERN.matcher(normalized);
- if (m.find()) {
+ if (m.find()) {
StringBuffer sb = new StringBuffer();
do {
String match = m.group();
@@ -107,7 +115,7 @@ public static String normaliseXMLString(String value) {
m.appendReplacement(sb, Matcher.quoteReplacement(replacement));
} while (m.find());
m.appendTail(sb);
- normalized = sb.toString();
+ normalized = sb.toString();
}
// suppress and escape all non XML compliance
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/package-info.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/package-info.java
index 9dd50707..5b9dc08b 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/package-info.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/nodes/package-info.java
@@ -1,5 +1,42 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.
+ */
/**
* Provides all classes and method to create, manage and edit to disk the
* ArchiveUnits with their metadata. The metadata is in XML format on disk.
*/
-package fr.gouv.vitam.tools.mailextractlib.nodes;
\ No newline at end of file
+package fr.gouv.vitam.tools.mailextractlib.nodes;
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/JMEmbeddedStore.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/JMEmbeddedStore.java
index cb1f7e4a..b317344d 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/JMEmbeddedStore.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/JMEmbeddedStore.java
@@ -1,49 +1,58 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail;
/**
* Interface implemented on JavaMail extractor that can to extract embedded message (only eml).
*/
public interface JMEmbeddedStore {
-
/**
* Sets the object content.
*
* @param objectContent
* the new object content
*/
- abstract public void setObjectContent(Object objectContent);
+ public abstract void setObjectContent(Object objectContent);
/**
* Gets the object content.
*
* @return the object content
*/
- abstract public Object getObjectContent();
+ public abstract Object getObjectContent();
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/JMMimeMessage.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/JMMimeMessage.java
index 83d571de..165303a9 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/JMMimeMessage.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/JMMimeMessage.java
@@ -1,35 +1,46 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail;
import jakarta.mail.Folder;
import jakarta.mail.MessagingException;
import jakarta.mail.internet.MimeMessage;
+
import java.io.InputStream;
/**
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/JMStoreExtractor.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/JMStoreExtractor.java
index dad23acd..e80e3827 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/JMStoreExtractor.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/JMStoreExtractor.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail;
import fr.gouv.vitam.tools.mailextractlib.core.StoreAttachment;
@@ -37,8 +47,8 @@
import fr.gouv.vitam.tools.mailextractlib.store.javamail.thunderbird.ThunderbirdStore;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractLibException;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractProgressLogger;
-
import jakarta.mail.*;
+
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Properties;
@@ -50,6 +60,7 @@
* could also be used for POP3 and Gmail, via StoreExtractor (not tested).
*/
public class JMStoreExtractor extends StoreExtractor {
+
private Store store;
/**
@@ -58,14 +69,14 @@ public class JMStoreExtractor extends StoreExtractor {
* This is in default list.
*/
public static void subscribeStoreExtractor() {
- addExtractionRelation("message/rfc822", "fmt/278","eml", false, JMStoreExtractor.class);
- addExtractionRelation("message/rfc822", "fmt/950","eml", false, JMStoreExtractor.class);
- addExtractionRelation("application/mbox", "fmt/720","mbox", true, JMStoreExtractor.class);
- addExtractionRelation(null, null,"thunderbird", true, JMStoreExtractor.class);
- addExtractionRelation(null, null,"imap", true, JMStoreExtractor.class);
- addExtractionRelation(null, null,"imaps", true, JMStoreExtractor.class);
- addExtractionRelation(null, null,"gimap", true, JMStoreExtractor.class);
- addExtractionRelation(null, null,"pop3", true, JMStoreExtractor.class);
+ addExtractionRelation("message/rfc822", "fmt/278", "eml", false, JMStoreExtractor.class);
+ addExtractionRelation("message/rfc822", "fmt/950", "eml", false, JMStoreExtractor.class);
+ addExtractionRelation("application/mbox", "fmt/720", "mbox", true, JMStoreExtractor.class);
+ addExtractionRelation(null, null, "thunderbird", true, JMStoreExtractor.class);
+ addExtractionRelation(null, null, "imap", true, JMStoreExtractor.class);
+ addExtractionRelation(null, null, "imaps", true, JMStoreExtractor.class);
+ addExtractionRelation(null, null, "gimap", true, JMStoreExtractor.class);
+ addExtractionRelation(null, null, "pop3", true, JMStoreExtractor.class);
}
// Attachment to complete with decoded form
@@ -93,15 +104,19 @@ public static void subscribeStoreExtractor() {
* Any unrecoverable extraction exception (access trouble, major
* format problems...)
*/
- public JMStoreExtractor(String urlString, String folder, String destPathString, StoreExtractorOptions options,
- StoreExtractor rootStoreExtractor, MailExtractProgressLogger logger) throws MailExtractLibException {
+ public JMStoreExtractor(
+ String urlString,
+ String folder,
+ String destPathString,
+ StoreExtractorOptions options,
+ StoreExtractor rootStoreExtractor,
+ MailExtractProgressLogger logger
+ ) throws MailExtractLibException {
super(urlString, folder, destPathString, options, rootStoreExtractor, null, logger);
-
String url;
url = urlString;
- if (folder != null && !folder.isEmpty())
- url += "/" + folder;
+ if (folder != null && !folder.isEmpty()) url += "/" + folder;
try {
// Connect to the store
@@ -112,17 +127,35 @@ public JMStoreExtractor(String urlString, String folder, String destPathString,
Session session = Session.getDefaultInstance(props, null);
// add thunderbird provider
- session.addProvider(new Provider(Provider.Type.STORE, "thunderbird",
+ session.addProvider(
+ new Provider(
+ Provider.Type.STORE,
+ "thunderbird",
ThunderbirdStore.class.getName(),
- "fr.gouv.vitam", getClass().getPackage().getImplementationVersion()));
+ "fr.gouv.vitam",
+ getClass().getPackage().getImplementationVersion()
+ )
+ );
// add eml provider
- session.addProvider(new Provider(Provider.Type.STORE, "eml",
- EmlStore.class.getName(), "fr.gouv.vitam",
- getClass().getPackage().getImplementationVersion()));
+ session.addProvider(
+ new Provider(
+ Provider.Type.STORE,
+ "eml",
+ EmlStore.class.getName(),
+ "fr.gouv.vitam",
+ getClass().getPackage().getImplementationVersion()
+ )
+ );
// add mbox provider
- session.addProvider(new Provider(Provider.Type.STORE, "mbox",
- MboxStore.class.getName(), "fr.gouv.vitam",
- getClass().getPackage().getImplementationVersion()));
+ session.addProvider(
+ new Provider(
+ Provider.Type.STORE,
+ "mbox",
+ MboxStore.class.getName(),
+ "fr.gouv.vitam",
+ getClass().getPackage().getImplementationVersion()
+ )
+ );
URLName urlName = new URLName(url);
store = session.getStore(urlName);
@@ -135,18 +168,25 @@ public JMStoreExtractor(String urlString, String folder, String destPathString,
JMStoreFolder jMRootMailBoxFolder;
try {
- if ((folder == null) || folder.isEmpty())
-
- jMRootMailBoxFolder = JMStoreFolder.createRootFolder(this, store.getDefaultFolder(), rootNode);
- else
- jMRootMailBoxFolder = JMStoreFolder.createRootFolder(this, store.getFolder(folder), rootNode);
+ if ((folder == null) || folder.isEmpty()) jMRootMailBoxFolder = JMStoreFolder.createRootFolder(
+ this,
+ store.getDefaultFolder(),
+ rootNode
+ );
+ else jMRootMailBoxFolder = JMStoreFolder.createRootFolder(this, store.getFolder(folder), rootNode);
if (!jMRootMailBoxFolder.folder.exists()) {
- throw new MailExtractLibException("mailextractlib.javamail: can't find extraction root folder " + folder, null);
+ throw new MailExtractLibException(
+ "mailextractlib.javamail: can't find extraction root folder " + folder,
+ null
+ );
}
setRootFolder(jMRootMailBoxFolder);
} catch (MessagingException e) {
- throw new MailExtractLibException("mailextractlib.javamail: can't find extraction root folder " + folder, e);
+ throw new MailExtractLibException(
+ "mailextractlib.javamail: can't find extraction root folder " + folder,
+ e
+ );
}
}
@@ -161,9 +201,23 @@ public JMStoreExtractor(String urlString, String folder, String destPathString,
* @param logger logger used
* @throws MailExtractLibException Any unrecoverable extraction exception (access trouble, major format problems...)
*/
- public JMStoreExtractor(StoreAttachment attachment, ArchiveUnit rootNode, StoreExtractorOptions options,
- StoreExtractor rootStoreExtractor, StoreElement fatherElement, MailExtractProgressLogger logger) throws MailExtractLibException {
- super(attachment.getScheme() + "://localhost/", "", rootNode.getFullName(), options, rootStoreExtractor, fatherElement, logger);
+ public JMStoreExtractor(
+ StoreAttachment attachment,
+ ArchiveUnit rootNode,
+ StoreExtractorOptions options,
+ StoreExtractor rootStoreExtractor,
+ StoreElement fatherElement,
+ MailExtractProgressLogger logger
+ ) throws MailExtractLibException {
+ super(
+ attachment.getScheme() + "://localhost/",
+ "",
+ rootNode.getFullName(),
+ options,
+ rootStoreExtractor,
+ fatherElement,
+ logger
+ );
String url;
url = attachment.getScheme() + ":";
@@ -177,26 +231,39 @@ public JMStoreExtractor(StoreAttachment attachment, ArchiveUnit rootNode, StoreE
Session session = Session.getDefaultInstance(props, null);
// add eml provider
- session.addProvider(new Provider(Provider.Type.STORE, "eml",
- EmlStore.class.getName(), "fr.gouv.vitam",
- getClass().getPackage().getImplementationVersion()));
+ session.addProvider(
+ new Provider(
+ Provider.Type.STORE,
+ "eml",
+ EmlStore.class.getName(),
+ "fr.gouv.vitam",
+ getClass().getPackage().getImplementationVersion()
+ )
+ );
// add mbox provider
- session.addProvider(new Provider(Provider.Type.STORE, "mbox",
- MboxStore.class.getName(), "fr.gouv.vitam",
- getClass().getPackage().getImplementationVersion()));
+ session.addProvider(
+ new Provider(
+ Provider.Type.STORE,
+ "mbox",
+ MboxStore.class.getName(),
+ "fr.gouv.vitam",
+ getClass().getPackage().getImplementationVersion()
+ )
+ );
URLName urlName = new URLName(url);
store = session.getStore(urlName);
if (!(store instanceof JMEmbeddedStore)) {
throw new MailExtractLibException(
- "mailextractlib.javamail: can't extract embedded store for scheme [" + scheme + "]", null);
+ "mailextractlib.javamail: can't extract embedded store for scheme [" + scheme + "]",
+ null
+ );
}
JMEmbeddedStore ejs = (JMEmbeddedStore) store;
ejs.setObjectContent(attachment.getStoreContent());
store.connect();
} catch (MessagingException e) {
- throw new MailExtractLibException(
- "mailextractlib.javamail: can't get store for " + url, e);
+ throw new MailExtractLibException("mailextractlib.javamail: can't get store for " + url, e);
}
JMStoreFolder jMRootMailBoxFolder;
@@ -242,12 +309,11 @@ public StoreAttachment getAttachment() {
return attachment;
}
-
/* (non-Javadoc)
* @see fr.gouv.vitam.tools.mailextractlib.core.StoreExtractor#canExtractObjectsLists()
*/
@Override
public boolean canExtractObjectsLists() {
- return ! scheme.equals("eml");
+ return !scheme.equals("eml");
}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/JMStoreFolder.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/JMStoreFolder.java
index 3ac4a0ad..6b8824ca 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/JMStoreFolder.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/JMStoreFolder.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail;
import fr.gouv.vitam.tools.mailextractlib.core.StoreExtractor;
@@ -33,7 +43,6 @@
import fr.gouv.vitam.tools.mailextractlib.store.javamail.mbox.MboxFolder;
import fr.gouv.vitam.tools.mailextractlib.store.javamail.thunderbird.ThunderbirdFolder;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractLibException;
-
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractProgressLogger;
import jakarta.mail.Flags;
import jakarta.mail.Folder;
@@ -65,12 +74,11 @@ private JMStoreFolder(StoreExtractor storeExtractor, final Folder folder) {
private JMStoreFolder(StoreExtractor storeExtractor, final Folder folder, StoreFolder father) {
super(storeExtractor);
this.folder = folder;
- if (folder instanceof ThunderbirdFolder)
- ((ThunderbirdFolder) folder).setLogger(storeExtractor.getProgressLogger());
- else if (folder instanceof MboxFolder)
- ((MboxFolder) folder).setLogger(storeExtractor.getProgressLogger());
- if (father != null)
- finalizeStoreFolder(father);
+ if (folder instanceof ThunderbirdFolder) ((ThunderbirdFolder) folder).setLogger(
+ storeExtractor.getProgressLogger()
+ );
+ else if (folder instanceof MboxFolder) ((MboxFolder) folder).setLogger(storeExtractor.getProgressLogger());
+ if (father != null) finalizeStoreFolder(father);
}
/**
@@ -81,8 +89,11 @@ else if (folder instanceof MboxFolder)
* @param rootArchiveUnit Root ArchiveUnit
* @return the JM store folder
*/
- public static JMStoreFolder createRootFolder(StoreExtractor storeExtractor, final Folder folder,
- ArchiveUnit rootArchiveUnit) {
+ public static JMStoreFolder createRootFolder(
+ StoreExtractor storeExtractor,
+ final Folder folder,
+ ArchiveUnit rootArchiveUnit
+ ) {
JMStoreFolder result = new JMStoreFolder(storeExtractor, folder);
result.folderArchiveUnit = rootArchiveUnit;
@@ -127,19 +138,29 @@ protected void doExtractFolderElements(boolean writeFlag) throws MailExtractLibE
for (int i = 0; i < submittedTasks; i++) {
Future
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail;
+import fr.gouv.vitam.tools.mailextractlib.core.StoreAttachment;
import fr.gouv.vitam.tools.mailextractlib.core.StoreFolder;
import fr.gouv.vitam.tools.mailextractlib.core.StoreMessage;
-import fr.gouv.vitam.tools.mailextractlib.core.StoreAttachment;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractLibException;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractProgressLogger;
import fr.gouv.vitam.tools.mailextractlib.utils.RFC822Headers;
-
import jakarta.activation.CommandMap;
import jakarta.activation.DataHandler;
import jakarta.activation.MailcapCommandMap;
@@ -60,27 +69,40 @@
* could also be used for POP3 and Gmail, via StoreExtractor (not tested).
*/
public class JMStoreMessage extends StoreMessage {
-
/**
* Define Mime DataContentHandler to be able to extract signed and encrypted messages (but not decrypting them!)
*/
static {
final MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
- mc.addMailcap("application/pgp-signature;; x-java-content-handler=fr.gouv.vitam.tools.mailextractlib.store.javamail.handlers.pgp");
- mc.addMailcap("application/pkcs7-signature;; x-java-content-handler=fr.gouv.vitam.tools.mailextractlib.store.javamail.handlers.pkcs7_signature");
- mc.addMailcap("application/pkcs7-mime;; x-java-content-handler=fr.gouv.vitam.tools.mailextractlib.store.javamail.handlers.pkcs7_mime");
- mc.addMailcap("application/x-pkcs7-signature;; x-java-content-handler=fr.gouv.vitam.tools.mailextractlib.store.javamail.handlers.x_pkcs7_signature");
- mc.addMailcap("application/x-pkcs7-mime;; x-java-content-handler=fr.gouv.vitam.tools.mailextractlib.store.javamail.handlers.x_pkcs7_mime");
- mc.addMailcap("multipart/signed;; x-java-content-handler=fr.gouv.vitam.tools.mailextractlib.store.javamail.handlers.multipart_signed");
-
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- CommandMap.setDefaultCommandMap(mc);
-
- return null;
+ mc.addMailcap(
+ "application/pgp-signature;; x-java-content-handler=fr.gouv.vitam.tools.mailextractlib.store.javamail.handlers.pgp"
+ );
+ mc.addMailcap(
+ "application/pkcs7-signature;; x-java-content-handler=fr.gouv.vitam.tools.mailextractlib.store.javamail.handlers.pkcs7_signature"
+ );
+ mc.addMailcap(
+ "application/pkcs7-mime;; x-java-content-handler=fr.gouv.vitam.tools.mailextractlib.store.javamail.handlers.pkcs7_mime"
+ );
+ mc.addMailcap(
+ "application/x-pkcs7-signature;; x-java-content-handler=fr.gouv.vitam.tools.mailextractlib.store.javamail.handlers.x_pkcs7_signature"
+ );
+ mc.addMailcap(
+ "application/x-pkcs7-mime;; x-java-content-handler=fr.gouv.vitam.tools.mailextractlib.store.javamail.handlers.x_pkcs7_mime"
+ );
+ mc.addMailcap(
+ "multipart/signed;; x-java-content-handler=fr.gouv.vitam.tools.mailextractlib.store.javamail.handlers.multipart_signed"
+ );
+
+ AccessController.doPrivileged(
+ new PrivilegedAction() {
+ public Object run() {
+ CommandMap.setDefaultCommandMap(mc);
+
+ return null;
+ }
}
- });
+ );
}
/**
@@ -89,7 +111,7 @@ public Object run() {
protected MimeMessage message;
// format to parse dates in Receive header
- static private MailDateFormat mailDateFormat = new MailDateFormat();
+ private static MailDateFormat mailDateFormat = new MailDateFormat();
/**
* Instantiates a new JM mail box message.
@@ -115,8 +137,7 @@ public long getMessageSize() throws InterruptedException {
// geMessageSize of JavaMail is quite approximative...
long result;
- if (mimeContent != null)
- result = mimeContent.length;
+ if (mimeContent != null) result = mimeContent.length;
else {
mimeContent = getNativeMimeContent();
result = mimeContent.length;
@@ -127,23 +148,21 @@ public long getMessageSize() throws InterruptedException {
// utilities
// simple InternetAddress to metadata String
- static private String getElementalStringAddress(InternetAddress address) {
+ private static String getElementalStringAddress(InternetAddress address) {
String result = "";
String s;
if (address != null) {
s = address.getPersonal();
- if (s != null)
- result = s + " ";
+ if (s != null) result = s + " ";
s = address.getAddress();
- if (s != null)
- result += "<" + s + ">";
+ if (s != null) result += "<" + s + ">";
}
return result;
}
// any (simple or group) InternetAddress to metadata String
- static private String getStringAddress(InternetAddress address) {
+ private static String getStringAddress(InternetAddress address) {
String result = "";
if (address != null) {
@@ -154,8 +173,7 @@ static private String getStringAddress(InternetAddress address) {
InternetAddress[] group = address.getGroup(false);
result += ":";
for (int k = 0; k < group.length; k++) {
- if (k > 0)
- result += ",";
+ if (k > 0) result += ",";
result += getElementalStringAddress(group[k]);
}
} catch (AddressException e) {
@@ -211,10 +229,16 @@ protected void analyzeSubject() throws InterruptedException {
try {
result = message.getSubject();
- if ((result != null) && (result.contains("=?")))
- result = decodeRfc2047Flexible(message.getHeader("Subject", (String) null));
+ if ((result != null) && (result.contains("=?"))) result = decodeRfc2047Flexible(
+ message.getHeader("Subject", (String) null)
+ );
} catch (MessagingException e) {
- doProgressLog(getProgressLogger(), MailExtractProgressLogger.MESSAGE_DETAILS, "mailextractlib.javamail: can't get message subject", e);
+ doProgressLog(
+ getProgressLogger(),
+ MailExtractProgressLogger.MESSAGE_DETAILS,
+ "mailextractlib.javamail: can't get message subject",
+ e
+ );
}
subject = result;
}
@@ -252,10 +276,8 @@ protected void analyzeFrom() throws InterruptedException {
if (aList.size() > 1) {
result = String.join(", ", aList);
logMessageWarning("mailextractlib.javamail: multiple From addresses [" + result + "]", null);
- } else
- result = aList.get(0);
- if ((result != null) && (result.contains("=?")))
- result = decodeRfc2047Flexible(result);
+ } else result = aList.get(0);
+ if ((result != null) && (result.contains("=?"))) result = decodeRfc2047Flexible(result);
}
from = result;
}
@@ -269,7 +291,7 @@ private List
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail;
@@ -38,6 +49,7 @@
* but considering that LF alone in content are CRLF. This is especially to correct encoding in TNEF.
*/
public class LFFixingQPDecoderStream extends FilterInputStream {
+
/**
* The back buffer.
*/
@@ -140,8 +152,7 @@ public int read(byte[] buf, int off, int len) throws IOException {
public long skip(long n) throws IOException {
long skipped;
- for (skipped = 0L; n-- > 0L && this.read() >= 0; ++skipped) {
- }
+ for (skipped = 0L; n-- > 0L && this.read() >= 0; ++skipped) {}
return skipped;
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/charsets/OtherMimeCharsetProvider.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/charsets/OtherMimeCharsetProvider.java
index 24b49a83..0cfd464c 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/charsets/OtherMimeCharsetProvider.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/charsets/OtherMimeCharsetProvider.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.charsets;
import fr.gouv.vitam.tools.mailextractlib.store.javamail.charsets.jutf7.ModifiedUTF7Charset;
@@ -51,16 +61,25 @@ public class OtherMimeCharsetProvider extends CharsetProvider {
* For example, the MIME codes for the existing Java charsets are registered with alternate canonical names.
*
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.charsets;
import java.nio.charset.Charset;
@@ -88,4 +98,4 @@ public CharsetDecoder newDecoder() {
public CharsetEncoder newEncoder() {
return delegate.newEncoder();
}
-}
\ No newline at end of file
+}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/charsets/jutf7/Base64Util.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/charsets/jutf7/Base64Util.java
index 9c7773c3..855bdcff 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/charsets/jutf7/Base64Util.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/charsets/jutf7/Base64Util.java
@@ -1,106 +1,118 @@
-/* ====================================================================
- * Copyright (c) 2006 J.T. Beetstra
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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".
*
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
+ * 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.
*
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
+ * 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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * ====================================================================
+ * 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.vitam.tools.mailextractlib.store.javamail.charsets.jutf7;
import java.util.Arrays;
/**
- * Represent a base 64 mapping. The 64 characters used in the encoding can be specified,
+ * Represent a base 64 mapping. The 64 characters used in the encoding can be specified,
* since modified-UTF-7 uses other characters than UTF-7 (',' instead of '/'). The exact type of the arguments and result values is adapted to the needs of the
- * encoder and decoder, as opposed to following a strict interpretation of base 64. Base 64, as specified in RFC 2045, is an encoding used to encode bytes as characters.
- * In (modified-)UTF-7 however, it is used to encode characters as bytes, using some
+ *
+ * The exact type of the arguments and result values is adapted to the needs of the
+ * encoder and decoder, as opposed to following a strict interpretation of base 64. Base 64, as specified in RFC 2045, is an encoding used to encode bytes as characters.
+ * In (modified-)UTF-7 however, it is used to encode characters as bytes, using some
* intermediate steps: The character set specified in RFC 3501 to use for IMAP4rev1 mailbox name encoding. The character set specified in RFC 2152. Two variants are supported using the encodeOptional
* constructor flag Abstract base class for UTF-7 style encoding and decoding. Besides the name and aliases, two additional parameters are required. First the
- * base 64 alphabet used; in modified UTF-7 a slightly different alphabet is used.
- * Additionally, it should be specified if encoders and decoders should be strict
- * about the interpretation of malformed encoded sequences. This is used since
- * modified UTF-7 specifically disallows some constructs which are allowed (or not
- * specifically disallowed) in UTF-7 (RFC 2152). Besides the name and aliases, two additional parameters are required. First the
+ * base 64 alphabet used; in modified UTF-7 a slightly different alphabet is used.
+ * Additionally, it should be specified if encoders and decoders should be strict
+ * about the interpretation of malformed encoded sequences. This is used since
+ * modified UTF-7 specifically disallows some constructs which are allowed (or not
+ * specifically disallowed) in UTF-7 (RFC 2152). The CharsetDecoder used to decode both variants of the UTF-7 charset and the
+ * The CharsetDecoder used to decode both variants of the UTF-7 charset and the
* modified-UTF-7 charset. Decodes a byte in base 64 mode. Will directly write a character to the output
- * buffer if completed. Decodes a byte in base 64 mode. Will directly write a character to the output
+ * buffer if completed. Resets the input buffer position to just before the last byte read, and returns
- * a result indicating to skip the last byte. Resets the input buffer position to just before the last byte read, and returns
+ * a result indicating to skip the last byte. Updates internal state to reflect the decoder is no longer in base 64
- * mode Updates internal state to reflect the decoder is no longer in base 64
+ * mode The CharsetEncoder used to encode both variants of the UTF-7 charset and the
+ * The CharsetEncoder used to encode both variants of the UTF-7 charset and the
* modified-UTF-7 charset. Please note this class does not behave strictly according to the specification in
- * Sun Java VMs before 1.6. This is done to get around a bug in the implementation
+ *
+ * Please note this class does not behave strictly according to the specification in
+ * Sun Java VMs before 1.6. This is done to get around a bug in the implementation
* of {@link CharsetEncoder#encode(CharBuffer)}. Unfortunately, that method
* cannot be overridden. Note that this method might return Note that this method might return Note that this method might return However, String.getBytes() fails if CoderResult.OVERFLOW is returned, since
- * this assumes it always allocates sufficient bytes (maxBytesPerChar * nr_of_chars).
- * Thus, as an extra check, the size of the input buffer is compared against the size
- * of the output buffer.
- * A static variable is used to indicate if a broken java version is used. It is not possible to directly write the last few bytes, since more bytes
- * might be waiting to be encoded then those available in the input buffer. Note that this method might return However, String.getBytes() fails if CoderResult.OVERFLOW is returned, since
+ * this assumes it always allocates sufficient bytes (maxBytesPerChar * nr_of_chars).
+ * Thus, as an extra check, the size of the input buffer is compared against the size
+ * of the output buffer.
+ * A static variable is used to indicate if a broken java version is used. It is not possible to directly write the last few bytes, since more bytes
+ * might be waiting to be encoded then those available in the input buffer. Writes the bytes necessary to leave base 64 mode. This might include an unshift
- * character. Writes the bytes necessary to leave base 64 mode. This might include an unshift
+ * character. Writes the bytes necessary to encode a character in base 64 mode. All bytes
- * which are fully determined will be written. The fields Writes the bytes necessary to encode a character in base 64 mode. All bytes
+ * which are fully determined will be written. The fields
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.eml;
import fr.gouv.vitam.tools.mailextractlib.store.javamail.JMMimeMessage;
-
import jakarta.mail.*;
import jakarta.mail.util.SharedByteArrayInputStream;
import jakarta.mail.util.SharedFileInputStream;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -173,10 +183,8 @@ public boolean hasNewMessages() {
*/
@Override
public Folder getFolder(String name) throws MessagingException {
- if ((name == null) || (name.isEmpty()))
- return new EmlFolder(emlstore);
- else
- throw new MethodNotSupportedException("eml: no folder supported");
+ if ((name == null) || (name.isEmpty())) return new EmlFolder(emlstore);
+ else throw new MethodNotSupportedException("eml: no folder supported");
}
/*
@@ -220,8 +228,7 @@ public boolean isOpen() {
*/
@Override
public void open(int mode) throws MessagingException {
- if (opened)
- throw new IllegalStateException("eml: simulated folder is already open");
+ if (opened) throw new IllegalStateException("eml: simulated folder is already open");
this.mode = mode;
switch (mode) {
@@ -238,7 +245,6 @@ public void open(int mode) throws MessagingException {
} else {
// create input stream from file
try {
-
emlInputStream = new SharedFileInputStream(new File(emlstore.getContainer()));
} catch (IOException e) {
throw new MessagingException("eml: open failure, can't read: " + emlstore.getContainer());
@@ -254,8 +260,7 @@ public void open(int mode) throws MessagingException {
*/
@Override
public void close(boolean expunge) throws MessagingException {
- if (!opened)
- throw new IllegalStateException("eml: simulated folder is not open");
+ if (!opened) throw new IllegalStateException("eml: simulated folder is not open");
opened = false;
try {
emlInputStream.close();
@@ -281,8 +286,7 @@ public int getMessageCount() throws MessagingException {
*/
@Override
public Message getMessage(int msgno) throws MessagingException {
- if (msgno != 1)
- throw new IndexOutOfBoundsException("Eml: only message 1, no message number " + msgno);
+ if (msgno != 1) throw new IndexOutOfBoundsException("Eml: only message 1, no message number " + msgno);
Message m;
m = new JMMimeMessage(this, emlInputStream, msgno);
@@ -315,7 +319,14 @@ public Message[] expunge() throws MessagingException {
public URLName getURLName() {
URLName storeURL = getStore().getURLName();
- return new URLName(storeURL.getProtocol(), storeURL.getHost(), storeURL.getPort(), emlstore.getContainer(),
- storeURL.getUsername(), null /* no password */);
+ return new URLName(
+ storeURL.getProtocol(),
+ storeURL.getHost(),
+ storeURL.getPort(),
+ emlstore.getContainer(),
+ storeURL.getUsername(),
+ null
+ /* no password */
+ );
}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/eml/EmlStore.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/eml/EmlStore.java
index be96a951..c42c9106 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/eml/EmlStore.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/eml/EmlStore.java
@@ -1,35 +1,45 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.eml;
import fr.gouv.vitam.tools.mailextractlib.store.javamail.JMEmbeddedStore;
-
import jakarta.mail.*;
+
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
@@ -93,12 +103,11 @@ protected boolean protocolConnect(String host, int port, String user, String pas
// verify only if not embedded
if (objectContent == null) {
// verify params significance in ThunderMBox context
- if (!host.equals("localhost"))
- throw new MessagingException("eml: only support localhost");
- if (!((passwd == null) || (passwd.isEmpty())))
- throw new MessagingException("eml: does not allow passwords");
- if (port != -1)
- throw new MessagingException("eml: does not allow port selection");
+ if (!host.equals("localhost")) throw new MessagingException("eml: only support localhost");
+ if (!((passwd == null) || (passwd.isEmpty()))) throw new MessagingException(
+ "eml: does not allow passwords"
+ );
+ if (port != -1) throw new MessagingException("eml: does not allow port selection");
// verify declared file for eml availability
try {
@@ -131,10 +140,8 @@ public Folder getDefaultFolder() throws MessagingException {
*/
@Override
public Folder getFolder(String name) throws MessagingException {
- if ((name == null) || (name.isEmpty()))
- return new EmlFolder(this);
- else
- throw new MessagingException("eml: only one root simulated folder, no " + name + " folder");
+ if ((name == null) || (name.isEmpty())) return new EmlFolder(this);
+ else throw new MessagingException("eml: only one root simulated folder, no " + name + " folder");
}
/*
@@ -145,19 +152,15 @@ public Folder getFolder(String name) throws MessagingException {
@Override
public Folder getFolder(URLName url) throws MessagingException {
// verify that the root directory in store is respected
- if ((url.getFile() == null) || (url.getFile().isEmpty()))
- return new EmlFolder(this);
- else
- throw new MessagingException("eml: only one root simulated folder, no " + url.getFile() + " folder");
+ if ((url.getFile() == null) || (url.getFile().isEmpty())) return new EmlFolder(this);
+ else throw new MessagingException("eml: only one root simulated folder, no " + url.getFile() + " folder");
}
public void setObjectContent(Object objectContent) {
- if (objectContent instanceof byte[])
- this.objectContent = (byte[]) objectContent;
+ if (objectContent instanceof byte[]) this.objectContent = (byte[]) objectContent;
}
public Object getObjectContent() {
return objectContent;
}
-
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/eml/package-info.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/eml/package-info.java
index c9a40213..553376f3 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/eml/package-info.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/eml/package-info.java
@@ -1,7 +1,44 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.
+ */
/**
* Provides all classes to implement a rfc822 single message container for
* JavaMail library.
* Warning:Only for reading and without file locking or
* new messages management.
*/
-package fr.gouv.vitam.tools.mailextractlib.store.javamail.eml;
\ No newline at end of file
+package fr.gouv.vitam.tools.mailextractlib.store.javamail.eml;
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/HandlerUtil.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/HandlerUtil.java
index bf53b29b..a9993af0 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/HandlerUtil.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/HandlerUtil.java
@@ -1,78 +1,97 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.handlers;
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import jakarta.mail.MessagingException;
-import jakarta.mail.internet.MimeBodyPart;
import jakarta.activation.ActivationDataFlavor;
import jakarta.activation.DataContentHandler;
import jakarta.activation.DataSource;
+import jakarta.mail.MessagingException;
+import jakarta.mail.internet.MimeBodyPart;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
-class HandlerUtil
-{
+class HandlerUtil {
- static void writeFromInputStream(InputStream obj, OutputStream os)
- throws IOException
- {
- int b;
+ static void writeFromInputStream(InputStream obj, OutputStream os) throws IOException {
+ int b;
InputStream in = obj;
- if (!(in instanceof BufferedInputStream))
- {
+ if (!(in instanceof BufferedInputStream)) {
in = new BufferedInputStream(in);
}
- while ((b = in.read()) >= 0)
- {
+ while ((b = in.read()) >= 0) {
os.write(b);
}
in.close();
}
- static void writeFromBarrInputStream(Object obj, OutputStream os)
- throws IOException
- {
- if(obj instanceof byte[])
- {
- os.write((byte[])obj);
- }
- else if (obj instanceof InputStream)
- {
- writeFromInputStream((InputStream)obj, os);
- }
- else
- {
+ static void writeFromBarrInputStream(Object obj, OutputStream os) throws IOException {
+ if (obj instanceof byte[]) {
+ os.write((byte[]) obj);
+ } else if (obj instanceof InputStream) {
+ writeFromInputStream((InputStream) obj, os);
+ } else {
throw new IOException("unknown object in writeTo " + obj);
}
}
- static void writeFromMimeBodyPart(MimeBodyPart obj, OutputStream os)
- throws IOException
- {
- try
- {
+ static void writeFromMimeBodyPart(MimeBodyPart obj, OutputStream os) throws IOException {
+ try {
obj.writeTo(os);
- }
- catch (MessagingException ex)
- {
+ } catch (MessagingException ex) {
throw new IOException(ex.getMessage());
}
}
- static Object getTransferData(DataContentHandler handler, ActivationDataFlavor adf, ActivationDataFlavor df, DataSource ds)
- throws IOException
- {
- if (adf.equals(df))
- {
+ static Object getTransferData(
+ DataContentHandler handler,
+ ActivationDataFlavor adf,
+ ActivationDataFlavor df,
+ DataSource ds
+ ) throws IOException {
+ if (adf.equals(df)) {
return handler.getContent(ds);
- }
- else
- {
+ } else {
return null;
}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/SignatureContentHandler.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/SignatureContentHandler.java
index 0793d380..6e84ae05 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/SignatureContentHandler.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/SignatureContentHandler.java
@@ -1,59 +1,76 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.handlers;
-import java.io.IOException;
-import java.io.OutputStream;
-
import jakarta.activation.ActivationDataFlavor;
import jakarta.activation.DataContentHandler;
import jakarta.activation.DataSource;
import jakarta.mail.internet.MimeBodyPart;
-public class SignatureContentHandler
- implements DataContentHandler
-{
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class SignatureContentHandler implements DataContentHandler {
+
private final ActivationDataFlavor _adf;
- private final ActivationDataFlavor[] _dfs;
-
- SignatureContentHandler(
- ActivationDataFlavor adf,
- ActivationDataFlavor[] dfs)
- {
+ private final ActivationDataFlavor[] _dfs;
+
+ SignatureContentHandler(ActivationDataFlavor adf, ActivationDataFlavor[] dfs) {
_adf = adf;
_dfs = dfs;
}
- public Object getContent(
- DataSource ds)
- throws IOException
- {
+ public Object getContent(DataSource ds) throws IOException {
return ds.getInputStream();
}
-
- public Object getTransferData(
- ActivationDataFlavor df,
- DataSource ds)
- throws IOException
- {
+
+ public Object getTransferData(ActivationDataFlavor df, DataSource ds) throws IOException {
return HandlerUtil.getTransferData(this, _adf, df, ds);
}
-
- public ActivationDataFlavor[] getTransferDataFlavors()
- {
+
+ public ActivationDataFlavor[] getTransferDataFlavors() {
return _dfs;
}
-
- public void writeTo(
- Object obj,
- String mimeType,
- OutputStream os)
- throws IOException
- {
- if (obj instanceof MimeBodyPart)
- {
- HandlerUtil.writeFromMimeBodyPart((MimeBodyPart)obj, os);
- }
- else
- {
+
+ public void writeTo(Object obj, String mimeType, OutputStream os) throws IOException {
+ if (obj instanceof MimeBodyPart) {
+ HandlerUtil.writeFromMimeBodyPart((MimeBodyPart) obj, os);
+ } else {
HandlerUtil.writeFromBarrInputStream(obj, os);
}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/multipart_signed.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/multipart_signed.java
index 8a01ee87..9465250d 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/multipart_signed.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/multipart_signed.java
@@ -1,12 +1,42 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.handlers;
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.charset.StandardCharsets;
-import java.util.Enumeration;
-
import jakarta.activation.ActivationDataFlavor;
import jakarta.activation.DataContentHandler;
import jakarta.activation.DataSource;
@@ -16,53 +46,46 @@
import jakarta.mail.internet.MimeBodyPart;
import jakarta.mail.internet.MimeMultipart;
-public class multipart_signed
- implements DataContentHandler
-{
- private static final ActivationDataFlavor ADF = new ActivationDataFlavor(MimeMultipart.class, "multipart/signed", "Multipart Signed");
- private static final ActivationDataFlavor[] DFS = new ActivationDataFlavor[]{ADF};
-
- public Object getContent(DataSource ds)
- throws IOException
- {
- try
- {
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Enumeration;
+
+public class multipart_signed implements DataContentHandler {
+
+ private static final ActivationDataFlavor ADF = new ActivationDataFlavor(
+ MimeMultipart.class,
+ "multipart/signed",
+ "Multipart Signed"
+ );
+ private static final ActivationDataFlavor[] DFS = new ActivationDataFlavor[] { ADF };
+
+ public Object getContent(DataSource ds) throws IOException {
+ try {
return new MimeMultipart(ds);
- }
- catch (MessagingException ex)
- {
+ } catch (MessagingException ex) {
return null;
}
}
- public Object getTransferData(ActivationDataFlavor df, DataSource ds)
- throws IOException
- {
+ public Object getTransferData(ActivationDataFlavor df, DataSource ds) throws IOException {
return HandlerUtil.getTransferData(this, ADF, df, ds);
}
- public ActivationDataFlavor[] getTransferDataFlavors()
- {
+ public ActivationDataFlavor[] getTransferDataFlavors() {
return DFS;
}
- public void writeTo(Object obj, String _mimeType, OutputStream os)
- throws IOException
- {
-
- if (obj instanceof MimeMultipart)
- {
- try
- {
+ public void writeTo(Object obj, String _mimeType, OutputStream os) throws IOException {
+ if (obj instanceof MimeMultipart) {
+ try {
outputBodyPart(os, obj);
- }
- catch (MessagingException ex)
- {
+ } catch (MessagingException ex) {
throw new IOException(ex.getMessage());
}
- }
- else
- {
+ } else {
HandlerUtil.writeFromBarrInputStream(obj, os);
}
}
@@ -70,51 +93,42 @@ public void writeTo(Object obj, String _mimeType, OutputStream os)
/*
* Output the mulitpart as a collection of leaves to make sure preamble text is not included.
*/
- private void outputBodyPart(
- OutputStream out,
- Object bodyPart)
- throws MessagingException, IOException
- {
- if (bodyPart instanceof Multipart)
- {
- Multipart mp = (Multipart)bodyPart;
+ private void outputBodyPart(OutputStream out, Object bodyPart) throws MessagingException, IOException {
+ if (bodyPart instanceof Multipart) {
+ Multipart mp = (Multipart) bodyPart;
ContentType contentType = new ContentType(mp.getContentType());
String boundary = "--" + contentType.getParameter("boundary");
LineOutputStream lOut = new LineOutputStream(out);
- for (int i = 0; i < mp.getCount(); i++)
- {
+ for (int i = 0; i < mp.getCount(); i++) {
lOut.writeln(boundary);
outputBodyPart(out, mp.getBodyPart(i));
- lOut.writeln(); // CRLF terminator
+ lOut.writeln(); // CRLF terminator
}
lOut.writeln(boundary + "--");
return;
}
- MimeBodyPart mimePart = (MimeBodyPart)bodyPart;
+ MimeBodyPart mimePart = (MimeBodyPart) bodyPart;
- if (mimePart.isMimeType("multipart/*"))
- {
+ if (mimePart.isMimeType("multipart/*")) {
Object content = mimePart.getContent();
- if (content instanceof Multipart)
- {
- Multipart mp = (Multipart)content;
+ if (content instanceof Multipart) {
+ Multipart mp = (Multipart) content;
ContentType contentType = new ContentType(mp.getContentType());
String boundary = "--" + contentType.getParameter("boundary");
LineOutputStream lOut = new LineOutputStream(out);
Enumeration headers = mimePart.getAllHeaderLines();
- while (headers.hasMoreElements())
- {
- lOut.writeln((String)headers.nextElement());
+ while (headers.hasMoreElements()) {
+ lOut.writeln((String) headers.nextElement());
}
- lOut.writeln(); // CRLF separator
+ lOut.writeln(); // CRLF separator
outputPreamble(lOut, mimePart, boundary);
@@ -131,25 +145,19 @@ private void outputBodyPart(
* if we find internal preamble we include it by default.
*/
static void outputPreamble(LineOutputStream lOut, MimeBodyPart part, String boundary)
- throws MessagingException, IOException
- {
+ throws MessagingException, IOException {
InputStream in;
- try
- {
+ try {
in = part.getRawInputStream();
- }
- catch (MessagingException e)
- {
- return; // no underlying content, rely on default generation
+ } catch (MessagingException e) {
+ return; // no underlying content, rely on default generation
}
String line;
- while ((line = readLine(in)) != null)
- {
- if (line.equals(boundary))
- {
+ while ((line = readLine(in)) != null) {
+ if (line.equals(boundary)) {
break;
}
@@ -158,8 +166,7 @@ static void outputPreamble(LineOutputStream lOut, MimeBodyPart part, String boun
in.close();
- if (line == null)
- {
+ if (line == null) {
throw new MessagingException("no boundary found");
}
}
@@ -167,68 +174,50 @@ static void outputPreamble(LineOutputStream lOut, MimeBodyPart part, String boun
/*
* read a line of input stripping of the tailing \r\n
*/
- private static String readLine(InputStream in)
- throws IOException
- {
+ private static String readLine(InputStream in) throws IOException {
StringBuffer b = new StringBuffer();
int ch;
- while ((ch = in.read()) >= 0 && ch != '\n')
- {
- if (ch != '\r')
- {
- b.append((char)ch);
+ while ((ch = in.read()) >= 0 && ch != '\n') {
+ if (ch != '\r') {
+ b.append((char) ch);
}
}
- if (ch < 0)
- {
+ if (ch < 0) {
return null;
}
return b.toString();
}
- private static class LineOutputStream
- extends FilterOutputStream
- {
+ private static class LineOutputStream extends FilterOutputStream {
+
private static byte newline[];
- public LineOutputStream(OutputStream outputstream)
- {
+ public LineOutputStream(OutputStream outputstream) {
super(outputstream);
}
- public void writeln(String s)
- throws MessagingException
- {
- try
- {
+ public void writeln(String s) throws MessagingException {
+ try {
byte abyte0[] = s.getBytes(StandardCharsets.UTF_8);
super.out.write(abyte0);
super.out.write(newline);
- }
- catch (Exception exception)
- {
+ } catch (Exception exception) {
throw new MessagingException("IOException", exception);
}
}
- public void writeln()
- throws MessagingException
- {
- try
- {
+ public void writeln() throws MessagingException {
+ try {
super.out.write(newline);
- }
- catch (Exception exception)
- {
+ } catch (Exception exception) {
throw new MessagingException("IOException", exception);
}
}
- static
- {
+ static {
newline = new byte[2];
newline[0] = 13;
newline[1] = 10;
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/package-info.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/package-info.java
index 27fd6646..17d9ee49 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/package-info.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/package-info.java
@@ -1,3 +1,40 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.
+ */
/**
* S/MIME and OpenPGP handlers for the JavaMail API.
*/
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/pgp.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/pgp.java
index 9b33dc31..f64f294e 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/pgp.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/pgp.java
@@ -1,16 +1,55 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.handlers;
import jakarta.activation.ActivationDataFlavor;
import jakarta.mail.internet.MimeBodyPart;
-public class pgp
- extends SignatureContentHandler
-{
- private static final ActivationDataFlavor ADF = new ActivationDataFlavor(MimeBodyPart.class, "application/pgp-signature", "PGP Signature");
- private static final ActivationDataFlavor[] DFS = new ActivationDataFlavor[] { ADF };
+public class pgp extends SignatureContentHandler {
- public pgp()
- {
+ private static final ActivationDataFlavor ADF = new ActivationDataFlavor(
+ MimeBodyPart.class,
+ "application/pgp-signature",
+ "PGP Signature"
+ );
+ private static final ActivationDataFlavor[] DFS = new ActivationDataFlavor[] { ADF };
+
+ public pgp() {
super(ADF, DFS);
}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/pkcs7_mime.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/pkcs7_mime.java
index 338d745f..394f33e8 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/pkcs7_mime.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/pkcs7_mime.java
@@ -1,16 +1,55 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.handlers;
import jakarta.activation.ActivationDataFlavor;
import jakarta.mail.internet.MimeBodyPart;
-public class pkcs7_mime
- extends SignatureContentHandler
-{
- private static final ActivationDataFlavor ADF = new ActivationDataFlavor(MimeBodyPart.class, "application/pkcs7-mime", "Encrypted Data");
- private static final ActivationDataFlavor[] DFS = new ActivationDataFlavor[] { ADF };
-
- public pkcs7_mime()
- {
+public class pkcs7_mime extends SignatureContentHandler {
+
+ private static final ActivationDataFlavor ADF = new ActivationDataFlavor(
+ MimeBodyPart.class,
+ "application/pkcs7-mime",
+ "Encrypted Data"
+ );
+ private static final ActivationDataFlavor[] DFS = new ActivationDataFlavor[] { ADF };
+
+ public pkcs7_mime() {
super(ADF, DFS);
}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/pkcs7_signature.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/pkcs7_signature.java
index 42d60ceb..fd9bbb11 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/pkcs7_signature.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/pkcs7_signature.java
@@ -1,16 +1,55 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.handlers;
import jakarta.activation.ActivationDataFlavor;
import jakarta.mail.internet.MimeBodyPart;
-public class pkcs7_signature
- extends SignatureContentHandler
-{
- private static final ActivationDataFlavor ADF = new ActivationDataFlavor(MimeBodyPart.class, "application/pkcs7-signature", "Signature");
- private static final ActivationDataFlavor[] DFS = new ActivationDataFlavor[] { ADF };
-
- public pkcs7_signature()
- {
+public class pkcs7_signature extends SignatureContentHandler {
+
+ private static final ActivationDataFlavor ADF = new ActivationDataFlavor(
+ MimeBodyPart.class,
+ "application/pkcs7-signature",
+ "Signature"
+ );
+ private static final ActivationDataFlavor[] DFS = new ActivationDataFlavor[] { ADF };
+
+ public pkcs7_signature() {
super(ADF, DFS);
}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/x_pkcs7_mime.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/x_pkcs7_mime.java
index a8c369e3..40eb904c 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/x_pkcs7_mime.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/x_pkcs7_mime.java
@@ -1,16 +1,55 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.handlers;
import jakarta.activation.ActivationDataFlavor;
import jakarta.mail.internet.MimeBodyPart;
-public class x_pkcs7_mime
- extends SignatureContentHandler
-{
- private static final ActivationDataFlavor ADF = new ActivationDataFlavor(MimeBodyPart.class, "application/x-pkcs7-mime", "Encrypted Data");
- private static final ActivationDataFlavor[] DFS = new ActivationDataFlavor[] { ADF };
-
- public x_pkcs7_mime()
- {
+public class x_pkcs7_mime extends SignatureContentHandler {
+
+ private static final ActivationDataFlavor ADF = new ActivationDataFlavor(
+ MimeBodyPart.class,
+ "application/x-pkcs7-mime",
+ "Encrypted Data"
+ );
+ private static final ActivationDataFlavor[] DFS = new ActivationDataFlavor[] { ADF };
+
+ public x_pkcs7_mime() {
super(ADF, DFS);
}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/x_pkcs7_signature.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/x_pkcs7_signature.java
index 6ad79af0..bc43ef04 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/x_pkcs7_signature.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/handlers/x_pkcs7_signature.java
@@ -1,67 +1,87 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.handlers;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
import jakarta.activation.ActivationDataFlavor;
import jakarta.activation.DataContentHandler;
import jakarta.activation.DataSource;
import jakarta.mail.internet.MimeBodyPart;
-public class x_pkcs7_signature
- implements DataContentHandler
-{
-
- /*
- *
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class x_pkcs7_signature implements DataContentHandler {
+
+ /*
+ *
* VARIABLES
- *
- */
-
+ *
+ */
+
private static final ActivationDataFlavor ADF;
- private static final ActivationDataFlavor[] ADFs;
-
- static
- {
- ADF = new ActivationDataFlavor(MimeBodyPart.class, "application/x-pkcs7-signature", "Signature");
+ private static final ActivationDataFlavor[] ADFs;
+
+ static {
+ ADF = new ActivationDataFlavor(MimeBodyPart.class, "application/x-pkcs7-signature", "Signature");
ADFs = new ActivationDataFlavor[] { ADF };
}
-
- public Object getContent(DataSource _ds)
- throws IOException
- {
+
+ public Object getContent(DataSource _ds) throws IOException {
return _ds.getInputStream();
}
-
- public Object getTransferData(ActivationDataFlavor _df, DataSource _ds)
- throws IOException
- {
+
+ public Object getTransferData(ActivationDataFlavor _df, DataSource _ds) throws IOException {
return HandlerUtil.getTransferData(this, ADF, _df, _ds);
}
-
- public ActivationDataFlavor[] getTransferDataFlavors()
- {
+
+ public ActivationDataFlavor[] getTransferDataFlavors() {
return ADFs;
}
-
- public void writeTo(Object _obj, String _mimeType, OutputStream _os)
- throws IOException
- {
- if (_obj instanceof MimeBodyPart)
- {
- HandlerUtil.writeFromMimeBodyPart((MimeBodyPart)_obj, _os);
- }
- else if (_obj instanceof byte[])
- {
- _os.write((byte[])_obj);
- }
- else if (_obj instanceof InputStream)
- {
- HandlerUtil.writeFromInputStream((InputStream)_obj, _os);
- }
- else
- {
+
+ public void writeTo(Object _obj, String _mimeType, OutputStream _os) throws IOException {
+ if (_obj instanceof MimeBodyPart) {
+ HandlerUtil.writeFromMimeBodyPart((MimeBodyPart) _obj, _os);
+ } else if (_obj instanceof byte[]) {
+ _os.write((byte[]) _obj);
+ } else if (_obj instanceof InputStream) {
+ HandlerUtil.writeFromInputStream((InputStream) _obj, _os);
+ } else {
throw new IOException("unknown object in writeTo " + _obj);
}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/mbox/MboxFolder.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/mbox/MboxFolder.java
index a307255e..9591a1b2 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/mbox/MboxFolder.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/mbox/MboxFolder.java
@@ -1,36 +1,46 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.mbox;
import fr.gouv.vitam.tools.mailextractlib.store.javamail.JMMimeMessage;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractProgressLogger;
-
import jakarta.mail.*;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -54,6 +64,7 @@ public class MboxFolder extends Folder {
private int total; // total number of messages in mailbox
private class MessageFork {
+
long beg, end;
MessageFork(long beg, long end) {
@@ -198,10 +209,8 @@ public boolean hasNewMessages() {
*/
@Override
public Folder getFolder(String name) throws MessagingException {
- if ((name == null) || (name.isEmpty()))
- return new MboxFolder(mboxstore);
- else
- throw new MethodNotSupportedException("mbox: no folder supported");
+ if ((name == null) || (name.isEmpty())) return new MboxFolder(mboxstore);
+ else throw new MethodNotSupportedException("mbox: no folder supported");
}
/*
@@ -245,8 +254,7 @@ public boolean isOpen() {
*/
@Override
public void open(int mode) throws MessagingException {
- if (opened)
- throw new IllegalStateException("mbox: file " + mboxstore.getContainer() + " is already open");
+ if (opened) throw new IllegalStateException("mbox: file " + mboxstore.getContainer() + " is already open");
this.mode = mode;
switch (mode) {
@@ -261,10 +269,11 @@ public void open(int mode) throws MessagingException {
MessageFork mf;
try {
- if (mboxstore.getObjectContent() != null)
- mboxfilereader = new MboxReader(logger, (byte[]) mboxstore.getObjectContent());
- else
- mboxfilereader = new MboxReader(logger, new File(mboxstore.getContainer()));
+ if (mboxstore.getObjectContent() != null) mboxfilereader = new MboxReader(
+ logger,
+ (byte[]) mboxstore.getObjectContent()
+ );
+ else mboxfilereader = new MboxReader(logger, new File(mboxstore.getContainer()));
opened = true; // now really opened
long beg, end;
@@ -290,8 +299,7 @@ public void open(int mode) throws MessagingException {
*/
@Override
public void close(boolean expunge) throws MessagingException {
- if (!opened)
- throw new IllegalStateException("mbox: file " + mboxstore.getContainer() + " is not open");
+ if (!opened) throw new IllegalStateException("mbox: file " + mboxstore.getContainer() + " is not open");
messages = null;
opened = false;
try {
@@ -308,8 +316,7 @@ public void close(boolean expunge) throws MessagingException {
*/
@Override
public int getMessageCount() throws MessagingException {
- if (!opened)
- return -1;
+ if (!opened) return -1;
return total;
}
@@ -321,16 +328,17 @@ public int getMessageCount() throws MessagingException {
*/
@Override
public Message getMessage(int msgno) throws MessagingException {
- if (msgno < 1) // message-numbers start at 1
- throw new IndexOutOfBoundsException("message number " + msgno + " < 1");
- else if (msgno > total) // Still out of range ? Throw up ...
- throw new IndexOutOfBoundsException("message number " + msgno + " > " + total);
+ if (msgno < 1) throw new IndexOutOfBoundsException("message number " + msgno + " < 1"); // message-numbers start at 1
+ else if (msgno > total) throw new IndexOutOfBoundsException("message number " + msgno + " > " + total); // Still out of range ? Throw up ...
Message m;
// each get regenerate a message with no strong link so that it can be
// GC
// optimal for the extraction usage with only one get by message
- m = new JMMimeMessage(this, mboxfilereader.newStream(messages.get(msgno - 1).beg, messages.get(msgno - 1).end),
- msgno);
+ m = new JMMimeMessage(
+ this,
+ mboxfilereader.newStream(messages.get(msgno - 1).beg, messages.get(msgno - 1).end),
+ msgno
+ );
return m;
}
@@ -360,7 +368,14 @@ public Message[] expunge() throws MessagingException {
public URLName getURLName() {
URLName storeURL = getStore().getURLName();
- return new URLName(storeURL.getProtocol(), storeURL.getHost(), storeURL.getPort(), mboxstore.getContainer(),
- storeURL.getUsername(), null /* no password */);
+ return new URLName(
+ storeURL.getProtocol(),
+ storeURL.getHost(),
+ storeURL.getPort(),
+ mboxstore.getContainer(),
+ storeURL.getUsername(),
+ null
+ /* no password */
+ );
}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/mbox/MboxReader.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/mbox/MboxReader.java
index a8b847c8..3623bb72 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/mbox/MboxReader.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/mbox/MboxReader.java
@@ -1,37 +1,47 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.mbox;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractProgressLogger;
-
import jakarta.mail.internet.SharedInputStream;
import jakarta.mail.util.SharedByteArrayInputStream;
import jakarta.mail.util.SharedFileInputStream;
+
import java.io.*;
/**
@@ -105,10 +115,8 @@ public MailExtractProgressLogger getProgressLogger() {
* @throws IOException Unable to close the file.
*/
public void close() throws IOException {
- if (raf != null)
- raf.close();
- if (sifs instanceof InputStream)
- ((InputStream) sifs).close();
+ if (raf != null) raf.close();
+ if (sifs instanceof InputStream) ((InputStream) sifs).close();
}
/**
@@ -131,8 +139,7 @@ private final int read() throws IOException {
// if File
if (curPos >= len) {
bufferPos = raf.getFilePointer();
- if ((len = raf.read(buffer)) == -1)
- return -1;
+ if ((len = raf.read(buffer)) == -1) return -1;
curPos = 0;
}
} else {
@@ -140,8 +147,7 @@ private final int read() throws IOException {
// TODO get rid of buffer when byte[]
if (curPos >= len) {
bufferPos = sifs.getPosition();
- if ((len = ((ByteArrayInputStream) sifs).read(buffer)) == -1)
- return -1;
+ if ((len = ((ByteArrayInputStream) sifs).read(buffer)) == -1) return -1;
curPos = 0;
}
}
@@ -161,10 +167,8 @@ private final int readFirstBytesLine(byte[] buffer) throws IOException {
lineNum++;
while (true) {
b = read();
- if (b == -1)
- return -1;
- if (b == '\n')
- return i;
+ if (b == -1) return -1;
+ if (b == '\n') return i;
if (i < 64) {
buffer[i++] = (byte) b;
}
@@ -176,8 +180,7 @@ private String constructLine(byte[] buffer, int len) {
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < len; i++) {
final char c = (char) (buffer[i]);
- if (c >= 32)
- stringBuilder.append(c);
+ if (c >= 32) stringBuilder.append(c);
}
return stringBuilder.toString();
}
@@ -196,12 +199,10 @@ private String constructLine(byte[] buffer, int len) {
//After the "From " line is the message itself in RFC 5322 format. The final line is a completely blank line with no spaces or tabs.
// WARNING: due to tested mbox files diversity the only kept filter is the beginning "From " pattern!
private boolean isCompliantMBoxDelimiterLine(byte[] buffer, int len) {
- if ((buffer[0] == 'F') && (buffer[1] == 'r') && (buffer[2] == 'o') && (buffer[3] == 'm')
- && (buffer[4] == ' '))
- return true;
- else
- return false;
-
+ if (
+ (buffer[0] == 'F') && (buffer[1] == 'r') && (buffer[2] == 'o') && (buffer[3] == 'm') && (buffer[4] == ' ')
+ ) return true;
+ else return false;
}
/**
@@ -222,10 +223,10 @@ public long getNextFromLineBeg() throws IOException {
fromLineEnd = -1;
return -1;
}
- if (isCompliantMBoxDelimiterLine(buffer, len)) {
- fromLineEnd = getPointer();
- return beg;
- }
+ if (isCompliantMBoxDelimiterLine(buffer, len)) {
+ fromLineEnd = getPointer();
+ return beg;
+ }
}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/mbox/MboxStore.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/mbox/MboxStore.java
index 1905b0e0..137ded21 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/mbox/MboxStore.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/mbox/MboxStore.java
@@ -1,35 +1,45 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.mbox;
import fr.gouv.vitam.tools.mailextractlib.store.javamail.JMEmbeddedStore;
-
import jakarta.mail.*;
+
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
@@ -93,12 +103,11 @@ protected boolean protocolConnect(String host, int port, String user, String pas
// verify only if not embedded
if (objectContent == null) {
// verify params significance in ThunderMBox context
- if (!host.equals("localhost"))
- throw new MessagingException("mbox: only support localhost");
- if (!((passwd == null) || (passwd.isEmpty())))
- throw new MessagingException("mbox: does not allow passwords");
- if (port != -1)
- throw new MessagingException("mbox: does not allow port selection");
+ if (!host.equals("localhost")) throw new MessagingException("mbox: only support localhost");
+ if (!((passwd == null) || (passwd.isEmpty()))) throw new MessagingException(
+ "mbox: does not allow passwords"
+ );
+ if (port != -1) throw new MessagingException("mbox: does not allow port selection");
// verify declared file for mbox availability
try {
@@ -131,10 +140,8 @@ public Folder getDefaultFolder() throws MessagingException {
*/
@Override
public Folder getFolder(String name) throws MessagingException {
- if ((name == null) || (name.isEmpty()))
- return new MboxFolder(this);
- else
- throw new MessagingException("mbox: only one root simulated folder, no " + name + " folder");
+ if ((name == null) || (name.isEmpty())) return new MboxFolder(this);
+ else throw new MessagingException("mbox: only one root simulated folder, no " + name + " folder");
}
/*
@@ -144,16 +151,13 @@ public Folder getFolder(String name) throws MessagingException {
*/
@Override
public Folder getFolder(URLName url) throws MessagingException {
- if ((url.getFile() == null) || (url.getFile().isEmpty()))
- return new MboxFolder(this);
- else
- throw new MessagingException("mbox: only one root simulated folder, no " + url.getFile() + " folder");
+ if ((url.getFile() == null) || (url.getFile().isEmpty())) return new MboxFolder(this);
+ else throw new MessagingException("mbox: only one root simulated folder, no " + url.getFile() + " folder");
}
@Override
public void setObjectContent(Object objectContent) {
- if (objectContent instanceof byte[])
- this.objectContent = (byte[]) objectContent;
+ if (objectContent instanceof byte[]) this.objectContent = (byte[]) objectContent;
}
@Override
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/mbox/package-info.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/mbox/package-info.java
index f65d63e0..9c6c2192 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/mbox/package-info.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/mbox/package-info.java
@@ -1,7 +1,44 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.
+ */
/**
* Provides all classes to implement a Thunderbird mbox provider for JavaMail
* library.
* Warning:Only for reading and without file locking or new
* messages management.
*/
-package fr.gouv.vitam.tools.mailextractlib.store.javamail.mbox;
\ No newline at end of file
+package fr.gouv.vitam.tools.mailextractlib.store.javamail.mbox;
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/package-info.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/package-info.java
index 634a3eef..a008f012 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/package-info.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/package-info.java
@@ -1,7 +1,44 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.
+ */
/**
* Provides all classes to extract stores with JavaMail library.
*
* For now, IMAP and Thunderbird mbox, eml structure through MailExtract application,
* could also be used for POP3 and Gmail, via StoreExtractor (not tested).
*/
-package fr.gouv.vitam.tools.mailextractlib.store.javamail;
\ No newline at end of file
+package fr.gouv.vitam.tools.mailextractlib.store.javamail;
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/thunderbird/ThunderbirdFolder.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/thunderbird/ThunderbirdFolder.java
index 60aa2b18..3edbda1d 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/thunderbird/ThunderbirdFolder.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/thunderbird/ThunderbirdFolder.java
@@ -1,38 +1,48 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.thunderbird;
import fr.gouv.vitam.tools.mailextractlib.store.javamail.JMMimeMessage;
import fr.gouv.vitam.tools.mailextractlib.store.javamail.mbox.MboxReader;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractProgressLogger;
-
import jakarta.mail.*;
import org.eclipse.angus.mail.imap.protocol.BASE64MailboxDecoder;
+
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
@@ -62,6 +72,7 @@ public class ThunderbirdFolder extends Folder {
private MailExtractProgressLogger logger;
private class MessageFork {
+
long beg, end;
MessageFork(long beg, long end) {
@@ -99,8 +110,8 @@ public ThunderbirdFolder(ThunderbirdStore store, String folderFullName) throws M
this.mstore = store;
this.folderFullName = folderFullName;
- holdsFlags = (isBoxHoldingMessages(folderFullName) ? HOLDS_MESSAGES : 0)
- | (isBoxHoldingFolders(folderFullName) ? HOLDS_FOLDERS : 0);
+ holdsFlags = (isBoxHoldingMessages(folderFullName) ? HOLDS_MESSAGES : 0) |
+ (isBoxHoldingFolders(folderFullName) ? HOLDS_FOLDERS : 0);
if (folderFullName != null) {
folderFile = new File(getFilePathFromFolderFullName(folderFullName));
}
@@ -135,13 +146,21 @@ private String getFilePathFromFolderFullName(String folderFullName) {
}
private String getSubFolderDirectoryPathFromFolderFullName(String folderPath) {
- return mstore.getContainer() + File.separator + folderPath.replace(File.separator, ".sbd" + File.separator)
- + ".sbd";
+ return (
+ mstore.getContainer() +
+ File.separator +
+ folderPath.replace(File.separator, ".sbd" + File.separator) +
+ ".sbd"
+ );
}
private String getIndexFilePathFromFolderFullName(String folderPath) {
- return mstore.getContainer() + File.separator + folderPath.replace(File.separator, ".sbd" + File.separator)
- + ".msf";
+ return (
+ mstore.getContainer() +
+ File.separator +
+ folderPath.replace(File.separator, ".sbd" + File.separator) +
+ ".msf"
+ );
}
private String getFolderNameFromFileName(String fileName) {
@@ -149,17 +168,13 @@ private String getFolderNameFromFileName(String fileName) {
}
private String getFolderNameFromIndexFileName(String fileName) {
- if (fileName.endsWith(".msf"))
- return fileName.substring(0, fileName.length() - 4);
- else
- return fileName;
+ if (fileName.endsWith(".msf")) return fileName.substring(0, fileName.length() - 4);
+ else return fileName;
}
private String getFolderNameFromSubFolderDirectoryName(String fileName) {
- if (fileName.endsWith(".sbd"))
- return fileName.substring(0, fileName.length() - 4);
- else
- return fileName;
+ if (fileName.endsWith(".sbd")) return fileName.substring(0, fileName.length() - 4);
+ else return fileName;
}
private String getFolderFullNameFromPath(String filePath) {
@@ -180,11 +195,8 @@ private String getSubFolderFullName(String folderName) {
*/
@Override
public String getName() {
- if (folderFullName == null)
- return "";
- else
- // XXXX
- return BASE64MailboxDecoder.decode(folderFile.getName());
+ if (folderFullName == null) return "";
+ else return BASE64MailboxDecoder.decode(folderFile.getName()); // XXXX
}
/*
@@ -194,21 +206,21 @@ public String getName() {
*/
@Override
public String getFullName() {
- if (folderFullName == null)
- return "";
- else
- return BASE64MailboxDecoder.decode(folderFullName);
+ if (folderFullName == null) return "";
+ else return BASE64MailboxDecoder.decode(folderFullName);
}
// test functions used to determine if a folder hold messages and/or
// subfolders
private boolean isSubFoldersDirectory(File test) {
- if (!test.exists() || !test.isDirectory())
- return false;
+ if (!test.exists() || !test.isDirectory()) return false;
if (!test.getName().endsWith(".sbd")) {
- doProgressLogWithoutInterruption(logger, MailExtractProgressLogger.WARNING,
- "ThunderMBox: Maybe sub folders directory " + test.getPath() + " without .sbd suffix is ignored",
- null);
+ doProgressLogWithoutInterruption(
+ logger,
+ MailExtractProgressLogger.WARNING,
+ "ThunderMBox: Maybe sub folders directory " + test.getPath() + " without .sbd suffix is ignored",
+ null
+ );
return false;
}
return true;
@@ -216,8 +228,7 @@ private boolean isSubFoldersDirectory(File test) {
private boolean isThundebirdMboxFile(File test) {
// first is it a file
- if (!test.exists() || !test.isFile())
- return false;
+ if (!test.exists() || !test.isFile()) return false;
// then verify that the file content is beginning with "From "
BufferedReader reader = null;
try {
@@ -225,62 +236,55 @@ private boolean isThundebirdMboxFile(File test) {
String firstline = "";
while (firstline.isEmpty()) {
firstline = reader.readLine();
- if (firstline == null)
- break;
+ if (firstline == null) break;
firstline = firstline.trim();
}
- if (firstline == null || !firstline.startsWith("From"))
- return false;
+ if (firstline == null || !firstline.startsWith("From")) return false;
} catch (IOException e) {
- doProgressLogWithoutInterruption(logger, MailExtractProgressLogger.WARNING,
- "ThunderMBox: Maybe mailbox file " + test.getPath() + " can't be opened and is ignored",
- e);
+ doProgressLogWithoutInterruption(
+ logger,
+ MailExtractProgressLogger.WARNING,
+ "ThunderMBox: Maybe mailbox file " + test.getPath() + " can't be opened and is ignored",
+ e
+ );
} finally {
try {
- if (reader != null)
- reader.close();
+ if (reader != null) reader.close();
} catch (IOException e) {
// forget it
}
}
// then verify that an index file exists "fileName".msf
test = new File(test.getPath() + ".msf");
- if (!test.exists())
- doProgressLogWithoutInterruption(logger, MailExtractProgressLogger.WARNING,
- "ThunderMBox: Maybe mailbox file " + test.getPath() + " don't have an index file but is analyzed",
- null);
+ if (!test.exists()) doProgressLogWithoutInterruption(
+ logger,
+ MailExtractProgressLogger.WARNING,
+ "ThunderMBox: Maybe mailbox file " + test.getPath() + " don't have an index file but is analyzed",
+ null
+ );
return true;
}
private boolean isThunderIndexFile(File test) {
- if (!test.exists() || !test.isFile())
- return false;
+ if (!test.exists() || !test.isFile()) return false;
return (test.getName().endsWith(".msf"));
}
private boolean isBoxHoldingMessages(String folderFullName) {
- if (folderFullName == null)
- return false;
- else
- return isThundebirdMboxFile(new File(getFilePathFromFolderFullName(folderFullName)));
+ if (folderFullName == null) return false;
+ else return isThundebirdMboxFile(new File(getFilePathFromFolderFullName(folderFullName)));
}
private boolean isBoxHoldingFolders(String folderFullName) {
- if (folderFullName == null)
- return true;
- else
- return isSubFoldersDirectory(new File(getSubFolderDirectoryPathFromFolderFullName(folderFullName)));
+ if (folderFullName == null) return true;
+ else return isSubFoldersDirectory(new File(getSubFolderDirectoryPathFromFolderFullName(folderFullName)));
}
private boolean isBox(String folderPath) {
- if (isThundebirdMboxFile(new File(getFilePathFromFolderFullName(folderPath))))
- return true;
- else if (isSubFoldersDirectory(new File(getSubFolderDirectoryPathFromFolderFullName(folderPath))))
- return true;
- else if (isThunderIndexFile(new File(getIndexFilePathFromFolderFullName(folderPath))))
- return true;
- else
- return false;
+ if (isThundebirdMboxFile(new File(getFilePathFromFolderFullName(folderPath)))) return true;
+ else if (isSubFoldersDirectory(new File(getSubFolderDirectoryPathFromFolderFullName(folderPath)))) return true;
+ else if (isThunderIndexFile(new File(getIndexFilePathFromFolderFullName(folderPath)))) return true;
+ else return false;
}
/*
@@ -325,8 +329,7 @@ public Folder[] list() throws MessagingException {
File folder = new File(sbdPath);
File[] listOfFiles = folder.listFiles();
- if (listOfFiles == null)
- return result;
+ if (listOfFiles == null) return result;
HashMap
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.javamail.thunderbird;
import jakarta.mail.*;
+
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
@@ -69,7 +80,6 @@ public String getContainer() {
*/
public ThunderbirdStore(Session session, URLName url) {
super(session, url);
-
try {
container = URLDecoder.decode(url.getFile(), "UTF-8");
} catch (UnsupportedEncodingException e) {
@@ -100,10 +110,10 @@ public ThunderbirdStore(Session session, URLName url) {
@Override
protected boolean protocolConnect(String host, int port, String user, String passwd) throws MessagingException {
// verify params significance in ThunderMBox context
- if (!((passwd == null) || (passwd.isEmpty())))
- throw new MessagingException("ThunderMBox: does not allow passwords");
- if (port != -1)
- throw new MessagingException("ThunderMBox: does not allow port selection");
+ if (!((passwd == null) || (passwd.isEmpty()))) throw new MessagingException(
+ "ThunderMBox: does not allow passwords"
+ );
+ if (port != -1) throw new MessagingException("ThunderMBox: does not allow port selection");
// verify declared directory for thunderbird mbox hierarchy availability
File test = new File(container);
@@ -130,10 +140,8 @@ public Folder getDefaultFolder() throws MessagingException {
*/
@Override
public Folder getFolder(String name) throws MessagingException {
- if (name.equals(container))
- name = null;
- else if (name.startsWith(container))
- name = name.substring(container.length() + 1);
+ if (name.equals(container)) name = null;
+ else if (name.startsWith(container)) name = name.substring(container.length() + 1);
return new ThunderbirdFolder(this, name);
}
@@ -151,9 +159,9 @@ public Folder getFolder(URLName url) throws MessagingException {
} catch (UnsupportedEncodingException e) {
// not possible
}
- if (!filename.startsWith(container))
- throw new MessagingException("ThunderMBox: folder must be in directory declared for the store");
+ if (!filename.startsWith(container)) throw new MessagingException(
+ "ThunderMBox: folder must be in directory declared for the store"
+ );
return getFolder(url.getFile().substring(container.length()));
}
-
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/thunderbird/package-info.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/thunderbird/package-info.java
index 8df50a77..a8aa0e3f 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/thunderbird/package-info.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/thunderbird/package-info.java
@@ -1,7 +1,44 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.
+ */
/**
* Provides all classes to implement a Thunderbird mbox directory/file provider for JavaMail
* library.
* Warning:Only for reading and without file locking or new
* messages management.
*/
-package fr.gouv.vitam.tools.mailextractlib.store.javamail.thunderbird;
\ No newline at end of file
+package fr.gouv.vitam.tools.mailextractlib.store.javamail.thunderbird;
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/MicrosoftStoreElement.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/MicrosoftStoreElement.java
index acea1a46..ea143551 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/MicrosoftStoreElement.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/MicrosoftStoreElement.java
@@ -1,3 +1,40 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.microsoft;
import fr.gouv.vitam.tools.mailextractlib.core.StoreAttachment;
@@ -9,7 +46,6 @@
import static fr.gouv.vitam.tools.mailextractlib.store.microsoft.MicrosoftStoreMessageAttachment.*;
public interface MicrosoftStoreElement {
-
String getEmbeddedMessageScheme();
// try to get the best attachment name
@@ -17,16 +53,17 @@ static String getAttachementFilename(MicrosoftStoreMessageAttachment nativeAttac
String result;
result = nativeAttachment.longFilename;
- if (result.isEmpty())
- result = nativeAttachment.filename;
- if (result.isEmpty())
- result = nativeAttachment.displayName;
+ if (result.isEmpty()) result = nativeAttachment.filename;
+ if (result.isEmpty()) result = nativeAttachment.displayName;
return result;
}
// utility function to extract attachment from different types of microsoft container (pst message, pst appointment, msg)
- static List
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.microsoft;
import fr.gouv.vitam.tools.mailextractlib.core.StoreFolder;
import fr.gouv.vitam.tools.mailextractlib.core.StoreMessage;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractProgressLogger;
import fr.gouv.vitam.tools.mailextractlib.utils.RFC822Headers;
-
import jakarta.mail.MessagingException;
import java.time.Instant;
@@ -76,76 +85,75 @@ public MicrosoftStoreMessage(StoreFolder mBFolder) {
public long getMessageSize() {
long result;
result = getNativeMessageSize();
- if ((result == 0) && (mimeContent != null))
- result = mimeContent.length;
+ if ((result == 0) && (mimeContent != null)) result = mimeContent.length;
return result;
}
// Native message fields access functions
- abstract protected String getNativeSmtpTransportHeader() throws InterruptedException;
+ protected abstract String getNativeSmtpTransportHeader() throws InterruptedException;
- abstract protected String getNativeSubject() throws InterruptedException;
+ protected abstract String getNativeSubject() throws InterruptedException;
- abstract protected String getNativeInternetMessageId() throws InterruptedException;
+ protected abstract String getNativeInternetMessageId() throws InterruptedException;
- abstract protected String getNativeSenderName() throws InterruptedException;
+ protected abstract String getNativeSenderName() throws InterruptedException;
- abstract protected String getNativeSentRepresentingName() throws InterruptedException;
+ protected abstract String getNativeSentRepresentingName() throws InterruptedException;
- abstract protected String getNativeSenderAddrType() throws InterruptedException;
+ protected abstract String getNativeSenderAddrType() throws InterruptedException;
- abstract protected String getNativeSenderEmailAddress() throws InterruptedException;
+ protected abstract String getNativeSenderEmailAddress() throws InterruptedException;
- abstract protected String getNativeSentRepresentingAddrType() throws InterruptedException;
+ protected abstract String getNativeSentRepresentingAddrType() throws InterruptedException;
- abstract protected String getNativeSentRepresentingEmailAddress() throws InterruptedException;
+ protected abstract String getNativeSentRepresentingEmailAddress() throws InterruptedException;
- abstract protected String getNativeReturnPath() throws InterruptedException;
+ protected abstract String getNativeReturnPath() throws InterruptedException;
- abstract protected Date getNativeMessageDeliveryTime();
+ protected abstract Date getNativeMessageDeliveryTime();
- abstract protected Date getNativeClientSubmitTime();
+ protected abstract Date getNativeClientSubmitTime();
- abstract protected String getNativeInReplyToId() throws InterruptedException;
+ protected abstract String getNativeInReplyToId() throws InterruptedException;
- abstract protected long getNativeMessageSize();
+ protected abstract long getNativeMessageSize();
// Native message ConversationIndex access functions
- abstract protected boolean hasNativeConversationIndex();
+ protected abstract boolean hasNativeConversationIndex();
- abstract protected Date getNativeCIDeliveryTime();
+ protected abstract Date getNativeCIDeliveryTime();
- abstract protected UUID getNativeCIGuid();
+ protected abstract UUID getNativeCIGuid();
- abstract protected int getNativeCINumberOfResponseLevels();
+ protected abstract int getNativeCINumberOfResponseLevels();
- abstract protected short getNativeCIResponseLevelDeltaCode(int responseLevelNumber);
+ protected abstract short getNativeCIResponseLevelDeltaCode(int responseLevelNumber);
- abstract protected long getNativeCIResponseLevelTimeDelta(int responseLevelNumber);
+ protected abstract long getNativeCIResponseLevelTimeDelta(int responseLevelNumber);
- abstract protected short getNativeCIResponseLevelRandom(int responseLevelNumber);
+ protected abstract short getNativeCIResponseLevelRandom(int responseLevelNumber);
// Native message Recipients access functions
- abstract protected int getNativeNumberOfRecipients();
+ protected abstract int getNativeNumberOfRecipients();
- abstract protected String getNativeRecipientsSmtpAddress(int recipientNumber);
+ protected abstract String getNativeRecipientsSmtpAddress(int recipientNumber);
- abstract protected String getNativeRecipientsEmailAddress(int recipientNumber);
+ protected abstract String getNativeRecipientsEmailAddress(int recipientNumber);
- abstract protected String getNativeRecipientsDisplayName(int recipientNumber);
+ protected abstract String getNativeRecipientsDisplayName(int recipientNumber);
- abstract protected int getNativeRecipientsType(int recipientNumber);
+ protected abstract int getNativeRecipientsType(int recipientNumber);
// Native message body access functions
- abstract protected String getNativeBodyText();
+ protected abstract String getNativeBodyText();
- abstract protected String getNativeBodyHTML();
+ protected abstract String getNativeBodyHTML();
- abstract protected String getNativeRTFBody();
+ protected abstract String getNativeRTFBody();
// Native message attachment access functions
- abstract protected MicrosoftStoreMessageAttachment[] getNativeAttachments();
+ protected abstract MicrosoftStoreMessageAttachment[] getNativeAttachments();
// General Headers function
@@ -166,15 +174,14 @@ protected void prepareAnalyze() throws InterruptedException {
if (!hasRFC822Headers()) {
headerString = getNativeSmtpTransportHeader();
- if ((headerString != null) && (!headerString.isEmpty()))
- try {
- rfc822Headers = new RFC822Headers(headerString, this);
- mailHeader = Collections.list(rfc822Headers.getAllHeaderLines());
- } catch (MessagingException e) {
- logMessageWarning("mailextractlib.microsoft: can't decode smtp header", e);
- rfc822Headers = null;
- mailHeader = null;
- }
+ if ((headerString != null) && (!headerString.isEmpty())) try {
+ rfc822Headers = new RFC822Headers(headerString, this);
+ mailHeader = Collections.list(rfc822Headers.getAllHeaderLines());
+ } catch (MessagingException e) {
+ logMessageWarning("mailextractlib.microsoft: can't decode smtp header", e);
+ rfc822Headers = null;
+ mailHeader = null;
+ }
}
nativeAttachments = getNativeAttachments();
}
@@ -194,11 +201,12 @@ protected void analyzeSubject() throws InterruptedException {
// smtp header value
String[] sList = rfc822Headers.getHeader("Subject");
if (sList != null) {
- if (sList.length > 1)
- logMessageWarning("mailextractlib.microsoft: multiple subjects, keep the first one in header", null);
+ if (sList.length > 1) logMessageWarning(
+ "mailextractlib.microsoft: multiple subjects, keep the first one in header",
+ null
+ );
result = RFC822Headers.getHeaderValue(sList[0]);
- if ((result != null) && (result.contains("=?")))
- result = decodeRfc2047Flexible(result);
+ if ((result != null) && (result.contains("=?"))) result = decodeRfc2047Flexible(result);
}
} else {
// pst file value
@@ -213,12 +221,14 @@ protected void analyzeSubject() throws InterruptedException {
result = result.substring(2);
}
}
- if (result.isEmpty())
- result = null;
+ if (result.isEmpty()) result = null;
}
- if (result == null)
- doProgressLog(getProgressLogger(), MailExtractProgressLogger.MESSAGE_DETAILS,
- "mailextractlib.microsoft: no subject in header", null);
+ if (result == null) doProgressLog(
+ getProgressLogger(),
+ MailExtractProgressLogger.MESSAGE_DETAILS,
+ "mailextractlib.microsoft: no subject in header",
+ null
+ );
subject = result;
}
@@ -238,8 +248,10 @@ protected void analyzeMessageID() throws InterruptedException {
// smtp header value
String[] mList = rfc822Headers.getHeader("message-ID");
if (mList != null) {
- if (mList.length > 1)
- logMessageWarning("mailextractlib.microsoft: multiple message ID, keep the first one in header", null);
+ if (mList.length > 1) logMessageWarning(
+ "mailextractlib.microsoft: multiple message ID, keep the first one in header",
+ null
+ );
result = RFC822Headers.getHeaderValue(mList[0]);
}
} else {
@@ -261,9 +273,7 @@ protected void analyzeMessageID() throws InterruptedException {
result += ">";
}
}
- }
- // FIXME AN pst to test
- catch (Exception e) {
+ } catch (Exception e) { // FIXME AN pst to test
logMessageWarning("mailextractlib.microsoft: error during Message ID extraction", e);
result = "NoMessageID";
}
@@ -282,11 +292,9 @@ private String getSenderName() throws InterruptedException {
String result;
result = getNativeSenderName();
- if ((result == null) || result.isEmpty())
- result = getNativeSentRepresentingName();
+ if ((result == null) || result.isEmpty()) result = getNativeSentRepresentingName();
- if (result.isEmpty())
- result = null;
+ if (result.isEmpty()) result = null;
return result;
}
@@ -295,30 +303,23 @@ private String getSenderName() throws InterruptedException {
private String getSenderEmailAddress() throws InterruptedException {
String result = "";
- if (getNativeSenderAddrType().equalsIgnoreCase("SMTP"))
- result = getNativeSenderEmailAddress();
- if (result.isEmpty() && getNativeSentRepresentingAddrType().equalsIgnoreCase("SMTP"))
- result = getNativeSentRepresentingEmailAddress();
- if (result.isEmpty())
- result = getNativeSenderEmailAddress();
- if (result.isEmpty())
- result = getNativeSentRepresentingEmailAddress();
-
- if (result.isEmpty())
- result = null;
+ if (getNativeSenderAddrType().equalsIgnoreCase("SMTP")) result = getNativeSenderEmailAddress();
+ if (result.isEmpty() && getNativeSentRepresentingAddrType().equalsIgnoreCase("SMTP")) result =
+ getNativeSentRepresentingEmailAddress();
+ if (result.isEmpty()) result = getNativeSenderEmailAddress();
+ if (result.isEmpty()) result = getNativeSentRepresentingEmailAddress();
+
+ if (result.isEmpty()) result = null;
return result;
}
static String getFormattedAddress(String name, String smtpAddress) {
- String result=null;
+ String result = null;
- if (name != null){
- if (smtpAddress != null)
- result = name + " <" + smtpAddress + ">";
- else
- result = name;
- }
- else {
+ if (name != null) {
+ if (smtpAddress != null) result = name + " <" + smtpAddress + ">";
+ else result = name;
+ } else {
result = smtpAddress;
}
return result;
@@ -336,8 +337,7 @@ protected void analyzeFrom() throws InterruptedException {
// smtp header value
String[] fromArray = rfc822Headers.getHeader("From");
if (fromArray != null) {
- if (fromArray.length == 1)
- result = RFC822Headers.getHeaderValue(fromArray[0]);
+ if (fromArray.length == 1) result = RFC822Headers.getHeaderValue(fromArray[0]);
else {
List
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.microsoft;
import java.util.Date;
@@ -91,7 +101,5 @@ public class MicrosoftStoreMessageAttachment {
/**
* Instantiates a new microsoft store message attachment.
*/
- public MicrosoftStoreMessageAttachment() {
- }
-
+ public MicrosoftStoreMessageAttachment() {}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgConversationIndex.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgConversationIndex.java
index ee76ee86..63592ccc 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgConversationIndex.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgConversationIndex.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.microsoft.msg;
import java.util.ArrayList;
@@ -39,6 +49,7 @@
* @author Nick Buller
*/
public class MsgConversationIndex {
+
private static final int HUNDRED_NS_TO_MS = 1000;
private static final int MINIMUM_HEADER_SIZE = 22;
private static final int RESPONSE_LEVEL_SIZE = 5;
@@ -167,7 +178,6 @@ protected MsgConversationIndex(final byte[] rawConversationIndex) {
}
private static long convertBigEndianBytesToLong(final byte[] data, final int start, final int end) {
-
long offset = 0;
for (int x = start; x < end; ++x) {
offset = offset << 8;
@@ -190,7 +200,7 @@ private static long convertBigEndianBytesToLong(final byte[] data, final int sta
private static final long EPOCH_DIFF = 11644473600000L;
private static Date filetimeToDate(final int high, final int low) {
- final long filetime = ((long) high) << 32 | (low & 0xffffffffL);
+ final long filetime = (((long) high) << 32) | (low & 0xffffffffL);
final long ms_since_16010101 = filetime / (1000 * 10);
final long ms_since_19700101 = ms_since_16010101 - EPOCH_DIFF;
return new Date(ms_since_19700101);
@@ -216,10 +226,12 @@ private void decodeResponseLevel(final byte[] rawConversationIndex) {
final int responseLevelCount = (rawConversationIndex.length - MINIMUM_HEADER_SIZE) / RESPONSE_LEVEL_SIZE;
this.responseLevels = new ArrayList<>(responseLevelCount);
- for (int responseLevelIndex = 0, position = 22; responseLevelIndex < responseLevelCount; responseLevelIndex++, position += RESPONSE_LEVEL_SIZE) {
-
- final long responseLevelValue = convertBigEndianBytesToLong(rawConversationIndex, position,
- position + 5);
+ for (
+ int responseLevelIndex = 0, position = 22;
+ responseLevelIndex < responseLevelCount;
+ responseLevelIndex++, position += RESPONSE_LEVEL_SIZE
+ ) {
+ final long responseLevelValue = convertBigEndianBytesToLong(rawConversationIndex, position, position + 5);
final short deltaCode = (short) (responseLevelValue >> 39);
final short random = (short) (responseLevelValue & 0xFF);
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgStoreExtractor.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgStoreExtractor.java
index d46f8df6..5c6e88a6 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgStoreExtractor.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgStoreExtractor.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.microsoft.msg;
import fr.gouv.vitam.tools.mailextractlib.core.StoreAttachment;
@@ -52,8 +62,8 @@ public class MsgStoreExtractor extends StoreExtractor {
* This is in default list.
*/
public static void subscribeStoreExtractor() {
- addExtractionRelation("application/vnd.ms-outlook", "x-fmt/430","msg", false, MsgStoreExtractor.class);
- addExtractionRelation(null, null,"msg.embeddedmsg", false, MsgStoreExtractor.class);
+ addExtractionRelation("application/vnd.ms-outlook", "x-fmt/430", "msg", false, MsgStoreExtractor.class);
+ addExtractionRelation(null, null, "msg.embeddedmsg", false, MsgStoreExtractor.class);
}
// Attachment to complete with decoded form
@@ -71,8 +81,14 @@ public static void subscribeStoreExtractor() {
* @throws MailExtractLibException the extraction exception
* @throws InterruptedException the interrupted exception
*/
- public MsgStoreExtractor(String urlString, String folder, String destPathString, StoreExtractorOptions options,
- StoreExtractor rootStoreExtractor, MailExtractProgressLogger logger) throws MailExtractLibException, InterruptedException {
+ public MsgStoreExtractor(
+ String urlString,
+ String folder,
+ String destPathString,
+ StoreExtractorOptions options,
+ StoreExtractor rootStoreExtractor,
+ MailExtractProgressLogger logger
+ ) throws MailExtractLibException, InterruptedException {
super(urlString, folder, destPathString, options, rootStoreExtractor, null, logger);
MAPIMessage message;
long size;
@@ -83,7 +99,9 @@ public MsgStoreExtractor(String urlString, String folder, String destPathString,
size = Files.size(messageFile.toPath());
} catch (Exception e) {
throw new MailExtractLibException(
- "mailextractlib.msg: can't open " + path + ", doesn't exist or is not a msg file", e);
+ "mailextractlib.msg: can't open " + path + ", doesn't exist or is not a msg file",
+ e
+ );
}
ArchiveUnit rootNode = new ArchiveUnit(this, destRootPath, destName);
@@ -102,14 +120,27 @@ public MsgStoreExtractor(String urlString, String folder, String destPathString,
* @throws MailExtractLibException the extraction exception
* @throws InterruptedException the interrupted exception
*/
- public MsgStoreExtractor(StoreAttachment attachment, ArchiveUnit rootNode, StoreExtractorOptions options,
- StoreExtractor rootStoreExtractor, StoreElement fatherElement, MailExtractProgressLogger logger) throws MailExtractLibException, InterruptedException {
- super("msg.embeddedmsg://localhost/", "", rootNode.getFullName(), options, rootStoreExtractor, fatherElement, logger);
+ public MsgStoreExtractor(
+ StoreAttachment attachment,
+ ArchiveUnit rootNode,
+ StoreExtractorOptions options,
+ StoreExtractor rootStoreExtractor,
+ StoreElement fatherElement,
+ MailExtractProgressLogger logger
+ ) throws MailExtractLibException, InterruptedException {
+ super(
+ "msg.embeddedmsg://localhost/",
+ "",
+ rootNode.getFullName(),
+ options,
+ rootStoreExtractor,
+ fatherElement,
+ logger
+ );
MAPIMessage message;
this.attachment = attachment;
- if (attachment.getStoreContent() instanceof MAPIMessage)
- message = (MAPIMessage) attachment.getStoreContent();
+ if (attachment.getStoreContent() instanceof MAPIMessage) message = (MAPIMessage) attachment.getStoreContent();
else if (attachment.getStoreContent() instanceof byte[]) {
ByteArrayInputStream bais = new ByteArrayInputStream((byte[]) attachment.getStoreContent());
try {
@@ -117,8 +148,7 @@ else if (attachment.getStoreContent() instanceof byte[]) {
} catch (IOException e) {
throw new MailExtractLibException("mailextractlib.msg: can't extract msg store", e);
}
- } else
- throw new MailExtractLibException("mailextractlib.msg: can't extract msg store", null);
+ } else throw new MailExtractLibException("mailextractlib.msg: can't extract msg store", null);
setRootFolder(MsgStoreFolder.createRootFolder(this, message, 0, rootNode));
}
@@ -142,8 +172,16 @@ public boolean canExtractObjectsLists() {
/**
* The Constant MSG_MN.
*/
- static final byte[] MSG_MN = new byte[]{(byte) 0xD0, (byte) 0xCF, 0x11, (byte) 0xE0, (byte) 0xA1, (byte) 0xB1,
- 0x1A, (byte) 0xE1};
+ static final byte[] MSG_MN = new byte[] {
+ (byte) 0xD0,
+ (byte) 0xCF,
+ 0x11,
+ (byte) 0xE0,
+ (byte) 0xA1,
+ (byte) 0xB1,
+ 0x1A,
+ (byte) 0xE1,
+ };
/**
* Gets the verified scheme.
@@ -154,7 +192,6 @@ public boolean canExtractObjectsLists() {
public static String getVerifiedScheme(byte[] content) {
if (hasMagicNumber(content, MSG_MN)) {
return "msg";
- } else
- return null;
+ } else return null;
}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgStoreFolder.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgStoreFolder.java
index a9f1e1d3..5a7cadd3 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgStoreFolder.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgStoreFolder.java
@@ -1,34 +1,44 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.microsoft.msg;
-import fr.gouv.vitam.tools.mailextractlib.core.StoreFolder;
import fr.gouv.vitam.tools.mailextractlib.core.StoreAttachment;
+import fr.gouv.vitam.tools.mailextractlib.core.StoreFolder;
import fr.gouv.vitam.tools.mailextractlib.nodes.ArchiveUnit;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractLibException;
import org.apache.poi.hsmf.MAPIMessage;
@@ -51,9 +61,9 @@ public class MsgStoreFolder extends StoreFolder {
* @param size the size
* @throws InterruptedException the interrupted exception
*/
- public MsgStoreFolder(MsgStoreExtractor storeExtractor, MAPIMessage message, long size) throws InterruptedException {
+ public MsgStoreFolder(MsgStoreExtractor storeExtractor, MAPIMessage message, long size)
+ throws InterruptedException {
super(storeExtractor);
-
this.msgStoreMessage = new MsgStoreMessage(this, message, size);
}
@@ -67,8 +77,12 @@ public MsgStoreFolder(MsgStoreExtractor storeExtractor, MAPIMessage message, lon
* @return the LP store folder
* @throws InterruptedException the interrupted exception
*/
- public static MsgStoreFolder createRootFolder(MsgStoreExtractor storeExtractor, MAPIMessage message, long size,
- ArchiveUnit rootArchiveUnit) throws InterruptedException {
+ public static MsgStoreFolder createRootFolder(
+ MsgStoreExtractor storeExtractor,
+ MAPIMessage message,
+ long size,
+ ArchiveUnit rootArchiveUnit
+ ) throws InterruptedException {
MsgStoreFolder result = new MsgStoreFolder(storeExtractor, message, size);
result.folderArchiveUnit = rootArchiveUnit;
@@ -108,8 +122,9 @@ protected void doExtractFolderElements(boolean writeFlag) throws MailExtractLibE
if (attachment != null) {
attachment.setStoreContent(msgStoreMessage.getMimeContent());
attachment.setMimeType("message/rfc822");
- if ((attachment.getName() == null) || attachment.getName().isEmpty())
- attachment.setName(msgStoreMessage.getSubject() + ".eml");
+ if ((attachment.getName() == null) || attachment.getName().isEmpty()) attachment.setName(
+ msgStoreMessage.getSubject() + ".eml"
+ );
}
}
@@ -121,8 +136,7 @@ protected void doExtractFolderElements(boolean writeFlag) throws MailExtractLibE
* int, boolean)
*/
@Override
- protected void doExtractSubFolders(int level, boolean writeFlag) throws MailExtractLibException {
- }
+ protected void doExtractSubFolders(int level, boolean writeFlag) throws MailExtractLibException {}
/*
* (non-Javadoc)
@@ -164,6 +178,5 @@ protected void doListFolderElements(boolean stats) throws MailExtractLibExceptio
* boolean)
*/
@Override
- protected void doListSubFolders(boolean stats) throws MailExtractLibException {
- }
+ protected void doListSubFolders(boolean stats) throws MailExtractLibException {}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgStoreMessage.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgStoreMessage.java
index caddc0e2..c499607c 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgStoreMessage.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgStoreMessage.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.microsoft.msg;
import fr.gouv.vitam.tools.mailextractlib.core.StoreFolder;
@@ -158,8 +168,7 @@ private void getConversationIndex() throws InterruptedException {
byte[] byteConversationIndex = getByteItem(CONVERSATION_INDEX);
if (byteConversationIndex != null) {
msgConversationIndex = new MsgConversationIndex(byteConversationIndex);
- if (msgConversationIndex.getGuid() == null)
- msgConversationIndex = null;
+ if (msgConversationIndex.getGuid() == null) msgConversationIndex = null;
}
}
@@ -178,13 +187,15 @@ private String getStringItem(int item) throws InterruptedException {
if (lChunk != null) {
if (lChunk.size() > 1) {
- logMessageWarning("mailextractlib.msg: multiple MSG object [" + prop.name + "], keep the first one", null);
+ logMessageWarning(
+ "mailextractlib.msg: multiple MSG object [" + prop.name + "], keep the first one",
+ null
+ );
}
if (lChunk.get(0) instanceof StringChunk) {
StringChunk sChunk = (StringChunk) lChunk.get(0);
result = sChunk.getValue();
- } else
- logMessageWarning("mailextractlib.msg: unexpected MSG object type [" + prop.name + "]", null);
+ } else logMessageWarning("mailextractlib.msg: unexpected MSG object type [" + prop.name + "]", null);
}
return result;
}
@@ -196,13 +207,15 @@ private byte[] getByteItem(int item) throws InterruptedException {
if (lChunk != null) {
if (lChunk.size() > 1) {
- logMessageWarning("mailextractlib.msg: multiple MSG object [" + prop.name + "], keep the first one", null);
+ logMessageWarning(
+ "mailextractlib.msg: multiple MSG object [" + prop.name + "], keep the first one",
+ null
+ );
}
if (lChunk.get(0) instanceof ByteChunk) {
ByteChunk bChunk = (ByteChunk) lChunk.get(0);
result = bChunk.getValue();
- } else
- logMessageWarning("mailextractlib.msg: unexpected MSG object type [" + prop.name + "]", null);
+ } else logMessageWarning("mailextractlib.msg: unexpected MSG object type [" + prop.name + "]", null);
}
return result;
}
@@ -214,8 +227,7 @@ private Date getDateItem(int item) {
if (lVal != null) {
Calendar cal = (Calendar) lVal.get(0).getValue();
- if (cal != null)
- result = cal.getTime();
+ if (cal != null) result = cal.getTime();
}
return result;
}
@@ -417,8 +429,11 @@ protected String getNativeRecipientsDisplayName(int recipientNumber) {
*/
@Override
protected int getNativeRecipientsType(int recipientNumber) {
- return (int) message.getRecipientDetailsChunks()[recipientNumber].getProperties()
- .get(MAPIProperty.RECIPIENT_TYPE).get(0).getValue();
+ return (int) message
+ .getRecipientDetailsChunks()[recipientNumber].getProperties()
+ .get(MAPIProperty.RECIPIENT_TYPE)
+ .get(0)
+ .getValue();
}
/* (non-Javadoc)
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgStoreMessageAttachment.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgStoreMessageAttachment.java
index 3b63bee8..ee0899ac 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgStoreMessageAttachment.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/msg/MsgStoreMessageAttachment.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.microsoft.msg;
import fr.gouv.vitam.tools.mailextractlib.store.microsoft.MicrosoftStoreMessageAttachment;
@@ -57,29 +67,23 @@ public MsgStoreMessageAttachment(AttachmentChunks attachmentChunks) {
Map
* Package for Microsoft extraction and, when possible, abstraction for pst and msg classes.
*/
-package fr.gouv.vitam.tools.mailextractlib.store.microsoft;
\ No newline at end of file
+package fr.gouv.vitam.tools.mailextractlib.store.microsoft;
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/PstStoreAppointment.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/PstStoreAppointment.java
index d349ad52..3fd18d9e 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/PstStoreAppointment.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/PstStoreAppointment.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.microsoft.pst;
import fr.gouv.vitam.tools.javalibpst.*;
@@ -95,21 +105,24 @@ protected PstStoreAppointment(PstStoreFolder pstStoreFolder, PSTAppointment appo
* @param isRecurrenceDeletion the is recurrence deletion
* @param exceptionDate the exception date
*/
- protected PstStoreAppointment(StoreFolder storeFolder, String uniqId,
- int sequenceNumber,
- String subject,
- String location,
- String from,
- String toAttendees,
- String ccAttendees,
- ZonedDateTime startTime,
- ZonedDateTime endTime,
- String miscNotes,
- String otherMiscNotes,
- int messageStatus,
- List
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.microsoft.pst;
import fr.gouv.vitam.tools.javalibpst.PSTAttachment;
@@ -36,7 +46,6 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.PrintStream;
import java.util.LinkedHashSet;
/**
@@ -69,23 +78,18 @@ private String getFullName() {
String tmp1, tmp2;
tmp1 = contact.getAccount();
tmp2 = contact.getDisplayName();
- if ((tmp1 == null) || tmp1.isEmpty())
- return tmp2;
- if ((tmp2 == null) || tmp2.isEmpty())
- return tmp1;
- if (tmp1.toLowerCase().equals(tmp2.toLowerCase()))
- return tmp1;
+ if ((tmp1 == null) || tmp1.isEmpty()) return tmp2;
+ if ((tmp2 == null) || tmp2.isEmpty()) return tmp1;
+ if (tmp1.toLowerCase().equals(tmp2.toLowerCase())) return tmp1;
return tmp1 + "/" + tmp2;
}
private String getStringFromSet(LinkedHashSet
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.microsoft.pst;
import fr.gouv.vitam.tools.javalibpst.PSTException;
import fr.gouv.vitam.tools.javalibpst.PSTFile;
import fr.gouv.vitam.tools.javalibpst.PSTFolder;
+import fr.gouv.vitam.tools.mailextractlib.core.StoreAttachment;
import fr.gouv.vitam.tools.mailextractlib.core.StoreElement;
import fr.gouv.vitam.tools.mailextractlib.core.StoreExtractor;
import fr.gouv.vitam.tools.mailextractlib.core.StoreExtractorOptions;
-import fr.gouv.vitam.tools.mailextractlib.core.StoreAttachment;
import fr.gouv.vitam.tools.mailextractlib.nodes.ArchiveUnit;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractLibException;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractProgressLogger;
@@ -55,8 +65,8 @@ public class PstStoreExtractor extends StoreExtractor {
* This is in default list.
*/
public static void subscribeStoreExtractor() {
- addExtractionRelation("application/vnd.ms-outlook-pst", "x-fmt/248","pst", true, PstStoreExtractor.class);
- addExtractionRelation("application/vnd.ms-outlook-pst", "x-fmt/249","pst", true, PstStoreExtractor.class);
+ addExtractionRelation("application/vnd.ms-outlook-pst", "x-fmt/248", "pst", true, PstStoreExtractor.class);
+ addExtractionRelation("application/vnd.ms-outlook-pst", "x-fmt/249", "pst", true, PstStoreExtractor.class);
}
// Attachment to complete with decoded form
@@ -86,15 +96,22 @@ public static void subscribeStoreExtractor() {
* @throws MailExtractLibException Any unrecoverable extraction exception (access trouble, major
* format problems...)
*/
- public PstStoreExtractor(String urlString, String storeFolder, String destPathString, StoreExtractorOptions options,
- StoreExtractor rootStoreExtractor, MailExtractProgressLogger logger) throws MailExtractLibException {
+ public PstStoreExtractor(
+ String urlString,
+ String storeFolder,
+ String destPathString,
+ StoreExtractorOptions options,
+ StoreExtractor rootStoreExtractor,
+ MailExtractProgressLogger logger
+ ) throws MailExtractLibException {
super(urlString, storeFolder, destPathString, options, rootStoreExtractor, null, logger);
-
try {
pstFile = new PSTFile(path);
} catch (Exception e) {
throw new MailExtractLibException(
- "mailextractlib.pst: can't open " + path + ", doesn't exist or is not a pst file", e);
+ "mailextractlib.pst: can't open " + path + ", doesn't exist or is not a pst file",
+ e
+ );
}
pstFile.setGlobalCodepage(options.defaultCharsetName);
@@ -106,9 +123,10 @@ public PstStoreExtractor(String urlString, String storeFolder, String destPathSt
try {
PSTFolder pstFolder = findChildFolder(pstFile.getRootFolder(), storeFolder);
- if (pstFolder == null)
- throw new MailExtractLibException(
- "mailextractlib.pst: can't find the root folder " + storeFolder + " in pst file", null);
+ if (pstFolder == null) throw new MailExtractLibException(
+ "mailextractlib.pst: can't find the root folder " + storeFolder + " in pst file",
+ null
+ );
lPRootMailBoxFolder = PstStoreFolder.createRootFolder(this, pstFolder, rootNode);
@@ -116,7 +134,10 @@ public PstStoreExtractor(String urlString, String storeFolder, String destPathSt
} catch (IOException e) {
throw new MailExtractLibException("mailextractlib.pst: can't use " + path + " pst file", e);
} catch (PSTException e) {
- throw new MailExtractLibException("mailextractlib.pst: can't find extraction root folder " + storeFolder, e);
+ throw new MailExtractLibException(
+ "mailextractlib.pst: can't find extraction root folder " + storeFolder,
+ e
+ );
}
}
@@ -129,25 +150,27 @@ private static File writeStoreFile(String dirPath, byte[] byteContent) throws Ma
Files.createDirectories(Paths.get(dirPath));
storeFile = getStoreTemporaryFile(dirPath);
output = new BufferedOutputStream(new FileOutputStream(storeFile));
- if (byteContent != null)
- output.write(byteContent);
+ if (byteContent != null) output.write(byteContent);
} catch (IOException ex) {
- if (dirPath.length() + 8 > 250)
- throw new MailExtractLibException(
- "mailextractlib.pst: store file extraction illegal destination file (may be too long pathname), extracting unit in path "
- + dirPath, ex);
- else
- throw new MailExtractLibException(
- "mailextractlib.pst: store file extraction illegal destination file, extracting unit in path "
- + dirPath, ex);
+ if (dirPath.length() + 8 > 250) throw new MailExtractLibException(
+ "mailextractlib.pst: store file extraction illegal destination file (may be too long pathname), extracting unit in path " +
+ dirPath,
+ ex
+ );
+ else throw new MailExtractLibException(
+ "mailextractlib.pst: store file extraction illegal destination file, extracting unit in path " +
+ dirPath,
+ ex
+ );
} finally {
- if (output != null)
- try {
- output.close();
- } catch (IOException e) {
- throw new MailExtractLibException(
- "mailextractlib.pst: can't close store file extraction, extracting unit in path " + dirPath, e);
- }
+ if (output != null) try {
+ output.close();
+ } catch (IOException e) {
+ throw new MailExtractLibException(
+ "mailextractlib.pst: can't close store file extraction, extracting unit in path " + dirPath,
+ e
+ );
+ }
}
return (storeFile);
@@ -160,7 +183,7 @@ private static File getStoreTemporaryFile(String destPathString) {
// generate temporary file and create the url to it
private static String generateFileAndUrl(StoreAttachment attachment, ArchiveUnit rootNode)
- throws MailExtractLibException {
+ throws MailExtractLibException {
String result = null;
File storeFile = writeStoreFile(rootNode.getFullName(), attachment.getRawAttachmentContent());
try {
@@ -171,7 +194,8 @@ private static String generateFileAndUrl(StoreAttachment attachment, ArchiveUnit
return result;
}
- private void deleteStoreFileAndContainerAndThrowException(String message, Exception e) throws MailExtractLibException {
+ private void deleteStoreFileAndContainerAndThrowException(String message, Exception e)
+ throws MailExtractLibException {
if (storeFile != null) {
try {
Files.deleteIfExists(storeFile.toPath());
@@ -180,7 +204,10 @@ private void deleteStoreFileAndContainerAndThrowException(String message, Except
Files.deleteIfExists(parentDirectory.toPath());
}
} catch (IOException ee) {
- throw new MailExtractLibException(message + ", and unable to suppress temporary files ("+ee.getMessage()+")", e);
+ throw new MailExtractLibException(
+ message + ", and unable to suppress temporary files (" + ee.getMessage() + ")",
+ e
+ );
}
}
throw new MailExtractLibException(message, e);
@@ -197,17 +224,33 @@ private void deleteStoreFileAndContainerAndThrowException(String message, Except
* @param logger logger used
* @throws MailExtractLibException Any unrecoverable extraction exception (access trouble, major format problems...)
*/
- public PstStoreExtractor(StoreAttachment attachment, ArchiveUnit rootNode, StoreExtractorOptions options,
- StoreExtractor rootStoreExtractor, StoreElement fatherElement, MailExtractProgressLogger logger) throws MailExtractLibException {
- super(generateFileAndUrl(attachment, rootNode), "", rootNode.getFullName(), options, rootStoreExtractor, fatherElement, logger);
-
+ public PstStoreExtractor(
+ StoreAttachment attachment,
+ ArchiveUnit rootNode,
+ StoreExtractorOptions options,
+ StoreExtractor rootStoreExtractor,
+ StoreElement fatherElement,
+ MailExtractProgressLogger logger
+ ) throws MailExtractLibException {
+ super(
+ generateFileAndUrl(attachment, rootNode),
+ "",
+ rootNode.getFullName(),
+ options,
+ rootStoreExtractor,
+ fatherElement,
+ logger
+ );
this.attachment = attachment;
this.storeFile = new File(path);
try {
pstFile = new PSTFile(path);
} catch (Exception e) {
- deleteStoreFileAndContainerAndThrowException("mailextractlib.pst: can't open " + path + ", doesn't exist or is not a pst file",e);
+ deleteStoreFileAndContainerAndThrowException(
+ "mailextractlib.pst: can't open " + path + ", doesn't exist or is not a pst file",
+ e
+ );
}
PstStoreFolder lPRootMailBoxFolder;
@@ -216,7 +259,10 @@ public PstStoreExtractor(StoreAttachment attachment, ArchiveUnit rootNode, Store
PSTFolder pstFolder = findChildFolder(pstFile.getRootFolder(), "");
if (pstFolder == null) {
- deleteStoreFileAndContainerAndThrowException("mailextractlib.pst: Can't find the root folder in pst file", null);
+ deleteStoreFileAndContainerAndThrowException(
+ "mailextractlib.pst: Can't find the root folder in pst file",
+ null
+ );
}
lPRootMailBoxFolder = PstStoreFolder.createRootFolder(this, pstFolder, rootNode);
@@ -247,18 +293,15 @@ private PSTFolder findChildFolder(PSTFolder father, String folderFullName) throw
String regex;
PSTFolder result = father;
- if ((folderFullName == null) || (folderFullName.isEmpty()))
- return result;
+ if ((folderFullName == null) || (folderFullName.isEmpty())) return result;
else {
regex = File.separator;
- if (regex.equals("\\"))
- regex = "\\\\";
+ if (regex.equals("\\")) regex = "\\\\";
String[] folderHierarchy = folderFullName.split(regex);
for (int i = 0; i < folderHierarchy.length; i++) {
if (!folderHierarchy[i].isEmpty()) {
result = getNamedSubFolder(result, folderHierarchy[i]);
- if (result == null)
- break;
+ if (result == null) break;
}
}
return result;
@@ -272,14 +315,14 @@ private PSTFolder findChildFolder(PSTFolder father, String folderFullName) throw
public void endStoreExtractor() throws MailExtractLibException {
super.endStoreExtractor();
try {
- if (pstFile!=null)
- pstFile.close();
+ if (pstFile != null) pstFile.close();
} catch (IOException e) {
throw new MailExtractLibException("mailextractlib.pst: Can't close temporary file tmpstore", e);
}
- if ((storeFile != null) &&
- !storeFile.delete())
- throw new MailExtractLibException("mailextractlib.pst: Can't delete temporary file tmpstore", null);
+ if ((storeFile != null) && !storeFile.delete()) throw new MailExtractLibException(
+ "mailextractlib.pst: Can't delete temporary file tmpstore",
+ null
+ );
}
/* (non-Javadoc)
@@ -301,7 +344,7 @@ public boolean canExtractObjectsLists() {
/**
* The Constant PST_MN.
*/
- static final byte[] PST_MN = new byte[]{0x21, 0x42, 0x44, 0x4e};
+ static final byte[] PST_MN = new byte[] { 0x21, 0x42, 0x44, 0x4e };
/**
* Gets the verified scheme.
@@ -312,8 +355,6 @@ public boolean canExtractObjectsLists() {
public static String getVerifiedScheme(byte[] content) {
if (hasMagicNumber(content, PST_MN)) {
return "pst";
- } else
- return null;
+ } else return null;
}
-
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/PstStoreFolder.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/PstStoreFolder.java
index 042433c6..07f1fa13 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/PstStoreFolder.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/PstStoreFolder.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.microsoft.pst;
import fr.gouv.vitam.tools.javalibpst.*;
@@ -69,12 +79,9 @@ private PstStoreFolder(StoreExtractor storeExtractor, PSTFolder pstFolder, PstSt
super(storeExtractor);
this.pstFolder = pstFolder;
this.name = pstFolder.getDisplayName();
- if (this.name == null)
- this.name = "";
- if (father.getFullName().isEmpty())
- this.fullName = this.name;
- else
- this.fullName = father.fullName + File.separator + this.name;
+ if (this.name == null) this.name = "";
+ if (father.getFullName().isEmpty()) this.fullName = this.name;
+ else this.fullName = father.fullName + File.separator + this.name;
finalizeStoreFolder(father);
}
@@ -86,8 +93,11 @@ private PstStoreFolder(StoreExtractor storeExtractor, PSTFolder pstFolder, PstSt
* @param rootArchiveUnit Root ArchiveUnit
* @return the LP store folder
*/
- public static PstStoreFolder createRootFolder(PstStoreExtractor storeExtractor, PSTFolder pstFolder,
- ArchiveUnit rootArchiveUnit) {
+ public static PstStoreFolder createRootFolder(
+ PstStoreExtractor storeExtractor,
+ PSTFolder pstFolder,
+ ArchiveUnit rootArchiveUnit
+ ) {
PstStoreFolder result = new PstStoreFolder(storeExtractor, pstFolder);
result.folderArchiveUnit = rootArchiveUnit;
@@ -95,10 +105,13 @@ public static PstStoreFolder createRootFolder(PstStoreExtractor storeExtractor,
}
private void logMessageWarning(String msg, Exception e) throws InterruptedException {
- if (getStoreExtractor().getOptions().warningMsgProblem)
- doProgressLog(getProgressLogger(), MailExtractProgressLogger.WARNING, msg, e);
- else
- doProgressLog(getProgressLogger(), MailExtractProgressLogger.MESSAGE_DETAILS, msg, e);
+ if (getStoreExtractor().getOptions().warningMsgProblem) doProgressLog(
+ getProgressLogger(),
+ MailExtractProgressLogger.WARNING,
+ msg,
+ e
+ );
+ else doProgressLog(getProgressLogger(), MailExtractProgressLogger.MESSAGE_DETAILS, msg, e);
}
private PSTMessage getNextPSTObject(int count) throws MailExtractLibException, InterruptedException {
@@ -111,14 +124,23 @@ private PSTMessage getNextPSTObject(int count) throws MailExtractLibException, I
} catch (IOException e) {
throw new MailExtractLibException("mailextractlib.pst: can't use pst file", e);
} catch (PSTException e) {
- throw new MailExtractLibException("mailextractlib.pst: can't get elements from folder " + getFullName(), e);
+ throw new MailExtractLibException(
+ "mailextractlib.pst: can't get elements from folder " + getFullName(),
+ e
+ );
} catch (Exception e) {
- logMessageWarning("mailextractlib.pst: end folder operation at message " + count
- + "/" + pstFolder.getContentCount() + " in folder " + this.getName(), e);
+ logMessageWarning(
+ "mailextractlib.pst: end folder operation at message " +
+ count +
+ "/" +
+ pstFolder.getContentCount() +
+ " in folder " +
+ this.getName(),
+ e
+ );
error = true;
}
- }
- while (error);
+ } while (error);
return (PSTMessage) po;
}
@@ -131,8 +153,10 @@ private void extractPSTObject(PSTMessage message, int count, boolean writeFlag)
} catch (InterruptedException e) {
throw e;
} catch (Exception e) {
- logMessageWarning("mailextractlib.pst: can't extract contact " + count
- + " in folder " + this.getName(), e);
+ logMessageWarning(
+ "mailextractlib.pst: can't extract contact " + count + " in folder " + this.getName(),
+ e
+ );
}
} else if (message instanceof PSTAppointment) {
try {
@@ -141,8 +165,10 @@ private void extractPSTObject(PSTMessage message, int count, boolean writeFlag)
} catch (InterruptedException e) {
throw e;
} catch (Exception e) {
- logMessageWarning("mailextractlib.pst: can't extract appointment " + count
- + " in folder " + this.getName(), e);
+ logMessageWarning(
+ "mailextractlib.pst: can't extract appointment " + count + " in folder " + this.getName(),
+ e
+ );
}
} else {
try {
@@ -151,8 +177,10 @@ private void extractPSTObject(PSTMessage message, int count, boolean writeFlag)
} catch (InterruptedException e) {
throw e;
} catch (Exception e) {
- logMessageWarning("mailextractlib.pst: can't extract message " + count
- + " in folder " + this.getName(), e);
+ logMessageWarning(
+ "mailextractlib.pst: can't extract message " + count + " in folder " + this.getName(),
+ e
+ );
}
}
}
@@ -177,28 +205,33 @@ protected void doExtractFolderElements(boolean writeFlag) throws MailExtractLibE
while (true) {
final int messageRank = submittedTasks + 1; // Task index
message = getNextPSTObject(messageRank);
- if (message == null)
- break;
+ if (message == null) break;
final PSTMessage msg = message;
completionService.submit(() -> {
extractPSTObject(msg, messageRank, writeFlag);
return null;
});
- submittedTasks=messageRank;
+ submittedTasks = messageRank;
}
// Retrieve the results with a maximum wait of 60 seconds per task
for (int i = 0; i < submittedTasks; i++) {
Future
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.microsoft.pst;
-import fr.gouv.vitam.tools.javalibpst.PSTAppointment;
import fr.gouv.vitam.tools.javalibpst.PSTConversationIndex.ResponseLevel;
import fr.gouv.vitam.tools.javalibpst.PSTException;
import fr.gouv.vitam.tools.javalibpst.PSTMessage;
@@ -37,8 +46,6 @@
import fr.gouv.vitam.tools.mailextractlib.store.microsoft.MicrosoftStoreMessageAttachment;
import java.io.IOException;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@@ -210,10 +217,8 @@ protected UUID getNativeCIGuid() {
protected int getNativeCINumberOfResponseLevels() {
List
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.microsoft.pst;
import fr.gouv.vitam.tools.javalibpst.PSTAttachment;
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/embeddedmsg/PstEmbeddedStoreExtractor.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/embeddedmsg/PstEmbeddedStoreExtractor.java
index d96bd5d5..b41eb9ca 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/embeddedmsg/PstEmbeddedStoreExtractor.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/embeddedmsg/PstEmbeddedStoreExtractor.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.microsoft.pst.embeddedmsg;
import fr.gouv.vitam.tools.javalibpst.PSTMessage;
@@ -48,7 +58,7 @@ public class PstEmbeddedStoreExtractor extends StoreExtractor {
* This is in default list.
*/
public static void subscribeStoreExtractor() {
- addExtractionRelation(null, null,"pst.embeddedmsg", false, PstEmbeddedStoreExtractor.class);
+ addExtractionRelation(null, null, "pst.embeddedmsg", false, PstEmbeddedStoreExtractor.class);
}
// Attachment to complete with decoded form
@@ -65,13 +75,27 @@ public static void subscribeStoreExtractor() {
* @param logger logger used
* @throws MailExtractLibException Any unrecoverable extraction exception (access trouble, major format problems...)
*/
- public PstEmbeddedStoreExtractor(StoreAttachment attachment, ArchiveUnit rootNode,
- StoreExtractorOptions options, StoreExtractor rootStoreExtractor, StoreElement fatherElement, MailExtractProgressLogger logger)
- throws MailExtractLibException {
- super("pst.embeddedmsg://localhost/", "", rootNode.getFullName(), options, rootStoreExtractor, fatherElement, logger);
-
+ public PstEmbeddedStoreExtractor(
+ StoreAttachment attachment,
+ ArchiveUnit rootNode,
+ StoreExtractorOptions options,
+ StoreExtractor rootStoreExtractor,
+ StoreElement fatherElement,
+ MailExtractProgressLogger logger
+ ) throws MailExtractLibException {
+ super(
+ "pst.embeddedmsg://localhost/",
+ "",
+ rootNode.getFullName(),
+ options,
+ rootStoreExtractor,
+ fatherElement,
+ logger
+ );
this.attachment = attachment;
- setRootFolder(PstEmbeddedStoreFolder.createRootFolder((PSTMessage) attachment.getStoreContent(), this, rootNode));
+ setRootFolder(
+ PstEmbeddedStoreFolder.createRootFolder((PSTMessage) attachment.getStoreContent(), this, rootNode)
+ );
}
/* (non-Javadoc)
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/embeddedmsg/PstEmbeddedStoreFolder.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/embeddedmsg/PstEmbeddedStoreFolder.java
index 3c0a4d27..19172500 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/embeddedmsg/PstEmbeddedStoreFolder.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/embeddedmsg/PstEmbeddedStoreFolder.java
@@ -1,36 +1,46 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.store.microsoft.pst.embeddedmsg;
import fr.gouv.vitam.tools.javalibpst.PSTMessage;
+import fr.gouv.vitam.tools.mailextractlib.core.StoreAttachment;
import fr.gouv.vitam.tools.mailextractlib.core.StoreExtractor;
import fr.gouv.vitam.tools.mailextractlib.core.StoreFolder;
-import fr.gouv.vitam.tools.mailextractlib.core.StoreAttachment;
import fr.gouv.vitam.tools.mailextractlib.nodes.ArchiveUnit;
import fr.gouv.vitam.tools.mailextractlib.store.microsoft.pst.PstStoreMessage;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractLibException;
@@ -50,7 +60,6 @@ public class PstEmbeddedStoreFolder extends StoreFolder {
// for the root folder
private PstEmbeddedStoreFolder(PSTMessage content, StoreExtractor storeExtractor) {
super(storeExtractor);
-
this.lpStoreMessage = new PstStoreMessage(this, content);
this.fullName = "";
this.name = "";
@@ -67,8 +76,11 @@ private PstEmbeddedStoreFolder(PSTMessage content, StoreExtractor storeExtractor
* Root ArchiveUnit
* @return the LP store folder
*/
- public static PstEmbeddedStoreFolder createRootFolder(PSTMessage content, PstEmbeddedStoreExtractor storeExtractor,
- ArchiveUnit rootArchiveUnit) {
+ public static PstEmbeddedStoreFolder createRootFolder(
+ PSTMessage content,
+ PstEmbeddedStoreExtractor storeExtractor,
+ ArchiveUnit rootArchiveUnit
+ ) {
PstEmbeddedStoreFolder result = new PstEmbeddedStoreFolder(content, storeExtractor);
result.folderArchiveUnit = rootArchiveUnit;
@@ -89,8 +101,9 @@ protected void doExtractFolderElements(boolean writeFlag) throws MailExtractLibE
StoreAttachment attachment = ((PstEmbeddedStoreExtractor) storeExtractor).getAttachment();
attachment.setStoreContent(lpStoreMessage.getMimeContent());
attachment.setMimeType("message/rfc822");
- if ((attachment.getName() == null) || attachment.getName().isEmpty())
- attachment.setName(lpStoreMessage.getSubject() + ".eml");
+ if ((attachment.getName() == null) || attachment.getName().isEmpty()) attachment.setName(
+ lpStoreMessage.getSubject() + ".eml"
+ );
}
/*
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/embeddedmsg/package-info.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/embeddedmsg/package-info.java
index 99d4aa59..fcca9d5e 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/embeddedmsg/package-info.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/embeddedmsg/package-info.java
@@ -1,4 +1,41 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.
+ */
/**
* Provides all classes to implement a Microsoft .pst embedded message extraction with libpst library.
*/
-package fr.gouv.vitam.tools.mailextractlib.store.microsoft.pst.embeddedmsg;
\ No newline at end of file
+package fr.gouv.vitam.tools.mailextractlib.store.microsoft.pst.embeddedmsg;
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/package-info.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/package-info.java
index 2e209ce1..aacced3f 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/package-info.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/microsoft/pst/package-info.java
@@ -1,3 +1,40 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.
+ */
/**
* Provides all classes to implement a Microsoft .pst messages container with
* libpst library.
@@ -13,4 +50,4 @@
*
* Thanks to Richard Johnson http://github.com/rjohnsondev
*/
-package fr.gouv.vitam.tools.mailextractlib.store.microsoft.pst;
\ No newline at end of file
+package fr.gouv.vitam.tools.mailextractlib.store.microsoft.pst;
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/DateRange.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/DateRange.java
index 6256e373..704a3e1d 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/DateRange.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/DateRange.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.utils;
import java.text.SimpleDateFormat;
@@ -39,6 +49,7 @@
* it directly contains and of the start and end dates of all its subfolders.
*/
public class DateRange {
+
private Date start, end;
/**
@@ -76,7 +87,7 @@ public DateRange() {
* Date
* @return the ISO date string
*/
- static public String getISODateString(Date date) {
+ public static String getISODateString(Date date) {
if (date == null) {
return null;
} else {
@@ -124,10 +135,8 @@ public void extendRange(Date date) {
start = date;
end = date;
} else {
- if (start.after(date))
- start = date;
- else if (end.before(date))
- end = date;
+ if (start.after(date)) start = date;
+ else if (end.before(date)) end = date;
}
}
}
@@ -145,10 +154,8 @@ public void extendRange(DateRange dateRange) {
start = dateRange.start;
end = dateRange.end;
} else {
- if (start.after(dateRange.start))
- start = dateRange.start;
- if (end.before(dateRange.end))
- end = dateRange.end;
+ if (start.after(dateRange.start)) start = dateRange.start;
+ if (end.before(dateRange.end)) end = dateRange.end;
}
}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/HtmlAndXmlEscape.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/HtmlAndXmlEscape.java
index 2b40bee6..923a70f3 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/HtmlAndXmlEscape.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/HtmlAndXmlEscape.java
@@ -1,30 +1,40 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.utils;
import java.util.Map;
@@ -39,7 +49,6 @@
*/
public class HtmlAndXmlEscape {
-
/**
* Escapes a given string for XML 1.0 compliance.
*
@@ -77,7 +86,7 @@ public static String escapeXml(String input) {
// Ensure a valid low surrogate exists
if (i + 1 < length && Character.isLowSurrogate(input.charAt(i + 1))) {
sb.append(c).append(input.charAt(i + 1));
- i++; // Skip to the low surrogate
+ i++; // Skip to the low surrogate
continue;
}
// If unmatched high surrogate, skip it
@@ -89,10 +98,11 @@ public static String escapeXml(String input) {
continue;
}
// Invalid characters according to the XML 1.0 specification
- if ((c <= 0x1F && c != '\t' && c != '\n' && c != '\r') ||
- (c >= 0x7F && c <= 0x84) ||
- (c >= 0x86 && c <= 0x9F))
- continue; // Ignore invalid characters
+ if (
+ (c <= 0x1F && c != '\t' && c != '\n' && c != '\r') ||
+ (c >= 0x7F && c <= 0x84) ||
+ (c >= 0x86 && c <= 0x9F)
+ ) continue; // Ignore invalid characters
switch (c) {
case '&':
@@ -119,262 +129,262 @@ public static String escapeXml(String input) {
}
private static final Map
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.utils;
/**
@@ -45,9 +55,9 @@ public MailExtractLibException() {
super();
}
-/*
- */
-/**
+ /*
+ */
+ /**
* Instantiates a new extraction exception.
*
* @param message
@@ -59,7 +69,7 @@ public MailExtractLibException(String message) {
}
*/
-/**
+ /**
* Instantiates a new extraction exception.
*
* @param cause
@@ -95,8 +105,12 @@ public MailExtractLibException(String message, Throwable cause) {
* @param writableStackTrace
* the writable stack trace
*/
- public MailExtractLibException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ public MailExtractLibException(
+ String message,
+ Throwable cause,
+ boolean enableSuppression,
+ boolean writableStackTrace
+ ) {
super(message, cause, enableSuppression, writableStackTrace);
}
-
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/MailExtractProgressLogger.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/MailExtractProgressLogger.java
index f76b3050..08910c05 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/MailExtractProgressLogger.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/MailExtractProgressLogger.java
@@ -1,29 +1,39 @@
/**
- * Copyright French Prime minister Office/DINSIC/Vitam Program (2015-2019)
- *
- * contact.vitam@programmevitam.fr
- *
- * This software is developed as a validation helper tool, for constructing Submission Information Packages (archives
- * sets) in the Vitam 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 archiveDeliveryRequestReply 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.utils;
@@ -77,7 +87,6 @@ public class MailExtractProgressLogger {
*/
@FunctionalInterface
public interface ProgressLogFunc {
-
/**
* Do progress log.
*
@@ -90,22 +99,22 @@ public interface ProgressLogFunc {
/**
* The progress log func.
*/
- final private ProgressLogFunc progressLogFunc;
+ private final ProgressLogFunc progressLogFunc;
/**
* The logger.
*/
- final private Logger logger;
+ private final Logger logger;
/**
* The number used to determine if an accumulation as to be a progress log or not.
*/
- final private int step;
+ private final int step;
/**
* The number of seconds expected between to "step" log publication.
*/
- final private int stepDuration;
+ private final int stepDuration;
/**
* The last "step" log epoch seconds.
@@ -186,7 +195,13 @@ public MailExtractProgressLogger(Logger logger, int progressLogLevel, ProgressLo
* @param step the step value
* @param stepDuration the step duration
*/
- public MailExtractProgressLogger(Logger logger, int progressLogLevel, ProgressLogFunc progressConsumer, int step, int stepDuration) {
+ public MailExtractProgressLogger(
+ Logger logger,
+ int progressLogLevel,
+ ProgressLogFunc progressConsumer,
+ int step,
+ int stepDuration
+ ) {
this.progressLogFunc = progressConsumer;
this.logger = logger;
this.step = step;
@@ -209,8 +224,15 @@ public MailExtractProgressLogger(Logger logger, int progressLogLevel, ProgressLo
* @param stepDuration the maximum time duration in seconds between progress updates
* @param progressFuncLogLevel the progress log level specifically for the progress function
*/
- public MailExtractProgressLogger(Logger logger, int progressLogLevel, ProgressLogFunc progressConsumer,
- int step, int stepDuration, int progressFuncLogLevel, int progressFuncStep) {
+ public MailExtractProgressLogger(
+ Logger logger,
+ int progressLogLevel,
+ ProgressLogFunc progressConsumer,
+ int step,
+ int stepDuration,
+ int progressFuncLogLevel,
+ int progressFuncStep
+ ) {
this.progressLogFunc = progressConsumer;
this.logger = logger;
this.step = step;
@@ -247,15 +269,14 @@ public boolean getDebugFlag() {
* @param e the exception
* @return the messages stack string
*/
- static public String getMessagesStackString(Throwable e) {
+ public static String getMessagesStackString(Throwable e) {
String result;
result = "-> " + e.getMessage();
- if (e.getCause() instanceof Exception)
- result += "\n" + getMessagesStackString((Exception) e.getCause());
+ if (e.getCause() instanceof Exception) result += "\n" + getMessagesStackString((Exception) e.getCause());
return result;
}
- static private String getJavaStackString(Throwable e) {
+ private static String getJavaStackString(Throwable e) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
e.printStackTrace(ps);
@@ -268,11 +289,11 @@ static private String getJavaStackString(Throwable e) {
* @param e the exception
* @return the all java stack string
*/
- static public String getAllJavaStackString(Throwable e) {
+ public static String getAllJavaStackString(Throwable e) {
String result;
result = getJavaStackString(e);
- if (e.getCause() instanceof Exception)
- result += "\n------------------------------------\n" + getJavaStackString((Exception) e.getCause());
+ if (e.getCause() instanceof Exception) result +=
+ "\n------------------------------------\n" + getJavaStackString((Exception) e.getCause());
return result;
}
@@ -286,18 +307,21 @@ static public String getAllJavaStackString(Throwable e) {
* @param log the log
* @param e the exception
*/
- static public void doProgressLogWithoutInterruption(MailExtractProgressLogger mepl, int level, String log, Throwable e) {
+ public static void doProgressLogWithoutInterruption(
+ MailExtractProgressLogger mepl,
+ int level,
+ String log,
+ Throwable e
+ ) {
if (mepl != null) {
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (mepl) {
if (level <= mepl.progressLogLevel) {
- if (e != null)
- log += "\n" + getMessagesStackString(e);
+ if (e != null) log += "\n" + getMessagesStackString(e);
if ((mepl.progressLogFunc != null) && (level <= mepl.progressFuncLogLevel)) {
mepl.progressLogFunc.doProgressLog(-1, log);
}
- if ((e != null) && mepl.debugFlag)
- log += "\n" + getAllJavaStackString(e);
+ if ((e != null) && mepl.debugFlag) log += "\n" + getAllJavaStackString(e);
mepl.log(level, log);
}
}
@@ -313,7 +337,7 @@ static public void doProgressLogWithoutInterruption(MailExtractProgressLogger me
* @param log the log
* @param e the exception
*/
- static public void doProgressLogIfDebug(MailExtractProgressLogger mepl, String log, Throwable e) {
+ public static void doProgressLogIfDebug(MailExtractProgressLogger mepl, String log, Throwable e) {
if ((mepl != null) && mepl.debugFlag) {
doProgressLogWithoutInterruption(mepl, GLOBAL, log, e);
}
@@ -330,7 +354,8 @@ static public void doProgressLogIfDebug(MailExtractProgressLogger mepl, String l
* @param e the exception
* @throws InterruptedException the interrupted exception
*/
- static public void doProgressLog(MailExtractProgressLogger mepl, int level, String log, Throwable e) throws InterruptedException {
+ public static void doProgressLog(MailExtractProgressLogger mepl, int level, String log, Throwable e)
+ throws InterruptedException {
if (mepl != null) {
doProgressLogWithoutInterruption(mepl, level, log, e);
Thread.sleep(1);
@@ -346,7 +371,8 @@ static public void doProgressLog(MailExtractProgressLogger mepl, int level, Stri
* @param log the log that can contain %count key replaced by the number
* @throws InterruptedException the interrupted exception
*/
- static public void doProgressLogOneMoreCountedObject(MailExtractProgressLogger mepl, int level, String log) throws InterruptedException {
+ public static void doProgressLogOneMoreCountedObject(MailExtractProgressLogger mepl, int level, String log)
+ throws InterruptedException {
if (mepl != null) {
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (mepl) {
@@ -355,8 +381,12 @@ static public void doProgressLogOneMoreCountedObject(MailExtractProgressLogger m
int rank = mepl.counter.addAndGet(1);
if (mepl.stepDuration < nowEpochSeconds - mepl.previousStepEpochSeconds) {
log = log.replace("%count", Integer.toString(rank));
- if ((mepl.progressLogFunc != null) && (level <= mepl.progressFuncLogLevel))
- mepl.progressLogFunc.doProgressLog(rank, (rank % mepl.progressFuncStep == 0 ? "" : "* ") + log);
+ if (
+ (mepl.progressLogFunc != null) && (level <= mepl.progressFuncLogLevel)
+ ) mepl.progressLogFunc.doProgressLog(
+ rank,
+ (rank % mepl.progressFuncStep == 0 ? "" : "* ") + log
+ );
mepl.log(level, log);
Thread.sleep(1);
mepl.previousStepEpochSeconds = nowEpochSeconds;
@@ -368,8 +398,7 @@ static public void doProgressLogOneMoreCountedObject(MailExtractProgressLogger m
mepl.log(level, countLog);
}
if ((mepl.progressLogFunc != null) && (rank % mepl.progressFuncStep) == 0) {
- if (countLog == null)
- countLog = log.replace("%count", Integer.toString(rank));
+ if (countLog == null) countLog = log.replace("%count", Integer.toString(rank));
mepl.progressLogFunc.doProgressLog(rank, countLog);
Thread.sleep(1);
}
@@ -385,9 +414,8 @@ static public void doProgressLogOneMoreCountedObject(MailExtractProgressLogger m
* @return the string
*/
public static String readableFileSize(long size) {
- if (size <= 0)
- return "0";
- final String[] units = new String[]{"B", "kB", "MB", "GB", "TB"};
+ if (size <= 0) return "0";
+ final String[] units = new String[] { "B", "kB", "MB", "GB", "TB" };
int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups];
}
@@ -419,7 +447,6 @@ public String getLevelName() {
return getMarker(progressLogLevel).getName();
}
-
/**
* Gets the current progress log level.
*
@@ -440,14 +467,12 @@ public void setProgressLogLevel(int progressLogLevel) {
private void log(int level, String message) {
if (level <= progressLogLevel) {
- if (logger != null)
- logger.info(getMarker(level), message);
+ if (logger != null) logger.info(getMarker(level), message);
}
}
/**
* Close.
*/
- public void close() {
- }
+ public void close() {}
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/RFC822Headers.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/RFC822Headers.java
index 0b16c63f..8a9b1341 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/RFC822Headers.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/RFC822Headers.java
@@ -1,34 +1,43 @@
/**
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.utils;
import fr.gouv.vitam.tools.mailextractlib.core.StoreMessage;
-
import jakarta.mail.MessagingException;
import jakarta.mail.internet.AddressException;
import jakarta.mail.internet.InternetAddress;
@@ -62,14 +71,12 @@ public class RFC822Headers extends InternetHeaders {
* @return the bais
*/
static ByteArrayInputStream getBAIS(String headersString) {
- if (headersString == null)
- headersString = "";
+ if (headersString == null) headersString = "";
headersString += "\n\n";
ByteArrayInputStream bais = null;
try {
bais = new ByteArrayInputStream(headersString.getBytes("UTF-8"));
- } catch (UnsupportedEncodingException ignored) {
- }
+ } catch (UnsupportedEncodingException ignored) {}
return bais;
}
@@ -92,17 +99,15 @@ public RFC822Headers(String headersString, StoreMessage message) throws Messagin
* @param line the line
* @return the header value
*/
-// utility function to get the value part of an header string
+ // utility function to get the value part of an header string
public static String getHeaderValue(String line) {
int i = line.indexOf(':');
- if (i < 0)
- return line;
+ if (i < 0) return line;
// skip whitespace after ':'
int j;
for (j = i + 1; j < line.length(); j++) {
char c = line.charAt(j);
- if (!(c == ' ' || c == '\t' || c == '\r' || c == '\n'))
- break;
+ if (!(c == ' ' || c == '\t' || c == '\r' || c == '\n')) break;
}
return line.substring(j);
}
@@ -118,34 +123,28 @@ public List
@@ -198,7 +194,8 @@ public List
- * 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib.utils;
import jakarta.activation.DataSource;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -59,8 +70,7 @@ public class RawDataSource implements DataSource {
* the name
*/
public RawDataSource(byte[] rawContent, String mimeType, String name) {
- if (rawContent == null)
- rawContent = new byte[0];
+ if (rawContent == null) rawContent = new byte[0];
inputStream = new ByteArrayInputStream(rawContent);
this.mimeType = mimeType;
this.name = name;
@@ -119,5 +129,4 @@ public String getContentType() {
public String getName() {
return name;
}
-
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/package-info.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/package-info.java
index f1cda5b5..536bbfda 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/package-info.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/utils/package-info.java
@@ -1,4 +1,41 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.
+ */
/**
* Utility classes.
*/
-package fr.gouv.vitam.tools.mailextractlib.utils;
\ No newline at end of file
+package fr.gouv.vitam.tools.mailextractlib.utils;
diff --git a/mailextractlib/src/test/java/fr/gouv/vitam/tools/mailextractlib/AllTests.java b/mailextractlib/src/test/java/fr/gouv/vitam/tools/mailextractlib/AllTests.java
index 0dcced30..30970502 100644
--- a/mailextractlib/src/test/java/fr/gouv/vitam/tools/mailextractlib/AllTests.java
+++ b/mailextractlib/src/test/java/fr/gouv/vitam/tools/mailextractlib/AllTests.java
@@ -1,3 +1,40 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.mailextractlib;
import ch.qos.logback.classic.LoggerContext;
@@ -8,7 +45,6 @@
import fr.gouv.vitam.tools.mailextractlib.core.StoreExtractor;
import fr.gouv.vitam.tools.mailextractlib.utils.MailExtractProgressLogger;
import org.apache.commons.io.FileUtils;
-import org.junit.jupiter.api.BeforeAll;
import org.slf4j.LoggerFactory;
import java.io.File;
@@ -21,11 +57,9 @@
import static org.assertj.core.api.Assertions.assertThat;
public interface AllTests {
-
static void initializeTests(String testName) throws IOException {
- File testDir=new File("target/tmpJUnit/"+testName);
- if (testDir.isDirectory())
- FileUtils.deleteDirectory(testDir);
+ File testDir = new File("target/tmpJUnit/" + testName);
+ if (testDir.isDirectory()) FileUtils.deleteDirectory(testDir);
StoreExtractor.initDefaultExtractors(false);
}
@@ -111,7 +145,6 @@ public static String removeColumnsAndSortLines(String input, int[] columnsToRemo
return String.join("\n", lineList);
}
-
/**
* Removes the specified columns from each line of a given array of CSV strings.
*
@@ -144,7 +177,11 @@ static String[] removeColumnsFromLines(String[] lines, int[] columnsToRemove) {
return result;
}
- static public void assertThatDirectoriesContainSameFilesWithExtensions(String expectedPath, String resultPath, String[] extensions) throws IOException {
+ public static void assertThatDirectoriesContainSameFilesWithExtensions(
+ String expectedPath,
+ String resultPath,
+ String[] extensions
+ ) throws IOException {
// Test data: paths of directories to compare
File expectedDir = new File(expectedPath); // Expected directory
File actualDir = new File(resultPath); // Produced directory
@@ -157,7 +194,7 @@ static public void assertThatDirectoriesContainSameFilesWithExtensions(String ex
compareDirectories(expectedDir, actualDir, extensions);
}
- static private void compareDirectories(File dir1, File dir2, String[] extensions) throws IOException {
+ private static void compareDirectories(File dir1, File dir2, String[] extensions) throws IOException {
// List the files in each directory
File[] dir1Files = dir1.listFiles();
File[] dir2Files = dir2.listFiles();
@@ -165,42 +202,60 @@ static private void compareDirectories(File dir1, File dir2, String[] extensions
// Filter with extensions
if (extensions != null) {
dir1Files = Arrays.stream(dir1Files)
- .filter(file -> file.isDirectory() || Arrays.stream(extensions)
- .anyMatch(ext -> file.getName().toLowerCase(Locale.ROOT).endsWith("." + ext.toLowerCase(Locale.ROOT))))
- .toArray(File[]::new);
+ .filter(
+ file ->
+ file.isDirectory() ||
+ Arrays.stream(extensions).anyMatch(
+ ext -> file.getName().toLowerCase(Locale.ROOT).endsWith("." + ext.toLowerCase(Locale.ROOT))
+ )
+ )
+ .toArray(File[]::new);
dir2Files = Arrays.stream(dir2Files)
- .filter(file -> file.isDirectory() || Arrays.stream(extensions)
- .anyMatch(ext -> file.getName().toLowerCase(Locale.ROOT).endsWith("." + ext.toLowerCase(Locale.ROOT))))
- .toArray(File[]::new);
+ .filter(
+ file ->
+ file.isDirectory() ||
+ Arrays.stream(extensions).anyMatch(
+ ext -> file.getName().toLowerCase(Locale.ROOT).endsWith("." + ext.toLowerCase(Locale.ROOT))
+ )
+ )
+ .toArray(File[]::new);
}
// Ensure both directories are not null
assertThat(dir1Files)
- .as("Expected directory files (%s) have to be not null", dir1.getAbsolutePath())
- .isNotNull();
- assertThat(dir2Files)
- .as("Actual directory files (%s) have to be not null", dir2.getAbsolutePath())
- .isNotNull();
+ .as("Expected directory files (%s) have to be not null", dir1.getAbsolutePath())
+ .isNotNull();
+ assertThat(dir2Files).as("Actual directory files (%s) have to be not null", dir2.getAbsolutePath()).isNotNull();
// Sort files to ensure consistent order (avoiding dependence on file system order)
- Arrays.sort(dir1Files, new Comparator
- * contact.vitam@programmevitam.fr
- *
- * This software is developed as a validation helper tool, for constructing Submission Information Packages (archives
- * sets) in the Vitam 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 archiveTransfer 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.resip.app;
@@ -158,63 +168,104 @@ private static Options createOptions() {
Option help = new Option("h", "help", false, "help");
options.addOption(help);
- Option diskimport = new Option("d", "diskimport", true,
+ Option diskimport = new Option(
+ "d",
+ "diskimport",
+ true,
"importe une hiérarchie d'AU depuis une hiérarchie de répertoires et fichiers avec en " +
- "argument le répertoire racine");
+ "argument le répertoire racine"
+ );
options.addOption(diskimport);
- Option exclude = new Option("e", "exclude", true, "de l'import par diskimport les fichiers" +
- " les fichiers dont le nom sont conformes aux expressions régulières contenue sur chaque ligne du fichier");
+ Option exclude = new Option(
+ "e",
+ "exclude",
+ true,
+ "de l'import par diskimport les fichiers" +
+ " les fichiers dont le nom sont conformes aux expressions régulières contenue sur chaque ligne du fichier"
+ );
options.addOption(exclude);
- Option listimport = new Option("l", "listimport", true,
+ Option listimport = new Option(
+ "l",
+ "listimport",
+ true,
"importe une hiérarchie d'AU depuis un ensemble de répertoires et de fichiers dont " +
- "la hiérarchie et les métadonnées sont décrits dans un csv");
+ "la hiérarchie et les métadonnées sont décrits dans un csv"
+ );
options.addOption(listimport);
- Option sipimport = new Option("s", "sipimport", true,
- "importe une hiérarchie d'AU depuis un SIP SEDA avec en argument le nom du fichier");
+ Option sipimport = new Option(
+ "s",
+ "sipimport",
+ true,
+ "importe une hiérarchie d'AU depuis un SIP SEDA avec en argument le nom du fichier"
+ );
options.addOption(sipimport);
- Option context = new Option("c", "context", true,
- "défini les informations globales utiles à la génération du SIP (MessageIdentifier...) dans le fichier indiqué");
+ Option context = new Option(
+ "c",
+ "context",
+ true,
+ "défini les informations globales utiles à la génération du SIP (MessageIdentifier...) dans le fichier indiqué"
+ );
options.addOption(context);
- Option generatesip = new Option("g", "generatesip", true,
- "génère un paquet SEDA SIP de la structure importée avec en argument le nom du fichier à " +
- "générer");
+ Option generatesip = new Option(
+ "g",
+ "generatesip",
+ true,
+ "génère un paquet SEDA SIP de la structure importée avec en argument le nom du fichier à " + "générer"
+ );
options.addOption(generatesip);
- Option manifest = new Option("m", "manifest", true,
- "génère le manifest SEDA de la structure importée avec en argument le nom du fichier à " +
- "générer");
+ Option manifest = new Option(
+ "m",
+ "manifest",
+ true,
+ "génère le manifest SEDA de la structure importée avec en argument le nom du fichier à " + "générer"
+ );
options.addOption(manifest);
- Option nolink = new Option("n", "nolink", false,
- "indique qu'il faut ignorer les liens symboliques et raccourcis");
+ Option nolink = new Option(
+ "n",
+ "nolink",
+ false,
+ "indique qu'il faut ignorer les liens symboliques et raccourcis"
+ );
options.addOption(nolink);
- Option workdir = new Option("w", "workdir", true,
- "désigne le répertoire de travail pour les logs, les répertoires d'extraction temporaire");
+ Option workdir = new Option(
+ "w",
+ "workdir",
+ true,
+ "désigne le répertoire de travail pour les logs, les répertoires d'extraction temporaire"
+ );
options.addOption(workdir);
- Option command = new Option("x", "xcommand", false, "ne lance pas l'interface " +
- "graphique");
+ Option command = new Option("x", "xcommand", false, "ne lance pas l'interface " + "graphique");
options.addOption(command);
- Option hierarchical = new Option("h", "hierarchical", false,
- "génère les ArchiveUnits en mode hiérarchique dans le manifest SEDA");
+ Option hierarchical = new Option(
+ "h",
+ "hierarchical",
+ false,
+ "génère les ArchiveUnits en mode hiérarchique dans le manifest SEDA"
+ );
options.addOption(hierarchical);
Option indented = new Option("i", "indented", false, "génère le manifest SEDA en XML indenté");
options.addOption(indented);
- Option verbatim = new Option("v", "verbatim", true,
- "niveau de log (OFF|ERROR|GLOBAL|STEP|OBJECTS_GROUP|OBJECTS|OBJECTS_WARNINGS)");
+ Option verbatim = new Option(
+ "v",
+ "verbatim",
+ true,
+ "niveau de log (OFF|ERROR|GLOBAL|STEP|OBJECTS_GROUP|OBJECTS|OBJECTS_WARNINGS)"
+ );
options.addOption(verbatim);
- Option sedaversion = new Option("V", "sedaversion", true,
- "sous-version du SEDA 2 (1|2), à 1 par défaut");
+ Option sedaversion = new Option("V", "sedaversion", true, "sous-version du SEDA 2 (1|2), à 1 par défaut");
options.addOption(sedaversion);
return options;
@@ -235,9 +286,7 @@ private static String[] importStringArray(String filename) throws IOException {
* @param args the arguments
* @throws ResipException the resip exception
*/
- public static void main(String[] args) throws
- ResipException {
-
+ public static void main(String[] args) throws ResipException {
System.out.println("Resip launched");
EventBus.subscribe(SedaVersionChangedEvent.class, event -> SedaContext.setVersion(event.getNewVersion()));
@@ -269,34 +318,44 @@ public static void main(String[] args) throws
List
- * contact.vitam@programmevitam.fr
- *
- * This software is developed as a validation helper tool, for constructing Submission Information Packages (archives
- * sets) in the Vitam 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 archiveTransfer 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.resip.app;
@@ -45,7 +55,6 @@
import fr.gouv.vitam.tools.resip.threads.ImportThread;
import fr.gouv.vitam.tools.resip.utils.ResipException;
import fr.gouv.vitam.tools.resip.utils.ResipLogger;
-import fr.gouv.vitam.tools.sedalib.core.seda.SedaContext;
import fr.gouv.vitam.tools.sedalib.core.seda.SedaVersion;
import fr.gouv.vitam.tools.sedalib.droid.DroidIdentifier;
import fr.gouv.vitam.tools.sedalib.utils.SEDALibException;
@@ -84,13 +93,13 @@ public class ResipGraphicApp implements ActionListener, Runnable {
/**
* The constant theApp.
*/
-// Uniq instance. */
+ // Uniq instance. */
private static ResipGraphicApp theApp = null;
/**
* The Launch creation context.
*/
-// Data elements. */
+ // Data elements. */
public CreationContext launchCreationContext;
/**
* The Current work.
@@ -116,7 +125,7 @@ public class ResipGraphicApp implements ActionListener, Runnable {
/**
* The Main window.
*/
-// GUI elements. */
+ // GUI elements. */
public static MainWindow mainWindow;
// MainWindow menu elements dis/enabled depending on work state and used by controller. */
@@ -129,7 +138,7 @@ public class ResipGraphicApp implements ActionListener, Runnable {
/**
* The Import thread running.
*/
-// Thread control elements. */
+ // Thread control elements. */
public boolean importThreadRunning;
/**
* The Add thread running.
@@ -143,7 +152,7 @@ public class ResipGraphicApp implements ActionListener, Runnable {
/**
* The Search dialog.
*/
-// Dialogs elements. */
+ // Dialogs elements. */
public SearchDialog searchDialog;
/**
* The Technical search dialog.
@@ -171,25 +180,22 @@ public class ResipGraphicApp implements ActionListener, Runnable {
* @throws ResipException the resip exception
*/
public ResipGraphicApp(CreationContext creationContext) throws ResipException {
- EventBus.subscribe(
- SedaVersionChangedEvent.class,
- event -> this.sedaVersion = event.getNewVersion()
- );
+ EventBus.subscribe(SedaVersionChangedEvent.class, event -> this.sedaVersion = event.getNewVersion());
try {
- if (System.getProperty("os.name").toLowerCase().contains("win"))
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- else
- UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
- } catch (IllegalAccessException | InstantiationException |
- UnsupportedLookAndFeelException | ClassNotFoundException e) {
+ if (System.getProperty("os.name").toLowerCase().contains("win")) UIManager.setLookAndFeel(
+ UIManager.getSystemLookAndFeelClassName()
+ );
+ else UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
+ } catch (
+ IllegalAccessException | InstantiationException | UnsupportedLookAndFeelException | ClassNotFoundException e
+ ) {
getGlobalLogger().logIfDebug("Graphic env error", null);
}
System.out.println("Resip GraphicApp launched");
- if (theApp != null)
- throw new ResipException("L'application a déjà été lancée");
+ if (theApp != null) throw new ResipException("L'application a déjà été lancée");
theApp = this;
// inner variables
@@ -206,7 +212,8 @@ public ResipGraphicApp(CreationContext creationContext) throws ResipException {
this.treatmentParameters = new TreatmentParameters(Preferences.getInstance());
getGlobalLogger().setDebugFlag(interfaceParameters.isDebugFlag());
- getGlobalLogger().logIfDebug("Resip prefs accessed from " + Preferences.getInstance().getPrefPropertiesFilename(), null);
+ getGlobalLogger()
+ .logIfDebug("Resip prefs accessed from " + Preferences.getInstance().getPrefPropertiesFilename(), null);
// identification objects initialization
try {
@@ -230,11 +237,11 @@ public void run() {
this.duplicatesWindow = new DuplicatesWindow();
currentWork = null;
- if ((launchCreationContext instanceof DiskImportContext) ||
- (launchCreationContext instanceof SIPImportContext))
- importWork(launchCreationContext);
- else
- mainWindow.load();
+ if (
+ (launchCreationContext instanceof DiskImportContext) ||
+ (launchCreationContext instanceof SIPImportContext)
+ ) importWork(launchCreationContext);
+ else mainWindow.load();
MailImportContext mic = new MailImportContext(Preferences.getInstance());
StoreExtractor.initDefaultExtractors(mic.isAllowsExternalToolsForTextExtraction());
@@ -242,7 +249,6 @@ public void run() {
getGlobalLogger().log(ResipLogger.ERROR, "Erreur fatale, exécution interrompue", e);
System.exit(1);
}
-
}
/**
@@ -279,21 +285,30 @@ public JMenuBar createMenu() {
saveMenuItem = new JMenuItem("Sauver");
saveMenuItem.addActionListener(this);
- saveMenuItem.setAccelerator(KeyStroke.getKeyStroke('S', Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()));
+ saveMenuItem.setAccelerator(
+ KeyStroke.getKeyStroke('S', Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx())
+ );
saveMenuItem.setEnabled(false);
actionByMenuItem.put(saveMenuItem, "SaveWork");
fileMenu.add(saveMenuItem);
saveAsMenuItem = new JMenuItem("Sauver sous...");
saveAsMenuItem.addActionListener(this);
- saveAsMenuItem.setAccelerator(KeyStroke.getKeyStroke('S', InputEvent.SHIFT_DOWN_MASK + Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()));
+ saveAsMenuItem.setAccelerator(
+ KeyStroke.getKeyStroke(
+ 'S',
+ InputEvent.SHIFT_DOWN_MASK + Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()
+ )
+ );
saveAsMenuItem.setEnabled(false);
actionByMenuItem.put(saveAsMenuItem, "SaveAsWork");
fileMenu.add(saveAsMenuItem);
closeMenuItem = new JMenuItem("Fermer");
closeMenuItem.addActionListener(this);
- closeMenuItem.setAccelerator(KeyStroke.getKeyStroke('W', Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()));
+ closeMenuItem.setAccelerator(
+ KeyStroke.getKeyStroke('W', Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx())
+ );
closeMenuItem.setEnabled(false);
actionByMenuItem.put(closeMenuItem, "CloseWork");
fileMenu.add(closeMenuItem);
@@ -344,7 +359,12 @@ public JMenuBar createMenu() {
menuItem = new JMenuItem("Chercher des objets...");
menuItem.addActionListener(this);
- menuItem.setAccelerator(KeyStroke.getKeyStroke('F', InputEvent.SHIFT_DOWN_MASK + Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()));
+ menuItem.setAccelerator(
+ KeyStroke.getKeyStroke(
+ 'F',
+ InputEvent.SHIFT_DOWN_MASK + Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()
+ )
+ );
actionByMenuItem.put(menuItem, "TechnicalSearch");
treatMenu.add(menuItem);
@@ -382,19 +402,33 @@ public JMenuBar createMenu() {
sedaValidationMenuItem = new JMenuItem("Vérifier la conformité " + sedaVersion.displayString() + "...");
sedaValidationMenuItem.addActionListener(this);
- sedaValidationMenuItem.setAccelerator(KeyStroke.getKeyStroke('R', Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()));
+ sedaValidationMenuItem.setAccelerator(
+ KeyStroke.getKeyStroke('R', Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx())
+ );
actionByMenuItem.put(sedaValidationMenuItem, "CheckSEDASchema");
treatMenu.add(sedaValidationMenuItem);
- sedaProfileValidationMenuItem = new JMenuItem("Vérifier la conformité à un profil " + sedaVersion.displayString() + "...");
+ sedaProfileValidationMenuItem = new JMenuItem(
+ "Vérifier la conformité à un profil " + sedaVersion.displayString() + "..."
+ );
sedaProfileValidationMenuItem.addActionListener(this);
- sedaProfileValidationMenuItem.setAccelerator(KeyStroke.getKeyStroke('R', InputEvent.SHIFT_DOWN_MASK + Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()));
+ sedaProfileValidationMenuItem.setAccelerator(
+ KeyStroke.getKeyStroke(
+ 'R',
+ InputEvent.SHIFT_DOWN_MASK + Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()
+ )
+ );
actionByMenuItem.put(sedaProfileValidationMenuItem, "CheckSpecificSEDASchemaProfile");
treatMenu.add(sedaProfileValidationMenuItem);
menuItem = new JMenuItem("Vérifier EndDate > StartDate");
menuItem.addActionListener(this);
- menuItem.setAccelerator(KeyStroke.getKeyStroke('R', InputEvent.ALT_DOWN_MASK + Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()));
+ menuItem.setAccelerator(
+ KeyStroke.getKeyStroke(
+ 'R',
+ InputEvent.ALT_DOWN_MASK + Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx()
+ )
+ );
actionByMenuItem.put(menuItem, "CheckEndDate");
treatMenu.add(menuItem);
@@ -508,129 +542,127 @@ public void actionPerformed(final ActionEvent actionEvent) {
if (source instanceof JMenuItem) {
String action = actionByMenuItem.get(source);
- if (action == null)
- System.err.println("unknown menu action");
- else
- switch (action) {
- // File Menu
- case "LoadWork":
- loadWork();
- break;
- case "SaveWork":
- saveWork();
- break;
- case "SaveAsWork":
- saveAsWork();
- break;
- case "CloseWork":
- closeWork();
- break;
- case "EditPrefs":
- editPrefs();
- break;
- case "Exit":
- exit();
- break;
- case "EmptyWorkDir":
- emptyWorkDir();
- break;
- // Treat Menu
- case "Search":
- search();
- break;
- case "TechnicalSearch":
- technicalSearch();
- break;
- case "Duplicates":
- duplicates();
- break;
- case "Clean":
- clean();
- break;
- case "Statistics":
- generateStatistics();
- break;
- case "SeeManifest":
- seeManifest();
- break;
- case "CheckSEDASchema":
- checkSEDASchema();
- break;
- case "CheckSpecificSEDASchemaProfile":
- checkSpecificSEDASchemaProfile();
- break;
- case "CheckEndDate":
- checkEndDate();
- break;
- case "RegenerateContinuousIds":
- doRegenerateContinuousIds();
- break;
- case "SortTreeViewer":
- doSortTreeViewer();
- break;
- // Context Menu
- case "SeeImportContext":
- seeImportContext();
- break;
- case "EditExportContext":
- editExportContext();
- break;
- // Import Menu
- case "ImportFromSIP":
- importFromSIP();
- break;
- case "ImportFromDIP":
- importFromDIP();
- break;
- case "ImportFromDisk":
- importFromDisk();
- break;
- case "ImportFromZip":
- importFromZip();
- break;
- case "ImportFromCSVTree":
- importFromCSVTree();
- break;
- case "ImportFromCSVMetadata":
- importFromCSVMetadata();
- break;
- case "ImportFromMail":
- importFromMail();
- break;
- // Export Menu
- case "ExportToSEDASIP":
- exportWork(ExportThread.SIP_ALL_EXPORT);
- break;
- case "ExportToSEDAXMLManifest":
- exportWork(ExportThread.SIP_MANIFEST_EXPORT);
- break;
- case "ExportToDisk":
- exportWork(ExportThread.DISK_EXPORT);
- break;
- case "ExportToCSVDisk":
- exportWork(ExportThread.CSV_ALL_DISK_EXPORT);
- break;
- case "ExportToCSVZip":
- exportWork(ExportThread.CSV_ALL_ZIP_EXPORT);
- break;
- case "ExportToCSVMetadataFile":
- exportWork(ExportThread.CSV_METADATA_FILE_EXPORT);
- break;
- case "About":
- about();
- break;
- case "ToggleStructuredEdition":
- toggleStructuredEdition();
- break;
- case "ToggleDebugMode":
- toggleDebugMode();
- break;
- case "ToggleExperimentalMode":
- toggleExperimentalMode();
- break;
- default:
- break;
- }
+ if (action == null) System.err.println("unknown menu action");
+ else switch (action) {
+ // File Menu
+ case "LoadWork":
+ loadWork();
+ break;
+ case "SaveWork":
+ saveWork();
+ break;
+ case "SaveAsWork":
+ saveAsWork();
+ break;
+ case "CloseWork":
+ closeWork();
+ break;
+ case "EditPrefs":
+ editPrefs();
+ break;
+ case "Exit":
+ exit();
+ break;
+ case "EmptyWorkDir":
+ emptyWorkDir();
+ break;
+ // Treat Menu
+ case "Search":
+ search();
+ break;
+ case "TechnicalSearch":
+ technicalSearch();
+ break;
+ case "Duplicates":
+ duplicates();
+ break;
+ case "Clean":
+ clean();
+ break;
+ case "Statistics":
+ generateStatistics();
+ break;
+ case "SeeManifest":
+ seeManifest();
+ break;
+ case "CheckSEDASchema":
+ checkSEDASchema();
+ break;
+ case "CheckSpecificSEDASchemaProfile":
+ checkSpecificSEDASchemaProfile();
+ break;
+ case "CheckEndDate":
+ checkEndDate();
+ break;
+ case "RegenerateContinuousIds":
+ doRegenerateContinuousIds();
+ break;
+ case "SortTreeViewer":
+ doSortTreeViewer();
+ break;
+ // Context Menu
+ case "SeeImportContext":
+ seeImportContext();
+ break;
+ case "EditExportContext":
+ editExportContext();
+ break;
+ // Import Menu
+ case "ImportFromSIP":
+ importFromSIP();
+ break;
+ case "ImportFromDIP":
+ importFromDIP();
+ break;
+ case "ImportFromDisk":
+ importFromDisk();
+ break;
+ case "ImportFromZip":
+ importFromZip();
+ break;
+ case "ImportFromCSVTree":
+ importFromCSVTree();
+ break;
+ case "ImportFromCSVMetadata":
+ importFromCSVMetadata();
+ break;
+ case "ImportFromMail":
+ importFromMail();
+ break;
+ // Export Menu
+ case "ExportToSEDASIP":
+ exportWork(ExportThread.SIP_ALL_EXPORT);
+ break;
+ case "ExportToSEDAXMLManifest":
+ exportWork(ExportThread.SIP_MANIFEST_EXPORT);
+ break;
+ case "ExportToDisk":
+ exportWork(ExportThread.DISK_EXPORT);
+ break;
+ case "ExportToCSVDisk":
+ exportWork(ExportThread.CSV_ALL_DISK_EXPORT);
+ break;
+ case "ExportToCSVZip":
+ exportWork(ExportThread.CSV_ALL_ZIP_EXPORT);
+ break;
+ case "ExportToCSVMetadataFile":
+ exportWork(ExportThread.CSV_METADATA_FILE_EXPORT);
+ break;
+ case "About":
+ about();
+ break;
+ case "ToggleStructuredEdition":
+ toggleStructuredEdition();
+ break;
+ case "ToggleDebugMode":
+ toggleDebugMode();
+ break;
+ case "ToggleExperimentalMode":
+ toggleExperimentalMode();
+ break;
+ default:
+ break;
+ }
}
}
@@ -709,20 +741,29 @@ private void loadWork() {
String filename = "Non défini";
try {
if (importThreadRunning) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Un import est en cours vous devez l'annuler ou attendre la fin avant de faire un chargement.",
- "Information", UserInteractionDialog.IMPORTANT_DIALOG,
- null);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Un import est en cours vous devez l'annuler ou attendre la fin avant de faire un chargement.",
+ "Information",
+ UserInteractionDialog.IMPORTANT_DIALOG,
+ null
+ );
return;
}
- if ((currentWork != null) && modifiedWork
- && (UserInteractionDialog.getUserAnswer(mainWindow,
- "Vous avez un contexte en cours non sauvegardé, un chargement l'écrasera.\n"
- + "Voulez-vous continuer?",
- "Confirmation", UserInteractionDialog.WARNING_DIALOG,
- null) != OK_DIALOG))
- return;
+ if (
+ (currentWork != null) &&
+ modifiedWork &&
+ (UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Vous avez un contexte en cours non sauvegardé, un chargement l'écrasera.\n" +
+ "Voulez-vous continuer?",
+ "Confirmation",
+ UserInteractionDialog.WARNING_DIALOG,
+ null
+ ) !=
+ OK_DIALOG)
+ ) return;
JFileChooser fileChooser = new JFileChooser(Preferences.getInstance().getPrefsLoadDir());
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
@@ -732,13 +773,19 @@ private void loadWork() {
final SedaVersion sedaVersionFromWorkspace = Work.getSeda2VersionFromFile(filename);
if (sedaVersionFromWorkspace != sedaVersion) {
- if (UserInteractionDialog.getUserAnswer(mainWindow,
+ if (
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
"Pour charger ce fichier il faut faire passer l'interface en " +
- sedaVersion + "\n" +
- "Voulez-vous continuer?",
- "Confirmation", UserInteractionDialog.WARNING_DIALOG,
- null) != OK_DIALOG)
- return;
+ sedaVersion +
+ "\n" +
+ "Voulez-vous continuer?",
+ "Confirmation",
+ UserInteractionDialog.WARNING_DIALOG,
+ null
+ ) !=
+ OK_DIALOG
+ ) return;
EventBus.publish(new SedaVersionChangedEvent(sedaVersionFromWorkspace));
treatmentParameters.toPrefs(Preferences.getInstance());
}
@@ -753,10 +800,13 @@ private void loadWork() {
Preferences.getInstance().setPrefsLoadDirFromChild(filename);
}
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Erreur de chargement de [" + filename + "]\n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur de chargement de [" + filename + "]\n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
getGlobalLogger().log(ResipLogger.STEP, "Erreur de chargement de [" + filename + "]", e);
mainWindow.setCursor(Cursor.getDefaultCursor());
}
@@ -765,21 +815,22 @@ private void loadWork() {
// MenuItem Save
private void saveWork() {
- if (filenameWork != null)
- try {
- mainWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- currentWork.save(filenameWork);
- mainWindow.setCursor(Cursor.getDefaultCursor());
- setModifiedContext(false);
- } catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Erreur de sauvegarde de [" + filenameWork + "]\n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- getGlobalLogger().log(ResipLogger.STEP,
- "Resip.Graphic: Erreur de sauvegarde de [" + filenameWork + "]", e);
- mainWindow.setCursor(Cursor.getDefaultCursor());
- }
+ if (filenameWork != null) try {
+ mainWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ currentWork.save(filenameWork);
+ mainWindow.setCursor(Cursor.getDefaultCursor());
+ setModifiedContext(false);
+ } catch (Exception e) {
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur de sauvegarde de [" + filenameWork + "]\n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ getGlobalLogger().log(ResipLogger.STEP, "Resip.Graphic: Erreur de sauvegarde de [" + filenameWork + "]", e);
+ mainWindow.setCursor(Cursor.getDefaultCursor());
+ }
}
// MenuItem SaveAs
@@ -792,12 +843,17 @@ private void saveAsWork() {
if (fileChooser.showSaveDialog(mainWindow) == JFileChooser.APPROVE_OPTION) {
filename = fileChooser.getSelectedFile().getCanonicalPath();
- if ((new File(filename).exists()) &&
- (UserInteractionDialog.getUserAnswer(mainWindow,
- "Le fichier [" + filename + "] existe. Voulez-vous le remplacer ?",
- "Confirmation", UserInteractionDialog.WARNING_DIALOG,
- null) != OK_DIALOG))
- return;
+ if (
+ (new File(filename).exists()) &&
+ (UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Le fichier [" + filename + "] existe. Voulez-vous le remplacer ?",
+ "Confirmation",
+ UserInteractionDialog.WARNING_DIALOG,
+ null
+ ) !=
+ OK_DIALOG)
+ ) return;
mainWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
currentWork.save(filename);
mainWindow.setCursor(Cursor.getDefaultCursor());
@@ -807,10 +863,13 @@ private void saveAsWork() {
Preferences.getInstance().setPrefsLoadDirFromChild(filename);
}
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Erreur de sauvegarde de [" + filename + "]\n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur de sauvegarde de [" + filename + "]\n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
getGlobalLogger().log(ResipLogger.STEP, "Erreur de sauvegarde de [" + filename + "]", e);
mainWindow.setCursor(Cursor.getDefaultCursor());
}
@@ -819,13 +878,19 @@ private void saveAsWork() {
// MenuItem Close
private void closeWork() {
try {
- if ((currentWork != null) && modifiedWork
- && UserInteractionDialog.getUserAnswer(mainWindow,
- "Vous avez un contexte en cours non sauvegardé, la fermeture entrainera la perte des modifications.\n"
- + "Voulez-vous continuer?",
- "Confirmation", UserInteractionDialog.WARNING_DIALOG,
- null) != OK_DIALOG)
- return;
+ if (
+ (currentWork != null) &&
+ modifiedWork &&
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Vous avez un contexte en cours non sauvegardé, la fermeture entrainera la perte des modifications.\n" +
+ "Voulez-vous continuer?",
+ "Confirmation",
+ UserInteractionDialog.WARNING_DIALOG,
+ null
+ ) !=
+ OK_DIALOG
+ ) return;
currentWork = null;
setFilenameWork(null);
@@ -833,12 +898,19 @@ private void closeWork() {
setContextLoaded(false);
mainWindow.load();
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Erreur de fermeture du contexte en cours [" + filenameWork + "]\n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- getGlobalLogger().log(ResipLogger.STEP, "Resip.Graphic: Erreur de fermeture du contexte en cours ["
- + filenameWork + "]", e);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur de fermeture du contexte en cours [" + filenameWork + "]\n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ getGlobalLogger()
+ .log(
+ ResipLogger.STEP,
+ "Resip.Graphic: Erreur de fermeture du contexte en cours [" + filenameWork + "]",
+ e
+ );
}
}
@@ -866,17 +938,21 @@ void editPrefs() {
experimentalMenuItem.setState(interfaceParameters.isExperimentalFlag());
structuredMenuItem.setState(interfaceParameters.isStructuredMetadataEditionFlag());
toggleStructuredEdition();
- ResipLogger.createGlobalLogger(preferencesDialog.cc.getWorkDir() + File.separator + "log.txt",
- getGlobalLogger().getProgressLogLevel());
+ ResipLogger.createGlobalLogger(
+ preferencesDialog.cc.getWorkDir() + File.separator + "log.txt",
+ getGlobalLogger().getProgressLogLevel()
+ );
}
} catch (ResipException e) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Erreur fatale, impossible d'éditer les préférences \n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- getGlobalLogger().log(ResipLogger.ERROR,
- "resip.graphicapp: erreur fatale, impossible d'éditer les préférences", e);
-
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur fatale, impossible d'éditer les préférences \n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ getGlobalLogger()
+ .log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible d'éditer les préférences", e);
}
}
@@ -886,35 +962,47 @@ private void emptyWorkDir() {
CreationContext cc;
try {
if (currentWork != null) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Vous devez fermer tout travail en cours avant de\n" +
- "procéder au nettoyage du répertoire de travail",
- "Information", UserInteractionDialog.IMPORTANT_DIALOG,
- null);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Vous devez fermer tout travail en cours avant de\n" +
+ "procéder au nettoyage du répertoire de travail",
+ "Information",
+ UserInteractionDialog.IMPORTANT_DIALOG,
+ null
+ );
return;
}
cc = new CreationContext(Preferences.getInstance());
- if (UserInteractionDialog.getUserAnswer(mainWindow,
+ if (
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
"Vous allez effacer tous les répertoires temporaires " +
- "d'extraction (finissant par \"-tmpdir\")\ndans le répertoire de travail\n" +
- cc.getWorkDir() + "\n" +
- "Voulez-vous continuer?",
+ "d'extraction (finissant par \"-tmpdir\")\ndans le répertoire de travail\n" +
+ cc.getWorkDir() +
+ "\n" +
+ "Voulez-vous continuer?",
"Confirmation",
UserInteractionDialog.WARNING_DIALOG,
"Ces répertoires temporaires sont utilisés pour stocker les fichiers issus " +
- "des extraction de conteneurs de messageries ou de SIP, DIP...\nAssurez-vous que vous n'avez" +
- " pas de sauvegarde de travail en cours qui utilise ces fichiers, avant de les supprimer.") != OK_DIALOG)
- return;
+ "des extraction de conteneurs de messageries ou de SIP, DIP...\nAssurez-vous que vous n'avez" +
+ " pas de sauvegarde de travail en cours qui utilise ces fichiers, avant de les supprimer."
+ ) !=
+ OK_DIALOG
+ ) return;
InOutDialog inOutDialog = new InOutDialog(mainWindow, "Nettoyage");
CleanThread cleanThread = new CleanThread(cc.getWorkDir(), inOutDialog);
cleanThread.execute();
inOutDialog.setVisible(true);
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Erreur fatale, impossible de faire le nettoyage \n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- getGlobalLogger().log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire le nettoyage", e);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur fatale, impossible de faire le nettoyage \n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ getGlobalLogger()
+ .log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire le nettoyage", e);
}
}
@@ -925,20 +1013,29 @@ private void emptyWorkDir() {
*/
public void exit() {
try {
- if ((currentWork != null) && modifiedWork
- && UserInteractionDialog.getUserAnswer(mainWindow,
- "Vous avez un contexte en cours non sauvegardé, la fermeture de l'application entrainera la perte des modifications.\n"
- + "Voulez-vous continuer?",
- "Confirmation", UserInteractionDialog.WARNING_DIALOG,
- null) != OK_DIALOG)
- return;
+ if (
+ (currentWork != null) &&
+ modifiedWork &&
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Vous avez un contexte en cours non sauvegardé, la fermeture de l'application entrainera la perte des modifications.\n" +
+ "Voulez-vous continuer?",
+ "Confirmation",
+ UserInteractionDialog.WARNING_DIALOG,
+ null
+ ) !=
+ OK_DIALOG
+ ) return;
System.exit(0);
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Erreur de fermeture de l'application\n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur de fermeture de l'application\n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
getGlobalLogger().log(ResipLogger.STEP, "resip.graphicapp: erreur de fermeture de l'application", e);
}
}
@@ -1007,21 +1104,37 @@ void checkSpecificSEDASchemaProfile() {
JFileChooser fileChooser = new JFileChooser(Preferences.getInstance().getPrefsImportDir());
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
if (fileChooser.showOpenDialog(mainWindow) == JFileChooser.APPROVE_OPTION) {
- InOutDialog inOutDialog = new InOutDialog(mainWindow, "Vérification Profil " + sedaVersion.displayString());
- CheckProfileThread checkProfileThread = new CheckProfileThread(fileChooser.getSelectedFile()
- .getAbsolutePath(), inOutDialog);
+ InOutDialog inOutDialog = new InOutDialog(
+ mainWindow,
+ "Vérification Profil " + sedaVersion.displayString()
+ );
+ CheckProfileThread checkProfileThread = new CheckProfileThread(
+ fileChooser.getSelectedFile().getAbsolutePath(),
+ inOutDialog
+ );
completeResipWork();
checkProfileThread.execute();
inOutDialog.setVisible(true);
}
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Erreur fatale, impossible de faire la vérification de confirmité au profil " + sedaVersion.displayString() + "\n->"
- + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- getGlobalLogger().log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire la " +
- "vérification de confirmité au profil " + sedaVersion.displayString(), e);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur fatale, impossible de faire la vérification de confirmité au profil " +
+ sedaVersion.displayString() +
+ "\n->" +
+ e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ getGlobalLogger()
+ .log(
+ ResipLogger.ERROR,
+ "resip.graphicapp: erreur fatale, impossible de faire la " +
+ "vérification de confirmité au profil " +
+ sedaVersion.displayString(),
+ e
+ );
}
}
@@ -1077,15 +1190,26 @@ void seeImportContext() {
if (currentWork != null) {
CreationContext oic = currentWork.getCreationContext();
if (oic != null) {
- CreationContextDialog creationContextDialog = new CreationContextDialog(mainWindow, oic,
- currentWork.getDataObjectPackage());
+ CreationContextDialog creationContextDialog = new CreationContextDialog(
+ mainWindow,
+ oic,
+ currentWork.getDataObjectPackage()
+ );
creationContextDialog.setVisible(true);
- } else
- UserInteractionDialog.getUserAnswer(mainWindow, "Pas de contexte de création défini", "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- } else
- UserInteractionDialog.getUserAnswer(mainWindow, "Pas de contexte ouvert", "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
+ } else UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Pas de contexte de création défini",
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ } else UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Pas de contexte ouvert",
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
}
// MenuItem Edit ExportContext
@@ -1098,34 +1222,50 @@ void editExportContext() {
if (currentWork.getExportContext() == null) {
currentWork.setExportContext(new ExportContext(Preferences.getInstance()));
}
- ExportContextDialog exportContextDialog = new ExportContextDialog(mainWindow, currentWork.getExportContext());
+ ExportContextDialog exportContextDialog = new ExportContextDialog(
+ mainWindow,
+ currentWork.getExportContext()
+ );
exportContextDialog.setVisible(true);
if (exportContextDialog.getReturnValue() == OK_DIALOG) {
currentWork.setExportContext(exportContextDialog.gmc);
setModifiedContext(true);
}
- } else
- UserInteractionDialog.getUserAnswer(mainWindow, "Pas de contexte ouvert", "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
+ } else UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Pas de contexte ouvert",
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
}
// Import Menu
private boolean isImportActionWrong() {
if (importThreadRunning) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Un import est en cours vous devez l'annuler ou attendre la fin avant de faire un autre import.",
- "Information", UserInteractionDialog.IMPORTANT_DIALOG,
- null);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Un import est en cours vous devez l'annuler ou attendre la fin avant de faire un autre import.",
+ "Information",
+ UserInteractionDialog.IMPORTANT_DIALOG,
+ null
+ );
return true;
}
- return (currentWork != null) && modifiedWork
- && (UserInteractionDialog.getUserAnswer(mainWindow,
- "Vous avez un contexte en cours non sauvegardé, un import l'écrasera.\n"
- + "Voulez-vous continuer?",
- "Confirmation", UserInteractionDialog.WARNING_DIALOG,
- null) != OK_DIALOG);
+ return (
+ (currentWork != null) &&
+ modifiedWork &&
+ (UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Vous avez un contexte en cours non sauvegardé, un import l'écrasera.\n" + "Voulez-vous continuer?",
+ "Confirmation",
+ UserInteractionDialog.WARNING_DIALOG,
+ null
+ ) !=
+ OK_DIALOG)
+ );
}
private void importWork(CreationContext cc) {
@@ -1135,11 +1275,15 @@ private void importWork(CreationContext cc) {
importThread.execute();
inOutDialog.setVisible(true);
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Erreur fatale, impossible de faire l'import \n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- getGlobalLogger().log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire l'import", e);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur fatale, impossible de faire l'import \n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ getGlobalLogger()
+ .log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire l'import", e);
}
}
@@ -1150,8 +1294,7 @@ private void importWork(CreationContext cc) {
*/
void importFromSIP() {
try {
- if (isImportActionWrong())
- return;
+ if (isImportActionWrong()) return;
JFileChooser fileChooser = new JFileChooser(Preferences.getInstance().getPrefsImportDir());
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
@@ -1161,11 +1304,15 @@ void importFromSIP() {
importWork(oic);
}
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Erreur fatale, impossible de faire l'import \n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- getGlobalLogger().log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire l'import", e);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur fatale, impossible de faire l'import \n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ getGlobalLogger()
+ .log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire l'import", e);
}
}
@@ -1176,8 +1323,7 @@ void importFromSIP() {
*/
void importFromDIP() {
try {
- if (isImportActionWrong())
- return;
+ if (isImportActionWrong()) return;
JFileChooser fileChooser = new JFileChooser(Preferences.getInstance().getPrefsImportDir());
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
@@ -1187,11 +1333,15 @@ void importFromDIP() {
importWork(oic);
}
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Erreur fatale, impossible de faire l'import \n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- getGlobalLogger().log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire l'import", e);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur fatale, impossible de faire l'import \n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ getGlobalLogger()
+ .log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire l'import", e);
}
}
@@ -1202,8 +1352,7 @@ void importFromDIP() {
*/
void importFromDisk() {
try {
- if (isImportActionWrong())
- return;
+ if (isImportActionWrong()) return;
JFileChooser fileChooser = new JFileChooser(Preferences.getInstance().getPrefsImportDir());
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@@ -1213,11 +1362,15 @@ void importFromDisk() {
importWork(oic);
}
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Erreur fatale, impossible de faire l'import \n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- getGlobalLogger().log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire l'import", e);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur fatale, impossible de faire l'import \n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ getGlobalLogger()
+ .log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire l'import", e);
}
}
@@ -1228,8 +1381,7 @@ void importFromDisk() {
*/
void importFromZip() {
try {
- if (isImportActionWrong())
- return;
+ if (isImportActionWrong()) return;
JFileChooser fileChooser = new JFileChooser(Preferences.getInstance().getPrefsImportDir());
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
@@ -1239,11 +1391,15 @@ void importFromZip() {
importWork(oic);
}
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Erreur fatale, impossible de faire l'import \n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- getGlobalLogger().log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire l'import", e);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur fatale, impossible de faire l'import \n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ getGlobalLogger()
+ .log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire l'import", e);
}
}
@@ -1254,8 +1410,7 @@ void importFromZip() {
*/
void importFromMail() {
try {
- if (isImportActionWrong())
- return;
+ if (isImportActionWrong()) return;
JFileChooser fileChooser = new JFileChooser(Preferences.getInstance().getPrefsImportDir());
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
@@ -1264,17 +1419,20 @@ void importFromMail() {
mic.setOnDiskInput(fileChooser.getSelectedFile().toString());
MailImportContextDialog micd = new MailImportContextDialog(mainWindow, mic);
micd.setVisible(true);
- if (micd.returnValue != OK_DIALOG)
- return;
+ if (micd.returnValue != OK_DIALOG) return;
micd.setMailImportContextFromDialog(mic);
importWork(mic);
}
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Erreur fatale, impossible de faire l'import \n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- getGlobalLogger().log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire l'import", e);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur fatale, impossible de faire l'import \n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ getGlobalLogger()
+ .log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire l'import", e);
}
}
@@ -1285,8 +1443,7 @@ void importFromMail() {
*/
void importFromCSVTree() {
try {
- if (isImportActionWrong())
- return;
+ if (isImportActionWrong()) return;
JFileChooser fileChooser = new JFileChooser(Preferences.getInstance().getPrefsImportDir());
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
@@ -1296,11 +1453,15 @@ void importFromCSVTree() {
importWork(ctic);
}
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Erreur fatale, impossible de faire l'import \n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- getGlobalLogger().log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire l'import", e);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur fatale, impossible de faire l'import \n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ getGlobalLogger()
+ .log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire l'import", e);
}
}
@@ -1311,8 +1472,7 @@ void importFromCSVTree() {
*/
void importFromCSVMetadata() {
try {
- if (isImportActionWrong())
- return;
+ if (isImportActionWrong()) return;
JFileChooser fileChooser = new JFileChooser(Preferences.getInstance().getPrefsImportDir());
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
@@ -1322,25 +1482,27 @@ void importFromCSVMetadata() {
importWork(cmic);
}
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow,
- "Erreur fatale, impossible de faire l'import \n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- getGlobalLogger().log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire l'import", e);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur fatale, impossible de faire l'import \n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ getGlobalLogger()
+ .log(ResipLogger.ERROR, "resip.graphicapp: erreur fatale, impossible de faire l'import", e);
}
}
// Export Menu
private boolean completeResipWork() {
- if (currentWork == null)
- return true;
+ if (currentWork == null) return true;
if (currentWork.getExportContext() == null) {
ExportContext newExportContext = new ExportContext(Preferences.getInstance());
ExportContextDialog exportContextDialog = new ExportContextDialog(mainWindow, newExportContext);
exportContextDialog.setVisible(true);
- if (exportContextDialog.getReturnValue() == KO_DIALOG)
- return true;
+ if (exportContextDialog.getReturnValue() == KO_DIALOG) return true;
currentWork.setExportContext(exportContextDialog.gmc);
}
return false;
@@ -1351,8 +1513,7 @@ private boolean completeResipWork() {
private void exportWork(int exportType) {
String defaultFilename;
try {
- if (completeResipWork())
- return;
+ if (completeResipWork()) return;
JFileChooser fileChooser;
if (currentWork.getExportContext().getOnDiskOutput() != null) {
fileChooser = new JFileChooser(currentWork.getExportContext().getOnDiskOutput());
@@ -1376,26 +1537,40 @@ private void exportWork(int exportType) {
defaultFilename += "metadata.csv";
break;
default:
- throw new SEDALibException("type d'export ["+exportType+"] inconnu");
+ throw new SEDALibException("type d'export [" + exportType + "] inconnu");
}
fileChooser.setSelectedFile(new File(defaultFilename));
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- } else
- fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ } else fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (fileChooser.showSaveDialog(mainWindow) == JFileChooser.APPROVE_OPTION) {
Path path = Paths.get(fileChooser.getSelectedFile().getAbsolutePath());
if (Files.exists(path)) {
- if (!Files.isDirectory(path) && UserInteractionDialog.getUserAnswer(mainWindow,
- "Le fichier [" + path + "] existe. Voulez-vous le remplacer ?",
- "Confirmation", UserInteractionDialog.WARNING_DIALOG,
- null) != OK_DIALOG)
- return;
- else if (Files.isDirectory(path) && Files.list(path).findAny().isPresent() && UserInteractionDialog.getUserAnswer(mainWindow,
- "Le répertoire [" + path + "] existe. Les fichiers exportés sur le disque vont " +
- "se mélanger avec ceux déjà existants. Voulez-vous continuer? ?",
- "Confirmation", UserInteractionDialog.WARNING_DIALOG,
- null) != OK_DIALOG)
- return;
+ if (
+ !Files.isDirectory(path) &&
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Le fichier [" + path + "] existe. Voulez-vous le remplacer ?",
+ "Confirmation",
+ UserInteractionDialog.WARNING_DIALOG,
+ null
+ ) !=
+ OK_DIALOG
+ ) return;
+ else if (
+ Files.isDirectory(path) &&
+ Files.list(path).findAny().isPresent() &&
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Le répertoire [" +
+ path +
+ "] existe. Les fichiers exportés sur le disque vont " +
+ "se mélanger avec ceux déjà existants. Voulez-vous continuer? ?",
+ "Confirmation",
+ UserInteractionDialog.WARNING_DIALOG,
+ null
+ ) !=
+ OK_DIALOG
+ ) return;
}
InOutDialog inOutDialog = new InOutDialog(mainWindow, "Export");
currentWork.getExportContext().setOnDiskOutput(path.toString());
@@ -1404,9 +1579,13 @@ else if (Files.isDirectory(path) && Files.list(path).findAny().isPresent() && Us
inOutDialog.setVisible(true);
}
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow, "Erreur fatale, impossible de faire l'export \n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur fatale, impossible de faire l'export \n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
getGlobalLogger().log(ResipLogger.STEP, "resip.graphicapp: erreur fatale, impossible de faire l'export", e);
}
}
@@ -1424,7 +1603,10 @@ private void about() {
version = p.getProperty("version", "");
builddate = p.getProperty("builddate", "");
}
- AboutDialog dialog = new AboutDialog(mainWindow, "Application Resip\n - Version : " + version + "\n - Date : " + builddate);
+ AboutDialog dialog = new AboutDialog(
+ mainWindow,
+ "Application Resip\n - Version : " + version + "\n - Date : " + builddate
+ );
dialog.setVisible(true);
} catch (Exception ignored) {
//no real case
@@ -1435,10 +1617,12 @@ private void toggleStructuredEdition() {
try {
interfaceParameters.setStructuredMetadataEditionFlag(structuredMenuItem.getState());
if (ResipGraphicApp.getTheApp().interfaceParameters.isStructuredMetadataEditionFlag()) {
- StructuredArchiveUnitEditorPanel structuredArchiveUnitEditorPanel = new StructuredArchiveUnitEditorPanel();
+ StructuredArchiveUnitEditorPanel structuredArchiveUnitEditorPanel =
+ new StructuredArchiveUnitEditorPanel();
ResipGraphicApp.getTheWindow().itemPane.setTopComponent(structuredArchiveUnitEditorPanel);
ResipGraphicApp.getTheWindow().auMetadataPane = structuredArchiveUnitEditorPanel;
- StructuredDataObjectGroupEditorPanel structuredDataObjectGroupEditorPanel = new StructuredDataObjectGroupEditorPanel();
+ StructuredDataObjectGroupEditorPanel structuredDataObjectGroupEditorPanel =
+ new StructuredDataObjectGroupEditorPanel();
ResipGraphicApp.getTheWindow().itemPane.setBottomComponent(structuredDataObjectGroupEditorPanel);
ResipGraphicApp.getTheWindow().dogMetadataPane = structuredDataObjectGroupEditorPanel;
} else {
@@ -1450,13 +1634,17 @@ private void toggleStructuredEdition() {
ResipGraphicApp.getTheWindow().dogMetadataPane = xmlDataObjectGroupEditorPanel;
}
DataObjectPackageTreeNode node = ResipGraphicApp.getTheWindow().treePane.getDisplayedTreeNode();
- if (node != null)
- ResipGraphicApp.getTheWindow().auMetadataPane.editArchiveUnit(node.getArchiveUnit());
+ if (node != null) ResipGraphicApp.getTheWindow().auMetadataPane.editArchiveUnit(node.getArchiveUnit());
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow, "Erreur fatale, impossible de changer de type d'édition \n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- getGlobalLogger().log(ResipLogger.STEP, "resip.graphicapp: erreur fatale, impossible de changer de type d'édition", e);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur fatale, impossible de changer de type d'édition \n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ getGlobalLogger()
+ .log(ResipLogger.STEP, "resip.graphicapp: erreur fatale, impossible de changer de type d'édition", e);
}
}
@@ -1464,10 +1652,15 @@ private void toggleDebugMode() {
try {
interfaceParameters.setDebugFlag(debugMenuItem.getState());
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow, "Erreur fatale, impossible de passer en mode débug \n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- getGlobalLogger().log(ResipLogger.STEP, "resip.graphicapp: erreur fatale, impossible de passer en mode débug", e);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur fatale, impossible de passer en mode débug \n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ getGlobalLogger()
+ .log(ResipLogger.STEP, "resip.graphicapp: erreur fatale, impossible de passer en mode débug", e);
}
}
@@ -1475,10 +1668,19 @@ private void toggleExperimentalMode() {
try {
interfaceParameters.setExperimentalFlag(experimentalMenuItem.getState());
} catch (Exception e) {
- UserInteractionDialog.getUserAnswer(mainWindow, "Erreur fatale, impossible de passer en mode expérimental \n->" + e.getMessage(),
- "Erreur", UserInteractionDialog.ERROR_DIALOG,
- null);
- getGlobalLogger().log(ResipLogger.STEP, "resip.graphicapp: erreur fatale, impossible de changer de type de mode de débug", e);
+ UserInteractionDialog.getUserAnswer(
+ mainWindow,
+ "Erreur fatale, impossible de passer en mode expérimental \n->" + e.getMessage(),
+ "Erreur",
+ UserInteractionDialog.ERROR_DIALOG,
+ null
+ );
+ getGlobalLogger()
+ .log(
+ ResipLogger.STEP,
+ "resip.graphicapp: erreur fatale, impossible de changer de type de mode de débug",
+ e
+ );
}
}
}
diff --git a/resip/src/main/java/fr/gouv/vitam/tools/resip/app/package-info.java b/resip/src/main/java/fr/gouv/vitam/tools/resip/app/package-info.java
index 78c07d02..ddd4a698 100644
--- a/resip/src/main/java/fr/gouv/vitam/tools/resip/app/package-info.java
+++ b/resip/src/main/java/fr/gouv/vitam/tools/resip/app/package-info.java
@@ -1 +1,38 @@
-package fr.gouv.vitam.tools.resip.app;
\ No newline at end of file
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.resip.app;
diff --git a/resip/src/main/java/fr/gouv/vitam/tools/resip/data/DustbinItem.java b/resip/src/main/java/fr/gouv/vitam/tools/resip/data/DustbinItem.java
index 3a27a2a0..5cfca237 100644
--- a/resip/src/main/java/fr/gouv/vitam/tools/resip/data/DustbinItem.java
+++ b/resip/src/main/java/fr/gouv/vitam/tools/resip/data/DustbinItem.java
@@ -1,29 +1,39 @@
/**
- * Copyright French Prime minister Office/DINSIC/Vitam Program (2015-2019)
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
*
- * contact.vitam@programmevitam.fr
+ * contact@programmevitam.fr
*
- * This software is developed as a validation helper tool, for constructing Submission Information Packages (archives
- * sets) in the Vitam program whose purpose is to implement a digital archiving back-office system managing high
- * volumetry securely and efficiently.
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
*
- * 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 archiveTransfer the following URL "http://www.cecill.info".
+ * 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.
+ * 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.
+ * 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.
+ * 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.vitam.tools.resip.data;
@@ -37,6 +47,7 @@
* The type Dustbin item.
*/
public class DustbinItem {
+
/**
* The Former root.
*/
@@ -69,13 +80,13 @@ public class DustbinItem {
* @param node the node
*/
public DustbinItem(DataObjectPackageTreeNode parentNode, DataObjectPackageTreeNode node) {
- this.node = node;
- this.formerRoot = parentNode;
- this.removedArchiveUnitList = new ArrayList<>();
- this.removedDataObjectGroupList = new ArrayList<>();
- this.removedBinaryDataObjectList = new ArrayList<>();
- this.removedPhysicalDataObjectList = new ArrayList<>();
- }
+ this.node = node;
+ this.formerRoot = parentNode;
+ this.removedArchiveUnitList = new ArrayList<>();
+ this.removedDataObjectGroupList = new ArrayList<>();
+ this.removedBinaryDataObjectList = new ArrayList<>();
+ this.removedPhysicalDataObjectList = new ArrayList<>();
+ }
/**
* Add tree node.
@@ -83,15 +94,13 @@ public DustbinItem(DataObjectPackageTreeNode parentNode, DataObjectPackageTreeNo
* @param node the node
*/
public void addTreeNode(DataObjectPackageTreeNode node) {
- if (node.getArchiveUnit()!=null)
- addArchiveUnit(node.getArchiveUnit());
- else if (node.getDataObject()!=null) {
- DataObject zod=node.getDataObject();
- if (zod instanceof DataObjectGroup)
- addDataObjectGroup((DataObjectGroup)zod);
- //FIXME ne traite les autres DataObject car à terme un TreeNode ne sera qu'un ArchiveUnit ou un DataObjectGroup
- }
- }
+ if (node.getArchiveUnit() != null) addArchiveUnit(node.getArchiveUnit());
+ else if (node.getDataObject() != null) {
+ DataObject zod = node.getDataObject();
+ if (zod instanceof DataObjectGroup) addDataObjectGroup((DataObjectGroup) zod);
+ //FIXME ne traite les autres DataObject car à terme un TreeNode ne sera qu'un ArchiveUnit ou un DataObjectGroup
+ }
+ }
/**
* Add archive unit.
@@ -99,8 +108,8 @@ else if (node.getDataObject()!=null) {
* @param archiveUnit the archive unit
*/
public void addArchiveUnit(ArchiveUnit archiveUnit) {
- removedArchiveUnitList.add(archiveUnit);
- }
+ removedArchiveUnitList.add(archiveUnit);
+ }
/**
* Add data object group.
@@ -108,8 +117,8 @@ public void addArchiveUnit(ArchiveUnit archiveUnit) {
* @param dataObjectGroup the data object group
*/
public void addDataObjectGroup(DataObjectGroup dataObjectGroup) {
- removedDataObjectGroupList.add(dataObjectGroup);
- removedBinaryDataObjectList.addAll(dataObjectGroup.getBinaryDataObjectList());
- removedPhysicalDataObjectList.addAll(dataObjectGroup.getPhysicalDataObjectList());
- }
+ removedDataObjectGroupList.add(dataObjectGroup);
+ removedBinaryDataObjectList.addAll(dataObjectGroup.getBinaryDataObjectList());
+ removedPhysicalDataObjectList.addAll(dataObjectGroup.getPhysicalDataObjectList());
+ }
}
diff --git a/resip/src/main/java/fr/gouv/vitam/tools/resip/data/NullDeserializer.java b/resip/src/main/java/fr/gouv/vitam/tools/resip/data/NullDeserializer.java
index 4373fee0..5a220974 100644
--- a/resip/src/main/java/fr/gouv/vitam/tools/resip/data/NullDeserializer.java
+++ b/resip/src/main/java/fr/gouv/vitam/tools/resip/data/NullDeserializer.java
@@ -1,29 +1,39 @@
/**
- * Copyright French Prime minister Office/DINSIC/Vitam Program (2015-2019)
- *
- * contact.vitam@programmevitam.fr
- *
- * This software is developed as a validation helper tool, for constructing Submission Information Packages (archives
- * sets) in the Vitam 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 dataObjectPackage 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.resip.data;
@@ -35,6 +45,7 @@
import java.io.IOException;
public class NullDeserializer
- * contact.vitam@programmevitam.fr
- *
- * This software is developed as a validation helper tool, for constructing Submission Information Packages (archives
- * sets) in the Vitam 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 dataObjectPackage 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.resip.data;
@@ -119,10 +129,7 @@ public Work(DataObjectPackage dataObjectPackage, CreationContext creationContext
this.creationContext = creationContext;
this.exportContext = exportContext;
- EventBus.subscribe(
- SedaVersionChangedEvent.class,
- event -> this.version = event.getNewVersion()
- );
+ EventBus.subscribe(SedaVersionChangedEvent.class, event -> this.version = event.getNewVersion());
}
/**
@@ -133,18 +140,27 @@ public Work(DataObjectPackage dataObjectPackage, CreationContext creationContext
* @throws SEDALibException the SEDA lib exception
* @throws InterruptedException the interrupted exception
*/
- public String doVitamNormalize(SEDALibProgressLogger spl)
- throws SEDALibException, InterruptedException {
+ public String doVitamNormalize(SEDALibProgressLogger spl) throws SEDALibException, InterruptedException {
Instant start = Instant.now();
- String log = "resip: début de la vérification de l'absence de cycle et de la normalisation Vitam de la structure";
+ String log =
+ "resip: début de la vérification de l'absence de cycle et de la normalisation Vitam de la structure";
doProgressLog(spl, SEDALibProgressLogger.GLOBAL, log, null);
dataObjectPackage.vitamNormalize(spl);
- doProgressLog(spl, SEDALibProgressLogger.STEP, "resip: " +
- dataObjectPackage.getArchiveUnitCount() + " ArchiveUnits normalisées", null);
+ doProgressLog(
+ spl,
+ SEDALibProgressLogger.STEP,
+ "resip: " + dataObjectPackage.getArchiveUnitCount() + " ArchiveUnits normalisées",
+ null
+ );
Instant end = Instant.now();
- doProgressLog(spl, SEDALibProgressLogger.GLOBAL, "resip: opération terminée en " + Duration.between(start, end).toString().substring(2), null);
+ doProgressLog(
+ spl,
+ SEDALibProgressLogger.GLOBAL,
+ "resip: opération terminée en " + Duration.between(start, end).toString().substring(2),
+ null
+ );
return "Vérification de l'absence de cycle et normalisation Vitam effectuées";
}
@@ -165,13 +181,15 @@ public static SedaVersion getSeda2VersionFromFile(String file) throws ResipExcep
module.addDeserializer(CreationContext.class, new NullDeserializer
- * contact.vitam@programmevitam.fr
- *
- * This software is developed as a validation helper tool, for constructing Submission Information Packages (archives
- * sets) in the Vitam 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 archiveTransfer 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.resip.frame;
@@ -69,7 +79,8 @@ public class BigTextEditDialog extends JDialog {
* @throws NoSuchMethodException the no such method exception
* @throws InvocationTargetException the invocation target exception
*/
- public static void main(String[] args) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+ public static void main(String[] args)
+ throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
TestDialogWindow window = new TestDialogWindow(BigTextEditDialog.class);
}
@@ -80,7 +91,14 @@ public static void main(String[] args) throws ClassNotFoundException, Unsupporte
* @throws SEDALibException the seda lib exception
*/
public BigTextEditDialog(JFrame owner) throws SEDALibException, IOException {
- this(owner, FileUtils.readFileToString(new File("resip/src/main/java/fr/gouv/vitam/tools/resip/frame/BigTextEditDialog.java"),"UTF8"),"Code");
+ this(
+ owner,
+ FileUtils.readFileToString(
+ new File("resip/src/main/java/fr/gouv/vitam/tools/resip/frame/BigTextEditDialog.java"),
+ "UTF8"
+ ),
+ "Code"
+ );
}
/**
@@ -98,9 +116,9 @@ public BigTextEditDialog(JFrame owner, String text, String title) {
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
setPreferredSize(new Dimension(1024, 600));
- gbl=new GridBagLayout();
- gbl.rowWeights = new double[]{1.0,0.0};
- gbl.columnWeights = new double[]{0.0,1.0,0.0};
+ gbl = new GridBagLayout();
+ gbl.rowWeights = new double[] { 1.0, 0.0 };
+ gbl.columnWeights = new double[] { 0.0, 1.0, 0.0 };
Container contentPane = getContentPane();
contentPane.setLayout(gbl);
@@ -114,9 +132,9 @@ public BigTextEditDialog(JFrame owner, String text, String title) {
gbc.insets = new Insets(0, 0, 0, 0);
gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 0;
- gbc.gridwidth=3;
+ gbc.gridwidth = 3;
gbc.gridy = 0;
- JScrollPane editScrollPane=new JScrollPane(editTextArea);
+ JScrollPane editScrollPane = new JScrollPane(editTextArea);
contentPane.add(editScrollPane, gbc);
final JButton validateButton = new JButton("Valider");
@@ -135,12 +153,14 @@ public BigTextEditDialog(JFrame owner, String text, String title) {
gbc.gridy = 1;
contentPane.add(cancelButton, gbc);
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- cancelButton.doClick();
+ addWindowListener(
+ new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ cancelButton.doClick();
+ }
}
- });
+ );
pack();
setLocationRelativeTo(owner);
@@ -151,8 +171,8 @@ private void buttonCancel() {
}
private void buttonValidate() {
- textResult=editTextArea.getText();
- setVisible(false);
+ textResult = editTextArea.getText();
+ setVisible(false);
}
/**
diff --git a/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/CleanDialog.java b/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/CleanDialog.java
index b1909752..6fb4fada 100644
--- a/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/CleanDialog.java
+++ b/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/CleanDialog.java
@@ -1,3 +1,40 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.resip.frame;
import fr.gouv.vitam.tools.resip.app.ResipGraphicApp;
@@ -71,7 +108,8 @@ public class CleanDialog extends JDialog {
* @throws NoSuchMethodException the no such method exception
* @throws InvocationTargetException the invocation target exception
*/
- public static void main(String[] args) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+ public static void main(String[] args)
+ throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
TestDialogWindow window = new TestDialogWindow(CleanDialog.class);
}
@@ -96,7 +134,6 @@ public CleanDialog(MainWindow owner) {
GridBagConstraints gbc;
GridBagLayout gbl;
-
searchThread = null;
technicalSearchThread = null;
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
@@ -107,8 +144,8 @@ public CleanDialog(MainWindow owner) {
Container contentPane = getContentPane();
gbl = new GridBagLayout();
- gbl.columnWeights = new double[]{1.0, 0.1, 0.0, 0.0};
- gbl.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0};
+ gbl.columnWeights = new double[] { 1.0, 0.1, 0.0, 0.0 };
+ gbl.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0 };
contentPane.setLayout(gbl);
JButton searchButton = new JButton();
@@ -151,8 +188,8 @@ public CleanDialog(MainWindow owner) {
previousButton.addActionListener(arg0 -> buttonPrevious());
gbl = new GridBagLayout();
- gbl.columnWeights = new double[]{0.0, 1.0};
- gbl.columnWidths = new int[]{30, 0};
+ gbl.columnWeights = new double[] { 0.0, 1.0 };
+ gbl.columnWidths = new int[] { 30, 0 };
JPanel choicePanel = new JPanel(gbl);
gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
@@ -291,9 +328,11 @@ public CleanDialog(MainWindow owner) {
explanationTextArea.setFont(new JLabel().getFont());
explanationTextArea.setBackground(UIManager.getColor("Dialog.background"));
explanationTextArea.setFocusable(false);
- explanationTextArea.setText("Le nettoyage va éliminer des éléments jugés inutiles ou contraire à la construction de paquets SEDA corrects:\n\n" +
- " - objet numériques de taille nulle: l'objet et ses métadonnées sont supprimés ainsi que le groupe d'objets si lui-même se retrouve vide,\n\n" +
- " - unité d'archives sans descendance: l'unité d'archive qui n'a ni descendance en unité d'archives, ni objet (numérique ou physique) associé est supprimée avec toutes ses métadonnées.");
+ explanationTextArea.setText(
+ "Le nettoyage va éliminer des éléments jugés inutiles ou contraire à la construction de paquets SEDA corrects:\n\n" +
+ " - objet numériques de taille nulle: l'objet et ses métadonnées sont supprimés ainsi que le groupe d'objets si lui-même se retrouve vide,\n\n" +
+ " - unité d'archives sans descendance: l'unité d'archive qui n'a ni descendance en unité d'archives, ni objet (numérique ou physique) associé est supprimée avec toutes ses métadonnées."
+ );
explanationTextArea.setWrapStyleWord(true);
gbc = new GridBagConstraints();
gbc.gridx = 1;
@@ -310,12 +349,14 @@ public CleanDialog(MainWindow owner) {
pack();
setLocationRelativeTo(owner);
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- close();
+ addWindowListener(
+ new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ close();
+ }
}
- });
+ );
}
void changeChoice(ActionEvent e) {
@@ -341,25 +382,35 @@ private void removeDataObjectGroup(ArchiveUnit archiveUnit) {
archiveUnit.getDataObjectPackage().getDogInDataObjectPackageIdMap().remove(dog.getInDataObjectPackageId());
}
- private boolean confirmCleanAll(int auCount, int bdoCount){
- return (UserInteractionDialog.getUserAnswer(ResipGraphicApp.getTheWindow(),
- "Vous allez supprimer "+(auCount!=0?auCount+" unité"+(auCount>1?"s":"")+" d'archives":"")+
- (bdoCount!=0?bdoCount+" objet"+(bdoCount>1?"s":"")+" binaire"+(bdoCount>1?"s":""):"")+".\n"
- + "Voulez-vous continuer?",
- "Confirmation", UserInteractionDialog.WARNING_DIALOG,
- null) == OK_DIALOG);
+ private boolean confirmCleanAll(int auCount, int bdoCount) {
+ return (
+ UserInteractionDialog.getUserAnswer(
+ ResipGraphicApp.getTheWindow(),
+ "Vous allez supprimer " +
+ (auCount != 0 ? auCount + " unité" + (auCount > 1 ? "s" : "") + " d'archives" : "") +
+ (bdoCount != 0
+ ? bdoCount + " objet" + (bdoCount > 1 ? "s" : "") + " binaire" + (bdoCount > 1 ? "s" : "")
+ : "") +
+ ".\n" +
+ "Voulez-vous continuer?",
+ "Confirmation",
+ UserInteractionDialog.WARNING_DIALOG,
+ null
+ ) ==
+ OK_DIALOG
+ );
}
void doCleanAll() {
if ((searchDataObjectResult != null) && (searchResultCount > 0)) {
- if (!confirmCleanAll(0,searchResultCount))
- return;
+ if (!confirmCleanAll(0, searchResultCount)) return;
for (Map.Entry
- * contact.vitam@programmevitam.fr
- *
- * This software is developed as a validation helper tool, for constructing Submission Information Packages (archives
- * sets) in the Vitam 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 archiveTransfer 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.resip.frame;
@@ -71,8 +81,9 @@ public class InOutDialog extends JDialog {
* @throws NoSuchMethodException the no such method exception
* @throws InvocationTargetException the invocation target exception
*/
- public static void main(String[] args) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
- TestDialogWindow window = new TestDialogWindow(InOutDialog.class);//NOSONAR used for debug run
+ public static void main(String[] args)
+ throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+ TestDialogWindow window = new TestDialogWindow(InOutDialog.class); //NOSONAR used for debug run
}
/**
@@ -102,8 +113,8 @@ public InOutDialog(JFrame owner, String title) {
contentPane.setLayout(new GridBagLayout());
GridBagLayout gridBagLayout = new GridBagLayout();
- gridBagLayout.columnWeights = new double[]{1.0,1.0};
- gridBagLayout.rowWeights = new double[]{0.0, 1.0, 0.0};
+ gridBagLayout.columnWeights = new double[] { 1.0, 1.0 };
+ gridBagLayout.rowWeights = new double[] { 0.0, 1.0, 0.0 };
contentPane.setLayout(gridBagLayout);
JLabel lblNewLabel = new JLabel("Informations de progression");
@@ -115,7 +126,7 @@ public InOutDialog(JFrame owner, String title) {
gbc.insets = new Insets(5, 5, 5, 5);
gbc.gridx = 0;
gbc.gridy = 0;
- gbc.gridwidth=2;
+ gbc.gridwidth = 2;
contentPane.add(lblNewLabel, gbc);
JScrollPane scrollPane = new JScrollPane();
@@ -124,7 +135,7 @@ public InOutDialog(JFrame owner, String title) {
gbc.insets = new Insets(0, 5, 5, 5);
gbc.gridx = 0;
gbc.gridy = 1;
- gbc.gridwidth=2;
+ gbc.gridwidth = 2;
contentPane.add(scrollPane, gbc);
extProgressTextArea = new JTextArea();
extProgressTextArea.setFont(MainWindow.LABEL_FONT);
@@ -151,13 +162,15 @@ public InOutDialog(JFrame owner, String title) {
okButton.addActionListener(arg -> buttonOk());
getRootPane().setDefaultButton(okButton);
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- cancelButton.doClick();
- okButton.doClick();
+ addWindowListener(
+ new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ cancelButton.doClick();
+ okButton.doClick();
+ }
}
- });
+ );
pack();
setLocationRelativeTo(owner);
@@ -166,10 +179,8 @@ public void windowClosing(WindowEvent e) {
// actions
private void buttonCancel() {
- if (thread != null)
- thread.cancel(true);
- else
- setVisible(false);
+ if (thread != null) thread.cancel(true);
+ else setVisible(false);
}
private void buttonOk() {
diff --git a/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/MailImportContextDialog.java b/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/MailImportContextDialog.java
index 0c605980..fae74121 100644
--- a/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/MailImportContextDialog.java
+++ b/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/MailImportContextDialog.java
@@ -1,29 +1,39 @@
/**
- * Copyright French Prime minister Office/DINSIC/Vitam Program (2015-2019)
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
*
- * contact.vitam@programmevitam.fr
- *
- * This software is developed as a validation helper tool, for constructing Submission Information Packages (archives
- * sets) in the Vitam program whose purpose is to implement a digital archiving back-office system managing high
- * volumetry securely and efficiently.
+ * contact@programmevitam.fr
*
- * 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 archiveTransfer the following URL "http://www.cecill.info".
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
*
- * 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.
+ * 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".
*
- * 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.
+ * 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.
*
- * 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.
+ * 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.vitam.tools.resip.frame;
@@ -42,36 +52,69 @@
*/
public class MailImportContextDialog extends JDialog {
- /**
- * The actions components.
- */
- private JCheckBox messageFileCheckBox;
- private JCheckBox attachementFileCheckBox;
- private JCheckBox messageMetadataCheckBox;
- private JCheckBox attachementMetadataCheckBox;
- private JCheckBox allowsExternalToolsForTextExtractionCheckBox;
- private JRadioButton pstRadioButton;
- private JRadioButton msgRadioButton;
- private JRadioButton tdbRadioButton;
- private JRadioButton mboxRadioButton;
- private JRadioButton emlRadioButton;
- private JComboBox defaultCharsetCombobox;
+ /**
+ * The actions components.
+ */
+ private JCheckBox messageFileCheckBox;
+ private JCheckBox attachementFileCheckBox;
+ private JCheckBox messageMetadataCheckBox;
+ private JCheckBox attachementMetadataCheckBox;
+ private JCheckBox allowsExternalToolsForTextExtractionCheckBox;
+ private JRadioButton pstRadioButton;
+ private JRadioButton msgRadioButton;
+ private JRadioButton tdbRadioButton;
+ private JRadioButton mboxRadioButton;
+ private JRadioButton emlRadioButton;
+ private JComboBox defaultCharsetCombobox;
/**
* The result.
*/
public int returnValue;
- /**
- * The proposed charsets.
- */
- static private String[] charsetStrings = {"windows-1252", "ISO-8859-1", "UTF-8", "CESU-8", "IBM00858", "IBM437", "IBM775",
- "IBM850", "IBM852", "IBM855", "IBM857", "IBM862", "IBM866", "ISO-8859-2", "ISO-8859-4", "ISO-8859-5",
- "ISO-8859-7", "ISO-8859-9", "ISO-8859-13", "ISO-8859-15", "KOI8-R", "KOI8-U", "US-ASCII", "UTF-16",
- "UTF-16BE", "UTF-16LE", "UTF-32", "UTF-32BE", "UTF-32LE", "x-UTF-32BE-BOM", "x-UTF-32LE-BOM",
- "windows-1250", "windows-1251", "windows-1253", "windows-1254", "windows-1257"};
-
- // Dialog test context
+ /**
+ * The proposed charsets.
+ */
+ private static String[] charsetStrings = {
+ "windows-1252",
+ "ISO-8859-1",
+ "UTF-8",
+ "CESU-8",
+ "IBM00858",
+ "IBM437",
+ "IBM775",
+ "IBM850",
+ "IBM852",
+ "IBM855",
+ "IBM857",
+ "IBM862",
+ "IBM866",
+ "ISO-8859-2",
+ "ISO-8859-4",
+ "ISO-8859-5",
+ "ISO-8859-7",
+ "ISO-8859-9",
+ "ISO-8859-13",
+ "ISO-8859-15",
+ "KOI8-R",
+ "KOI8-U",
+ "US-ASCII",
+ "UTF-16",
+ "UTF-16BE",
+ "UTF-16LE",
+ "UTF-32",
+ "UTF-32BE",
+ "UTF-32LE",
+ "x-UTF-32BE-BOM",
+ "x-UTF-32LE-BOM",
+ "windows-1250",
+ "windows-1251",
+ "windows-1253",
+ "windows-1254",
+ "windows-1257",
+ };
+
+ // Dialog test context
/**
* The entry point of dialog test.
@@ -84,9 +127,10 @@ public class MailImportContextDialog extends JDialog {
* @throws NoSuchMethodException the no such method exception
* @throws InvocationTargetException the invocation target exception
*/
- public static void main(String[] args) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
- TestDialogWindow window = new TestDialogWindow(MailImportContextDialog.class);
- }
+ public static void main(String[] args)
+ throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+ TestDialogWindow window = new TestDialogWindow(MailImportContextDialog.class);
+ }
/**
* Instantiates a new MailImportContextDialog for test.
@@ -94,8 +138,8 @@ public static void main(String[] args) throws ClassNotFoundException, Unsupporte
* @param owner the owner
*/
public MailImportContextDialog(JFrame owner) {
- this(owner, new MailImportContext(Preferences.getInstance()));
- }
+ this(owner, new MailImportContext(Preferences.getInstance()));
+ }
/**
* Create the dialog.
@@ -104,226 +148,228 @@ public MailImportContextDialog(JFrame owner) {
* @param mailImportContext the mail import context
*/
public MailImportContextDialog(JFrame owner, MailImportContext mailImportContext) {
- super(owner, "Edition des paramètres d'extraction des courriels", true);
- GridBagConstraints gbc;
-
- //this.setPreferredSize(new Dimension(500, 300));
- this.setMinimumSize(new Dimension(550, 230));
-
- Container contentPane = getContentPane();
- GridBagLayout gridBagLayout = new GridBagLayout();
- contentPane.setLayout(new GridBagLayout());
-
- // Parameters Panel
- JPanel parametersPanel = new JPanel();
- gbc = new GridBagConstraints();
- gbc.anchor = GridBagConstraints.EAST;
- gbc.insets = new Insets(5, 5, 5, 5);
- gbc.gridwidth = 2;
- gbc.gridx = 0;
- gbc.gridy = 0;
- contentPane.add(parametersPanel, gbc);
- GridBagLayout gbl_parametersPanel = new GridBagLayout();
- gbl_parametersPanel.columnWeights = new double[] { 0.1, 0.5, 0.5 };
- parametersPanel.setLayout(gbl_parametersPanel);
-
- JLabel protocolLabel = new JLabel("Protocole d'extraction courriel :");
- gbc = new GridBagConstraints();
- gbc.anchor = GridBagConstraints.EAST;
- gbc.insets = new Insets(0, 0, 0, 5);
- gbc.gridx = 0;
- gbc.gridy = 1;
- parametersPanel.add(protocolLabel, gbc);
-
- pstRadioButton = new JRadioButton("Outlook-Pst");
- pstRadioButton.setFont(MainWindow.CLICK_FONT);
- gbc = new GridBagConstraints();
- gbc.anchor = GridBagConstraints.WEST;
- gbc.insets = new Insets(0, 0, 0, 5);
- gbc.gridx = 1;
- gbc.gridy = 1;
- parametersPanel.add(pstRadioButton, gbc);
-
- msgRadioButton = new JRadioButton("Outlook-Msg");
- msgRadioButton.setFont(MainWindow.CLICK_FONT);
- gbc = new GridBagConstraints();
- gbc.anchor = GridBagConstraints.WEST;
- gbc.insets = new Insets(0, 0, 0, 5);
- gbc.gridx = 2;
- gbc.gridy = 1;
- parametersPanel.add(msgRadioButton, gbc);
-
- tdbRadioButton = new JRadioButton("Thunderbird");
- tdbRadioButton.setFont(MainWindow.CLICK_FONT);
- gbc = new GridBagConstraints();
- gbc.anchor = GridBagConstraints.WEST;
- gbc.insets = new Insets(0, 0, 0, 5);
- gbc.gridx = 1;
- gbc.gridy = 2;
- parametersPanel.add(tdbRadioButton, gbc);
-
- mboxRadioButton = new JRadioButton("Mbox");
- mboxRadioButton.setFont(MainWindow.CLICK_FONT);
- gbc = new GridBagConstraints();
- gbc.anchor = GridBagConstraints.WEST;
- gbc.insets = new Insets(0, 0, 0, 5);
- gbc.gridx = 2;
- gbc.gridy =2;
- parametersPanel.add(mboxRadioButton, gbc);
-
- emlRadioButton = new JRadioButton("Eml");
- emlRadioButton.setFont(MainWindow.CLICK_FONT);
- gbc = new GridBagConstraints();
- gbc.anchor = GridBagConstraints.WEST;
- gbc.insets = new Insets(0, 0, 0, 5);
- gbc.gridx = 1;
- gbc.gridy =3;
- parametersPanel.add(emlRadioButton, gbc);
-
- ButtonGroup protocolButtonGroup = new ButtonGroup();
- protocolButtonGroup.add(pstRadioButton);
- protocolButtonGroup.add(msgRadioButton);
- protocolButtonGroup.add(tdbRadioButton);
- protocolButtonGroup.add(mboxRadioButton);
- protocolButtonGroup.add(emlRadioButton);
- pstRadioButton.setSelected("pst".equals(mailImportContext.getProtocol()));
- msgRadioButton.setSelected("msg".equals(mailImportContext.getProtocol()));
- tdbRadioButton.setSelected("thunderbird".equals(mailImportContext.getProtocol()));
- mboxRadioButton.setSelected("mbox".equals(mailImportContext.getProtocol()));
- emlRadioButton.setSelected("eml".equals(mailImportContext.getProtocol()));
-
- defaultCharsetCombobox = new JComboBox
- * contact.vitam@programmevitam.fr
- *
- * This software is developed as a validation helper tool, for constructing Submission Information Packages (archives
- * sets) in the Vitam 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 dataObjectPackage 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.resip.frame;
import fr.gouv.vitam.tools.resip.app.ResipGraphicApp;
import fr.gouv.vitam.tools.resip.sedaobjecteditor.components.highlevelcomponents.*;
-import fr.gouv.vitam.tools.resip.sedaobjecteditor.components.viewers.DataObjectPackageTreeModel;
-import fr.gouv.vitam.tools.resip.sedaobjecteditor.components.viewers.DataObjectPackageTreeNode;
-import fr.gouv.vitam.tools.resip.sedaobjecteditor.components.viewers.DataObjectPackageTreeViewer;
import fr.gouv.vitam.tools.resip.utils.ResipException;
-import fr.gouv.vitam.tools.resip.utils.ResipLogger;
-import fr.gouv.vitam.tools.sedalib.core.ArchiveUnit;
-import fr.gouv.vitam.tools.sedalib.core.DataObjectPackageIdElement;
import fr.gouv.vitam.tools.sedalib.utils.SEDALibException;
import javax.swing.*;
-import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
-import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
-import java.nio.file.Path;
-
-import static fr.gouv.vitam.tools.resip.app.ResipGraphicApp.OK_DIALOG;
/**
* The Class MainWindow.
@@ -115,7 +114,8 @@ public class MainWindow extends JFrame {
* @throws ResipException the resip exception
* @throws InterruptedException the interrupted exception
*/
- public static void main(String[] args) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, ResipException, InterruptedException {
+ public static void main(String[] args)
+ throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, ResipException, InterruptedException {
ResipGraphicApp rga = new ResipGraphicApp(null);
Thread.sleep(1000);
}
@@ -164,7 +164,7 @@ private void initialize() {
generalSplitPaneHoriz.setResizeWeight(0.3);
getContentPane().add(generalSplitPaneHoriz);
- treePane= new TreeDataObjectPackageEditorPanel();
+ treePane = new TreeDataObjectPackageEditorPanel();
generalSplitPaneHoriz.setLeftComponent(treePane);
itemPane = new JSplitPane();
@@ -185,24 +185,25 @@ private void initialize() {
}
if (ResipGraphicApp.getTheApp().interfaceParameters.isStructuredMetadataEditionFlag()) {
- StructuredDataObjectGroupEditorPanel structuredDataObjectGroupEditorPanel = new StructuredDataObjectGroupEditorPanel();
+ StructuredDataObjectGroupEditorPanel structuredDataObjectGroupEditorPanel =
+ new StructuredDataObjectGroupEditorPanel();
itemPane.setBottomComponent(structuredDataObjectGroupEditorPanel);
dogMetadataPane = structuredDataObjectGroupEditorPanel;
- }
- else
- {
+ } else {
XMLDataObjectGroupEditorPanel xmlDataObjectGroupEditorPanel = new XMLDataObjectGroupEditorPanel();
itemPane.setBottomComponent(xmlDataObjectGroupEditorPanel);
dogMetadataPane = xmlDataObjectGroupEditorPanel;
}
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- ResipGraphicApp.getTheApp().exit();
+ addWindowListener(
+ new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ ResipGraphicApp.getTheApp().exit();
+ }
}
- });
+ );
pack();
}
@@ -214,7 +215,6 @@ public void load() {
try {
treePane.editDataObjectPackage(app.currentWork == null ? null : app.currentWork.getDataObjectPackage());
auMetadataPane.editArchiveUnit(null);
- } catch (SEDALibException ignored) {
- }
+ } catch (SEDALibException ignored) {}
}
}
diff --git a/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/ManifestFindToolBar.java b/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/ManifestFindToolBar.java
index 13c3f6cb..e94b0e02 100644
--- a/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/ManifestFindToolBar.java
+++ b/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/ManifestFindToolBar.java
@@ -1,3 +1,40 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.resip.frame;
import org.fife.rsta.ui.search.FindToolBar;
@@ -7,6 +44,7 @@
import java.awt.*;
public class ManifestFindToolBar extends FindToolBar {
+
public ManifestFindToolBar(SearchListener listener) {
super(listener);
}
@@ -63,6 +101,4 @@ protected Container createButtonPanel() {
//panel.add(this.markAllCheckBox);
return panel;
}
-
-
}
diff --git a/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/ManifestWindow.java b/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/ManifestWindow.java
index eee57c9d..833f7eab 100644
--- a/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/ManifestWindow.java
+++ b/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/ManifestWindow.java
@@ -1,35 +1,45 @@
/**
- * Copyright French Prime minister Office/DINSIC/Vitam Program (2015-2019)
- *
- * contact.vitam@programmevitam.fr
- *
- * This software is developed as a validation helper tool, for constructing Submission Information Packages (archives
- * sets) in the Vitam 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 archiveTransfer 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.resip.frame;
import fr.gouv.vitam.tools.resip.app.ResipGraphicApp;
-import fr.gouv.vitam.tools.sedalib.utils.LocalDateTimeUtil;
import fr.gouv.vitam.tools.resip.utils.ResipException;
+import fr.gouv.vitam.tools.sedalib.utils.LocalDateTimeUtil;
import org.fife.rsta.ui.search.SearchEvent;
import org.fife.rsta.ui.search.SearchListener;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
@@ -74,7 +84,8 @@ public class ManifestWindow extends JFrame implements SearchListener {
* @throws NoSuchMethodException the no such method exception
* @throws InvocationTargetException the invocation target exception
*/
- public static void main(String[] args) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, ResipException, InterruptedException {
+ public static void main(String[] args)
+ throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, ResipException, InterruptedException {
ResipGraphicApp rga = new ResipGraphicApp(null);
Thread.sleep(1000);
ManifestWindow mw = new ManifestWindow();
@@ -93,9 +104,9 @@ public ManifestWindow() throws InterruptedException {
setMinimumSize(new Dimension(700, 300));
gbl = new GridBagLayout();
- gbl.rowWeights = new double[]{1.0, 0.0};
- gbl.columnWeights = new double[]{1.0, 0, 0, 0.0};
- gbl.columnWidths = new int[]{400, 0, 200};
+ gbl.rowWeights = new double[] { 1.0, 0.0 };
+ gbl.columnWeights = new double[] { 1.0, 0, 0, 0.0 };
+ gbl.columnWidths = new int[] { 400, 0, 200 };
Container contentPane = getContentPane();
contentPane.setLayout(gbl);
@@ -136,7 +147,6 @@ public ManifestWindow() throws InterruptedException {
gbc.gridy = 1;
contentPane.add(separator, gbc);
-
statusLabel = new JLabel("Prêt");
gbc = new GridBagConstraints();
gbc.insets = new Insets(5, 5, 5, 5);
@@ -162,7 +172,6 @@ public void setText(String text) {
@Override
public void searchEvent(SearchEvent e) {
-
SearchEvent.Type type = e.getType();
SearchContext context = e.getSearchContext();
SearchResult result;
@@ -192,12 +201,10 @@ public void searchEvent(SearchEvent e) {
text = "Trouvé";
}
statusLabel.setText(text);
-
}
@Override
public String getSelectedText() {
return xmlTextArea.getSelectedText();
}
-
}
diff --git a/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/NumericFilter.java b/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/NumericFilter.java
index e879fe8a..c30d0bc2 100644
--- a/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/NumericFilter.java
+++ b/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/NumericFilter.java
@@ -1,3 +1,40 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.resip.frame;
import javax.swing.text.AttributeSet;
@@ -8,17 +45,16 @@
* The type Numeric filter.
*/
public class NumericFilter extends DocumentFilter {
+
@Override
- public void replace(FilterBypass fb, int offs, int length,
- String str, AttributeSet a) throws BadLocationException {
+ public void replace(FilterBypass fb, int offs, int length, String str, AttributeSet a) throws BadLocationException {
str = str.replaceAll("[^0-9]", "");
super.replace(fb, offs, length, str, a);
}
@Override
- public void insertString(FilterBypass fb, int offs, String str,
- AttributeSet a) throws BadLocationException {
+ public void insertString(FilterBypass fb, int offs, String str, AttributeSet a) throws BadLocationException {
str = str.replaceAll("[^0-9]", "");
super.insertString(fb, offs, str, a);
}
-}
\ No newline at end of file
+}
diff --git a/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/SearchDialog.java b/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/SearchDialog.java
index 6b8356f8..f844eb80 100644
--- a/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/SearchDialog.java
+++ b/resip/src/main/java/fr/gouv/vitam/tools/resip/frame/SearchDialog.java
@@ -1,3 +1,40 @@
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.resip.frame;
import fr.gouv.vitam.tools.resip.app.ResipGraphicApp;
@@ -58,7 +95,8 @@ public class SearchDialog extends JDialog {
* @throws NoSuchMethodException the no such method exception
* @throws InvocationTargetException the invocation target exception
*/
- public static void main(String[] args) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+ public static void main(String[] args)
+ throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
TestDialogWindow window = new TestDialogWindow(SearchDialog.class);
}
@@ -79,7 +117,6 @@ public SearchDialog(JFrame owner) throws ResipException {
*/
public SearchDialog(MainWindow owner) {
super(owner, "Chercher des unités d'archives", false);
-
searchThread = null;
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
@@ -259,8 +296,10 @@ public SearchDialog(MainWindow owner) {
gbc.gridx = 0;
gbc.gridy = 1;
optionalInfoPanel.add(informationLabel, gbc);
- JTextArea informationTextArea = new JTextArea("Il s'agit d'une recherche par expression régulière de type java d'une partie quelconque de la chaine, avec les caractères spéciaux classiques .?+*[]^|\\\\s\\w...\n" +
- "Pour plus d'info chercher sur Internet \"Regexp java\"");
+ JTextArea informationTextArea = new JTextArea(
+ "Il s'agit d'une recherche par expression régulière de type java d'une partie quelconque de la chaine, avec les caractères spéciaux classiques .?+*[]^|\\\\s\\w...\n" +
+ "Pour plus d'info chercher sur Internet \"Regexp java\""
+ );
informationTextArea.setFont(MainWindow.LABEL_FONT);
informationTextArea.setEditable(false);
informationTextArea.setLineWrap(true);
@@ -282,12 +321,14 @@ public SearchDialog(MainWindow owner) {
pack();
setLocationRelativeTo(owner);
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- close();
+ addWindowListener(
+ new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ close();
+ }
}
- });
+ );
}
// actions
@@ -324,10 +365,17 @@ private void regexpEvent(ItemEvent event) {
private void buttonSearch() {
if (searchThread == null) {
- searchThread = new SearchThread(mainWindow.getApp().currentWork.getDataObjectPackage().getGhostRootAu(),
- withoutChildArchiveUnitCheckBox.isSelected(), withoutChildDataObjectCheckBox.isSelected(),
- idCheckBox.isSelected(), metadataCheckBox.isSelected(), regExpCheckBox.isSelected(), caseCheckBox.isSelected(),
- searchTextField.getText(), e -> setSearchResult(e));
+ searchThread = new SearchThread(
+ mainWindow.getApp().currentWork.getDataObjectPackage().getGhostRootAu(),
+ withoutChildArchiveUnitCheckBox.isSelected(),
+ withoutChildDataObjectCheckBox.isSelected(),
+ idCheckBox.isSelected(),
+ metadataCheckBox.isSelected(),
+ regExpCheckBox.isSelected(),
+ caseCheckBox.isSelected(),
+ searchTextField.getText(),
+ e -> setSearchResult(e)
+ );
searchThread.execute();
searchResult = null;
resultLabel.setText("En cours");
@@ -337,7 +385,13 @@ private void buttonSearch() {
private void buttonNext() {
if (searchResult != null && searchResult.size() > 0) {
searchResultPosition = Math.min(searchResultPosition + 1, searchResult.size() - 1);
- resultLabel.setText((searchResultPosition + 1) + "/" + searchResult.size() + " trouvé" + (searchResult.size() > 1 ? "s" : ""));
+ resultLabel.setText(
+ (searchResultPosition + 1) +
+ "/" +
+ searchResult.size() +
+ " trouvé" +
+ (searchResult.size() > 1 ? "s" : "")
+ );
ResipGraphicApp.getTheWindow().treePane.focusArchiveUnit(searchResult.get(searchResultPosition));
}
}
@@ -345,7 +399,13 @@ private void buttonNext() {
private void buttonPrevious() {
if (searchResult != null && searchResult.size() > 0) {
searchResultPosition = Math.max(searchResultPosition - 1, 0);
- resultLabel.setText((searchResultPosition + 1) + "/" + searchResult.size() + " trouvé" + (searchResult.size() > 1 ? "s" : ""));
+ resultLabel.setText(
+ (searchResultPosition + 1) +
+ "/" +
+ searchResult.size() +
+ " trouvé" +
+ (searchResult.size() > 1 ? "s" : "")
+ );
ResipGraphicApp.getTheWindow().treePane.focusArchiveUnit(searchResult.get(searchResultPosition));
}
}
@@ -361,8 +421,7 @@ public void setSearchResult(List
- * contact.vitam@programmevitam.fr
- *
- * This software is developed as a validation helper tool, for constructing Submission Information Packages (archives
- * sets) in the Vitam 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 archiveTransfer 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.resip.frame;
import fr.gouv.vitam.tools.resip.app.ResipGraphicApp;
import fr.gouv.vitam.tools.resip.data.StatisticData;
-import fr.gouv.vitam.tools.resip.threads.StatisticThread;
-import fr.gouv.vitam.tools.resip.utils.ResipException;
import fr.gouv.vitam.tools.resip.sedaobjecteditor.components.viewers.DefaultTableHeaderCellRenderer;
import fr.gouv.vitam.tools.resip.sedaobjecteditor.components.viewers.StatisticCellRenderer;
import fr.gouv.vitam.tools.resip.sedaobjecteditor.components.viewers.StatisticTableModel;
+import fr.gouv.vitam.tools.resip.threads.StatisticThread;
+import fr.gouv.vitam.tools.resip.utils.ResipException;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
@@ -82,23 +92,22 @@ public class StatisticWindow extends JFrame {
* @throws ResipException the resip exception
* @throws InterruptedException the interrupted exception
*/
- public static void main(String[] args) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, ResipException, InterruptedException {
+ public static void main(String[] args)
+ throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, ResipException, InterruptedException {
ResipGraphicApp rga = new ResipGraphicApp(null);
Thread.sleep(1000);
StatisticWindow window = new StatisticWindow();
ArrayList
- * contact.vitam@programmevitam.fr
- *
- * This software is developed as a validation helper tool, for constructing Submission Information Packages (archives
- * sets) in the Vitam 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 archiveTransfer 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.resip.frame;
@@ -97,7 +107,8 @@ public class XmlEditDialog extends JDialog {
* @throws NoSuchMethodException the no such method exception
* @throws InvocationTargetException the invocation target exception
*/
- public static void main(String[] args) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+ public static void main(String[] args)
+ throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
TestDialogWindow window = new TestDialogWindow(XmlEditDialog.class);
}
@@ -108,7 +119,7 @@ public static void main(String[] args) throws ClassNotFoundException, Unsupporte
* @throws SEDALibException the seda lib exception
*/
public XmlEditDialog(JFrame owner) throws SEDALibException {
- this(owner, createSEDAMetadataSample("AgentType","Writer",false));
+ this(owner, createSEDAMetadataSample("AgentType", "Writer", false));
}
/**
@@ -130,13 +141,17 @@ public XmlEditDialog(JFrame owner, Object xmlObject) {
presentationText = dataObject.getInDataObjectPackageId();
try {
xmlData = dataObject.toSedaXmlFragments();
- xmlData = IndentXMLTool.getInstance(IndentXMLTool.STANDARD_INDENT)
- .indentString(xmlData);
+ xmlData = IndentXMLTool.getInstance(IndentXMLTool.STANDARD_INDENT).indentString(xmlData);
} catch (Exception e) {
- ResipLogger.getGlobalLogger().log(ResipLogger.STEP, "Resip.InOut: Erreur à l'indentation du DataObject ["
- + dataObject.getInDataObjectPackageId() + "]",e);
+ ResipLogger.getGlobalLogger()
+ .log(
+ ResipLogger.STEP,
+ "Resip.InOut: Erreur à l'indentation du DataObject [" +
+ dataObject.getInDataObjectPackageId() +
+ "]",
+ e
+ );
}
-
} else if (xmlObject instanceof SEDAMetadata) {
SEDAMetadata sm = (SEDAMetadata) xmlObject;
title = "Edition partielle de métadonnées";
@@ -145,8 +160,12 @@ public XmlEditDialog(JFrame owner, Object xmlObject) {
try {
xmlData = sm.toString();
} catch (Exception e) {
- ResipLogger.getGlobalLogger().log(ResipLogger.STEP, "Resip.InOut: Erreur à la génération XML de la métadonnée ["
- + sm.getXmlElementName() + "]",e);
+ ResipLogger.getGlobalLogger()
+ .log(
+ ResipLogger.STEP,
+ "Resip.InOut: Erreur à la génération XML de la métadonnée [" + sm.getXmlElementName() + "]",
+ e
+ );
}
} else if (xmlObject instanceof ArchiveUnit) {
ArchiveUnit au = (ArchiveUnit) xmlObject;
@@ -296,7 +315,7 @@ public XmlEditDialog(JFrame owner, Object xmlObject) {
actionPanel.add(cleanButton, gbc);
}
- final JButton saveButton = new JButton((xmlObject instanceof String?"Valider":"Sauver"));
+ final JButton saveButton = new JButton((xmlObject instanceof String ? "Valider" : "Sauver"));
saveButton.addActionListener(arg -> buttonSaveXmlEdit());
gbc = new GridBagConstraints();
gbc.insets = new Insets(0, 0, 5, 5);
@@ -325,12 +344,14 @@ public XmlEditDialog(JFrame owner, Object xmlObject) {
gbc.gridx = buttonPlace;
actionPanel.add(cancelButton, gbc);
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- cancelButton.doClick();
+ addWindowListener(
+ new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ cancelButton.doClick();
+ }
}
- });
+ );
pack();
informationPanel.setVisible(false);
@@ -382,23 +403,39 @@ public void buttonIndent() {
/**
* The Default values.
*/
- static ArrayList
- * contact.vitam@programmevitam.fr
- *
- * This software is developed as a validation helper tool, for constructing Submission Information Packages (archives
- * sets) in the Vitam 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 archiveTransfer 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.
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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.vitam.tools.resip.frame.preferences;
@@ -164,11 +174,44 @@ public class PreferencesDialog extends JDialog {
/**
* The proposed charsets.
*/
- private static final String[] charsetStrings = {"windows-1252", "ISO-8859-1", "UTF-8", "CESU-8", "IBM00858", "IBM437", "IBM775",
- "IBM850", "IBM852", "IBM855", "IBM857", "IBM862", "IBM866", "ISO-8859-2", "ISO-8859-4", "ISO-8859-5",
- "ISO-8859-7", "ISO-8859-9", "ISO-8859-13", "ISO-8859-15", "KOI8-R", "KOI8-U", "US-ASCII", "UTF-16",
- "UTF-16BE", "UTF-16LE", "UTF-32", "UTF-32BE", "UTF-32LE", "x-UTF-32BE-BOM", "x-UTF-32LE-BOM",
- "windows-1250", "windows-1251", "windows-1253", "windows-1254", "windows-1257"};
+ private static final String[] charsetStrings = {
+ "windows-1252",
+ "ISO-8859-1",
+ "UTF-8",
+ "CESU-8",
+ "IBM00858",
+ "IBM437",
+ "IBM775",
+ "IBM850",
+ "IBM852",
+ "IBM855",
+ "IBM857",
+ "IBM862",
+ "IBM866",
+ "ISO-8859-2",
+ "ISO-8859-4",
+ "ISO-8859-5",
+ "ISO-8859-7",
+ "ISO-8859-9",
+ "ISO-8859-13",
+ "ISO-8859-15",
+ "KOI8-R",
+ "KOI8-U",
+ "US-ASCII",
+ "UTF-16",
+ "UTF-16BE",
+ "UTF-16LE",
+ "UTF-32",
+ "UTF-32BE",
+ "UTF-32LE",
+ "x-UTF-32BE-BOM",
+ "x-UTF-32LE-BOM",
+ "windows-1250",
+ "windows-1251",
+ "windows-1253",
+ "windows-1254",
+ "windows-1257",
+ };
private SedaVersion currentVersion;
@@ -187,10 +230,11 @@ public class PreferencesDialog extends JDialog {
* @throws ResipException the resip exception
* @throws InterruptedException the interrupted exception
*/
- public static void main(String[] args) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, ResipException, InterruptedException {
- ResipGraphicApp rga = new ResipGraphicApp(null);//NOSONAR used for debug run
+ public static void main(String[] args)
+ throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, ResipException, InterruptedException {
+ ResipGraphicApp rga = new ResipGraphicApp(null); //NOSONAR used for debug run
Thread.sleep(1000);
- TestDialogWindow window = new TestDialogWindow(PreferencesDialog.class);//NOSONAR used for debug run
+ TestDialogWindow window = new TestDialogWindow(PreferencesDialog.class); //NOSONAR used for debug run
}
/**
@@ -200,7 +244,6 @@ public static void main(String[] args) throws ClassNotFoundException, Unsupporte
*/
public PreferencesDialog(JFrame owner) {
super(owner, "Edition des paramètres par défaut", true);
-
EventBus.subscribe(SedaVersionChangedEvent.class, event -> {
this.currentVersion = event.getNewVersion();
});
@@ -220,8 +263,8 @@ public PreferencesDialog(JFrame owner) {
Container contentPane = getContentPane();
GridBagLayout gridBagLayout = new GridBagLayout();
- gridBagLayout.rowWeights = new double[]{1.0, 0.1};
- gridBagLayout.columnWeights = new double[]{1.0, 1.0};
+ gridBagLayout.rowWeights = new double[] { 1.0, 0.1 };
+ gridBagLayout.columnWeights = new double[] { 1.0, 1.0 };
contentPane.setLayout(new GridBagLayout());
GridBagConstraints gbc;
@@ -239,12 +282,17 @@ public PreferencesDialog(JFrame owner) {
// header and footer simple fields
JPanel headerFooterSimplePanel = new JPanel();
- tabbedPane.addTab("Métadonnées globales", new ImageIcon(getClass().getResource("/icon/document-properties.png")), headerFooterSimplePanel, null);
+ tabbedPane.addTab(
+ "Métadonnées globales",
+ new ImageIcon(getClass().getResource("/icon/document-properties.png")),
+ headerFooterSimplePanel,
+ null
+ );
GridBagLayout gblHeaderFooterSimplePanel = new GridBagLayout();
- gblHeaderFooterSimplePanel.columnWidths = new int[]{0, 0, 0};
- gblHeaderFooterSimplePanel.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
- gblHeaderFooterSimplePanel.columnWeights = new double[]{0.0, 1.0, 0.0};
- gblHeaderFooterSimplePanel.rowWeights = new double[]{0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
+ gblHeaderFooterSimplePanel.columnWidths = new int[] { 0, 0, 0 };
+ gblHeaderFooterSimplePanel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
+ gblHeaderFooterSimplePanel.columnWeights = new double[] { 0.0, 1.0, 0.0 };
+ gblHeaderFooterSimplePanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 };
headerFooterSimplePanel.setLayout(gblHeaderFooterSimplePanel);
JLabel presentationLabel = new JLabel("Champs globaux du SIP");
@@ -388,7 +436,9 @@ public PreferencesDialog(JFrame owner) {
headerFooterSimplePanel.add(lblTransferringAgencyIdentifier, gbc);
transferringAgencyIdentifierTextField = new JTextField();
- transferringAgencyIdentifierTextField.setText(gmc.getArchiveTransferGlobalMetadata().transferringAgencyIdentifier);
+ transferringAgencyIdentifierTextField.setText(
+ gmc.getArchiveTransferGlobalMetadata().transferringAgencyIdentifier
+ );
transferringAgencyIdentifierTextField.setFont(MainWindow.DETAILS_FONT);
gbc = new GridBagConstraints();
gbc.insets = new Insets(0, 0, 5, 5);
@@ -401,12 +451,17 @@ public PreferencesDialog(JFrame owner) {
// Header and footer complex fields
JPanel headerFooterComplexPanel = new JPanel();
- tabbedPane.addTab("Métadonnées globales étendues", new ImageIcon(getClass().getResource("/icon/text-x-generic.png")), headerFooterComplexPanel, null);
+ tabbedPane.addTab(
+ "Métadonnées globales étendues",
+ new ImageIcon(getClass().getResource("/icon/text-x-generic.png")),
+ headerFooterComplexPanel,
+ null
+ );
GridBagLayout gblHeaderFooterComplexPanel = new GridBagLayout();
- gblHeaderFooterComplexPanel.columnWidths = new int[]{0, 0, 0};
- gblHeaderFooterComplexPanel.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0};
- gblHeaderFooterComplexPanel.columnWeights = new double[]{0.0, 1.0, 0.0};
- gblHeaderFooterComplexPanel.rowWeights = new double[]{0.0, 1.0, 1.0, 0.0, 0.5, 0.5, 0.0};
+ gblHeaderFooterComplexPanel.columnWidths = new int[] { 0, 0, 0 };
+ gblHeaderFooterComplexPanel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0 };
+ gblHeaderFooterComplexPanel.columnWeights = new double[] { 0.0, 1.0, 0.0 };
+ gblHeaderFooterComplexPanel.rowWeights = new double[] { 0.0, 1.0, 1.0, 0.0, 0.5, 0.5, 0.0 };
headerFooterComplexPanel.setLayout(gblHeaderFooterComplexPanel);
JLabel presentationComplexLabel = new JLabel("Champs globaux étendus du SIP");
@@ -480,26 +535,28 @@ public PreferencesDialog(JFrame owner) {
transferRequestReplyIdentifierTextField = new JTextField();
transferRequestReplyIdentifierTextField.setFont(MainWindow.DETAILS_FONT);
- transferRequestReplyIdentifierTextField.setText(gmc.getArchiveTransferGlobalMetadata().transferRequestReplyIdentifier);
+ transferRequestReplyIdentifierTextField.setText(
+ gmc.getArchiveTransferGlobalMetadata().transferRequestReplyIdentifier
+ );
gbc = new GridBagConstraints();
gbc.insets = new Insets(0, 0, 5, 5);
gbc.gridwidth = 2;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.gridx = 1;
gbc.gridy = 3;
- headerFooterComplexPanel.add(transferRequestReplyIdentifierTextField,
- gbc);
+ headerFooterComplexPanel.add(transferRequestReplyIdentifierTextField, gbc);
transferRequestReplyIdentifierTextField.setColumns(10);
JLabel archivalAgencyOrganizationDescriptiveMetadataLabel = new JLabel("Détails sur l'acteur d'archivage :");
- archivalAgencyOrganizationDescriptiveMetadataLabel.setToolTipText("Bloc XML OrganisationDescriptiveMetadata de la métadonnée ArchivalAgency ");
+ archivalAgencyOrganizationDescriptiveMetadataLabel.setToolTipText(
+ "Bloc XML OrganisationDescriptiveMetadata de la métadonnée ArchivalAgency "
+ );
gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.EAST;
gbc.insets = new Insets(0, 5, 5, 5);
gbc.gridx = 0;
gbc.gridy = 4;
- headerFooterComplexPanel.add(archivalAgencyOrganizationDescriptiveMetadataLabel,
- gbc);
+ headerFooterComplexPanel.add(archivalAgencyOrganizationDescriptiveMetadataLabel, gbc);
JScrollPane scrollPane3 = new JScrollPane();
gbc = new GridBagConstraints();
@@ -513,19 +570,23 @@ public PreferencesDialog(JFrame owner) {
archivalAgencyOrganizationDescriptiveMetadataTextArea = new JTextArea();
archivalAgencyOrganizationDescriptiveMetadataTextArea.setFont(MainWindow.DETAILS_FONT);
scrollPane3.setViewportView(archivalAgencyOrganizationDescriptiveMetadataTextArea);
- archivalAgencyOrganizationDescriptiveMetadataTextArea
- .setText(gmc.getArchiveTransferGlobalMetadata().archivalAgencyOrganizationDescriptiveMetadataXmlData);
+ archivalAgencyOrganizationDescriptiveMetadataTextArea.setText(
+ gmc.getArchiveTransferGlobalMetadata().archivalAgencyOrganizationDescriptiveMetadataXmlData
+ );
archivalAgencyOrganizationDescriptiveMetadataTextArea.setCaretPosition(0);
- JLabel transferringAgencyOrganizationDescriptiveMetadataLabel = new JLabel("Détails sur l'acteur de transfert :");
- transferringAgencyOrganizationDescriptiveMetadataLabel.setToolTipText("Bloc XML OrganisationDescriptiveMetadata de la métadonnée TransferringAgency ");
+ JLabel transferringAgencyOrganizationDescriptiveMetadataLabel = new JLabel(
+ "Détails sur l'acteur de transfert :"
+ );
+ transferringAgencyOrganizationDescriptiveMetadataLabel.setToolTipText(
+ "Bloc XML OrganisationDescriptiveMetadata de la métadonnée TransferringAgency "
+ );
gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.EAST;
gbc.insets = new Insets(0, 5, 5, 5);
gbc.gridx = 0;
gbc.gridy = 5;
- headerFooterComplexPanel.add(transferringAgencyOrganizationDescriptiveMetadataLabel,
- gbc);
+ headerFooterComplexPanel.add(transferringAgencyOrganizationDescriptiveMetadataLabel, gbc);
JScrollPane scrollPane4 = new JScrollPane();
gbc = new GridBagConstraints();
@@ -539,17 +600,23 @@ public PreferencesDialog(JFrame owner) {
transferringAgencyOrganizationDescriptiveMetadataTextArea = new JTextArea();
transferringAgencyOrganizationDescriptiveMetadataTextArea.setFont(MainWindow.DETAILS_FONT);
scrollPane4.setViewportView(transferringAgencyOrganizationDescriptiveMetadataTextArea);
- transferringAgencyOrganizationDescriptiveMetadataTextArea
- .setText(gmc.getArchiveTransferGlobalMetadata().transferringAgencyOrganizationDescriptiveMetadataXmlData);
+ transferringAgencyOrganizationDescriptiveMetadataTextArea.setText(
+ gmc.getArchiveTransferGlobalMetadata().transferringAgencyOrganizationDescriptiveMetadataXmlData
+ );
transferringAgencyOrganizationDescriptiveMetadataTextArea.setCaretPosition(0);
// ExportParameters Panel
JPanel exportParametersPanel = new JPanel();
- tabbedPane.addTab("Export", new ImageIcon(getClass().getResource("/icon/document-save.png")), exportParametersPanel, null);
+ tabbedPane.addTab(
+ "Export",
+ new ImageIcon(getClass().getResource("/icon/document-save.png")),
+ exportParametersPanel,
+ null
+ );
GridBagLayout gblExportParametersPanel = new GridBagLayout();
- gblExportParametersPanel.columnWeights = new double[]{0, 0.5, 0.5, 0};
- gblExportParametersPanel.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
- gblExportParametersPanel.rowWeights = new double[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0};
+ gblExportParametersPanel.columnWeights = new double[] { 0, 0.5, 0.5, 0 };
+ gblExportParametersPanel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
+ gblExportParametersPanel.rowWeights = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 };
exportParametersPanel.setLayout(gblExportParametersPanel);
JLabel inSIPLabel = new JLabel("Options de formation du SIP");
@@ -592,10 +659,8 @@ public PreferencesDialog(JFrame owner) {
hierarchicalAUButtonGroup.add(flatRadioButton);
hierarchicalAUButtonGroup.add(hierarchicalRadioButton);
hierarchicalAUButtonGroup.clearSelection();
- if (gmc.isHierarchicalArchiveUnits())
- hierarchicalRadioButton.setSelected(true);
- else
- flatRadioButton.setSelected(true);
+ if (gmc.isHierarchicalArchiveUnits()) hierarchicalRadioButton.setSelected(true);
+ else flatRadioButton.setSelected(true);
JLabel xmlPresentationLabel = new JLabel("Présentation XML dans le SIP:");
gbc = new GridBagConstraints();
@@ -624,10 +689,8 @@ public PreferencesDialog(JFrame owner) {
indentedButtonGroup.add(linearRadioButton);
indentedButtonGroup.add(indentedRadioButton);
indentedButtonGroup.clearSelection();
- if (gmc.isIndented())
- indentedRadioButton.setSelected(true);
- else
- linearRadioButton.setSelected(true);
+ if (gmc.isIndented()) indentedRadioButton.setSelected(true);
+ else linearRadioButton.setSelected(true);
JLabel xmlReindexLabel = new JLabel("Renumérotation des éléments XML avant export:");
gbc = new GridBagConstraints();
@@ -657,10 +720,8 @@ public PreferencesDialog(JFrame owner) {
reindexButtonGroup.add(reindexYesRadioButton);
reindexButtonGroup.add(reindexNoRadioButton);
reindexButtonGroup.clearSelection();
- if (gmc.isReindex())
- reindexYesRadioButton.setSelected(true);
- else
- reindexNoRadioButton.setSelected(true);
+ if (gmc.isReindex()) reindexYesRadioButton.setSelected(true);
+ else reindexNoRadioButton.setSelected(true);
JLabel inCSVLabel = new JLabel("Options d'export en hiérarchie simplifiée et fichier csv");
inCSVLabel.setFont(MainWindow.BOLD_LABEL_FONT);
@@ -790,12 +851,15 @@ public PreferencesDialog(JFrame owner) {
metadataFilterTextArea = new JTextArea();
metadataFilterTextArea.setFont(MainWindow.DETAILS_FONT);
scrollPane.setViewportView(metadataFilterTextArea);
- if (gmc.getKeptMetadataList() != null)
- metadataFilterTextArea.setText(String.join("\n", String.join("\n", gmc.getKeptMetadataList())));
+ if (gmc.getKeptMetadataList() != null) metadataFilterTextArea.setText(
+ String.join("\n", String.join("\n", gmc.getKeptMetadataList()))
+ );
metadataFilterTextArea.setCaretPosition(0);
metadataFilterCheckBox = new JCheckBox("Seules métadonnées exportées :");
- metadataFilterCheckBox.setToolTipText("Liste des noms de métadonnées dans
*
- *
+ *
* @author Jaap Beetstra
*/
class Base64Util {
- private static final int ALPHABET_LENGTH = 64;
- private final char[] alphabet;
- private final int[] inverseAlphabet;
- /**
- * Initializes the class with the specified encoding/decoding alphabet.
- *
- * @param alphabet
- * @throws IllegalArgumentException if alphabet is not 64 characters long or
- * contains characters which are not 7-bit ASCII
- */
- Base64Util(final String alphabet) {
- this.alphabet = alphabet.toCharArray();
- if (alphabet.length() != ALPHABET_LENGTH)
- throw new IllegalArgumentException("alphabet has incorrect length (should be 64, not "
- + alphabet.length() + ")");
- inverseAlphabet = new int[128];
- Arrays.fill(inverseAlphabet, -1);
- for (int i = 0; i < this.alphabet.length; i++) {
- final char ch = this.alphabet[i];
- if (ch >= 128)
- throw new IllegalArgumentException("invalid character in alphabet: " + ch);
- inverseAlphabet[ch] = i;
- }
- }
+ private static final int ALPHABET_LENGTH = 64;
+ private final char[] alphabet;
+ private final int[] inverseAlphabet;
+
+ /**
+ * Initializes the class with the specified encoding/decoding alphabet.
+ *
+ * @param alphabet
+ * @throws IllegalArgumentException if alphabet is not 64 characters long or
+ * contains characters which are not 7-bit ASCII
+ */
+ Base64Util(final String alphabet) {
+ this.alphabet = alphabet.toCharArray();
+ if (alphabet.length() != ALPHABET_LENGTH) throw new IllegalArgumentException(
+ "alphabet has incorrect length (should be 64, not " + alphabet.length() + ")"
+ );
+ inverseAlphabet = new int[128];
+ Arrays.fill(inverseAlphabet, -1);
+ for (int i = 0; i < this.alphabet.length; i++) {
+ final char ch = this.alphabet[i];
+ if (ch >= 128) throw new IllegalArgumentException("invalid character in alphabet: " + ch);
+ inverseAlphabet[ch] = i;
+ }
+ }
- /**
- * Returns the integer value of the six bits represented by the specified character.
- *
- * @param ch The character, as a ASCII encoded byte
- * @return The six bits, as an integer value, or -1 if the byte is not in the alphabet
- */
- int getSextet(final byte ch) {
- if (ch >= 128)
- return -1;
- return inverseAlphabet[ch];
- }
+ /**
+ * Returns the integer value of the six bits represented by the specified character.
+ *
+ * @param ch The character, as a ASCII encoded byte
+ * @return The six bits, as an integer value, or -1 if the byte is not in the alphabet
+ */
+ int getSextet(final byte ch) {
+ if (ch >= 128) return -1;
+ return inverseAlphabet[ch];
+ }
- /**
- * Tells whether the alphabet contains the specified character.
- *
- * @param ch The character
- * @return true if the alphabet contains ch, false otherwise
- */
- boolean contains(final char ch) {
- if (ch >= 128)
- return false;
- return inverseAlphabet[ch] >= 0;
- }
+ /**
+ * Tells whether the alphabet contains the specified character.
+ *
+ * @param ch The character
+ * @return true if the alphabet contains ch, false otherwise
+ */
+ boolean contains(final char ch) {
+ if (ch >= 128) return false;
+ return inverseAlphabet[ch] >= 0;
+ }
- /**
- * Encodes the six bit group as a character.
- *
- * @param sextet The six bit group to be encoded
- * @return The ASCII value of the character
- */
- byte getChar(final int sextet) {
- return (byte) alphabet[sextet];
- }
+ /**
+ * Encodes the six bit group as a character.
+ *
+ * @param sextet The six bit group to be encoded
+ * @return The ASCII value of the character
+ */
+ byte getChar(final int sextet) {
+ return (byte) alphabet[sextet];
+ }
}
diff --git a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/charsets/jutf7/ModifiedUTF7Charset.java b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/charsets/jutf7/ModifiedUTF7Charset.java
index 1eae7868..886702f9 100644
--- a/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/charsets/jutf7/ModifiedUTF7Charset.java
+++ b/mailextractlib/src/main/java/fr/gouv/vitam/tools/mailextractlib/store/javamail/charsets/jutf7/ModifiedUTF7Charset.java
@@ -1,54 +1,67 @@
-/* ====================================================================
- * Copyright (c) 2006 J.T. Beetstra
+/**
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2022)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to provide
+ * tools for construction and manipulation of SIP (Submission
+ * Information Package) conform to the SEDA (Standard d’Échange
+ * de données pour l’Archivage) standard.
+ *
+ * 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".
*
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
+ * 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.
*
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
+ * 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 SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * ====================================================================
+ * 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.vitam.tools.mailextractlib.store.javamail.charsets.jutf7;
-
/**
* CoderResult.OVERFLOW (as is
- * required by the specification) if insufficient space is available in the output
- * buffer. However, calling it again on JDKs before Java 6 triggers a bug in
- * {@link CharsetEncoder#flush(ByteBuffer)} causing it to throw an
- * IllegalStateException (the buggy method is final, thus cannot be
- * overridden).CoderResult.OVERFLOW (as is
+ * required by the specification) if insufficient space is available in the output
+ * buffer. However, calling it again on JDKs before Java 6 triggers a bug in
+ * {@link CharsetEncoder#flush(ByteBuffer)} causing it to throw an
+ * IllegalStateException (the buggy method is final, thus cannot be
+ * overridden).CoderResult.OVERFLOW, even
- * though there is sufficient space available in the output buffer. This is done
- * to force the broken implementation of
- * {@link CharsetEncoder#encode(CharBuffer)} to call flush
- * (the buggy method is final, thus cannot be overridden).CoderResult.OVERFLOW, even
+ * though there is sufficient space available in the output buffer. This is done
+ * to force the broken implementation of
+ * {@link CharsetEncoder#encode(CharBuffer)} to call flush
+ * (the buggy method is final, thus cannot be overridden).bitsToOutput and
- * sextet are used to remember the bytes not yet fully determined.bitsToOutput and
+ * sextet are used to remember the bytes not yet fully determined.