private EntryCache getCache() { IPentahoSession session = PentahoSessionHolder.getSession(); EntryCache cache = (EntryCache) cacheManager.getFromSessionCache( session, ENTRY_COLLECTOR ); if ( cache == null ) { cache = new EntryCache(); cacheManager.putInSessionCache( session, ENTRY_COLLECTOR, cache ); } return cache; }
@Override public void call( EntryCache cache ) { cache.clear(); } } );
/** * 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 ( getCache().containsKey( parentId ) ) { nextId = parentId; } else { NodeImpl parent = (NodeImpl) n.getParent(); if ( hasEntries( parent ) ) { nextId = parentId; } else { // try next ancestor n = parent; } } } return nextId; }
/** * 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 ( ( isRootId( node.getNodeId() ) && getCache().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)); getCache().put( node.getNodeId(), entries ); } // else: not access controlled -> ignore. return entries; }
/** * @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; }
@Override public void call( EntryCache cache ) { cache.clear(); } } );
@Override public void call( EntryCache cache ) { cache.remove( nodeId, false ); } } );
@Override public void call( EntryCache cache ) { cache.clear(); } } );
/** * @see EntryCollector#getEntries(org.apache.jackrabbit.core.NodeImpl) */ @Override protected PentahoEntries getEntries( NodeImpl node ) throws RepositoryException { NodeId nodeId = node.getNodeId(); Entries entries = getCache().get( nodeId ); if ( entries == null ) { // fetch entries and update the cache entries = updateCache( node ); } return entries instanceof PentahoEntries ? (PentahoEntries) entries : new PentahoEntries( entries ); }
@Override public void call( EntryCache cache ) { cache.remove( nodeId, true ); } } );