RM-2192 (User has no access to the recorded document after it was filed)

+review RM @rwetherall

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.2.1.x@102687 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2015-04-25 13:51:08 +00:00
parent dc4d19240c
commit 04996533fd
3 changed files with 188 additions and 11 deletions

View File

@@ -18,6 +18,10 @@
*/ */
package org.alfresco.module.org_alfresco_module_rm.jscript.app; package org.alfresco.module.org_alfresco_module_rm.jscript.app;
import static org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel.READ_RECORDS;
import static org.alfresco.repo.security.authentication.AuthenticationUtil.runAsSystem;
import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -341,17 +345,20 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
rmNodeValues.put("kind", kind.toString()); rmNodeValues.put("kind", kind.toString());
// File plan node reference // File plan node reference
NodeRef filePlan = filePlanService.getFilePlan(nodeRef); NodeRef filePlan = getFilePlan(nodeRef);
rmNodeValues.put("filePlan", filePlan.toString()); if (permissionService.hasPermission(filePlan, READ_RECORDS).equals(ALLOWED))
// Unfiled container node reference
NodeRef unfiledRecordContainer = filePlanService.getUnfiledContainer(filePlan);
if (unfiledRecordContainer != null)
{ {
rmNodeValues.put("unfiledRecordContainer", unfiledRecordContainer.toString()); rmNodeValues.put("filePlan", filePlan.toString());
rmNodeValues.put("properties", propertiesToJSON(unfiledRecordContainer, nodeService.getProperties(unfiledRecordContainer), useShortQName));
QName type = fileFolderService.getFileInfo(unfiledRecordContainer).getType(); // Unfiled container node reference
rmNodeValues.put("type", useShortQName ? type.toPrefixString(namespaceService) : type.toString()); NodeRef unfiledRecordContainer = filePlanService.getUnfiledContainer(filePlan);
if (unfiledRecordContainer != null)
{
rmNodeValues.put("unfiledRecordContainer", unfiledRecordContainer.toString());
rmNodeValues.put("properties", propertiesToJSON(unfiledRecordContainer, nodeService.getProperties(unfiledRecordContainer), useShortQName));
QName type = fileFolderService.getFileInfo(unfiledRecordContainer).getType();
rmNodeValues.put("type", useShortQName ? type.toPrefixString(namespaceService) : type.toString());
}
} }
// Set the indicators array // Set the indicators array
@@ -363,6 +370,23 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JSONC
return rmNodeValues; return rmNodeValues;
} }
/**
* Helper method to get the file plan as a system user for the given node
*
* @param nodeRef The node reference
* @return The file plan where the node is in
*/
private NodeRef getFilePlan(final NodeRef nodeRef)
{
return runAsSystem(new RunAsWork<NodeRef>()
{
public NodeRef doWork()
{
return filePlanService.getFilePlan(nodeRef);
}
});
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void setIndicators(JSONObject rmNodeValues, NodeRef nodeRef) private void setIndicators(JSONObject rmNodeValues, NodeRef nodeRef)
{ {

View File

@@ -43,7 +43,8 @@ import org.junit.runners.Suite.SuiteClasses;
RM994Test.class, RM994Test.class,
RM1039Test.class, RM1039Test.class,
RM1799Test.class, RM1799Test.class,
RM2190Test.class RM2190Test.class,
RM2192Test.class
}) })
public class IssueTestSuite public class IssueTestSuite
{ {

View File

@@ -0,0 +1,152 @@
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
import static org.alfresco.repo.site.SiteModel.SITE_MANAGER;
import static org.alfresco.repo.site.SiteServiceImpl.getSiteContainer;
import static org.alfresco.service.cmr.rule.RuleType.INBOUND;
import static org.alfresco.service.cmr.security.AccessStatus.ALLOWED;
import static org.alfresco.service.cmr.site.SiteService.DOCUMENT_LIBRARY;
import static org.alfresco.service.cmr.site.SiteVisibility.PUBLIC;
import static org.alfresco.util.GUID.generate;
import org.alfresco.module.org_alfresco_module_rm.action.dm.CreateRecordAction;
import org.alfresco.module.org_alfresco_module_rm.action.impl.FileToAction;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
import org.alfresco.repo.jscript.app.JSONConversionComponent;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.rule.Rule;
import org.alfresco.service.cmr.rule.RuleService;
/**
* Integration test for RM-2192
*
* @author Tuna Aksoy
* @since 2.2.1.1
*/
public class RM2192Test extends BaseRMTestCase
{
private static final String PATH = "/111/222/333";
private RuleService ruleService;
private JSONConversionComponent converter;
private NodeRef folder;
private String user;
private NodeRef documentLibrary2;
@Override
protected void initServices()
{
super.initServices();
ruleService = (RuleService) applicationContext.getBean("RuleService");
converter = (JSONConversionComponent) applicationContext.getBean("jsonConversionComponent");
}
@Override
protected boolean isCollaborationSiteTest()
{
return true;
}
@Override
protected boolean isRecordTest()
{
return true;
}
@Override
protected boolean isUserTest()
{
return true;
}
@Override
protected void setupCollaborationSiteTestDataImpl()
{
super.setupCollaborationSiteTestDataImpl();
String collabSiteId2 = generate();
siteService.createSite("site-dashboard", collabSiteId2, generate(), generate(), PUBLIC);
documentLibrary2 = getSiteContainer(
collabSiteId2,
DOCUMENT_LIBRARY,
true,
siteService,
transactionService,
taggingService);
assertNotNull("Collaboration site document library component was not successfully created.", documentLibrary2);
user = generate();
createPerson(user);
siteService.setMembership(collabSiteId2, user, SITE_MANAGER);
}
public void testAccessToRecordAfterDeclaring()
{
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
folder = fileFolderService.create(documentLibrary2, generate(), TYPE_FOLDER).getNodeRef();
Action createAction = actionService.createAction(CreateRecordAction.NAME);
createAction.setParameterValue(CreateRecordAction.PARAM_FILE_PLAN, filePlan);
Rule declareRule = new Rule();
declareRule.setRuleType(INBOUND);
declareRule.setTitle(generate());
declareRule.setAction(createAction);
declareRule.setExecuteAsynchronously(true);
declareRule.applyToChildren(true);
ruleService.saveRule(folder, declareRule);
Action fileAction = actionService.createAction(FileToAction.NAME);
fileAction.setParameterValue(FileToAction.PARAM_PATH, PATH);
fileAction.setParameterValue(FileToAction.PARAM_CREATE_RECORD_PATH, true);
Rule fileRule = new Rule();
fileRule.setRuleType(INBOUND);
fileRule.setTitle(generate());
fileRule.setAction(fileAction);
fileRule.setExecuteAsynchronously(true);
ruleService.saveRule(unfiledContainer, fileRule);
return null;
}
@Override
public void test(Void result) throws Exception
{
assertFalse(ruleService.getRules(folder).isEmpty());
assertFalse(ruleService.getRules(unfiledContainer).isEmpty());
}
});
doTestInTransaction(new Test<Void>()
{
NodeRef document;
@Override
public Void run()
{
document = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef();
return null;
}
@Override
public void test(Void result) throws InterruptedException
{
Thread.sleep(10000);
assertEquals(permissionService.hasPermission(document, READ_RECORDS), ALLOWED);
assertTrue(recordService.isFiled(document));
assertNotNull(converter.toJSON(document, true));
}
}, user);
}
}