diff --git a/src/main/java/org/alfresco/repo/node/UndeletableAspect.java b/src/main/java/org/alfresco/repo/node/UndeletableAspect.java
index 1396c38f9b..c2ce8dabfa 100644
--- a/src/main/java/org/alfresco/repo/node/UndeletableAspect.java
+++ b/src/main/java/org/alfresco/repo/node/UndeletableAspect.java
@@ -1,32 +1,36 @@
-/*
- * #%L
- * Alfresco Repository
- * %%
- * Copyright (C) 2005 - 2016 Alfresco Software Limited
- * %%
- * This file is part of the Alfresco software.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- * #L%
- */
+/*
+ * #%L
+ * Alfresco Repository
+ * %%
+ * Copyright (C) 2005 - 2016 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ * #L%
+ */
package org.alfresco.repo.node;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
+import org.alfresco.repo.copy.CopyBehaviourCallback;
+import org.alfresco.repo.copy.CopyDetails;
+import org.alfresco.repo.copy.CopyServicePolicies;
+import org.alfresco.repo.copy.DoNothingCopyBehaviourCallback;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy;
import org.alfresco.repo.policy.Behaviour;
@@ -35,6 +39,7 @@ import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.site.SiteService;
+import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
/**
@@ -54,7 +59,8 @@ import org.alfresco.service.namespace.QName;
* @author Neil Mc Erlean
* @since 3.5.0
*/
-public class UndeletableAspect implements NodeServicePolicies.BeforeDeleteNodePolicy
+public class UndeletableAspect implements NodeServicePolicies.BeforeDeleteNodePolicy,
+ CopyServicePolicies.OnCopyNodePolicy
{
private PolicyComponent policyComponent;
private NodeService nodeService;
@@ -87,6 +93,11 @@ public class UndeletableAspect implements NodeServicePolicies.BeforeDeleteNodePo
this.policyComponent.bindClassBehaviour(BeforeDeleteNodePolicy.QNAME,
ContentModel.ASPECT_UNDELETABLE,
new JavaBehaviour(this, "beforeDeleteNode", Behaviour.NotificationFrequency.EVERY_EVENT));
+
+ policyComponent.bindClassBehaviour(
+ QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"),
+ ContentModel.ASPECT_UNDELETABLE,
+ new JavaBehaviour(this, "getCopyCallback"));
}
/**
@@ -98,4 +109,10 @@ public class UndeletableAspect implements NodeServicePolicies.BeforeDeleteNodePo
QName nodeType = nodeService.getType(nodeRef);
throw new AlfrescoRuntimeException(nodeType.toPrefixString() + " deletion is not allowed. Attempted to delete " + nodeRef);
}
+
+ @Override
+ public CopyBehaviourCallback getCopyCallback(QName classRef, CopyDetails copyDetails)
+ {
+ return DoNothingCopyBehaviourCallback.getInstance();
+ }
}
diff --git a/src/test/java/org/alfresco/repo/coci/CheckOutCheckInServiceImplTest.java b/src/test/java/org/alfresco/repo/coci/CheckOutCheckInServiceImplTest.java
index dbbe147aaa..e7958c356f 100644
--- a/src/test/java/org/alfresco/repo/coci/CheckOutCheckInServiceImplTest.java
+++ b/src/test/java/org/alfresco/repo/coci/CheckOutCheckInServiceImplTest.java
@@ -1047,6 +1047,29 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest
fail("Lockable aspect should not be copied from the working copy to the original document");
}
}
+
+ public void testCanCheckInWhenOriginalHasUndeletableAspect()
+ {
+ nodeService.addAspect(nodeRef, ContentModel.ASPECT_UNDELETABLE, null);
+ // Pre-condition of test, original must have sys:undeletable
+ assertTrue(nodeService.hasAspect(nodeRef, ContentModel.ASPECT_UNDELETABLE));
+
+ // Check-out nodeRef
+ NodeRef workingCopy = this.cociService.checkout(
+ this.nodeRef,
+ this.rootNodeRef,
+ ContentModel.ASSOC_CHILDREN,
+ QName.createQName("workingCopy"));
+ assertNotNull(workingCopy);
+
+ // Check that the working copy does not have the sys:undeletable aspect
+ assertFalse(nodeService.hasAspect(workingCopy, ContentModel.ASPECT_UNDELETABLE));
+
+ // Check-in: must work despite original having the sys:undeletable aspect (MNT-18546)
+ Map versionProperties = new HashMap();
+ versionProperties.put(Version.PROP_DESCRIPTION, "This is a test version");
+ cociService.checkin(workingCopy, versionProperties);
+ }
private NodeRef createFolderWithPermission(NodeRef parent, String username, String permission)
{