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


Java QName.createValidLocalName方法代碼示例

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


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

示例1: addPackageItems

import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
private void addPackageItems(final NodeRef packageRef)
{
    for (NodeRef item : addItems)
    {
        String name = (String) nodeService.getProperty(item, ContentModel.PROP_NAME);
        if (name == null)
        {
            name = GUID.generate();
        }
        String localName = QName.createValidLocalName(name);
        QName qName = QName.createQName(CM_URL, localName);

        behaviourFilter.disableBehaviour(item, ContentModel.ASPECT_AUDITABLE);
        try
        {
            nodeService.addChild(packageRef, item, PCKG_CONTAINS, qName);
        }
        finally
        {
            behaviourFilter.enableBehaviour(item, ContentModel.ASPECT_AUDITABLE);
        }
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:24,代碼來源:PackageManager.java

示例2: testExecutionApproveWhenDestinationSameAsSource

import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
/** Test for MNT-14730*/
public void testExecutionApproveWhenDestinationSameAsSource()
{
    addWorkflowAspect(node, sourceFolder, Boolean.FALSE, Boolean.FALSE);
    
    assertTrue(nodeService.hasAspect(node, ApplicationModel.ASPECT_SIMPLE_WORKFLOW));
    NodeRef pParent = nodeService.getPrimaryParent(node).getParentRef();
    assertEquals(sourceFolder, pParent);
    
    ActionImpl action = new ActionImpl(null, ID, "accept-simpleworkflow", null);
    acceptExecuter.execute(action, node);
    
    String copyName = QName.createValidLocalName("Copy of my node.txt");
    NodeRef nodeRef = nodeService.getChildByName(sourceFolder, ContentModel.ASSOC_CONTAINS, copyName);
    assertNotNull(nodeRef);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:17,代碼來源:TransitionSimpleWorkflowActionExecuterTest.java

示例3: testExecutionRejectWhenDestinationSameAsSource

import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
/** Test for MNT-14730*/
public void testExecutionRejectWhenDestinationSameAsSource()
{
    addWorkflowAspect(node, sourceFolder, Boolean.FALSE, Boolean.FALSE);
    
    assertTrue(nodeService.hasAspect(node, ApplicationModel.ASPECT_SIMPLE_WORKFLOW));
    NodeRef pParent = nodeService.getPrimaryParent(node).getParentRef();
    assertEquals(sourceFolder, pParent);
    assertEquals(0, nodeService.getChildAssocs(destinationFolder).size());
    
    ActionImpl action = new ActionImpl(null, ID, "reject-simpleworkflow", null);
    rejectExecuter.execute(action, node);
    
    assertFalse(nodeService.hasAspect(node, ApplicationModel.ASPECT_SIMPLE_WORKFLOW));
    pParent = nodeService.getPrimaryParent(node).getParentRef();
    assertEquals(sourceFolder, pParent);        
    assertEquals(0, nodeService.getChildAssocs(destinationFolder).size());
    
    String copyName = QName.createValidLocalName("Copy of my node.txt");
    NodeRef nodeRef = nodeService.getChildByName(sourceFolder, ContentModel.ASSOC_CONTAINS, copyName);
    assertNotNull(nodeRef);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:23,代碼來源:TransitionSimpleWorkflowActionExecuterTest.java

示例4: getCategory

import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
public ChildAssociationRef getCategory(NodeRef parent, QName aspectName, String name)
{
    String uri = nodeService.getPrimaryParent(parent).getQName().getNamespaceURI();
    String validLocalName = QName.createValidLocalName(name);
    Collection<ChildAssociationRef> assocs = nodeService.getChildAssocs(parent, ContentModel.ASSOC_SUBCATEGORIES,
            QName.createQName(uri, validLocalName), false);
    if (assocs.isEmpty())
    {
        return null;
    }
    return assocs.iterator().next();
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:13,代碼來源:LuceneCategoryServiceImpl.java

示例5: createCategoryInternal

import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
private ChildAssociationRef createCategoryInternal(NodeRef parent, String name)
{
    if (!nodeService.exists(parent))
    {
        throw new AlfrescoRuntimeException("Missing category?");
    }
    String uri = nodeService.getPrimaryParent(parent).getQName().getNamespaceURI();
    String validLocalName = QName.createValidLocalName(name);
    ChildAssociationRef newCategory = publicNodeService.createNode(parent, ContentModel.ASSOC_SUBCATEGORIES, QName.createQName(uri, validLocalName), ContentModel.TYPE_CATEGORY);
    publicNodeService.setProperty(newCategory.getChildRef(), ContentModel.PROP_NAME, name);
    return newCategory;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:13,代碼來源:LuceneCategoryServiceImpl.java

示例6: createValidPath

import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
/**
 * Create a valid qname-based xpath
 * 
 * Note: 
 * - the localname will be truncated to 100 chars
 * - the localname should already be encoded for ISO 9075 (in case of MT bootstrap, the @ sign will be auto-encoded, see below)
 * 
 * Some examples:
 *      /
 *      sys:people/cm:admin
 *      /app:company_home/app:dictionary
 *      ../../cm:people_x0020_folder
 *      sys:people/cm:admin_x0040_test
 *      
 * @param path String
 * @return String
 */
private String createValidPath(String path)
{
    StringBuffer validPath = new StringBuffer(path.length());
    String[] segments = StringUtils.delimitedListToStringArray(path, "/");
    for (int i = 0; i < segments.length; i++)
    {
        if (segments[i] != null && segments[i].length() > 0)
        {
            int colonIndex = segments[i].indexOf(QName.NAMESPACE_PREFIX);
            if (colonIndex == -1)
            {
                // eg. ".."
                validPath.append(segments[i]);
            }
            else
            {
                String[] qnameComponents = QName.splitPrefixedQName(segments[i]);
                
                String localName = QName.createValidLocalName(qnameComponents[1]);
                
                // MT: bootstrap of "alfrescoUserStore.xml" requires 'sys:people/cm:[email protected]' to be encoded as 'sys:people/cm:admin_x0040_tenant' (for XPath)
                localName = localName.replace("@", "_x0040_");
                
                QName segmentQName = QName.createQName(qnameComponents[0], localName, namespaceService);
                validPath.append(segmentQName.toPrefixString());
            }
        }
        if (i < (segments.length -1))
        {
            validPath.append("/");
        }
    }
    return validPath.toString();
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:52,代碼來源:ImporterComponent.java

示例7: createDirectory

import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
private NodeRef createDirectory(NodeRef parentNodeRef, String name, String path)
{
    // check the parent node's type to determine which association to use
    QName assocTypeQName = getAssocTypeQName(parentNodeRef);
    if (assocTypeQName == null)
    {
        throw new IllegalArgumentException(
                "Unable to create directory.  " +
                "Parent type is inappropriate: " + nodeService.getType(parentNodeRef));
    }
    
    String qname = QName.createValidLocalName(name);
    ChildAssociationRef assocRef = this.nodeService.createNode(
          parentNodeRef,
          assocTypeQName,
          QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, qname),
          ContentModel.TYPE_FOLDER);
    
    NodeRef nodeRef = assocRef.getChildRef();
    
    // set the name property on the node
    this.nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, name);
    
    if (logger.isDebugEnabled())
       logger.debug("Created folder node with name: " + name);

    // apply the uifacets aspect - icon, title and description props
    Map<QName, Serializable> uiFacetsProps = new HashMap<QName, Serializable>(5);
    uiFacetsProps.put(ApplicationModel.PROP_ICON, "space-icon-default");
    uiFacetsProps.put(ContentModel.PROP_TITLE, name);
    uiFacetsProps.put(ContentModel.PROP_DESCRIPTION, path);
    this.nodeService.addAspect(nodeRef, ApplicationModel.ASPECT_UIFACETS, uiFacetsProps);
    
    if (logger.isDebugEnabled())
       logger.debug("Added uifacets aspect with properties: " + uiFacetsProps);
    
    return nodeRef;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:39,代碼來源:FileImporterImpl.java

示例8: linkNode

import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
/**
 * Link an existing Node
 * 
 * @param context  node to link in
 * @return  node reference of child linked in
 */
private NodeRef linkNode(ImportNode context)
{
    ImportParent parentContext = context.getParentContext();
    NodeRef parentRef = parentContext.getParentRef();
    
    // determine the node reference to link to
    String uuid = context.getUUID();
    if (uuid == null || uuid.length() == 0)
    {
        throw new ImporterException("Node reference does not specify a reference to follow.");
    }
    NodeRef referencedRef = new NodeRef(rootRef.getStoreRef(), uuid);

    // Note: do not link references that are defined in the root of the import
    if (!parentRef.equals(getRootRef()))
    {
        // determine child assoc type
        QName assocType = getAssocType(context);
        AssociationDefinition assocDef = dictionaryService.getAssociation(assocType);
        if (assocDef.isChild())
        {
            // determine child name
            QName childQName = getChildName(context);
            if (childQName == null)
            {
                String name = (String)nodeService.getProperty(referencedRef, ContentModel.PROP_NAME);
                if (name == null || name.length() == 0)
                {
                    throw new ImporterException("Cannot determine node reference child name");
                }
                String localName = QName.createValidLocalName(name);
                childQName = QName.createQName(assocType.getNamespaceURI(), localName);
            }
        
            // create the secondary link
            nodeService.addChild(parentRef, referencedRef, assocType, childQName);
            reportNodeLinked(referencedRef, parentRef, assocType, childQName);
        }
        else
        {
            nodeService.createAssociation(parentRef, referencedRef, assocType);
            reportNodeLinked(parentRef, referencedRef, assocType, null);
        }
    }
    
    // second, perform any specified udpates to the node
    updateStrategy.importNode(context);
    return referencedRef; 
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:56,代碼來源:ImporterComponent.java

示例9: getChildName

import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
/**
 * Get the child name to import node under
 * 
 * @param context  the node
 * @return  the child name
 */
private QName getChildName(ImportNode context)
{
    QName assocType = getAssocType(context);
    QName childQName = null;
    
    // Determine child name
    String childName = context.getChildName();
    if (childName != null)
    {
        childName = bindPlaceHolder(childName, binding);
        // <Fix for ETHREEOH-2299>
        if (ContentModel.TYPE_PERSON.equals(context.getTypeDefinition().getName())
                && assocType.equals(ContentModel.ASSOC_CHILDREN))
        {
            childName = childName.toLowerCase();
        }
        // </Fix for ETHREEOH-2299>
        String[] qnameComponents = QName.splitPrefixedQName(childName);
        childQName = QName.createQName(qnameComponents[0], QName.createValidLocalName(qnameComponents[1]), namespaceService); 
    }
    else
    {
        Map<QName, Serializable> typeProperties = context.getProperties();
        
        Serializable nameValue = typeProperties.get(ContentModel.PROP_NAME);

        if(nameValue != null && !String.class.isAssignableFrom(nameValue.getClass()))
        {
            throw new  ImporterException("Unable to use childName property: "+ ContentModel.PROP_NAME + " is not a string");  
        }
        
        String name = (String)nameValue;
        
        if (name != null && name.length() > 0)
        {
            name = bindPlaceHolder(name, binding);
            String localName = QName.createValidLocalName(name);
            childQName = QName.createQName(assocType.getNamespaceURI(), localName);
        }
    }
    
    return childQName;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:50,代碼來源:ImporterComponent.java

示例10: createExportZip

import org.alfresco.service.namespace.QName; //導入方法依賴的package包/類
/**
 * Creates the ZIP file node in the repository for the export
 * 
 * @param ruleAction The rule being executed
 * @return The NodeRef of the newly created ZIP file
 */
private NodeRef createExportZip(Action ruleAction, NodeRef actionedUponNodeRef)
{
    // create a node in the repository to represent the export package
    NodeRef exportDest = (NodeRef)ruleAction.getParameterValue(PARAM_DESTINATION_FOLDER);
    String packageName = (String)ruleAction.getParameterValue(PARAM_PACKAGE_NAME);

    // add the default Alfresco content package extension if an extension hasn't been given
    if (!packageName.endsWith("." + ACPExportPackageHandler.ACP_EXTENSION))
    {
        packageName += (packageName.charAt(packageName.length() -1) == '.') ? ACPExportPackageHandler.ACP_EXTENSION : "." + ACPExportPackageHandler.ACP_EXTENSION;
    }
    
    // set the name for the new node
    Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>(1);
    contentProps.put(ContentModel.PROP_NAME, packageName);
        
    // create the node to represent the zip file
    String assocName = QName.createValidLocalName(packageName);
    ChildAssociationRef assocRef = this.nodeService.createNode(
          exportDest, ContentModel.ASSOC_CONTAINS,
          QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, assocName),
          ContentModel.TYPE_CONTENT, contentProps);
     
    NodeRef zipNodeRef = assocRef.getChildRef();
    
    // build a description string to be set on the node representing the content package
    String desc = "";
    String storeRef = (String)ruleAction.getParameterValue(PARAM_STORE);
    NodeRef rootNode = this.nodeService.getRootNode(new StoreRef(storeRef));
    if (rootNode.equals(actionedUponNodeRef))
    {
       desc = I18NUtil.getMessage("export.root.package.description");
    }
    else
    {
       String spaceName = (String)this.nodeService.getProperty(actionedUponNodeRef, ContentModel.PROP_NAME);
       String pattern = I18NUtil.getMessage("export.package.description");
       if (pattern != null && spaceName != null)
       {
          desc = MessageFormat.format(pattern, spaceName);
       }
    }
    
    // apply the titled aspect to behave in the web client
    Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(3, 1.0f);
    titledProps.put(ContentModel.PROP_TITLE, packageName);
    titledProps.put(ContentModel.PROP_DESCRIPTION, desc);
    this.nodeService.addAspect(zipNodeRef, ContentModel.ASPECT_TITLED, titledProps);
    
    return zipNodeRef;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:58,代碼來源:ExporterActionExecuter.java


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