cancel
Showing results for 
Search instead for 
Did you mean: 

content list

abichet
Champ in-the-making
Champ in-the-making
hi

i write a function in the file NewSpaceWizard.java that is called just after modified properties of a space (my custom:advancedFolder of this post http://forums.alfresco.com/viewtopic.php?t=1278)

in this function i want to retrieve all contents of this space for modify content  properties.
this code :
List<Node> listNode = browseBean.getContent() ;
retrieve content of the current navigation but not necessarily the content of the space a just modify.
in order to this code work i have to enter in the space before click on More Actions->View details->modify.
I cant click on the View details in the "browse space" because the code retrieve the content of the parent space (the content in the "content item").

Are there a other code that i can use to retrieve the good content ??

Regards
4 REPLIES 4

gavinc
Champ in-the-making
Champ in-the-making
I'm not entierly sure what you are trying to achieve to be honest but I'll have a go at suggesting something that may help. NavigationBean has a getCurrentNode() method, this may well return the node you need in your context.

abichet
Champ in-the-making
Champ in-the-making
oki
i try to explain exactly what i want to do
I add a type to a space (my custom:AdvancedFolder) actually this type add three properties to this space. I set this three properties in detail -> modify space(I have add the possibility to modifiy properties type in this view).

When i add a document in this space, a action add the space properties to the document ( now the document have the same properties that the space and this properties have the same value). All this part work but i have a little problem.
When i remodify the properties of the space , i want to remodify the properties of document in this space). So in the class NewSpaceWizard.java i call a function a the end of the function finish() :
public void updateDocumentProperties() {
     
      Node currentSpace = this.browseBean.getActionSpace();
         
      FacesContext context = FacesContext.getCurrentInstance();   
      
       List<Node> listNode = browseBean.getContent() ;     
      
       if(listNode != null)
       {      
          for (Node node : listNode) {
             UserTransaction tx = null;
            
             try
             {
                 tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
                 tx.begin();         
                               
                 Map<String, Object> props = currentSpace.getProperties() ;
                                   
                 Iterator<String> iterProps = props.keySet().iterator();
                 while (iterProps.hasNext())
                 {
                    String propName = iterProps.next();
                    QName qname = QName.createQName(propName);
   
                                    
                       // make sure the property is represented correctly
                       Serializable propValue = (Serializable)props.get(propName);
                      
                       // check for empty strings when using number types, set to null in this case
                                   
                       if(qname.toPrefixString(this.namespaceService).indexOf("custom:") == 0)
                          this.nodeService.setProperty(node.getNodeRef(),QName.createQName(propName),propValue) ;
                   
                 }
                
                
                 // give subclasses a chance to perform custom processing before committing
                   performCustomProcessing(context);
                  
                   // commit the transaction
                   tx.commit();
             }
             catch (Throwable e)
             {
                // rollback the transaction
                try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
                 Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
                       FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
   
            }
          }
          
       }
   }

but in order to this code work i have to enter in this space before modifiy this properties by more actions -> view detail -> modifiy. if i dont do this this code modify the document of the parent space.
thus i look of an other code to replace browseBean.getContent() ;

I hope , that is more clean.

regards

gavinc
Champ in-the-making
Champ in-the-making
Thanks, that's much clearer.

Unfortunately there isn't support for the scenario you want out of the box. You have a couple of choices you can either add a method that takes the node you want the documents for to BrowseBean or add the code to retrieve the docs in your version of NewSpaceWizard.

You could add a getContent(Node node) method to BrowseBean and mimic what the current getContent method is doing.

Alternatively, you could just retrieve the children of the 'currentSpace' node directly in NewSpaceWizard.

All you need to do to get the children of a node is the following (use BrowseBean.queryBrowseNodes() as a reference)


List<NodeRef> childNodes = new ArrayList<NodeRef>();
List<ChildAssociationRef> childRefs = this.nodeService.getChildAssocs(currentSpace,
               ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref: childRefs)
{
   // create our Node representation from the NodeRef
   NodeRef nodeRef = ref.getChildRef();
   if (this.nodeService.exists(nodeRef))
   {
      <if node is content> (type checking omitted for brevity)
         childNodes.add(nodeRef);
   }
}

Hope this helps.

abichet
Champ in-the-making
Champ in-the-making
thanks a lot gavin