diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeServiceImpl.java index 045b66b72c..5c65630f02 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeServiceImpl.java @@ -333,13 +333,17 @@ public class FreezeServiceImpl extends ServiceBaseImpl List records = recordsManagementService.getRecords(nodeRef); for (NodeRef record : records) { - nodeService.addAspect(record, ASPECT_FROZEN, props); - - if (logger.isDebugEnabled()) + // no need to freeze if already frozen! + if (nodeService.hasAspect(record, ASPECT_FROZEN) == false) { - StringBuilder msg = new StringBuilder(); - msg.append("Frozen aspect applied to '").append(record).append("'."); - logger.debug(msg.toString()); + nodeService.addAspect(record, ASPECT_FROZEN, props); + + if (logger.isDebugEnabled()) + { + StringBuilder msg = new StringBuilder(); + msg.append("Frozen aspect applied to '").append(record).append("'."); + logger.debug(msg.toString()); + } } } } diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/IssueTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/IssueTestSuite.java index f330d13846..6558be6352 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/IssueTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/IssueTestSuite.java @@ -19,6 +19,7 @@ package org.alfresco.module.org_alfresco_module_rm.test; import org.alfresco.module.org_alfresco_module_rm.test.issue.RM1008Test; +import org.alfresco.module.org_alfresco_module_rm.test.issue.RM1030Test; import org.alfresco.module.org_alfresco_module_rm.test.issue.RM452Test; import org.alfresco.module.org_alfresco_module_rm.test.issue.RM994Test; import org.junit.runner.RunWith; @@ -36,7 +37,8 @@ import org.junit.runners.Suite.SuiteClasses; { RM452Test.class, RM994Test.class, - RM1008Test.class + RM1008Test.class, + RM1030Test.class }) public class IssueTestSuite { diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1008Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1008Test.java index c0ed653f4b..ed09fba0ac 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1008Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1008Test.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2011 Alfresco Software Limited. + * Copyright (C) 2005-2013 Alfresco Software Limited. * * This file is part of Alfresco * @@ -42,6 +42,7 @@ import org.alfresco.util.GUID; * System test for RM-1008 * * @author Roy Wetherall + * @since 2.1 */ public class RM1008Test extends BaseRMTestCase { diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1030Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1030Test.java new file mode 100644 index 0000000000..6861077541 --- /dev/null +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM1030Test.java @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2005-2013 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * 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 . + */ +package org.alfresco.module.org_alfresco_module_rm.test.issue; + +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase; +import org.alfresco.service.cmr.repository.NodeRef; + + +/** + * Unit test for RM-1030 .. can't freeze a record folder that already has a frozen record containted within + * + * @author Roy Wetherall + * @since 2.1 + */ +public class RM1030Test extends BaseRMTestCase +{ + @Override + protected boolean isRecordTest() + { + return true; + } + + public void testRM1030() throws Exception + { + final NodeRef recordHold = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // show there are no holds when we start + Set holds = freezeService.getHolds(filePlan); + assertNotNull(holds); + assertEquals(0, holds.size()); + + // freeze record contained within the record folder + NodeRef hold = freezeService.freeze("in true life for serious", recordOne); + assertNotNull(hold); + + return hold; + } + + @Override + public void test(NodeRef hold) throws Exception + { + // show the record is frozen + assertTrue(freezeService.isFrozen(recordOne)); + + // count the number of holds + Set holds = freezeService.getHolds(filePlan); + assertNotNull(holds); + assertEquals(1, holds.size()); + } + + }); + + final NodeRef recordFolderHold = doTestInTransaction(new Test() + { + @Override + public NodeRef run() + { + // freeze the record folder that contains the frozen record + NodeRef folderHold = freezeService.freeze("innit but", rmFolder); + assertNotNull(folderHold); + + return folderHold; + } + + @Override + public void test(NodeRef hold) throws Exception + { + // show that the record and the record folder are frozen + assertTrue(freezeService.isFrozen(recordOne)); + assertTrue(freezeService.isFrozen(rmFolder)); + + // count the number of holds + Set holds = freezeService.getHolds(filePlan); + assertNotNull(holds); + assertEquals(2, holds.size()); + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // relinquish the record folder hold + freezeService.relinquish(recordFolderHold); + return null; + } + + @Override + public void test(Void result) throws Exception + { + assertTrue(freezeService.isFrozen(recordOne)); + assertFalse(freezeService.isFrozen(rmFolder)); + + Set holds = freezeService.getHolds(filePlan); + assertNotNull(holds); + assertEquals(1, holds.size()); + } + }); + + doTestInTransaction(new Test() + { + @Override + public Void run() + { + // relinquish the record hold + freezeService.relinquish(recordHold); + return null; + } + + @Override + public void test(Void result) throws Exception + { + assertFalse(freezeService.isFrozen(recordOne)); + assertFalse(freezeService.isFrozen(rmFolder)); + + Set holds = freezeService.getHolds(filePlan); + assertNotNull(holds); + assertEquals(0, holds.size()); + } + }); + + } +} diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM452Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM452Test.java index d22a0ec0a8..380022d301 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM452Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM452Test.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2011 Alfresco Software Limited. + * Copyright (C) 2005-2013 Alfresco Software Limited. * * This file is part of Alfresco * @@ -29,6 +29,7 @@ import org.alfresco.module.org_alfresco_module_rm.test.util.TestService; * See alfresco.extension.rm-method-security.properties * * @author Roy Wetherall + * @since 2.1 */ public class RM452Test extends BaseRMTestCase { diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM994Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM994Test.java index fbc0f63d0a..5dd658e9af 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM994Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/issue/RM994Test.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2011 Alfresco Software Limited. + * Copyright (C) 2005-2013 Alfresco Software Limited. * * This file is part of Alfresco * @@ -28,6 +28,7 @@ import org.alfresco.service.cmr.repository.Period; * System test for RM-994 * * @author Roy Wetherall + * @since 2.1 */ public class RM994Test extends BaseRMTestCase {