diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java index cf1857b4bd..52915ffca9 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java @@ -415,7 +415,7 @@ public class RecordAspect extends AbstractDisposableItem @Behaviour ( kind = BehaviourKind.CLASS, - notificationFrequency = NotificationFrequency.EVERY_EVENT + notificationFrequency = NotificationFrequency.FIRST_EVENT ) public void onUpdateProperties(NodeRef nodeRef, Map before, Map after) { @@ -425,7 +425,7 @@ public class RecordAspect extends AbstractDisposableItem ContentData contentAfter = (ContentData) after.get(ContentModel.PROP_CONTENT); // Check only storeNameAfter since the store name is updated before this method is triggered - // Does not allow content setting content to null when moving content between stores (case not covered by + // Does not allow setting content to null when moving content between stores (case not covered by // ContentPropertyRestrictionInterceptor) if (storeNameAfter != null && contentAfter != null) { diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspectUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspectUnitTest.java index 60aee3793d..4b2eb829b8 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspectUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspectUnitTest.java @@ -29,19 +29,29 @@ 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.model.ContentModel.PROP_CONTENT; +import static org.alfresco.model.ContentModel.PROP_STORE_NAME; import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_RECORD; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; +import java.io.Serializable; +import java.util.Locale; +import java.util.Map; + +import com.google.common.collect.ImmutableMap; + import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; import org.alfresco.module.org_alfresco_module_rm.util.ContentBinDuplicationUtility; +import org.alfresco.repo.node.integrity.IntegrityException; import org.alfresco.service.cmr.repository.AssociationRef; +import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.QName; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -123,5 +133,27 @@ public class RecordAspectUnitTest verify(mockContentBinDuplicationUtility, times(1)).duplicate(COPY_REF); } + /** + * Check that an IntegrityException is thrown when content is changed + */ + @Test (expected = IntegrityException.class) + public void testOnUpdatePropertiesContentChanged() + { + Map before = ImmutableMap.of(PROP_CONTENT, new ContentData("dummyContentUrl", "text/plain", + 0L, "UTF-8", Locale.UK)); + Map after = ImmutableMap.of(PROP_CONTENT, new ContentData("dummyContentUrl", "text/plain", 0L, "UTF-8", Locale.UK)); + recordAspect.onUpdateProperties(NODE_REF, before, after); + } + /** + * Check that no exception is thrown when moving record between stores + */ + @Test + public void testOnUpdatePropertiesContentMovedToAnotherStore() + { + Map before = ImmutableMap.of(PROP_CONTENT, new ContentData("dummyContentUrl", "text/plain", 0L, "UTF" + + "-8", Locale.UK)); + Map after = ImmutableMap.of(PROP_CONTENT, new ContentData("dummyContentUrl", "text/plain", 0L, "UTF-8", Locale.UK), PROP_STORE_NAME, "store2"); + recordAspect.onUpdateProperties(NODE_REF, before, after); + } }