Search in sources :

Example 16 with FileSystemException

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

the class DatabaseFileSystem method listFolders.

/**
     * {@inheritDoc}
     */
public String[] listFolders(String folderPath) throws FileSystemException {
    if (!initialized) {
        throw new IllegalStateException("not initialized");
    }
    FileSystemPathUtil.checkFormat(folderPath);
    if (!isFolder(folderPath)) {
        throw new FileSystemException("no such folder: " + folderPath);
    }
    synchronized (selectFolderNamesSQL) {
        ResultSet rs = null;
        try {
            rs = conHelper.exec(selectFolderNamesSQL, new Object[] { folderPath }, false, 0);
            ArrayList<String> names = new ArrayList<String>();
            while (rs.next()) {
                String name = rs.getString(1);
                if (name.length() == 0 && FileSystemPathUtil.denotesRoot(folderPath)) {
                    // this is the file system root entry, skip...
                    continue;
                }
                names.add(name);
            }
            return (String[]) names.toArray(new String[names.size()]);
        } catch (SQLException e) {
            String msg = "failed to list folder entries of folder: " + folderPath;
            log.error(msg, e);
            throw new FileSystemException(msg, e);
        } finally {
            DbUtility.close(rs);
        }
    }
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList)

Example 17 with FileSystemException

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

the class ObjectPersistenceManager method exists.

/**
     * {@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);
    }
}
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 18 with FileSystemException

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

the class ObjectPersistenceManager method load.

/**
     * {@inheritDoc}
     */
public synchronized PropertyState load(PropertyId id) throws NoSuchItemStateException, ItemStateException {
    if (!initialized) {
        throw new IllegalStateException("not initialized");
    }
    String propFilePath = buildPropFilePath(id);
    try {
        if (!itemStateFS.isFile(propFilePath)) {
            throw new NoSuchItemStateException(propFilePath);
        }
    } catch (FileSystemException fse) {
        String msg = "failed to read property state: " + propFilePath;
        log.debug(msg);
        throw new ItemStateException(msg, fse);
    }
    try {
        BufferedInputStream in = new BufferedInputStream(itemStateFS.getInputStream(propFilePath));
        try {
            PropertyState state = createNew(id);
            Serializer.deserialize(state, in, blobStore);
            return state;
        } finally {
            in.close();
        }
    } catch (Exception e) {
        String msg = "failed to read property state: " + propFilePath;
        log.debug(msg);
        throw new ItemStateException(msg, e);
    }
}
Also used : FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) BufferedInputStream(java.io.BufferedInputStream) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException) FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException) PropertyState(org.apache.jackrabbit.core.state.PropertyState)

Example 19 with FileSystemException

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

the class ObjectPersistenceManager 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 20 with FileSystemException

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

the class ObjectPersistenceManager method destroy.

/**
     * {@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);
    }
}
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)

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