Java Code Examples for org.alfresco.model.ContentModel#TYPE_CONTAINER
The following examples show how to use
org.alfresco.model.ContentModel#TYPE_CONTAINER .
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: EditionServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** {@inheritDoc} */ public VersionHistory getEditions(NodeRef mlContainer) { VersionHistory editionHistory = null; // Only the mlContainer can have editions if (nodeService.getType(mlContainer).equals( ContentModel.TYPE_MULTILINGUAL_CONTAINER)) { // get the editions of the mlContainer editionHistory = versionService.getVersionHistory(mlContainer); } else { throw new IllegalArgumentException("The type of the node must be " + ContentModel.TYPE_CONTAINER); } if (logger.isDebugEnabled()) { logger.debug("Found all editions: \n" + " Node: " + mlContainer + " (type " + ContentModel.TYPE_MULTILINGUAL_CONTAINER + ")\n" + " Editions: " + editionHistory); } return editionHistory; }
Example 2
Source File: TestWithUserUtils.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public static void createUser( String userName, String password, String email, NodeRef rootNodeRef, NodeService nodeService, MutableAuthenticationService authenticationService) { // ignore if the user's authentication already exists if (authenticationService.authenticationExists(userName)) { // ignore return; } QName children = ContentModel.ASSOC_CHILDREN; QName system = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "system"); QName container = ContentModel.TYPE_CONTAINER; QName types = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "people"); NodeRef systemNodeRef = nodeService.createNode(rootNodeRef, children, system, container).getChildRef(); NodeRef typesNodeRef = nodeService.createNode(systemNodeRef, children, types, container).getChildRef(); HashMap<QName, Serializable> properties = new HashMap<QName, Serializable>(); properties.put(ContentModel.PROP_USERNAME, userName); if (email != null && email.length() != 0) { properties.put(ContentModel.PROP_EMAIL, email); } nodeService.createNode(typesNodeRef, children, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, userName) , container, properties); // Create the users authenticationService.createAuthentication(userName, password.toCharArray()); }
Example 3
Source File: RegistryServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
private NodeRef getRegistryRootNodeRef() { NodeRef registryRootNodeRef = null; // Ensure that the registry root node is present NodeRef storeRootNodeRef = nodeService.getRootNode(registryStoreRef); List<NodeRef> nodeRefs = searchService.selectNodes( storeRootNodeRef, registryRootPath, new QueryParameterDefinition[] {}, namespaceService, false, SearchService.LANGUAGE_XPATH); if (nodeRefs.size() == 0) { throw new AlfrescoRuntimeException( "Registry root not present: \n" + " Store: " + registryStoreRef + "\n" + " Path: " + registryRootPath); } else if (nodeRefs.size() > 1) { throw new AlfrescoRuntimeException( "Registry root path has multiple targets: \n" + " Store: " + registryStoreRef + "\n" + " Path: " + registryRootPath); } else { registryRootNodeRef = nodeRefs.get(0); } // Check the root QName typeQName = nodeService.getType(registryRootNodeRef); if (!typeQName.equals(ContentModel.TYPE_CONTAINER)) { throw new AlfrescoRuntimeException( "Registry root is not of type " + ContentModel.TYPE_CONTAINER + ": \n" + " Node: " + registryRootNodeRef + "\n" + " Type: " + typeQName); } // Done if (logger.isDebugEnabled()) { logger.debug( "Found root for registry: \n" + " Store: " + registryStoreRef + "\n" + " Path : " + registryRootPath + "\n" + " Root: " + registryRootNodeRef); } return registryRootNodeRef; }
Example 4
Source File: AclDaoComponentTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 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()); } aclDaoComponent = (AclDAO) applicationContext.getBean("aclDAO"); nodeService = (NodeService) applicationContext.getBean("nodeService"); dictionaryService = (DictionaryService) applicationContext.getBean(ServiceRegistry.DICTIONARY_SERVICE .getLocalName()); permissionService = (PermissionServiceSPI) applicationContext.getBean("permissionService"); namespacePrefixResolver = (NamespacePrefixResolver) applicationContext .getBean(ServiceRegistry.NAMESPACE_SERVICE.getLocalName()); authenticationService = (MutableAuthenticationService) applicationContext.getBean("authenticationService"); authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent"); serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); permissionModelDAO = (ModelDAO) applicationContext.getBean("permissionsModelDAO"); personService = (PersonService) applicationContext.getBean("personService"); authorityService = (AuthorityService) applicationContext.getBean("authorityService"); authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName()); authenticationDAO = (MutableAuthenticationDao) applicationContext.getBean("authenticationDao"); transactionService = (TransactionService) applicationContext.getBean("transactionComponent"); testTX = transactionService.getUserTransaction(); testTX.begin(); this.authenticationComponent.setSystemUserAsCurrentUser(); StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.nanoTime()); rootNodeRef = nodeService.getRootNode(storeRef); QName children = ContentModel.ASSOC_CHILDREN; QName system = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "system"); QName container = ContentModel.TYPE_CONTAINER; QName types = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "people"); systemNodeRef = nodeService.createNode(rootNodeRef, children, system, container).getChildRef(); NodeRef typesNodeRef = nodeService.createNode(systemNodeRef, children, types, container).getChildRef(); Map<QName, Serializable> props = createPersonProperties("andy"); nodeService.createNode(typesNodeRef, children, ContentModel.TYPE_PERSON, container, props).getChildRef(); props = createPersonProperties("lemur"); nodeService.createNode(typesNodeRef, children, ContentModel.TYPE_PERSON, container, props).getChildRef(); // create an authentication object e.g. the user if(authenticationDAO.userExists("andy")) { authenticationService.deleteAuthentication("andy"); } authenticationService.createAuthentication("andy", "andy".toCharArray()); if(authenticationDAO.userExists("lemur")) { authenticationService.deleteAuthentication("lemur"); } authenticationService.createAuthentication("lemur", "lemur".toCharArray()); if(authenticationDAO.userExists(AuthenticationUtil.getAdminUserName())) { authenticationService.deleteAuthentication(AuthenticationUtil.getAdminUserName()); } authenticationService.createAuthentication(AuthenticationUtil.getAdminUserName(), "admin".toCharArray()); authenticationComponent.clearCurrentSecurityContext(); }
Example 5
Source File: AbstractPermissionTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 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) applicationContext.getBean("nodeService"); dictionaryService = (DictionaryService) applicationContext.getBean(ServiceRegistry.DICTIONARY_SERVICE .getLocalName()); permissionService = (PermissionServiceSPI) applicationContext.getBean("permissionService"); permissionServiceImpl = (PermissionServiceImpl) applicationContext.getBean("permissionServiceImpl"); namespacePrefixResolver = (NamespacePrefixResolver) applicationContext .getBean(ServiceRegistry.NAMESPACE_SERVICE.getLocalName()); authenticationService = (MutableAuthenticationService) applicationContext.getBean("authenticationService"); authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent"); serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); permissionModelDAO = (ModelDAO) applicationContext.getBean("permissionsModelDAO"); personService = (PersonService) applicationContext.getBean("personService"); authorityService = (AuthorityService) applicationContext.getBean("authorityService"); authorityDAO = (AuthorityDAO) applicationContext.getBean("authorityDAO"); siteService = (SiteService) applicationContext.getBean("SiteService"); // Big 'S' authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName()); authenticationDAO = (MutableAuthenticationDao) applicationContext.getBean("authenticationDao"); nodeDAO = (NodeDAO) applicationContext.getBean("nodeDAO"); aclDaoComponent = (AclDAO) applicationContext.getBean("aclDAO"); publicServiceAccessService = (PublicServiceAccessService) applicationContext.getBean("publicServiceAccessService"); policyComponent = (PolicyComponent) applicationContext.getBean("policyComponent"); retryingTransactionHelper = (RetryingTransactionHelper) applicationContext.getBean("retryingTransactionHelper"); transactionService = (TransactionService) applicationContext.getBean("transactionComponent"); testTX = transactionService.getUserTransaction(); testTX.begin(); testStoreRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.nanoTime()); rootNodeRef = nodeService.getRootNode(testStoreRef); QName children = ContentModel.ASSOC_CHILDREN; QName system = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "system"); QName container = ContentModel.TYPE_CONTAINER; QName types = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "people"); systemNodeRef = nodeService.createNode(rootNodeRef, children, system, container).getChildRef(); NodeRef typesNodeRef = nodeService.createNode(systemNodeRef, children, types, container).getChildRef(); Map<QName, Serializable> props = createPersonProperties(USER1_ANDY); nodeService.createNode(typesNodeRef, children, ContentModel.TYPE_PERSON, container, props).getChildRef(); props = createPersonProperties(USER2_LEMUR); nodeService.createNode(typesNodeRef, children, ContentModel.TYPE_PERSON, container, props).getChildRef(); // create an authentication object e.g. the user if(authenticationDAO.userExists(USER1_ANDY)) { authenticationService.deleteAuthentication(USER1_ANDY); } authenticationService.createAuthentication(USER1_ANDY, USER1_ANDY.toCharArray()); if(authenticationDAO.userExists(USER2_LEMUR)) { authenticationService.deleteAuthentication(USER2_LEMUR); } authenticationService.createAuthentication(USER2_LEMUR, USER2_LEMUR.toCharArray()); if(authenticationDAO.userExists(USER3_PAUL)) { authenticationService.deleteAuthentication(USER3_PAUL); } authenticationService.createAuthentication(USER3_PAUL, USER3_PAUL.toCharArray()); if(authenticationDAO.userExists(AuthenticationUtil.getAdminUserName())) { authenticationService.deleteAuthentication(AuthenticationUtil.getAdminUserName()); } authenticationService.createAuthentication(AuthenticationUtil.getAdminUserName(), "admin".toCharArray()); authenticationComponent.clearCurrentSecurityContext(); assertTrue(permissionServiceImpl.getAnyDenyDenies()); }
Example 6
Source File: AuthenticationTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 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()); } dialect = (Dialect) ctx.getBean("dialect"); nodeService = (NodeService) ctx.getBean("nodeService"); authorityService = (AuthorityService) ctx.getBean("authorityService"); tenantService = (TenantService) ctx.getBean("tenantService"); tenantAdminService = (TenantAdminService) ctx.getBean("tenantAdminService"); compositePasswordEncoder = (CompositePasswordEncoder) ctx.getBean("compositePasswordEncoder"); ticketComponent = (TicketComponent) ctx.getBean("ticketComponent"); authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService"); pubAuthenticationService = (MutableAuthenticationService) ctx.getBean("AuthenticationService"); authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); authenticationComponentImpl = (AuthenticationComponent) ctx.getBean("authenticationComponent"); pubPersonService = (PersonService) ctx.getBean("PersonService"); personService = (PersonService) ctx.getBean("personService"); policyComponent = (PolicyComponent) ctx.getBean("policyComponent"); behaviourFilter = (BehaviourFilter) ctx.getBean("policyBehaviourFilter"); authenticationCache = (SimpleCache<String, CacheEntry>) ctx.getBean("authenticationCache"); immutableSingletonCache = (SimpleCache<String, NodeRef>) ctx.getBean("immutableSingletonCache"); // permissionServiceSPI = (PermissionServiceSPI) // ctx.getBean("permissionService"); ticketsCache = (SimpleCache<String, Ticket>) ctx.getBean("ticketsCache"); usernameToTicketIdCache = (SimpleCache<String, String>) ctx.getBean("usernameToTicketIdCache"); ChildApplicationContextFactory sysAdminSubsystem = (ChildApplicationContextFactory) ctx.getBean("sysAdmin"); assertNotNull("sysAdminSubsystem", sysAdminSubsystem); ApplicationContext sysAdminCtx = sysAdminSubsystem.getApplicationContext(); sysAdminParams = (SysAdminParamsImpl) sysAdminCtx.getBean("sysAdminParams"); dao = (MutableAuthenticationDao) ctx.getBean("authenticationDao"); // Let's look inside the alfresco authentication subsystem to get the DAO-wired authentication manager ChildApplicationContextManager authenticationChain = (ChildApplicationContextManager) ctx.getBean("Authentication"); ApplicationContext subsystem = authenticationChain.getApplicationContext(authenticationChain.getInstanceIds().iterator().next()); authenticationManager = (AuthenticationManager) subsystem.getBean("authenticationManager"); transactionService = (TransactionService) ctx.getBean(ServiceRegistry.TRANSACTION_SERVICE.getLocalName()); // Clean up before we start trying to create the test user transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() { @Override public Void execute() throws Throwable { AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); try { deleteAndy(); return null; } finally { authenticationComponent.clearCurrentSecurityContext(); } } }, false, true); userTransaction = transactionService.getUserTransaction(); userTransaction.begin(); StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); rootNodeRef = nodeService.getRootNode(storeRef); QName children = ContentModel.ASSOC_CHILDREN; QName system = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "system"); QName container = ContentModel.TYPE_CONTAINER; QName types = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "people"); systemNodeRef = nodeService.createNode(rootNodeRef, children, system, container).getChildRef(); typesNodeRef = nodeService.createNode(systemNodeRef, children, types, container).getChildRef(); Map<QName, Serializable> props = createPersonProperties("Andy"); personAndyNodeRef = nodeService.createNode(typesNodeRef, children, ContentModel.TYPE_PERSON, container, props).getChildRef(); assertNotNull(personAndyNodeRef); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); authenticationComponent.clearCurrentSecurityContext(); }