mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1727 (Error on Folder/record details page when user have no permissions on parent category)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@98884 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -18,6 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.forms;
|
package org.alfresco.module.org_alfresco_module_rm.forms;
|
||||||
|
|
||||||
|
import static org.alfresco.repo.security.authentication.AuthenticationUtil.runAsSystem;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -41,6 +43,7 @@ import org.alfresco.repo.forms.processor.node.FieldUtils;
|
|||||||
import org.alfresco.repo.forms.processor.node.FormFieldConstants;
|
import org.alfresco.repo.forms.processor.node.FormFieldConstants;
|
||||||
import org.alfresco.repo.i18n.StaticMessageLookup;
|
import org.alfresco.repo.i18n.StaticMessageLookup;
|
||||||
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.service.cmr.dictionary.AspectDefinition;
|
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
@@ -258,14 +261,23 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter
|
|||||||
* @param form
|
* @param form
|
||||||
* @param nodeRef
|
* @param nodeRef
|
||||||
*/
|
*/
|
||||||
protected void addTransientProperties(Form form, NodeRef nodeRef)
|
protected void addTransientProperties(Form form, final NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
if (recordService.isRecord(nodeRef))
|
if (recordService.isRecord(nodeRef))
|
||||||
{
|
{
|
||||||
addTransientPropertyField(form, TRANSIENT_DECLARED, DataTypeDefinition.BOOLEAN, recordService.isDeclared(nodeRef));
|
addTransientPropertyField(form, TRANSIENT_DECLARED, DataTypeDefinition.BOOLEAN, recordService.isDeclared(nodeRef));
|
||||||
}
|
}
|
||||||
|
|
||||||
DispositionSchedule ds = getDispositionService().getDispositionSchedule(nodeRef);
|
// Need to get the disposition schedule as the system user. See RM-1727.
|
||||||
|
DispositionSchedule ds = runAsSystem(new RunAsWork<DispositionSchedule>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public DispositionSchedule doWork()
|
||||||
|
{
|
||||||
|
return getDispositionService().getDispositionSchedule(nodeRef);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (ds != null)
|
if (ds != null)
|
||||||
{
|
{
|
||||||
String instructions = ds.getDispositionInstructions();
|
String instructions = ds.getDispositionInstructions();
|
||||||
|
@@ -42,6 +42,7 @@ import org.junit.runners.Suite.SuiteClasses;
|
|||||||
RM804Test.class,
|
RM804Test.class,
|
||||||
RM994Test.class,
|
RM994Test.class,
|
||||||
RM1039Test.class,
|
RM1039Test.class,
|
||||||
|
RM1727Test.class,
|
||||||
RM1799Test.class,
|
RM1799Test.class,
|
||||||
RM1814Test.class,
|
RM1814Test.class,
|
||||||
RM978Test.class,
|
RM978Test.class,
|
||||||
|
@@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* 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.issue;
|
||||||
|
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.forms.RecordsManagementNodeFormFilter;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||||
|
import org.alfresco.repo.forms.Form;
|
||||||
|
import org.alfresco.repo.forms.Item;
|
||||||
|
import org.alfresco.repo.forms.PropertyFieldDefinition;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.util.GUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for RM-1727
|
||||||
|
*
|
||||||
|
* @author Tatsiana Shalima
|
||||||
|
* @since 2.3
|
||||||
|
*/
|
||||||
|
public class RM1727Test extends BaseRMTestCase
|
||||||
|
{
|
||||||
|
private String myUser;
|
||||||
|
private NodeRef folder;
|
||||||
|
private NodeRef record;
|
||||||
|
private PropertyFieldDefinition declaredField;
|
||||||
|
|
||||||
|
private RecordsManagementNodeFormFilter nodeFormFilter;
|
||||||
|
private Form form;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isRecordTest()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isUserTest()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setupTestUsersImpl(NodeRef filePlan)
|
||||||
|
{
|
||||||
|
nodeFormFilter = (RecordsManagementNodeFormFilter)applicationContext.getBean("rmNodeFormFilter");
|
||||||
|
//create user
|
||||||
|
myUser = GUID.generate();
|
||||||
|
createPerson(myUser);
|
||||||
|
//give user RM Manager role
|
||||||
|
filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, myUser);
|
||||||
|
//create category > folder > record
|
||||||
|
NodeRef category = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||||
|
folder = recordFolderService.createRecordFolder(category, GUID.generate());
|
||||||
|
record = recordService.createRecordFromContent(folder, GUID.generate(), TYPE_CONTENT, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testRM1727()
|
||||||
|
{
|
||||||
|
//set read and file permissions for folder
|
||||||
|
filePlanPermissionService.setPermission(folder, myUser, RMPermissionModel.FILING);
|
||||||
|
doTestInTransaction(new Test<Void>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Void run()
|
||||||
|
{
|
||||||
|
Item item = new Item("node",folder.toString());
|
||||||
|
item.setType("rma:recordFolder");
|
||||||
|
form = new Form(item);
|
||||||
|
nodeFormFilter.afterGenerate(folder, null, null, form, null);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, myUser);
|
||||||
|
|
||||||
|
doTestInTransaction(new Test<Void>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Void run()
|
||||||
|
{
|
||||||
|
Item item = new Item("node",record.toString());
|
||||||
|
item.setType("rma:record");
|
||||||
|
form = new Form(item);
|
||||||
|
nodeFormFilter.afterGenerate(record, null, null, form, null);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, myUser);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user