Skip to content
Snippets Groups Projects
Commit 826febd8 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- fixed DateTime

- added counters to improve EventOutComeDetail1
parent 8caeb05e
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@
</fr:x_form>
</pl:initParameters>
<pl:description>repairs broken file original paths</pl:description>
<pl:version>1.05</pl:version>
<pl:version>1.08</pl:version>
<pl:materialType>DIGITAL</pl:materialType>
<pl:module>Repository</pl:module>
<pl:generalType>TASK</pl:generalType>
......
......@@ -6,7 +6,9 @@ import com.exlibris.digitool.common.dnx.DnxDocumentHelper;
import com.exlibris.digitool.exceptions.DigitoolException;
import com.exlibris.digitool.repository.api.IEEditor;
import com.exlibris.digitool.repository.api.RepositoryTaskPlugin;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
......@@ -31,6 +33,8 @@ public class DnxMoveFileOriginalPath implements RepositoryTaskPlugin {
taskResults.addResult(ieEditor.getIEPid(), null, false, "no RepPids found!");
return taskResults;
}
int countFiles=0;
int countSuccess=0;
// get all file pids
for (String repPid: repPids) {
List<String> filePids;
......@@ -44,7 +48,8 @@ public class DnxMoveFileOriginalPath implements RepositoryTaskPlugin {
}
for (String filePid: filePids) {
try {
replaceFileOriginalPath(ieEditor, repPid, filePid);
countFiles++;
if (replaceFileOriginalPath(ieEditor, repPid, filePid)) { countSuccess++; }
taskResults.addResult(ieEditor.getIEPid(), null, true, "filepid=" + filePid + " processed");
} catch (DigitoolException e) {
success = false;
......@@ -62,14 +67,16 @@ public class DnxMoveFileOriginalPath implements RepositoryTaskPlugin {
DnxDocumentHelper.Event event = ieDnxH.new Event();
event.setEventIdentifierType("Rosetta-SupportCase");
event.setEventIdentifierValue("00490927");
event.setEventDateTime(LocalDate.now().toString());
LocalDateTime date = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
event.setEventDateTime(date.format(formatter));
event.setEventType("external repair using DnxMoveFileOriginalPath plugin");
if (success) {
event.setEventOutcome1("success");
} else {
event.setEventOutcome1("fail");
}
event.setEventOutcomeDetail1("IE-PID = '" + ieEditor.getIEPid() + "'");
event.setEventOutcomeDetail1("IE-PID = '" + ieEditor.getIEPid() + "', " + countSuccess + " of " + countFiles + " fileOriginalPath entries replaced");
event.setEventDescription("fileOriginalPath needs to be updated to correct a mistake in the Submission Application where wrong fileOriginalPath metadata was read and inserted. The result of this mistake was that the fileOriginalPath now includes directories that are too high up in the directory hierarchy.");
event.setLinkingAgentIdentifierType1("HUMAN");
event.setLinkingAgentIdentifierValue1("plugin programmed by Andreas Romeyke (SLUB Dresden), code available at https://github.com/SLUB-digitalpreservation/fileoriginalpath_plugin4rosetta");
......@@ -85,7 +92,7 @@ public class DnxMoveFileOriginalPath implements RepositoryTaskPlugin {
/* replace file original path if it starts with "file://data/" or "/data/" */
private void replaceFileOriginalPath(IEEditor ieEditor, String repPid, String filePid) throws DigitoolException {
private boolean replaceFileOriginalPath(IEEditor ieEditor, String repPid, String filePid) throws DigitoolException {
DnxDocumentHelper ieDnxH = ieEditor.getDnxHelper(filePid);
DnxDocumentHelper.GeneralFileCharacteristics ieGfs = ieDnxH.getGeneralFileCharacteristics();
String currentFileOriginalPath = ieGfs.getFileOriginalPath();
......@@ -118,6 +125,7 @@ public class DnxMoveFileOriginalPath implements RepositoryTaskPlugin {
ieGfs.setFileOriginalPath(updatedFileOriginalPath);
ieDnxH.setGeneralFileCharacteristics(ieGfs);
ieEditor.setDnx(ieDnxH, filePid);
return updated;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment