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

- added javadoc comments

- refactoring, simplified code to get IEPID
- raise Exception if IEPID becomes null
- fixed datetimestring (which result in wrong month-value)
parent 31657a75
Branches
Tags
No related merge requests found
...@@ -35,6 +35,7 @@ public class SLUBStoragePlugin extends NFSStoragePlugin { ...@@ -35,6 +35,7 @@ public class SLUBStoragePlugin extends NFSStoragePlugin {
log.info("SLUBStoragePlugin instantiated"); log.info("SLUBStoragePlugin instantiated");
} }
/** copied from NFS Storage Plugin, enhanced with debugging info */
@Override @Override
public String storeEntity(InputStream is, StoredEntityMetaData storedEntityMetadata) throws Exception { public String storeEntity(InputStream is, StoredEntityMetaData storedEntityMetadata) throws Exception {
log.info("SLUBStoragePlugin.storeEntity() called"); log.info("SLUBStoragePlugin.storeEntity() called");
...@@ -63,7 +64,13 @@ public class SLUBStoragePlugin extends NFSStoragePlugin { ...@@ -63,7 +64,13 @@ public class SLUBStoragePlugin extends NFSStoragePlugin {
return storedEntityIdentifier; return storedEntityIdentifier;
} }
// path should be of form yyyy/mm/dd/IE-PID/ /** prepare right path
* path should be of form yyyy/MM/dd/IE-PID/
* we need to findout the associated dnx document (IE),
* get the creation date of the IE/SIP
* and get the IE PID of the associated IE.
* returns the path as string
*/
protected String getStreamRelativePath(StoredEntityMetaData storedEntityMetaData ) throws Exception { protected String getStreamRelativePath(StoredEntityMetaData storedEntityMetaData ) throws Exception {
log.info("SLUBStoragePlugin AAB"); log.info("SLUBStoragePlugin AAB");
String relativeDirectoryPath = File.separator; String relativeDirectoryPath = File.separator;
...@@ -73,48 +80,31 @@ public class SLUBStoragePlugin extends NFSStoragePlugin { ...@@ -73,48 +80,31 @@ public class SLUBStoragePlugin extends NFSStoragePlugin {
String iepid = null; String iepid = null;
log.info ("SLUBStoragePlugin.getStreamRelativePath iesec="+iesec.toString() ); log.info ("SLUBStoragePlugin.getStreamRelativePath iesec="+iesec.toString() );
List<DnxSectionRecord> records = iesec.getRecordList(); List<DnxSectionRecord> records = iesec.getRecordList();
int foo =0;
boolean foundsection = false;
for (Iterator<DnxSectionRecord> iter = records.iterator(); iter.hasNext(); ) { for (Iterator<DnxSectionRecord> iter = records.iterator(); iter.hasNext(); ) {
DnxSectionRecord element = iter.next(); DnxSectionRecord element = iter.next();
foo++; if (element.getKeyById("internalIdentifierType").getValue().equals("PID")) {
log.info("SLUBStoragePlugin.getStreamRelativePath foo=" + foo + " element=" + element.toString()); iepid = element.getKeyById("internalIdentifierValue").getValue();
List<DnxRecordKey> keys = element.getKeylist(); break;
// check if right section
for (Iterator<DnxRecordKey> iter2 = keys.iterator(); iter2.hasNext(); ) {
DnxRecordKey ele2 = iter2.next();
log.info("SLUBStoragePlugin.getStreamRelativePath getId=" + ele2.getId());
log.info("SLUBStoragePlugin.getStreamRelativePath getValue=" + ele2.getValue());
if (
(ele2.getId().equals("internalIdentifierType")) &&
(ele2.getValue().equals("PID"))
) {
foundsection=true;
}
log.info("SLUBStoragePlugin.getStreamRelativePath foundsection=" + foundsection);
}
if (foundsection == true) {
// check pid
for (Iterator<DnxRecordKey> iter2 = keys.iterator(); iter2.hasNext(); ) {
DnxRecordKey ele2 = iter2.next();
if (ele2.getId().equals("internalIdentifierValue")) {
iepid = ele2.getValue();
foundsection = false;
}
} }
} }
// raise Exception if iepid is null
if (null == iepid) {
log.error ("SLUBStoragePlugin.getStreamRelativePath iesec="+iesec.toString() );
throw new Exception("error, could not get IEPID for storedEntityMetaData:"+storedEntityMetaData.toString());
} }
log.info("SLUBStoragePlugin.getStreamRelativePath iepid=" + iepid); log.info("SLUBStoragePlugin.getStreamRelativePath iepid=" + iepid);
// get creationDate of "objectCharacteristics"
String datestring = iedoc.getSectionKeyValue("objectCharacteristics", "creationDate"); String datestring = iedoc.getSectionKeyValue("objectCharacteristics", "creationDate");
Calendar date = Calendar.getInstance(); Calendar date = Calendar.getInstance();
// date: 2014-01-15 14:28:01 // date ist there stored in format (example): 2014-01-15 14:28:01
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
date.setTime(sdf.parse(datestring)); sdf.setLenient(false); /* if parse errors, do not guess about */
Date d = date.getTime(); Date d = sdf.parse(datestring);
date.setTime(d);
log.info("SLUBStoragePlugin.getStreamRelativePath creation Date read=" + datestring + " parsed=" + date.toString()); log.info("SLUBStoragePlugin.getStreamRelativePath creation Date read=" + datestring + " parsed=" + date.toString());
relativeDirectoryPath = relativeDirectoryPath + new SimpleDateFormat("yyyy").format(d); relativeDirectoryPath = relativeDirectoryPath + new SimpleDateFormat("yyyy").format(d);
relativeDirectoryPath = relativeDirectoryPath + File.separator; relativeDirectoryPath = relativeDirectoryPath + File.separator;
relativeDirectoryPath = relativeDirectoryPath + new SimpleDateFormat("MM").format(d); // FIXME: check, why stored in 2014/01/18 instead 2014/02/18 relativeDirectoryPath = relativeDirectoryPath + new SimpleDateFormat("MM").format(d);
relativeDirectoryPath = relativeDirectoryPath + File.separator; relativeDirectoryPath = relativeDirectoryPath + File.separator;
relativeDirectoryPath = relativeDirectoryPath + new SimpleDateFormat("dd").format(d); relativeDirectoryPath = relativeDirectoryPath + new SimpleDateFormat("dd").format(d);
relativeDirectoryPath = relativeDirectoryPath + File.separator; relativeDirectoryPath = relativeDirectoryPath + File.separator;
...@@ -124,6 +114,7 @@ public class SLUBStoragePlugin extends NFSStoragePlugin { ...@@ -124,6 +114,7 @@ public class SLUBStoragePlugin extends NFSStoragePlugin {
return relativeDirectoryPath; return relativeDirectoryPath;
} }
/** copied from NFS Storage Plugin, enhanced with debugging info */
protected File getStreamDirectory(String path, String fileName) { protected File getStreamDirectory(String path, String fileName) {
File newDir = new File(parameters.get(DIR_ROOT) + File.separator + path); File newDir = new File(parameters.get(DIR_ROOT) + File.separator + path);
log.info("SLUBStoragePlugin.getStreamDirectory path=" + path); log.info("SLUBStoragePlugin.getStreamDirectory path=" + path);
...@@ -133,6 +124,7 @@ public class SLUBStoragePlugin extends NFSStoragePlugin { ...@@ -133,6 +124,7 @@ public class SLUBStoragePlugin extends NFSStoragePlugin {
return new File(newDir.getAbsolutePath() + File.separator + fileName); return new File(newDir.getAbsolutePath() + File.separator + fileName);
} }
/** copied from NFS Storage Plugin, enhanced with debugging info */
private boolean canHandleSourcePath(String srcPath) { private boolean canHandleSourcePath(String srcPath) {
try { try {
File file = new File(srcPath); File file = new File(srcPath);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment