/* (non-Javadoc)
* @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementAdded(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
*/
public void notifyElementAdded(final JetspeedCache cache, final boolean local, final Object key, final Object element)
{
final NodeImpl node = (NodeImpl)element;
// infuse node with page manager configuration
// or the page manager itself and add to the
// paths cache
node.setConstraintsEnabled(constraintsEnabled);
node.setPermissionsEnabled(permissionsEnabled);
if (node instanceof FolderImpl)
{
((FolderImpl)node).setPageManager(pageManager);
}
}
/* (non-Javadoc)
* @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementChanged(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
*/
public void notifyElementChanged(final JetspeedCache cache, final boolean local, final Object key, final Object element)
{
final NodeImpl node = (NodeImpl)element;
// infuse node with page manager configuration
// or the page manager itself and add to the
// paths cache
node.setConstraintsEnabled(constraintsEnabled);
node.setPermissionsEnabled(permissionsEnabled);
if (node instanceof FolderImpl)
{
((FolderImpl)node).setPageManager(pageManager);
}
}
/* (non-Javadoc)
* @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementEvicted(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
*/
public void notifyElementEvicted(final JetspeedCache cache, final boolean local, final Object key, final Object element)
{
final NodeImpl node = (NodeImpl)element;
// reset internal FolderImpl caches
if (node instanceof FolderImpl)
{
((FolderImpl)node).resetAll(false);
}
}
/* (non-Javadoc)
* @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementExpired(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
*/
public void notifyElementExpired(final JetspeedCache cache, final boolean local, final Object key, final Object element)
{
final NodeImpl node = (NodeImpl)element;
// reset internal FolderImpl caches
if (node instanceof FolderImpl)
{
((FolderImpl)node).resetAll(false);
}
}
/* (non-Javadoc)
* @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementRemoved(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
*/
public void notifyElementRemoved(final JetspeedCache cache, final boolean local, final Object key, final Object element)
{
final NodeImpl node = (NodeImpl)element;
// reset internal FolderImpl caches
if (node instanceof FolderImpl)
{
((FolderImpl)node).resetAll(false);
}
}
}, true);
// setup remote path cache listener
pathCache.addEventListener(new JetspeedCacheEventListener()
{
/* (non-Javadoc)
* @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementAdded(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
*/
public void notifyElementAdded(final JetspeedCache cache, final boolean local, final Object key, final Object element)
{
}
/* (non-Javadoc)
* @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementChanged(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
*/
public void notifyElementChanged(final JetspeedCache cache, final boolean local, final Object key, final Object element)
{
}
/* (non-Javadoc)
* @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementEvicted(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
*/
public void notifyElementEvicted(final JetspeedCache cache, final boolean local, final Object key, final Object element)
{
}
/* (non-Javadoc)
* @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementExpired(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
*/
public void notifyElementExpired(final JetspeedCache cache, final boolean local, final Object key, final Object element)
{
}
/* (non-Javadoc)
* @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementRemoved(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
*/
public void notifyElementRemoved(final JetspeedCache cache, final boolean local, final Object key, final Object element)
{
final DatabasePageManagerCacheObject cacheObject = (DatabasePageManagerCacheObject)element;
// remove cache object from local oid cache
if (cacheObject != null)
{
final Identity oid = cacheObject.getId();
final String path = cacheObject.getPath();
if ((oid != null) || (path != null))
{
synchronized (DatabasePageManagerCache.class)
{
if (oid != null)
{
// get object cached by oid
final NodeImpl node = (NodeImpl)cacheLookup(oid);
// reset internal FolderImpl caches
if (node instanceof FolderImpl)
{
((FolderImpl)node).resetAll(false);
}
// notify page manager of update
pageManager.notifyUpdatedNode(node);
// remove from cache
oidCache.removeQuiet(oid);
}
if (path != null)
{
// lookup parent object cached by path and oid
final int pathLastSeparatorIndex = path.lastIndexOf(Folder.PATH_SEPARATOR);
final String parentPath = ((pathLastSeparatorIndex > 0) ? path.substring(0, pathLastSeparatorIndex) : Folder.PATH_SEPARATOR);
final NodeImpl parentNode = cacheLookup(parentPath);
// reset internal FolderImpl caches in case element removed
if (parentNode instanceof FolderImpl)
{
((FolderImpl)parentNode).resetAll(false);
}