mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
APPS-391: [AGS/WORM] Wrong error message received when updating the content store property for a locked record
This commit is contained in:
@@ -27,11 +27,6 @@
|
|||||||
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect;
|
package org.alfresco.module.org_alfresco_module_rm.model.rma.aspect;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.model.QuickShareModel;
|
import org.alfresco.model.QuickShareModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies;
|
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies;
|
||||||
@@ -39,6 +34,7 @@ import org.alfresco.module.org_alfresco_module_rm.model.behaviour.AbstractDispos
|
|||||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.util.ContentBinDuplicationUtility;
|
import org.alfresco.module.org_alfresco_module_rm.util.ContentBinDuplicationUtility;
|
||||||
|
import org.alfresco.repo.content.ContentServicePolicies;
|
||||||
import org.alfresco.repo.copy.CopyBehaviourCallback;
|
import org.alfresco.repo.copy.CopyBehaviourCallback;
|
||||||
import org.alfresco.repo.copy.CopyDetails;
|
import org.alfresco.repo.copy.CopyDetails;
|
||||||
import org.alfresco.repo.copy.CopyServicePolicies;
|
import org.alfresco.repo.copy.CopyServicePolicies;
|
||||||
@@ -57,9 +53,13 @@ import org.alfresco.service.cmr.repository.ContentData;
|
|||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.ScriptService;
|
import org.alfresco.service.cmr.repository.ScriptService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.EqualsHelper;
|
|
||||||
import org.springframework.extensions.surf.util.I18NUtil;
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rma:record behaviour bean
|
* rma:record behaviour bean
|
||||||
*
|
*
|
||||||
@@ -77,7 +77,8 @@ public class RecordAspect extends AbstractDisposableItem
|
|||||||
RecordsManagementPolicies.OnRemoveReference,
|
RecordsManagementPolicies.OnRemoveReference,
|
||||||
NodeServicePolicies.OnMoveNodePolicy,
|
NodeServicePolicies.OnMoveNodePolicy,
|
||||||
CopyServicePolicies.OnCopyCompletePolicy,
|
CopyServicePolicies.OnCopyCompletePolicy,
|
||||||
NodeServicePolicies.OnUpdatePropertiesPolicy
|
NodeServicePolicies.OnUpdatePropertiesPolicy,
|
||||||
|
ContentServicePolicies.OnContentPropertyUpdatePolicy
|
||||||
{
|
{
|
||||||
/** Well-known location of the scripts folder. */
|
/** Well-known location of the scripts folder. */
|
||||||
// TODO make configurable
|
// TODO make configurable
|
||||||
@@ -100,7 +101,11 @@ public class RecordAspect extends AbstractDisposableItem
|
|||||||
|
|
||||||
/** I18N */
|
/** I18N */
|
||||||
private static final String MSG_CANNOT_UPDATE_RECORD_CONTENT = "rm.service.update-record-content";
|
private static final String MSG_CANNOT_UPDATE_RECORD_CONTENT = "rm.service.update-record-content";
|
||||||
|
private static final String MSG_UPDATE_STORE_NAME = "rm.action.update-store-name";
|
||||||
|
|
||||||
|
// WORM lock aspect
|
||||||
|
public static final String RME_URI = "http://www.alfresco.org/model/recordsmanagemententerprise/1.0";
|
||||||
|
public static final QName ASPECT_WORM_LOCK = QName.createQName(RME_URI, "wormLock");
|
||||||
/**
|
/**
|
||||||
* @param extendedSecurityService extended security service
|
* @param extendedSecurityService extended security service
|
||||||
*/
|
*/
|
||||||
@@ -416,23 +421,41 @@ public class RecordAspect extends AbstractDisposableItem
|
|||||||
@Behaviour
|
@Behaviour
|
||||||
(
|
(
|
||||||
kind = BehaviourKind.CLASS,
|
kind = BehaviourKind.CLASS,
|
||||||
notificationFrequency = NotificationFrequency.FIRST_EVENT
|
notificationFrequency = NotificationFrequency.FIRST_EVENT,
|
||||||
|
type = "rma:record"
|
||||||
)
|
)
|
||||||
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
|
public void onUpdateProperties(NodeRef nodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
|
||||||
{
|
{
|
||||||
String storeNameAfter = (String) after.get(ContentModel.PROP_STORE_NAME);
|
String storeNameAfter = (String) after.get(ContentModel.PROP_STORE_NAME);
|
||||||
|
String beforeNameAfter = (String) before.get(ContentModel.PROP_STORE_NAME);
|
||||||
|
|
||||||
ContentData contentBefore = (ContentData) before.get(ContentModel.PROP_CONTENT);
|
|
||||||
ContentData contentAfter = (ContentData) after.get(ContentModel.PROP_CONTENT);
|
ContentData contentAfter = (ContentData) after.get(ContentModel.PROP_CONTENT);
|
||||||
|
if (storeNameAfter != null && !storeNameAfter.equals(beforeNameAfter))
|
||||||
// Check only storeNameAfter since the store name is updated before this method is triggered
|
{
|
||||||
|
if (nodeService.hasAspect(nodeRef, ASPECT_WORM_LOCK))
|
||||||
|
{
|
||||||
|
// we cannot change the worm store name
|
||||||
|
throw new IntegrityException(MSG_UPDATE_STORE_NAME, null);
|
||||||
|
}
|
||||||
// Does not allow 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)
|
// ContentPropertyRestrictionInterceptor)
|
||||||
if (storeNameAfter != null && contentAfter != null)
|
else if (contentAfter != null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (contentBefore != null && !contentBefore.equals(contentAfter))
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Behaviour
|
||||||
|
(
|
||||||
|
kind = BehaviourKind.CLASS,
|
||||||
|
notificationFrequency = NotificationFrequency.FIRST_EVENT
|
||||||
|
)
|
||||||
|
public void onContentPropertyUpdate(NodeRef nodeRef, QName propertyQName, ContentData beforeValue, ContentData afterValue)
|
||||||
|
{
|
||||||
|
// Allow creation of content but not update
|
||||||
|
if (beforeValue != null)
|
||||||
{
|
{
|
||||||
throw new IntegrityException(I18NUtil.getMessage(MSG_CANNOT_UPDATE_RECORD_CONTENT), null);
|
throw new IntegrityException(I18NUtil.getMessage(MSG_CANNOT_UPDATE_RECORD_CONTENT), null);
|
||||||
}
|
}
|
||||||
|
@@ -133,19 +133,6 @@ public class RecordAspectUnitTest
|
|||||||
verify(mockContentBinDuplicationUtility, times(1)).duplicate(COPY_REF);
|
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<QName, Serializable> before = ImmutableMap.of(PROP_CONTENT, new ContentData("dummyContentUrl", "text/plain",
|
|
||||||
0L, "UTF-8", Locale.UK));
|
|
||||||
Map<QName, Serializable> after = ImmutableMap.of(PROP_CONTENT, new ContentData("dummyContentUrl2", "text" +
|
|
||||||
"/plain", 0L, "UTF-8", Locale.UK));
|
|
||||||
recordAspect.onUpdateProperties(NODE_REF, before, after);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that no exception is thrown when moving record between stores
|
* Check that no exception is thrown when moving record between stores
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user