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

- file creation/modification date extracted by GeneralObjectCharacteristics as...

- file creation/modification date extracted by GeneralObjectCharacteristics as suggested in Supportcase https://exlibrisgroup--c.na62.visual.force.com/apex/VF_Case_WithoutJira?id=5000e00001LYpukAAD
- bugfix, parse date using SimpleDateFormat uses parse string now
- fixed default values in plugin config
parent 4573875f
No related branches found
No related tags found
No related merge requests found
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<mandatory>true</mandatory> <mandatory>true</mandatory>
<x_logic_type>String</x_logic_type> <x_logic_type>String</x_logic_type>
<x_ui_type>TextField</x_ui_type> <x_ui_type>TextField</x_ui_type>
<default_value>localhost</default_value> <default_value>Goobi_SMA</default_value>
<css_class>width40</css_class> <css_class>width40</css_class>
<x_options></x_options> <x_options></x_options>
</x_field> </x_field>
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
<mandatory>true</mandatory> <mandatory>true</mandatory>
<x_logic_type>String</x_logic_type> <x_logic_type>String</x_logic_type>
<x_ui_type>TextField</x_ui_type> <x_ui_type>TextField</x_ui_type>
<default_value>localhost</default_value> <default_value>SLUB</default_value>
<css_class>width40</css_class> <css_class>width40</css_class>
<x_options></x_options> <x_options></x_options>
</x_field> </x_field>
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
<mandatory>true</mandatory> <mandatory>true</mandatory>
<x_logic_type>String</x_logic_type> <x_logic_type>String</x_logic_type>
<x_ui_type>TextField</x_ui_type> <x_ui_type>TextField</x_ui_type>
<default_value>localhost</default_value> <default_value>a12345678A</default_value>
<css_class>width40</css_class> <css_class>width40</css_class>
<x_options></x_options> <x_options></x_options>
</x_field> </x_field>
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
</fr:x_form> </fr:x_form>
</pl:initParameters> </pl:initParameters>
<pl:description>repairs broken file original paths with dublettes, see <a href="https://intranet.slub-dresden.de/display/LZA/Umgang+mit+Updates+auf+alte+Kitodo-AIPs">https://intranet.slub-dresden.de/display/LZA/Umgang+mit+Updates+auf+alte+Kitodo-AIPs</a></pl:description> <pl:description>repairs broken file original paths with dublettes, see <a href="https://intranet.slub-dresden.de/display/LZA/Umgang+mit+Updates+auf+alte+Kitodo-AIPs">https://intranet.slub-dresden.de/display/LZA/Umgang+mit+Updates+auf+alte+Kitodo-AIPs</a></pl:description>
<pl:version>1.3</pl:version> <pl:version>1.6</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>
......
...@@ -122,6 +122,26 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug ...@@ -122,6 +122,26 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
} }
} }
private String get_file_object_creation_date (IEEditor ieEditor, String filePid) throws DigitoolException {
DnxDocumentHelper ieDnxH = ieEditor.getDnxHelper(filePid);
DnxDocumentHelper.ObjectCharacteristics ieOs = ieDnxH.getObjectCharacteristics();
String file_cre_date = ieOs.getInternalCreationDate();
return file_cre_date;
}
private String get_file_object_modification_date (IEEditor ieEditor, String filePid) throws DigitoolException {
DnxDocumentHelper ieDnxH = ieEditor.getDnxHelper(filePid);
DnxDocumentHelper.ObjectCharacteristics ieOs = ieDnxH.getObjectCharacteristics();
String file_mod_date = ieOs.getInternalModificationDate();
return file_mod_date;
}
private String get_file_object_originalpath (IEEditor ieEditor, String filePid) throws DigitoolException {
DnxDocumentHelper ieDnxH = ieEditor.getDnxHelper(filePid);
DnxDocumentHelper.GeneralFileCharacteristics ieGfs = ieDnxH.getGeneralFileCharacteristics();
String currentFileOriginalPath = ieGfs.getFileOriginalPath();
return currentFileOriginalPath;
}
public TaskResults execute(IEEditor ieEditor, Map<String, String> initParams, TaskResults taskResults) { public TaskResults execute(IEEditor ieEditor, Map<String, String> initParams, TaskResults taskResults) {
log.info("Executing DnxMoveFileOriginalPathDublettesClean for " + ieEditor.getIEPid()); log.info("Executing DnxMoveFileOriginalPathDublettesClean for " + ieEditor.getIEPid());
...@@ -140,15 +160,13 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug ...@@ -140,15 +160,13 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
Map<String, Pair<String,Date>> filePathsWithModificationDate = new HashMap<>(); Map<String, Pair<String,Date>> filePathsWithModificationDate = new HashMap<>();
for (String filePid : filePids) { for (String filePid : filePids) {
try { try {
DnxDocumentHelper ieDnxH = ieEditor.getDnxHelper(filePid); String file_mod_date = get_file_object_modification_date(ieEditor, filePid);
DnxDocumentHelper.GeneralFileCharacteristics ieGfs = ieDnxH.getGeneralFileCharacteristics(); String file_cre_date = get_file_object_creation_date(ieEditor, filePid);
DateFormat date = new SimpleDateFormat(); log.info( "found1 fileobject creationdate='" + file_cre_date + "' file object modification date='" + file_mod_date + "' for filepid=" + filePid );
String file_mod_date = ieGfs.getInternalFileModificationDate(); DateFormat date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String file_cre_date = ieGfs.getInternalFileCreationDate();
log.info( "found1 filecreationdate='" + file_cre_date + "' filemoddate='" + file_mod_date + "' for filepid=" + filePid );
Date currentUpdateDate = date.parse( file_mod_date ); Date currentUpdateDate = date.parse( file_mod_date );
String currentFileOriginalPath = ieGfs.getFileOriginalPath(); String currentFileOriginalPath = get_file_object_originalpath(ieEditor, filePid);
// workaround to check if fileOriginalPath has no "file://" because the replacement // workaround to check if fileOriginalPath has no "file://" because the replacement
// always(!) starts with "file://" // always(!) starts with "file://"
...@@ -242,6 +260,7 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug ...@@ -242,6 +260,7 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
TimeUnit.SECONDS.sleep(2); TimeUnit.SECONDS.sleep(2);
doRep(); doRep();
} catch (Exception e) { } catch (Exception e) {
log.error("unexpected time storage", e);
} }
return taskResults; return taskResults;
...@@ -252,15 +271,12 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug ...@@ -252,15 +271,12 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
/* replace file original path if it starts with "file://data/" or "/data/" */ /* replace file original path if it starts with "file://data/" or "/data/" */
private boolean replaceFileOriginalPath(IEEditor ieEditor, String repPid, String filePid, Map<String, Pair<String,Date>> filePathsWithModificationDate) throws DigitoolException, FileOriginalPathCollisionException, java.text.ParseException { private boolean replaceFileOriginalPath(IEEditor ieEditor, String repPid, String filePid, Map<String, Pair<String,Date>> filePathsWithModificationDate) throws DigitoolException, FileOriginalPathCollisionException, java.text.ParseException {
DnxDocumentHelper ieDnxH = ieEditor.getDnxHelper(filePid); String currentFileOriginalPath = get_file_object_originalpath(ieEditor, filePid);
DnxDocumentHelper.GeneralFileCharacteristics ieGfs = ieDnxH.getGeneralFileCharacteristics();
String currentFileOriginalPath = ieGfs.getFileOriginalPath();
String iePid = ieEditor.getIEPid(); String iePid = ieEditor.getIEPid();
DateFormat date = new SimpleDateFormat(); String file_cre_date = get_file_object_creation_date(ieEditor, filePid);
String file_mod_date = ieGfs.getInternalFileModificationDate(); String file_mod_date = get_file_object_modification_date(ieEditor, filePid);
String file_cre_date = ieGfs.getInternalFileCreationDate(); log.info( "found2 file object creation date='" + file_cre_date + "' file object modification date='" + file_mod_date + "' for filepid=" + filePid );
log.info( "found2 filecreationdate='" + file_cre_date + "' filemoddate='" + file_mod_date + "' for filepid=" + filePid ); DateFormat date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date currentModificationDate = date.parse( file_mod_date ); Date currentModificationDate = date.parse( file_mod_date );
String updatedFileOriginalPath = currentFileOriginalPath; /* default to current to avoid empty string */ String updatedFileOriginalPath = currentFileOriginalPath; /* default to current to avoid empty string */
boolean updated = false; boolean updated = false;
...@@ -273,9 +289,9 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug ...@@ -273,9 +289,9 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
if (filePathsWithModificationDate.containsKey( updatedFileOriginalPath )) { //collision found as expected if (filePathsWithModificationDate.containsKey( updatedFileOriginalPath )) { //collision found as expected
// find file and check date // find file and check date
Date updatedFileModificationDate = new Date(); Date updatedFileModificationDate = new Date();
String updatedFilePid = new String(); // file pid which is outdated now String updatedFilePid = ""; // file pid which is outdated now
for(Map.Entry<String, Pair<String, Date>> entry : filePathsWithModificationDate.entrySet()) { for(Map.Entry<String, Pair<String, Date>> entry : filePathsWithModificationDate.entrySet()) {
if (entry.getKey() == updatedFileOriginalPath) { if (entry.getKey().equals(updatedFileOriginalPath)) {
updatedFilePid = entry.getValue().getKey(); updatedFilePid = entry.getValue().getKey();
updatedFileModificationDate = entry.getValue().getValue(); updatedFileModificationDate = entry.getValue().getValue();
break; break;
...@@ -298,6 +314,7 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug ...@@ -298,6 +314,7 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
} else { // no collision but candidate to rename found } else { // no collision but candidate to rename found
// Do nothing, because we set fileoriginalpath to updated version // Do nothing, because we set fileoriginalpath to updated version
log.info("nothing todo, because no collision but candidate to rename found");
} }
updated = true; updated = true;
log.info("update needed for IE " + ieEditor.getIEPid() + " RepPid " + repPid + " FilePid " + filePid + log.info("update needed for IE " + ieEditor.getIEPid() + " RepPid " + repPid + " FilePid " + filePid +
...@@ -309,6 +326,8 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug ...@@ -309,6 +326,8 @@ public class DnxMoveFileOriginalPathDublettesClean implements RepositoryTaskPlug
log.info("No update needed for IE " + ieEditor.getIEPid() + " RepPid " + repPid + " FilePid " + log.info("No update needed for IE " + ieEditor.getIEPid() + " RepPid " + repPid + " FilePid " +
filePid + " (file_original_path='" + currentFileOriginalPath + "')"); filePid + " (file_original_path='" + currentFileOriginalPath + "')");
} }
DnxDocumentHelper ieDnxH = ieEditor.getDnxHelper(filePid);
DnxDocumentHelper.GeneralFileCharacteristics ieGfs = ieDnxH.getGeneralFileCharacteristics();
ieGfs.setFileOriginalPath(updatedFileOriginalPath); // new set of fileoriginalpath ieGfs.setFileOriginalPath(updatedFileOriginalPath); // new set of fileoriginalpath
ieDnxH.setGeneralFileCharacteristics(ieGfs); ieDnxH.setGeneralFileCharacteristics(ieGfs);
ieEditor.setDnx(ieDnxH, filePid); /* necessary to commit changes on filePID */ ieEditor.setDnx(ieDnxH, filePid); /* necessary to commit changes on filePID */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment