@Override public void run() { lockFile.delete(); } }));
@Override public boolean delete() { return delegate.delete(); }
/** * Renames a resource by reading it and writing to the new resource, then deleting the old one. * This is not atomic. * * @param source Resource to rename * @param destination New resource location * @return true if successful, false if either the write or delete failed. */ public static boolean renameByCopy(Resource source, Resource destination) { try { copy(source, destination); return source.delete(); } catch (IOException e) { return false; } }
/** removes the user group service config from persistence */ public void removeConfig(String name) throws IOException { getRoot().get(name).delete(); }
/** 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()); } }
Resource newKSFile = dir.get(PREPARED_FILE_NAME); if (newKSFile.getType() != Type.UNDEFINED) { newKSFile.delete();
public void handleServiceRemove(ServiceInfo service) { XStreamServiceLoader loader = findServiceLoader(service); try { Resource dir = service.getWorkspace() != null ? dir(service.getWorkspace()) : resourceLoader.get(Paths.BASE); dir.get(loader.getFilename()).delete(); } catch (Throwable t) { throw new RuntimeException(t); } }
if (oldKSFile.delete() == false) { LOGGER.severe("cannot delete " + oldKSFile.path()); return;
@Theory public void theoryRecursiveDelete(String path) throws Exception { final Resource res = getResource(path); assumeThat(res, is(directory())); assumeThat(res, is(directory())); Collection<Resource> result = res.list(); assumeThat(result.size(), greaterThan(0)); assertTrue(res.delete()); }
@Test public void testReloadDefaultStyles() throws Exception { // clear up all "point" styles final Resource styles = getDataDirectory().getStyles(); styles.list() .stream() .filter(r -> r.getType() == Resource.Type.RESOURCE && r.name().contains("point")) .forEach(r -> r.delete()); // reload getGeoServer().reload(); // check the default point style has been re-created final StyleInfo point = getCatalog().getStyleByName("point"); assertNotNull(point); }
@Theory public void theoryUndefinedNotDeleted(String path) throws Exception { Resource res = getResource(path); assumeThat(res, undefined()); assertThat(res.delete(), is(false)); assertThat(res, undefined()); }
@Theory public void theoryDeletedResourcesAreUndefined(String path) throws Exception { Resource res = getResource(path); assumeThat(res, resource()); assertThat(res.delete(), is(true)); assertThat(res, undefined()); }
public boolean delete(final String id) { checkNotNull(id, "provided a null id"); checkIdFormat(id); lock.writeLock().lock(); try { infosById.remove(id); return resource(id).delete(); } finally { lock.writeLock().unlock(); } }
/** Removes all stored queries. */ public void removeAll() { for (Resource file : storedQueryDir().list()) { file.delete(); } }
/** * Removes an existing stored query. * * @param query The stored query */ public void removeStoredQuery(StoredQuery query) { storedQueryDir().get(toFilename(query.getName())).delete(); }
public static void saveOrUpdateEchoParameter(EchoParameter echoParameter) { Resource echoParameters = DATA_DIRECTORY.get(getEchoParametersPath()); Resource tmpEchoParameters = DATA_DIRECTORY.get(getTmpEchoParametersPath()); saveOrUpdateEchoParameter(echoParameter, echoParameters.in(), tmpEchoParameters.out()); echoParameters.delete(); tmpEchoParameters.renameTo(echoParameters); }
@Theory public void theoryRecursiveDelete(String path) throws Exception { final Resource res = getResource(path); assumeThat(res, is(directory())); assumeThat(res, is(directory())); Collection<Resource> result = res.list(); assumeThat(result.size(), greaterThan(0)); assertTrue(res.delete()); }
public static void saveOrUpdateRule(Rule rule) { Resource rules = DATA_DIRECTORY.get(getRulesPath()); Resource tmpRules = DATA_DIRECTORY.get(getTempRulesPath()); saveOrUpdateRule(rule, rules.in(), tmpRules.out()); rules.delete(); tmpRules.renameTo(rules); }
@Theory public void theoryDeletedResourcesAreUndefined(String path) throws Exception { Resource res = getResource(path); assumeThat(res, resource()); assertThat(res.delete(), is(true)); assertThat(res, undefined()); }
@Test public void testUpload() throws Exception { put(RestBaseController.ROOT_PATH + "/resource/mydir/mynewres", STR_MY_NEW_TEST); Resource newRes = getDataDirectory().get("/mydir/mynewres"); try (InputStream is = newRes.in()) { Assert.assertEquals(STR_MY_NEW_TEST, IOUtils.toString(is)); } newRes.delete(); }