/** * @see FileSystem#exists */ public boolean exists() throws FileSystemException { return fs.exists(path); }
/** * @see FileSystem#exists */ public boolean exists() throws FileSystemException { return fs.exists(path); }
/** * @see FileSystem#exists */ public boolean exists() throws FileSystemException { return fs.exists(path); }
/** * {@inheritDoc} */ public boolean exists(String path) throws FileSystemException { return fsBase.exists(buildBasePath(path)); }
/** * {@inheritDoc} */ public boolean exists(String path) throws FileSystemException { return fsBase.exists(buildBasePath(path)); }
/** * {@inheritDoc} */ public boolean exists(String path) throws FileSystemException { return fsBase.exists(buildBasePath(path)); }
/** * {@inheritDoc} */ public synchronized boolean existsReferencesTo(NodeId targetId) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } try { StringBuffer buf = buildNodeReferencesFilePath(null, targetId); return itemFs.exists(buf.toString()); } catch (Exception e) { String msg = "failed to check existence of node references: " + targetId; BundleFsPersistenceManager.log.error(msg, e); throw new ItemStateException(msg, e); } }
/** * {@inheritDoc} */ public synchronized boolean existsReferencesTo(NodeId targetId) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } try { StringBuffer buf = buildNodeReferencesFilePath(null, targetId); return itemFs.exists(buf.toString()); } catch (Exception e) { String msg = "failed to check existence of node references: " + targetId; BundleFsPersistenceManager.log.error(msg, e); throw new ItemStateException(msg, e); } }
/** * Creates the parent directory of this resource, including any necessary * but nonexistent parent directories. * * @throws FileSystemException */ public synchronized void makeParentDirs() throws FileSystemException { String parentDir = getParentDir(); if (!fs.exists(parentDir)) { fs.createFolder(parentDir); } }
/** * Creates the parent directory of this resource, including any necessary * but nonexistent parent directories. * * @throws FileSystemException */ public synchronized void makeParentDirs() throws FileSystemException { String parentDir = getParentDir(); if (!fs.exists(parentDir)) { fs.createFolder(parentDir); } }
/** * Creates the parent directory of this resource, including any necessary * but nonexistent parent directories. * * @throws FileSystemException */ public synchronized void makeParentDirs() throws FileSystemException { String parentDir = getParentDir(); if (!fs.exists(parentDir)) { fs.createFolder(parentDir); } }
private Properties loadProperties(String path) throws RepositoryException { Properties properties = new Properties(); FileSystem filesystem = source.getFileSystem(); try { if (filesystem.exists(path)) { InputStream stream = filesystem.getInputStream(path); try { properties.load(stream); } finally { stream.close(); } } } catch (FileSystemException e) { throw new RepositoryException(e); } catch (IOException e) { throw new RepositoryException(e); } return properties; }
/** * {@inheritDoc} */ public synchronized void store(NodeReferences refs) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } try { StringBuffer buf = buildNodeFolderPath(null, refs.getTargetId()); buf.append('.'); buf.append(NODEREFSFILENAME); String fileName = buf.toString(); String dir = fileName.substring(0, fileName.lastIndexOf(FileSystem.SEPARATOR_CHAR)); if (!itemFs.exists(dir)) { itemFs.createFolder(dir); } OutputStream out = itemFs.getOutputStream(fileName); Serializer.serialize(refs, out); out.close(); } catch (Exception e) { String msg = "failed to write " + refs; BundleFsPersistenceManager.log.error(msg, e); throw new ItemStateException(msg, e); } }
private Properties loadProperties(String path) throws RepositoryException { Properties properties = new Properties(); FileSystem filesystem = source.getFileSystem(); try { if (filesystem.exists(path)) { InputStream stream = filesystem.getInputStream(path); try { properties.load(stream); } finally { stream.close(); } } } catch (FileSystemException e) { throw new RepositoryException(e); } catch (IOException e) { throw new RepositoryException(e); } return properties; }
/** * {@inheritDoc} */ protected NodePropBundle loadBundle(NodeId id) throws ItemStateException { try { String path = buildNodeFilePath(null, id).toString(); if (!itemFs.exists(path)) { return null; } InputStream in = itemFs.getInputStream(path); try { return binding.readBundle(in, id); } finally { IOUtils.closeQuietly(in); } } catch (Exception e) { String msg = "failed to read bundle: " + id + ": " + e; log.error(msg); throw new ItemStateException(msg, e); } }
/** * {@inheritDoc} */ protected NodePropBundle loadBundle(NodeId id) throws ItemStateException { try { String path = buildNodeFilePath(null, id).toString(); if (!itemFs.exists(path)) { return null; } InputStream in = itemFs.getInputStream(path); try { return binding.readBundle(in, id); } finally { IOUtils.closeQuietly(in); } } catch (Exception e) { String msg = "failed to read bundle: " + id + ": " + e; log.error(msg); throw new ItemStateException(msg, e); } }
/** * Deletes this resource. * * @param pruneEmptyParentDirs if <code>true</code>, empty parent folders will * automatically be deleted * @see FileSystem#deleteFile */ public synchronized void delete(boolean pruneEmptyParentDirs) throws FileSystemException { fs.deleteFile(path); if (pruneEmptyParentDirs) { // prune empty parent folders String parentDir = FileSystemPathUtil.getParentDir(path); while (!parentDir.equals(FileSystem.SEPARATOR) && fs.exists(parentDir) && !fs.hasChildren(parentDir)) { fs.deleteFolder(parentDir); parentDir = FileSystemPathUtil.getParentDir(parentDir); } } }
/** * Deletes this resource. * * @param pruneEmptyParentDirs if <code>true</code>, empty parent folders will * automatically be deleted * @see FileSystem#deleteFile */ public synchronized void delete(boolean pruneEmptyParentDirs) throws FileSystemException { fs.deleteFile(path); if (pruneEmptyParentDirs) { // prune empty parent folders String parentDir = FileSystemPathUtil.getParentDir(path); while (!parentDir.equals(FileSystem.SEPARATOR) && fs.exists(parentDir) && !fs.hasChildren(parentDir)) { fs.deleteFolder(parentDir); parentDir = FileSystemPathUtil.getParentDir(parentDir); } } }
/** * Deletes this resource. * * @param pruneEmptyParentDirs if <code>true</code>, empty parent folders will * automatically be deleted * @see FileSystem#deleteFile */ public synchronized void delete(boolean pruneEmptyParentDirs) throws FileSystemException { fs.deleteFile(path); if (pruneEmptyParentDirs) { // prune empty parent folders String parentDir = FileSystemPathUtil.getParentDir(path); while (!parentDir.equals(FileSystem.SEPARATOR) && fs.exists(parentDir) && !fs.hasChildren(parentDir)) { fs.deleteFolder(parentDir); parentDir = FileSystemPathUtil.getParentDir(parentDir); } } }
@Override protected void tearDown() throws Exception { try { if (fs.exists("/privileges") && fs.isFolder("/privileges")) { fs.deleteFolder("/privileges"); } } finally { super.tearDown(); } }