RM-1738 Merged revisions 94050-94454 from DEV to V2.3

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.3@94455 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ana Bozianu
2015-01-30 13:29:28 +00:00
parent 31fb488b0c
commit e3dfeea6c3
3 changed files with 106 additions and 7 deletions

View File

@@ -1212,14 +1212,9 @@ public class RecordServiceImpl extends BaseBehaviourBean
if (isRecord(nodeRef)) if (isRecord(nodeRef))
{ {
ChildAssociationRef childAssocRef = nodeService.getPrimaryParent(nodeRef);
if (childAssocRef != null) if (childAssocRef != null)
{ {
NodeRef parent = childAssocRef.getParentRef(); result = (null != nodeService.getProperty(nodeRef, PROP_DATE_FILED));
if (parent != null && recordFolderService.isRecordFolder(parent))
{
result = true;
}
} }
} }

View File

@@ -35,7 +35,8 @@ import org.junit.runners.Suite.SuiteClasses;
CreateRecordTest.class, CreateRecordTest.class,
MoveRecordTest.class, MoveRecordTest.class,
HideInplaceRecordTest.class, HideInplaceRecordTest.class,
MoveInplaceRecordTest.class MoveInplaceRecordTest.class,
ViewRecordTest.class
}) })
public class RecordTestSuite public class RecordTestSuite
{ {

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
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<Capability> capabilities = new HashSet<Capability>(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<Void>()
{
public Void doWork() throws Exception
{
recordIsFiled = recordService.isFiled(record);
return null;
}
}, user);
}
public void then()
{
//check if the property is evaluated correctly
assertTrue(recordIsFiled);
}
});
}
}