Search in sources :

Example 86 with NodeImpl

use of org.apache.jackrabbit.core.NodeImpl in project pentaho-platform by pentaho.

the class PentahoEntryCollector method collectEntries.

/**
 * Overridden since {@code collectEntries()} from {@code EntryCollector} called {@code node.getParentId()} instead of
 * {@code entries.getNextId()}.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected List collectEntries(NodeImpl node, EntryFilter filter) throws RepositoryException {
    LinkedList userAces = new LinkedList();
    LinkedList groupAces = new LinkedList();
    if (node == null) {
        // repository level permissions
        NodeImpl root = (NodeImpl) systemSession.getRootNode();
        if (ACLProvider.isRepoAccessControlled(root)) {
            NodeImpl aclNode = root.getNode(N_REPO_POLICY);
            String path = aclNode != null ? aclNode.getParent().getPath() : null;
            if (filter instanceof PentahoEntryFilter) {
                filterEntries(filter, PentahoEntry.readEntries(aclNode, path), userAces, groupAces);
            } else {
                filterEntries(filter, Entry.readEntries(aclNode, path), userAces, groupAces);
            }
        }
    } else {
        Entries entries = getEntries(node);
        filterEntries(filter, entries.getACEs(), userAces, groupAces);
        NodeId next = entries.getNextId();
        while (next != null) {
            entries = getEntries(next);
            filterEntries(filter, entries.getACEs(), userAces, groupAces);
            next = entries.getNextId();
        }
    }
    List entries = new ArrayList(userAces.size() + groupAces.size());
    entries.addAll(userAces);
    entries.addAll(groupAces);
    return entries;
}
Also used : NodeImpl(org.apache.jackrabbit.core.NodeImpl) NodeId(org.apache.jackrabbit.core.id.NodeId) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) LinkedList(java.util.LinkedList)

Example 87 with NodeImpl

use of org.apache.jackrabbit.core.NodeImpl in project pentaho-platform by pentaho.

the class CachingPentahoEntryCollector method getEntries.

/**
 * @see EntryCollector#getEntries(org.apache.jackrabbit.core.id.NodeId)
 */
@Override
protected Entries getEntries(NodeId nodeId) throws RepositoryException {
    Entries entries = getCache().get(nodeId);
    if (entries == null) {
        // fetch entries and update the cache
        NodeImpl n = getNodeById(nodeId);
        entries = updateCache(n);
    }
    return entries;
}
Also used : NodeImpl(org.apache.jackrabbit.core.NodeImpl)

Example 88 with NodeImpl

use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.

the class VirtualNodeTypeStateManager method nodeTypeRegistered.

/**
 * {@inheritDoc}
 */
public void nodeTypeRegistered(Name ntName) {
    try {
        if (virtProvider != null) {
            // allow provider to update
            virtProvider.onNodeTypeAdded(ntName);
        }
        if (systemSession != null) {
            // generate observation events
            NodeImpl root = (NodeImpl) systemSession.getItemManager().getItem(rootNodeId);
            NodeImpl child = root.getNode(ntName);
            List<EventState> events = new ArrayList<EventState>();
            recursiveAdd(events, root, child);
            obsDispatcher.dispatch(events, systemSession, NODE_TYPES_PATH, null);
        }
    } catch (RepositoryException e) {
        log.error("Unable to index new nodetype: " + e.toString());
    }
}
Also used : EventState(org.apache.jackrabbit.core.observation.EventState) NodeImpl(org.apache.jackrabbit.core.NodeImpl) ArrayList(java.util.ArrayList) RepositoryException(javax.jcr.RepositoryException)

Example 89 with NodeImpl

use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.

the class RetentionRegistryImpl method readRetentionFile.

/**
 * Read the file system resource containing the node ids of those nodes
 * contain holds/retention policies and populate the 2 path maps.
 *
 * If an entry in the retention file doesn't have a corresponding entry
 * (either rep:hold property or rep:retentionPolicy property at the
 * node identified by the node id entry) or doesn't correspond to an existing
 * node, that entry will be ignored. Upon {@link #close()} of this
 * manager, the file will be updated to reflect the actual set of holds/
 * retentions present and effective in the content.
 *
 * @throws IOException
 * @throws FileSystemException
 */
