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

- added Event reporting about correction call

parent ee8f98f1
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</fr:x_form> </fr:x_form>
</pl:initParameters> </pl:initParameters>
<pl:description>repairs broken file original paths</pl:description> <pl:description>repairs broken file original paths</pl:description>
<pl:version>1.03</pl:version> <pl:version>1.04</pl:version>
<pl:materialType>DIGITAL</pl:materialType> <pl:materialType>DIGITAL</pl:materialType>
<pl:module>Repository</pl:module> <pl:module>Repository</pl:module>
<pl:generalType>TASK</pl:generalType> <pl:generalType>TASK</pl:generalType>
......
...@@ -6,14 +6,14 @@ import com.exlibris.digitool.common.dnx.DnxDocumentHelper; ...@@ -6,14 +6,14 @@ import com.exlibris.digitool.common.dnx.DnxDocumentHelper;
import com.exlibris.digitool.exceptions.DigitoolException; import com.exlibris.digitool.exceptions.DigitoolException;
import com.exlibris.digitool.repository.api.IEEditor; import com.exlibris.digitool.repository.api.IEEditor;
import com.exlibris.digitool.repository.api.RepositoryTaskPlugin; import com.exlibris.digitool.repository.api.RepositoryTaskPlugin;
import java.time.LocalDate;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class DnxMoveFileOriginalPath implements RepositoryTaskPlugin { public class DnxMoveFileOriginalPath implements RepositoryTaskPlugin {
ExLogger log = ExLogger.getExLogger(DnxMoveFileOriginalPath.class); private ExLogger log = ExLogger.getExLogger(DnxMoveFileOriginalPath.class);
private boolean success = true;
public DnxMoveFileOriginalPath() { public DnxMoveFileOriginalPath() {
super(); super();
} }
...@@ -22,19 +22,22 @@ public class DnxMoveFileOriginalPath implements RepositoryTaskPlugin { ...@@ -22,19 +22,22 @@ public class DnxMoveFileOriginalPath implements RepositoryTaskPlugin {
log.info("Executing DnxMoveFileOriginalPath for " + ieEditor.getIEPid()); log.info("Executing DnxMoveFileOriginalPath for " + ieEditor.getIEPid());
init(initParams); init(initParams);
// get all rep pids // get all rep pids
List<String> repPids = null; List<String> repPids;
try { try {
repPids = ieEditor.getReps(); repPids = ieEditor.getReps();
} catch (DigitoolException e) { } catch (DigitoolException e) {
success = false;
e.printStackTrace(); e.printStackTrace();
taskResults.addResult(ieEditor.getIEPid(), null, false, "no RepPids found!"); taskResults.addResult(ieEditor.getIEPid(), null, false, "no RepPids found!");
return taskResults; return taskResults;
} }
// get all file pids
for (String repPid: repPids) { for (String repPid: repPids) {
List<String> filePids = null; List<String> filePids;
try { try {
filePids = ieEditor.getFilesForRep( repPid ); filePids = ieEditor.getFilesForRep( repPid );
} catch (DigitoolException e) { } catch (DigitoolException e) {
success = false;
e.printStackTrace(); e.printStackTrace();
taskResults.addResult(ieEditor.getIEPid(), null, false, "no FilePids found for RepPid=" + repPid + " !"); taskResults.addResult(ieEditor.getIEPid(), null, false, "no FilePids found for RepPid=" + repPid + " !");
return taskResults; return taskResults;
...@@ -44,13 +47,37 @@ public class DnxMoveFileOriginalPath implements RepositoryTaskPlugin { ...@@ -44,13 +47,37 @@ public class DnxMoveFileOriginalPath implements RepositoryTaskPlugin {
replaceFileOriginalPath(ieEditor, repPid, filePid); replaceFileOriginalPath(ieEditor, repPid, filePid);
taskResults.addResult(ieEditor.getIEPid(), null, true, "filepid=" + filePid + " processed"); taskResults.addResult(ieEditor.getIEPid(), null, true, "filepid=" + filePid + " processed");
} catch (DigitoolException e) { } catch (DigitoolException e) {
success = false;
e.printStackTrace(); e.printStackTrace();
taskResults.addResult(ieEditor.getIEPid(), null, false, "unknown Digitool exception: " + e); taskResults.addResult(ieEditor.getIEPid(), null, false, "unknown Digitool exception: " + e);
return taskResults; return taskResults;
} }
} }
} }
// now add an event
try {
DnxDocumentHelper ieDnxH = ieEditor.getDnxHelperForIE();
List<DnxDocumentHelper.Event> eventList = ieDnxH.getEvents();
DnxDocumentHelper.Event event = ieDnxH.new Event();
event.setEventIdentifierType("Rosetta-SupportCase");
event.setEventIdentifierValue("00490927");
event.setEventDateTime(LocalDate.now().toString());
event.setEventType("external repair using DnxMoveFileOriginalPath plugin");
if (success) {
event.setEventOutcome1("success");
} else {
event.setEventOutcome1("fail");
}
event.setEventOutcomeDetail1("IE-PID = '" + ieEditor.getIEPid() + "'");
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");
eventList.add( event );
ieDnxH.setEvents( eventList );
} catch (DigitoolException e) {
e.printStackTrace();
}
return taskResults; return taskResults;
} }
...@@ -76,7 +103,7 @@ public class DnxMoveFileOriginalPath implements RepositoryTaskPlugin { ...@@ -76,7 +103,7 @@ public class DnxMoveFileOriginalPath implements RepositoryTaskPlugin {
updated = true; updated = true;
} }
/* if something is updated */ /* if something is updated */
if (updated == true) { if (updated) {
// update it // update it
log.info("update needed for IE " + ieEditor.getIEPid() + " RepPid " + repPid + " FilePid " + filePid + log.info("update needed for IE " + ieEditor.getIEPid() + " RepPid " + repPid + " FilePid " + filePid +
" (old file_original_path='" + currentFileOriginalPath + "') to new file_original_path='" + " (old file_original_path='" + currentFileOriginalPath + "') to new file_original_path='" +
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment