03-23-2007 01:16 PM
Node node2 = this.session.getRootNode();
Node child = node2.addNode("testeindex5", "cm:content");
child.setProperty("cm:title", "My test");
child.setProperty("cm:content", "Just a test content.");
String query = "PATH:\"//*\" AND TEXT:\"Just\" ";
StoreRef sr = new StoreRef("workspace", "SpacesStore");
SearchParameters sp = new SearchParameters();
sp.addStore(sr);
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
sp.setQuery(query);
03-23-2007 02:19 PM
public void saveContent(String strContent) throws Exception {
// get the node ref of the node that will contain the content
NodeRef containerNodeRef = JCRNodeRef
.getNodeRef(getNode("/"));
FileInfo fileInfo = this.serviceRegistry.getFileFolderService().create(
containerNodeRef,
"myTesteFileContent",
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
"content"));
NodeRef fileNodeRef = fileInfo.getNodeRef();
// set the author aspect
Map<QName, Serializable> authorProps = new HashMap<QName, Serializable>(
1, 1.0f);
authorProps.put(ContentModel.PROP_AUTHOR, "fabio");
this.serviceRegistry.getNodeService().addAspect(fileNodeRef,
ContentModel.ASPECT_AUTHOR, authorProps);
// apply the titled aspect - title and description
Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(
3, 1.0f);
titledProps.put(ContentModel.PROP_TITLE, "teste title");
titledProps.put(ContentModel.PROP_DESCRIPTION, "teste desc");
this.serviceRegistry.getNodeService().addAspect(fileNodeRef,
ContentModel.ASPECT_TITLED, titledProps);
// get a writer for the content and put the file
ContentWriter writer = this.serviceRegistry.getContentService()
.getWriter(fileNodeRef, ContentModel.PROP_CONTENT, true);
// set the mimetype and encoding
writer.setMimetype("plain/text");
writer.setEncoding("UTF-8");
writer.putContent(strContent == null ? "" : strContent);
}
03-23-2007 03:55 PM
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.