Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- name: Build and Run Tests
run: mvn --settings .ci/github-actions-settings.xml verify
env:
JAVA_TOOL_OPTIONS: "-Duser.timezone=Europe/Paris"
SERVICE_NEXUS_URL: ${{ secrets.SERVICE_NEXUS_URL }}
CI_USR: ${{ secrets.CI_USR }}
CI_PSW: ${{ secrets.CI_PSW }}
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pipeline {

environment {
MVN_BASE = "/usr/local/maven/bin/mvn"
MVN_COMMAND = "${MVN_BASE} --settings ${pwd()}/.ci/settings.xml --show-version --batch-mode --errors --fail-at-end -DinstallAtEnd=true -DdeployAtEnd=true "
MVN_COMMAND = "${MVN_BASE} --settings ${pwd()}/.ci/settings.xml --show-version --batch-mode --errors --fail-at-end -DinstallAtEnd=true -DdeployAtEnd=true -Duser.timezone=Europe/Paris"
DEPLOY_GOAL = " " // Deploy goal used by maven ; typically "deploy" for master* branches & "" (nothing) for everything else (we don't deploy) ; keep a space so can work in other branches than develop
CI = credentials("app-jenkins")
SERVICE_SONAR_URL = credentials("service-sonar-url")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,6 @@ public static void initDefaultExtractors(boolean allowsExternalToolsForTextExtra
* errors, it could lead to silent data loss or misinterpretation if the encoded data is critical.
*/
System.setProperty("mail.mime.base64.ignoreerrors", "true");

/*
* Set the default time zone of the application to UTC.
* This ensures that MIME message generation will use normalized
* UTC dates everywhere. This is important for consistency across
* different systems and timezones.
*/
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
}

private static void preventExternalToolsForTextExtractionInTika() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Date: Mon, 19 Aug 2019 21:18:50 +0000 (UTC)
Date: Mon, 19 Aug 2019 23:18:50 +0200 (CEST)
From: "Test" <test@programmevitam.fr>
To: <test-a@programmevitam.fr>
Message-ID: <003e01d556d3$b3116ed0$19344c70$@programmevitam.fr>
Expand Down
4 changes: 2 additions & 2 deletions mailextractlib/src/test/resources/msg/results/mail.eml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Date: Mon, 19 Aug 2019 21:30:50 +0000 (UTC)
Date: Mon, 19 Aug 2019 23:30:50 +0200 (CEST)
From: "Test" <test@programmevitam.fr>
To: <test-a@programmevitam.fr>,<test-b@programmevitam.fr>
Message-ID: <000c01d556d5$611cfc50$2356f4f0$@programmevitam.fr>
Expand Down Expand Up @@ -72,7 +72,7 @@ div.WordSection1
Content-Type: message/rfc822; name="Test message 1.eml"
Content-Disposition: attachment; filename="Test message 1.eml"

Date: Mon, 19 Aug 2019 21:18:50 +0000 (UTC)
Date: Mon, 19 Aug 2019 23:18:50 +0200 (CEST)
From: "Test" <test@programmevitam.fr>
To: <test-a@programmevitam.fr>
Message-ID: <003e01d556d3$b3116ed0$19344c70$@programmevitam.fr>
Expand Down
4 changes: 2 additions & 2 deletions mailextractlib/src/test/resources/pst/results/mail.eml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Date: Mon, 19 Aug 2019 21:30:50 +0000 (UTC)
Date: Mon, 19 Aug 2019 23:30:50 +0200 (CEST)
From: "Test" <test@programmevitam.fr>
To: <test-a@programmevitam.fr>,<test-b@programmevitam.fr>
Message-ID: <000c01d556d5$611cfc50$2356f4f0$@programmevitam.fr>
Expand Down Expand Up @@ -71,7 +71,7 @@ div.WordSection1
Content-Type: message/rfc822; name="Test message 1.eml"
Content-Disposition: attachment; filename="Test message 1.eml"

Date: Mon, 19 Aug 2019 21:18:50 +0000 (UTC)
Date: Mon, 19 Aug 2019 23:18:50 +0200 (CEST)
From: "Test" <test@programmevitam.fr>
To: <test-a@programmevitam.fr>
Message-ID: <003e01d556d3$b3116ed0$19344c70$@programmevitam.fr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@
import fr.gouv.vitam.tools.sedalib.metadata.namedtype.DateTimeType;
import fr.gouv.vitam.tools.sedalib.utils.SEDALibException;

import javax.swing.*;
import java.awt.*;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.temporal.TemporalAccessor;

import fr.gouv.vitam.tools.sedalib.metadata.namedtype.DateTimeType.DateTimeFormatType;

/**
* The DateTimeType object editor class.
Expand All @@ -46,34 +54,87 @@ public class DateTimeTypeEditor extends SEDAObjectEditor {
/**
* The editedObject edition graphic component
*/
private DateTimePicker valueDateTimePicker;
private final DateTimePicker valueDateTimePicker = new DateTimePicker();
private final JLabel warningLabel = new JLabel();
private DateTimeType lastDateTimeType;

/**
* Instantiates a new DateTimeType editor.
*
* @param metadata the DateTimeType editedObject
* @param father the father
* @param parent the parent editor
* @throws SEDALibException if not a DateTimeType editedObject
*/
public DateTimeTypeEditor(SEDAMetadata metadata, SEDAObjectEditor father) throws SEDALibException {
super(metadata, father);
public DateTimeTypeEditor(SEDAMetadata metadata, SEDAObjectEditor parent) throws SEDALibException {
super(metadata, parent);

if (!(metadata instanceof DateTimeType))
throw new SEDALibException("La métadonnée à éditer n'est pas du bon type");

this.update(getInitialValue());

valueDateTimePicker.setDateTimePermissive(getInitialValue().toLocalDateTime());
valueDateTimePicker.addDateTimeChangeListener((event) -> {
LocalDateTime old = event.getOldDateTimePermissive();
LocalDateTime next = event.getNewDateTimePermissive();

if (next != null && !next.equals(old)) {
update(new DateTimeType(getInitialValue().getXmlElementName(), next));
}
});

JPanel labelPanel = new JPanel();
GridBagLayout gbl = new GridBagLayout();
gbl.columnWeights = new double[] { 1.0 };
labelPanel.setLayout(gbl);

JLabel label = new JLabel(getName() + " :");
label.setToolTipText(getTag());
label.setFont(SEDAObjectEditor.LABEL_FONT);
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.LINE_END;
gbc.insets = new Insets(0, 5, 0, 0);
gbc.gridx = 0;
gbc.gridy = 0;
labelPanel.add(label, gbc);

JPanel editPanel = new JPanel();
gbl = new GridBagLayout();
gbl.columnWeights = new double[] { 1.0 };
editPanel.setLayout(gbl);

gbc = new GridBagConstraints();
gbc.insets = new Insets(0, 0, 0, 0);
gbc.anchor = GridBagConstraints.LINE_START;
gbc.gridx = 0;
gbc.gridy = 0;
editPanel.add(valueDateTimePicker, gbc);

gbc = new GridBagConstraints();
gbc.insets = new Insets(0, 0, 0, 0);
gbc.anchor = GridBagConstraints.LINE_START;
gbc.gridx = 0;
gbc.gridy = 1;
editPanel.add(warningLabel, gbc);

this.sedaObjectEditorPanel = new SEDAObjectEditorSimplePanel(this, labelPanel, editPanel);
}

private DateTimeType getDateTimeTypeMetadata() {
private DateTimeType getInitialValue() {
return (DateTimeType) editedObject;
}

/**
* Gets DateTimeType sample.
*
* @param elementName the element name, corresponding to the XML tag in SEDA
* @param minimal the minimal flag, if true subfields are selected and values are empty, if false all subfields are added and values are default values
* @param minimal the minimal flag, if true subfields are selected and
* values are empty, if false all subfields are added and
* values are default values
* @return the seda editedObject sample
* @throws SEDALibException the seda lib exception
*/
static public SEDAMetadata getSEDAMetadataSample(String elementName, boolean minimal) throws SEDALibException {
public static SEDAMetadata getSEDAMetadataSample(String elementName, boolean minimal) throws SEDALibException {
if (minimal)
return new DateTimeType(elementName);
else
Expand All @@ -82,8 +143,7 @@ static public SEDAMetadata getSEDAMetadataSample(String elementName, boolean min

@Override
public SEDAMetadata extractEditedObject() throws SEDALibException {
getDateTimeTypeMetadata().setValue(valueDateTimePicker.getDateTimePermissive());
return getDateTimeTypeMetadata();
return lastDateTimeType;
}

@Override
Expand All @@ -96,35 +156,44 @@ public String getSummary() throws SEDALibException {

@Override
public void createSEDAObjectEditorPanel() throws SEDALibException {
JPanel labelPanel = new JPanel();
GridBagLayout gbl = new GridBagLayout();
gbl.columnWeights = new double[]{1.0};
labelPanel.setLayout(gbl);

JLabel label = new JLabel(getName() + " :");
label.setToolTipText(getTag());
label.setFont(SEDAObjectEditor.LABEL_FONT);
GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.LINE_END;
gbc.insets = new Insets(0, 5, 0, 0);
gbc.gridx = 0;
gbc.gridy = 0;
labelPanel.add(label, gbc);
}

JPanel editPanel = new JPanel();
gbl = new GridBagLayout();
gbl.columnWeights = new double[]{1.0};
editPanel.setLayout(gbl);
private String computeWarningMessage(DateTimeType dateTimeType) {
String warning = "";
if (dateTimeType.getFormatTypeEnum() == DateTimeFormatType.OFFSET_DATE_TIME)
warning += " (Timezone)";
TemporalAccessor ta = dateTimeType.getTemporalValue();
if (ta instanceof LocalDateTime) {
LocalDateTime ldt = (LocalDateTime) ta;
if (ldt.getSecond() != 0 || ldt.getNano() != 0)
warning += " (Secondes/Millisecondes)";
} else if (ta instanceof OffsetDateTime) {
OffsetDateTime odt = (OffsetDateTime) ta;
if (odt.getSecond() != 0 || odt.getNano() != 0)
warning += " (Secondes/Millisecondes)";
}

valueDateTimePicker = new DateTimePicker();
valueDateTimePicker.setDateTimePermissive(getDateTimeTypeMetadata().getValue());
gbc = new GridBagConstraints();
gbc.insets = new Insets(0, 0, 0, 0);
gbc.anchor = GridBagConstraints.LINE_START;
gbc.gridx = 0;
gbc.gridy = 0;
editPanel.add(valueDateTimePicker, gbc);
if (!warning.isEmpty()) {
return "Perte si édition en mode structuré: " + warning;
}

this.sedaObjectEditorPanel = new SEDAObjectEditorSimplePanel(this, labelPanel, editPanel);
return "";
}

private String computeWarningTooltip() {
return "Afin de ne pas perdre d'information, \n" +
"il est nécessaire de modifier les dates en mode non structuré.";
}

private void updateWarning(DateTimeType dateTimeType) {
warningLabel.setText(computeWarningMessage(dateTimeType));
warningLabel.setForeground(Color.RED);
warningLabel.setToolTipText(computeWarningTooltip());
}

private void update(DateTimeType next) {
this.lastDateTimeType = next;
this.updateWarning(this.lastDateTimeType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -732,10 +732,7 @@ else if ((sm instanceof TextType) && (((TextType) sm).getLang().equals("fr")))
else if ((sm instanceof EnumType))
return ((EnumType) sm).getValue();
else if (sm instanceof DateTimeType) {
if (((DateTimeType) sm).getValue() == null)
return "";
else
return SEDAXMLStreamWriter.getStringFromDateTime(((DateTimeType) sm).getValue());
return (((DateTimeType) sm).getDateTimeString());
}
}
}
Expand Down
Loading