03-28-2006 07:41 AM
03-28-2006 09:30 AM
03-28-2006 11:02 AM
03-28-2006 11:26 AM
ContentModel.ASSOC_CHILDREN,
ContentModel.ASSOC_CONTAINS,
03-29-2006 10:23 AM
03-30-2006 04:03 AM
Hi Kevin,
I have done this modification but I still have the same problem : I do not see created objects with the "webClient".
Modified code :
// add a simple folder to the root node
nodeProperties.clear();
nodeProperties.put(ContentModel.PROP_NAME, "My First Folder");
ChildAssociationRef assocRef = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NAMESPACE, QName.createValidLocalName("My First Folder")),
ContentModel.TYPE_FOLDER,
nodeProperties);
NodeRef folderRef = assocRef.getChildRef();
Regards,
Andre
03-30-2006 10:07 AM
private static void doExample(ServiceRegistry serviceRegistry) throws Exception
{
// get individual, required services
NodeService nodeService = serviceRegistry.getNodeService();
ContentService contentService = serviceRegistry.getContentService();
// authenticate
AuthenticationService authenticationService = serviceRegistry.getAuthenticationService();
authenticationService.authenticate("admin", "admin".toCharArray());
// get the store
StoreRef storeRef = new StoreRef(
StoreRef.PROTOCOL_WORKSPACE,
"SpacesStore"
);
if (!nodeService.exists(storeRef))
{
return;
}
// get the Company Home node from which to hang the next level of nodes
NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
List<ChildAssociationRef> rootChildren = nodeService.getChildAssocs(rootNodeRef);
int nbRootChildren = rootChildren.size();
int iRootChild;
NodeRef rootChild = null;
NodeRef companyHomeNode = null;
String nodeId;
for (iRootChild=0; iRootChild < nbRootChildren; iRootChild++){
rootChild = rootChildren.get(iRootChild).getChildRef();
nodeId = rootChild.getId();
System.out.println(nodeId);
Serializable prop = nodeService.getProperty(rootChild,ContentModel.PROP_NAME);
System.out.println("|" + prop.toString() + "|");
if ("Company Home".equals(prop.toString())){
companyHomeNode = rootChild;
break;
}
}
if (companyHomeNode == null)return;
Map<QName, Serializable> nodeProperties = new HashMap<QName, Serializable>(7);
// add a simple folder to the "Company Home" node
nodeProperties.clear();
nodeProperties.put(ContentModel.PROP_NAME, "My First Folder");
nodeProperties.put(ContentModel.PROP_TITLE,"My First Folder");
ChildAssociationRef assocRef = nodeService.createNode(
companyHomeNode,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NAMESPACE, QName.createValidLocalName("My First Folder")),
ContentModel.TYPE_FOLDER,
nodeProperties);
NodeRef folderRef = assocRef.getChildRef();
// create a file
nodeProperties.clear();
nodeProperties.put(ContentModel.PROP_NAME, "My First File");
assocRef = nodeService.createNode(
folderRef,
ContentModel.ASSOC_CONTAINS,
QName.createQName(NAMESPACE, QName.createValidLocalName("My First File")),
ContentModel.TYPE_CONTENT,
nodeProperties);
NodeRef fileRef = assocRef.getChildRef();
ContentWriter writer = contentService.getWriter(fileRef, ContentModel.PROP_CONTENT, true);
// the mimetype will up pushed onto the node automatically once the stream closes
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
// store string content as UTF-8
writer.setEncoding("UTF-8");
// write some content - this API allows streaming and direct loading,
// but for now we'll just upload a string
// The writer, being updating, will take care of updating the node once the stream
// closes.
String content = "The quick brown fox jumps over the lazy dog";
writer.putContent(content);
// dump the content to a file
File file = TempFileProvider.createTempFile("sample", ".txt");
ContentReader reader = contentService.getReader(fileRef, ContentModel.PROP_CONTENT);
reader.getContent(file);
}
03-30-2006 10:14 AM
[code]
tags around your code when you paste it into a forum message it's much easier for us to read (i've edited your post as an example! )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.