Changeset 7465
- Timestamp:
- 2004-05-27T14:08:15+12:00 (20 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFile.java
r6014 r7465 139 139 { String mimeType; 140 140 141 if (url. toString().startsWith("file://"))141 if (url.getProtocol().equals("file")) 142 142 { // TODO: Work out the MIME type 143 143 mimeType = URLConnection.getFileNameMap().getContentTypeFor(url.toString().substring(7)); … … 288 288 } 289 289 290 /** 291 * Get the location of this file as a URL 292 */ 290 293 public URL getURL() 291 294 { return this.location.getLocation(); 292 295 } 293 296 297 /** 298 * 299 */ 300 public long getModifiedDatestamp() 301 { return this.location.getModifiedDatestamp(); 302 } 294 303 295 304 /** -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFileGroup.java
r6287 r7465 37 37 } 38 38 39 /** 40 * Get the modified datestamp that applies for this file group. An empty group 41 * will return <code>0</code>. 42 * 43 * @return <code>long</code> the date modified as milliseconds from the 1st January 1970 44 */ 45 public long getModifiedDatestamp() 46 { long reply = 0; // empty groups reply '0' 47 48 Iterator childIter = children.iterator(); 49 while (childIter.hasNext()) 50 { METSFile file = (METSFile) childIter.next(); 51 long fileStamp = file.getModifiedDatestamp(); 52 if (fileStamp > reply) { 53 reply = fileStamp; 54 } 55 } 56 57 childIter = childGroups.iterator(); 58 while (childIter.hasNext()) 59 { METSFileGroup fileGroup = (METSFileGroup) childIter.next(); 60 long fileStamp = fileGroup.getModifiedDatestamp(); 61 if (fileStamp > reply) { 62 reply = fileStamp; 63 } 64 } 65 66 return reply; 67 } 68 39 69 /** 40 70 * Find all the occurrences of a given file, and place them -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFilePos.java
r5945 r7465 28 28 } 29 29 30 public long getModifiedDatestamp() 31 { return this.location.getModifiedDatestamp(); 32 } 33 30 34 public String toString() 31 35 { return this.location.getLocation().toString(); -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFileSet.java
r6287 r7465 47 47 } 48 48 49 public long getModifiedDatestamp() 50 { long reply = 0; 51 52 Iterator groupsIter = this.fileGroups.values().iterator(); 53 while (groupsIter.hasNext()) 54 { METSFileGroup group = (METSFileGroup) groupsIter.next(); 55 56 long groupStamp = group.getModifiedDatestamp(); 57 if (groupStamp > reply) 58 { reply = groupStamp; 59 } 60 } 61 62 return reply; 63 } 64 65 49 66 /** 50 67 * Get a new FileGroup to lie within this fileset. The group is not initialised with … … 92 109 } 93 110 111 /** 112 * Add a file to the default file group 113 */ 94 114 public void addFile(METSFile file) 95 115 { METSFileGroup defaultGroup = (METSFileGroup) this.fileGroups.get("default"); … … 97 117 } 98 118 119 /** 120 * Add a file to the default file group 121 * 122 * @return <code>METSFile</code> an object that wraps the given url into 123 * a METS file object 124 */ 99 125 public METSFile addFile(URL url) 100 126 { METSFile file = METSFile.makeMETSFile(url); -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSLocation.java
r5945 r7465 3 3 import java.io.File; 4 4 import java.net.URL; 5 import java.net.URLConnection; 6 7 import org.greenstone.gsdl3.gs3build.util.URLTools; 5 8 6 9 public class METSLocation … … 19 22 } 20 23 21 public METSLocation(File file) throws java.net.MalformedURLException24 public METSLocation(File file) 22 25 { this.type = "URL"; 23 this.location = new URL("file://" + file.toString());26 this.location = URLTools.getFileURL(file); 24 27 } 25 28 … … 32 35 } 33 36 37 public long getModifiedDatestamp() 38 { if (this.location != null) { 39 if (this.location.getProtocol().equals("file")) { 40 File file = new File(this.location.getPath()); 41 return file.lastModified(); 42 } 43 else { 44 try { 45 URLConnection connection = this.location.openConnection(); 46 return connection.getLastModified(); 47 } 48 catch (java.io.IOException io) 49 { // TODO: report error 50 } 51 } 52 } 53 return System.currentTimeMillis(); 54 } 55 34 56 public String getType() 35 57 { return this.type;
Note:
See TracChangeset
for help on using the changeset viewer.