diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeService.java index 087d869996..f7fc67efea 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/freeze/FreezeService.java @@ -26,134 +26,134 @@ import org.alfresco.service.cmr.repository.NodeRef; /** * Freeze Service Interface * - * TODO Fill the implementation of this service out and consolidate existing freeze code. For now consider this a guide for a future service implementation. - * Implementation used to consolidate freeze behaviours in 2.0. - * When implementing consider application of freeze to 'any' node references, not just records and record folders. (Consider implecations for security and - * capabilities) + * TODO + * Implementation used to consolidate freeze behaviours in 2.0. + * When implementing consider application of freeze to 'any' node references, not just records and record folders. + * (Consider implications for security and capabilities) * * @author Roy Wetherall * @since 2.0 */ public interface FreezeService { - /** - * Indicates whether the passed node reference is a hold. A hold is a container for a group of frozen object and contains the freeze - * reason. - * - * @param nodeRef hold node reference - * @return boolean true if hold, false otherwise - */ - boolean isHold(NodeRef nodeRef); - - /** - * Indicates whether the passed node reference is frozen. - * - * @param nodeRef node reference - * @return boolean true if frozen, false otherwise - */ - boolean isFrozen(NodeRef nodeRef); - - /** - * Get the 'root' frozen node references in a hold. - * - * @param hold hold node reference - * @return Set frozen node references - */ - Set getFrozen(NodeRef hold); - - /** - * Freezes a node with the provided reason, creating a hold node reference. - * - * @param reason freeze reason - * @param nodeRef node reference - * @return NodeRef hold node reference - */ - NodeRef freeze(String reason, NodeRef nodeRef); - - /** - * Freezes a node, adding it an existing hold. - * - * @param hold hold node reference - * @param nodeRef node reference - */ - void freeze(NodeRef hold, NodeRef nodeRef); - - /** - * Freezes a collection of nodes with the given reason, creating a hold. - * - * @param reason freeze reason - * @param nodeRefs set of nodes to freeze - * @return NodeRef hold node reference - */ + /** + * Indicates whether the passed node reference is a hold. A hold is a container for a group of frozen object and contains the freeze + * reason. + * + * @param nodeRef hold node reference + * @return boolean true if hold, false otherwise + */ + boolean isHold(NodeRef nodeRef); + + /** + * Indicates whether the passed node reference is frozen. + * + * @param nodeRef node reference + * @return boolean true if frozen, false otherwise + */ + boolean isFrozen(NodeRef nodeRef); + + /** + * Get the 'root' frozen node references in a hold. + * + * @param hold hold node reference + * @return Set frozen node references + */ + Set getFrozen(NodeRef hold); + + /** + * Freezes a node with the provided reason, creating a hold node reference. + * + * @param reason freeze reason + * @param nodeRef node reference + * @return NodeRef hold node reference + */ + NodeRef freeze(String reason, NodeRef nodeRef); + + /** + * Freezes a node, adding it an existing hold. + * + * @param hold hold node reference + * @param nodeRef node reference + */ + void freeze(NodeRef hold, NodeRef nodeRef); + + /** + * Freezes a collection of nodes with the given reason, creating a hold. + * + * @param reason freeze reason + * @param nodeRefs set of nodes to freeze + * @return NodeRef hold node reference + */ NodeRef freeze(String reason, Set nodeRefs); - - /** - * Freeze a collection of nodes, adding them to an existing hold. - * - * @param hold hold node reference - * @param nodeRefs set of nodes to freeze - */ - void freeze(NodeRef hold, Set nodeRefs); - - /** - * Unfreeze a frozen node. - *

- * The unfrozen node is automatically removed from the hold(s) it is in. If the hold is - * subsequently empty, the hold is automatically deleted. - * - * @param nodeRef node reference - */ - void unFreeze(NodeRef nodeRef); - - /** - * Unfreeze a collection of nodes. - *

- * The unfrozen nodes are automatically removed from the hold(s) the are in. If the hold(s) is - * subsequently empty, the hold is automatically deleted. - * - * @param nodeRefs set of nodes to unfreeze - */ - void unFreeze(Set nodeRefs); - - /** - * Unfreezes all nodes within a hold and deletes the hold. - * - * @param hold hold node reference - */ - void relinquish(NodeRef hold); - - /** - * Gets the freeze reason for a hold. - * - * @param hold hold node reference - * @return String freeze reason - */ - String getReason(NodeRef hold); - - /** - * Updates the freeze reason for a given hold. - * - * @param hold hold node reference - * @param reason updated reason - */ - void updateReason(NodeRef hold, String reason); - /** - * Gets the hold node references for a given file plan - * or an empty set if there is not any hold node available - * - * @param filePlan file plan for which the hold nodes will be retrieved - * @return Set hold node references - */ - Set getHolds(NodeRef filePlan); + /** + * Freeze a collection of nodes, adding them to an existing hold. + * + * @param hold hold node reference + * @param nodeRefs set of nodes to freeze + */ + void freeze(NodeRef hold, Set nodeRefs); - /** - * Checks whether or not the given node has frozen children - * - * @param nodeRef The nodeRef for which will be checked if it has frozen children - * @return true if the given nodeRef has frozen children, false otherwise - */ - boolean hasFrozenChildren(NodeRef nodeRef); + /** + * Unfreeze a frozen node. + *

+ * The unfrozen node is automatically removed from the hold(s) it is in. If the hold is + * subsequently empty, the hold is automatically deleted. + * + * @param nodeRef node reference + */ + void unFreeze(NodeRef nodeRef); + + /** + * Unfreeze a collection of nodes. + *

+ * The unfrozen nodes are automatically removed from the hold(s) the are in. If the hold(s) is + * subsequently empty, the hold is automatically deleted. + * + * @param nodeRefs set of nodes to unfreeze + */ + void unFreeze(Set nodeRefs); + + /** + * Unfreezes all nodes within a hold and deletes the hold. + * + * @param hold hold node reference + */ + void relinquish(NodeRef hold); + + /** + * Gets the freeze reason for a hold. + * + * @param hold hold node reference + * @return String freeze reason + */ + String getReason(NodeRef hold); + + /** + * Updates the freeze reason for a given hold. + * + * @param hold hold node reference + * @param reason updated reason + */ + void updateReason(NodeRef hold, String reason); + + /** + * Gets the hold node references for a given file plan + * or an empty set if there is not any hold node available + * + * @param filePlan file plan for which the hold nodes will be retrieved + * @return Set hold node references + */ + Set getHolds(NodeRef filePlan); + + /** + * Checks whether or not the given node has frozen children + * + * @param nodeRef The nodeRef for which will be checked if it has frozen children + * @return true if the given nodeRef has frozen children, false otherwise + */ + boolean hasFrozenChildren(NodeRef nodeRef); /** * Gets the date of the freeze for the given node, null if the node is not frozen diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FreezeServiceImplTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FreezeServiceImplTest.java index d9a1436a4b..86ab7a3129 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FreezeServiceImplTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/service/FreezeServiceImplTest.java @@ -182,9 +182,27 @@ public class FreezeServiceImplTest extends BaseRMTestCase assertNotNull(freezeService.getFreezeInitiator(recordTwo)); assertFalse(freezeService.isFrozen(recordThree)); - // FIXME - freezeService.unFreeze(recordTwo); - freezeService.unFreeze(recordOne); + // Relinquish the first hold + holdNodeRef = holdAssocs.iterator().next(); + freezeService.relinquish(holdNodeRef); + + // Check the existing hold + holdAssocs = freezeService.getHolds(filePlan); + assertNotNull(holdAssocs); + assertEquals(1, holdAssocs.size()); + + // Relinquish the second hold + holdNodeRef = holdAssocs.iterator().next(); + freezeService.unFreeze(freezeService.getFrozen(holdNodeRef)); + + // All holds should be deleted + holdAssocs = freezeService.getHolds(filePlan); + assertEquals(0, holdAssocs.size()); + + // Check the nodes are unfrozen + assertFalse(freezeService.isFrozen(recordOne)); + assertFalse(freezeService.isFrozen(recordTwo)); + assertFalse(freezeService.isFrozen(recordThree)); } /**