{"id":26,"date":"2009-01-06T12:01:10","date_gmt":"2009-01-06T06:31:10","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=26"},"modified":"2016-12-19T15:19:21","modified_gmt":"2016-12-19T09:49:21","slug":"how-to-add-content-to-wcm-with-java-backed-webscripts","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/how-to-add-content-to-wcm-with-java-backed-webscripts\/","title":{"rendered":"How to add content to WCM with Java Backed Webscripts?"},"content":{"rendered":"<p>Hi,<\/p>\n<p>Content can be written to the wcm repository by simply using the AVMService class. The instance of this service is available through the instance of ServiceRegistry class. I&#8217;ll again point out that if you are starting with Java backed web-scripts to read\/write content from\/to alfresco wcm, then the example script at http:\/\/wiki.alfresco.com\/wiki\/Java-backed_Web_Scripts_Samples is a good place to start. The Abstract class that it defines can be used as a base for other web-scripts. The specific method that can be used to create a node in our web project is the createFile method in the AVMService. This method returns the outputStream to the newly created object. The parameters for the createFile method are;<br \/>\n\u2022 Path: It is the path to the directory in which the file is to be created.<br \/>\n\u2022 FileName: It is the name with which the file will be created.<br \/>\nOnce we have the output stream for the newly created file, we can just write the contents to the file using the write method (it is used to write a byte array to the stream).<\/p>\n<p>Thus creating the file can be done in three (simple) steps:-<br \/>\n1. Create a file using the createFile method of AVMService.<br \/>\n2. Write the contents in the form of byte array to the output stream returned by the method called in 1.<br \/>\n3. Close the output stream.<\/p>\n<p>Your feedback and\u00a0 suggestions are welcome.<\/p>\n<p>Regards<br \/>\n~~Himanshu Seth~~<\/p>\n<p>http:\/\/www.tothenew.com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, Content can be written to the wcm repository by simply using the AVMService class. The instance of this service is available through the instance of ServiceRegistry class. I&#8217;ll again point out that if you are starting with Java backed web-scripts to read\/write content from\/to alfresco wcm, then the example script at http:\/\/wiki.alfresco.com\/wiki\/Java-backed_Web_Scripts_Samples is a [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":2},"categories":[1],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/26"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}