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


Java QName.createQNameWithValidLocalName方法代碼示例

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


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

示例1: testCaseSensitivity

import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
/**
 * MNT-9289
 * 
 * Change in case in email Subject causes DuplicateChildNodeNameException
 */
public void testCaseSensitivity() throws Exception
{
 NodeRef person = personService.getPerson(TEST_USER);
 String TEST_EMAIL="[email protected]";
 NodeRef testUserHomeFolder = (NodeRef)nodeService.getProperty(person, ContentModel.PROP_HOMEFOLDER);
    if(person == null)
    {
        logger.debug("new person created");
        Map<QName, Serializable> props = new HashMap<QName, Serializable>();
        props.put(ContentModel.PROP_USERNAME, TEST_USER);
        props.put(ContentModel.PROP_EMAIL, TEST_EMAIL);
        person = personService.createPerson(props);
    }
    
    nodeService.setProperty(person, ContentModel.PROP_EMAIL, TEST_EMAIL);

    Set<String> auths = authorityService.getContainedAuthorities(null, "GROUP_EMAIL_CONTRIBUTORS", true);
    if(!auths.contains(TEST_USER))
    {
        authorityService.addAuthority("GROUP_EMAIL_CONTRIBUTORS", TEST_USER);
    }
    
    String companyHomePathInStore = "/app:company_home"; 
    String storePath = "workspace://SpacesStore";
    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);
    assertNotNull("company home is null", companyHomeNodeRef);
 
    String TEST_CASE_SENSITIVITY_SUBJECT = "Test (Mail)";
    String testUserHomeDBID = ((Long)nodeService.getProperty(testUserHomeFolder, ContentModel.PROP_NODE_DBID)).toString() + "@Alfresco.com";
 
    String from = TEST_EMAIL;
    String to = testUserHomeDBID;
    String content = "hello world";

    Session sess = Session.getDefaultInstance(new Properties());
    assertNotNull("sess is null", sess);
    SMTPMessage msg = new SMTPMessage(sess);
    InternetAddress[] toa =  { new InternetAddress(to) };
    
    EmailDelivery delivery = new EmailDelivery(to, from, null);

    msg.setFrom(new InternetAddress(TEST_EMAIL));
    msg.setRecipients(Message.RecipientType.TO, toa);
    msg.setContent(content, "text/plain");
 
    msg.setSubject(TEST_CASE_SENSITIVITY_SUBJECT);
    ByteArrayOutputStream bos1 = new ByteArrayOutputStream();
    msg.writeTo(bos1);
    InputStream is = IOUtils.toInputStream(bos1.toString());
    assertNotNull("is is null", is);
    SubethaEmailMessage m = new SubethaEmailMessage(is);  
    folderEmailMessageHandler.setOverwriteDuplicates(false);
    emailService.importMessage(delivery, m);
    
    QName safeQName = QName.createQNameWithValidLocalName(NamespaceService.CONTENT_MODEL_1_0_URI, TEST_CASE_SENSITIVITY_SUBJECT);
    List<ChildAssociationRef> assocs = nodeService.getChildAssocs(testUserHomeFolder, ContentModel.ASSOC_CONTAINS, safeQName);
    assertEquals(1, assocs.size());
    
    msg.setSubject(TEST_CASE_SENSITIVITY_SUBJECT.toUpperCase());
    ByteArrayOutputStream bos2 = new ByteArrayOutputStream();
    msg.writeTo(bos2);
    is = IOUtils.toInputStream(bos2.toString());
    assertNotNull("is is null", is);
    m = new SubethaEmailMessage(is);  
    folderEmailMessageHandler.setOverwriteDuplicates(false);
    emailService.importMessage(delivery, m);
    
    safeQName = QName.createQNameWithValidLocalName(NamespaceService.CONTENT_MODEL_1_0_URI, TEST_CASE_SENSITIVITY_SUBJECT.toUpperCase() +  "(1)");
    assocs = nodeService.getChildAssocs(testUserHomeFolder, ContentModel.ASSOC_CONTAINS, safeQName);
    assertEquals(1, assocs.size());
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:81,代碼來源:EmailServiceImplTest.java

示例2: getParentAssocs

