Merge branch 'feature-3.0.1/RM-6788_ArchiveClassifyDeclareFix' into 'release/V3.0'

RM-6788 adding change to 3.0.1 branch

See merge request records-management/records-management!1133
This commit is contained in:
Ross Gale
2019-03-18 13:07:58 +00:00
4 changed files with 53 additions and 14 deletions

View File

@@ -32,6 +32,7 @@ import java.util.List;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
import org.alfresco.repo.node.integrity.IntegrityException;
import org.alfresco.repo.policy.BehaviourFilter;
@@ -142,4 +143,32 @@ public abstract class BaseBehaviourBean extends ServiceBaseImpl
//no match was found in sub-types of permitted types list
throw new IntegrityException(I18NUtil.getMessage(MULTIPLE_CHILDREN_TYPE_ERROR, childType), null);
}
/**
* Helper method to duplicate the bin file of a node and replace the contenturl property with the new reference
*
* @param nodeRef The node to update with a new copy of the bin file
*/
protected void duplicateContentFileIfRequired(NodeRef nodeRef)
{
//Adding fix for RM-6788 where too many duplicates are being made this is a workaround waiting on a full solution
if (!nodeService.hasAspect(nodeRef, ASPECT_ARCHIVED))
{
//disable versioning and auditing
behaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
behaviourFilter.disableBehaviour(ContentModel.ASPECT_VERSIONABLE);
try
{
//create a new content URL for the copy/original node
createNewContentURL(nodeRef);
}
finally
{
//enable versioning and auditing
behaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);
behaviourFilter.enableBehaviour(ContentModel.ASPECT_VERSIONABLE);
}
}
}
}

View File

@@ -285,4 +285,9 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
QName PROP_COUNT = QName.createQName(RM_URI, "count");
QName ASPECT_SAVED_SEARCH = QName.createQName(RM_URI, "savedSearch");
//Workaround for RM-6788
String GL_URI = "http://www.alfresco.org/model/glacier/1.0";
QName ASPECT_ARCHIVED = QName.createQName(GL_URI, "archived");
}

View File

@@ -401,20 +401,7 @@ public class RecordAspect extends AbstractDisposableItem
if (!nodeService.getTargetAssocs(nodeRef, ContentModel.ASSOC_ORIGINAL).isEmpty() ||
!nodeService.getSourceAssocs(nodeRef, ContentModel.ASSOC_ORIGINAL).isEmpty())
{
//disable versioning and auditing
behaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
behaviourFilter.disableBehaviour(ContentModel.ASPECT_VERSIONABLE);
try
{
//create a new content URL for the copy/original node
createNewContentURL(nodeRef);
}
finally
{
//enable versioning and auditing
behaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);
behaviourFilter.enableBehaviour(ContentModel.ASPECT_VERSIONABLE);
}
duplicateContentFileIfRequired(nodeRef);
}
return null;

View File

@@ -29,6 +29,7 @@ package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_ARCHIVED;
import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_RECORD;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.never;
@@ -158,6 +159,23 @@ public class RecordAspectUnitTest
verify(mockContentWriter, times(1)).putContent(mockContentReader);
}
/**
* This is testing the fix for RM-6788 where archived content couldn't be declared as a record
* This was caused by attempting to copy the bin file and updating the content url of the
* archived piece of content which failed as this is a protected property. This is done if
* the node is/has a copy but the same duplication already happens during archive.
*/
@Test
public void testBinFileNotDuplicatedForArchivedContent()
{
when(mockNodeService.getTargetAssocs(NODE_REF, ContentModel.ASSOC_ORIGINAL)).thenReturn(asList(TARGET_ASSOC_REF));
when(mockContentService.getReader(NODE_REF, ContentModel.PROP_CONTENT)).thenReturn(null);
when(mockNodeService.hasAspect(NODE_REF, ASPECT_ARCHIVED)).thenReturn(true);
recordAspect.beforeAddAspect(NODE_REF, ASPECT_RECORD);
verifyBeforeAddAspectMethodsInvocations(0);
}
/**
* Helper to verify beforeAddAspect methods invocations
*