diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java index e0513e1b17..82fb53ca83 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/record/RecordServiceImpl.java @@ -1212,14 +1212,9 @@ public class RecordServiceImpl extends BaseBehaviourBean if (isRecord(nodeRef)) { - ChildAssociationRef childAssocRef = nodeService.getPrimaryParent(nodeRef); if (childAssocRef != null) { - NodeRef parent = childAssocRef.getParentRef(); - if (parent != null && recordFolderService.isRecordFolder(parent)) - { - result = true; - } + result = (null != nodeService.getProperty(nodeRef, PROP_DATE_FILED)); } } diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RecordTestSuite.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RecordTestSuite.java index 7394d0d767..b134320645 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RecordTestSuite.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/RecordTestSuite.java @@ -35,7 +35,8 @@ import org.junit.runners.Suite.SuiteClasses; CreateRecordTest.class, MoveRecordTest.class, HideInplaceRecordTest.class, - MoveInplaceRecordTest.class + MoveInplaceRecordTest.class, + ViewRecordTest.class }) public class RecordTestSuite { diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/ViewRecordTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/ViewRecordTest.java new file mode 100644 index 0000000000..116e618982 --- /dev/null +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/record/ViewRecordTest.java @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2005-2014 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.integration.record; + +import java.util.HashSet; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.capability.Capability; +import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; +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.RunAsWork; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.util.GUID; + +/** + * View record tests. + * + * @author Ana Bozianu + * @since 2.3 + */ +public class ViewRecordTest extends BaseRMTestCase +{ + /** + * Given a user with read permission on a record and without read permission on the parent folder check if the user can check if the record is filed + * + * @see https://issues.alfresco.com/jira/browse/RM-1738 + */ + public void testReadIsFiledPropertyWithoutReadPermissionOnParentFolder() throws Exception + { + doBehaviourDrivenTest(new BehaviourDrivenTest() + { + /** test data */ + String roleName = GUID.generate(); + String user = GUID.generate(); + NodeRef rc; + NodeRef recordFolder; + NodeRef record; + boolean recordIsFiled = false; + + public void given() + { + // create role + Set capabilities = new HashSet(2); + capabilities.add(capabilityService.getCapability("ViewRecords")); + filePlanRoleService.createRole(filePlan, roleName, roleName, capabilities); + + // create user and assign to role + createPerson(user, true); + filePlanRoleService.assignRoleToAuthority(filePlan, roleName, user); + + // create file plan structure + rc = filePlanService.createRecordCategory(filePlan, GUID.generate()); + NodeRef rsc = filePlanService.createRecordCategory(rc, GUID.generate()); + recordFolder = recordFolderService.createRecordFolder(rsc, GUID.generate()); + record = recordService.createRecordFromContent(recordFolder, GUID.generate(), TYPE_CONTENT, null, null); + } + + public void when() + { + // give read and file permissions on folder and remove permission from parent + filePlanPermissionService.setPermission(rc, user, RMPermissionModel.READ_RECORDS); + permissionService.setInheritParentPermissions(recordFolder, false); + filePlanPermissionService.setPermission(record, user, RMPermissionModel.READ_RECORDS); + + //check if the user can read the isFiled property + AuthenticationUtil.runAs(new RunAsWork() + { + public Void doWork() throws Exception + { + recordIsFiled = recordService.isFiled(record); + + return null; + } + }, user); + } + + public void then() + { + //check if the property is evaluated correctly + assertTrue(recordIsFiled); + } + + }); + } + +}