Combination View Flat View Tree View
Threads [ Previous | Next ]
Philip Coates
Web Content Publishing via REST/WS - LR 6 - Newbie question
June 1, 2011 2:08 PM
Answer

Philip Coates

Rank: Junior Member

Posts: 34

Join Date: December 10, 2010

Recent Posts

Hi,

I'm trying to develop a tool that pulls a variety of RSS feeds from remote sources and dumps those feeds into the Asset Publisher as Web Content items.

I've been reliably informed that this can be done via REST/Web Services, which would be ideal, since my application could then just make an HTTP call out to the appropriate service using something like Commons HttpClient or Spring RestTemplate.

I've been trying to get this set up with no joy so far.

I've added lines to the end of portal-ext.properties:

tunnel.servlet.hosts.allowed=127.0.0.1,SERVER_IP,<couple of other IP addresses>
tunnel.servlet.https.required=false
axis.servlet.hosts.allowed=127.0.0.1,SERVER_IP,<couple of other IP addresses>

And restarted a few times, but nothing seems to happen.

In the worst case, I could simply write the articles directly to the DB, but I'd rather not do this.

I've tried connecting to the tunnel-web portlet, but only get a 403:

From local machine:

http://localhost:8080/tunnel-web/axis ---> 403
http://localhost:8080/tunnel-web/secure/axis ---> 403
http://<machine_username>:<machine_password>@localhost:8080/tunnel-web/axis ---> 403
http://<machine_username>:<machine_password>@localhost:8080/tunnel-web/secure/axis ---> 403

Remotely:

http://<server>:8080/tunnel-web/axis ---> 403
http://<server>:8080/tunnel-web/secure/axis ---> 403
http://<machine_username>:<machine_password>@<server>:8080/tunnel-web/axis ---> 403
http://<machine_username>:<machine_password>@<server>:8080/tunnel-web/secure/axis ---> 403

I can't work out what I'm doing wrong, and documentation seems to be scarce around this.

How do I connect to tunnel-web, and is there a Web Service of some sort that will let me publish in this way already?

It sort of looks like the Atom Publishing Plugin came close to doing some of this, but it seems to have disappeared.

Many thanks,

Phil.
Hamish Campbell
RE: Web Content Publishing via REST/WS - LR 6 - Newbie question
June 4, 2011 6:25 AM
Answer

Hamish Campbell

Rank: Junior Member

Posts: 87

Join Date: August 20, 2008

Recent Posts

We are producing a GPL licensed portlet to allow RSS items to be imported to liferay as web content and would like to give this back to the communerty. Can anyone help with the Q above?
Philip Coates
RE: Web Content Publishing via REST/WS - LR 6 - Newbie question
June 5, 2011 4:43 PM
Answer

Philip Coates

Rank: Junior Member

Posts: 34

Join Date: December 10, 2010

Recent Posts

Any takers?

I'm currently approaching this in a way I feel is somewhat suboptimal:

1) Login programmatically as a user using HttpClient
2) Determine form field names to use an auth ID by scraping and regex-ing the HTML returned (nice that Liferay doesn't produce nicely formed XHTML or HTML so JTidy and XML parsers don't work! This ought to be considered a bug emoticon)
3) Populate for fields for web content and post these in
4) Repeat until all data added
5) Logout

This is all being done using HttpClient call to replicate a user journey through Asset Publisher - surely there's a better way to do this?

Many thanks,

Phil.
Hamish Campbell
RE: Web Content Publishing via REST/WS - LR 6 - Newbie question
June 8, 2011 3:28 PM
Answer

Hamish Campbell

Rank: Junior Member

Posts: 87

Join Date: August 20, 2008

Recent Posts

BUMP - we are still struggling with this.
James Falkner
RE: Web Content Publishing via REST/WS - LR 6 - Newbie question
June 9, 2011 1:40 PM
Answer

James Falkner

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1222

Join Date: September 17, 2010

Recent Posts

Hamish Campbell:
BUMP - we are still struggling with this.


Try http://127.0.0.1:8080/tunnel-web/axis
or http://test:test@127.0.0.1:8080/tunnel-web/secure/axis

For testing that should work. For production you should use HTTPS and the "right" IP address whitelist in your portal.properties.

There are WSDLs for the various service endpoints if you want to use those sorts of web services. There are also "simpler" JSON-based interfaces that allow you to create web content structures, templates, and new articles. I will work out an example and post tomorrow. The JSON web services have gone through a couple of iterations in the last couple of releases which is why documentation is scarce - no sense documenting a changing thing. But I believe there is work going on to do this now that it has quieted somewhat.

You can also look at this and this and this thread (but you probably already have).
James Falkner
RE: Web Content Publishing via REST/WS - LR 6 - Newbie question
June 13, 2011 5:42 AM
Answer

James Falkner

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1222

Join Date: September 17, 2010

Recent Posts

Philip Coates:
Any takers?

I'm currently approaching this in a way I feel is somewhat suboptimal:

1) Login programmatically as a user using HttpClient
2) Determine form field names to use an auth ID by scraping and regex-ing the HTML returned (nice that Liferay doesn't produce nicely formed XHTML or HTML so JTidy and XML parsers don't work! This ought to be considered a bug emoticon)
3) Populate for fields for web content and post these in
4) Repeat until all data added
5) Logout

