Search in sources :

Example 1 with DOMWalker

use of org.apache.jackrabbit.core.util.DOMWalker in project jackrabbit by apache.

the class XMLPersistenceManager method load.

/**
     * {@inheritDoc}
     */
public synchronized NodeState load(NodeId id) throws NoSuchItemStateException, ItemStateException {
    if (!initialized) {
        throw new IllegalStateException("not initialized");
    }
    Exception e = null;
    String nodeFilePath = buildNodeFilePath(id);
    try {
        if (!itemStateFS.isFile(nodeFilePath)) {
            throw new NoSuchItemStateException(id.toString());
        }
        InputStream in = itemStateFS.getInputStream(nodeFilePath);
        try {
            DOMWalker walker = new DOMWalker(in);
            String ntName = walker.getAttribute(NODETYPE_ATTRIBUTE);
            NodeState state = createNew(id);
            state.setNodeTypeName(factory.create(ntName));
            readState(walker, state);
            return state;
        } finally {
            in.close();
        }
    } catch (IOException ioe) {
        e = ioe;
    // fall through
    } catch (FileSystemException fse) {
        e = fse;
    // fall through
    }
    String msg = "failed to read node state: " + id;
    log.debug(msg);
    throw new ItemStateException(msg, e);
}
Also used : DOMWalker(org.apache.jackrabbit.core.util.DOMWalker) FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) NodeState(org.apache.jackrabbit.core.state.NodeState) InputStream(java.io.InputStream) IOException(java.io.IOException) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) IOException(java.io.IOException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException) FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException)

Example 2 with DOMWalker

use of org.apache.jackrabbit.core.util.DOMWalker in project jackrabbit by apache.

the class XMLPersistenceManager method loadReferencesTo.

/**
     * {@inheritDoc}
     */
public synchronized NodeReferences loadReferencesTo(NodeId id) throws NoSuchItemStateException, ItemStateException {
    if (!initialized) {
        throw new IllegalStateException("not initialized");
    }
    Exception e = null;
    String refsFilePath = buildNodeReferencesFilePath(id);
    try {
        if (!itemStateFS.isFile(refsFilePath)) {
            throw new NoSuchItemStateException(id.toString());
        }
        InputStream in = itemStateFS.getInputStream(refsFilePath);
        try {
            DOMWalker walker = new DOMWalker(in);
            NodeReferences refs = new NodeReferences(id);
            readState(walker, refs);
            return refs;
        } finally {
            in.close();
        }
    } catch (IOException ioe) {
        e = ioe;
    // fall through
    } catch (FileSystemException fse) {
        e = fse;
    // fall through
    }
    String msg = "failed to load references: " + id;
    log.debug(msg);
    throw new ItemStateException(msg, e);
}
Also used : DOMWalker(org.apache.jackrabbit.core.util.DOMWalker) FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) InputStream(java.io.InputStream) NodeReferences(org.apache.jackrabbit.core.state.NodeReferences) IOException(java.io.IOException) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) IOException(java.io.IOException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException) FileSystemException(org.apache.jackrabbit.core.fs.FileSystemException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException)

Example 3 with DOMWalker

use of org.apache.jackrabbit.core.util.DOMWalker in project jackrabbit by apache.

the class XMLPersistenceManager method load.

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

Aggregations

IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 FileSystemException (org.apache.jackrabbit.core.fs.FileSystemException)3 ItemStateException (org.apache.jackrabbit.core.state.ItemStateException)3 NoSuchItemStateException (org.apache.jackrabbit.core.state.NoSuchItemStateException)3 DOMWalker (org.apache.jackrabbit.core.util.DOMWalker)3 NodeReferences (org.apache.jackrabbit.core.state.NodeReferences)1 NodeState (org.apache.jackrabbit.core.state.NodeState)1 PropertyState (org.apache.jackrabbit.core.state.PropertyState)1