Merged V3.3-BUG-FIX to HEAD

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
This commit is contained in:
Dave Ward
2010-07-29 13:10:48 +00:00
parent 73bdab1db9
commit 3feaed5d5a
9 changed files with 150 additions and 33 deletions

View File

@@ -37,6 +37,7 @@ import org.alfresco.repo.version.common.VersionHistoryImpl;
import org.alfresco.repo.version.common.VersionImpl;
import org.alfresco.repo.version.common.VersionUtil;
import org.alfresco.repo.version.common.VersionHistoryImpl.VersionComparatorAsc;
import org.alfresco.repo.version.common.versionlabel.SerialVersionLabelPolicy;
import org.alfresco.service.cmr.repository.AspectMissingException;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -50,6 +51,7 @@ import org.alfresco.service.cmr.version.VersionService;
import org.alfresco.service.cmr.version.VersionServiceException;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.VersionNumber;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.surf.util.ParameterCheck;
@@ -265,6 +267,10 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
}
else
{
// ALF-3962 fix
// check for corrupted version histories that are marked with version label "0"
checkForCorruptedVersions(versionHistoryRef, nodeRef);
// Since we have an existing version history we should be able to lookup
// the current version
currentVersionRef = getCurrentVersionNodeRef(versionHistoryRef, nodeRef);
@@ -684,6 +690,30 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
}
}
/**
* Gets all versions in version history
*
* @param versionHistoryRef the version history nodeRef
* @return list of all versions
*/
protected List<Version> getAllVersions(NodeRef versionHistoryRef)
{
List<ChildAssociationRef> versionsAssoc = this.dbNodeService.getChildAssocs(versionHistoryRef, Version2Model.CHILD_QNAME_VERSIONS, RegexQNamePattern.MATCH_ALL);
List<Version> versions = new ArrayList<Version>(versionsAssoc.size());
for (ChildAssociationRef versionAssoc : versionsAssoc)
{
String localName = versionAssoc.getQName().getLocalName();
if (localName.indexOf(Version2Model.CHILD_VERSIONS+"-") != -1) // TODO - could remove this belts-and-braces, should match correctly above !
{
versions.add(getVersion(versionAssoc.getChildRef()));
}
}
return versions;
}
/**
* Builds a version history object from the version history reference.
* <p>
@@ -703,18 +733,7 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
VersionHistory versionHistory = null;
List<ChildAssociationRef> versionsAssoc = this.dbNodeService.getChildAssocs(versionHistoryRef, Version2Model.CHILD_QNAME_VERSIONS, RegexQNamePattern.MATCH_ALL);
List<Version> versions = new ArrayList<Version>(versionsAssoc.size());
for (ChildAssociationRef versionAssoc : versionsAssoc)
{
String localName = versionAssoc.getQName().getLocalName();
if (localName.indexOf(Version2Model.CHILD_VERSIONS+"-") != -1) // TODO - could remove this belts-and-braces, should match correctly above !
{
versions.add(getVersion(versionAssoc.getChildRef()));
}
}
List<Version> versions = getAllVersions(versionHistoryRef);
Collections.sort(versions, versionComparatorAsc);
@@ -879,6 +898,63 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
return result;
}
/**
* Check if versions are marked with invalid version label, if true > apply default serial version label (e.g. "1.0", "1.1")
*
* @param versionHistory a version histore node reference
* @param nodeRef a node reference
*/
private void checkForCorruptedVersions(NodeRef versionHistory, NodeRef nodeRef)
{
// get the current version label in live store
String versionLabel = (String) this.nodeService.getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL);
if (versionLabel != null && versionLabel.equals("0"))
{
// need to correct version labels
List<Version> versions = getAllVersions(versionHistory);
// sort versions by node id
Collections.sort(versions, new Comparator<Version>()
{
public int compare(Version v1, Version v2)
{
int result = v1.getFrozenModifiedDate().compareTo(v2.getFrozenModifiedDate());
if (result == 0)
{
result = v1.getFrozenStateNodeRef().getId().compareTo(v2.getFrozenStateNodeRef().getId());
}
return result;
}
});
SerialVersionLabelPolicy serialVersionLabelPolicy = new SerialVersionLabelPolicy();
QName classRef = this.nodeService.getType(nodeRef);
Version preceedingVersion = null;
for (Version version : versions)
{
// re-calculate version label
versionLabel = serialVersionLabelPolicy.calculateVersionLabel(classRef, preceedingVersion, 0, version.getVersionProperties());
// update version with new version label
NodeRef versionNodeRef = new NodeRef(StoreRef.PROTOCOL_WORKSPACE, version.getFrozenStateNodeRef().getStoreRef().getIdentifier(), version.getFrozenStateNodeRef()
.getId());
this.dbNodeService.setProperty(versionNodeRef, Version2Model.PROP_QNAME_VERSION_LABEL, versionLabel);
version.getVersionProperties().put(VersionBaseModel.PROP_VERSION_LABEL, versionLabel);
// remember preceding version
preceedingVersion = version;
}
// update current version label in live store
this.nodeService.setProperty(nodeRef, ContentModel.PROP_VERSION_LABEL, versionLabel);
}
}
/**
* @see org.alfresco.cms.version.VersionService#revert(NodeRef)
*/