mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged 5.0.N (5.0.4) to 5.1.N (5.1.1)
120075 rmunteanu: Merged V4.2-BUG-FIX (4.2.6) to 5.0.N (5.0.4) 120039 amukha: Merged V4.2-BUG-FIX-MNT-14688 (4.2.6) to V4.2-BUG-FIX (4.2.6) 120019 amukha: MNT-14688: version revert on first version failure if type has aspect - Restoring a version now restores the node's type. - Added JUnit test. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@120108 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1056,16 +1056,24 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
|
|||||||
Map<QName, Serializable> newProps = this.nodeService.getProperties(versionNodeRef);
|
Map<QName, Serializable> newProps = this.nodeService.getProperties(versionNodeRef);
|
||||||
VersionUtil.convertFrozenToOriginalProps(newProps);
|
VersionUtil.convertFrozenToOriginalProps(newProps);
|
||||||
Set<QName> newAspectQNames = this.nodeService.getAspects(versionNodeRef);
|
Set<QName> newAspectQNames = this.nodeService.getAspects(versionNodeRef);
|
||||||
|
QName newNodeTypeQName = nodeService.getType(versionNodeRef);
|
||||||
|
|
||||||
// RevertDetails - given to policy behaviours
|
// RevertDetails - given to policy behaviours
|
||||||
VersionRevertDetailsImpl revertDetails = new VersionRevertDetailsImpl();
|
VersionRevertDetailsImpl revertDetails = new VersionRevertDetailsImpl();
|
||||||
revertDetails.setNodeRef(nodeRef);
|
revertDetails.setNodeRef(nodeRef);
|
||||||
revertDetails.setNodeType(oldNodeTypeQName);
|
revertDetails.setNodeType(newNodeTypeQName);
|
||||||
|
|
||||||
// Do we want to maintain any existing property values?
|
// Do we want to maintain any existing property values?
|
||||||
Collection<QName> propsToLeaveAlone = new ArrayList<QName>();
|
Collection<QName> propsToLeaveAlone = new ArrayList<QName>();
|
||||||
Collection<QName> assocsToLeaveAlone = new ArrayList<QName>();
|
Collection<QName> assocsToLeaveAlone = new ArrayList<QName>();
|
||||||
|
|
||||||
|
// The VersionRevertCallback was added in r50122 on HEAD-QA branch in ACE-1001
|
||||||
|
// If it is required to preserve this callback when the type is changed,
|
||||||
|
// this part should be reimplemented.
|
||||||
|
// see MNT-14688
|
||||||
|
if (newNodeTypeQName.equals(oldNodeTypeQName))
|
||||||
|
{
|
||||||
|
// The node did not change the type, check the associations
|
||||||
TypeDefinition typeDef = dictionaryService.getType(oldNodeTypeQName);
|
TypeDefinition typeDef = dictionaryService.getType(oldNodeTypeQName);
|
||||||
if(typeDef != null)
|
if(typeDef != null)
|
||||||
{
|
{
|
||||||
@@ -1077,6 +1085,7 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (QName aspect : oldAspectQNames)
|
for (QName aspect : oldAspectQNames)
|
||||||
{
|
{
|
||||||
@@ -1110,6 +1119,9 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
|
|||||||
//Restore forum properties
|
//Restore forum properties
|
||||||
this.nodeService.addProperties(nodeRef, forumProps);
|
this.nodeService.addProperties(nodeRef, forumProps);
|
||||||
|
|
||||||
|
// Restore the type
|
||||||
|
this.nodeService.setType(nodeRef, newNodeTypeQName);
|
||||||
|
|
||||||
Set<QName> aspectsToRemove = new HashSet<QName>(oldAspectQNames);
|
Set<QName> aspectsToRemove = new HashSet<QName>(oldAspectQNames);
|
||||||
aspectsToRemove.removeAll(newAspectQNames);
|
aspectsToRemove.removeAll(newAspectQNames);
|
||||||
|
|
||||||
|
@@ -96,6 +96,8 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest
|
|||||||
*/
|
*/
|
||||||
protected static final String TEST_NAMESPACE = "http://www.alfresco.org/test/versionstorebasetest/1.0";
|
protected static final String TEST_NAMESPACE = "http://www.alfresco.org/test/versionstorebasetest/1.0";
|
||||||
protected static final QName TEST_TYPE_QNAME = QName.createQName(TEST_NAMESPACE, "testtype");
|
protected static final QName TEST_TYPE_QNAME = QName.createQName(TEST_NAMESPACE, "testtype");
|
||||||
|
protected static final QName TEST_TYPE_WITH_MANDATORY_ASPECT_QNAME = QName.createQName(TEST_NAMESPACE, "contentWithMandatoryAspect");
|
||||||
|
protected static final QName TEST_MANDATORY_ASPECT_QNAME = QName.createQName(TEST_NAMESPACE, "mandatoryAspect");
|
||||||
protected static final QName TEST_ASPECT_QNAME = QName.createQName(TEST_NAMESPACE, "testaspect");
|
protected static final QName TEST_ASPECT_QNAME = QName.createQName(TEST_NAMESPACE, "testaspect");
|
||||||
protected static final QName PROP_1 = QName.createQName(TEST_NAMESPACE, "prop1");
|
protected static final QName PROP_1 = QName.createQName(TEST_NAMESPACE, "prop1");
|
||||||
protected static final QName PROP_2 = QName.createQName(TEST_NAMESPACE, "prop2");
|
protected static final QName PROP_2 = QName.createQName(TEST_NAMESPACE, "prop2");
|
||||||
|
@@ -1005,6 +1005,59 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test reverting from Share with changing type
|
||||||
|
* see MNT-14688
|
||||||
|
* <li>
|
||||||
|
* <ul>1) Create a node and a version (simulates upload a doc to Share)</ul>
|
||||||
|
* <ul>2) Change the node's type to a custom with mandatory aspect</ul>
|
||||||
|
* <ul>3) Create a new version via upload</ul>
|
||||||
|
* <ul>4) Try to revert to original document and see if the type is reverted, too</ul>
|
||||||
|
* </li>
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public void testScriptNodeRevertWithChangeType()
|
||||||
|
{
|
||||||
|
CheckOutCheckInService checkOutCheckInService =
|
||||||
|
(CheckOutCheckInService) applicationContext.getBean("checkOutCheckInService");
|
||||||
|
|
||||||
|
// Create a versionable node
|
||||||
|
NodeRef versionableNode = createNewVersionableNode();
|
||||||
|
Version version1 = createVersion(versionableNode);
|
||||||
|
//Set new type
|
||||||
|
nodeService.setType(versionableNode, TEST_TYPE_WITH_MANDATORY_ASPECT_QNAME);
|
||||||
|
// Create a new version
|
||||||
|
NodeRef checkedOut = checkOutCheckInService.checkout(versionableNode);
|
||||||
|
ContentWriter contentWriter = this.contentService.getWriter(checkedOut, ContentModel.PROP_CONTENT, true);
|
||||||
|
assertNotNull(contentWriter);
|
||||||
|
contentWriter.putContent(UPDATED_CONTENT_1);
|
||||||
|
nodeService.setProperty(checkedOut, PROP_1, VALUE_1);
|
||||||
|
checkOutCheckInService.checkin(checkedOut, null, contentWriter.getContentUrl(), false);
|
||||||
|
Version version2 = createVersion(versionableNode);
|
||||||
|
|
||||||
|
// Create a ScriptNode as used in Share
|
||||||
|
ServiceRegistry services = applicationContext.getBean(ServiceRegistry.class);
|
||||||
|
ScriptNode scriptNode = new ScriptNode(versionableNode, services);
|
||||||
|
assertEquals("0.2", nodeService.getProperty(scriptNode.getNodeRef(), ContentModel.PROP_VERSION_LABEL));
|
||||||
|
assertEquals(TEST_TYPE_WITH_MANDATORY_ASPECT_QNAME, nodeService.getType(scriptNode.getNodeRef()));
|
||||||
|
|
||||||
|
// Revert to version1
|
||||||
|
ScriptNode newNode = scriptNode.revert("History", false, version1.getVersionLabel());
|
||||||
|
assertEquals("0.3", nodeService.getProperty(newNode.getNodeRef(), ContentModel.PROP_VERSION_LABEL));
|
||||||
|
assertEquals(TEST_TYPE_QNAME, nodeService.getType(newNode.getNodeRef()));
|
||||||
|
|
||||||
|
// All done
|
||||||
|
setComplete();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
endTransaction();
|
||||||
|
}
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
fail("Transaction failed: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test restore
|
* Test restore
|
||||||
*/
|
*/
|
||||||
|
@@ -126,6 +126,17 @@
|
|||||||
</associations>
|
</associations>
|
||||||
</type>
|
</type>
|
||||||
|
|
||||||
|
<type name="test:contentWithMandatoryAspect">
|
||||||
|
<title>Custom content type</title>
|
||||||
|
<description>Custom content type basic parent content</description>
|
||||||
|
<parent>cm:content</parent>
|
||||||
|
<properties />
|
||||||
|
<associations />
|
||||||
|
<mandatory-aspects>
|
||||||
|
<aspect>test:mandatoryAspect</aspect>
|
||||||
|
</mandatory-aspects>
|
||||||
|
</type>
|
||||||
|
|
||||||
</types>
|
</types>
|
||||||
|
|
||||||
<aspects>
|
<aspects>
|
||||||
@@ -149,6 +160,19 @@
|
|||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
</aspect>
|
</aspect>
|
||||||
|
|
||||||
|
<aspect name="test:mandatoryAspect">
|
||||||
|
<title>Custom Aspect</title>
|
||||||
|
<description>Just basic text aspect</description>
|
||||||
|
<properties>
|
||||||
|
<property name="test:mandatoryAspectText">
|
||||||
|
<title>aspect text</title>
|
||||||
|
<description>Text for aspect content</description>
|
||||||
|
<type>d:text</type>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
</aspect>
|
||||||
|
|
||||||
</aspects>
|
</aspects>
|
||||||
|
|
||||||
</model>
|
</model>
|
||||||
|
Reference in New Issue
Block a user