Java Code Examples for org.alfresco.service.ServiceRegistry#getNamespaceService()
The following examples show how to use
org.alfresco.service.ServiceRegistry#getNamespaceService() .
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: FileFolderPerformanceTester.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); retryingTransactionHelper = (RetryingTransactionHelper) ctx.getBean("retryingTransactionHelper"); authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); fileFolderService = serviceRegistry.getFileFolderService(); searchService = serviceRegistry.getSearchService(); namespaceService = serviceRegistry.getNamespaceService(); nodeService = getNodeService(); authenticate(USERNAME); rootFolderRef = getOrCreateRootFolder(); dataFile = AbstractContentTransformerTest.loadQuickTestFile("txt"); }
Example 2
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 3
Source File: SOLRTrackingComponentTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void before() throws Exception { ServiceRegistry serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); transactionService = serviceRegistry.getTransactionService(); txnHelper = transactionService.getRetryingTransactionHelper(); solrTrackingComponent = (SOLRTrackingComponent) applicationContext.getBean("solrTrackingComponent"); nodeDAO = (NodeDAO)applicationContext.getBean("nodeDAO"); qnameDAO = (QNameDAO) applicationContext.getBean("qnameDAO"); dictionaryDAO = (DictionaryDAO)applicationContext.getBean("dictionaryDAO"); nodeService = (NodeService)applicationContext.getBean("NodeService"); fileFolderService = (FileFolderService)applicationContext.getBean("FileFolderService"); dictionaryService = serviceRegistry.getDictionaryService(); namespaceService = serviceRegistry.getNamespaceService(); authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent"); dbNodeService = (DbNodeServiceImpl)applicationContext.getBean("dbNodeService"); dbNodeService.setEnableTimestampPropagation(false); authenticationComponent.setSystemUserAsCurrentUser(); storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, getName() + System.currentTimeMillis()); rootNodeRef = nodeService.getRootNode(storeRef); }
Example 4
Source File: SOLRWebScriptTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected void setUp() throws Exception { super.setUp(); ctx = getServer().getApplicationContext(); ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); transactionService = serviceRegistry.getTransactionService(); nodeService = serviceRegistry.getNodeService(); fileFolderService = serviceRegistry.getFileFolderService(); namespaceService = serviceRegistry.getNamespaceService(); txnHelper = transactionService.getRetryingTransactionHelper(); nodeDAO = (NodeDAO)ctx.getBean("nodeDAO"); solrTrackingComponent = (SOLRTrackingComponent) ctx.getBean("solrTrackingComponent"); admin = AuthenticationUtil.getAdminUserName(); AuthenticationUtil.setFullyAuthenticatedUser(admin); storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, getName() + ".1." + System.currentTimeMillis()); rootNodeRef = nodeService.getRootNode(storeRef); }
Example 5
Source File: JscriptWorkflowTask.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Creates a new instance of a workflow task from a WorkflowTask from the CMR workflow object model * * @param task * an instance of WorkflowTask from CMR workflow object model * @param serviceRegistry * Service Registry object */ public JscriptWorkflowTask(WorkflowTask task, ServiceRegistry serviceRegistry, Scriptable scope) { this.serviceRegistry = serviceRegistry; this.namespaceProvider = new DefaultNamespaceProvider(serviceRegistry.getNamespaceService()); this.workflowService = serviceRegistry.getWorkflowService(); this.nodeService = serviceRegistry.getNodeService(); this.dictionaryService = serviceRegistry.getDictionaryService(); this.authenticationService = serviceRegistry.getAuthenticationService(); this.task = task; this.setScope(scope); }
Example 6
Source File: ScriptAction.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Construct * * @param action * Alfresco action */ public ScriptAction(ServiceRegistry services, Action action, ActionDefinition actionDef) { this.services = services; this.actionService = services.getActionService(); this.namespaceService = services.getNamespaceService(); this.transactionService = services.getTransactionService(); this.action = action; this.actionDef = actionDef; this.converter = new ActionValueConverter(); }
Example 7
Source File: ContentAwareScriptableQNameMap.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Constructor * * @param factory Factory to provide further ScriptNode objects * @param services ServiceRegistry */ public ContentAwareScriptableQNameMap(final ScriptNode factory, final ServiceRegistry services) { super(new NamespacePrefixResolverProvider(){ public NamespacePrefixResolver getNamespacePrefixResolver() { return services.getNamespaceService(); } }); this.services = services; this.factory = factory; }
Example 8
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 9
Source File: TransactionCleanupTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") @Before public void before() { ServiceRegistry serviceRegistry = (ServiceRegistry)ctx.getBean("ServiceRegistry"); NamespaceService namespaceService = serviceRegistry.getNamespaceService(); this.transactionService = serviceRegistry.getTransactionService(); this.authenticationService = (MutableAuthenticationService)ctx.getBean("authenticationService"); this.nodeService = serviceRegistry.getNodeService(); this.searchService = serviceRegistry.getSearchService(); this.nodeDAO = (NodeDAO)ctx.getBean("nodeDAO"); this.nodesCache = (SimpleCache<Serializable, Serializable>) ctx.getBean("node.nodesSharedCache"); this.worker = (DeletedNodeCleanupWorker)ctx.getBean("nodeCleanup.deletedNodeCleanup"); this.worker.setMinPurgeAgeDays(0); this.helper = transactionService.getRetryingTransactionHelper(); authenticationService.authenticate("admin", "admin".toCharArray()); StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); NodeRef storeRoot = nodeService.getRootNode(storeRef); List<NodeRef> nodeRefs = searchService.selectNodes( storeRoot, "/app:company_home", null, namespaceService, false); final NodeRef companyHome = nodeRefs.get(0); RetryingTransactionHelper.RetryingTransactionCallback<NodeRef> createNode = new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>() { @Override public NodeRef execute() throws Throwable { return nodeService.createNode(companyHome, ContentModel.ASSOC_CONTAINS, QName.createQName("test", GUID.generate()), ContentModel.TYPE_CONTENT).getChildRef(); } }; this.nodeRef1 = helper.doInTransaction(createNode, false, true); this.nodeRef2 = helper.doInTransaction(createNode, false, true); this.nodeRef3 = helper.doInTransaction(createNode, false, true); this.nodeRef4 = helper.doInTransaction(createNode, false, true); this.nodeRef5 = helper.doInTransaction(createNode, false, true); }
Example 10
Source File: FilesystemBulkImportItemVersion.java From alfresco-bulk-import with Apache License 2.0 | 5 votes |
public FilesystemBulkImportItemVersion(final ServiceRegistry serviceRegistry, final ContentStore configuredContentStore, final MetadataLoader metadataLoader, final BigDecimal versionNumber, final File contentFile, final File metadataFile) { super(calculateType(metadataLoader, contentFile, metadataFile, ContentModel.TYPE_FOLDER.toPrefixString(serviceRegistry.getNamespaceService()), ContentModel.TYPE_CONTENT.toPrefixString(serviceRegistry.getNamespaceService())), versionNumber); this.mimeTypeService = serviceRegistry.getMimetypeService(); this.namespaceService = serviceRegistry.getNamespaceService(); this.configuredContentStore = configuredContentStore; this.metadataLoader = metadataLoader; this.contentReference = contentFile; this.metadataReference = metadataFile; // "stat" the content file then cache the results this.isDirectory = serviceRegistry.getDictionaryService().isSubClass(createQName(serviceRegistry, getType()), ContentModel.TYPE_FOLDER); if (contentFile == null || contentFile.isDirectory()) { cachedSizeInBytes = 0L; } else { cachedSizeInBytes = contentFile.length(); } }
Example 11
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 12
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 13
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); }