mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-30 18:15:39 +00:00
21384: ALF-2879: XAM Connector changes - Added callbacks for code to modify the XSet fields - Changed XAMArchivedAspect to use callback (moved code out of XAMContentStore) - Added XAMNodePropertyWriter to set metadata including some global properties and node-specific values - See readme.txt for details 21393: ALF-2879: XAM Connector changes - Sprinkled DEBUG logging around - Updated readme.txt with logging details - Metadata writing tested and no changes required 21403: ALF-2879: XAM Connector changes - Workaround ContentStoreSelector bug present in V3.3.2 - NodeRef context not present during write - Added bug back into ContentStoreSelector for testing and verified that metadata is written to XSet 21487: Merged V3.3 to V3.3-BUG-FIX 21374: ALF-4028: In "createNode", save the ScriptNode before calling cmis.applyVersioningState to ensure updated properties have been saved. 21389: Add main to run index check against current repository by hand 21390: ALF-4016: Files uploaded to ts are not visible - multi-threaded tracking never abandons an index chunk - warns of long running transaction chunks - logging change 21392: ALF-4016: Files uploaded to ts are not visible - make sure FTS update exceptions can not lead to a TX commit and deletions 21428: NFS fixes to return the current file size in the post op attributes if the file is open, fixes to rename to close the current file if open before the rename, also delete the target file for a rename if it exists as per NFS v3 spec. ALF-3181, ALF-3954, ALF-3955, ALF-3956, ALF-3957. 21443: Merged PATCHES/V3.2.1 to V3.3 21396: ALF-3779, ALF-4025: Corrected driving column in alf_node_status --FOREACH statement to handle null node_ids and added --FOREACH for building of t_summary_nstat 21455: Remove old language pack pieces 21458: Fix linux install for some distros (ALF-4000) 21467: Merged DEV/TEMPORARY to V3.3 21444: ALF-3962 : Message 'The current implementation of the version service does not support the creation of branches.' being thrown from Version2ServiceImpl 1. Change AbstractVersionServiceImpl.invokeCalculateVersionLabel to make SerialVersionLabelPolicy behaviour default rather than the versionNumber when calculating new version label. 2. Change Version2ServiceImpl to handle any existing corrupted version histories that are marked with version label "0" (see Version2ServiceImpl. checkForCorruptedVersions method). 3. Unit tests was updated. 21464: Reimplemented according to David's review. 1. Update logic of checkForCorruptedVersions method in Version2ServiceImpl. A reusable protected method (getAllVersions) was created containing the shared code. 2. Update unit test to include tests for the corrupt version fixing behaviour. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21488 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
261 lines
8.5 KiB
Java
261 lines
8.5 KiB
Java
/*
|
|
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
|
*
|
|
* This file is part of Alfresco
|
|
*
|
|
* Alfresco is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Alfresco is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package org.alfresco.repo.version.common;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.Collection;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
import org.alfresco.repo.policy.ClassPolicyDelegate;
|
|
import org.alfresco.repo.policy.PolicyComponent;
|
|
import org.alfresco.repo.policy.PolicyScope;
|
|
import org.alfresco.repo.version.VersionServicePolicies;
|
|
import org.alfresco.repo.version.VersionServicePolicies.AfterCreateVersionPolicy;
|
|
import org.alfresco.repo.version.VersionServicePolicies.BeforeCreateVersionPolicy;
|
|
import org.alfresco.repo.version.VersionServicePolicies.CalculateVersionLabelPolicy;
|
|
import org.alfresco.repo.version.VersionServicePolicies.OnCreateVersionPolicy;
|
|
import org.alfresco.repo.version.common.versionlabel.SerialVersionLabelPolicy;
|
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
|
import org.alfresco.service.cmr.repository.NodeRef;
|
|
import org.alfresco.service.cmr.repository.NodeService;
|
|
import org.alfresco.service.cmr.repository.StoreRef;
|
|
import org.alfresco.service.cmr.version.Version;
|
|
import org.alfresco.service.cmr.version.VersionServiceException;
|
|
import org.alfresco.service.namespace.QName;
|
|
|
|
/**
|
|
* Abstract version service implementation.
|
|
*
|
|
* @author Roy Wetherall
|
|
*/
|
|
public abstract class AbstractVersionServiceImpl
|
|
{
|
|
/**
|
|
* The common node service
|
|
*/
|
|
protected NodeService nodeService ;
|
|
|
|
/**
|
|
* Policy component
|
|
*/
|
|
protected PolicyComponent policyComponent;
|
|
|
|
/**
|
|
* The dictionary service
|
|
*/
|
|
protected DictionaryService dictionaryService;
|
|
|
|
/**
|
|
* Policy delegates
|
|
*/
|
|
private ClassPolicyDelegate<BeforeCreateVersionPolicy> beforeCreateVersionDelegate;
|
|
private ClassPolicyDelegate<AfterCreateVersionPolicy> afterCreateVersionDelegate;
|
|
private ClassPolicyDelegate<OnCreateVersionPolicy> onCreateVersionDelegate;
|
|
private ClassPolicyDelegate<CalculateVersionLabelPolicy> calculateVersionLabelDelegate;
|
|
|
|
/**
|
|
* Sets the general node service
|
|
*
|
|
* @param nodeService the node service
|
|
*/
|
|
public void setNodeService(NodeService nodeService)
|
|
{
|
|
this.nodeService = nodeService;
|
|
}
|
|
|
|
/**
|
|
* Sets the policy component
|
|
*
|
|
* @param policyComponent the policy component
|
|
*/
|
|
public void setPolicyComponent(PolicyComponent policyComponent)
|
|
{
|
|
this.policyComponent = policyComponent;
|
|
}
|
|
|
|
/**
|
|
* Sets the dictionary service
|
|
*
|
|
* @param dictionaryService the dictionary service
|
|
*/
|
|
public void setDictionaryService(DictionaryService dictionaryService)
|
|
{
|
|
this.dictionaryService = dictionaryService;
|
|
}
|
|
|
|
/**
|
|
* Initialise method
|
|
*/
|
|
public void initialise()
|
|
{
|
|
// Register the policies
|
|
this.beforeCreateVersionDelegate = this.policyComponent.registerClassPolicy(VersionServicePolicies.BeforeCreateVersionPolicy.class);
|
|
this.afterCreateVersionDelegate = this.policyComponent.registerClassPolicy(VersionServicePolicies.AfterCreateVersionPolicy.class);
|
|
this.onCreateVersionDelegate = this.policyComponent.registerClassPolicy(VersionServicePolicies.OnCreateVersionPolicy.class);
|
|
this.calculateVersionLabelDelegate = this.policyComponent.registerClassPolicy(VersionServicePolicies.CalculateVersionLabelPolicy.class);
|
|
}
|
|
|
|
/**
|
|
* Invokes the before create version policy behaviour
|
|
*
|
|
* @param nodeRef the node being versioned
|
|
*/
|
|
protected void invokeBeforeCreateVersion(NodeRef nodeRef)
|
|
{
|
|
// invoke for node type
|
|
QName nodeTypeQName = nodeService.getType(nodeRef);
|
|
this.beforeCreateVersionDelegate.get(nodeTypeQName).beforeCreateVersion(nodeRef);
|
|
// invoke for node aspects
|
|
Set<QName> nodeAspectQNames = nodeService.getAspects(nodeRef);
|
|
this.beforeCreateVersionDelegate.get(nodeAspectQNames).beforeCreateVersion(nodeRef);
|
|
}
|
|
|
|
/**
|
|
* Invoke the after create version policy bahaviour
|
|
*
|
|
* @param nodeRef the nodeRef versioned
|
|
* @param version the created version
|
|
*/
|
|
protected void invokeAfterCreateVersion(NodeRef nodeRef, Version version)
|
|
{
|
|
// invoke for node type
|
|
QName nodeTypeQName = nodeService.getType(nodeRef);
|
|
this.afterCreateVersionDelegate.get(nodeTypeQName).afterCreateVersion(nodeRef, version);
|
|
// invoke for node aspects
|
|
Set<QName> nodeAspectQNames = nodeService.getAspects(nodeRef);
|
|
this.afterCreateVersionDelegate.get(nodeAspectQNames).afterCreateVersion(nodeRef, version);
|
|
}
|
|
|
|
/**
|
|
* Invoke the on create version policy behaviour
|
|
*
|
|
*/
|
|
protected void invokeOnCreateVersion(
|
|
NodeRef nodeRef,
|
|
Map<String, Serializable> versionProperties,
|
|
PolicyScope nodeDetails)
|
|
{
|
|
// Sort out the policies for the node type
|
|
QName classRef = this.nodeService.getType(nodeRef);
|
|
invokeOnCreateVersion(classRef, nodeRef, versionProperties, nodeDetails);
|
|
|
|
// Sort out the policies for the aspects
|
|
Collection<QName> aspects = this.nodeService.getAspects(nodeRef);
|
|
for (QName aspect : aspects)
|
|
{
|
|
invokeOnCreateVersion(aspect, nodeRef, versionProperties, nodeDetails);
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Invokes the on create version policy behaviour for a given type
|
|
*
|
|
* @param classRef
|
|
* @param nodeDetails
|
|
* @param nodeRef
|
|
* @param versionProperties
|
|
*/
|
|
private void invokeOnCreateVersion(
|
|
QName classRef,
|
|
NodeRef nodeRef,
|
|
Map<String, Serializable> versionProperties,
|
|
PolicyScope nodeDetails)
|
|
{
|
|
Collection<OnCreateVersionPolicy> policies = this.onCreateVersionDelegate.getList(classRef);
|
|
if (policies.size() == 0)
|
|
{
|
|
// Call the default implementation
|
|
defaultOnCreateVersion(
|
|
classRef,
|
|
nodeRef,
|
|
versionProperties,
|
|
nodeDetails);
|
|
}
|
|
else
|
|
{
|
|
// Call the policy definitions
|
|
for (VersionServicePolicies.OnCreateVersionPolicy policy : policies)
|
|
{
|
|
policy.onCreateVersion(
|
|
classRef,
|
|
nodeRef,
|
|
versionProperties,
|
|
nodeDetails);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Default implementation of the on create version policy. Called if no behaviour is registered for the
|
|
* policy for the specified type.
|
|
*
|
|
* @param nodeRef
|
|
* @param versionProperties
|
|
* @param nodeDetails
|
|
*/
|
|
abstract protected void defaultOnCreateVersion(
|
|
QName classRef,
|
|
NodeRef nodeRef,
|
|
Map<String, Serializable> versionProperties,
|
|
PolicyScope nodeDetails);
|
|
|
|
/**
|
|
* Invoke the calculate version label policy behaviour
|
|
*
|
|
* @param classRef
|
|
* @param preceedingVersion
|
|
* @param versionNumber
|
|
* @param versionProperties
|
|
* @return
|
|
*/
|
|
protected String invokeCalculateVersionLabel(
|
|
QName classRef,
|
|
Version preceedingVersion,
|
|
int versionNumber,
|
|
Map<String, Serializable>versionProperties)
|
|
{
|
|
String versionLabel = null;
|
|
|
|
Collection<CalculateVersionLabelPolicy> behaviours = this.calculateVersionLabelDelegate.getList(classRef);
|
|
if (behaviours.size() == 0)
|
|
{
|
|
// Default the version label to the SerialVersionLabelPolicy
|
|
SerialVersionLabelPolicy defaultVersionLabelPolicy = new SerialVersionLabelPolicy();
|
|
versionLabel = defaultVersionLabelPolicy.calculateVersionLabel(classRef, preceedingVersion, versionNumber, versionProperties);
|
|
}
|
|
else if (behaviours.size() == 1)
|
|
{
|
|
// Call the policy behaviour
|
|
CalculateVersionLabelPolicy[] arr = behaviours.toArray(new CalculateVersionLabelPolicy[]{});
|
|
versionLabel = arr[0].calculateVersionLabel(classRef, preceedingVersion, versionNumber, versionProperties);
|
|
}
|
|
else
|
|
{
|
|
// Error since we can only deal with a single caculate version label policy
|
|
throw new VersionServiceException("More than one CalculateVersionLabelPolicy behaviour has been registered for the type " + classRef.toString());
|
|
}
|
|
|
|
return versionLabel;
|
|
}
|
|
|
|
abstract public StoreRef getVersionStoreReference();
|
|
}
|