Java Code Examples for org.alfresco.service.ServiceRegistry#getAuthorityService()

The following examples show how to use org.alfresco.service.ServiceRegistry#getAuthorityService() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScriptUser.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Constructs a scriptable object representing a user.
 * 
 * @param userName The username
 * @param personNodeRef The NodeRef
 * @param serviceRegistry A ServiceRegistry instance
 * @param scope Script scope
 * @since 4.0
 */
public ScriptUser(String userName, NodeRef personNodeRef, ServiceRegistry serviceRegistry, Scriptable scope)
{
   this.serviceRegistry = serviceRegistry;
   this.authorityService = serviceRegistry.getAuthorityService();
   this.personService = serviceRegistry.getPersonService();
   this.scope = scope;
   this.personNodeRef = personNodeRef == null ? personService.getPerson(userName) : personNodeRef;
   this.userName = userName;
   
   this.shortName = authorityService.getShortName(userName);
   NodeService nodeService = serviceRegistry.getNodeService();
   String firstName = (String)nodeService.getProperty(this.personNodeRef, ContentModel.PROP_FIRSTNAME);
   String lastName = (String)nodeService.getProperty(this.personNodeRef, ContentModel.PROP_LASTNAME);
   this.displayName = this.fullName = (firstName != null ? firstName : "") + (lastName != null ? (' ' + lastName) : "");
}
 
Example 2
Source File: ScriptAuthorityService.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setServiceRegistry(ServiceRegistry serviceRegistry)
{
   this.serviceRegistry = serviceRegistry;
   this.authorityService = serviceRegistry.getAuthorityService();
   this.personService = serviceRegistry.getPersonService();
}
 
Example 3
Source File: AbstractWorkflowServiceIntegrationTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Before
public void before() throws Exception
{
    serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
    this.workflowService = serviceRegistry.getWorkflowService();
    this.authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
    this.nodeService = serviceRegistry.getNodeService();
    this.historyService = (HistoryService) applicationContext.getBean("activitiHistoryService");
    Repository repositoryHelper = (Repository) applicationContext.getBean("repositoryHelper");
    this.companyHome = repositoryHelper.getCompanyHome();
    try
    {
        this.transactionService = (TransactionServiceImpl) serviceRegistry.getTransactionService();
    }
    catch (ClassCastException e)
    {
        throw new AlfrescoRuntimeException("The AbstractWorkflowServiceIntegrationTest needs direct access to the TransactionServiceImpl");
    }

    MutableAuthenticationService authenticationService = serviceRegistry.getAuthenticationService();
    AuthorityService authorityService = serviceRegistry.getAuthorityService();
    PersonService personService = serviceRegistry.getPersonService();

    authenticationComponent.setSystemUserAsCurrentUser();

    WorkflowAdminServiceImpl workflowAdminService = (WorkflowAdminServiceImpl) applicationContext.getBean(WorkflowAdminServiceImpl.NAME);
    this.wfTestHelper = new WorkflowTestHelper(workflowAdminService, getEngine(), true);
    
    // create test users
    this.personManager = new TestPersonManager(authenticationService, personService, nodeService);
    this.groupManager = new TestGroupManager(authorityService);
    
    personManager.createPerson(USER1);
    personManager.createPerson(USER2);
    personManager.createPerson(USER3);
    personManager.createPerson(USER4);

    // create test groups
    groupManager.addGroupToParent(GROUP, SUB_GROUP);
    
    // add users to groups
    groupManager.addUserToGroup(GROUP, USER1);
    groupManager.addUserToGroup(SUB_GROUP, USER2);
    
    personManager.setUser(USER1);
}
 
Example 4
Source File: ScriptGroup.java    From alfresco-repository with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * New script group
 * @param fullName String
 * @param displayName String
 * @param serviceRegistry ServiceRegistry
 * @param scope Scriptable
 */
public ScriptGroup(String fullName, String displayName, ServiceRegistry serviceRegistry, Scriptable scope)
{
   this(fullName, displayName, serviceRegistry, serviceRegistry.getAuthorityService(), scope);
}
 
Example 5
Source File: ScriptGroup.java    From alfresco-repository with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * New script group
 * @param fullName String
 * @param serviceRegistry ServiceRegistry
 * @param scope Scriptable
 */
public ScriptGroup(String fullName, ServiceRegistry serviceRegistry, Scriptable scope)
{
   this(fullName, null, serviceRegistry, serviceRegistry.getAuthorityService(), scope);
}