How to add/ modify/ delete/ read contents to a Plone portal from java application

I want to add contents like adding new page, new folder etc. to Plone portal from java application. Let me know if there is any API meant for java that can integrate with Plone.

Hi,

AFAIK, there's no such this as a Java client for Plone.
Since Plone is a webapp, you could write an HTTP client to do whatever you need it to do.

Please let us know if you have any specific Plone questions.

-Roel

1 Like

Thanks for your suggestion. I think HTTP client is not possible because when we use POST method URL contains a session Id attached to it. And lot of hidden variables also. So, if I want to post any content to Plone websites via java is not possible.

Just GET the forms from the server and fill in the details, like a normal browser would :wink:

We also support webdav, so maybe that could work?

-Roel

What about Plone JSON API?

http://plonejsonapiroutes.readthedocs.org/en/latest/crud.html

1 Like

I'm using
org.apache.commons.httpclient.HttpClient;

while post ie
client.executeMethod(post)

I'm getting 302 status code and location something like this
http://127.0.0.1:8999/Knowledge_Dashboard/acl_users/credentials_cookie_auth/require_login?came_from=http%3A//127.0.0.1%3A8999/Knowledge_Dashboard/portal_factory/File/file.2015-01-26.2076364576/edit

I think above link is related to cookie
Can anyone please send me snippet code to set cookie(Same as plone) while sending request to POST url using
org.apache.commons.httpclient.HttpClient;

Or any working java code related to plone to post file .

thanks in advance

Log in to Plone using a browser, and observe the communication using e.g. Firebug or Chrome developer tools.
You'll see that Plone sets a __ac cookie when authentication succeeds.
So in your Java code, you'll need to send the username/password in the same manner that the browser sends them. And you'll need to capture the __ac cookie and resubmit it in subsequent requests. See HttpClient cookie documentation.

"Plone JSON API" sounds good, I would try that first. Otherwise Zope/Plone also supports XML-RPC: http://docs.plone.org/develop/plone/serving/xmlrpc.html .

There is also an add-on which extends the list of methods available through XML-RPC, see https://pythonhosted.org/wsapi4plone.core/ for more info.