Search in sources :

Example 46 with FileSystemException

use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.

the class XMLPersistenceManager method existsReferencesTo.

/**
     * {@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);
    }
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) FileSystemResource(org.apache.jackrabbit.core.fs.FileSystemResource) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException)

Example 47 with FileSystemException

use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.

the class RetentionRegistryImpl method writeRetentionFile.

/**
     * Write back the file system resource containing the node ids of those
     * nodes containing holds and/or retention policies. Each node id is
     * present only once.
     */
private void writeRetentionFile() {
    final Set<NodeId> nodeIds = new HashSet<NodeId>();
    // first look for nodes containing holds
    holdMap.traverse(new PathMap.ElementVisitor<List<HoldImpl>>() {

        public void elementVisited(PathMap.Element<List<HoldImpl>> element) {
            List<HoldImpl> holds = element.get();
            if (!holds.isEmpty()) {
                nodeIds.add(holds.get(0).getNodeId());
            }
        }
    }, false);
    // then collect ids of nodes having an retention policy
    retentionMap.traverse(new PathMap.ElementVisitor<RetentionPolicyImpl>() {

        public void elementVisited(PathMap.Element<RetentionPolicyImpl> element) {
            nodeIds.add(element.get().getNodeId());
        }
    }, false);
    if (!nodeIds.isEmpty()) {
        BufferedWriter writer = null;
        try {
            writer = new BufferedWriter(new OutputStreamWriter(retentionFile.getOutputStream()));
            for (Iterator<NodeId> it = nodeIds.iterator(); it.hasNext(); ) {
                writer.write(it.next().toString());
                if (it.hasNext()) {
                    writer.newLine();
                }
            }
        } catch (FileSystemException fse) {
            log.error("Error while saving locks to '" + retentionFile.getPath() + "': " + fse.getMessage());
        } catch (IOException ioe) {
            log.error("Error while saving locks to '" + retentionFile.getPath() + "': " + ioe.getMessage());
        } finally {
            IOUtils.closeQuietly(writer);
        }
    }
}
Also used : IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter) FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) NodeId(org.apache.jackrabbit.core.id.NodeId) List(java.util.List) OutputStreamWriter(java.io.OutputStreamWriter) PathMap(org.apache.jackrabbit.spi.commons.name.PathMap) HashSet(java.util.HashSet)

Example 48 with FileSystemException

use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.

the class MultiDataStore method init.

/**
     * {@inheritDoc}
     */
public void init(String homeDir) throws RepositoryException {
    if (delayedDelete) {
        // First initialize the identifiersToDeleteFile
        LocalFileSystem fileSystem = new LocalFileSystem();
        fileSystem.setRoot(new File(homeDir));
        identifiersToDeleteFile = new FileSystemResource(fileSystem, FileSystem.SEPARATOR + IDENTIFIERS_TO_DELETE_FILE_KEY);
    }
    moveDataTaskThread = new Thread(new MoveDataTask(), "Jackrabbit-MulitDataStore-MoveDataTaskThread");
    moveDataTaskThread.setDaemon(true);
    moveDataTaskThread.start();
    log.info("MultiDataStore-MoveDataTask thread started; first run scheduled at " + moveDataTaskNextRun.getTime());
    if (delayedDelete) {
        try {
            // delayedDeleteSleep timeout ...
            if (identifiersToDeleteFile != null && identifiersToDeleteFile.exists() && (identifiersToDeleteFile.lastModified() + (delayedDeleteSleep * 1000)) < System.currentTimeMillis()) {
                deleteDelayedIdentifiersTaskThread = new Thread(//Start immediately ...
                new DeleteDelayedIdentifiersTask(0L), "Jackrabbit-MultiDataStore-DeleteDelayedIdentifiersTaskThread");
                deleteDelayedIdentifiersTaskThread.setDaemon(true);
                deleteDelayedIdentifiersTaskThread.start();
                log.info("Old entries in the " + IDENTIFIERS_TO_DELETE_FILE_KEY + " File found. DeleteDelayedIdentifiersTask-Thread started now.");
            }
        } catch (FileSystemException e) {
            throw new RepositoryException("I/O error while reading from '" + identifiersToDeleteFile.getPath() + "'", e);
        }
    }
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) LocalFileSystem(org.apache.jackrabbit.core.fs.local.LocalFileSystem) RepositoryException(javax.jcr.RepositoryException) FileSystemResource(org.apache.jackrabbit.core.fs.FileSystemResource) File(java.io.File)

Example 49 with FileSystemException

use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.

the class LocalFileSystem method createFolder.

/**
     * {@inheritDoc}
     */
public void createFolder(String folderPath) throws FileSystemException {
    File f = new File(root, osPath(folderPath));
    if (f.exists()) {
        String msg = f.getPath() + " already exists";
        log.debug(msg);
        throw new FileSystemException(msg);
    }
    if (!f.mkdirs()) {
        String msg = "failed to create folder " + f.getPath();
        log.debug(msg);
        throw new FileSystemException(msg);
    }
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) File(java.io.File)

Example 50 with FileSystemException

use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.

the class LocalFileSystem method list.

/**
     * {@inheritDoc}
     */
public String[] list(String folderPath) throws FileSystemException {
    File f = new File(root, osPath(folderPath));
    String[] entries = f.list();
    if (entries == null) {
        String msg = folderPath + " does not denote a folder";
        log.debug(msg);
        throw new FileSystemException(msg);
    }
    return entries;
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) File(java.io.File)

Aggregations

FileSystemException (org.apache.jackrabbit.core.fs.FileSystemException)54 ItemStateException (org.apache.jackrabbit.core.state.ItemStateException)19 NoSuchItemStateException (org.apache.jackrabbit.core.state.NoSuchItemStateException)18 FileSystemResource (org.apache.jackrabbit.core.fs.FileSystemResource)16 IOException (java.io.IOException)15 SQLException (java.sql.SQLException)15 File (java.io.File)11 ResultSet (java.sql.ResultSet)10 InputStream (java.io.InputStream)7 RepositoryException (javax.jcr.RepositoryException)7 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)6 OutputStreamWriter (java.io.OutputStreamWriter)4 ArrayList (java.util.ArrayList)4 FileSystem (org.apache.jackrabbit.core.fs.FileSystem)4 BufferedInputStream (java.io.BufferedInputStream)3 BufferedWriter (java.io.BufferedWriter)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 Properties (java.util.Properties)3 FileFilter (java.io.FileFilter)2 FileInputStream (java.io.FileInputStream)2