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;
}
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;
}
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());
}
}
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);
}
}
}
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);
}
}
}
Aggregations