/** * Returns the path string of this resource. This is just the * string returned by the <code>{@link #getPath}</code> method. * * @return The path string of this resource */ public String toString() { return getPath(); }
/** * Returns the path string of this resource. This is just the * string returned by the <code>{@link #getPath}</code> method. * * @return The path string of this resource */ public String toString() { return getPath(); }
/** * Returns the path string of this resource. This is just the * string returned by the <code>{@link #getPath}</code> method. * * @return The path string of this resource */ public String toString() { return getPath(); }
/** * Purges the delayedDeletedFile. * * @return boolean true if it was successful otherwise false */ private boolean purgeDelayedDeleteFile() { BufferedWriter writer = null; try { writer = new BufferedWriter(new OutputStreamWriter( identifiersToDeleteFile.getOutputStream())); writer.write(""); return true; } catch (Exception e) { log.warn("I/O error while purging (stacktrace on DEBUG log level) the " + IDENTIFIERS_TO_DELETE_FILE_KEY + " file '" + identifiersToDeleteFile.getPath() + "': " + e.getMessage()); log.debug("Root cause: ", e); return false; } finally { IOUtils.closeQuietly(writer); } }
/** * Purges the delayedDeletedFile. * * @return boolean true if it was successful otherwise false */ private boolean purgeDelayedDeleteFile() { BufferedWriter writer = null; try { writer = new BufferedWriter(new OutputStreamWriter( identifiersToDeleteFile.getOutputStream())); writer.write(""); return true; } catch (Exception e) { log.warn("I/O error while purging (stacktrace on DEBUG log level) the " + IDENTIFIERS_TO_DELETE_FILE_KEY + " file '" + identifiersToDeleteFile.getPath() + "': " + e.getMessage()); log.debug("Root cause: ", e); return false; } finally { IOUtils.closeQuietly(writer); } }
/** * Purges the delayedDeletedFile. * * @return boolean true if it was successful otherwise false */ private boolean purgeDelayedDeleteFile() { BufferedWriter writer = null; try { writer = new BufferedWriter(new OutputStreamWriter( identifiersToDeleteFile.getOutputStream())); writer.write(""); return true; } catch (Exception e) { log.warn("I/O error while purging (stacktrace on DEBUG log level) the " + IDENTIFIERS_TO_DELETE_FILE_KEY + " file '" + identifiersToDeleteFile.getPath() + "': " + e.getMessage()); log.debug("Root cause: ", e); return false; } finally { IOUtils.closeQuietly(writer); } }
/** * Writes the given DataIdentifier to the delayedDeletedFile. * * @param identifier * @return boolean true if it was successful otherwise false */ private boolean writeDelayedDataIdentifier(DataIdentifier identifier) { BufferedWriter writer = null; try { File identifierFile = new File( ((LocalFileSystem) identifiersToDeleteFile.getFileSystem()).getPath(), identifiersToDeleteFile.getPath()); writer = new BufferedWriter(new FileWriter(identifierFile, true)); writer.write(identifier.toString()); return true; } catch (Exception e) { log.warn("I/O error while saving DataIdentifier (stacktrace on DEBUG log level) to '" + identifiersToDeleteFile.getPath() + "': " + e.getMessage()); log.debug("Root cause: ", e); return false; } finally { IOUtils.closeQuietly(writer); } }
/** * Creates a new instance from a stream. * * @param fsResource the file system resource * @throws IOException */ private BLOBInResource(FileSystemResource fsResource) throws IOException { try { if (!fsResource.exists()) { throw new IOException(fsResource.getPath() + ": the specified resource does not exist"); } length = fsResource.length(); } catch (FileSystemException fse) { IOException e2 = new IOException(fsResource.getPath() + ": Error while creating value: " + fse.toString()); e2.initCause(fse); throw e2; } this.fsResource = fsResource; }
public InputStream getStream() throws RepositoryException { try { return fsResource.getInputStream(); } catch (FileSystemException fse) { throw new RepositoryException(fsResource.getPath() + ": the specified resource does not exist", fse); } }
/** * Writes the given DataIdentifier to the delayedDeletedFile. * * @param identifier * @return boolean true if it was successful otherwise false */ private boolean writeDelayedDataIdentifier(DataIdentifier identifier) { BufferedWriter writer = null; try { File identifierFile = new File( ((LocalFileSystem) identifiersToDeleteFile.getFileSystem()).getPath(), identifiersToDeleteFile.getPath()); writer = new BufferedWriter(new FileWriter(identifierFile, true)); writer.write(identifier.toString()); return true; } catch (Exception e) { log.warn("I/O error while saving DataIdentifier (stacktrace on DEBUG log level) to '" + identifiersToDeleteFile.getPath() + "': " + e.getMessage()); log.debug("Root cause: ", e); return false; } finally { IOUtils.closeQuietly(writer); } }
/** * Writes the given DataIdentifier to the delayedDeletedFile. * * @param identifier * @return boolean true if it was successful otherwise false */ private boolean writeDelayedDataIdentifier(DataIdentifier identifier) { BufferedWriter writer = null; try { File identifierFile = new File( ((LocalFileSystem) identifiersToDeleteFile.getFileSystem()).getPath(), identifiersToDeleteFile.getPath()); writer = new BufferedWriter(new FileWriter(identifierFile, true)); writer.write(identifier.toString()); return true; } catch (Exception e) { log.warn("I/O error while saving DataIdentifier (stacktrace on DEBUG log level) to '" + identifiersToDeleteFile.getPath() + "': " + e.getMessage()); log.debug("Root cause: ", e); return false; } finally { IOUtils.closeQuietly(writer); } }
/** * Creates a new instance from a stream. * * @param fsResource the file system resource * @throws IOException */ private BLOBInResource(FileSystemResource fsResource) throws IOException { try { if (!fsResource.exists()) { throw new IOException(fsResource.getPath() + ": the specified resource does not exist"); } length = fsResource.length(); } catch (FileSystemException fse) { IOException e2 = new IOException(fsResource.getPath() + ": Error while creating value: " + fse.toString()); e2.initCause(fse); throw e2; } this.fsResource = fsResource; }
public InputStream getStream() throws RepositoryException { try { return fsResource.getInputStream(); } catch (FileSystemException fse) { throw new RepositoryException(fsResource.getPath() + ": the specified resource does not exist", 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); } }
/** * Checks if the synonym properties file has been updated and this provider * should reload the synonyms. This method performs the actual check at most * every {@link #CHECK_INTERVAL}. If reloading fails an error is logged and * this provider will retry after {@link #CHECK_INTERVAL}. */ private synchronized void checkConfigUpdated() { if (lastCheck + CHECK_INTERVAL > System.currentTimeMillis()) { return; } // check last modified try { if (configLastModified != config.lastModified()) { synonyms = getSynonyms(config); configLastModified = config.lastModified(); log.info("Reloaded synonyms from {}", config.getPath()); } } catch (Exception e) { log.error("Exception while reading synonyms", e); } // update lastCheck timestamp, even if error occurred (retry later) lastCheck = System.currentTimeMillis(); }
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); } }
/** * Checks if the synonym properties file has been updated and this provider * should reload the synonyms. This method performs the actual check at most * every {@link #CHECK_INTERVAL}. If reloading fails an error is logged and * this provider will retry after {@link #CHECK_INTERVAL}. */ private synchronized void checkConfigUpdated() { if (lastCheck + CHECK_INTERVAL > System.currentTimeMillis()) { return; } // check last modified try { if (configLastModified != config.lastModified()) { synonyms = getSynonyms(config); configLastModified = config.lastModified(); log.info("Reloaded synonyms from {}", config.getPath()); } } catch (Exception e) { log.error("Exception while reading synonyms", e); } // update lastCheck timestamp, even if error occurred (retry later) lastCheck = System.currentTimeMillis(); }
public RetentionRegistryImpl(SessionImpl session, FileSystem fs) throws RepositoryException { this.session = session; this.retentionFile = new FileSystemResource(fs, FileSystem.SEPARATOR + FILE_NAME); // start listening to added/changed or removed holds and retention policies. Workspace wsp = session.getWorkspace(); // register event listener to be informed about new/removed holds and // retention policies. int types = Event.PROPERTY_ADDED | Event.PROPERTY_REMOVED | Event.PROPERTY_CHANGED; String[] ntFilter = new String[] {session.getJCRName(RetentionManagerImpl.REP_RETENTION_MANAGEABLE)}; wsp.getObservationManager().addEventListener(this, types, "/", true, null, ntFilter, false); // populate the retentionMap and the holdMap with the effective // holds and retention policies present within the content. try { readRetentionFile(); } catch (FileSystemException e) { throw new RepositoryException("Error while reading retention/holds from '" + retentionFile.getPath() + "'", e); } catch (IOException e) { throw new RepositoryException("Error while reading retention/holds from '" + retentionFile.getPath() + "'", e); } initialized = true; }
public RetentionRegistryImpl(SessionImpl session, FileSystem fs) throws RepositoryException { this.session = session; this.retentionFile = new FileSystemResource(fs, FileSystem.SEPARATOR + FILE_NAME); // start listening to added/changed or removed holds and retention policies. Workspace wsp = session.getWorkspace(); // register event listener to be informed about new/removed holds and // retention policies. int types = Event.PROPERTY_ADDED | Event.PROPERTY_REMOVED | Event.PROPERTY_CHANGED; String[] ntFilter = new String[] {session.getJCRName(RetentionManagerImpl.REP_RETENTION_MANAGEABLE)}; wsp.getObservationManager().addEventListener(this, types, "/", true, null, ntFilter, false); // populate the retentionMap and the holdMap with the effective // holds and retention policies present within the content. try { readRetentionFile(); } catch (FileSystemException e) { throw new RepositoryException("Error while reading retention/holds from '" + retentionFile.getPath() + "'", e); } catch (IOException e) { throw new RepositoryException("Error while reading retention/holds from '" + retentionFile.getPath() + "'", e); } initialized = true; }
/** * Create a new instance of this class. * * @param session system session * @param fs file system for persisting locks * @param executor scheduled executor service for handling lock timeouts * @throws RepositoryException if an error occurs */ public LockManagerImpl( SessionImpl session, FileSystem fs, ScheduledExecutorService executor) throws RepositoryException { this.sysSession = session; this.locksFile = new FileSystemResource(fs, FileSystem.SEPARATOR + LOCKS_FILE); session.getWorkspace().getObservationManager(). addEventListener(this, Event.NODE_ADDED | Event.NODE_REMOVED, "/", true, null, null, true); try { if (locksFile.exists()) { load(); } } catch (FileSystemException e) { throw new RepositoryException("I/O error while reading locks from '" + locksFile.getPath() + "'", e); } timeoutHandler = executor.scheduleWithFixedDelay( new TimeoutHandler(), 1, 1, TimeUnit.SECONDS); }