private void logFormatMismatch() { StringBuilder buf = new StringBuilder("all files are not the same format:\n"); for (int i = 0; i < files.size(); i++) { FileData f = files.get(i); String format = "not recognized"; if (f.getFormat() != null) { format = f.getName(); } buf.append(f.getFile().getName()).append(" : ").append(format).append('\n'); } LOGGER.warning(buf.toString()); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; SpatialFile other = (SpatialFile) obj; if (suppFiles == null) { if (other.suppFiles != null) return false; } else if (!suppFiles.equals(other.suppFiles)) return false; return true; }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((suppFiles == null) ? 0 : suppFiles.hashCode()); return result; }
/** * Returns a File from the ImportData, assuming the import data itself is a FileData (a class * cast exception will happen otherwise) * * @param data */ protected File getFileFromData(ImportData data) { assert data instanceof FileData; FileData fileData = (FileData) data; File file = fileData.getFile(); return file; } }
/** * Returns the data format of the files in the directory iff all the files are of the same * format, if they are not this returns null. */ public DataFormat format() throws IOException { if (files.isEmpty()) { LOGGER.warning("no files recognized"); return null; } FileData file = files.get(0); DataFormat format = file.getFormat(); for (int i = 1; i < files.size(); i++) { FileData other = files.get(i); if (format != null && !format.equals(other.getFormat())) { logFormatMismatch(); return null; } if (format == null && other.getFormat() != null) { logFormatMismatch(); return null; } } return format; }
@Override public boolean apply(FileData input) { return name.equals(input.getName()); } });
@Override public void cleanup() throws IOException { File[] files = file.listFiles(); if (files != null) { for (File f : files) { if (f.isDirectory()) { new Directory(f).cleanup(); } else { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Deleting file " + f.getAbsolutePath()); } if (!f.delete()) { throw new IOException("unable to delete " + f); } } } } super.cleanup(); }
FileData fileData = new FileData(file); for (DataFormat df : GeoServerExtensions.extensions(DataFormat.class)) { try {
@Override public void cleanup() throws IOException { cleanupFile(file); }
final FileData spatialData = FileData.createFromFile(file); ImportContext context = (store != null
public FileData(FileData file) { super(file); this.file = file.getFile(); }
/** * Returns the data format of the files in the directory iff all the files are of the same * format, if they are not this returns null. */ public DataFormat format() throws IOException { if (files.isEmpty()) { LOGGER.warning("no files recognized"); return null; } FileData file = files.get(0); DataFormat format = file.getFormat(); for (int i = 1; i < files.size(); i++) { FileData other = files.get(i); if (format != null && !format.equals(other.getFormat())) { logFormatMismatch(); return null; } if (format == null && other.getFormat() != null) { logFormatMismatch(); return null; } } return format; }
@Override public boolean apply(FileData input) { return name.equals(input.getName()); } });
@Override public void cleanup() throws IOException { File[] files = file.listFiles(); if (files != null) { for (File f: files) { if (f.isDirectory()) { new Directory(f).cleanup(); } else { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Deleting file " + f.getAbsolutePath()); } if (!f.delete()) { throw new IOException("unable to delete " + f); } } } } super.cleanup(); }
FileData fileData = new FileData(file); for (DataFormat df : GeoServerExtensions.extensions(DataFormat.class)) { try {
private void logFormatMismatch() { StringBuilder buf = new StringBuilder("all files are not the same format:\n"); for (int i = 0; i < files.size(); i++) { FileData f = files.get(i); String format = "not recognized"; if (f.getFormat() != null) { format = f.getName(); } buf.append(f.getFile().getName()).append(" : ").append(format).append('\n'); } LOGGER.warning(buf.toString()); }
private File getFileFromData(ImportData data) { assert data instanceof FileData; FileData fileData = (FileData) data; File file = fileData.getFile(); return file; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; SpatialFile other = (SpatialFile) obj; if (suppFiles == null) { if (other.suppFiles != null) return false; } else if (!suppFiles.equals(other.suppFiles)) return false; return true; }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((suppFiles == null) ? 0 : suppFiles.hashCode()); return result; }