Java Code Examples for org.alfresco.service.ServiceRegistry#getPersonService()
The following examples show how to use
org.alfresco.service.ServiceRegistry#getPersonService() .
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: ProcessesImplTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void setUp() throws Exception { applicationContext = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS); processes = (Processes) applicationContext.getBean(PROCESSES_BEAN_NAME); ServiceRegistry registry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); workflowService = registry.getWorkflowService(); personService = registry.getPersonService(); transaction = registry.getTransactionService().getUserTransaction(); transaction.begin(); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); AuthenticationUtil.setRunAsUser(AuthenticationUtil.getAdminUserName()); NodeRef adminUserNodeRef = personService.getPerson(AuthenticationUtil.getAdminUserName()); WorkflowDefinition workflowDefinition = findAppropriateWorkflowDefinitionId(); for (int i = 0; i < ACTIVE_WORKFLOWS_INITIAL_AMOUNT; i++) { startWorkflow(workflowDefinition, adminUserNodeRef); } }
Example 2
Source File: ActivitiScriptBase.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
protected ActivitiScriptNode getPersonNode(String runAsUser) { String userName = null; if (runAsUser != null) { userName = runAsUser; } else { userName = AuthenticationUtil.getFullyAuthenticatedUser(); } // The "System" user is a special case, which has no person object associated with it. if(userName != null && !AuthenticationUtil.SYSTEM_USER_NAME.equals(userName)) { ServiceRegistry services = getServiceRegistry(); PersonService personService = services.getPersonService(); if (personService.personExists(userName)) { NodeRef person = personService.getPerson(userName); return new ActivitiScriptNode(person, services); } } return null; }
Example 3
Source File: Node.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
protected void mapMinimalInfo(Map<QName, Serializable> nodeProps, Map<String, UserInfo> mapUserInfo, ServiceRegistry sr) { PersonService personService = sr.getPersonService(); this.name = (String)nodeProps.get(ContentModel.PROP_NAME); if (mapUserInfo == null) { // minor: save one lookup if creator & modifier are the same mapUserInfo = new HashMap<>(2); } this.createdAt = (Date)nodeProps.get(ContentModel.PROP_CREATED); this.createdByUser = lookupUserInfo((String)nodeProps.get(ContentModel.PROP_CREATOR), mapUserInfo, personService); this.modifiedAt = (Date)nodeProps.get(ContentModel.PROP_MODIFIED); this.modifiedByUser = lookupUserInfo((String)nodeProps.get(ContentModel.PROP_MODIFIER), mapUserInfo, personService); }
Example 4
Source File: ActivitiTimerExecutionTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void before() throws Exception { ServiceRegistry registry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); this.workflowService = registry.getWorkflowService(); this.authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent"); this.nodeService = registry.getNodeService(); this.transactionHelper = (RetryingTransactionHelper) this.applicationContext .getBean("retryingTransactionHelper"); this.activitiProcessEngine = (ProcessEngine) this.applicationContext.getBean("activitiProcessEngine"); MutableAuthenticationService authenticationService = registry.getAuthenticationService(); PersonService personService = registry.getPersonService(); this.personManager = new TestPersonManager(authenticationService, personService, nodeService); authenticationComponent.setSystemUserAsCurrentUser(); }
Example 5
Source File: ScriptUser.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * 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 6
Source File: PeopleTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
protected void setUp() throws Exception { MockitoAnnotations.initMocks(this); ctx = ApplicationContextHelper.getApplicationContext(); people = (People) ctx.getBean("peopleScript"); serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry"); transactionService = serviceRegistry.getTransactionService(); personService = serviceRegistry.getPersonService(); ServiceRegistry mockServiceRegistry = spy(serviceRegistry); people.setServiceRegistry(mockServiceRegistry); doReturn(mockSearchService).when(mockServiceRegistry).getSearchService(); when(mockSearchService.query(any())).thenReturn(mockResultSet); when(mockResultSet.getNodeRefs()).thenReturn(mockResultSetNodeRefs); AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); createUsers(); // Start a transaction txn = transactionService.getUserTransaction(); txn.begin(); }
Example 7
Source File: PersonServiceLoader.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
Nester(String name, Thread waiter, ApplicationContext ctx, int batchSize, int batchCount) { super(name); this.setDaemon(true); this.waiter = waiter; this.ctx = ctx; serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); personService = serviceRegistry.getPersonService(); transactionService = serviceRegistry.getTransactionService(); this.batchSize = batchSize; this.batchCount = batchCount; }
Example 8
Source File: Site.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Constructor * * @param siteInfo site information */ /*package*/ Site(SiteInfo siteInfo, ServiceRegistry serviceRegistry, SiteService siteService, Scriptable scope) { this.serviceRegistry = serviceRegistry; this.siteService = siteService; this.siteInfo = siteInfo; this.scope = scope; this.invitationService = serviceRegistry.getInvitationService(); NodeService nodeService = serviceRegistry.getNodeService(); PersonService personService = serviceRegistry.getPersonService(); this.scriptInvitationFactory = new ScriptInvitationFactory(invitationService, nodeService, personService); }
Example 9
Source File: InviteSender.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public InviteSender(ServiceRegistry services, Repository repository, MessageService messageService) { this.actionService = services.getActionService(); this.nodeService = services.getNodeService(); this.personService = services.getPersonService(); this.searchService = services.getSearchService(); this.siteService = services.getSiteService(); this.fileFolderService = services.getFileFolderService(); this.repoAdminService = services.getRepoAdminService(); this.namespaceService = services.getNamespaceService(); this.repository = repository; this.messageService = messageService; }
Example 10
Source File: AbstractCommentsWebScript.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public void setServiceRegistry(ServiceRegistry serviceRegistry) { this.serviceRegistry = serviceRegistry; this.nodeService = serviceRegistry.getNodeService(); this.siteService = serviceRegistry.getSiteService(); this.contentService = serviceRegistry.getContentService(); this.personService = serviceRegistry.getPersonService(); this.permissionService = serviceRegistry.getPermissionService(); }
Example 11
Source File: OAuth1CredentialsStoreServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void before() throws Exception { serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); transactionHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper(); authenticationService = serviceRegistry.getAuthenticationService(); personService = serviceRegistry.getPersonService(); oauth1CredentialsStoreService = (OAuth1CredentialsStoreService) applicationContext.getBean("oauth1CredentialsStoreService"); AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); createUser(TEST_USER_ONE); createUser(TEST_USER_TWO); }
Example 12
Source File: OAuth2CredentialsStoreServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void setUp() throws Exception { serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); transactionHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper(); authenticationService = serviceRegistry.getAuthenticationService(); personService = serviceRegistry.getPersonService(); oauth2CredentialsStoreService = (OAuth2CredentialsStoreService) applicationContext.getBean("oauth2CredentialsStoreService"); AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); createUser(TEST_USER_ONE); createUser(TEST_USER_TWO); }
Example 13
Source File: SubscriptionDAOTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void setUp() throws Exception { ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); transactionService = serviceRegistry.getTransactionService(); txnHelper = transactionService.getRetryingTransactionHelper(); personService = serviceRegistry.getPersonService(); subscriptionsDAO = (SubscriptionsDAO) ctx.getBean("subscriptionsDAO"); }
Example 14
Source File: AbstractWorkflowServiceIntegrationTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@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 15
Source File: ArchivedNodeState.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
public static ArchivedNodeState create(NodeRef archivedNode, ServiceRegistry serviceRegistry) { ArchivedNodeState result = new ArchivedNodeState(); NodeService nodeService = serviceRegistry.getNodeService(); Map<QName, Serializable> properties = nodeService.getProperties(archivedNode); result.archivedNodeRef = archivedNode; result.archivedBy = (String) properties.get(ContentModel.PROP_ARCHIVED_BY); result.archivedDate = (Date) properties.get(ContentModel.PROP_ARCHIVED_DATE); result.name = (String) properties.get(ContentModel.PROP_NAME); result.title = (String) properties.get(ContentModel.PROP_TITLE); result.description = (String) properties.get(ContentModel.PROP_DESCRIPTION); QName type = nodeService.getType(archivedNode); result.isContentType = (type.equals(ContentModel.TYPE_CONTENT) || serviceRegistry.getDictionaryService().isSubClass(type, ContentModel.TYPE_CONTENT)); result.nodeType = type.toPrefixString(serviceRegistry.getNamespaceService()); PersonService personService = serviceRegistry.getPersonService(); if (result.archivedBy != null && personService.personExists(result.archivedBy)) { NodeRef personNodeRef = personService.getPerson(result.archivedBy, false); Map<QName, Serializable> personProps = nodeService.getProperties(personNodeRef); result.firstName = (String) personProps.get(ContentModel.PROP_FIRSTNAME); result.lastName = (String) personProps.get(ContentModel.PROP_LASTNAME); } ChildAssociationRef originalParentAssoc = (ChildAssociationRef) properties.get(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC); if (serviceRegistry.getPermissionService().hasPermission(originalParentAssoc.getParentRef(), PermissionService.READ).equals(AccessStatus.ALLOWED) && nodeService.exists(originalParentAssoc.getParentRef())) { result.displayPath = PathUtil.getDisplayPath(nodeService.getPath(originalParentAssoc.getParentRef()), true); } else { result.displayPath = ""; } return result; }
Example 16
Source File: NodeServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@SuppressWarnings("unchecked") @BeforeClass public static void setup() throws Exception { I18NUtil.setLocale(null); serviceRegistry = (ServiceRegistry) APP_CONTEXT_INIT.getApplicationContext().getBean(ServiceRegistry.SERVICE_REGISTRY); nodeService = serviceRegistry.getNodeService(); personService = serviceRegistry.getPersonService(); contentService = serviceRegistry.getContentService(); permissionService = serviceRegistry.getPermissionService(); nodeDAO = (NodeDAO) APP_CONTEXT_INIT.getApplicationContext().getBean("nodeDAO"); txnService = serviceRegistry.getTransactionService(); policyComponent = (PolicyComponent) APP_CONTEXT_INIT.getApplicationContext().getBean("policyComponent"); cannedQueryDAOForTesting = (CannedQueryDAO) APP_CONTEXT_INIT.getApplicationContext().getBean("cannedQueryDAOForTesting"); // Get the caches for later testing nodesCache = (SimpleCache<Serializable, ValueHolder<Serializable>>) APP_CONTEXT_INIT.getApplicationContext().getBean("node.nodesSharedCache"); propsCache = (SimpleCache<Serializable, ValueHolder<Serializable>>) APP_CONTEXT_INIT.getApplicationContext().getBean("node.propertiesSharedCache"); aspectsCache = (SimpleCache<Serializable, ValueHolder<Serializable>>) APP_CONTEXT_INIT.getApplicationContext().getBean("node.aspectsSharedCache"); // Clear the caches to remove fluff nodesCache.clear(); propsCache.clear(); aspectsCache.clear(); AuthenticationUtil.setRunAsUserSystem(); // create a first store directly RetryingTransactionCallback<NodeRef> createStoreWork = new RetryingTransactionCallback<NodeRef>() { public NodeRef execute() { StoreRef storeRef = nodeService.createStore( StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.nanoTime()); return nodeService.getRootNode(storeRef); } }; rootNodeRef = txnService.getRetryingTransactionHelper().doInTransaction(createStoreWork); final QNameDAO qnameDAO = (QNameDAO) APP_CONTEXT_INIT.getApplicationContext().getBean("qnameDAO"); deletedTypeQNameId = txnService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Long>() { @Override public Long execute() throws Throwable { return qnameDAO.getOrCreateQName(ContentModel.TYPE_DELETED).getFirst(); } }); }
Example 17
Source File: DocumentLinkServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void setUp() throws Exception { ctx = ApplicationContextHelper.getApplicationContext(); // Set up the services ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry"); transactionService = serviceRegistry.getTransactionService(); documentLinkService = serviceRegistry.getDocumentLinkService(); permissionService = serviceRegistry.getPermissionService(); personService = serviceRegistry.getPersonService(); siteService = serviceRegistry.getSiteService(); fileFolderService = serviceRegistry.getFileFolderService(); nodeService = serviceRegistry.getNodeService(); cociService = serviceRegistry.getCheckOutCheckInService(); // Start the transaction txn = transactionService.getUserTransaction(); txn.begin(); // Authenticate AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); /* Create the test user */ Map<QName, Serializable> props = new HashMap<QName, Serializable>(); props.put(ContentModel.PROP_USERNAME, TEST_USER); personService.createPerson(props); /* * Create the working test root 1 to which the user has read/write * permission */ site1 = siteService.createSite("site1", GUID.generate(), "myTitle", "myDescription", SiteVisibility.PUBLIC).getNodeRef(); permissionService.setPermission(site1, TEST_USER, PermissionService.ALL_PERMISSIONS, true); site1Folder1 = fileFolderService.create(site1, site1Folder1Name, ContentModel.TYPE_FOLDER).getNodeRef(); site1File1 = fileFolderService.create(site1Folder1, site1File1Name, ContentModel.TYPE_CONTENT).getNodeRef(); site1File2 = fileFolderService.create(site1Folder1, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); site1Folder2 = fileFolderService.create(site1, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); site1Folder3 = fileFolderService.create(site1, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); // create a link of site1File1 in site1Folder3 to test regular deletion documentLinkService.createDocumentLink(site1File2, site1Folder3); /* Create the working test root 2 to which the user has no permission */ NodeRef site2 = siteService.createSite("site2", GUID.generate(), "myTitle", "myDescription", SiteVisibility.PRIVATE).getNodeRef(); permissionService.setPermission(site2, TEST_USER, PermissionService.ALL_PERMISSIONS, false); site2File = fileFolderService.create(site2, GUID.generate(), ContentModel.TYPE_CONTENT).getNodeRef(); site2Folder1 = fileFolderService.create(site2, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); site2Folder2 = fileFolderService.create(site2, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef(); // Create a link of site1File1 in site2Folder2 to test the deletion // without permission linkOfFile1Site2 = documentLinkService.createDocumentLink(site1File2, site2Folder2); }
Example 18
Source File: HiddenAspectTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Before public void setup() throws SystemException, NotSupportedException { ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry"); transactionService = serviceRegistry.getTransactionService(); nodeService = serviceRegistry.getNodeService(); fileFolderService = serviceRegistry.getFileFolderService(); authenticationService = (MutableAuthenticationService) ctx.getBean("AuthenticationService"); hiddenAspect = (HiddenAspect) ctx.getBean("hiddenAspect"); interceptor = (FilenameFilteringInterceptor) ctx.getBean("filenameFilteringInterceptor"); namespacePrefixResolver = (DictionaryNamespaceComponent) ctx.getBean("namespaceService"); cociService = (CheckOutCheckInService) ctx.getBean("checkOutCheckInService"); imapService = serviceRegistry.getImapService(); personService = serviceRegistry.getPersonService(); permissionService = serviceRegistry.getPermissionService(); imapEnabled = serviceRegistry.getImapService().getImapServerEnabled(); nodeDAO = (NodeDAO)ctx.getBean("nodeDAO"); Properties properties = (Properties) ctx.getBean("global-properties"); cmisDisableHide = Boolean.getBoolean(properties.getProperty("cmis.disable.hidden.leading.period.files")); // start the transaction txn = transactionService.getUserTransaction(); txn.begin(); username = "user" + System.currentTimeMillis(); PropertyMap testUser = new PropertyMap(); testUser.put(ContentModel.PROP_USERNAME, username); testUser.put(ContentModel.PROP_FIRSTNAME, username); testUser.put(ContentModel.PROP_LASTNAME, username); testUser.put(ContentModel.PROP_EMAIL, username + "@alfresco.com"); testUser.put(ContentModel.PROP_JOBTITLE, "jobTitle"); // authenticate AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); personService.createPerson(testUser); // create the ACEGI Authentication instance for the new user authenticationService.createAuthentication(username, username.toCharArray()); user = new AlfrescoImapUser(username + "@alfresco.com", username, username); // create a test store storeRef = nodeService .createStore(StoreRef.PROTOCOL_WORKSPACE, getName() + System.currentTimeMillis()); rootNodeRef = nodeService.getRootNode(storeRef); permissionService.setPermission(rootNodeRef, username, PermissionService.CREATE_CHILDREN, true); AuthenticationUtil.setFullyAuthenticatedUser(username); topNodeRef = nodeService.createNode( rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.ALFRESCO_URI, "working root"), ContentModel.TYPE_FOLDER).getChildRef(); AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); }
Example 19
Source File: ImapServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void setUp() throws Exception { ctx = ApplicationContextHelper.getApplicationContext(); ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry"); transactionService = serviceRegistry.getTransactionService(); nodeService = serviceRegistry.getNodeService(); importerService = serviceRegistry.getImporterService(); personService = serviceRegistry.getPersonService(); authenticationService = serviceRegistry.getAuthenticationService(); permissionService = serviceRegistry.getPermissionService(); imapService = serviceRegistry.getImapService(); searchService = serviceRegistry.getSearchService(); namespaceService = serviceRegistry.getNamespaceService(); fileFolderService = serviceRegistry.getFileFolderService(); contentService = serviceRegistry.getContentService(); flags = new Flags(); flags.add(Flags.Flag.SEEN); flags.add(Flags.Flag.FLAGGED); flags.add(Flags.Flag.ANSWERED); flags.add(Flags.Flag.DELETED); // start the transaction txn = transactionService.getUserTransaction(); txn.begin(); authenticationService.authenticate(USER_NAME, USER_PASSWORD.toCharArray()); // downgrade integrity IntegrityChecker.setWarnInTransaction(); anotherUserName = "user" + System.currentTimeMillis(); PropertyMap testUser = new PropertyMap(); testUser.put(ContentModel.PROP_USERNAME, anotherUserName); testUser.put(ContentModel.PROP_FIRSTNAME, anotherUserName); testUser.put(ContentModel.PROP_LASTNAME, anotherUserName); testUser.put(ContentModel.PROP_EMAIL, anotherUserName + "@alfresco.com"); testUser.put(ContentModel.PROP_JOBTITLE, "jobTitle"); personService.createPerson(testUser); // create the ACEGI Authentication instance for the new user authenticationService.createAuthentication(anotherUserName, anotherUserName.toCharArray()); user = new AlfrescoImapUser(anotherUserName + "@alfresco.com", anotherUserName, anotherUserName); NodeRef companyHomeNodeRef = findCompanyHomeNodeRef(); ChildApplicationContextFactory imap = (ChildApplicationContextFactory) ctx.getBean("imap"); ApplicationContext imapCtx = imap.getApplicationContext(); imapServiceImpl = (ImapServiceImpl)imapCtx.getBean("imapService"); // Creating IMAP test folder for IMAP root LinkedList<String> folders = new LinkedList<String>(); folders.add(TEST_IMAP_FOLDER_NAME); FileFolderUtil.makeFolders(fileFolderService, companyHomeNodeRef, folders, ContentModel.TYPE_FOLDER); // Setting IMAP root RepositoryFolderConfigBean imapHome = new RepositoryFolderConfigBean(); imapHome.setStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE.toString()); imapHome.setRootPath(APP_COMPANY_HOME); imapHome.setFolderPath(NamespaceService.CONTENT_MODEL_PREFIX + ":" + TEST_IMAP_FOLDER_NAME); imapServiceImpl.setImapHome(imapHome); // Starting IMAP imapServiceImpl.startupInTxn(true); NodeRef storeRootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef , APP_COMPANY_HOME + "/" + NamespaceService.CONTENT_MODEL_PREFIX + ":" + TEST_IMAP_FOLDER_NAME, null, namespaceService, false); testImapFolderNodeRef = nodeRefs.get(0); /* * Importing test folders: * * Test folder contains: "___-___folder_a" * * "___-___folder_a" contains: "___-___folder_a_a", * "___-___file_a", * "Message_485.eml" (this is IMAP Message) * * "___-___folder_a_a" contains: "____-____file_a_a" * */ importInternal("imap/imapservice_test_folder_a.acp", testImapFolderNodeRef); reauthenticate(anotherUserName, anotherUserName); }
Example 20
Source File: ScriptAuthorityService.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public void setServiceRegistry(ServiceRegistry serviceRegistry) { this.serviceRegistry = serviceRegistry; this.authorityService = serviceRegistry.getAuthorityService(); this.personService = serviceRegistry.getPersonService(); }