Permalink
Browse files

remove extraneous logging in staging job

added create time to METS on capture
  • Loading branch information...
1 parent 4a6bca8 commit bddcc50fbb5ea11c05cb5da2c243c6a32ed41f55 @gregjan gregjan committed Mar 8, 2013
@@ -40,11 +40,14 @@
import java.net.URLConnection;
import java.util.Collection;
import java.util.Date;
+import java.util.GregorianCalendar;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import javax.activation.MimetypesFileTypeMap;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
@@ -204,14 +207,24 @@ public static DivType findBagDiv(MetsType m) {
* the original IFile
* @return the file element
*/
- public static FileType addFile(MetsType mets, URI originalData, String xmlid, long size, String md5) {
+ public static FileType addFile(MetsType mets, URI originalData, String xmlid, long size, Long createdTimestamp, String md5) {
FileType f = MetsFactory.eINSTANCE.createFileType();
f.setID(xmlid);
if (md5 != null) {
f.setCHECKSUMTYPE(CHECKSUMTYPEType.MD5);
f.setCHECKSUM(md5);
}
+ if(createdTimestamp != null) {
+ GregorianCalendar cal= (GregorianCalendar) GregorianCalendar.getInstance();
+ cal.setTimeInMillis(createdTimestamp.longValue());
+ try {
+ XMLGregorianCalendar createdCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
+ f.setCREATED(createdCal);
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
f.setSIZE(size);
FileNameMap fileNameMap = URLConnection.getFileNameMap();
String type = fileNameMap.getContentTypeFor(originalData.toString());
@@ -24,6 +24,12 @@
import gov.loc.mets.util.METSConstants;
import gov.loc.mets.util.METSUtils;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.FileTime;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Arrays;
@@ -310,11 +316,18 @@ private DivType makeDiv(OriginalFileStore original) throws CoreException {
// calc size and checksum.
IFileInfo sourceFileInfo = original.fetchInfo();
long size = sourceFileInfo.getLength();
-
+ //long lastModifiedTimestamp = sourceFileInfo.getLastModified();
+ Long createTimestamp = null;
+ Path path = Paths.get(original.getWrapped().toURI());
+ try {
+ BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
+ FileTime create = attr.creationTime();
+ if(create != null) createTimestamp = new Long(create.toMillis());
+ } catch(IOException ignored) {}
// find File section (for previously captured) or make one
FileType ft = original.getMetsFileType();
if (ft == null) {
- ft = METSUtils.addFile(m, original.getWrapped().toURI(), original.getFileID(), size, null);
+ ft = METSUtils.addFile(m, original.getWrapped().toURI(), original.getFileID(), size, createTimestamp, null);
}
FptrType fptr = MetsFactory.eINSTANCE.createFptrType();
@@ -107,9 +107,9 @@ protected IStatus run(IProgressMonitor monitor) {
FLocatType loc = original.getStagingLocatorType();
if (loc == null) {
toStage.add(original);
- System.err.println(" queued");
+ //System.err.println(" queued");
} else {
- System.err.println(" found stage flocat");
+ //System.err.println(" found stage flocat");
}
} else {
System.err.println(" cannot find original");

0 comments on commit bddcc50

Please sign in to comment.