Fórum
Add articles to Liferay programmatically?
Marc Vanderstraeten, modificado 15 Anos atrás.
Add articles to Liferay programmatically?
New Member Postagens: 4 Data de Entrada: 04/06/08 Postagens Recentes
I am a newbie to Liferay. I would like to add programmatically articles (or other content) to liferay using php or via other means (xml, http, rest, soap...), or even directly in MySQL? Is this possible?
I need to run a program that monitors a directory on a ftp server where xml files (articles form a new site) are posted on a daily basis, and should be imported regularly (cron job) and put in Liferay as articles, and then deleted (the .xml files of course).
The articles put in Liferay this way are in draft mode (not yet published) and can then be reviewed/changed and finally be published.
How can I accomplish this?
I have some articles attached...
Please help... or do I have to go back to a php based solution?
I need to run a program that monitors a directory on a ftp server where xml files (articles form a new site) are posted on a daily basis, and should be imported regularly (cron job) and put in Liferay as articles, and then deleted (the .xml files of course).
The articles put in Liferay this way are in draft mode (not yet published) and can then be reviewed/changed and finally be published.
How can I accomplish this?
I have some articles attached...
Please help... or do I have to go back to a php based solution?
Björn Ryding, modificado 15 Anos atrás.
RE: Add articles to Liferay programmatically?
Liferay Master Postagens: 582 Data de Entrada: 16/05/07 Postagens Recentes
Hi Marc,
Have a look at Liferay's Journal Article Service:
http://content.liferay.com/4.3/api/portal-service/com/liferay/portlet/journal/service/JournalArticleService.html
When updating the articles, the journal portlet's webdav interface may also be an option.
Cheers,
Björn
Have a look at Liferay's Journal Article Service:
http://content.liferay.com/4.3/api/portal-service/com/liferay/portlet/journal/service/JournalArticleService.html
When updating the articles, the journal portlet's webdav interface may also be an option.
Cheers,
Björn
Björn Ryding, modificado 15 Anos atrás.
RE: Add articles to Liferay programmatically?
Liferay Master Postagens: 582 Data de Entrada: 16/05/07 Postagens Recentes
I forgot to mention that you can access Liferay's services in a number of ways.
For example, to access a service using SOAP use:
http://localhost:8080/tunnel-web/secure/axis/someServiceOfYourChoice
The Web Service Deployment Descriptor with the service names is located at:
webapps/tunnel-web/WEB-INF/server-config.wsdd
For some introductory information about how Liferay's services are built, see:
http://www.liferay.com/web/guest/products/tech_specs/architecture/soa
For example, to access a service using SOAP use:
http://localhost:8080/tunnel-web/secure/axis/someServiceOfYourChoice
The Web Service Deployment Descriptor with the service names is located at:
webapps/tunnel-web/WEB-INF/server-config.wsdd
For some introductory information about how Liferay's services are built, see:
http://www.liferay.com/web/guest/products/tech_specs/architecture/soa
navkalp varshney, modificado 15 Anos atrás.
RE: Add articles to Liferay programmatically?
New Member Postagens: 8 Data de Entrada: 27/06/08 Postagens Recentes
for articles seems there are no webdav URLs. Is it possible to create htmls from portlets programmatically, or save article programmatically in html format
Radu Banica, modificado 15 Anos atrás.
RE: Add articles to Liferay programmatically?
New Member Postagens: 11 Data de Entrada: 19/06/08 Postagens Recentes
I have successfully used the function JournalArticleServiceUtil.addArticle in a portlet to add a new article.
The portlet parse an XML file with a list of article content and calls this function. You can also load images to the article by playing with the "Map<String, byte[]> images" parameter.
You can approve the article automatically by calling the function JournalArticleServiceUtil.approveArticle
The portlet parse an XML file with a list of article content and calls this function. You can also load images to the article by playing with the "Map<String, byte[]> images" parameter.
You can approve the article automatically by calling the function JournalArticleServiceUtil.approveArticle
Edgar Tanaka, modificado 13 Anos atrás.
RE: Add articles to Liferay programmatically?
New Member Postagens: 4 Data de Entrada: 24/11/10 Postagens RecentesRadu B:
I have successfully used the function JournalArticleServiceUtil.addArticle in a portlet to add a new article.
The portlet parse an XML file with a list of article content and calls this function. You can also load images to the article by playing with the "Map<String, byte[]> images" parameter.
You can approve the article automatically by calling the function JournalArticleServiceUtil.approveArticle
This approveArticle method is not available after version 6. I spent a lot of time trying to figure out how to add article programatically and make them approved right away. The way to do it if you are using version 6.0.5 is set a workflow aciton in your ServiceContext object:
JournalArticleServiceSoapServiceLocator locator = new JournalArticleServiceSoapServiceLocator();
ServiceContext serviceContext = new ServiceContext();
serviceContext.setScopeGroupId(GROUP_ID);
serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); //so that the article is added as published and not draft
JournalArticleServiceSoap soap = locator.getPortlet_Journal_JournalArticleService(LifeRayUtils.getURL(remoteUser, remotePassword, ARTICLE_ENTRY_SERVICE_NAME, server, port));
JournalArticleSoap jas = soap.addArticle(GROUP_ID,
b.getBlogId().toString(),
true, //autoArticleId
b.getTitle(), //title
null, //description
b.getBody(), //content
"news", //type: General, news, blogs, test, press release
"", // structure id
"", //template id
displayDateMonth,
displayDateDay,
displayDateYear,
displayDateHour,
displayDateMinute,
0, //expirationDateMonth
0, //expirationDateDay
0, //expirationDateYear
0, //expirationDateHour
0, //expirationDateMinute
true, //never expire
0, //reviewDateMonth
0, //reviewDateDay
0, //reviewDateYear
0, //reviewDateHour
0, //reviewDateMinute
true, //neverReview
true, //indexable
"", //articleURL
serviceContext);
I hope this help someone save time in the future.
Suraj Bihari, modificado 12 Anos atrás.
RE: Add articles to Liferay programmatically?
Junior Member Postagens: 41 Data de Entrada: 20/05/11 Postagens Recentes
Thanks from the future!
Edgar Tanaka:
I hope this help someone save time in the future.
Jacques Traore, modificado 10 Anos atrás.
RE: Add articles to Liferay programmatically?
Junior Member Postagens: 49 Data de Entrada: 21/01/13 Postagens Recentes
Hi Edgar,
What about translation?
My contents (with a custom structure) have both English and French versions.
How to construct the XML content to achieve this?
Thanks
What about translation?
My contents (with a custom structure) have both English and French versions.
How to construct the XML content to achieve this?
Thanks
Anirudh Joshi, modificado 8 Anos atrás.
RE: Add articles to Liferay programmatically?
New Member Postagens: 7 Data de Entrada: 11/11/05 Postagens Recentes
were you able to achieve this? We also want to do the same and create translated content which come to back to us from a 3rd party in a XML format
Thanks
Ani
Thanks
Ani
Olaf Kock, modificado 8 Anos atrás.
RE: Add articles to Liferay programmatically?
Liferay Legend Postagens: 6396 Data de Entrada: 23/09/08 Postagens Recentes
A very stupid version (just by concatenating strings - the way you shouldn't construct xml in production) was demonstrated in my Ridiculously simple plugins session on dev.life - code is linked from the article. Just use proper xml construction and assume that the individual string snippets are safe to concatenate when you look at my code. At least it's easy to understand that way.
mallepula narayanagoud, modificado 14 Anos atrás.
RE: Add articles to Liferay programmatically?
Junior Member Postagens: 95 Data de Entrada: 18/06/09 Postagens Recentes
Hi Marc,
i have the same issues,can u help me to resolve the problem.
if possible send me code or approach.
Thanks,
Mallepula.
i have the same issues,can u help me to resolve the problem.
if possible send me code or approach.
Thanks,
Mallepula.
Victor Zorin, modificado 14 Anos atrás.
RE: Add articles to Liferay programmatically?
Liferay Legend Postagens: 1228 Data de Entrada: 14/04/08 Postagens Recentes
you may also read this link: How to use liferay for Larger Sites, it was in v5.1.* but the approach is still relevant.