static void validateInput(final File file) throws IOException { if (ZipUtils.isZip(file)) { if(!ZipUtils.findInZip(file, "s1", ".tiff")) { throw new IOException("measurement folder is missing in product"); } } else { final File baseFolder = file.getParentFile(); final File annotationFolder = new File(baseFolder, ANNOTATION); if (!annotationFolder.exists()) { throw new IOException("annotation folder is missing in product"); } } }
@Override protected String findRootFolder() { String rootFolder = ""; try { if (isCompressed()) { rootFolder = ZipUtils.getRootFolder(getBaseDir(), "manifest.safe"); } } catch (IOException e) { SystemUtils.LOG.severe("Unable to get root path from zip file " + e.getMessage()); } return rootFolder; }
private synchronized Raster getData(final ImageReadParam param, final int destOffsetX, final int destOffsetY, final int destWidth, final int destHeight) throws IOException { try { final RenderedImage image = reader.readAsRenderedImage(0, param); return image.getData(new Rectangle(destOffsetX, destOffsetY, destWidth, destHeight)); } catch (Exception e) { if(ZipUtils.isZip(productInputFile) && !ZipUtils.isValid(productInputFile)) { throw new IOException("Zip file is corrupt "+productInputFile.getName()); } throw e; } }
protected String getHeaderFileName() { if (ZipUtils.isZip(headerFile)) { return ""; //todo } else { return headerFile.getName(); } }
@Override protected DecodeQualification checkProductQualification(File file) { final String name = file.getName().toUpperCase(); if(name.contains("ALOS2")) { for (String prefix : constants.getVolumeFilePrefix()) { if (name.startsWith(prefix)) { final Alos2ProductReader reader = new Alos2ProductReader(this); return reader.checkProductQualification(file); } } } if (name.endsWith(".ZIP") && (ZipUtils.findInZip(file, "vol-alos2", ""))) { return DecodeQualification.INTENDED; } return DecodeQualification.UNABLE; }
private static void getQCFiles(final String missionPrefix, final String orbitType, int year, int month, final double stateVectorTime) throws Exception { final File localFolder = getDestFolder(missionPrefix, orbitType, year, month); final QCScraper qc = new QCScraper(orbitType); final String[] orbitFiles = qc.getFileURLs(missionPrefix, year, month); final URL remotePath = new URL(qc.getRemoteURL()); final SSLUtil ssl = new SSLUtil(); ssl.disableSSLCertificateCheck(); for (String file : orbitFiles) { if (isWithinRange(file, stateVectorTime)) { final File localFile = new File(localFolder, file); DownloadableContentImpl.getRemoteHttpFile(remotePath, localFile); if (localFile.exists()) { final File localZipFile = FileUtils.exchangeExtension(localFile, ".EOF.zip"); ZipUtils.zipFile(localFile, localZipFile); localFile.delete(); } } } ssl.enableSSLCertificateCheck(); }
protected String getHeaderFileName() { if (ZipUtils.isZip(productInputFile)) { try { String[] files = listFiles(""); for (String file : files) { if (file.startsWith("SS_") && file.endsWith(".xml") && !file.endsWith(".iso.xml")) { return file; } } } catch (Exception e) { } } return productInputFile.getName(); }
/** * Checks whether the given object is an acceptable input for this product reader and if so, the method checks if it * is capable of decoding the input's content. * * @param input any input object * @return true if this product reader can decode the given input, otherwise false. */ public DecodeQualification getDecodeQualification(final Object input) { final File file = ReaderUtils.getFileFromInput(input); if (file != null) { final File metadataFile = findMetadataFile(file); if (metadataFile != null) { return DecodeQualification.INTENDED; } final String filename = file.getName().toLowerCase(); if (filename.endsWith(".zip") && ZipUtils.findInZip(file, "", Risat1Constants.BAND_HEADER_NAME)) { return DecodeQualification.INTENDED; } } //todo zip stream return DecodeQualification.UNABLE; }
protected void createProductDir(final File inputFile) { if (ZipUtils.isZip(inputFile)) { baseDir = inputFile; productDir = VirtualDir.create(baseDir); baseName = baseDir.getName(); if(baseName.endsWith(".zip")) { baseName = baseName.substring(0, baseName.lastIndexOf(".zip")); } } else { baseDir = inputFile.getParentFile(); productDir = VirtualDir.create(baseDir); baseName = baseDir.getName(); } }
ZipUtils.findInZip(file, "", Radarsat2Constants.PRODUCT_HEADER_NAME)) { return DecodeQualification.INTENDED;
protected String findRootFolder() { String rootFolder = ""; try { if (productDir.isCompressed()) { rootFolder = ZipUtils.getRootFolder(baseDir, getHeaderFileName()); } } catch (IOException e) { SystemUtils.LOG.severe("Unable to get root path from zip file " + e.getMessage()); } return rootFolder; }
static boolean isLevel2(final File file) { if (ZipUtils.isZip(file)) { return ZipUtils.findInZip(file, "s1", ".nc"); } else { final File baseFolder = file.getParentFile(); final File measurementFolder = new File(baseFolder, MEASUREMENT); return measurementFolder.exists() && checkFolder(measurementFolder, ".nc"); } }
protected VirtualDir createProductDir(final File inputFile) { if (ZipUtils.isZip(inputFile)) { return VirtualDir.create(inputFile); } else { return VirtualDir.create(inputFile.getParentFile()); } }
/** * Checks whether the given object is an acceptable input for this product reader and if so, the method checks if it * is capable of decoding the input's content. * * @param input any input object * @return true if this product reader can decode the given input, otherwise false. */ public DecodeQualification getDecodeQualification(final Object input) { final File file = ReaderUtils.getFileFromInput(input); if (file != null) { final String filename = file.getName().toUpperCase(); if (filename.startsWith(SeaSatConstants.PRODUCT_HEADER_PREFIX)) { if (filename.endsWith(SeaSatConstants.getIndicationKey()) && !filename.endsWith(".ISO.XML")) { return DecodeQualification.INTENDED; } if (filename.endsWith(".ZIP") && ZipUtils.findInZip(file, SeaSatConstants.PRODUCT_HEADER_PREFIX, SeaSatConstants.getIndicationKey())) { return DecodeQualification.INTENDED; } } } //todo zip stream return DecodeQualification.UNABLE; }
static boolean isLevel1(final File file) { if (ZipUtils.isZip(file)) { if(ZipUtils.findInZip(file, "s1", ".tiff")) { return true; } final String name = file.getName().toUpperCase(); return name.contains("_1AS") || name.contains("_1AD") || name.contains("_1SS") || name.contains("_1SD"); } else { final File baseFolder = file.getParentFile(); final File annotationFolder = new File(baseFolder, ANNOTATION); return annotationFolder.exists() && checkFolder(annotationFolder, ".xml"); } }
/** * Checks whether the given object is an acceptable input for this product reader and if so, the method checks if it * is capable of decoding the input's content. * * @param input any input object * @return true if this product reader can decode the given input, otherwise false. */ public DecodeQualification getDecodeQualification(final Object input) { final File file = ReaderUtils.getFileFromInput(input); if (file != null) { if (file.getName().startsWith(PRODUCT_PREFIX) && ZipUtils.isZip(file)) { return DecodeQualification.INTENDED; } if (findMetadataFile(file) != null) { return DecodeQualification.INTENDED; } } return DecodeQualification.UNABLE; }