Java Code Examples for org.alfresco.service.ServiceRegistry#getImapService()
The following examples show how to use
org.alfresco.service.ServiceRegistry#getImapService() .
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: AbstractMimeMessage.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
protected void buildMessage(FileInfo fileInfo, ServiceRegistry serviceRegistry) throws MessagingException { checkParameter(serviceRegistry, "ServiceRegistry"); this.content = null; this.serviceRegistry = serviceRegistry; this.imapService = serviceRegistry.getImapService(); this.messageFileInfo = fileInfo; this.isMessageInSitesLibrary = imapService.getNodeSiteContainer(messageFileInfo.getNodeRef()) != null ? true : false; RetryingTransactionHelper txHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper(); txHelper.setMaxRetries(MAX_RETRIES); txHelper.setReadOnly(false); txHelper.doInTransaction(new RetryingTransactionCallback<Object>() { public Object execute() throws Throwable { buildMessageInternal(); return null; } }, false); }
Example 2
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 3
Source File: ImapServiceImplCacheTest.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"); nodeService = serviceRegistry.getNodeService(); authenticationService = serviceRegistry.getAuthenticationService(); imapService = serviceRegistry.getImapService(); searchService = serviceRegistry.getSearchService(); namespaceService = serviceRegistry.getNamespaceService(); fileFolderService = serviceRegistry.getFileFolderService(); contentService = serviceRegistry.getContentService(); authenticationService.authenticate(USER_NAME, USER_PASSWORD.toCharArray()); String storePath = "workspace://SpacesStore"; String companyHomePathInStore = "/app:company_home"; StoreRef storeRef = new StoreRef(storePath); NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef); List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, companyHomePathInStore, null, namespaceService, false); NodeRef companyHomeNodeRef = nodeRefs.get(0); ChildApplicationContextFactory imap = (ChildApplicationContextFactory) ctx.getBean("imap"); ApplicationContext imapCtx = imap.getApplicationContext(); final ImapServiceImpl imapServiceImpl = (ImapServiceImpl)imapCtx.getBean("imapService"); // Creating IMAP test folder for IMAP root LinkedList<String> folders = new LinkedList<String>(); folders.add(TEST_IMAP_FOLDER_NAME); FileInfo folder = FileFolderUtil.makeFolders(fileFolderService, companyHomeNodeRef, folders, ContentModel.TYPE_FOLDER); oldFile = fileFolderService.create(folder.getNodeRef(), "oldFile", ContentModel.TYPE_CONTENT); // Setting IMAP root RepositoryFolderConfigBean imapHome = new RepositoryFolderConfigBean(); imapHome.setStore(storePath); imapHome.setRootPath(companyHomePathInStore); imapHome.setFolderPath(NamespaceService.CONTENT_MODEL_PREFIX + ":" + TEST_IMAP_FOLDER_NAME); imapServiceImpl.setImapHome(imapHome); // Starting IMAP imapServiceImpl.startupInTxn(true); nodeRefs = searchService.selectNodes(storeRootNodeRef, companyHomePathInStore + "/" + NamespaceService.CONTENT_MODEL_PREFIX + ":" + TEST_IMAP_FOLDER_NAME, null, namespaceService, false); testImapFolderNodeRef = nodeRefs.get(0); }
Example 4
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(); }