10-27-2011 10:16 AM
10-27-2011 10:28 AM
public void onUpdateProperties(
NodeRef nodeRef,
Map<QName, Serializable> before,
Map<QName, Serializable> after)
{
if (stores.contains(tenantService.getBaseName(nodeRef.getStoreRef()).toString()) && (! alreadyCreated(nodeRef)))
{
// Check for change in content size
// TODO use data dictionary to get content property
ContentData contentDataBefore = (ContentData)before.get(ContentModel.PROP_CONTENT);
Long contentSizeBefore = (contentDataBefore == null ? null : contentDataBefore.getSize());
ContentData contentDataAfter = (ContentData)after.get(ContentModel.PROP_CONTENT);
Long contentSizeAfter = (contentDataAfter == null ? null : contentDataAfter.getSize());
// Check for change in owner/creator
String ownerBefore = (String)before.get(ContentModel.PROP_OWNER);
if ((ownerBefore == null) || (ownerBefore.equals(OwnableService.NO_OWNER)))
{
ownerBefore = (String)before.get(ContentModel.PROP_CREATOR);
}
String ownerAfter = (String)after.get(ContentModel.PROP_OWNER);
if ((ownerAfter == null) || (ownerAfter.equals(OwnableService.NO_OWNER)))
{
ownerAfter = (String)after.get(ContentModel.PROP_CREATOR);
}
// check change in size (and possibly owner)
if (contentSizeBefore == null && contentSizeAfter != null && contentSizeAfter != 0 && ownerAfter != null)
{
// new size has been added - note: ownerBefore does not matter since the contentSizeBefore is null
if (logger.isDebugEnabled()) logger.debug("onUpdateProperties: updateSize (null -> "+contentSizeAfter+"): nodeRef="+nodeRef+", ownerAfter="+ownerAfter);
incrementUserUsage(ownerAfter, contentSizeAfter, nodeRef);
}
else if (contentSizeAfter == null && contentSizeBefore != null && contentSizeBefore != 0 && ownerBefore != null)
{
// old size has been removed - note: ownerAfter does not matter since contentSizeAfter is null
if (logger.isDebugEnabled()) logger.debug("onUpdateProperties: updateSize ("+contentSizeBefore+" -> null): nodeRef="+nodeRef+", ownerBefore="+ownerBefore);
decrementUserUsage(ownerBefore, contentSizeBefore, nodeRef);
}
else if (contentSizeBefore != null && contentSizeAfter != null)
{
if (contentSizeBefore.equals(contentSizeAfter) == false)
{
// size has changed (and possibly owner)
if (logger.isDebugEnabled()) logger.debug("onUpdateProperties: updateSize ("+contentSizeBefore+" -> "+contentSizeAfter+"): nodeRef="+nodeRef+", ownerBefore="+ownerBefore+", ownerAfter="+ownerAfter);
if (contentSizeBefore != 0 && ownerBefore != null)
{
decrementUserUsage(ownerBefore, contentSizeBefore, nodeRef);
}
if (contentSizeAfter != 0 && ownerAfter != null)
{
incrementUserUsage(ownerAfter, contentSizeAfter, nodeRef);
}
}
else
{
// same size - check change in owner only
if (ownerBefore == null && ownerAfter != null && contentSizeAfter != 0 && ownerAfter != null)
{
// new owner has been added
if (logger.isDebugEnabled()) logger.debug("onUpdateProperties: updateOwner (null -> "+ownerAfter+"): nodeRef="+nodeRef+", contentSize="+contentSizeAfter);
incrementUserUsage(ownerAfter, contentSizeAfter, nodeRef);
}
else if (ownerAfter == null && ownerBefore != null && contentSizeBefore != 0)
{
// old owner has been removed
if (logger.isDebugEnabled()) logger.debug("onUpdateProperties: updateOwner ("+ownerBefore+" -> null): nodeRef="+nodeRef+", contentSize="+contentSizeBefore);
decrementUserUsage(ownerBefore, contentSizeBefore, nodeRef);
}
else if (ownerBefore != null && ownerAfter != null && ownerBefore.equals(ownerAfter) == false)
{
// owner has changed (size has not)
if (logger.isDebugEnabled()) logger.debug("onUpdateProperties: updateOwner ("+ownerBefore+" -> "+ownerAfter+"): nodeRef="+nodeRef+", contentSize="+contentSizeBefore);
if (contentSizeBefore != 0)
{
decrementUserUsage(ownerBefore, contentSizeBefore, nodeRef);
}
if (contentSizeAfter != 0)
{
incrementUserUsage(ownerAfter, contentSizeAfter, nodeRef);
}
}
}
}
}
}
10-27-2011 11:42 AM
10-27-2011 11:31 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.