/** * {@inheritDoc} */ public FileSystemResource getResource(String blobId) throws Exception { // the blobId is an absolute file system path return new FileSystemResource(fs, blobId); } }
/** * {@inheritDoc} */ public FileSystemResource getResource(String blobId) throws Exception { // the blobId is an absolute file system path return new FileSystemResource(fs, blobId); } }
/** * Returns the local name index * @return the local name index * @throws IllegalStateException if an error occurs. */ public StringIndex getNameIndex() { try { if (nameIndex == null) { nameIndex = new FileBasedIndex(new FileSystemResource( context.getFileSystem(), RES_NAME_INDEX)); } return nameIndex; } catch (Exception e) { IllegalStateException e2 = new IllegalStateException("Unable to create nameIndex."); e2.initCause(e); throw e2; } }
/** * Returns the local name index * @return the local name index * @throws IllegalStateException if an error occurs. */ public StringIndex getNameIndex() { try { if (nameIndex == null) { nameIndex = new FileBasedIndex(new FileSystemResource( context.getFileSystem(), RES_NAME_INDEX)); } return nameIndex; } catch (Exception e) { IllegalStateException e2 = new IllegalStateException("Unable to create nameIndex."); e2.initCause(e); throw e2; } }
/** * {@inheritDoc} */ public void put(String blobId, InputStream in, long size) throws Exception { // the blobId is an absolute file system path FileSystemResource internalBlobFile = new FileSystemResource(fs, blobId); internalBlobFile.makeParentDirs(); OutputStream out = internalBlobFile.getOutputStream(); try { IOUtils.copy(in, out); } finally { out.close(); } }
/** * {@inheritDoc} */ public void put(String blobId, InputStream in, long size) throws Exception { // the blobId is an absolute file system path FileSystemResource internalBlobFile = new FileSystemResource(fs, blobId); internalBlobFile.makeParentDirs(); OutputStream out = internalBlobFile.getOutputStream(); try { IOUtils.copy(in, out); } finally { out.close(); } }
/** * {@inheritDoc} */ public boolean remove(String blobId) throws Exception { // the blobId is an absolute file system path FileSystemResource res = new FileSystemResource(fs, blobId); if (!res.exists()) { return false; } // delete resource and prune empty parent folders res.delete(true); return true; }
/** * {@inheritDoc} */ public boolean remove(String blobId) throws Exception { // the blobId is an absolute file system path FileSystemResource res = new FileSystemResource(fs, blobId); if (!res.exists()) { return false; } // delete resource and prune empty parent folders res.delete(true); return true; }
/** * {@inheritDoc} */ public synchronized boolean exists(PropertyId id) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } try { String propFilePath = buildPropFilePath(id); FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath); return propFile.exists(); } catch (FileSystemException fse) { String msg = "failed to check existence of item state: " + id; log.error(msg, fse); throw new ItemStateException(msg, fse); } }
/** * {@inheritDoc} */ public synchronized boolean exists(NodeId id) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } try { String nodeFilePath = buildNodeFilePath(id); FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath); return nodeFile.exists(); } catch (FileSystemException fse) { String msg = "failed to check existence of item state: " + id; log.error(msg, fse); throw new ItemStateException(msg, fse); } }
/** * {@inheritDoc} */ public synchronized boolean exists(PropertyId id) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } try { String propFilePath = buildPropFilePath(id); FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath); return propFile.exists(); } catch (FileSystemException fse) { String msg = "failed to check existence of item state: " + id; log.debug(msg); throw new ItemStateException(msg, fse); } }
/** * {@inheritDoc} */ public synchronized boolean exists(NodeId id) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } try { String nodeFilePath = buildNodeFilePath(id); FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath); return nodeFile.exists(); } catch (FileSystemException fse) { String msg = "failed to check existence of item state: " + id; log.error(msg, fse); throw new ItemStateException(msg, fse); } }
/** * {@inheritDoc} */ public synchronized boolean exists(NodeId id) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } try { String nodeFilePath = buildNodeFilePath(id); FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath); return nodeFile.exists(); } catch (FileSystemException fse) { String msg = "failed to check existence of item state: " + id; log.debug(msg); throw new ItemStateException(msg, fse); } }
/** * {@inheritDoc} */ public synchronized boolean exists(PropertyId id) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } try { String propFilePath = buildPropFilePath(id); FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath); return propFile.exists(); } catch (FileSystemException fse) { String msg = "failed to check existence of item state: " + id; log.debug(msg); throw new ItemStateException(msg, fse); } }
/** * {@inheritDoc} */ public synchronized boolean exists(NodeId id) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } try { String nodeFilePath = buildNodeFilePath(id); FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath); return nodeFile.exists(); } catch (FileSystemException fse) { String msg = "failed to check existence of item state: " + id; log.debug(msg); throw new ItemStateException(msg, fse); } }
/** * {@inheritDoc} */ public synchronized boolean exists(PropertyId id) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } try { String propFilePath = buildPropFilePath(id); FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath); return propFile.exists(); } catch (FileSystemException fse) { String msg = "failed to check existence of item state: " + id; log.error(msg, fse); throw new ItemStateException(msg, fse); } }
/** * {@inheritDoc} */ public synchronized boolean existsReferencesTo(NodeId id) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } try { String refsFilePath = buildNodeReferencesFilePath(id); FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath); return refsFile.exists(); } catch (FileSystemException fse) { String msg = "failed to check existence of references: " + id; log.debug(msg); throw new ItemStateException(msg, fse); } } }
/** * {@inheritDoc} */ protected void destroy(NodeReferences refs) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } String refsFilePath = buildNodeReferencesFilePath(refs.getTargetId()); FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath); try { if (refsFile.exists()) { // delete resource and prune empty parent folders refsFile.delete(true); } } catch (FileSystemException fse) { String msg = "failed to delete " + refs; log.debug(msg); throw new ItemStateException(msg, fse); } }
private FileSystem createFileSystem() { FileSystem fs = new MemoryFileSystem(); BufferedWriter writer = null; try { fs.createFolder("/"); FileSystemResource file = new FileSystemResource(fs, "/retention"); writer = new BufferedWriter(new OutputStreamWriter(file.getOutputStream())); writer.write(((NodeImpl) childN).getNodeId().toString()); } catch (FileSystemException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } finally { IOUtils.closeQuietly(writer); } return fs; }
@Override protected void setUp() throws Exception { super.setUp(); resolver = ((SessionImpl) superuser); // setup the custom privilege file with cyclic references fs = ((RepositoryImpl) superuser.getRepository()).getConfig().getFileSystem(); FileSystemResource resource = new FileSystemResource(fs, "/privileges/custom_privileges.xml"); if (!resource.exists()) { resource.makeParentDirs(); } privilegeRegistry = new PrivilegeRegistry(superuser.getWorkspace().getNamespaceRegistry(), fs); }