protected FileWatcher(Resource resource) { this.resource = resource; this.path = resource.path(); }
public SerializableResourceWrapper(Resource delegate) { this.delegate = delegate; path = delegate.path(); }
@Override public String getDescription() { return resource.path(); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Resource other = (Resource) obj; if (path == null) { if (other.path() != null) return false; } else if (!path.equals(other.path())) return false; return true; }
/** * @param file * @deprecated Use Resource instead of File */ @Deprecated protected FileWatcher(File file) { this.resource = Files.asResource(file); this.path = resource.path(); }
/** remove the lockfile */ public void writeUnLock() { if (Resources.exists(lockFile)) { if (lockFile.lastmodified() == lockFileLastModified) { lockFileLastModified = 0; lockFile.delete(); } else { LOGGER.warning("Tried to unlock foreign lock: " + lockFile.path()); } } else { LOGGER.warning("Tried to unlock not exisiting lock: " + lockFile.path()); } }
private void rmRes(Resource r) { try { rl.remove(r.path()); } catch (Exception e) { throw new CatalogException(e); } }
/** @deprecated use {@link Resources#fromURL(Resource, String)} */ @Deprecated public static File url(File baseDirectory, String url) { Resource res = Resources.fromURL(asResource(baseDirectory), url); if (res == null) { return null; } File file = Resources.find(res); if (file == null) { return new File(baseDirectory, res.path()); } return file; }
private void removeStyle(StyleInfo s) throws IOException { Resource sld = dd.style(s); if (Resources.exists(sld)) { Resource sldBackup = dd.get(sld.path() + ".bak"); int i = 1; while (Resources.exists(sldBackup)) { sldBackup = dd.get(sld.path() + ".bak." + i++); } LOGGER.fine("Removing the SLD as well but making backup " + sldBackup.name()); sld.renameTo(sldBackup); } }
@Test public void testNullWorkspace() { assertEquals(dataDir.get((WorkspaceInfo) null, "test").path(), dataDir.get("test").path()); assertEquals( dataDir.getStyles((WorkspaceInfo) null, "test").path(), dataDir.getStyles("test").path()); assertEquals( dataDir.getLayerGroups((WorkspaceInfo) null, "test").path(), dataDir.getLayerGroups("test").path()); }
@Theory public void theoryHaveSamePath(String path) throws Exception { Resource res = getResource(path); String result = res.path(); assertThat(result, is(equalTo(path))); }
@Override public void initializeFor(GeoServerUserGroupService service) throws IOException { if (!keystoreProvider.hasUserGroupKey(service.getName())) { throw new IOException( "No key alias: " + keystoreProvider.aliasForGroupService(service.getName()) + " in key store: " + keystoreProvider.getResource().path()); } keyAliasInKeyStore = keystoreProvider.aliasForGroupService(service.getName()); }
@Override public LayerContents apply(Resource rd) throws IOException { Resource r = rd.get(resourceFileName); Resource lr = rd.get("layer.xml"); if (Resources.exists(r) && Resources.exists(lr)) { byte[] contents = r.getContents(); byte[] lrContents = lr.getContents(); return new LayerContents(rd, contents, lrContents); } else { LOGGER.warning("Ignoring " + resourceType + " directory " + rd.path()); return null; } } }
@Override public WorkspaceContents apply(Resource rd) throws IOException { Resource wr = rd.get("workspace.xml"); Resource nr = rd.get("namespace.xml"); if (Resources.exists(wr) && Resources.exists(nr)) { byte[] contents = wr.getContents(); byte[] nrContents = nr.getContents(); return new WorkspaceContents(rd, contents, nrContents); } else { LOGGER.warning("Ignoring workspace directory " + rd.path()); return null; } } }
@Theory public void theoryAddingFileToDirectoryAddsResource(String path) throws Exception { Resource res = getResource(path); assumeThat(res, is(directory())); File dir = res.dir(); File file = new File(dir, "newFileCreatedDirectly"); assumeTrue(file.createNewFile()); Resource child = getResource(Paths.path(res.path(), "newFileCreatedDirectly")); Collection<Resource> children = res.list(); assertThat(child, is(defined())); assertThat(children, hasItem(child)); }