mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
ALF-5352: User usage not always updated for bulk import (eg. ZIP or ACP) - hence reported negative after deleting space imported by ACP
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@37632 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -64,6 +64,9 @@
|
|||||||
<property name="hiddenAspect">
|
<property name="hiddenAspect">
|
||||||
<ref bean="hiddenAspect" />
|
<ref bean="hiddenAspect" />
|
||||||
</property>
|
</property>
|
||||||
|
<property name="contentUsageImpl">
|
||||||
|
<ref bean="contentUsageImpl"/>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
@@ -36,6 +36,7 @@ import org.alfresco.repo.importer.view.NodeContext;
|
|||||||
import org.alfresco.repo.model.filefolder.HiddenAspect;
|
import org.alfresco.repo.model.filefolder.HiddenAspect;
|
||||||
import org.alfresco.repo.policy.BehaviourFilter;
|
import org.alfresco.repo.policy.BehaviourFilter;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationContext;
|
import org.alfresco.repo.security.authentication.AuthenticationContext;
|
||||||
|
import org.alfresco.repo.usage.ContentUsageImpl;
|
||||||
import org.alfresco.repo.version.Version2Model;
|
import org.alfresco.repo.version.Version2Model;
|
||||||
import org.alfresco.repo.version.common.VersionUtil;
|
import org.alfresco.repo.version.common.VersionUtil;
|
||||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||||
@@ -110,12 +111,14 @@ public class ImporterComponent
|
|||||||
private OwnableService ownableService;
|
private OwnableService ownableService;
|
||||||
private VersionService versionService;
|
private VersionService versionService;
|
||||||
private HiddenAspect hiddenAspect;
|
private HiddenAspect hiddenAspect;
|
||||||
|
private ContentUsageImpl contentUsageImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The db node service, used when updating the version store.
|
* The db node service, used when updating the version store.
|
||||||
*/
|
*/
|
||||||
protected NodeService dbNodeService;
|
protected NodeService dbNodeService;
|
||||||
|
|
||||||
|
|
||||||
// binding markers
|
// binding markers
|
||||||
private static final String START_BINDING_MARKER = "${";
|
private static final String START_BINDING_MARKER = "${";
|
||||||
private static final String END_BINDING_MARKER = "}";
|
private static final String END_BINDING_MARKER = "}";
|
||||||
@@ -243,6 +246,20 @@ public class ImporterComponent
|
|||||||
this.hiddenAspect = hiddenAspect;
|
this.hiddenAspect = hiddenAspect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When all behaviour is disabled it is necessary to use {@link ContentUsageImpl}
|
||||||
|
* directly to update user usage. An instance of this class (with ID
|
||||||
|
* <code>importerComponentWithBehaviour</code>) that does not disable
|
||||||
|
* behaviours is also defined in the system - in that case it should not reference
|
||||||
|
* the {@link ContentUsageImpl} collaborator.
|
||||||
|
*
|
||||||
|
* @param contentUsageImpl the contentUsageImpl to set
|
||||||
|
*/
|
||||||
|
public void setContentUsageImpl(ContentUsageImpl contentUsageImpl)
|
||||||
|
{
|
||||||
|
this.contentUsageImpl = contentUsageImpl;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.service.cmr.view.ImporterService#importView(java.io.InputStreamReader, org.alfresco.service.cmr.view.Location, java.util.Properties, org.alfresco.service.cmr.view.ImporterProgress)
|
* @see org.alfresco.service.cmr.view.ImporterService#importView(java.io.InputStreamReader, org.alfresco.service.cmr.view.Location, java.util.Properties, org.alfresco.service.cmr.view.ImporterProgress)
|
||||||
*/
|
*/
|
||||||
@@ -770,7 +787,23 @@ public class ImporterComponent
|
|||||||
ContentWriter writer = contentService.getWriter(nodeRef, propertyName, true);
|
ContentWriter writer = contentService.getWriter(nodeRef, propertyName, true);
|
||||||
writer.setEncoding(contentData.getEncoding());
|
writer.setEncoding(contentData.getEncoding());
|
||||||
writer.setMimetype(contentData.getMimetype());
|
writer.setMimetype(contentData.getMimetype());
|
||||||
|
|
||||||
|
Map<QName, Serializable> propsBefore = null;
|
||||||
|
if (contentUsageImpl != null && contentUsageImpl.getEnabled())
|
||||||
|
{
|
||||||
|
propsBefore = nodeService.getProperties(nodeRef);
|
||||||
|
}
|
||||||
|
|
||||||
writer.putContent(contentStream);
|
writer.putContent(contentStream);
|
||||||
|
|
||||||
|
if (contentUsageImpl != null && contentUsageImpl.getEnabled())
|
||||||
|
{
|
||||||
|
// Since behaviours for content nodes have all been disabled,
|
||||||
|
// it is necessary to update the user's usage stats.
|
||||||
|
Map<QName, Serializable> propsAfter = nodeService.getProperties(nodeRef);
|
||||||
|
contentUsageImpl.onUpdateProperties(nodeRef, propsBefore, propsAfter);
|
||||||
|
}
|
||||||
|
|
||||||
reportContentCreated(nodeRef, contentUrl);
|
reportContentCreated(nodeRef, contentUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user