Search in sources :

Example 21 with NoSuchItemStateException

use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.

the class InMemPersistenceManager method loadReferencesTo.

/**
     * {@inheritDoc}
     */
public synchronized NodeReferences loadReferencesTo(NodeId id) throws NoSuchItemStateException, ItemStateException {
    if (!initialized) {
        throw new IllegalStateException("not initialized");
    }
    byte[] data = refsStore.get(id);
    if (data == null) {
        throw new NoSuchItemStateException(id.toString());
    }
    ByteArrayInputStream in = new ByteArrayInputStream(data);
    try {
        NodeReferences refs = new NodeReferences(id);
        Serializer.deserialize(refs, in);
        return refs;
    } catch (Exception e) {
        String msg = "failed to load references: " + id;
        log.debug(msg);
        throw new ItemStateException(msg, e);
    }
}
Also used : NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ByteArrayInputStream(java.io.ByteArrayInputStream) NodeReferences(org.apache.jackrabbit.core.state.NodeReferences) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException)

Example 22 with NoSuchItemStateException

use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.

the class InMemPersistenceManager method load.

/**
     * {@inheritDoc}
     */
public synchronized NodeState load(NodeId id) throws NoSuchItemStateException, ItemStateException {
    if (!initialized) {
        throw new IllegalStateException("not initialized");
    }
    byte[] data = stateStore.get(id);
    if (data == null) {
        throw new NoSuchItemStateException(id.toString());
    }
    ByteArrayInputStream in = new ByteArrayInputStream(data);
    try {
        NodeState state = createNew(id);
        Serializer.deserialize(state, in);
        return state;
    } catch (Exception e) {
        String msg = "failed to read node state: " + id;
        log.debug(msg);
        throw new ItemStateException(msg, e);
    }
}
Also used : NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) NodeState(org.apache.jackrabbit.core.state.NodeState) ByteArrayInputStream(java.io.ByteArrayInputStream) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException)

Example 23 with NoSuchItemStateException

use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.

the class ObjectPersistenceManager method loadReferencesTo.

/**
     * {@inheritDoc}
     */
public synchronized NodeReferences loadReferencesTo(NodeId id) throws NoSuchItemStateException, ItemStateException {
    if (!initialized) {
        throw new IllegalStateException("not initialized");
    }
    String refsFilePath = buildNodeReferencesFilePath(id);
    try {
        if (!itemStateFS.isFile(refsFilePath)) {
            throw new NoSuchItemStateException(id.toString());
        }
    } catch (FileSystemException fse) {
        String msg = "failed to load references: " + id;
        log.debug(msg);
        throw new ItemStateException(msg, fse);
    }
    try {
        BufferedInputStream in = new BufferedInputStream(itemStateFS.getInputStream(refsFilePath));
        try {
            NodeReferences refs = new NodeReferences(id);
            Serializer.deserialize(refs, in);
            return refs;
        } finally {
            in.close();
        }
    } catch (Exception e) {
        String msg = "failed to load references: " + id;
        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) NodeReferences(org.apache.jackrabbit.core.state.NodeReferences) 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)

Example 24 with NoSuchItemStateException

use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.

the class HierarchyManagerImpl method getName.

/**
     * {@inheritDoc}
     */
public Name getName(NodeId id, NodeId parentId) throws ItemNotFoundException, RepositoryException {
    NodeState parentState;
    try {
        parentState = (NodeState) getItemState(parentId);
    } catch (NoSuchItemStateException nsis) {
        String msg = "failed to resolve name of " + id;
        log.debug(msg);
        throw new ItemNotFoundException(id.toString());
    } catch (ItemStateException ise) {
        String msg = "failed to resolve name of " + id;
        log.debug(msg);
        throw new RepositoryException(msg, ise);
    }
    ChildNodeEntry entry = getChildNodeEntry(parentState, id);
    if (entry == null) {
        String msg = "failed to resolve name of " + id;
        log.debug(msg);
        throw new ItemNotFoundException(msg);
    }
    return entry.getName();
}
Also used : NodeState(org.apache.jackrabbit.core.state.NodeState) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ChildNodeEntry(org.apache.jackrabbit.core.state.ChildNodeEntry) RepositoryException(javax.jcr.RepositoryException) ItemNotFoundException(javax.jcr.ItemNotFoundException) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) InvalidItemStateException(javax.jcr.InvalidItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException)

Example 25 with NoSuchItemStateException

use of org.apache.jackrabbit.core.state.NoSuchItemStateException in project jackrabbit by apache.

the class HierarchyManagerImpl method getName.

/**
     * {@inheritDoc}
     */
public Name getName(ItemId itemId) throws ItemNotFoundException, RepositoryException {
    if (itemId.denotesNode()) {
        NodeId nodeId = (NodeId) itemId;
        try {
            NodeState nodeState = (NodeState) getItemState(nodeId);
            NodeId parentId = getParentId(nodeState);
            if (parentId == null) {
                // FIXME
                return EMPTY_NAME;
            }
            return getName(nodeId, parentId);
        } catch (NoSuchItemStateException nsis) {
            String msg = "failed to resolve name of " + nodeId;
            log.debug(msg);
            throw new ItemNotFoundException(nodeId.toString());
        } catch (ItemStateException ise) {
            String msg = "failed to resolve name of " + nodeId;
            log.debug(msg);
            throw new RepositoryException(msg, ise);
        }
    } else {
        return ((PropertyId) itemId).getName();
    }
}
Also used : NodeState(org.apache.jackrabbit.core.state.NodeState) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) NodeId(org.apache.jackrabbit.core.id.NodeId) RepositoryException(javax.jcr.RepositoryException) ItemNotFoundException(javax.jcr.ItemNotFoundException) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) InvalidItemStateException(javax.jcr.InvalidItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException) PropertyId(org.apache.jackrabbit.core.id.PropertyId)

Aggregations

NoSuchItemStateException (org.apache.jackrabbit.core.state.NoSuchItemStateException)37 ItemStateException (org.apache.jackrabbit.core.state.ItemStateException)31 RepositoryException (javax.jcr.RepositoryException)17 NodeId (org.apache.jackrabbit.core.id.NodeId)14 NodeState (org.apache.jackrabbit.core.state.NodeState)13 FileSystemException (org.apache.jackrabbit.core.fs.FileSystemException)11 PropertyState (org.apache.jackrabbit.core.state.PropertyState)11 IOException (java.io.IOException)10 ByteArrayInputStream (java.io.ByteArrayInputStream)8 InputStream (java.io.InputStream)8 InvalidItemStateException (javax.jcr.InvalidItemStateException)8 ItemNotFoundException (javax.jcr.ItemNotFoundException)8 ItemState (org.apache.jackrabbit.core.state.ItemState)8 NodeReferences (org.apache.jackrabbit.core.state.NodeReferences)8 SQLException (java.sql.SQLException)7 PropertyId (org.apache.jackrabbit.core.id.PropertyId)7 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)6 Name (org.apache.jackrabbit.spi.Name)6 InternalValue (org.apache.jackrabbit.core.value.InternalValue)5 FilterInputStream (java.io.FilterInputStream)4