org.alfresco.service.cmr.repository.NodeService Java Examples
The following examples show how to use
org.alfresco.service.cmr.repository.NodeService.
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: NodeRefPropertyMethodInterceptorTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void before() throws Exception { mlAwareNodeService = (NodeService) applicationContext.getBean("mlAwareNodeService"); nodeService = (NodeService) applicationContext.getBean("nodeService"); dictionaryDAO = (DictionaryDAO) applicationContext.getBean("dictionaryDAO"); authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent"); authenticationComponent.setSystemUserAsCurrentUser(); ClassLoader cl = BaseNodeServiceTest.class.getClassLoader(); InputStream modelStream = cl.getResourceAsStream("org/alfresco/repo/node/NodeRefTestModel.xml"); assertNotNull(modelStream); M2Model model = M2Model.createModel(modelStream); dictionaryDAO.putModel(model); StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); rootNodeRef = nodeService.getRootNode(storeRef); }
Example #2
Source File: ChildAssociatedNodeFinder.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * @param thisNode NodeRef * @return Set<NodeRef> */ private Set<NodeRef> processExcludedSet(NodeRef thisNode) { Set<NodeRef> results = new HashSet<NodeRef>(89); NodeService nodeService = serviceRegistry.getNodeService(); // Find all the child nodes (filtering as necessary). List<ChildAssociationRef> children = nodeService.getChildAssocs(thisNode); boolean filterChildren = !childAssociationTypes.isEmpty(); for (ChildAssociationRef child : children) { if (!filterChildren || !childAssociationTypes.contains(child.getTypeQName())) { results.add(child.getChildRef()); } } return results; }
Example #3
Source File: AbstractArchivedNodeWebScript.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
/** * * This method gets all nodes from the archive which were originally * contained within the specified StoreRef. * * @param storeRef mandatory store ref * @param paging mandatory paging * @param filter optional filter */ protected PagingResults<NodeRef> getArchivedNodesFrom(StoreRef storeRef, ScriptPagingDetails paging, String filter) { NodeService nodeService = serviceRegistry.getNodeService(); NodeRef archiveStoreRootNodeRef = nodeService.getStoreArchiveNode(storeRef); // Create canned query ArchivedNodesCannedQueryBuilder queryBuilder = new ArchivedNodesCannedQueryBuilder.Builder( archiveStoreRootNodeRef, paging).filter(filter) .sortOrderAscending(false).build(); // Query the DB PagingResults<NodeRef> result = nodeArchiveService.listArchivedNodes(queryBuilder); return result; }
Example #4
Source File: NodeChangeTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void setUp() throws Exception { namespaceService = mock(NamespaceService.class); Collection<String> cmAlways = new ArrayList<String>(); cmAlways.add("cm"); when(namespaceService.getPrefixes(anyString())).thenReturn(cmAlways); when(namespaceService.getNamespaceURI(anyString())).thenReturn("cm"); nodeService = mock(NodeService.class); Path rootPath = newPath(null, "/"); Path homeFolderPath = newPath(rootPath, "cm:homeFolder"); folderPath1 = newPath(homeFolderPath, "cm:folder1"); folderPath2 = newPath(homeFolderPath, "cm:folder2"); folder1 = newFolder(folderPath1); folder2 = newFolder(folderPath2); content1 = newContent(folderPath1, "cm:content1"); nodeInfoFactory = new NodeInfoFactory(nodeService, namespaceService); nodeChange = new NodeChange(nodeInfoFactory, namespaceService, content1); }
Example #5
Source File: LinksServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@BeforeClass public static void initTestsContext() throws Exception { AUTHENTICATION_SERVICE = (MutableAuthenticationService)testContext.getBean("authenticationService"); BEHAVIOUR_FILTER = (BehaviourFilter)testContext.getBean("policyBehaviourFilter"); LINKS_SERVICE = (LinksService)testContext.getBean("LinksService"); NODE_SERVICE = (NodeService)testContext.getBean("nodeService"); PUBLIC_NODE_SERVICE = (NodeService)testContext.getBean("NodeService"); PERSON_SERVICE = (PersonService)testContext.getBean("personService"); TRANSACTION_HELPER = (RetryingTransactionHelper)testContext.getBean("retryingTransactionHelper"); PERMISSION_SERVICE = (PermissionService)testContext.getBean("permissionService"); SITE_SERVICE = (SiteService)testContext.getBean("siteService"); CONTENT_SERVICE = (ContentService)testContext.getBean("ContentService"); // Do the setup as admin AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); createUser(TEST_USER); // We need to create the test site as the test user so that they can contribute content to it in tests below. AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER); createTestSites(); }
Example #6
Source File: ContentModelFormProcessor.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected void updateAssociations(NodeService nodeService) { List<AssociationRef> existingAssocs = nodeService.getTargetAssocs(sourceNodeRef, assocQName); for (AssociationRef assoc : existingAssocs) { if (assoc.getTargetRef().equals(targetNodeRef)) { if (logger.isWarnEnabled()) { logger.warn("Attempt to add existing association prevented. " + assoc); } return; } } nodeService.createAssociation(sourceNodeRef, targetNodeRef, assocQName); }
Example #7
Source File: NodeStoreInspector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Dumps the contents of a store to a string. * * @param nodeService the node service * @param storeRef the store reference * @return string containing textual representation of the contents of the store */ public static String dumpNodeStore(NodeService nodeService, StoreRef storeRef) { StringBuilder builder = new StringBuilder(); if (nodeService.exists(storeRef) == true) { NodeRef rootNode = nodeService.getRootNode(storeRef); builder.append(outputNode(0, nodeService, rootNode)); } else { builder. append("The store "). append(storeRef.toString()). append(" does not exist."); } return builder.toString(); }
Example #8
Source File: TaskFormProcessorTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private NodeService makeNodeService() { NodeService service = mock(NodeService.class); when(service.hasAspect(PCKG_NODE, ASPECT_WORKFLOW_PACKAGE)) .thenReturn(true); Map<QName, Serializable> props = new HashMap<QName, Serializable>(2); props.put(ContentModel.PROP_FIRSTNAME, "System"); props.put(ContentModel.PROP_LASTNAME, "Administrator"); when(service.getProperties(USER_NODE)).thenReturn(props); return service; }
Example #9
Source File: TransferServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Called during the transaction setup */ @Before public void before() throws Exception { super.before(); // Get the required services this.transferService = (TransferService)this.applicationContext.getBean("TransferService"); this.contentService = (ContentService)this.applicationContext.getBean("ContentService"); this.transferServiceImpl = (TransferServiceImpl2)this.applicationContext.getBean("transferService2"); this.searchService = (SearchService)this.applicationContext.getBean("SearchService"); this.transactionService = (TransactionService)this.applicationContext.getBean("TransactionService"); this.nodeService = (NodeService) this.applicationContext.getBean("nodeService"); this.contentService = (ContentService) this.applicationContext.getBean("contentService"); this.authenticationService = (MutableAuthenticationService) this.applicationContext.getBean("authenticationService"); this.actionService = (ActionService)this.applicationContext.getBean("actionService"); this.permissionService = (PermissionService)this.applicationContext.getBean("permissionService"); this.receiver = (TransferReceiver)this.applicationContext.getBean("transferReceiver"); this.transferManifestNodeFactory = (TransferManifestNodeFactory)this.applicationContext.getBean("transferManifestNodeFactory"); this.authenticationComponent = (AuthenticationComponent) this.applicationContext.getBean("authenticationComponent"); this.lockService = (LockService) this.applicationContext.getBean("lockService"); this.personService = (PersonService)this.applicationContext.getBean("PersonService"); this.descriptorService = (DescriptorService)this.applicationContext.getBean("DescriptorService"); this.copyService = (CopyService)this.applicationContext.getBean("CopyService"); this.taggingService = ((TaggingService)this.applicationContext.getBean("TaggingService")); this.categoryService = (CategoryService)this.applicationContext.getBean("CategoryService"); this.repositoryHelper = (Repository) this.applicationContext.getBean("repositoryHelper"); this.serverDescriptor = descriptorService.getServerDescriptor(); REPO_ID_B = descriptorService.getCurrentRepositoryDescriptor().getId(); authenticationComponent.setSystemUserAsCurrentUser(); assertNotNull("receiver is null", this.receiver); TestTransaction.flagForCommit(); TestTransaction.end(); }
Example #10
Source File: SiteServiceImplMoreTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@BeforeClass public static void initStaticData() throws Exception { AUTHORITY_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("AuthorityService", AuthorityService.class); NAMESPACE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("namespaceService", NamespaceService.class); NODE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("NodeService", NodeService.class); NODE_ARCHIVE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("nodeArchiveService", NodeArchiveService.class); SITE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("siteService", SiteService.class); COCI_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("checkOutCheckInService", CheckOutCheckInService.class); TRANSACTION_HELPER = APP_CONTEXT_INIT.getApplicationContext().getBean("retryingTransactionHelper", RetryingTransactionHelper.class); PERMISSION_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("permissionServiceImpl", PermissionService.class); AUTHENTICATION_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("authenticationService", MutableAuthenticationService.class); PERSON_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("PersonService", PersonService.class); FILE_FOLDER_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("FileFolderService",FileFolderService.class); AUTHENTICATION_COMPONENT = APP_CONTEXT_INIT.getApplicationContext().getBean("authenticationComponent",AuthenticationComponent.class); LOCK_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("lockService",LockService.class); // We'll create this test content as admin. final String admin = AuthenticationUtil.getAdminUserName(); TEST_SITE_NAME = GUID.generate(); TEST_SUB_SITE_NAME = GUID.generate(); final QName subSiteType = QName.createQName("testsite", "testSubsite", NAMESPACE_SERVICE); STATIC_TEST_SITES.createSite("sitePreset", TEST_SITE_NAME, "siteTitle", "siteDescription", SiteVisibility.PUBLIC, admin); STATIC_TEST_SITES.createSite("sitePreset", TEST_SUB_SITE_NAME, "siteTitle", "siteDescription", SiteVisibility.PUBLIC, subSiteType, admin); TEST_SITE_WITH_MEMBERS = STATIC_TEST_SITES.createTestSiteWithUserPerRole(SiteServiceImplMoreTest.class.getSimpleName(), "sitePreset", SiteVisibility.PUBLIC, admin); }
Example #11
Source File: RepositoryExporterComponentTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Before public void before() throws Exception { this.nodeService = (NodeService)applicationContext.getBean(ServiceRegistry.NODE_SERVICE.getLocalName()); this.fileFolderService = (FileFolderService)applicationContext.getBean(ServiceRegistry.FILE_FOLDER_SERVICE.getLocalName()); this.repositoryService = (RepositoryExporterService)applicationContext.getBean("repositoryExporterComponent"); this.authenticationComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent"); this.authenticationComponent.setSystemUserAsCurrentUser(); }
Example #12
Source File: NodeUtils.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public static Filter<NodeRef> exists(final NodeService nodeService) { return new Filter<NodeRef>() { public Boolean apply(NodeRef value) { return nodeService.exists(value); } }; }
Example #13
Source File: ContentModelFormProcessor.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void updateAssociations(NodeService nodeService) { List<AssociationRef> existingAssocs = nodeService.getTargetAssocs(sourceNodeRef, assocQName); boolean assocDoesNotExist = true; for (AssociationRef assoc : existingAssocs) { if (assoc.getTargetRef().equals(targetNodeRef)) { assocDoesNotExist = false; break; } } if (assocDoesNotExist) { if (logger.isWarnEnabled()) { StringBuilder msg = new StringBuilder(); msg.append("Attempt to remove non-existent association prevented. ").append(sourceNodeRef).append("|") .append(targetNodeRef).append(assocQName); logger.warn(msg.toString()); } return; } nodeService.removeAssociation(sourceNodeRef, targetNodeRef, assocQName); }
Example #14
Source File: SOLRTrackingComponentTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
SOLRTest4( RetryingTransactionHelper txnHelper, FileFolderService fileFolderService, NodeDAO nodeDAO, QNameDAO qnameDAO, NodeService nodeService, DictionaryService dictionaryService, NodeRef rootNodeRef, String containerName, boolean doNodeChecks, boolean doMetaDataChecks) { super(txnHelper, fileFolderService, nodeDAO, qnameDAO, nodeService, dictionaryService, rootNodeRef, containerName, doNodeChecks, doMetaDataChecks); }
Example #15
Source File: SystemNodeUtils.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Returns the NodeRef of a given Child Container within the current Tenant's * System Container, if found */ public static NodeRef getSystemChildContainer(final QName childName, final NodeService nodeService, final Repository repositoryHelper) { List<ChildAssociationRef> containerRefs = getChildAssociationRefs(childName, nodeService, repositoryHelper); NodeRef container = null; if (containerRefs.size() > 0) { container = containerRefs.get(0).getChildRef(); warnIfDuplicates(containerRefs); } return container; }
Example #16
Source File: OwnableServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public void setUp() throws Exception { if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE) { throw new AlfrescoRuntimeException( "A previous tests did not clean up transaction: " + AlfrescoTransactionSupport.getTransactionId()); } nodeService = (NodeService) ctx.getBean("nodeService"); authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService"); authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); ownableService = (OwnableService) ctx.getBean("ownableService"); permissionService = (PermissionService) ctx.getBean("permissionService"); authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName()); authenticationDAO = (MutableAuthenticationDao) ctx.getBean("authenticationDao"); TransactionService transactionService = (TransactionService) ctx.getBean(ServiceRegistry.TRANSACTION_SERVICE.getLocalName()); txn = transactionService.getUserTransaction(); txn.begin(); StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); rootNodeRef = nodeService.getRootNode(storeRef); permissionService.setPermission(rootNodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.ADD_CHILDREN, true); if(authenticationDAO.userExists("andy")) { authenticationService.deleteAuthentication("andy"); } authenticationService.createAuthentication("andy", "andy".toCharArray()); dynamicAuthority = new OwnerDynamicAuthority(); dynamicAuthority.setOwnableService(ownableService); authenticationComponent.clearCurrentSecurityContext(); }
Example #17
Source File: IntegrityEventTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public TestIntegrityEvent( NodeService nodeService, DictionaryService dictionaryService, NodeRef nodeRef, QName typeQName, QName qname) { super(nodeService, dictionaryService, nodeRef, typeQName, qname); }
Example #18
Source File: ExporterComponentTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private void dumpNodeStore(Locale locale) { System.out.println(locale.getDisplayLanguage() + " LOCALE: "); I18NUtil.setLocale(locale); System.out.println(NodeStoreInspector.dumpNodeStore((NodeService) applicationContext.getBean("NodeService"), storeRef)); }
Example #19
Source File: InvitationWebScriptTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public static String makeAvatar(final NodeService nodeService, final NodeRef person) { nodeService.addAspect(person, ContentModel.ASPECT_PREFERENCES, null); ChildAssociationRef assoc = nodeService.createNode(person, ContentModel.ASSOC_PREFERENCE_IMAGE, avatarQName, ContentModel.TYPE_CONTENT); NodeRef avatar = assoc.getChildRef(); nodeService.createAssociation(person, avatar, ContentModel.ASSOC_AVATAR); return "api/node/" + avatar + "/content/thumbnails/avatar"; }
Example #20
Source File: WellKnownNodes.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Constructs the rule with a reference to a {@link ApplicationContextInit rule} which can be used to retrieve the ApplicationContext. * * @param appContextRule a rule which can be used to retrieve the spring app context. */ public WellKnownNodes(ApplicationContextInit appContextRule) { this.appContextRule = appContextRule; this.repositoryHelper = (Repository)appContextRule.getApplicationContext().getBean("repositoryHelper"); this.nodeService = (NodeService)appContextRule.getApplicationContext().getBean("NodeService"); }
Example #21
Source File: TemporarySitesTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@BeforeClass public static void initStaticData() throws Exception { NAMESPACE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("namespaceService", NamespaceService.class); NODE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("nodeService", NodeService.class); SITE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("siteService", SiteService.class); TRANSACTION_HELPER = APP_CONTEXT_INIT.getApplicationContext().getBean("retryingTransactionHelper", RetryingTransactionHelper.class); }
Example #22
Source File: NodeCrawlerTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Called during the transaction setup */ @SuppressWarnings("deprecation") @Before public void before() throws Exception { super.before(); // Get the required services this.nodeService = (NodeService) applicationContext.getBean("NodeService"); this.serviceRegistry = (ServiceRegistry) applicationContext.getBean("ServiceRegistry"); this.nodeCrawlerFactory = (NodeCrawlerFactory) applicationContext.getBean("NodeCrawlerFactory"); Repository repositoryHelper = (Repository) applicationContext.getBean("repositoryHelper"); this.companyHome = repositoryHelper.getCompanyHome(); }
Example #23
Source File: TestPersonManager.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public TestPersonManager(MutableAuthenticationService authenticationService, PersonService personService, NodeService nodeService) { this.authenticationService = authenticationService; this.personService = personService; this.nodeService = nodeService; }
Example #24
Source File: SystemNodeUtils.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private static List<ChildAssociationRef> getChildAssociationRefs(final QName childName, final NodeService nodeService, final Repository repositoryHelper) { final NodeRef system = getSystemContainer(nodeService, repositoryHelper); List<ChildAssociationRef> containerRefs = AuthenticationUtil.runAsSystem(new RunAsWork<List<ChildAssociationRef>>() { @Override public List<ChildAssociationRef> doWork() throws Exception { return nodeService.getChildAssocs(system, ContentModel.ASSOC_CHILDREN, childName); } }); return containerRefs; }
Example #25
Source File: FilenameFilteringInterceptor.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * @param nodeService the service to use to apply the <b>sys:temporary</b> aspect */ public void setNodeService(NodeService nodeService) { this.nodeService = nodeService; }
Example #26
Source File: TransferReporterImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public NodeService getNodeService() { return nodeService; }
Example #27
Source File: DbOrIndexSwitchingQueryLanguage.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * @param nodeService the nodeService to set */ public void setNodeService(NodeService nodeService) { this.nodeService = nodeService; }
Example #28
Source File: Repository.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Sets the node service */ public void setNodeService(NodeService nodeService) { this.nodeService = nodeService; }
Example #29
Source File: FavouritesServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public void setNodeService(NodeService nodeService) { this.nodeService = nodeService; }
Example #30
Source File: CheckOutCheckInServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Set the node service */ public void setNodeService(NodeService nodeService) { this.nodeService = nodeService; }