02-23-2012 09:13 AM
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);
}
02-23-2012 09:46 AM
private QName NAME_ECOH_CV = QName.createQName("ecoh.model", "nome");
String nome = (String) properties.get(NAME_ECOH_CV);
02-24-2012 09:06 AM
02-24-2012 10:02 AM
02-24-2012 12:20 PM
<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.02-27-2012 08:56 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.