private void getRemoteFiles(final String orbitType, final int year) throws Exception { if(!orbitType.contains(DORIS_VOR)) { return; } final File localFolder = new File(Settings.getPath("OrbitFiles.dorisVOROrbitPath")); final URL remotePath = new URL(Settings.getPath("OrbitFiles.dorisHTTP_vor_remotePath")); final File localFile = new File(localFolder, year+".zip"); final DownloadableArchive archive = new DownloadableArchive(localFile, remotePath); archive.getContentFiles(); }
private void getRemotePrareFiles(final String remotePath, final File localPath, final String prefix) { final String prareFTP = Settings.instance().get("OrbitFiles.prareFTP"); try { if (ftp == null) { final String user = Settings.instance().get("OrbitFiles.prareFTP_user"); final String pass = Settings.instance().get("OrbitFiles.prareFTP_pass"); ftp = new FtpDownloader(prareFTP, user, pass); final Map<String, Long> allfileSizeMap = FtpDownloader.readRemoteFileList(ftp, prareFTP, remotePath); fileSizeMap = new HashMap<>(10); // keep only those starting with prefix final Set<String> remoteFileNames = allfileSizeMap.keySet(); for (String fileName : remoteFileNames) { if (fileName.startsWith(prefix)) { fileSizeMap.put(fileName, allfileSizeMap.get(fileName)); } } } if (!localPath.exists()) { if(!localPath.mkdirs()) { throw new IOException("Failed to create directory '" + localPath + "'."); } } getRemoteFiles(ftp, fileSizeMap, remotePath, localPath, new NullProgressMonitor()); } catch (Exception e) { System.out.println(e.getMessage()); } }
private static void getRemoteFiles(final String missionPrefix, final String orbitType, final int year, final int month) throws Exception { final URL remotePath; if (orbitType.startsWith(RESTITUTED)) { remotePath = new URL(Settings.instance().getPath("OrbitFiles.sentinel1RESOrbit_remotePath")); } else { remotePath = new URL(Settings.instance().getPath("OrbitFiles.sentinel1POEOrbit_remotePath")); } final File orbitFileFolder = getDestFolder(missionPrefix, orbitType, year, month); final File localFile = new File(orbitFileFolder, year + "-" + month + ".zip"); try { final DownloadableArchive archive = new DownloadableArchive(localFile, remotePath); archive.getContentFiles(); } catch (Exception e) { if (localFile.exists()) { localFile.delete(); final DownloadableArchive archive = new DownloadableArchive(localFile, remotePath); archive.getContentFiles(); } } }
String delftFTPPath = ""; if (mission.equals("ENVISAT")) { orbitPathStr = Settings.getPath("OrbitFiles.delftEnvisatOrbitPath"); delftFTPPath = Settings.getPath("OrbitFiles.delftFTP_ENVISAT_precise_remotePath"); } else if (mission.equals("ERS1")) { orbitPathStr = Settings.getPath("OrbitFiles.delftERS1OrbitPath"); delftFTPPath = Settings.getPath("OrbitFiles.delftFTP_ERS1_precise_remotePath"); } else if (mission.equals("ERS2")) { orbitPathStr = Settings.getPath("OrbitFiles.delftERS2OrbitPath"); delftFTPPath = Settings.getPath("OrbitFiles.delftFTP_ERS2_precise_remotePath"); final String delftFTP = Settings.instance().get("OrbitFiles.delftFTP");
static File getDestFolder(final String missionPrefix, final String orbitType, final int year, final int month) { final String prefOrbitPath; if (orbitType.startsWith(RESTITUTED)) { prefOrbitPath = Settings.getPath("OrbitFiles.sentinel1RESOrbitPath"); } else { prefOrbitPath = Settings.getPath("OrbitFiles.sentinel1POEOrbitPath"); } final File destFolder = new File(prefOrbitPath + File.separator + missionPrefix + File.separator + year + File.separator + StringUtils.padNum(month, 2, '0')); if(month < 10) { File oldFolder = new File(prefOrbitPath + File.separator + missionPrefix + File.separator + year + File.separator + month); if(oldFolder.exists()) { // rename oldFolder.renameTo(destFolder); } } return destFolder; }
/** * Get XCA file used for the original radiometric calibration. * * @return The complete path to the XCA file. */ private Path getOldXCAFilePath() throws Exception { oldXCAFileName = absRoot.getAttributeString(AbstractMetadata.external_calibration_file); final File localFolder = SystemUtils.getAuxDataPath().resolve("AuxCal").resolve("ENVISAT").toFile(); final URL remotePath = new URL(Settings.getPath("AuxCal.ENVISAT.remotePath")); File xcaFile = new File(localFolder, oldXCAFileName); if(xcaFile.exists()) { // unzipped return xcaFile.toPath(); } else { xcaFile = new File(localFolder, oldXCAFileName + ".zip"); if(xcaFile.exists()) { // zipped return xcaFile.toPath(); } else { final File localFile = new File(localFolder, "ENVISAT_XCA.zip"); final DownloadableArchive archive = new DownloadableArchive(localFile, remotePath); archive.getContentFiles(); } return xcaFile.toPath(); } }
private void getNewXCAFile() throws Exception { if (auxFile != null && auxFile.contains(CalibrationOp.EXTERNAL_AUX)) { if (externalAuxFile != null && externalAuxFile.exists()) { if (!externalAuxFile.getName().contains("ASA_XCA")) { throw new OperatorException("Invalid XCA file for ASAR product"); } newXCAFileName = externalAuxFile.getName(); newXCAFilePath = externalAuxFile.getAbsolutePath(); } else { throw new OperatorException("No external auxiliary file is specified."); } } else { final Date startDate = sourceProduct.getStartTime().getAsDate(); final Date endDate = sourceProduct.getEndTime().getAsDate(); final File localFolder = SystemUtils.getAuxDataPath().resolve("AuxCal").resolve("ENVISAT").toFile(); newXCAFileName = findXCAFile(localFolder, startDate, endDate); if(newXCAFileName == null) { final URL remotePath = new URL(Settings.getPath("AuxCal.ENVISAT.remotePath")); final File localFile = new File(localFolder, "ENVISAT_XCA.zip"); final DownloadableArchive archive = new DownloadableArchive(localFile, remotePath); archive.getContentFiles(); newXCAFileName = findXCAFile(localFolder, startDate, endDate); } newXCAFilePath = localFolder.toString() + File.separator + newXCAFileName; } }
final String remoteHTTPFolder; if (mission.equals("ERS1")) { orbitPath = Settings.getPath("OrbitFiles.prareERS1OrbitPath"); remoteBaseFolder = Settings.getPath("OrbitFiles.prareFTP_ERS1_remotePath"); remoteHTTPFolder = Settings.getPath("OrbitFiles.prareHTTP_ERS1_remotePath"); } else { orbitPath = Settings.getPath("OrbitFiles.prareERS2OrbitPath"); remoteBaseFolder = Settings.getPath("OrbitFiles.prareFTP_ERS2_remotePath"); remoteHTTPFolder = Settings.getPath("OrbitFiles.prareHTTP_ERS2_remotePath");