private void readRetentionFile() throws IOException, FileSystemException {
    if (retentionFile.exists()) {
        BufferedReader reader = null;
        try {
            reader = new BufferedReader(new InputStreamReader(retentionFile.getInputStream()));
            String line;
            while ((line = reader.readLine()) != null) {
                NodeId nodeId = NodeId.valueOf(line);
                try {
                    NodeImpl node = (NodeImpl) session.getItemManager().getItem(nodeId);
                    Path nodePath = node.getPrimaryPath();
                    if (node.hasProperty(RetentionManagerImpl.REP_HOLD)) {
                        PropertyImpl prop = node.getProperty(RetentionManagerImpl.REP_HOLD);
                        addHolds(nodePath, prop);
                    }
                    if (node.hasProperty(RetentionManagerImpl.REP_RETENTION_POLICY)) {
                        PropertyImpl prop = node.getProperty(RetentionManagerImpl.REP_RETENTION_POLICY);
                        addRetentionPolicy(nodePath, prop);
                    }
                } catch (RepositoryException e) {
                    // node doesn't exist any more or hold/retention has been removed.
                    // ignore. upon close() the file will not contain the given nodeId
                    // any more.
                    log.warn("Unable to read retention policy / holds from node '" + nodeId + "': " + e.getMessage());
                }
            }
        } finally {
            IOUtils.closeQuietly(reader);
        }
    }
}
Also used : Path(org.apache.jackrabbit.spi.Path) InputStreamReader(java.io.InputStreamReader) NodeImpl(org.apache.jackrabbit.core.NodeImpl) BufferedReader(java.io.BufferedReader) NodeId(org.apache.jackrabbit.core.id.NodeId) PropertyImpl(org.apache.jackrabbit.core.PropertyImpl) RepositoryException(javax.jcr.RepositoryException)

Example 90 with NodeImpl

use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.

the class TraversingNodeResolver method collectNodes.

/**
 * Searches the given value in the range of the given NodeIterator.
 * This method is called recursively to look within the complete tree
 * of authorizable nodes.
 *
 * @param value         the value to be found in the nodes
 * @param propertyNames property to be searched, or null if {@link javax.jcr.Item#getName()}
 * @param nodeTypeName  name of node types to search
 * @param itr           range of nodes and descendants to be searched
 * @param matchSet      Set of found matches to append results
 * @param exact         if set to true the value has to match exact
 * @param maxSize
 */
private void collectNodes(String value, Set<Name> propertyNames, Name nodeTypeName, NodeIterator itr, Set<Node> matchSet, boolean exact, long maxSize) {
    while (itr.hasNext()) {
        NodeImpl node = (NodeImpl) itr.nextNode();
        try {
            if (matches(node, nodeTypeName, propertyNames, value, exact)) {
                matchSet.add(node);
                maxSize--;
            }
            if (node.hasNodes() && maxSize > 0) {
                collectNodes(value, propertyNames, nodeTypeName, node.getNodes(), matchSet, exact, maxSize);
            }
        } catch (RepositoryException e) {
            log.warn("Internal error while accessing node", e);
        }
    }
}
Also used : NodeImpl(org.apache.jackrabbit.core.NodeImpl) RepositoryException(javax.jcr.RepositoryException)

Aggregations

NodeImpl (org.apache.jackrabbit.core.NodeImpl)161 RepositoryException (javax.jcr.RepositoryException)34 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)29 NodeId (org.apache.jackrabbit.core.id.NodeId)25 AccessControlPolicy (javax.jcr.security.AccessControlPolicy)18 ArrayList (java.util.ArrayList)17 Value (javax.jcr.Value)16 Name (org.apache.jackrabbit.spi.Name)16 AccessControlEntry (javax.jcr.security.AccessControlEntry)15 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)13 AccessControlManager (javax.jcr.security.AccessControlManager)13 ByteArrayInputStream (java.io.ByteArrayInputStream)12 InputStream (java.io.InputStream)12 NodeIterator (javax.jcr.NodeIterator)12 JackrabbitAccessControlManager (org.apache.jackrabbit.api.security.JackrabbitAccessControlManager)11 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)11 Principal (java.security.Principal)10 Node (javax.jcr.Node)10 ParsingContentHandler (org.apache.jackrabbit.commons.xml.ParsingContentHandler)10 JackrabbitAccessControlList (org.apache.jackrabbit.api.security.JackrabbitAccessControlList)9