This is all being done using HttpClient call to replicate a user journey through Asset Publisher - surely there's a better way to do this?

Many thanks,

Phil.


I spent some time Friday and ran through a non-trivial example of using Liferay's built-in JSON web services to create new web content. This example can be extended to create new templates, structures, and other items.
Philip Coates
RE: Web Content Publishing via REST/WS - LR 6 - Newbie question
June 13, 2011 1:11 PM
Answer

Philip Coates

Rank: Junior Member

Posts: 34

Join Date: December 10, 2010

Recent Posts

Many thanks for both of these!

I'm running through some of the examples now and using them to form the basis for services; I'll post the code back when I'm done.

A thing that confused me was knowing which user credentials to apply to the tunnel-web call - I wasn't sure if this was a system user or a Liferay user - in which case I'd have expected to see the same credential pairing as in the main UI (i.e. email + password) - it threw me a little having username + password.

Once I've got the HTTPClient version working, I'd be interested in looking at the problem again with Groovy/Grails and getting that posted in, as I tend now to use GonG over Java almost exclusively.

Thanks again!

Phil.
Hamish Campbell
RE: Web Content Publishing via REST/WS
June 28, 2011 4:21 AM
Answer

Hamish Campbell

Rank: Junior Member

Posts: 87

Join Date: August 20, 2008

Recent Posts

Update:

The RSS app has two separate components, the feed consumer which is largely working on the test server, and a Web Content publisher component, which is still in progress:

Feed consumer

The feed consumer component has a list of feeds to monitor (stored in the database)

It periodically (currently on an hourly basis) goes off to each of the feeds it knows about and performs a check for new feed entries and any updates to existing feeds. It stores any new or changed content in the database.

An outstanding task is to create a management interface for this - i.e. adding, removing and updating feeds, although these don't seem to change too much at the moment so this is a lower priority.

The application is built in Spring and Hibernate, with scheduling handled through Quartz, and feeds dealt with using the Rome RSS syndication (all open source)

Web Content publisher

This is what I've been trying to get to work for a while now, with some success following on from the blog post.

This takes feed content from the consumer component and posts it as Web Content items through the Liferay JSON interface.

I've been able to get this partially working: I can publish new entries and update existing ones, but I can't see items I've published through the front end, although they are visibly in the Liferay database, so have been entered. I can update existing items and see the change on the site.

This component mainly uses Apache HTTPClient, and will be integrated with the consumer, so the intermediate database phase is no longer necessary, and feed entries will only be stored into the Liferay database.

Current focus has been getting the publisher client to work, as this is really the crux of things. Once this is working properly it will be relatively simple to tie things together with the feed consumer component.
Philip Coates
RE: Web Content Publishing via REST/WS - LR 6 - Newbie question
July 13, 2011 1:48 AM
Answer

Philip Coates

Rank: Junior Member

Posts: 34

Join Date: December 10, 2010

Recent Posts

Hi,

I've been able to work this into a service suite where I can post into the database and update items, but I can't get articles posted through this mechanism to show up through the Web Content listing in Asset Publisher; am I doing something fundamentally wrong?

When I update an existing article programmatically through this mechanism, everything works fine and the article is updated; new articles appear in the database, but just not on the site. Valid JSON comes back from calling the addArticle method.

I've played around with permissions, trying this using credentials of a couple of different users to post both through the front-end and via JSON, and the front-end way works fine for both, and the groupId seems to be fine (BTW, using auto-generated articleId).

Is there a missing step somewhere along the way, or could it just be something to do with permissions or out setup?

Many thanks,

Phil.
Philip Coates
RE: Web Content Publishing via REST/WS - LR 6 - Newbie question
July 23, 2011 8:20 AM
Answer

Philip Coates

Rank: Junior Member

Posts: 34

Join Date: December 10, 2010

Recent Posts

Anyone have any ideas about the bit that still doesn't want to work?

I can publish to the DB, but new articles published in this way don't appear on the site. Updates and deletes work fine.

Anything special I need to do?
Hamish Campbell
RE: Web Content Publishing via REST/WS - LR 6 - Newbie question
July 25, 2011 6:12 AM
Answer

Hamish Campbell

Rank: Junior Member

Posts: 87

Join Date: August 20, 2008

Recent Posts

BUMP
Brian Scott Schupbach
RE: Web Content Publishing via REST/WS - LR 6 - Newbie question
October 6, 2011 11:14 AM
Answer

Brian Scott Schupbach

Rank: Expert

Posts: 329

Join Date: October 23, 2008

Recent Posts

any resolution to this? I'm using 6.0.6 and the webcontent feed doesn't update unless I clear the cache in the server admin. I looked in the source code and it appears to be set to a hardcoded value of 20 minutes but it doesn't update after 20 minutes...

Thanks,

Brian
Hamish Campbell
RE: Web Content Publishing via REST/WS - LR 6 - Newbie question
October 24, 2011 6:47 AM
Answer

Hamish Campbell

Rank: Junior Member

Posts: 87

Join Date: August 20, 2008

Recent Posts

we are still looking at it, still not working.
Pranay R Patadiya
RE: Web Content Publishing via REST/WS - LR 6 - Newbie question
August 22, 2012 2:44 AM
Answer

Pranay R Patadiya

Rank: Regular Member

Posts: 181

Join Date: February 22, 2010

Recent Posts

Hi,
You can use: Spring Rest

Thanks,
Pranay