mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
code review comments
This commit is contained in:
@@ -303,7 +303,7 @@ public class HoldServiceImpl extends ServiceBaseImpl
|
|||||||
if (!includedInHold)
|
if (!includedInHold)
|
||||||
{
|
{
|
||||||
// invert list to get list of holds that do not contain this node
|
// invert list to get list of holds that do not contain this node
|
||||||
NodeRef filePlan = isFilePlanComponent(nodeRef) ? filePlanService.getFilePlan(nodeRef) : filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||||
List<NodeRef> allHolds = getHolds(filePlan);
|
List<NodeRef> allHolds = getHolds(filePlan);
|
||||||
result = ListUtils.subtract(allHolds, new ArrayList<>(holdsNotIncludingNodeRef));
|
result = ListUtils.subtract(allHolds, new ArrayList<>(holdsNotIncludingNodeRef));
|
||||||
}
|
}
|
||||||
|
@@ -164,7 +164,7 @@ public class FrozenAspect extends BaseBehaviourBean
|
|||||||
{
|
{
|
||||||
if (nodeService.exists(nodeRef) && (isRecord(nodeRef) || instanceOf(nodeRef, TYPE_CONTENT)))
|
if (nodeService.exists(nodeRef) && (isRecord(nodeRef) || instanceOf(nodeRef, TYPE_CONTENT)))
|
||||||
{
|
{
|
||||||
// get the owning nodeRef folder
|
// get the owning folder
|
||||||
NodeRef parentRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
NodeRef parentRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
||||||
// check that the aspect has been added
|
// check that the aspect has been added
|
||||||
if (nodeService.hasAspect(parentRef, ASPECT_HELD_CHILDREN))
|
if (nodeService.hasAspect(parentRef, ASPECT_HELD_CHILDREN))
|
||||||
|
@@ -26,7 +26,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.hold;
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.hold;
|
||||||
|
|
||||||
|
import static org.alfresco.repo.security.authentication.AuthenticationUtil.getAdminUserName;
|
||||||
|
import static org.alfresco.repo.site.SiteModel.SITE_MANAGER;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
@@ -139,7 +143,7 @@ public class AddActiveContentToHoldTest extends BaseRMTestCase
|
|||||||
|
|
||||||
public void testAddDocumentToHoldNoWritePermissionOnDoc()
|
public void testAddDocumentToHoldNoWritePermissionOnDoc()
|
||||||
{
|
{
|
||||||
doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class)
|
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||||
{
|
{
|
||||||
private NodeRef hold;
|
private NodeRef hold;
|
||||||
|
|
||||||
@@ -153,6 +157,9 @@ public class AddActiveContentToHoldTest extends BaseRMTestCase
|
|||||||
|
|
||||||
// assert current states
|
// assert current states
|
||||||
assertFalse(freezeService.isFrozen(dmDocument));
|
assertFalse(freezeService.isFrozen(dmDocument));
|
||||||
|
|
||||||
|
//add rm Admin as consumer in collaboration site to have read permissions on dmDocument
|
||||||
|
siteService.setMembership(collabSiteId, rmAdminName, SiteModel.SITE_CONSUMER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void when()
|
public void when()
|
||||||
@@ -161,7 +168,16 @@ public class AddActiveContentToHoldTest extends BaseRMTestCase
|
|||||||
// hold, but no Write permissions on doc
|
// hold, but no Write permissions on doc
|
||||||
AuthenticationUtil.runAs(
|
AuthenticationUtil.runAs(
|
||||||
(RunAsWork<Void>) () -> {
|
(RunAsWork<Void>) () -> {
|
||||||
holdService.addToHold(hold, dmDocument);
|
try
|
||||||
|
{
|
||||||
|
holdService.addToHold(hold, dmDocument);
|
||||||
|
fail("Expected AlfrescoRuntimeException to be thrown.");
|
||||||
|
}
|
||||||
|
catch (AlfrescoRuntimeException e)
|
||||||
|
{
|
||||||
|
System.out.println(e);
|
||||||
|
assertTrue(e.getMessage().endsWith("Write permission on '" + NAME_DM_DOCUMENT + "' is needed."));
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}, rmAdminName);
|
}, rmAdminName);
|
||||||
}
|
}
|
||||||
@@ -170,61 +186,79 @@ public class AddActiveContentToHoldTest extends BaseRMTestCase
|
|||||||
|
|
||||||
public void testAddDocumentToHoldNoFilingPermissionOnHold()
|
public void testAddDocumentToHoldNoFilingPermissionOnHold()
|
||||||
{
|
{
|
||||||
doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class)
|
doBehaviourDrivenTest(new BehaviourDrivenTest(recordsManagerName, false)
|
||||||
{
|
{
|
||||||
private NodeRef hold;
|
private NodeRef hold;
|
||||||
|
|
||||||
public void given()
|
public void given()
|
||||||
{
|
{
|
||||||
// Check that the document is not a record
|
AuthenticationUtil.runAs(
|
||||||
assertFalse("The document should not be a record", recordService.isRecord(dmDocument));
|
(RunAsWork<Void>) () -> {
|
||||||
|
// Check that the document is not a record
|
||||||
|
assertFalse("The document should not be a record", recordService.isRecord(dmDocument));
|
||||||
|
|
||||||
// create a hold
|
// create a hold
|
||||||
hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate());
|
hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate());
|
||||||
|
|
||||||
// assert current states
|
//add Read permission on hold
|
||||||
assertFalse(freezeService.isFrozen(dmDocument));
|
filePlanPermissionService.setPermission(hold, recordsManagerName, RMPermissionModel.READ_RECORDS);
|
||||||
|
|
||||||
//add recordsManagerPerson as manager in collaboration site to have write permissions on dmDocument
|
// assert current states
|
||||||
siteService.setMembership(collabSiteId, recordsManagerName, SiteModel.SITE_MANAGER);
|
assertFalse(freezeService.isFrozen(dmDocument));
|
||||||
|
|
||||||
|
//add recordsManagerPerson as manager in collaboration site to have write permissions on dmDocument
|
||||||
|
siteService.setMembership(collabSiteId, recordsManagerName, SITE_MANAGER);
|
||||||
|
return null;
|
||||||
|
}, getAdminUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void when()
|
public void when()
|
||||||
{
|
{
|
||||||
// add the active content to hold as a RM manager who has Add to Hold Capability and write permission on
|
|
||||||
// doc, but no filing permission on hold
|
|
||||||
AuthenticationUtil.runAs(
|
AuthenticationUtil.runAs(
|
||||||
(RunAsWork<Void>) () -> {
|
(RunAsWork<Void>) () -> {
|
||||||
holdService.addToHold(hold, dmDocument);
|
// add the active content to hold as a RM manager who has Add to Hold Capability and write permission on
|
||||||
|
// doc, but no filing permission on hold
|
||||||
|
try
|
||||||
|
{
|
||||||
|
holdService.addToHold(hold, dmDocument);
|
||||||
|
fail("Expected AccessDeniedException to be thrown.");
|
||||||
|
}
|
||||||
|
catch (AccessDeniedException e)
|
||||||
|
{
|
||||||
|
//expected
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}, recordsManagerName);
|
}, recordsManagerName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testAddDocumentToHoldNoCapability()
|
public void testAddDocumentToHoldNoCapability()
|
||||||
{
|
{
|
||||||
doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class)
|
doBehaviourDrivenTest(new BehaviourDrivenTest(powerUserName, false)
|
||||||
{
|
{
|
||||||
private NodeRef hold;
|
private NodeRef hold;
|
||||||
|
|
||||||
public void given()
|
public void given()
|
||||||
{
|
{
|
||||||
// Check that the document is not a record
|
AuthenticationUtil.runAs(
|
||||||
assertFalse("The document should not be a record", recordService.isRecord(dmDocument));
|
(RunAsWork<Void>) () -> {
|
||||||
|
// Check that the document is not a record
|
||||||
|
assertFalse("The document should not be a record", recordService.isRecord(dmDocument));
|
||||||
|
|
||||||
// create a hold
|
// create a hold
|
||||||
hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate());
|
hold = holdService.createHold(filePlan, GUID.generate(), GUID.generate(), GUID.generate());
|
||||||
|
|
||||||
// assert current states
|
// assert current states
|
||||||
assertFalse(freezeService.isFrozen(dmDocument));
|
assertFalse(freezeService.isFrozen(dmDocument));
|
||||||
|
|
||||||
//add powerUserPerson as manager in collaboration site to have write permissions on dmDocument
|
//add powerUserPerson as manager in collaboration site to have write permissions on dmDocument
|
||||||
siteService.setMembership(collabSiteId, powerUserName, SiteModel.SITE_MANAGER);
|
siteService.setMembership(collabSiteId, powerUserName, SiteModel.SITE_MANAGER);
|
||||||
|
|
||||||
//assign powerUserPerson filing permission on hold
|
//assign powerUserPerson filing permission on hold
|
||||||
filePlanPermissionService.setPermission(hold, powerUserName, FILING);
|
filePlanPermissionService.setPermission(hold, powerUserName, FILING);
|
||||||
|
return null;
|
||||||
|
}, getAdminUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void when()
|
public void when()
|
||||||
@@ -233,7 +267,15 @@ public class AddActiveContentToHoldTest extends BaseRMTestCase
|
|||||||
// permission on hold, but no Add To Hold capability
|
// permission on hold, but no Add To Hold capability
|
||||||
AuthenticationUtil.runAs(
|
AuthenticationUtil.runAs(
|
||||||
(RunAsWork<Void>) () -> {
|
(RunAsWork<Void>) () -> {
|
||||||
holdService.addToHold(hold, dmDocument);
|
try
|
||||||
|
{
|
||||||
|
holdService.addToHold(hold, dmDocument);
|
||||||
|
fail("Expected AccessDeniedException to be thrown.");
|
||||||
|
}
|
||||||
|
catch (AccessDeniedException e)
|
||||||
|
{
|
||||||
|
//expected
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}, powerUserName);
|
}, powerUserName);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user