Java Code Examples for org.alfresco.service.ServiceRegistry#getContentService()
The following examples show how to use
org.alfresco.service.ServiceRegistry#getContentService() .
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: AuditableAspectTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void setUp() throws Exception { ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); // Set the services this.transactionService = serviceRegistry.getTransactionService(); this.nodeService = serviceRegistry.getNodeService(); this.contentService = serviceRegistry.getContentService(); this.behaviourFilter = (BehaviourFilter) ctx.getBean("policyBehaviourFilter"); AuthenticationUtil.setRunAsUserSystem(); // Create the store and get the root node reference this.storeRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); this.rootNodeRef = this.nodeService.getRootNode(storeRef); }
Example 2
Source File: DifferrentMimeTypeTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void setUp() throws Exception { ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); mimetypeService = serviceRegistry.getMimetypeService(); transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug"); transformerConfig = (TransformerConfig) ctx.getBean("transformerConfig"); registry = (ContentTransformerRegistry) ctx.getBean("contentTransformerRegistry"); transactionService = serviceRegistry.getTransactionService(); repositoryHelper = (Repository) ctx.getBean("repositoryHelper"); nodeService = serviceRegistry.getNodeService(); contentService = serviceRegistry.getContentService(); assertNotNull("MimetypeMap not present", this.mimetypeService); assertNotNull("ServiceRegistry not present", serviceRegistry); assertNotNull("TransformerDebug not present", transformerDebug); assertNotNull("TransformerConfig not present", transformerConfig); assertNotNull("transactionService not present", transactionService); assertNotNull("repositoryHelper not present", repositoryHelper); assertNotNull("nodeService not present", nodeService); assertNotNull("contentService not present", contentService); }
Example 3
Source File: RuleServiceIntegrationTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@BeforeClass public static void setupTest() throws Exception { SERVICE_REGISTRY = (ServiceRegistry)APP_CONTEXT_INIT.getApplicationContext().getBean(ServiceRegistry.SERVICE_REGISTRY); NODE_SERVICE = SERVICE_REGISTRY.getNodeService(); TRANSACTION_HELPER = SERVICE_REGISTRY.getTransactionService().getRetryingTransactionHelper(); ACTION_SERVICE = SERVICE_REGISTRY.getActionService(); RULE_SERVICE = SERVICE_REGISTRY.getRuleService(); CONTENT_SERVICE = SERVICE_REGISTRY.getContentService(); MAIL_ACTION_EXECUTER = APP_CONTEXT_INIT.getApplicationContext().getBean("OutboundSMTP", ApplicationContextFactory.class).getApplicationContext().getBean("mail", MailActionExecuter.class); WAS_IN_TEST_MODE = MAIL_ACTION_EXECUTER.isTestMode(); MAIL_ACTION_EXECUTER.setTestMode(true); Repository repositoryHelper = (Repository) APP_CONTEXT_INIT.getApplicationContext().getBean("repositoryHelper"); COMPANY_HOME = repositoryHelper.getCompanyHome(); // Create some static test content TEST_FOLDER = STATIC_TEST_NODES.createNode(COMPANY_HOME, "testFolder", ContentModel.TYPE_FOLDER, AuthenticationUtil.getAdminUserName()); }
Example 4
Source File: FileImporterTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void setUp() { ctx = ApplicationContextHelper.getApplicationContext(); serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); nodeService = serviceRegistry.getNodeService(); searchService = serviceRegistry.getSearchService(); dictionaryService = serviceRegistry.getDictionaryService(); contentService = serviceRegistry.getContentService(); authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService"); authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); permissionService = serviceRegistry.getPermissionService(); mimetypeService = serviceRegistry.getMimetypeService(); namespaceService = serviceRegistry.getNamespaceService(); transactionService = serviceRegistry.getTransactionService(); authenticationComponent.setSystemUserAsCurrentUser(); StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); rootNodeRef = nodeService.getRootNode(storeRef); }
Example 5
Source File: AbstractJodConverterBasedTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * This test relies upon customised OpenOffice.org subsystems being available. * The OOoDirect subsystem (usually enabled by default) is disabled and the * OOoJodconverter subsystem (usually disabled by default) is enabled. * @throws Exception */ @BeforeClass public static void initServicesAndRestartOOoSubsystems() throws Exception { if (log.isDebugEnabled()) { log.debug("initServicesAndRestartOOoSubsystems"); } repositoryHelper = (Repository) ctx.getBean("repositoryHelper"); serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); contentService = serviceRegistry.getContentService(); nodeService = serviceRegistry.getNodeService(); thumbnailService = serviceRegistry.getThumbnailService(); transactionService = serviceRegistry.getTransactionService(); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); oooJodcSubsystem = (ChildApplicationContextFactory) ctx.getBean("OOoJodconverter"); // Stop the OOoJodconverter subsystem and restart it with test settings i.e. enabled. // Also a pool of 3 JodConverter instances, just for fun. if (log.isDebugEnabled()) { log.debug("Enabling OOoJodconverter"); } oooJodcSubsystem.stop(); oooJodcSubsystem.setProperty("jodconverter.enabled", "true"); oooJodcSubsystem.setProperty("jodconverter.portNumbers", "2022, 2023, 2024"); oooJodcSubsystem.start(); }
Example 6
Source File: RuleTriggerTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void before() throws Exception { ServiceRegistry serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); this.nodeService = serviceRegistry.getNodeService(); this.contentService = serviceRegistry.getContentService(); AuthenticationUtil.setRunAsUser(AuthenticationUtil.getSystemUserName()); this.testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); this.rootNodeRef = this.nodeService.getRootNode(this.testStoreRef); }
Example 7
Source File: AbstractTenantRoutingContentStoreTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void setUp() throws Exception { AuthenticationUtil.setRunAsUserSystem(); serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry"); contentService = serviceRegistry.getContentService(); fileContentStore = (AbstractTenantRoutingContentStore) ctx.getBean("fileContentStore"); }
Example 8
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 9
Source File: RenditionServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Injects the ServiceRegistry bean. * @param serviceRegistry ServiceRegistry */ public void setServiceRegistry(ServiceRegistry serviceRegistry) { this.contentService = serviceRegistry.getContentService(); this.nodeService = serviceRegistry.getNodeService(); }
Example 10
Source File: FFCLoadsOfFiles.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public static void doExample(ServiceRegistry serviceRegistry) throws Exception { // // locate the company home node // SearchService searchService = serviceRegistry.getSearchService(); NodeService nodeService = serviceRegistry.getNodeService(); NamespaceService namespaceService = serviceRegistry.getNamespaceService(); StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); NodeRef rootNodeRef = nodeService.getRootNode(storeRef); List<NodeRef> results = searchService.selectNodes(rootNodeRef, "/app:company_home", null, namespaceService, false); if (results.size() == 0) { throw new AlfrescoRuntimeException("Can't find /app:company_home"); } NodeRef companyHomeNodeRef = results.get(0); results = searchService.selectNodes(companyHomeNodeRef, "./cm:LoadTest", null, namespaceService, false); final NodeRef loadTestHome; if (results.size() == 0) { loadTestHome = nodeService.createNode( companyHomeNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "LoadTest"), ContentModel.TYPE_FOLDER).getChildRef(); } else { loadTestHome = results.get(0); } if ((currentDoc + docsPerTx) > totalNumDocs) { docsPerTx = totalNumDocs - currentDoc; } // Create new Space String spaceName = "Bulk Load Space (" + System.currentTimeMillis() + ") from " + currentDoc + " to " + (currentDoc + docsPerTx - 1) + " of " + totalNumDocs; Map<QName, Serializable> spaceProps = new HashMap<QName, Serializable>(); spaceProps.put(ContentModel.PROP_NAME, spaceName); NodeRef newSpace = nodeService.createNode(loadTestHome, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, spaceName),ContentModel.TYPE_FOLDER,spaceProps).getChildRef(); // create new content node within new Space home for (int k = 1;k<=docsPerTx;k++) { currentDoc++; System.out.println("About to start document " + currentDoc); // assign name String name = "BulkLoad (" + System.currentTimeMillis() + ") " + currentDoc ; Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>(); contentProps.put(ContentModel.PROP_NAME, name); // create content node // NodeService nodeService = serviceRegistry.getNodeService(); ChildAssociationRef association = nodeService.createNode(newSpace, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, name), ContentModel.TYPE_CONTENT, contentProps); NodeRef content = association.getChildRef(); // add titled aspect (for Web Client display) Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(); titledProps.put(ContentModel.PROP_TITLE, name); titledProps.put(ContentModel.PROP_DESCRIPTION, name); nodeService.addAspect(content, ContentModel.ASPECT_TITLED, titledProps); // // write some content to new node // ContentService contentService = serviceRegistry.getContentService(); ContentWriter writer = contentService.getWriter(content, ContentModel.PROP_CONTENT, true); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); writer.setEncoding("UTF-8"); String text = "This is some text in a doc"; writer.putContent(text); System.out.println("About to get child assocs "); //Circa // nodeService.getChildAssocs(newSpace); for (int count=0;count<=10000;count++) { nodeService.getChildAssocs(newSpace); } } //doSearch(searchService); System.out.println("About to end transaction " ); }
Example 11
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 12
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 13
Source File: VirtualizationIntegrationTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Before public void setUp() throws Exception { ctx = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS);; virtualizationConfigTestBootstrap = ctx.getBean(VIRTUALIZATION_CONFIG_TEST_BOOTSTRAP_BEAN_ID, VirtualizationConfigTestBootstrap.class); // Get the required services ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry"); transactionService = serviceRegistry.getTransactionService(); retryingTransactionHelper = serviceRegistry.getRetryingTransactionHelper(); nodeService = serviceRegistry.getNodeService(); contentService = serviceRegistry.getContentService(); fileAndFolderService = serviceRegistry.getFileFolderService(); permissionService = serviceRegistry.getPermissionService(); authenticationComponent = ctx.getBean("authenticationComponent", AuthenticationComponent.class); environment = ctx.getBean("actualEnvironment", ActualEnvironment.class); typeAndAspectsFormProcessor = ctx.getBean("typeAndAspectsFormProcessor", TypeAndAspectsFormProcessor.class); constraints = ctx.getBean("systemTemplateLocations", SystemTemplateLocationsConstraint.class); Repository repository = ctx.getBean("repositoryHelper", Repository.class); if (!virtualizationConfigTestBootstrap.areVirtualFoldersEnabled()) { // "use the force" and enable virtual folders SpringExtensionBundle vfBundle = ctx.getBean("smartFoldersBundle", SpringExtensionBundle.class); vfBundle.start(); } else { logger.info("Virtual folders are spring-enabled."); } this.authenticationComponent.setSystemUserAsCurrentUser(); // start the transaction txn = transactionService.getUserTransaction(); txn.begin(); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); companyHomeNodeRef = repository.getCompanyHome(); testRootFolder = fileAndFolderService.create(companyHomeNodeRef, TEST_ROOT_FOLDER_NAME, ContentModel.TYPE_FOLDER); virtualFolder1NodeRef = createVirtualizedFolder(testRootFolder.getNodeRef(), VIRTUAL_FOLDER_1_NAME, TEST_TEMPLATE_1_JSON_SYS_PATH); rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); setupMocks(); }
Example 14
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(); } }); }