mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1862 (Reference to rejected record is remaining)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.3@97058 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -49,4 +49,8 @@ public interface RecordsManagementCustomModel
|
||||
// Some Custom references which are present on system startup.
|
||||
QName CUSTOM_REF_VERSIONS = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "versions");
|
||||
QName CUSTOM_REF_SUPERSEDES = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "supersedes");
|
||||
QName CUSTOM_REF_OBSOLETES = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "obsoletes");
|
||||
QName CUSTOM_REF_SUPPORTS = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "supports");
|
||||
QName CUSTOM_REF_CROSSREFERENCE = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "crossreference");
|
||||
QName CUSTOM_REF_RENDITION = QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "rendition");
|
||||
}
|
||||
|
@@ -25,7 +25,6 @@ import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.AbstractDisposableItem;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
||||
@@ -69,7 +68,7 @@ public class RecordAspect extends AbstractDisposableItem
|
||||
|
||||
/** script service */
|
||||
protected ScriptService scriptService;
|
||||
|
||||
|
||||
/** record service */
|
||||
protected RecordService recordService;
|
||||
|
||||
@@ -88,7 +87,7 @@ public class RecordAspect extends AbstractDisposableItem
|
||||
{
|
||||
this.scriptService = scriptService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param recordService record service
|
||||
*/
|
||||
@@ -150,7 +149,7 @@ public class RecordAspect extends AbstractDisposableItem
|
||||
public void onCreateReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference)
|
||||
{
|
||||
// Deal with versioned records
|
||||
if (reference.equals(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "versions")))
|
||||
if (reference.equals(CUSTOM_REF_VERSIONS))
|
||||
{
|
||||
// Apply the versioned aspect to the from node
|
||||
nodeService.addAspect(fromNodeRef, ASPECT_VERSIONED_RECORD, null);
|
||||
@@ -172,7 +171,7 @@ public class RecordAspect extends AbstractDisposableItem
|
||||
public void onRemoveReference(NodeRef fromNodeRef, NodeRef toNodeRef, QName reference)
|
||||
{
|
||||
// Deal with versioned records
|
||||
if (reference.equals(QName.createQName(RecordsManagementCustomModel.RM_CUSTOM_URI, "versions")))
|
||||
if (reference.equals(CUSTOM_REF_VERSIONS))
|
||||
{
|
||||
// Apply the versioned aspect to the from node
|
||||
nodeService.removeAspect(fromNodeRef, ASPECT_VERSIONED_RECORD);
|
||||
@@ -236,7 +235,7 @@ public class RecordAspect extends AbstractDisposableItem
|
||||
{
|
||||
public Object doWork()
|
||||
{
|
||||
if (nodeService.exists(record) &&
|
||||
if (nodeService.exists(record) &&
|
||||
recordService.isFiled(record))
|
||||
{
|
||||
// clean record
|
||||
|
@@ -217,10 +217,10 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
|
||||
/** Version service */
|
||||
private VersionService versionService;
|
||||
|
||||
|
||||
/** Relationship service */
|
||||
private RelationshipService relationshipService;
|
||||
|
||||
|
||||
/** records management container type */
|
||||
private RecordsManagementContainerType recordsManagementContainerType;
|
||||
|
||||
@@ -352,7 +352,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
{
|
||||
this.versionService = versionService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param relationshipService relationship service
|
||||
*/
|
||||
@@ -360,8 +360,8 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
{
|
||||
this.relationshipService = relationshipService;
|
||||
}
|
||||
|
||||
public void setRecordsManagementContainerType(RecordsManagementContainerType recordsManagementContainerType)
|
||||
|
||||
public void setRecordsManagementContainerType(RecordsManagementContainerType recordsManagementContainerType)
|
||||
{
|
||||
this.recordsManagementContainerType = recordsManagementContainerType;
|
||||
}
|
||||
@@ -862,7 +862,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
|
||||
// get the latest version record, if there is one
|
||||
NodeRef latestVersionRecord = getLatestVersionRecord(nodeRef);
|
||||
|
||||
|
||||
behaviourFilter.disableBehaviour();
|
||||
try
|
||||
{
|
||||
@@ -880,10 +880,10 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
aspectProperties.put(PROP_RECORD_ORIGINATING_USER_ID, owner);
|
||||
aspectProperties.put(PROP_RECORD_ORIGINATING_CREATION_DATE, new Date());
|
||||
nodeService.addAspect(nodeRef, ASPECT_RECORD_ORIGINATING_DETAILS, aspectProperties);
|
||||
|
||||
|
||||
// make the document a record
|
||||
makeRecord(nodeRef);
|
||||
|
||||
|
||||
if (latestVersionRecord != null)
|
||||
{
|
||||
// indicate that this is the 'final' record version
|
||||
@@ -891,9 +891,9 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
versionRecordProps.put(RecordableVersionModel.PROP_VERSION_LABEL, I18NUtil.getMessage(FINAL_VERSION));
|
||||
versionRecordProps.put(RecordableVersionModel.PROP_VERSION_DESCRIPTION, I18NUtil.getMessage(FINAL_DESCRIPTION));
|
||||
nodeService.addAspect(nodeRef, RecordableVersionModel.ASPECT_VERSION_RECORD, versionRecordProps);
|
||||
|
||||
|
||||
// link to previous version
|
||||
relationshipService.addRelationship("versions", nodeRef, latestVersionRecord);
|
||||
relationshipService.addRelationship(CUSTOM_REF_VERSIONS.getLocalName(), nodeRef, latestVersionRecord);
|
||||
}
|
||||
|
||||
if (isLinked)
|
||||
@@ -928,7 +928,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#createRecordFromCopy(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@@ -983,7 +983,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
{
|
||||
recordsManagementContainerType.enable();
|
||||
}
|
||||
|
||||
|
||||
// make record
|
||||
makeRecord(record);
|
||||
|
||||
@@ -1022,17 +1022,17 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper to get the latest version record for a given document (ie non-record)
|
||||
*
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return NodeRef latest version record, null otherwise
|
||||
*/
|
||||
private NodeRef getLatestVersionRecord(NodeRef nodeRef)
|
||||
{
|
||||
NodeRef versionRecord = null;
|
||||
|
||||
|
||||
// wire record up to previous record
|
||||
VersionHistory versionHistory = versionService.getVersionHistory(nodeRef);
|
||||
if (versionHistory != null)
|
||||
@@ -1048,9 +1048,9 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return versionRecord;
|
||||
}
|
||||
|
||||
return versionRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1105,10 +1105,10 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
writer.setMimetype(reader.getMimetype());
|
||||
writer.putContent(reader);
|
||||
}
|
||||
|
||||
|
||||
result = authenticationUtil.runAsSystem(new RunAsWork<NodeRef>()
|
||||
{
|
||||
public NodeRef doWork() throws Exception
|
||||
public NodeRef doWork() throws Exception
|
||||
{
|
||||
// Check if the "record" aspect has been applied already.
|
||||
// In case of filing a report the created node will be made
|
||||
@@ -1119,10 +1119,10 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
// make record
|
||||
makeRecord(record);
|
||||
}
|
||||
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
finally
|
||||
@@ -1280,6 +1280,14 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
ruleService.disableRules();
|
||||
try
|
||||
{
|
||||
// get the latest version record, if there is one
|
||||
NodeRef latestVersionRecord = getLatestVersionRecord(nodeRef);
|
||||
|
||||
if (latestVersionRecord != null)
|
||||
{
|
||||
relationshipService.removeRelationship(CUSTOM_REF_VERSIONS.getLocalName(), nodeRef, latestVersionRecord);
|
||||
}
|
||||
|
||||
// get record property values
|
||||
final Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
|
||||
final String recordId = (String)properties.get(PROP_IDENTIFIER);
|
||||
@@ -1690,24 +1698,24 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
throw new AlfrescoRuntimeException("Can not link a record to the same record folder more than once");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// get the current name of the record
|
||||
String name = nodeService.getProperty(record, ContentModel.PROP_NAME).toString();
|
||||
|
||||
|
||||
// create a secondary link to the record folder
|
||||
nodeService.addChild(
|
||||
recordFolder,
|
||||
record,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
recordFolder,
|
||||
record,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name));
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// can only link a record to a record folder
|
||||
throw new AlfrescoRuntimeException("Can only link a record to a record folder.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.record.RecordService#unlink(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@@ -1726,11 +1734,11 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Can't unlink a record from it's owning record folder.");
|
||||
}
|
||||
|
||||
|
||||
// remove the link
|
||||
nodeService.removeChild(recordFolder, record);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
// can only unlink a record from a record folder
|
||||
throw new AlfrescoRuntimeException("Can only unlink a record from a record folder.");
|
||||
|
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.version;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementCustomModel.CUSTOM_REF_VERSIONS;
|
||||
import static org.codehaus.plexus.util.StringUtils.isNotBlank;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -406,7 +407,7 @@ public class RecordableVersionServiceImpl extends Version2ServiceImpl
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// indicate that the new record versions the previous record
|
||||
relationshipService.addRelationship("versions", record, latestRecordVersion);
|
||||
relationshipService.addRelationship(CUSTOM_REF_VERSIONS.getLocalName(), record, latestRecordVersion);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
@@ -54,7 +54,7 @@ public class RM1814Test extends BaseRMTestCase
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
relationshipService.addRelationship("versions", recordOne, recordThree);
|
||||
relationshipService.addRelationship(CUSTOM_REF_VERSIONS.getLocalName(), recordOne, recordThree);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@@ -67,7 +67,7 @@ public class RM1814Test extends BaseRMTestCase
|
||||
@Override
|
||||
public void run() throws Exception
|
||||
{
|
||||
relationshipService.addRelationship("obsoletes", recordOne, recordTwo);
|
||||
relationshipService.addRelationship(CUSTOM_REF_OBSOLETES.getLocalName(), recordOne, recordTwo);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -76,7 +76,7 @@ public class RM1814Test extends BaseRMTestCase
|
||||
@Override
|
||||
public Void run()
|
||||
{
|
||||
relationshipService.addRelationship("supports", recordOne, recordFour);
|
||||
relationshipService.addRelationship(CUSTOM_REF_SUPPORTS.getLocalName(), recordOne, recordFour);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
@@ -18,15 +18,34 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.record;
|
||||
|
||||
import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel.PROP_FILE_PLAN;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel.PROP_RECORDABLE_VERSION_POLICY;
|
||||
import static org.alfresco.service.cmr.version.VersionType.MINOR;
|
||||
import static org.springframework.extensions.webscripts.GUID.generate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionPolicy;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.version.VersionModel;
|
||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.version.Version;
|
||||
import org.alfresco.service.cmr.version.VersionHistory;
|
||||
import org.alfresco.service.cmr.version.VersionService;
|
||||
import org.alfresco.util.PropertyMap;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
import org.springframework.extensions.webscripts.GUID;
|
||||
|
||||
/**
|
||||
@@ -38,8 +57,10 @@ import org.springframework.extensions.webscripts.GUID;
|
||||
public class RejectRecordTest extends BaseRMTestCase
|
||||
{
|
||||
private VersionService versionService;
|
||||
private CheckOutCheckInService checkOutCheckInService;
|
||||
|
||||
private static final String REASON = GUID.generate();
|
||||
private static final String FINAL_VERSION = "rm.service.final-version";
|
||||
|
||||
@Override
|
||||
protected boolean isUserTest()
|
||||
@@ -58,7 +79,8 @@ public class RejectRecordTest extends BaseRMTestCase
|
||||
{
|
||||
super.initServices();
|
||||
|
||||
versionService = (VersionService)applicationContext.getBean("VersionService");
|
||||
versionService = (VersionService) applicationContext.getBean("VersionService");
|
||||
checkOutCheckInService = (CheckOutCheckInService) applicationContext.getBean("CheckOutCheckInService");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,7 +113,7 @@ public class RejectRecordTest extends BaseRMTestCase
|
||||
assertTrue(recordService.isRecord(dmDocument));
|
||||
assertTrue(permissionService.getInheritParentPermissions(dmDocument));
|
||||
|
||||
// declare record
|
||||
// reject record
|
||||
recordService.rejectRecord(dmDocument, REASON);
|
||||
}
|
||||
|
||||
@@ -114,7 +136,7 @@ public class RejectRecordTest extends BaseRMTestCase
|
||||
public void testRevertAfterReject() throws Exception
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{;
|
||||
{
|
||||
private NodeRef document;
|
||||
|
||||
public void given()
|
||||
@@ -189,4 +211,83 @@ public class RejectRecordTest extends BaseRMTestCase
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testRelationshipAfterRevertingRecord()
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
// Test document
|
||||
private NodeRef document;
|
||||
|
||||
public void given()
|
||||
{
|
||||
// Create a test document
|
||||
NodeRef folder = fileFolderService.create(documentLibrary, generate(), TYPE_FOLDER).getNodeRef();
|
||||
document = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
|
||||
|
||||
// Set Auto-Declare Versions to "For all major and minor versions"
|
||||
PropertyMap recordableVersionProperties = new PropertyMap(2);
|
||||
recordableVersionProperties.put(PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL);
|
||||
recordableVersionProperties.put(PROP_FILE_PLAN, filePlan);
|
||||
nodeService.addAspect(document, ASPECT_VERSIONABLE, recordableVersionProperties);
|
||||
|
||||
// Upload New Version
|
||||
document = checkOutCheckInService.checkout(document);
|
||||
Map<String, Serializable> props = new HashMap<String, Serializable>(2);
|
||||
props.put(Version.PROP_DESCRIPTION, generate());
|
||||
props.put(VersionModel.PROP_VERSION_TYPE, MINOR);
|
||||
document = checkOutCheckInService.checkin(document, props);
|
||||
|
||||
// Check the declared version
|
||||
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(unfiledContainer);
|
||||
assertEquals(1, childAssocs.size());
|
||||
|
||||
// Declare document as record
|
||||
recordService.createRecord(filePlan, document);
|
||||
|
||||
// Check the declared versions
|
||||
childAssocs = nodeService.getChildAssocs(unfiledContainer);
|
||||
assertEquals(2, childAssocs.size());
|
||||
|
||||
// Check that the document is a file plan component
|
||||
assertTrue(nodeService.hasAspect(document, ASPECT_FILE_PLAN_COMPONENT));
|
||||
|
||||
// Get the final version
|
||||
NodeRef finalVersion = null;
|
||||
for (ChildAssociationRef childAssociationRef : nodeService.getChildAssocs(unfiledContainer))
|
||||
{
|
||||
NodeRef childRef = childAssociationRef.getChildRef();
|
||||
String label = (String) nodeService.getProperty(document, RecordableVersionModel.PROP_VERSION_LABEL);
|
||||
|
||||
if (label.equals(I18NUtil.getMessage(FINAL_VERSION)))
|
||||
{
|
||||
finalVersion = childRef;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// The final version should be the declared record
|
||||
assertEquals(document, finalVersion);
|
||||
|
||||
// Check the relationship
|
||||
Set<Relationship> relationships = relationshipService.getRelationshipsFrom(document);
|
||||
assertEquals(1, relationships.size());
|
||||
Relationship relationship = relationships.iterator().next();
|
||||
assertEquals(CUSTOM_REF_VERSIONS.getLocalName(), relationship.getUniqueName());
|
||||
}
|
||||
|
||||
public void when()
|
||||
{
|
||||
// Reject record
|
||||
recordService.rejectRecord(document, generate());
|
||||
}
|
||||
|
||||
public void then()
|
||||
{
|
||||
// Check the relationship
|
||||
Set<Relationship> relationships = relationshipService.getRelationshipsFrom(document);
|
||||
assertEquals(0, relationships.size());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -27,12 +27,12 @@ import org.alfresco.util.GUID;
|
||||
|
||||
/**
|
||||
* Delete relationship test.
|
||||
*
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
* @since 2.3
|
||||
*/
|
||||
public class DeleteRelationshipTest extends BaseRMTestCase
|
||||
{
|
||||
{
|
||||
public void testDeleteRelationship() throws Exception
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
@@ -40,27 +40,27 @@ public class DeleteRelationshipTest extends BaseRMTestCase
|
||||
/** test data */
|
||||
NodeRef sourceNode;
|
||||
NodeRef targetNode;
|
||||
String associationName = "obsoletes";
|
||||
|
||||
String associationName = CUSTOM_REF_OBSOLETES.getLocalName();
|
||||
|
||||
public void given()
|
||||
{
|
||||
|
||||
|
||||
// create the source record
|
||||
sourceNode = utils.createRecord(rmFolder, GUID.generate());
|
||||
|
||||
|
||||
//create the target record
|
||||
targetNode = utils.createRecord(rmFolder, GUID.generate());
|
||||
|
||||
|
||||
//create relationship
|
||||
relationshipService.addRelationship(associationName, sourceNode, targetNode);
|
||||
}
|
||||
|
||||
|
||||
public void when()
|
||||
{
|
||||
//delete relationship
|
||||
//delete relationship
|
||||
relationshipService.removeRelationship(associationName, sourceNode, targetNode);
|
||||
}
|
||||
|
||||
|
||||
public void then()
|
||||
{
|
||||
//check if relationship is deleted
|
||||
@@ -70,8 +70,8 @@ public class DeleteRelationshipTest extends BaseRMTestCase
|
||||
assertFalse(r.getTarget().equals(targetNode) && r.getUniqueName().equals(associationName));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -32,15 +32,15 @@ import org.alfresco.util.PropertyMap;
|
||||
|
||||
/**
|
||||
* Auto Recordable Versions Integration Test
|
||||
*
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.3
|
||||
*/
|
||||
public class AutoRecordableVersions extends RecordableVersionsBaseTest
|
||||
public class AutoRecordableVersions extends RecordableVersionsBaseTest
|
||||
{
|
||||
/** example content */
|
||||
public final static String MY_NEW_CONTENT = "this is some new content that I have changed to trigger auto version";
|
||||
|
||||
|
||||
/**
|
||||
* Given that all revisions will be recorded,
|
||||
* When I update the content of a document,
|
||||
@@ -51,34 +51,34 @@ public class AutoRecordableVersions extends RecordableVersionsBaseTest
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest(dmCollaborator)
|
||||
{
|
||||
public void given() throws Exception
|
||||
{
|
||||
{
|
||||
// set the recordable version policy
|
||||
PropertyMap recordableVersionProperties = new PropertyMap(1);
|
||||
recordableVersionProperties.put(PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL);
|
||||
recordableVersionProperties.put(PROP_FILE_PLAN, filePlan);
|
||||
nodeService.addAspect(dmDocument, RecordableVersionModel.ASPECT_VERSIONABLE, recordableVersionProperties);
|
||||
|
||||
nodeService.addAspect(dmDocument, RecordableVersionModel.ASPECT_VERSIONABLE, recordableVersionProperties);
|
||||
|
||||
// make the node versionable
|
||||
PropertyMap versionableProperties = new PropertyMap(1);
|
||||
versionableProperties.put(ContentModel.PROP_INITIAL_VERSION, false);
|
||||
nodeService.addAspect(dmDocument, ContentModel.ASPECT_VERSIONABLE, versionableProperties);
|
||||
nodeService.addAspect(dmDocument, ContentModel.ASPECT_VERSIONABLE, versionableProperties);
|
||||
}
|
||||
|
||||
|
||||
public void when()
|
||||
{
|
||||
{
|
||||
// generate new version by updating content
|
||||
ContentWriter writer = contentService.getWriter(dmDocument, ContentModel.PROP_CONTENT, true);
|
||||
writer.putContent(MY_NEW_CONTENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void then()
|
||||
{
|
||||
// check that the record has been recorded
|
||||
checkRecordedVersion(dmDocument, null, "0.1");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Given that all revisions will be automatically recorded,
|
||||
* When I update a document 3 times,
|
||||
@@ -90,18 +90,18 @@ public class AutoRecordableVersions extends RecordableVersionsBaseTest
|
||||
{
|
||||
/** given **/
|
||||
public void given() throws Exception
|
||||
{
|
||||
{
|
||||
doTestInTransaction(new VoidTest()
|
||||
{
|
||||
@Override
|
||||
public void runImpl() throws Exception
|
||||
{
|
||||
{
|
||||
// set the recordable version policy
|
||||
PropertyMap recordableVersionProperties = new PropertyMap(1);
|
||||
recordableVersionProperties.put(PROP_RECORDABLE_VERSION_POLICY, RecordableVersionPolicy.ALL);
|
||||
recordableVersionProperties.put(PROP_FILE_PLAN, filePlan);
|
||||
nodeService.addAspect(dmDocument, RecordableVersionModel.ASPECT_VERSIONABLE, recordableVersionProperties);
|
||||
|
||||
nodeService.addAspect(dmDocument, RecordableVersionModel.ASPECT_VERSIONABLE, recordableVersionProperties);
|
||||
|
||||
// make the node versionable
|
||||
PropertyMap versionableProperties = new PropertyMap(1);
|
||||
versionableProperties.put(ContentModel.PROP_INITIAL_VERSION, false);
|
||||
@@ -109,16 +109,16 @@ public class AutoRecordableVersions extends RecordableVersionsBaseTest
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/** when **/
|
||||
public void when()
|
||||
{
|
||||
{
|
||||
// update the content 3 times
|
||||
updateContent();
|
||||
updateContent();
|
||||
updateContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** then */
|
||||
public void then()
|
||||
{
|
||||
@@ -129,17 +129,17 @@ public class AutoRecordableVersions extends RecordableVersionsBaseTest
|
||||
{
|
||||
// check that the record has been recorded
|
||||
checkRecordedVersion(dmDocument, null, "0.3");
|
||||
|
||||
Version version = versionService.getCurrentVersion(dmDocument);
|
||||
|
||||
Version version = versionService.getCurrentVersion(dmDocument);
|
||||
NodeRef record = (NodeRef)version.getVersionProperties().get(RecordableVersionServiceImpl.PROP_VERSION_RECORD);
|
||||
|
||||
|
||||
boolean foundPrevious = false;
|
||||
Set<Relationship> relationships = relationshipService.getRelationshipsFrom(record);
|
||||
assertNotNull(relationships);
|
||||
assertEquals(1, relationships.size());
|
||||
for (Relationship relationship : relationships)
|
||||
{
|
||||
if (relationship.getUniqueName().equals("versions"))
|
||||
if (relationship.getUniqueName().equals(CUSTOM_REF_VERSIONS.getLocalName()))
|
||||
{
|
||||
NodeRef previousVersionRecord = relationship.getTarget();
|
||||
assertNotNull(previousVersionRecord);
|
||||
@@ -150,9 +150,9 @@ public class AutoRecordableVersions extends RecordableVersionsBaseTest
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to update content of dmDocument
|
||||
* Helper method to update content of dmDocument
|
||||
*/
|
||||
private void updateContent()
|
||||
{
|
||||
@@ -165,7 +165,7 @@ public class AutoRecordableVersions extends RecordableVersionsBaseTest
|
||||
writer.putContent(MY_NEW_CONTENT);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -431,7 +431,7 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan
|
||||
// GET a specific custom reference definition.
|
||||
// Here, we're using one of the built-in references
|
||||
// qname = rmc:versions
|
||||
rsp = sendRequest(new GetRequest(RMA_CUSTOM_REFS_DEFINITIONS_URL + "/" + "versions"), expectedStatus);
|
||||
rsp = sendRequest(new GetRequest(RMA_CUSTOM_REFS_DEFINITIONS_URL + "/" + CUSTOM_REF_VERSIONS.getLocalName()), expectedStatus);
|
||||
|
||||
jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString()));
|
||||
|
||||
@@ -597,7 +597,7 @@ public class RmRestApiTest extends BaseRMWebScriptTestCase implements RecordsMan
|
||||
}
|
||||
|
||||
// Add a supersedes ref instance between them
|
||||
final String supersedesRefLocalName = "supersedes";
|
||||
final String supersedesRefLocalName = CUSTOM_REF_SUPERSEDES.getLocalName();
|
||||
String jsonString = new JSONStringer().object()
|
||||
.key("toNode").value(testRecord2.toString())
|
||||
.key("refId").value(supersedesRefLocalName)
|
||||
|
Reference in New Issue
Block a user