cancel
Showing results for 
Search instead for 
Did you mean: 

Summary action problem

need
Champ in-the-making
Champ in-the-making
Hi all,

i develop a custom folder action in Alfresco share 4.0.b and i have a problem with retrieve custom properties nome, this is my snipplet code action:


public void executeImpl(Action action, NodeRef actionedUponNodeRef){
       
       if (this.nodeService.exists(actionedUponNodeRef) == true){
          
          StringBuffer nomiSB = new StringBuffer();
            StringBuffer tipoSB = new StringBuffer();
          
            NodeRef parentNodeRef = nodeService.getPrimaryParent(actionedUponNodeRef).getChildRef();
           
            List<ChildAssociationRef> children =  nodeService.getChildAssocs(actionedUponNodeRef);
          for (ChildAssociationRef childAssoc:children){
             childNodeRef = childAssoc.getChildRef();
             //nodeService.getProperty(childNodeRef,ASSOC_NAME_ECOH_CV).toString();
             Map<QName, Serializable> properties = nodeService.getProperties(childNodeRef);
               String name = (String) properties.get(ContentModel.PROP_NAME);
               if (name != null && name != "") {
                  nomiSB.append(name);
                  nomiSB.append("    ");       
               }else {nomiSB.append("NULL");}
               String nome = (String) properties.get("ecoh:nome");
               if (nome != null && nome != "") {
                  tipoSB.append(nome);
                  tipoSB.append("    ");
               }  else {tipoSB.append("NULL");}
          }
          
          QName prova = QName.createQName("http://www.alfresco.org/model/content/1.0", "content");
          org.alfresco.service.cmr.model.FileInfo summaryfile = fileFolderService.create(parentNodeRef, "Summary.html", prova);
          NodeRef summary = summaryfile.getNodeRef();
          
            ContentWriter writer = contentService.getWriter(summary, ContentModel.PROP_CONTENT, true);
           String content = "<h3>Riassunto dati CV</h3>" +
                        "<table>" +
                        "<tr>"+nomiSB.toString()+"</tr>" +
                        "<td>"+tipoSB.toString()+"</td>" +
                        "</table>";
           writer.setMimetype("text/html");
         writer.putContent(content);
        }

the name of the file are printed in Summary.html but the properties ecoh:nome is null why? what's wrong?

to get to this thank Jeff Potts who helped me a lot
5 REPLIES 5

need
Champ in-the-making
Champ in-the-making
I've resolved:

private QName NAME_ECOH_CV = QName.createQName("ecoh.model", "nome");

String nome = (String) properties.get(NAME_ECOH_CV);

It is possible to construct a table in the html file with the first line sets (full name, title, etc.) and other dynamic rows with property values​​?

I must also understand how to retrieve the comments for each document.

Thanks at all

need
Champ in-the-making
Champ in-the-making
How do you retrieve the comments for each document?

Help please

need
Champ in-the-making
Champ in-the-making
Hello to all
are able to browse the children associated with each document up to the comments now how do I access the contents of each comment?

I tried calling ContenModel.PROP_CONTENT but I'm not allowed to convert to a string.

Help please!

jpotts
World-Class Innovator
World-Class Innovator
To get the content you need to use a ContentReader. You can get a ContentReader from the ContentService. That means you'll need to inject the ContentService into your action as a dependency, like this:
<bean id="move-replaced" class="com.someco.action.executer.MoveReplacedActionExecuter" parent="action-executer">
      <property name="fileFolderService">
         <ref bean="FileFolderService" />
      </property>
      <property name="nodeService">
         <ref bean="NodeService" />
      </property>
                <property name="contentService">
                        <ref bean="ContentService" />
                </property>
   </bean>
And add the corresponding setter method and class variable to your action executer class:
        private ContentService contentService;

   public void setContentService(ContentService contentService) {
      this.contentService = contentService;
   }
Once you do that, you can use it to get a ContentReader which would look something like this:
ContentReader contentReader = contentService.getReader(actionedUponNodeRef, ContentModel.PROP_CONTENT);
Once you have contentReader you can get the content in a variety of ways. To get it as a String you would use:
String contentString = contentReader.getContentString();
If your content is not plain text, you won't be able to get it as a String. You'll have to get it as a ByteStream and then use some library that knows how to read that particular format.

Jeff

need
Champ in-the-making
Champ in-the-making
Yeah,

thanks a lot Jeff it Works fine!