title: How to get a companyHome for nodeService.getChildAssocs in Alfresco?
body: <p>Actually I'm trying to get files from the current task in alfresco but can't found any descryption of how to get the current node. I've found that I can get all the child nodeRefs I need using this:</p>
  
  <pre><code>List&lt;ChildAssociationRef&gt; children = nodeService.getChildAssocs(companyHome)
  </code></pre>
  
  <p>but <a href="http://dev.alfresco.com/resource/docs/java/org/alfresco/service/cmr/repository/NodeService.html" rel="nofollow">here</a> I only see that I need <code>NodeRef nodeRef, QNamePattern typeQNamePattern, QNamePattern qnamePattern</code> these are at least 3 parameters one of them is also a NodeRef and it turns out that I need a NodeRef to get NodeRef. As I understand the last nodeRef is something like the parent folder but how to get it I don't know too. It is also possible to get the NodeRef by PATH like this:</p>
  
  <pre><code>StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
     ResultSet rs = searchService.query(storeRef, SearchService.LANGUAGE_LUCENE, "PATH:\"/app:company_home/app:user_homes/sys:boris/cm:mypics\"");
     NodeRef companyHomeNodeRef = null;
     try
     {
         if (rs.length() == 0)
         {
             throw new AlfrescoRuntimeException("Didn't find Company Home");
         }
         companyHomeNodeRef = rs.getNodeRef(0);
     }
     finally
     {
         rs.close();
     }
  </code></pre>
  
  <p>but I can't hardcode the path as the Alfresco can be run anywhere on server or other. 
  It is also possible to get NodeRef using Lucene like this way:</p>
  
  <pre><code>        SearchParameters sp = new SearchParameters();
          sp.addStore(getStoreRef());
          sp.setLanguage(SearchService.LANGUAGE_LUCENE);
          sp.setQuery("TYPE:\"{http://www.alfresco.org/model/content/1.0}content\"");
          ResultSet results = null;
          try
          {
              results = serviceRegistry.getSearchService().query(sp);
              for(ResultSetRow row : results)
              {
                  NodeRef currentNodeRef = row.getNodeRef();
                  ...
              }
          }
          finally
          {
              if(results != null)
              {
                  results.close();
              }
          }  
  </code></pre>
  
  <p>But this will return me all the Nodes existing in alfresco. 
  Maybe there is a possibility to improve one of this methods to reach my wishes? Or maybe there are any other way?</p>
  
  <p><strong>UPD:</strong> here is the part of code where I'd like to get and use nodes:</p>
  
  <pre><code>        NodeService nodeService = getServiceRegistry().getNodeService();                    
          ContentService contentService = getServiceRegistry().getContentService();
  
          List&lt;ChildAssociationRef&gt; children = nodeService.getChildAssocs(companyHome);
           if (children.isEmpty()) {
              throw new AlfrescoRuntimeException("Workflow bpm_package does not contain any files");
          }
           for(ChildAssociationRef childAssoc: children){
                  NodeRef childNodeRef = childAssoc.getChildRef();
                  FileBinary = getFileBinary(childNodeRef, contentService);
  </code></pre>
  
  <p>further I'm going to perform file transformation. Hope this will shed some lite on the situation.</p>