public CollectionSingleFile(MFile file, org.slf4j.Logger logger) { super(file.getName(), logger); mfiles.add(file); Path p = Paths.get(file.getPath()); if (p.getParent() != null) this.root = p.getParent().toString(); else this.root = System.getProperty("user.dir"); this.lastModified = file.getLastModified(); }
@Override public long getLength() { return mfile.getLength(); }
public int compare(MFile o1, MFile o2) { if (o1.isDirectory() != o2.isDirectory()) return o1.isDirectory() ? 1 : -1; if (isSortIncreasing) return o1.getName().compareTo(o2.getName()); else return o2.getName().compareTo(o1.getName()); } });
protected Dataset(MFile mfile) { this.mfile = mfile; this.cacheLocation = mfile.getPath(); this.enhance = (Set<NetcdfDataset.Enhance>) mfile.getAuxInfo(); }
public CollectionConfig subdir(MFile child) { return new CollectionConfig( name+"/"+child.getName(), dirName+"/"+child.getName(), wantSubdirs, ff, child.getAuxInfo()); }
public String rename(MFile mfile) { String name = namer.onName ? mfile.getName() : mfile.getPath(); java.util.regex.Matcher matcher = this.pattern.matcher(name); if (!matcher.find()) return null; StringBuffer startTime = new StringBuffer(); matcher.appendReplacement(startTime, namer.replaceString); startTime.delete(0, matcher.start()); if (startTime.length() == 0) return null; return startTime.toString(); } }
public boolean hasChangedSince(MFile file, long when) { String idxPath = file.getPath(); if (!idxPath.endsWith(GBX9_IDX)) idxPath += GBX9_IDX; File idxFile = GribIndexCache.getExistingFileOrCache(idxPath); if (idxFile == null) return true; long idxLastModified = idxFile.lastModified(); if (idxLastModified < file.getLastModified()) return true; if (0 < when && when < idxLastModified) return true; return false; } public boolean hasntChangedSince(MFile file, long when) {
/** * Get the location of this Dataset * * @return the location of this Dataset */ public String getLocation() { return (mfile == null) ? cacheLocation : mfile.getPath(); }
if (mfile.isDirectory()) continue; if (now - mfile.getLastModified() < config.addLatest.lastModLimit) continue; String urlPath = parentPath + mfile.getName(); ds.put(Dataset.UrlPath, urlPath); ds.put(Dataset.DataSize, mfile.getLength()); // <dataSize units="Kbytes">54.73</dataSize> CalendarDate date = CalendarDate.of(mfile.getLastModified()); ds.put(Dataset.Dates, new DateType(date).setType("modified")); // <date type="modified">2011-09-02T20:50:58.288Z</date> ds.put(Dataset.Id, parentId + mfile.getName());
@Override public String getName() { return mfile.getName(); }
public static List<GcMFile> makeFiles(File directory, List<MFile> files, Set<Integer> allFileSet) { List<GcMFile> result = new ArrayList<>(files.size()); String dirPath = StringUtil2.replace(directory.getPath(), '\\', "/"); for (int index : allFileSet) { MFile file = files.get(index); String filename; if (file.getPath().startsWith(dirPath)) { filename = file.getPath().substring(dirPath.length()); if (filename.startsWith("/")) filename = filename.substring(1); } else filename = file.getPath(); // when does this happen ?? result.add( new GcMFile(directory, filename, file.getLastModified(), file.getLength(), index)); } return result; }
protected void reallyScan(java.util.Map<String, MFile> map) throws IOException { getController(); // make sure a controller is instantiated // run through all scanners and collect MFile instances into the Map for (MCollection mc : scanList) { // lOOK: are there any circumstances where we dont need to recheck against OS, ie always use cached values? Iterator<MFile> iter = (mc.wantSubdirs()) ? controller.getInventoryAll(mc, true) : controller.getInventoryTop(mc, true); /// NCDC wants subdir /global/nomads/nexus/gfsanl/**/gfsanl_3_.*\.grb$ if (iter == null) { logger.error(collectionName + ": Invalid collection= " + mc); continue; } int count = 0; while (iter.hasNext()) { MFile mfile = iter.next(); mfile.setAuxInfo(mc.getAuxInfo()); map.put(mfile.getPath(), mfile); count++; } logger.debug("{} : was scanned nfiles= {} ", collectionName, count); } if (map.size() == 0) { logger.warn("MFileCollectionManager: No files found for {}", collectionName); } }
@Override public long getLastModified() { return mfile.getLastModified(); }
@Override public boolean isDirectory() { return mfile.isDirectory(); }
@Override public void setAuxInfo(Object info) { mfile.setAuxInfo(info); }
@Override public Object getAuxInfo() { return mfile.getAuxInfo(); }
public boolean hasntChangedSince(MFile file, long when) { String idxPath = file.getPath(); if (!idxPath.endsWith(GBX9_IDX)) idxPath += GBX9_IDX; File idxFile = GribIndexCache.getExistingFileOrCache(idxPath); if (idxFile == null) return true; if (idxFile.lastModified() < file.getLastModified()) return true; if (0 < when && idxFile.lastModified() < when) return true; return false; } };
/** * Get the location of this Dataset * * @return the location of this Dataset */ public String getLocation() { return (mfile == null) ? cacheLocation : mfile.getPath(); }