ContentWriter writer = getContentService().getWriter(pdfNodeRef, MyModel.MY_TEXT_CONTENT_PROPERTY, true); writer.setMimetype("text/plain"); writer.setEncoding("UTF-8"); writer.putContent(stringFromXmlDescription); // the source XML gets thrown away
public NodeRef execute() throws Throwable { // Create some content NodeRef rootNodeRef = nodeService.getRootNode(storeRef); Map<QName, Serializable> properties = new HashMap<QName, Serializable>(13); properties.put(ContentModel.PROP_NAME, (Serializable)"test.txt"); NodeRef contentNodeRef = nodeService.createNode( rootNodeRef, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_CONTENT, properties).getChildRef(); ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); writer.putContent("INITIAL CONTENT"); // Done return contentNodeRef; } };
@Override public Void execute() throws Throwable { ChildAssociationRef child = nodeService.createNode(testData.A1NodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("A3"), ContentModel.TYPE_CONTENT); testData.A3NodeRef = child.getChildRef(); nodeService.setProperty(testData.A3NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE); nodeService.setProperty(testData.A3NodeRef, ContentModel.PROP_NAME, "A3"); ContentWriter writer = contentService.getWriter(testData.A3NodeRef, ContentModel.PROP_CONTENT, true); writer.setLocale(CONTENT_LOCALE); writer.putContent(CONTENT_STRING); return null; } });
private void makeCopy(NodeRef nodeRef) { InputStream resource = getClass().getClassLoader().getResourceAsStream(fileName); if (resource != null) { ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); writer.setEncoding("UTF-8"); writer.setMimetype(TEXT_CONTENT_MIMETYPE); writer.putContent(resource); } else throw new PatchException("Resource '"+fileName+"' not found"); }
protected ChildAssociationRef createContent(NodeRef parent, final String name, String contentString, String mimeType, String encoding) { ChildAssociationRef nodeAssoc = createTypedNode(parent, name, ContentModel.TYPE_CONTENT); NodeRef child = nodeAssoc.getChildRef(); ContentWriter writer = contentService.getWriter(child, ContentModel.PROP_CONTENT, true); writer.setMimetype(mimeType); writer.setEncoding(encoding); writer.putContent(contentString); return nodeAssoc; }
@Override public Void execute() throws Throwable { for(int i = 0; i < 100; i++) { ChildAssociationRef child = nodeService.createNode(testContext.nodeABA, ContentModel.ASSOC_CONTAINS, QName.createQName(GUID.generate() + i), ContentModel.TYPE_CONTENT); NodeRef nodeX = child.getChildRef(); nodeService.setProperty(nodeX , ContentModel.PROP_TITLE, CONTENT_TITLE + i); nodeService.setProperty(nodeX , ContentModel.PROP_NAME, CONTENT_NAME +i); nodes.add(nodeX); ContentWriter writer = contentService.getWriter(nodeX, ContentModel.PROP_CONTENT, true); writer.setLocale(CONTENT_LOCALE); writer.putContent(CONTENT_STRING + i); } return null; } };
@Override public NodeRef execute() throws Exception { final NodeRef nodeRef = createDownloadTypeNode(moduleId + SHARE_EXT_MODULE_SUFFIX); ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); writer.setMimetype(MimetypeMap.MIMETYPE_XML); writer.setEncoding("UTF-8"); writer.putContent(moduleFile); return nodeRef; } });
private void addMessageResource(NodeRef rootNodeRef, String name, InputStream resourceStream) throws Exception { Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>(); contentProps.put(ContentModel.PROP_NAME, name); ChildAssociationRef association = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), ContentModel.TYPE_CONTENT, contentProps); NodeRef content = association.getChildRef(); ContentWriter writer = contentService.getWriter(content, ContentModel.PROP_CONTENT, true); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); writer.setEncoding("UTF-8"); writer.putContent(resourceStream); resourceStream.close(); }
@Override public Void execute() throws Throwable { testData.destNodeRef = testNodeFactory.getMappedNodeRef(testData.A6NodeRef); ChildAssociationRef child = nodeService.createNode(testData.destNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B13"), ContentModel.TYPE_CONTENT); testData.B13NodeRef = child.getChildRef(); nodeService.setProperty(testData.B13NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE); nodeService.setProperty(testData.B13NodeRef, ContentModel.PROP_NAME, "B13"); ContentWriter writer = contentService.getWriter(testData.B13NodeRef, ContentModel.PROP_CONTENT, true); writer.setLocale(CONTENT_LOCALE); writer.putContent(CONTENT_STRING); return null; } });
private void makeCopy(NodeRef nodeRef) { InputStream resource = getClass().getClassLoader().getResourceAsStream(fileName); if (resource != null) { ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); writer.setEncoding("UTF-8"); writer.setMimetype(TEXT_CONTENT_MIMETYPE); writer.putContent(resource); } else throw new PatchException("Resource '"+fileName+"' not found"); }
public NodeRef execute() throws Throwable { // Create some content NodeRef rootNodeRef = nodeService.getRootNode(storeRef); Map<QName, Serializable> properties = new HashMap<QName, Serializable>(13); properties.put(ContentModel.PROP_NAME, (Serializable)"test.txt"); NodeRef contentNodeRef = nodeService.createNode( rootNodeRef, ContentModel.ASSOC_CHILDREN, ContentModel.ASSOC_CHILDREN, ContentModel.TYPE_CONTENT, properties).getChildRef(); ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); writer.putContent("INITIAL CONTENT"); // Done return contentNodeRef; } };
@Override public Void execute() throws Throwable { testData.destNodeRef = testNodeFactory.getMappedNodeRef(testData.A2NodeRef); ChildAssociationRef child = nodeService.createNode(testData.destNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B10"), ContentModel.TYPE_CONTENT); testData.B10NodeRef = child.getChildRef(); nodeService.setProperty(testData.B10NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE); nodeService.setProperty(testData.B10NodeRef, ContentModel.PROP_NAME, "B10"); ContentWriter writer = contentService.getWriter(testData.B10NodeRef, ContentModel.PROP_CONTENT, true); writer.setLocale(CONTENT_LOCALE); writer.putContent(CONTENT_STRING); return null; } });
@Override public NodeRef execute() throws Exception { final NodeRef nodeRef = createDownloadTypeNode(moduleId + SHARE_EXT_MODULE_SUFFIX); ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); writer.setMimetype(MimetypeMap.MIMETYPE_XML); writer.setEncoding("UTF-8"); writer.putContent(moduleFile); return nodeRef; } });
protected ChildAssociationRef createContent(NodeRef parent, final String name, InputStream stream, String mimeType, String encoding, QName nodeType) { ChildAssociationRef nodeAssoc = createTypedNode(parent, name, nodeType); NodeRef child = nodeAssoc.getChildRef(); ContentWriter writer = contentService.getWriter(child, ContentModel.PROP_CONTENT, true); writer.setMimetype(mimeType); writer.setEncoding(encoding); writer.putContent(stream); return nodeAssoc; }
private static NodeRef newContent(NodeRef parent, String name) { PropertyMap propertyMap0 = new PropertyMap(); propertyMap0.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-16", Locale.ENGLISH)); NodeRef content = nodeService.createNode( parent, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), ContentModel.TYPE_CONTENT, propertyMap0).getChildRef(); ContentWriter writer = serviceRegistry.getContentService().getWriter(content, ContentModel.TYPE_CONTENT, true); writer.putContent("The cat sat on the mat."); return content; }
private void updateContent(NodeRef nodeRef) { // Make versionable nodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, null); // Update content InputStream is = this.getClass().getClassLoader().getResourceAsStream(source); if (is != null) { ContentWriter contentWriter = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); contentWriter.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); contentWriter.setEncoding("UTF-8"); contentWriter.putContent(is); } }
private NodeRef addTextContent(NodeRef folderRef, String name, String textData, boolean custom) { Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>(); contentProps.put(ContentModel.PROP_NAME, name); ChildAssociationRef association = nodeService.createNode(folderRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), (custom == true ? customType: ContentModel.TYPE_CONTENT), contentProps); NodeRef content = association.getChildRef(); nodesToDelete.add(content); ContentWriter writer = contentService.getWriter(content, ContentModel.PROP_CONTENT, true); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); writer.setEncoding("UTF-8"); writer.putContent(textData); return content; }
@Override public Void execute() throws Throwable { testData.destNodeRef = testNodeFactory.getMappedNodeRef(testData.A1NodeRef); ChildAssociationRef child = nodeService.createNode(testData.destNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("B9"), ContentModel.TYPE_CONTENT); testData.B9NodeRef = child.getChildRef(); nodeService.setProperty(testData.B9NodeRef, ContentModel.PROP_TITLE, CONTENT_TITLE); nodeService.setProperty(testData.B9NodeRef, ContentModel.PROP_NAME, "B9"); ContentWriter writer = contentService.getWriter(testData.B9NodeRef, ContentModel.PROP_CONTENT, true); writer.setLocale(CONTENT_LOCALE); writer.putContent(CONTENT_STRING); return null; } });
private void updateContent(NodeRef nodeRef) { // Make versionable nodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, null); // Update content InputStream is = this.getClass().getClassLoader().getResourceAsStream(source); if (is != null) { ContentWriter contentWriter = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); contentWriter.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); contentWriter.setEncoding("UTF-8"); contentWriter.putContent(is); } }
private NodeRef addContent(NodeRef spaceRef, String name, InputStream is, String mimeType) { Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>(); contentProps.put(ContentModel.PROP_NAME, name); ChildAssociationRef association = nodeService.createNode(spaceRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), ContentModel.TYPE_CONTENT, contentProps); NodeRef content = association.getChildRef(); // add titled aspect (for Web Client display) Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(); titledProps.put(ContentModel.PROP_TITLE, name); titledProps.put(ContentModel.PROP_DESCRIPTION, name); this.nodeService.addAspect(content, ContentModel.ASPECT_TITLED, titledProps); ContentWriter writer = contentService.getWriter(content, ContentModel.PROP_CONTENT, true); writer.setMimetype(mimeType); writer.setEncoding("UTF-8"); writer.putContent(is); return content; }