import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
@Override
public List<ChildAssociationRef> getParentAssocs(NodeRef nodeRef, QNamePattern typeQNamePattern,
            QNamePattern qnamePattern)
{
    NodeServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference != null)
    {
        Reference parent = reference.execute(new GetParentReferenceMethod());
        if (parent == null)
        {
            return theTrait.getParentAssocs(reference.execute(new GetActualNodeRefMethod(environment)),
                                            typeQNamePattern,
                                            qnamePattern);
        }
        else
        {
            if (typeQNamePattern.isMatch(ContentModel.ASSOC_CONTAINS))
            {
                Reference parentsParent = parent.execute(new GetParentReferenceMethod());

                NodeRef parentNodeRef = parent.toNodeRef();
                if (parentsParent == null)
                {
                    parentNodeRef = parent.execute(new GetActualNodeRefMethod(environment));

                }

                NodeRef referenceNodeRef = reference.toNodeRef();
                Map<QName, Serializable> properties = smartStore.getProperties(reference);
                Serializable name = properties.get(ContentModel.PROP_NAME);
                QName assocChildName = QName
                            .createQNameWithValidLocalName(VirtualContentModel.VIRTUAL_CONTENT_MODEL_1_0_URI,
                                                           name.toString());
                if (qnamePattern.isMatch(assocChildName))
                {
                    ChildAssociationRef assoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS,
                                                                        parentNodeRef,
                                                                        assocChildName,
                                                                        referenceNodeRef);
                    return Arrays.asList(assoc);
                }
                else
                {
                    return Collections.emptyList();
                }
            }
            else
            {
                return Collections.emptyList();
            }
        }
    }
    else
    {
        return theTrait.getParentAssocs(nodeRef,
                                        typeQNamePattern,
                                        qnamePattern);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:61,代碼來源:VirtualNodeServiceExtension.java

示例3: getPrimaryParent

import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
@Override
public ChildAssociationRef getPrimaryParent(NodeRef nodeRef)
{
	Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference != null)
    {  
        Reference parent = reference.execute(new GetParentReferenceMethod());
        if (parent == null)
        {
            return getTrait().getPrimaryParent(reference.execute(new GetActualNodeRefMethod(environment)));
        }
        else
        {
            Reference parentsParent = parent.execute(new GetParentReferenceMethod());

            NodeRef parentNodeRef = parent.toNodeRef();
            if (parentsParent == null)
            {
                parentNodeRef = parent.execute(new GetActualNodeRefMethod(environment));

            }

            NodeRef referenceNodeRef = reference.toNodeRef();
            Map<QName, Serializable> refProperties = smartStore.getProperties(reference);
            Serializable childName = refProperties.get(ContentModel.PROP_NAME);
            QName childAssocQName = QName
                        .createQNameWithValidLocalName(VirtualContentModel.VIRTUAL_CONTENT_MODEL_1_0_URI,
                                                       childName.toString());
            ChildAssociationRef assoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS,
                                                                parentNodeRef,
                                                                childAssocQName,
                                                                referenceNodeRef,
                                                                true,
                                                                -1);
            return assoc;
        }
    }
    else
    {
        return getTrait().getPrimaryParent(nodeRef);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:43,代碼來源:VirtualNodeServiceExtension.java

示例4: execute

import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
@Override
public List<ChildAssociationRef> execute(VirtualProtocol virtualProtocol, Reference reference)
            throws ProtocolMethodException
{
    if (typeQNamePattern.isMatch(ContentModel.ASSOC_CONTAINS))
    {
        List<ChildAssociationRef> childAssocs = new LinkedList<>();
        List<Reference> children = smartStore.list(reference);
        NodeRef nodeRefReference = reference.toNodeRef();
        int count = 0;
        for (Reference child : children)
        {
            if (count >= maxResults)
            {
                break;
            }

            NodeRef childNodeRef = child.toNodeRef();
            Serializable childName = environment.getProperty(childNodeRef,
                                                             ContentModel.PROP_NAME);
            QName childAssocQName = QName
                        .createQNameWithValidLocalName(VirtualContentModel.VIRTUAL_CONTENT_MODEL_1_0_URI,
                                                       childName.toString());
            if (qnamePattern.isMatch(childAssocQName))
            {

                ChildAssociationRef childAssoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS,
                                                                         nodeRefReference,
                                                                         childAssocQName,
                                                                         childNodeRef,
                                                                         true,
                                                                         -1);
                childAssocs.add(childAssoc);
                count++;
            }
        }

        return childAssocs;
    }
    else
    {
        return Collections.emptyList();
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:45,代碼來源:GetChildAssocsMethod.java

示例5: setUpTestAssociations

import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
private void setUpTestAssociations(NodeRef actualNodeRef)
{
    rootChildrenQNames = new QName[13];
    rootChildrenQNames[0] = QName.createQNameWithValidLocalName(VirtualContentModel.VIRTUAL_CONTENT_MODEL_1_0_URI,
                                                                "Node2");
    rootChildrenQNames[1] = QName.createQNameWithValidLocalName(VirtualContentModel.VIRTUAL_CONTENT_MODEL_1_0_URI,
                                                                "Node1");

    NodeRef node2 = nodeService.getChildByName(virtualFolder1NodeRef,
                                               ContentModel.ASSOC_CONTAINS,
                                               "Node2");

    String node2ChildNameString = "test1_2.txt";
    ChildAssociationRef node2ChildAssoc = createContent(node2,
                                                        node2ChildNameString);
    node2Test1_2_TXTNodeRef = node2ChildAssoc.getChildRef();
    rootChildrenQNames[2] = QName.createQNameWithValidLocalName(NamespaceService.CONTENT_MODEL_1_0_URI,
                                                                node2ChildNameString);

    nodeService.setProperty(node2ChildAssoc.getChildRef(),
                            ContentModel.PROP_TITLE,
                            NODE2TEST1_2_TXT);

    node2ChildrenQNames = new QName[2];
    node2ChildrenQNames[0] = QName.createQNameWithValidLocalName(VirtualContentModel.VIRTUAL_CONTENT_MODEL_1_0_URI,
                                                                 "Node2_1");
    node2ChildrenQNames[1] = node2ChildAssoc.getQName();

    NodeRef node2_1 = nodeService.getChildByName(node2,
                                                 ContentModel.ASSOC_CONTAINS,
                                                 "Node2_1");

    node2_1ChildrenQNames = new QName[10];
    for (int i = 1; i <= 10; i++)
    {
        ChildAssociationRef childAssoc = createContent(node2_1,
                                                       "test" + i + "_2_1.txt");
        rootChildrenQNames[2 + i] = QName.createQNameWithValidLocalName(NamespaceService.CONTENT_MODEL_1_0_URI,
                                                                        childAssoc.getQName().getLocalName());
        node2_1ChildrenQNames[i - 1] = childAssoc.getQName();
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:43,代碼來源:VirtualNodeServiceExtensionTest.java


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