Initial fix for forum post 34098

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7764 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2008-01-07 16:35:27 +00:00
parent 75967c3736
commit c1fa7ba626
2 changed files with 47 additions and 33 deletions

View File

@@ -21,6 +21,7 @@
<property name="nodeService" ref="nodeService"/> <property name="nodeService" ref="nodeService"/>
<property name="policyComponent" ref="policyComponent"/> <property name="policyComponent" ref="policyComponent"/>
<property name="usageService" ref="usageService"/> <property name="usageService" ref="usageService"/>
<property name="authenticationComponent" ref="authenticationComponent"/>
<property name="enabled"> <property name="enabled">
<value>${system.usages.enabled}</value> <value>${system.usages.enabled}</value>
</property> </property>

View File

@@ -32,6 +32,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
@@ -61,6 +62,7 @@ public class ContentUsageImpl implements ContentUsageService,
private PersonService personService; private PersonService personService;
private PolicyComponent policyComponent; private PolicyComponent policyComponent;
private UsageService usageService; private UsageService usageService;
private AuthenticationComponent authenticationComponent;
private boolean enabled = true; private boolean enabled = true;
@@ -86,6 +88,11 @@ public class ContentUsageImpl implements ContentUsageService,
this.policyComponent = policyComponent; this.policyComponent = policyComponent;
} }
public void setAuthenticationComponent(AuthenticationComponent authenticationComponent)
{
this.authenticationComponent = authenticationComponent;
}
public void setEnabled(boolean enabled) public void setEnabled(boolean enabled)
{ {
this.enabled = enabled; this.enabled = enabled;
@@ -287,6 +294,8 @@ public class ContentUsageImpl implements ContentUsageService,
} }
private void incrementUserUsage(String userName, long contentSize, NodeRef contentNodeRef) private void incrementUserUsage(String userName, long contentSize, NodeRef contentNodeRef)
{
if (! userName.equals(authenticationComponent.getSystemUserName()))
{ {
// increment usage - add positive delta // increment usage - add positive delta
if (logger.isDebugEnabled()) logger.debug("incrementUserUsage: username="+userName+", contentSize="+contentSize+", contentNodeRef="+contentNodeRef); if (logger.isDebugEnabled()) logger.debug("incrementUserUsage: username="+userName+", contentSize="+contentSize+", contentNodeRef="+contentNodeRef);
@@ -311,8 +320,11 @@ public class ContentUsageImpl implements ContentUsageService,
NodeRef personNodeRef = personService.getPerson(userName); NodeRef personNodeRef = personService.getPerson(userName);
usageService.insertDelta(personNodeRef, contentSize); usageService.insertDelta(personNodeRef, contentSize);
} }
}
private void decrementUserUsage(String userName, long contentSize, NodeRef contentNodeRef) private void decrementUserUsage(String userName, long contentSize, NodeRef contentNodeRef)
{
if (! userName.equals(authenticationComponent.getSystemUserName()))
{ {
// decrement usage - add negative delta // decrement usage - add negative delta
if (logger.isDebugEnabled()) logger.debug("decrementUserUsage: username="+userName+", contentSize="+contentSize+", contentNodeRef="+contentNodeRef); if (logger.isDebugEnabled()) logger.debug("decrementUserUsage: username="+userName+", contentSize="+contentSize+", contentNodeRef="+contentNodeRef);
@@ -332,6 +344,7 @@ public class ContentUsageImpl implements ContentUsageService,
NodeRef personNodeRef = personService.getPerson(userName); NodeRef personNodeRef = personService.getPerson(userName);
usageService.insertDelta(personNodeRef, (-contentSize)); usageService.insertDelta(personNodeRef, (-contentSize));
} }
}
/** /**
* Set user's usage. Should only be called by background (collapse) job ! * Set user's usage. Should only be called by background (collapse) job !