As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
ContentModel.ASSOC_CHILDREN,
ContentModel.ASSOC_CONTAINS,
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
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); }
[code]