/** * Create a new instance. * * @param systemSession A system session. * @param rootID The id of the root node. * @throws RepositoryException If an error occurs. */ CachingEntryCollector(SessionImpl systemSession, NodeId rootID) throws RepositoryException { super(systemSession, rootID); cache = new EntryCache(); // for testing purposes, see JCR-2950 String propname = "org.apache.jackrabbit.core.security.authorization.acl.CachingEntryCollector.strategy"; strategy = System.getProperty(propname, "T"); if (!("S".equals(strategy) || "T".equals(strategy) || "P".equals(strategy))) { throw new RepositoryException("Invalid value " + strategy + " specified for system property " + propname); } log.info("Cache Update Strategy: " + strategy); propname = "org.apache.jackrabbit.core.security.authorization.acl.CachingEntryCollector.cacheNoACL"; cacheNoAcl = Boolean.parseBoolean(System.getProperty(propname, "false")); log.info("Caching entries with no ACLs: " + cacheNoAcl); }
cache.clear(); break; // no need for further processing. } else if ((type & POLICY_REMOVED) == POLICY_REMOVED) { cache.remove(nodeId, true); } else if ((type & POLICY_MODIFIED) == POLICY_MODIFIED) { cache.remove(nodeId, false); } else if ((type & MOVE) == MOVE) { cache.clear(); break; // no need for further processing.
cache.clear(); break; // no need for further processing. } else if ((type & POLICY_REMOVED) == POLICY_REMOVED) { cache.remove(nodeId, true); } else if ((type & POLICY_MODIFIED) == POLICY_MODIFIED) { cache.remove(nodeId, false); } else if ((type & MOVE) == MOVE) { cache.clear(); break; // no need for further processing.
/** * Find the next access control ancestor in the hierarchy 'null' indicates * that there is no ac-controlled ancestor. * * @param node The target node for which the cache needs to be updated. * @return The NodeId of the next access controlled ancestor in the hierarchy * or null */ private NodeId getNextID(NodeImpl node) throws RepositoryException { NodeImpl n = node; NodeId nextId = null; while (nextId == null && !isRootId(n.getNodeId())) { NodeId parentId = n.getParentId(); if (cache.containsKey(parentId)) { nextId = parentId; } else { NodeImpl parent = (NodeImpl) n.getParent(); if (hasEntries(parent)) { nextId = parentId; } else { // try next ancestor n = parent; } } } return nextId; }
/** * Find the next access control ancestor in the hierarchy 'null' indicates * that there is no ac-controlled ancestor. * * @param node The target node for which the cache needs to be updated. * @return The NodeId of the next access controlled ancestor in the hierarchy * or null */ private NodeId getNextID(NodeImpl node) throws RepositoryException { NodeImpl n = node; NodeId nextId = null; while (nextId == null && !isRootId(n.getNodeId())) { NodeId parentId = n.getParentId(); if (cache.containsKey(parentId)) { nextId = parentId; } else { NodeImpl parent = (NodeImpl) n.getParent(); if (hasEntries(parent)) { nextId = parentId; } else { // try next ancestor n = parent; } } } return nextId; }
/** * Create a new instance. * * @param systemSession A system session. * @param rootID The id of the root node. * @throws RepositoryException If an error occurs. */ CachingEntryCollector(SessionImpl systemSession, NodeId rootID) throws RepositoryException { super(systemSession, rootID); cache = new EntryCache(); // for testing purposes, see JCR-2950 String propname = "org.apache.jackrabbit.core.security.authorization.acl.CachingEntryCollector.strategy"; strategy = System.getProperty(propname, "T"); if (!("S".equals(strategy) || "T".equals(strategy) || "P".equals(strategy))) { throw new RepositoryException("Invalid value " + strategy + " specified for system property " + propname); } log.info("Cache Update Strategy: " + strategy); propname = "org.apache.jackrabbit.core.security.authorization.acl.CachingEntryCollector.cacheNoACL"; cacheNoAcl = Boolean.parseBoolean(System.getProperty(propname, "false")); log.info("Caching entries with no ACLs: " + cacheNoAcl); }
/** * Read the entries defined for the specified node and update the cache * accordingly. * * @param node The target node * @return The list of entries present on the specified node or an empty list. * @throws RepositoryException If an error occurs. */ private Entries internalUpdateCache(NodeImpl node) throws RepositoryException { Entries entries = super.getEntries(node); if (cacheNoAcl || (isRootId(node.getNodeId()) && cache.specialCasesRoot()) || !entries.isEmpty()) { // adjust the 'nextId' to point to the next access controlled // ancestor node instead of the parent and remember the entries. entries.setNextId(getNextID(node)); cache.put(node.getNodeId(), entries); } // else: not access controlled -> ignore. return entries; }
/** * Read the entries defined for the specified node and update the cache * accordingly. * * @param node The target node * @return The list of entries present on the specified node or an empty list. * @throws RepositoryException If an error occurs. */ private Entries internalUpdateCache(NodeImpl node) throws RepositoryException { Entries entries = super.getEntries(node); if (cacheNoAcl || (isRootId(node.getNodeId()) && cache.specialCasesRoot()) || !entries.isEmpty()) { // adjust the 'nextId' to point to the next access controlled // ancestor node instead of the parent and remember the entries. entries.setNextId(getNextID(node)); cache.put(node.getNodeId(), entries); } // else: not access controlled -> ignore. return entries; }
/** * @see EntryCollector#getEntries(org.apache.jackrabbit.core.NodeImpl) */ @Override protected Entries getEntries(NodeImpl node) throws RepositoryException { NodeId nodeId = node.getNodeId(); Entries entries = cache.get(nodeId); if (entries == null) { // fetch entries and update the cache entries = updateCache(node); } return entries; }
/** * @see EntryCollector#getEntries(org.apache.jackrabbit.core.id.NodeId) */ @Override protected Entries getEntries(NodeId nodeId) throws RepositoryException { Entries entries = cache.get(nodeId); if (entries == null) { // fetch entries and update the cache NodeImpl n = getNodeById(nodeId); entries = updateCache(n); } return entries; }
/** * @see EntryCollector#getEntries(org.apache.jackrabbit.core.id.NodeId) */ @Override protected Entries getEntries(NodeId nodeId) throws RepositoryException { Entries entries = cache.get(nodeId); if (entries == null) { // fetch entries and update the cache NodeImpl n = getNodeById(nodeId); entries = updateCache(n); } return entries; }
/** * @see EntryCollector#getEntries(org.apache.jackrabbit.core.NodeImpl) */ @Override protected Entries getEntries(NodeImpl node) throws RepositoryException { NodeId nodeId = node.getNodeId(); Entries entries = cache.get(nodeId); if (entries == null) { // fetch entries and update the cache entries = updateCache(node); } return entries; }
@Override protected void close() { super.close(); cache.clear(); }
@Override protected void close() { super.close(); cache.clear(); }