mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged V2.0 to HEAD
svn merge svn://svn.alfresco.com:3691/alfresco/BRANCHES/V2.0@5212 svn://svn.alfresco.com:3691/alfresco/BRANCHES/V2.0@5220 . - Installer updates (minor) - VersionService implementation git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5221 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package org.alfresco.repo.admin.patch.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.version.VersionModel;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.version.VersionService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
public class VersionHistoryPerformancePatch extends AbstractPatch
|
||||
{
|
||||
private static final String MSG_SUCCESS = "patch.versionHistoryPerformance.result";
|
||||
|
||||
private VersionService versionService;
|
||||
|
||||
public void setVersionService(VersionService versionService)
|
||||
{
|
||||
this.versionService = versionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
// Set the aspect on the root node of the version store
|
||||
StoreRef versionStoreRef = this.versionService.getVersionStoreReference();
|
||||
NodeRef rootNodeRef = this.nodeService.getRootNode(versionStoreRef);
|
||||
this.nodeService.addAspect(rootNodeRef, VersionModel.ASPECT_VERSION_STORE_ROOT, null);
|
||||
|
||||
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(rootNodeRef);
|
||||
int updateCount = 0;
|
||||
|
||||
for(ChildAssociationRef childAssocRef : assocs)
|
||||
{
|
||||
NodeRef nodeRef = childAssocRef.getChildRef();
|
||||
if (VersionModel.TYPE_QNAME_VERSION_HISTORY.equals(this.nodeService.getType(nodeRef)) == true)
|
||||
{
|
||||
// Get the id
|
||||
String versionedNodeId = (String)this.nodeService.getProperty(nodeRef, VersionModel.PROP_QNAME_VERSIONED_NODE_ID);
|
||||
|
||||
// Set the cm:name
|
||||
this.nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, versionedNodeId);
|
||||
|
||||
// Move the node
|
||||
this.nodeService.moveNode( nodeRef,
|
||||
rootNodeRef,
|
||||
VersionModel.CHILD_QNAME_VERSION_HISTORIES,
|
||||
QName.createQName(VersionModel.NAMESPACE_URI, versionedNodeId));
|
||||
|
||||
updateCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Build the result message
|
||||
return I18NUtil.getMessage(MSG_SUCCESS, updateCount);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user