Java Code Examples for org.alfresco.model.ContentModel.TYPE_CONTAINER

The following are Jave code examples for showing how to use TYPE_CONTAINER of the org.alfresco.model.ContentModel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: alfresco-repository   File: EditionServiceImpl.java   View Source Code Vote up 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
Project: alfresco-repository   File: TestWithUserUtils.java   View Source Code Vote up 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
Project: alfresco-repository   File: RegistryServiceImpl.java   View Source Code Vote up 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
Project: alfresco-repository   File: AclDaoComponentTest.java   View Source Code Vote up 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();
}