mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
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:
@@ -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>
|
||||||
|
@@ -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 !
|
||||||
|
Reference in New Issue
Block a user