當前位置: 首頁>>代碼示例>>Java>>正文


Java ContentModel.ASSOC_CHILDREN屬性代碼示例

本文整理匯總了Java中org.alfresco.model.ContentModel.ASSOC_CHILDREN屬性的典型用法代碼示例。如果您正苦於以下問題:Java ContentModel.ASSOC_CHILDREN屬性的具體用法?Java ContentModel.ASSOC_CHILDREN怎麽用?Java ContentModel.ASSOC_CHILDREN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.alfresco.model.ContentModel的用法示例。


在下文中一共展示了ContentModel.ASSOC_CHILDREN屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAssocTypeQName

/**
 * Get the type of child association that should be created.
 * 
 * @param parentNodeRef the parent
 * @return Returns the appropriate child association type qualified name for the type of the
 *      parent.  Null will be returned if it can't be determined.
 */
private QName getAssocTypeQName(NodeRef parentNodeRef)
{
    // check the parent node's type to determine which association to use
    QName parentNodeTypeQName = nodeService.getType(parentNodeRef);
    QName assocTypeQName = null;
    if (dictionaryService.isSubClass(parentNodeTypeQName, ContentModel.TYPE_CONTAINER))
    {
        // it may be a root node or something similar
        assocTypeQName = ContentModel.ASSOC_CHILDREN;
    }
    else if (dictionaryService.isSubClass(parentNodeTypeQName, ContentModel.TYPE_FOLDER))
    {
        // more like a directory
        assocTypeQName = ContentModel.ASSOC_CONTAINS;
    }
    return assocTypeQName;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:24,代碼來源:FileImporterImpl.java

示例2: getPrimaryParent

/**
 * Simulates the node begin attached to the root node of the version store.
 */
public ChildAssociationRef getPrimaryParent(NodeRef nodeRef) throws InvalidNodeRefException
{
    return new ChildAssociationRef(
            ContentModel.ASSOC_CHILDREN,
            dbNodeService.getRootNode(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, Version2Model.STORE_ID)),
            rootAssocName,
            nodeRef);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:11,代碼來源:Node2ServiceImpl.java

示例3: getPrimaryParent

/**
 * Simulates the node begin attached ot the root node of the version store.
 */
public ChildAssociationRef getPrimaryParent(NodeRef nodeRef) throws InvalidNodeRefException
{
    return new ChildAssociationRef(
            ContentModel.ASSOC_CHILDREN,
            dbNodeService.getRootNode(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, STORE_ID)),
            rootAssocName,
            nodeRef);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:11,代碼來源:NodeServiceImpl.java

示例4: getPrimaryAssocTypeQName

public QName getPrimaryAssocTypeQName()
{
    
    Field field = getDocument().getField("PRIMARYASSOCTYPEQNAME");
    if (field != null)
    {
        String qname = field.stringValue();
        return QName.createQName(qname);
    }
    else
    {
        return ContentModel.ASSOC_CHILDREN;
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:14,代碼來源:LuceneResultSetRow.java

示例5: getArchiveNodeRefAssocTypePair

private Pair<NodeRef, QName> getArchiveNodeRefAssocTypePair(final NodeRef archiveStoreRootNodeRef)
{
    final String currentUser = getCurrentUser();

    if (archiveStoreRootNodeRef == null || !nodeService.exists(archiveStoreRootNodeRef))
    {
        throw new InvalidNodeRefException("Invalid archive store root node Ref.",
                    archiveStoreRootNodeRef);
    }

    if (hasAdminAccess(currentUser))
    {
        return new Pair<NodeRef, QName>(archiveStoreRootNodeRef, ContentModel.ASSOC_CHILDREN);
    }
    else
    {
        List<ChildAssociationRef> list = AuthenticationUtil.runAs(new RunAsWork<List<ChildAssociationRef>>()
        {
            @Override
            public List<ChildAssociationRef> doWork() throws Exception
            {
                return nodeService.getChildrenByName(archiveStoreRootNodeRef,
                        ContentModel.ASSOC_ARCHIVE_USER_LINK,
                        Collections.singletonList(currentUser));
            }
        }, AuthenticationUtil.getAdminUserName());

        // Empty list means that the current user hasn't deleted anything yet.
        if (list == null || list.isEmpty())
        {
            return new Pair<NodeRef, QName>(null, null);
        }
        NodeRef userArchive = list.get(0).getChildRef();
        return new Pair<NodeRef, QName>(userArchive, ContentModel.ASSOC_ARCHIVED_LINK);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:36,代碼來源:NodeArchiveServiceImpl.java

示例6: createUser

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()); 
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:33,代碼來源:TestWithUserUtils.java

示例7: detectNodeChanges

public void detectNodeChanges(NodeRef nodeRef, SearchService searcher,
        Collection<ChildAssociationRef> addedParents, Collection<ChildAssociationRef> deletedParents,
        Collection<ChildAssociationRef> createdNodes, Collection<NodeRef> updatedNodes) throws LuceneIndexException
{
    boolean nodeExisted = false;
    boolean relationshipsChanged = false;
    
    ResultSet results = null;
    SearchParameters sp = new SearchParameters();
    sp.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp.addStore(nodeRef.getStoreRef());
    try
    {
        sp.setQuery("ID:" + SearchLanguageConversion.escapeLuceneQuery(nodeRef.toString()));
        results = searcher.query(sp);
        for (ResultSetRow row : results)
        {
            nodeExisted = true;
            Document document = ((LuceneResultSetRow) row).getDocument();
            Field qname = document.getField("QNAME");
            if (qname == null)
            {
                continue;
            }
            Collection<Pair<ChildAssociationRef, QName>> allParents = getAllParents(nodeRef, nodeService.getProperties(nodeRef));
            Set<ChildAssociationRef> dbParents = new HashSet<ChildAssociationRef>(allParents.size() * 2);
            for (Pair<ChildAssociationRef, QName> pair : allParents)
            {
                ChildAssociationRef qNameRef = tenantService.getName(pair.getFirst());
                if ((qNameRef != null) && (qNameRef.getParentRef() != null) && (qNameRef.getQName() != null))
                {
                    dbParents.add(new ChildAssociationRef(ContentModel.ASSOC_CHILDREN, qNameRef.getParentRef(), qNameRef.getQName(), qNameRef.getChildRef()));
                }
            }
                           
            Field[] parents = document.getFields("PARENT");
            String[] qnames = qname.stringValue().split(";/");
            Set<ChildAssociationRef> addedParentsSet = new HashSet<ChildAssociationRef>(dbParents);
            for (int i=0; i<Math.min(parents.length, qnames.length); i++)
            {
                QName parentQname = QName.createQName(qnames[i]);
                parentQname = QName.createQName(parentQname.getNamespaceURI(), ISO9075.decode(parentQname.getLocalName()));
                NodeRef parentRef = new NodeRef(parents[i].stringValue());
                ChildAssociationRef indexedParent = new ChildAssociationRef(ContentModel.ASSOC_CHILDREN, parentRef, parentQname, nodeRef);
                if (!addedParentsSet.remove(indexedParent))
                {
                    deletedParents.add(indexedParent);                        
                    relationshipsChanged = true;
                }
            }
            if (addedParents.addAll(addedParentsSet))
            {
                relationshipsChanged = true;
            }

            break;
        }

        if (!nodeExisted)
        {
            createdNodes.add(nodeService.getPrimaryParent(nodeRef));
        }
        else if (!relationshipsChanged)
        {
            updatedNodes.add(nodeRef);
        }
    }
    finally
    {
        if (results != null) { results.close(); }
    }
    
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:73,代碼來源:ADMLuceneIndexerImpl.java

示例8: getPath

@Override
public Path getPath(Reference reference) throws VirtualizationException
{
    Reference virtualPathElement = reference;
    Reference virtualPathParent = reference.execute(new GetParentReferenceMethod());

    Path virtualPath = new Path();

    while (virtualPathElement != null && virtualPathParent != null)
    {
        NodeRef parentNodeRef;

        parentNodeRef = virtualPathParent.toNodeRef();

        NodeRef parent = parentNodeRef;

        NodeRef virtualPathNodeRef = virtualPathElement.toNodeRef();

        // TODO: extract node reference name into protocol method in order
        // to enforce path processing code reuse and consistency

        String templatePath = virtualPathElement.execute(new GetTemplatePathMethod()).trim();
        final String pathSeparator = "/";
        if (pathSeparator.equals(templatePath))
        {
            // found root
            break;
        }
        else if (templatePath.endsWith(pathSeparator))
        {
            templatePath = templatePath.substring(0,
                                                  templatePath.length() - 1);
        }
        int lastSeparator = templatePath.lastIndexOf(pathSeparator);
        String childId = templatePath.substring(lastSeparator + 1);
        VirtualFolderDefinition structure = resolveVirtualFolderDefinition(virtualPathParent);
        VirtualFolderDefinition child = structure.findChildById(childId);
        if (child == null)
        {
            throw new VirtualizationException("Invalid reference: " + reference.encode());
        }
        String childName = child.getName();
        QName childQName = QName.createQName(VirtualContentModel.VIRTUAL_CONTENT_MODEL_1_0_URI,
                                             childName);

        ChildAssociationRef assocRef = new ChildAssociationRef(ContentModel.ASSOC_CHILDREN,
                                                               parent,
                                                               childQName,
                                                               virtualPathNodeRef,
                                                               true,
                                                               -1);
        ChildAssocElement assocRefElement = new ChildAssocElement(assocRef);
        virtualPath.prepend(assocRefElement);

        virtualPathElement = virtualPathParent;
        virtualPathParent = virtualPathParent.execute(new GetParentReferenceMethod());
    }

    return virtualPath;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:60,代碼來源:VirtualStoreImpl.java

示例9: reindexTransaction

/**
 * Perform full reindexing of the given transaction.  A read-only transaction is created
 * <b>if one doesn't already exist</b>.
 * 
 * @param txnId the transaction identifier
 */
public void reindexTransaction(final long txnId)
{
    if (logger.isDebugEnabled())
    {
        logger.debug("Reindexing transaction: " + txnId);
    }
    
    RetryingTransactionCallback<Object> reindexWork = new RetryingTransactionCallback<Object>()
    {
        public Object execute() throws Exception
        {
            // get the node references pertinent to the transaction
            List<NodeRef.Status> nodeStatuses = nodeDAO.getTxnChanges(txnId);
            // reindex each node
            for (NodeRef.Status nodeStatus : nodeStatuses)
            {
                NodeRef nodeRef = nodeStatus.getNodeRef();
                if (nodeStatus.isDeleted())                                 // node deleted
                {
                    // only the child node ref is relevant
                    ChildAssociationRef assocRef = new ChildAssociationRef(
                            ContentModel.ASSOC_CHILDREN,
                            null,
                            null,
                            nodeRef);
                  indexer.deleteNode(assocRef);
                }
                else                                                        // node created
                {
                    // reindex
                    indexer.updateNode(nodeRef);
                }
            }
            // done
            return null;
        }
    };
    transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork, true, false);
    // done
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:46,代碼來源:FullIndexRecoveryComponent.java

示例10: setUp

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();
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:68,代碼來源:AclDaoComponentTest.java


注:本文中的org.alfresco.model.ContentModel.ASSOC_CHILDREN屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。