@UriParser public void setUri(String uri) { Matcher matcher = URI_PATTERN.matcher(uri); if (matcher.matches()) { setServer(matcher.group(1)); setMountPath(matcher.group(2)); } else { throw new RuntimeException("invalid file URI"); } }
public void delete(String identifier) { try { delete(identifier, config.getDeleteOlderThan()); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Get the nfs, creating it from the config if necessary. * * @return the nfs */ private Nfs3 getNfs() { if (nfs == null) { NfsConfig config = getConfig(); try { nfs = new Nfs3(config.getServer() + ":" + config.getMountPath(), null, 3); } catch (IOException e) { throw new RuntimeException(e); } } return nfs; }
NfsConfig config = new NfsConfig(); config.setServer(server); config.setMountPath(mountPath); config.setSubPath(tempDir.getPath().substring(1)); config.setStoreMetadata(true);
/** * @param nfs * @return */ private NfsConfig getNfsConfig(Nfs nfs) { NfsConfig nfsConfig = new NfsConfig(); nfsConfig.setServer(nfs.getServer()); nfsConfig.setMountPath(nfs.getExportedPath() + testDirectoryPath); return nfsConfig; } }
throw new ConfigurationException("the mount " + mountPathRoot + " is unavailable."); syncRootFile = createFileFromPath(config.getSubPath()); identifierBase = syncRootFile.getAbsolutePath(); } catch (IOException e) { if (config.getModifiedSince() != null) { modifiedSince = Iso8601Util.parse(config.getModifiedSince()); if (modifiedSince == null) { throw new ConfigurationException("could not parse modified-since"); if (config.getExcludedPaths() != null) { excludedPathPatterns = new ArrayList<>(); for (String pattern : config.getExcludedPaths()) { excludedPathPatterns.add(Pattern.compile(pattern));
protected Nfs3File createFile(String identifier) throws IOException { String path = combineWithFileSeparator(config.getSubPath(), getRelativePath(identifier, true)); return createFileFromPath(path); }
@Test public void testNullSubPath() throws Exception { NfsConfig sourceConfig = getNfsConfig(nfs); Assert.assertNull(sourceConfig.getSubPath()); Nfs3Storage nfsStorage = new Nfs3Storage(); nfsStorage.setConfig(sourceConfig); try { nfsStorage.configure(nfsStorage, new ArrayList<SyncFilter>().iterator(), nfsStorage); } catch (Throwable t) { t.printStackTrace(); Assert.fail("This should not throw an exception"); } }