public ActionResult Index() { var contentData = new ContentData(); contentData.ContentDataA = "Hello"; contentData.ContentDataB = "World"; ViewData.Add("contentData", contentData); }
public ContentData getContentData() { ContentData property = new ContentData(contentUrl, mimetype, getSize(), encoding, locale); return property; }
public ContentData getContentData() { ContentData property = new ContentData(contentUrl, mimetype, getSize(), encoding, locale); return property; }
@Override public Void execute() throws Throwable { ContentData cd = new ContentData(null, null, 0, null); nodeService.setProperty(testContext.contentNodeRef, ContentModel.PROP_CONTENT, cd); return null; } };
public void testEquals() { ContentData contentData1 = new ContentData("abc://xxx", MimetypeMap.MIMETYPE_BINARY, 600L, "UTF-8", Locale.ENGLISH); ContentData contentData2 = new ContentData("abc://xxx", MimetypeMap.MIMETYPE_BINARY, 600L, "UTF-8", Locale.ENGLISH); ContentData contentData3 = new ContentData("abc://XXX", MimetypeMap.MIMETYPE_BINARY, 600L, "UTF-8", Locale.ENGLISH); ContentData contentData4 = new ContentData("abc://xxx", MimetypeMap.MIMETYPE_TEXT_PLAIN, 600L, "UTF-8", Locale.ENGLISH); ContentData contentData5 = new ContentData("abc://xxx", MimetypeMap.MIMETYPE_BINARY, 500L, "UTF-8", Locale.ENGLISH); ContentData contentData6 = new ContentData("abc://xxx", MimetypeMap.MIMETYPE_BINARY, 600L, "UTF-16", Locale.ENGLISH); ContentData contentData7 = new ContentData("abc://xxx", MimetypeMap.MIMETYPE_BINARY, 600L, "UTF-8", Locale.CHINESE); assertEquals(contentData1, contentData2); assertNotSame(contentData1, contentData3); assertNotSame(contentData1, contentData4); assertNotSame(contentData1, contentData5); assertNotSame(contentData1, contentData6); assertNotSame(contentData1, contentData7); } }
public Integer execute() throws Throwable { for (int i = 0; i < 1000; i++) { // We don't need to write anything String contentUrl = FileContentStore.createNewFileStoreUrl(); ContentData contentData = new ContentData(contentUrl, MimetypeMap.MIMETYPE_TEXT_PLAIN, 10, "UTF-8"); nodeHelper.makeNode(contentData); int count = doneCount.intValue(); count++; doneCount.setValue(count); // Do some reporting if (count % 1000 == 0) { System.out.println(String.format(" " + (new Date()) + "Total created: %6d", count)); } // Double check for shutdown if (vmShutdownListener.isVmShuttingDown()) { break; } } return maxCount; } };
public Integer execute() throws Throwable { for (int i = 0; i < 1000; i++) { // We don't need to write anything String contentUrl = FileContentStore.createNewFileStoreUrl(); ContentData contentData = new ContentData(contentUrl, MimetypeMap.MIMETYPE_TEXT_PLAIN, 10, "UTF-8"); nodeHelper.makeNode(contentData); int count = doneCount.intValue(); count++; doneCount.setValue(count); // Do some reporting if (count % 1000 == 0) { System.out.println(String.format(" " + (new Date()) + "Total created: %6d", count)); } // Double check for shutdown if (vmShutdownListener.isVmShuttingDown()) { break; } } return maxCount; } };
public void testNullReaderForNullUrl() throws Exception { // set the property, but with a null URL ContentData contentData = new ContentData(null, null, 0L, null); nodeService.setProperty(contentNodeRef, ContentModel.PROP_CONTENT, contentData); // get the reader ContentReader reader = contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT); assertNull("Reader must be null if the content URL is null", reader); }
/** * Check that the <code>ContentData</code> is decoded and persisted correctly. */ public void testCreateContentDataNulls() throws Exception { ContentData contentData = new ContentData(null, null, 0L, null, null); Pair<Long, ContentData> resultPair = create(contentData); getAndCheck(resultPair.getFirst(), contentData); }
private ContentData getContentData() { ContentContext contentCtx = new ContentContext(null, null); String contentUrl = contentStore.getWriter(contentCtx).getContentUrl(); ContentData contentData = new ContentData( contentUrl, MimetypeMap.MIMETYPE_TEXT_PLAIN, 12335L, "UTF-8", Locale.FRENCH); return contentData; }
/** * Ensure that upper and lowercase URLs don't clash * @throws Exception */ public void testEnsureCaseSensitiveStorage() throws Exception { ContentData contentData = getContentData(); String contentUrlUpper = contentData.getContentUrl().toUpperCase(); ContentData contentDataUpper = new ContentData( contentUrlUpper, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, "UTF-8", new Locale("FR")); String contentUrlLower = contentData.getContentUrl().toLowerCase(); ContentData contentDataLower = new ContentData( contentUrlLower, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, "utf-8", new Locale("fr")); Pair<Long, ContentData> resultPairUpper = create(contentDataUpper); getAndCheck(resultPairUpper.getFirst(), contentDataUpper); Pair<Long, ContentData> resultPairLower = create(contentDataLower); getAndCheck(resultPairLower.getFirst(), contentDataLower); }
private NodeRef createFreeMarkerNode(NodeRef companyHome) { NodeRef fmNode = createContentNode(companyHome, "testFreeMarkerNode-" + GUID.generate()); nodeService.setProperty(fmNode, ContentModel.PROP_CONTENT, new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, null)); URL url = getClass().getResource(FM_TEMPLATE); assertNotNull("The url is null", url); File templateFile = new File(url.getFile()); assertTrue("The template file does not exist", templateFile.exists()); ContentWriter fmWriter = contentService.getWriter(fmNode, ContentModel.PROP_CONTENT, true); fmWriter.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); fmWriter.setEncoding("UTF-8"); fmWriter.putContent(templateFile); return fmNode; }
private void setImageContentOnNode(NodeRef nodeWithImage, String mimetypeImage, File imageFile) { assertTrue(imageFile.exists()); nodeService.setProperty(nodeWithImage, ContentModel.PROP_CONTENT, new ContentData(null, mimetypeImage, 0L, null)); ContentWriter writer = contentService.getWriter(nodeWithImage, ContentModel.PROP_CONTENT, true); writer.setMimetype(mimetypeImage); writer.setEncoding("UTF-8"); writer.putContent(imageFile); }
/** * Test when the aspect is not set when check-in is performed */ @Test public void testVersionAspectNotSetOnCheckIn() { // Create a bag of props Map<QName, Serializable> bagOfProps = createTypePropertyBag(); bagOfProps.put(ContentModel.PROP_CONTENT, new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, "UTF-8")); // Create a new node ChildAssociationRef childAssocRef = nodeService.createNode( rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("test"), ContentModel.TYPE_CONTENT, bagOfProps); NodeRef noVersionNodeRef = childAssocRef.getChildRef(); // Check out and check in NodeRef workingCopy = cociService.checkout(noVersionNodeRef); cociService.checkin(workingCopy, new HashMap<String, Serializable>()); // Check that the origional node has no version history dispite sending verion props assertNull(this.versionService.getVersionHistory(noVersionNodeRef)); }
private NodeRef createCorruptedContent(NodeRef parentFolder) throws IOException { // The below pdf file has been truncated such that it is identifiable as a PDF but otherwise corrupt. File corruptPdfFile = AbstractContentTransformerTest.loadNamedQuickTestFile("quickCorrupt.pdf"); assertNotNull("Failed to load required test file.", corruptPdfFile); Map<QName, Serializable> props = new HashMap<QName, Serializable>(); props.put(ContentModel.PROP_NAME, "corrupt.pdf"); NodeRef node = this.secureNodeService.createNode(parentFolder, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "quickCorrupt.pdf"), ContentModel.TYPE_CONTENT, props).getChildRef(); secureNodeService.setProperty(node, ContentModel.PROP_CONTENT, new ContentData(null, MimetypeMap.MIMETYPE_PDF, 0L, null)); ContentWriter writer = contentService.getWriter(node, ContentModel.PROP_CONTENT, true); writer.setMimetype(MimetypeMap.MIMETYPE_PDF); writer.setEncoding("UTF-8"); writer.putContent(corruptPdfFile); return node; }
public void testToAndFromString() throws Exception { Locale locale = I18NUtil.getLocale(); String localeStr = DefaultTypeConverter.INSTANCE.convert(String.class, locale); ContentData property = new ContentData(null, null, 0L, null, null); // check null string String propertyStr = property.toString(); assertEquals("Null values not converted correctly", "contentUrl=|mimetype=|size=0|encoding=|locale=" + localeStr, propertyStr); // convert back ContentData checkProperty = ContentData.createContentProperty(propertyStr); assertEquals("Conversion from string failed", property, checkProperty); property = new ContentData("test://uuu", "mmm", 123L, "eee", I18NUtil.getLocale()); // convert to a string propertyStr = property.toString(); assertEquals("Incorrect property string representation", "contentUrl=test://uuu|mimetype=mmm|size=123|encoding=eee|locale=" + localeStr, propertyStr); // convert back checkProperty = ContentData.createContentProperty(propertyStr); assertEquals("Conversion from string failed", property, checkProperty); }
private void setupTestData() { // create a store and get the root node StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, this.getClass().getName()); if (!nodeService.exists(storeRef)) { storeRef = nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier()); } this.rootNodeRef = nodeService.getRootNode(storeRef); // create a content node ContentData contentData = new ContentData(null, "text/plain", 0L, "UTF-16", Locale.CHINESE); PropertyMap properties = new PropertyMap(); properties.put(ContentModel.PROP_CONTENT, contentData); ChildAssociationRef assocRef = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(TEST_NAMESPACE, GUID.generate()), ContentModel.TYPE_CONTENT, properties); this.contentNodeRef = assocRef.getChildRef(); validateSetUp(); }
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; }
@Before public void before() throws Exception { super.before(); this.transactionHelper = (RetryingTransactionHelper)this.applicationContext.getBean("retryingTransactionHelper"); // Create the node used for tests this.nodeRef = this.nodeService.createNode( this.rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}testnode"), ContentModel.TYPE_CONTENT).getChildRef(); this.nodeService.setProperty( this.nodeRef, ContentModel.PROP_CONTENT, new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, null)); this.folder = this.nodeService.createNode( this.rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{test}testFolder"), ContentModel.TYPE_FOLDER).getChildRef(); // Register the test executor, if needed SleepActionExecuter.registerIfNeeded(applicationContext); }
private NodeRef createContent(String parentPath, String name) throws Exception { NodeRef parent = createFolder(parentPath); PropertyMap propertyMap = new PropertyMap(); propertyMap.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-16", Locale.ENGLISH)); propertyMap.put(ContentModel.PROP_NAME, name); NodeRef content = nodeService.createNode( parent, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), ContentModel.TYPE_CONTENT, propertyMap).getChildRef(); ContentWriter writer = contentService.getWriter(content, ContentModel.TYPE_CONTENT, true); writer.putContent("The cat sat on the mat."); // System.out.println(NodeStoreInspector.dumpNode(nodeService, rootNodeRef)); return content; }