/** * {@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.debug(msg); throw new ItemStateException(msg, fse); } }
private CustomPrivilegeStore(FileSystemResource customPrivilegesResource) throws RepositoryException { this.customPrivilegesResource = customPrivilegesResource; try { // make sure path to resource exists if (!customPrivilegesResource.exists()) { customPrivilegesResource.makeParentDirs(); } } catch (FileSystemException e) { String error = "Internal error: Failed to access/create file system resource for custom privileges at " + customPrivilegesResource.getPath(); log.debug(error); throw new RepositoryException(error, e); } }
/** * {@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(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); } }
private CustomPrivilegeStore(FileSystemResource customPrivilegesResource) throws RepositoryException { this.customPrivilegesResource = customPrivilegesResource; try { // make sure path to resource exists if (!customPrivilegesResource.exists()) { customPrivilegesResource.makeParentDirs(); } } catch (FileSystemException e) { String error = "Internal error: Failed to access/create file system resource for custom privileges at " + customPrivilegesResource.getPath(); log.debug(error); throw new RepositoryException(error, e); } }
/** * {@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 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} */ 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); } } }
private Map<Name, PrivilegeDefinition> load() throws FileSystemException, RepositoryException, ParseException, IOException { Map<Name, PrivilegeDefinition> stubs = new LinkedHashMap<Name, PrivilegeDefinition>(); if (customPrivilegesResource.exists()) { InputStream in = customPrivilegesResource.getInputStream(); try { PrivilegeDefinitionReader pr = new PrivilegeDefinitionReader(in, "text/xml"); for (PrivilegeDefinition def : pr.getPrivilegeDefinitions()) { Name privName = def.getName(); if (stubs.containsKey(privName)) { throw new RepositoryException("Duplicate entry for custom privilege with name " + privName.toString()); } stubs.put(privName, def); } } finally { in.close(); } } return stubs; }
private Map<Name, PrivilegeDefinition> load() throws FileSystemException, RepositoryException, ParseException, IOException { Map<Name, PrivilegeDefinition> stubs = new LinkedHashMap<Name, PrivilegeDefinition>(); if (customPrivilegesResource.exists()) { InputStream in = customPrivilegesResource.getInputStream(); try { PrivilegeDefinitionReader pr = new PrivilegeDefinitionReader(in, "text/xml"); for (PrivilegeDefinition def : pr.getPrivilegeDefinitions()) { Name privName = def.getName(); if (stubs.containsKey(privName)) { throw new RepositoryException("Duplicate entry for custom privilege with name " + privName.toString()); } stubs.put(privName, def); } } finally { in.close(); } } return stubs; }
/** * Creates a new hashmap index and loads the lookup tables from the * filesystem resource. If it does not exist yet, it will create a new one. * * @param file the filesystem resource that stores the lookup tables. * * @throws IOException if an I/O error occurs. * @throws FileSystemException if an I/O error occurs. */ public FileBasedIndex(FileSystemResource file) throws FileSystemException, IOException { this.file = file; if (!file.exists()) { file.makeParentDirs(); file.getOutputStream().close(); } load(); }
/** * Creates a new hashmap index and loads the lookup tables from the * filesystem resource. If it does not exist yet, it will create a new one. * * @param file the filesystem resource that stores the lookup tables. * * @throws IOException if an I/O error occurs. * @throws FileSystemException if an I/O error occurs. */ public FileBasedIndex(FileSystemResource file) throws FileSystemException, IOException { this.file = file; if (!file.exists()) { file.makeParentDirs(); file.getOutputStream().close(); } load(); }
/** * {@inheritDoc} */ protected void destroy(NodeState state) throws ItemStateException { if (!initialized) { throw new IllegalStateException("not initialized"); } String nodeFilePath = buildNodeFilePath(state.getNodeId()); FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath); try { if (nodeFile.exists()) { // delete resource and prune empty parent folders nodeFile.delete(true); } } catch (FileSystemException fse) { String msg = "failed to delete node state: " + state.getNodeId(); log.debug(msg); throw new ItemStateException(msg, fse); } }
@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); }