use of org.alfresco.module.org_alfresco_module_rm.role.Role in project records-management by Alfresco.
the class RMv22RemoveInPlaceRolesFromAllPatchUnitTest method getMockedRole.
/**
* Helper method to create a mocked role.
*/
private Role getMockedRole(String name) {
Role mockedRole = mock(Role.class);
doReturn(name).when(mockedRole).getRoleGroupName();
return mockedRole;
}
use of org.alfresco.module.org_alfresco_module_rm.role.Role in project records-management by Alfresco.
the class NotificationServiceHelperSystemTest method setupTestData.
@Override
protected void setupTestData() {
super.setupTestData();
retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<Object>() {
@Override
public Object execute() throws Throwable {
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
// Create a user
userName = GUID.generate();
authenticationService.createAuthentication(userName, "".toCharArray());
PropertyMap props = new PropertyMap();
props.put(PROP_USERNAME, userName);
props.put(PROP_FIRSTNAME, "Test");
props.put(PROP_LASTNAME, "User");
props.put(PROP_EMAIL, EMAIL_ADDRESS);
person = personService.createPerson(props);
// Find the authority for the given role
Role role = filePlanRoleService.getRole(filePlan, NOTIFICATION_ROLE);
assertNotNull("Notification role could not be retrieved", role);
String roleGroup = role.getRoleGroupName();
assertNotNull("Notification role group can not be null.", roleGroup);
// Add user to notification role group
authorityService.addAuthority(roleGroup, userName);
return null;
}
});
}
use of org.alfresco.module.org_alfresco_module_rm.role.Role in project records-management by Alfresco.
the class UserAndGroupsUtils method addUserToRole.
/**
* Add a user to an RM role
*
* @param userName the username of the user to add to the role
* @param role the role to add the user to
*/
public void addUserToRole(NodeRef filePlan, String userName, RMRole role) {
// Find the authority for the given role
Role roleObj = filePlanRoleService.getRole(filePlan, role.getGroupName());
assertNotNull("Notification role " + role.getGroupName() + " could not be retrieved", roleObj);
String roleGroup = roleObj.getRoleGroupName();
assertNotNull("Notification role group " + roleGroup + " can not be null.", roleGroup);
// Add user to notification role group
authorityService.addAuthority(roleGroup, userName);
}
use of org.alfresco.module.org_alfresco_module_rm.role.Role in project records-management by Alfresco.
the class DataSetServiceImpl method patchLoadedData.
/**
* Temp method to patch AMP'ed data
*/
private void patchLoadedData() {
AuthenticationUtil.RunAsWork<Object> runAsWork = new AuthenticationUtil.RunAsWork<Object>() {
public Object doWork() {
Set<NodeRef> rmRoots = filePlanService.getFilePlans();
logger.info("Bootstraping " + rmRoots.size() + " rm roots ...");
for (NodeRef rmRoot : rmRoots) {
if (permissionService.getInheritParentPermissions(rmRoot)) {
logger.info("Updating permissions for rm root: " + rmRoot);
permissionService.setInheritParentPermissions(rmRoot, false);
}
String allRoleShortName = RMAuthority.ALL_ROLES_PREFIX + rmRoot.getId();
String allRoleGroupName = authorityService.getName(AuthorityType.GROUP, allRoleShortName);
if (!authorityService.authorityExists(allRoleGroupName)) {
logger.info("Creating all roles group for root node: " + rmRoot.toString());
// Create "all" role group for root node
String allRoles = authorityService.createAuthority(AuthorityType.GROUP, allRoleShortName, RMAuthority.ALL_ROLES_DISPLAY_NAME, new HashSet<String>(Arrays.asList(RMAuthority.ZONE_APP_RM)));
// Put all the role groups in it
Set<Role> roles = filePlanRoleService.getRoles(rmRoot);
for (Role role : roles) {
logger.info(" - adding role group " + role.getRoleGroupName() + " to all roles group");
authorityService.addAuthority(allRoles, role.getRoleGroupName());
}
// Set the permissions
permissionService.setPermission(rmRoot, allRoles, RMPermissionModel.READ_RECORDS, true);
}
}
// Make sure all the containers do not inherit permissions
ResultSet rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_FTS_ALFRESCO, "TYPE:\"rma:recordsManagementContainer\"");
try {
logger.info("Bootstraping " + rs.length() + " record containers ...");
for (NodeRef container : rs.getNodeRefs()) {
String containerName = (String) nodeService.getProperty(container, ContentModel.PROP_NAME);
// Set permissions
if (permissionService.getInheritParentPermissions(container)) {
logger.info("Updating permissions for record container: " + containerName);
permissionService.setInheritParentPermissions(container, false);
}
}
} finally {
rs.close();
}
// fix up the test dataset to fire initial events for
// disposition
// schedules
rs = searchService.query(SPACES_STORE, SearchService.LANGUAGE_FTS_ALFRESCO, "TYPE:\"rma:recordFolder\"");
try {
logger.info("Bootstraping " + rs.length() + " record folders ...");
for (NodeRef recordFolder : rs.getNodeRefs()) {
String folderName = (String) nodeService.getProperty(recordFolder, ContentModel.PROP_NAME);
// Set permissions
if (permissionService.getInheritParentPermissions(recordFolder)) {
logger.info("Updating permissions for record folder: " + folderName);
permissionService.setInheritParentPermissions(recordFolder, false);
}
if (!nodeService.hasAspect(recordFolder, ASPECT_DISPOSITION_LIFECYCLE)) {
// See if the folder has a disposition schedule that
// needs
// to be applied
DispositionSchedule ds = dispositionService.getDispositionSchedule(recordFolder);
if (ds != null) {
// Fire action to "set-up" the folder correctly
logger.info("Setting up bootstraped record folder: " + folderName);
recordFolderService.setupRecordFolder(recordFolder);
}
}
// fixup the search behaviour aspect for the record
// folder
logger.info("Setting up search aspect for record folder: " + folderName);
recordsManagementSearchBehaviour.fixupSearchAspect(recordFolder);
}
} finally {
rs.close();
}
return null;
}
};
AuthenticationUtil.runAs(runAsWork, AuthenticationUtil.getAdminUserName());
}
use of org.alfresco.module.org_alfresco_module_rm.role.Role in project records-management by Alfresco.
the class RmRolesGet method executeImpl.
/**
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
*/
@Override
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
Map<String, Object> model = new HashMap<String, Object>();
Set<Role> roles = null;
// get the file plan
NodeRef filePlan = getFilePlan(req);
if (filePlan == null) {
throw new WebScriptException(Status.STATUS_FOUND, "File plan does not exist.");
}
// get the includesystem parameter
boolean includeSystem = false;
String includeSystemValue = req.getParameter("is");
if (includeSystemValue != null && includeSystemValue.length() != 0) {
includeSystem = Boolean.parseBoolean(includeSystemValue);
}
// get the user filter
String user = req.getParameter("user");
if (user != null && user.length() != 0) {
roles = filePlanRoleService.getRolesByUser(filePlan, user, includeSystem);
} else {
roles = filePlanRoleService.getRoles(filePlan, includeSystem);
}
// get the auths parameter
boolean showAuths = false;
String auths = req.getParameter("auths");
if (auths != null && auths.length() != 0) {
showAuths = Boolean.parseBoolean(auths);
}
Set<RoleItem> items = createRoleItems(filePlan, roles, showAuths);
model.put("roles", items);
return model;
}
Aggregations