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


Java NodeService.exists方法代碼示例

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


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

示例1: isMoveOperation

import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
/**
 * Determine if it is a complex move operation, which consists of a create superseded by a delete.
 * 
 * @param sourceNodeRef NodeRef
 * @return boolean
 */
@SuppressWarnings("deprecation")
private boolean isMoveOperation(NodeRef sourceNodeRef)
{
    if (sourceNodeRef != null)
    {
        NodeService nodeService = serviceRegistry.getNodeService();
        if (nodeService.exists(sourceNodeRef))
        {
            FileFolderService fileFolderService = serviceRegistry.getFileFolderService();
            FileInfo node = fileFolderService.getFileInfo(sourceNodeRef);
            if (node != null)
            {
                if (fileFolderService.isHidden(sourceNodeRef))
                {
                    return true;
                }
            }
        }
    }
    return false;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:28,代碼來源:AlfrescoImapFolder.java

示例2: dumpNodeStore

import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
/**
 * Dumps the contents of a store to a string.
 * 
 * @param nodeService   the node service
 * @param storeRef      the store reference
 * @return              string containing textual representation of the contents of the store
 */
public static String dumpNodeStore(NodeService nodeService, StoreRef storeRef)
{
    StringBuilder builder = new StringBuilder();
    
    if (nodeService.exists(storeRef) == true)
    {
        NodeRef rootNode = nodeService.getRootNode(storeRef);            
        builder.append(outputNode(0, nodeService, rootNode));            
    }
    else
    {
        builder.
            append("The store ").
            append(storeRef.toString()).
            append(" does not exist.");
    }
    
    return builder.toString();
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:27,代碼來源:NodeStoreInspector.java

示例3: dumpNode

import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
/**
 * Dumps the contents of a node 
 * 
 * @param nodeService NodeService
 * @param nodeRef NodeRef
 * @return String
 */
public static String dumpNode(NodeService nodeService, NodeRef nodeRef)
{
    StringBuilder builder = new StringBuilder();
    
    if (nodeService.exists(nodeRef) == true)
    {
        builder.append(outputNode(0, nodeService, nodeRef));            
    }
    else
    {
        builder.
            append("The node ").
            append(nodeRef.toString()).
            append(" does not exist.");
    }
    
    return builder.toString();
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:26,代碼來源:NodeStoreInspector.java

示例4: createNodeLocation

import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
/**
 * This method creates a {@link RenditionLocation} object from the specified destination node.
 * This is formed from the specified destination NodeRef, its cm:name and its primary parent.
 * 
 * @param destination NodeRef
 * @return RenditionLocationImpl
 * @throws RenditionServiceException if the destination node does not exist.
 */
private RenditionLocationImpl createNodeLocation(NodeRef destination)
{
    NodeService nodeService = serviceRegistry.getNodeService();
    if(nodeService.exists(destination)==false)
        throw new RenditionServiceException("The rendition destination node does not exist! NodeRef: "+destination);
    
    NodeRef parentRef = nodeService.getPrimaryParent(destination).getParentRef();
    String destinationCmName = (String) nodeService.getProperty(destination, ContentModel.PROP_NAME);
    RenditionLocationImpl location  = new RenditionLocationImpl(parentRef, destination, destinationCmName);
    return location;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:20,代碼來源:StandardRenditionLocationResolverImpl.java

示例5: exists

import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
public static Filter<NodeRef> exists(final NodeService nodeService)
{
    return new Filter<NodeRef>()
    {
        public Boolean apply(NodeRef value)
        {
            return nodeService.exists(value);
        }
    };
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:11,代碼來源:NodeUtils.java

示例6: setUp

import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
@Override
public void setUp() throws Exception
{
    ctx = ApplicationContextHelper.getApplicationContext();
    transactionService = (TransactionService) ctx.getBean("TransactionService");
    nodeService = (NodeService) ctx.getBean("NodeService");
    contentService = (ContentService) ctx.getBean(ServiceRegistry.CONTENT_SERVICE.getLocalName());
    this.policyComponent = (PolicyComponent) ctx.getBean("policyComponent");
    this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
    
    // authenticate
    this.authenticationComponent.setSystemUserAsCurrentUser();
    
    // start the transaction
    txn = getUserTransaction();
    txn.begin();
    
    // create a store and get the root node
    StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, getName());
    if (!nodeService.exists(storeRef))
    {
        storeRef = nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier());
    }
    rootNodeRef = nodeService.getRootNode(storeRef);
    // create a content node
    ContentData contentData = new ContentData(null, "text/plain", 0L, "UTF-16", Locale.CHINESE);
    
    PropertyMap properties = new PropertyMap();
    properties.put(ContentModel.PROP_CONTENT, contentData);
    
    ChildAssociationRef assocRef = nodeService.createNode(
            rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName(TEST_NAMESPACE, GUID.generate()),
            ContentModel.TYPE_CONTENT,
            properties);
    contentNodeRef = assocRef.getChildRef();
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:39,代碼來源:RoutingContentServiceTest.java

示例7: query

import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
/**
 * Perform a SearchService query with the given Lucene search string
 */
protected List<TemplateNode> query(String search)
{
    List<TemplateNode> nodes = null;
    HashSet<NodeRef> nodeRefs = new HashSet<NodeRef>();

    // check if a full Lucene search string has been supplied or extracted from XML
    if (search != null && search.length() != 0)
    {
        // perform the search against the repo
        ResultSet results = null;
        try
        {
            results = this.services.getSearchService().query(this.parent.getNodeRef().getStoreRef(),
                    SearchService.LANGUAGE_LUCENE, search);

            if (results.length() != 0)
            {
                NodeService nodeService = this.services.getNodeService();
                
                nodes = new ArrayList<TemplateNode>(results.length());
                for (ResultSetRow row : results)
                {
                    NodeRef nodeRef = row.getNodeRef();
                    if (!nodeRefs.contains(nodeRef) && (nodeService.exists(nodeRef)))
                    {
                        nodes.add(new TemplateNode(nodeRef, services, this.parent.getImageResolver()));
                        nodeRefs.add(nodeRef);
                    }
                }
            }
        }
        catch (Throwable err)
        {
            throw new AlfrescoRuntimeException("Failed to execute search: " + search, err);
        }
        finally
        {
            if (results != null)
            {
                results.close();
            }
        }
    }

    return nodes != null ? nodes : (List) Collections.emptyList();
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:50,代碼來源:BaseSearchResultsMap.java

示例8: executeImpl

import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
/**
 * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
 */
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
    NodeService nodeService = this.serviceRegistry.getNodeService();
    if (nodeService.exists(actionedUponNodeRef))
    {
        NodeRef scriptRef = (NodeRef)action.getParameterValue(PARAM_SCRIPTREF);
        NodeRef spaceRef = this.serviceRegistry.getRuleService().getOwningNodeRef(action);
        if (spaceRef == null)
        {
            // the actionedUponNodeRef may actually be a space
            if (this.serviceRegistry.getDictionaryService().isSubClass(
                    nodeService.getType(actionedUponNodeRef), ContentModel.TYPE_FOLDER))
            {
                spaceRef = actionedUponNodeRef;
            }
            else
            {
                spaceRef = nodeService.getPrimaryParent(actionedUponNodeRef).getParentRef();
            }
        }
        
        if (this.scriptLocation != null || (scriptRef != null && nodeService.exists(scriptRef) == true))
        {
            // get the references we need to build the default scripting data-model
            String userName = this.serviceRegistry.getAuthenticationService().getCurrentUserName();
            NodeRef personRef = this.personService.getPerson(userName);
            NodeRef homeSpaceRef = (NodeRef)nodeService.getProperty(personRef, ContentModel.PROP_HOMEFOLDER);
            
            // the default scripting model provides access to well known objects and searching
            // facilities - it also provides basic create/update/delete/copy/move services
            Map<String, Object> model = this.serviceRegistry.getScriptService().buildDefaultModel(
                    personRef,
                    getCompanyHome(),
                    homeSpaceRef,
                    scriptRef,
                    actionedUponNodeRef,
                    spaceRef);
            
            // Add the action to the default model
            ScriptAction scriptAction = new ScriptAction(this.serviceRegistry, action, this.actionDefinition);
            model.put("action", scriptAction);

            model.put("webApplicationContextUrl", UrlUtil.getAlfrescoUrl(sysAdminParams)); 

            Object result = null;
            if (this.scriptLocation == null)
            {
                // execute the script against the default model
                result = this.serviceRegistry.getScriptService().executeScript(
                    scriptRef,
                    ContentModel.PROP_CONTENT,
                    model);
            }
            else
            {
                // execute the script at the specified script location
                result = this.serviceRegistry.getScriptService().executeScript(this.scriptLocation, model);
            }
            
            // Set the result
            if (result != null)
            {
                action.setParameterValue(PARAM_RESULT, (Serializable)result);
            }
        }
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:71,代碼來源:ScriptActionExecuter.java

示例9: testLifecycleOfXmlMetadataExtraction

import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
/**
 * Tests metadata extraction using an action with an EAGER MetadataExtracter for XML.
 */
public void testLifecycleOfXmlMetadataExtraction() throws Exception
{
    NodeService nodeService = serviceRegistry.getNodeService();
    ContentService contentService = serviceRegistry.getContentService();
    ActionExecuter executer = (ActionExecuter) ctx.getBean("extract-metadata");
    Action action = new ActionImpl(null, GUID.generate(), SetPropertyValueActionExecuter.NAME, null);
    
    StoreRef storeRef = new StoreRef("test", getName());
    NodeRef rootNodeRef = null;
    if (nodeService.exists(storeRef))
    {
        rootNodeRef = nodeService.getRootNode(storeRef);
    }
    else
    {
        nodeService.createStore("test", getName());
        rootNodeRef = nodeService.getRootNode(storeRef);
    }
    
    // Set up some properties
    PropertyMap properties = new PropertyMap();
    properties.put(ContentModel.PROP_TITLE, "My title");
    properties.put(ContentModel.PROP_DESCRIPTION, "My description");
    
    NodeRef contentNodeRef = nodeService.createNode(
            rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, getName()),
            ContentModel.TYPE_CONTENT,
            properties).getChildRef();
    // Add some content
    ContentReader alfrescoModelReader = getReader(FILE_ALFRESCO_MODEL);
    assertTrue(alfrescoModelReader.exists());
    ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
    writer.setEncoding("UTF-8");
    writer.setMimetype(MimetypeMap.MIMETYPE_XML);
    writer.putContent(alfrescoModelReader);
    
    // Execute the action
    executer.execute(action, contentNodeRef);
    
    // Check the node's properties.  The EAGER overwrite policy should have replaced the required
    // properties.
    String checkTitle = (String) nodeService.getProperty(contentNodeRef, ContentModel.PROP_TITLE);
    String checkDescription = (String) nodeService.getProperty(contentNodeRef, ContentModel.PROP_DESCRIPTION);
    assertEquals("fm:forummodel", checkTitle);
    assertEquals("Forum Model", checkDescription);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:52,代碼來源:XmlMetadataExtracterTest.java

示例10: create

import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
public static ArchivedNodeState create(NodeRef archivedNode, ServiceRegistry serviceRegistry)
{
    ArchivedNodeState result = new ArchivedNodeState();
    
    NodeService nodeService = serviceRegistry.getNodeService();
    Map<QName, Serializable> properties = nodeService.getProperties(archivedNode);

    result.archivedNodeRef = archivedNode;
    result.archivedBy = (String) properties.get(ContentModel.PROP_ARCHIVED_BY);
    result.archivedDate = (Date) properties.get(ContentModel.PROP_ARCHIVED_DATE);
    result.name = (String) properties.get(ContentModel.PROP_NAME);
    result.title = (String) properties.get(ContentModel.PROP_TITLE);
    result.description = (String) properties.get(ContentModel.PROP_DESCRIPTION);
    QName type = nodeService.getType(archivedNode);
    result.isContentType = (type.equals(ContentModel.TYPE_CONTENT) || serviceRegistry.getDictionaryService().isSubClass(type, ContentModel.TYPE_CONTENT));
    result.nodeType = type.toPrefixString(serviceRegistry.getNamespaceService());

    PersonService personService = serviceRegistry.getPersonService();
    if (result.archivedBy != null && personService.personExists(result.archivedBy))
    {
        NodeRef personNodeRef = personService.getPerson(result.archivedBy, false);
        Map<QName, Serializable> personProps = nodeService.getProperties(personNodeRef);
        
        result.firstName = (String) personProps.get(ContentModel.PROP_FIRSTNAME);
        result.lastName = (String) personProps.get(ContentModel.PROP_LASTNAME);
    }
    
    ChildAssociationRef originalParentAssoc = (ChildAssociationRef) properties.get(ContentModel.PROP_ARCHIVED_ORIGINAL_PARENT_ASSOC);
    
    if (serviceRegistry.getPermissionService().hasPermission(originalParentAssoc.getParentRef(), PermissionService.READ).equals(AccessStatus.ALLOWED)
            && nodeService.exists(originalParentAssoc.getParentRef()))
    {
       result.displayPath = PathUtil.getDisplayPath(nodeService.getPath(originalParentAssoc.getParentRef()), true);
    }
    else
    {
       result.displayPath = "";
    }
    
    return result;
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:42,代碼來源:ArchivedNodeState.java

示例11: initializeRootNode

import org.alfresco.service.cmr.repository.NodeService; //導入方法依賴的package包/類
/**
 * @param storeValue String
 * @param rootPath String
 * @param context WebApplicationContext
 * @param nodeService NodeService
 * @param searchService SearchService
 * @param namespaceService NamespaceService
 * @param tenantService TenantService
 * @param m_transactionService TransactionService
 */
private void initializeRootNode(String storeValue, String rootPath, WebApplicationContext context, NodeService nodeService, SearchService searchService,
        NamespaceService namespaceService, TenantService tenantService, TransactionService m_transactionService)
{

    // Use the system user as the authenticated context for the filesystem initialization

    AuthenticationContext authComponent = (AuthenticationContext) context.getBean("authenticationContext");
    authComponent.setSystemUserAsCurrentUser();

    // Wrap the initialization in a transaction

    UserTransaction tx = m_transactionService.getUserTransaction(true);

    try
    {
        // Start the transaction

        if (tx != null)
            tx.begin();
        
        StoreRef storeRef = new StoreRef(storeValue);
        
        if (nodeService.exists(storeRef) == false)
        {
            throw new RuntimeException("No store for path: " + storeRef);
        }
        
        NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef);
        
        List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, rootPath, null, namespaceService, false);
        
        if (nodeRefs.size() > 1)
        {
            throw new RuntimeException("Multiple possible children for : \n" + "   path: " + rootPath + "\n" + "   results: " + nodeRefs);
        }
        else if (nodeRefs.size() == 0)
        {
            throw new RuntimeException("Node is not found for : \n" + "   root path: " + rootPath);
        }
        
        defaultRootNode = nodeRefs.get(0);
        
        // Commit the transaction
        if (tx != null)
        	tx.commit();
    }
    catch (Exception ex)
    {
        logger.error(ex);
    }
    finally
    {
        // Clear the current system user

        authComponent.clearCurrentSecurityContext();
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:68,代碼來源:WebDAVServlet.java


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