AnsweredAssumed Answered

Publish content of type 'article' using WS

Question asked by billbaroud on May 30, 2011
Latest reply on May 30, 2011 by billbaroud
Hi everyone,

I would like to publish content (e.g. html pages) of type 'article' using web services, so that they can be published in the 'blog' section of the Web Quick Start application.

Right now, all I achieved to do, is to publish content and to change the type of this content in Alfresco Share to 'article' (see picture)

[img]http://img857.imageshack.us/img857/3042/changetype.png[/img]

Uploaded with ImageShack.us

However, I would like to directly publish it as an article, i.e. not have to set it manually in Alfresco Share for each content I publish. Is there a property that I can set to set it to type 'article' ?

Thanks a lot !  :)



Bellow my code (basically the same as the web service examples of the SDK)



// Create a parent reference, this contains information about the association we are createing to the new content and the
        // parent of the new content (the space retrived from the search)
        ParentReference parentReference = new ParentReference(STORE, null, parent, ASSOC_CONTAINS,
                "{" + Constants.NAMESPACE_CONTENT_MODEL + "}" + name);
       
        // Define the content format for the content we are adding
        ContentFormat contentFormat = new ContentFormat("text/html", "UTF-8");
       
        NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, name)};
        CMLCreate create = new CMLCreate("1", parentReference, null, null, null, Constants.TYPE_CONTENT, properties);
        CML cml = new CML();
        cml.setCreate(new CMLCreate[]{create});
        UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);    
       
        Reference newContentNode = result[0].getDestination();
        Content content = contentService.write(newContentNode, Constants.PROP_CONTENT, contentString.getBytes(), contentFormat);
       

Outcomes