RM-1814 (It's possible to add relationship to on hold record)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@93597 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2015-01-16 15:10:44 +00:00
parent d41ddc85e2
commit f1a300d7fe
2 changed files with 95 additions and 0 deletions

View File

@@ -18,6 +18,7 @@
*/
package org.alfresco.module.org_alfresco_module_rm.relationship;
import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_FROZEN;
import static org.alfresco.util.ParameterCheck.mandatory;
import static org.alfresco.util.ParameterCheck.mandatoryString;
import static org.apache.commons.lang.StringUtils.isBlank;
@@ -29,6 +30,7 @@ import java.util.Map.Entry;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeCreateReference;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeRemoveReference;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnCreateReference;
@@ -417,6 +419,15 @@ public class RelationshipServiceImpl extends RecordsManagementAdminBase implemen
mandatory("source", source);
mandatory("target", target);
if (getNodeService().hasAspect(target, ASPECT_FROZEN))
{
StringBuilder sb = new StringBuilder();
sb.append("Relationship cannot be created as the target '").
append(getNodeService().getProperty(target, ContentModel.PROP_NAME)).
append("' is in a hold.");
throw new AlfrescoRuntimeException(sb.toString());
}
// Check that the association definition for the given unique name exists.
AssociationDefinition associationDefinition = getAssociationDefinition(uniqueName);
if (associationDefinition == null)