/* (non-Javadoc)
* @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementAdded(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
*/
public void notifyElementAdded(JetspeedCache cache, boolean local, Object key, Object element)
{
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);
node.setPageManager(databasePageManager);
}
/* (non-Javadoc)
* @see org.apache.jetspeed.cache.JetspeedCacheEventListener#notifyElementChanged(org.apache.jetspeed.cache.JetspeedCache, boolean, java.lang.Object, java.lang.Object)
*/
public void notifyElementChanged(JetspeedCache cache, boolean local, Object key, Object element)
{
notifyElementAdded(cache, local, key, 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(JetspeedCache cache, boolean local, Object key, Object element)
{
notifyElementRemoved(cache, local, key, 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(JetspeedCache cache, boolean local, Object key, Object element)
{
notifyElementRemoved(cache, local, key, 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(JetspeedCache cache, boolean local, Object key, Object element)
{
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(JetspeedCache cache, boolean local, Object key, 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(JetspeedCache cache, boolean local, Object key, 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(JetspeedCache cache, boolean local, Object key, 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(JetspeedCache cache, boolean local, Object key, 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(JetspeedCache cache, boolean local, Object key, Object element)
{
DatabasePageManagerCacheObject cacheObject = (DatabasePageManagerCacheObject)element;
// remove cache object from local caches
Identity oid = ((cacheObject != null) ? cacheObject.getId() : null);
String path = ((cacheObject != null) ? cacheObject.getPath() : (String)key);
if ((oid != null) || (path != null))
{
synchronized (DatabasePageManagerCache.class)
{
if (oid != null)
{
// get object cached by oid
NodeImpl node = (NodeImpl)cacheLookup(oid);
// reset internal FolderImpl caches
if (node instanceof FolderImpl)
{
((FolderImpl)node).resetAll(false);
}
// notify page manager of update
DatabasePageManagerCache.pageManager.notifyUpdatedNode(node);
// remove from cache
DatabasePageManagerCache.oidCache.removeQuiet(oid);
}
if (path != null)
{
// lookup parent object cached by path and oid
int pathLastSeparatorIndex = path.lastIndexOf(Folder.PATH_SEPARATOR);
String parentPath = ((pathLastSeparatorIndex > 0) ? path.substring(0, pathLastSeparatorIndex) : Folder.PATH_SEPARATOR);
NodeImpl parentNode = cacheLookup(parentPath);
// reset internal FolderImpl caches in case element removed
if (parentNode instanceof FolderImpl)
{
((FolderImpl)parentNode).resetAll(false);
}