掲示板

Adding Article via Web Service with Published Status

13年前 に Chris Buley によって更新されました。

Adding Article via Web Service with Published Status

New Member 投稿: 4 参加年月日: 10/10/21 最新の投稿
Using Liferay 6 with Tomcat Bundle.

I am successfully adding journal articles to my liferay system and then adding categories to the associated Asset. All of that is going well, and I am about 90% to where I need to be. One last stumbling block is how I can make the posted articles have a published status after I have added them rather than draft status. Any help would be greatly appreciated.

Here is the basic code snippet I am using:


            ServiceContext context = new ServiceContext();
            JournalArticleSoap newArticle = jasssSoap.addArticle(
                    groupId,
                    "", // articleId, or blank string if using auto
                    true, // autoArticleId?
                    title,
                    abstractText,
                    body,
                    "news", // type
                    "", // structureId
                    "", // templateId
                    cal.get(Calendar.MONTH), //displayDateMonthInt
                    cal.get(Calendar.DAY_OF_MONTH), //displayDateDayInt
                    cal.get(Calendar.YEAR), //displayDateYearInt
                    cal.get(Calendar.HOUR_OF_DAY), //displayDateHourInt
                    cal.get(Calendar.MINUTE), //displayDateMinuteInt
                    1, //expirationDateMonthInt
                    1, //expirationDateDayInt
                    1, //expirationDateYearInt
                    1, //expirationDateHourInt
                    1, //expirationDateMinuteInt
                    true, //neverExpireBool
                    1, //reviewDateMonthInt
                    1, //reviewDateDayInt
                    1, //reviewDateYearInt
                    1, //reviewDateHourInt
                    1, //reviewDateMinuteInt
                    true, //neverReview
                    true, //indexable
                    null, //articleUrl
                    context //serviceContextProbablyNull
              );

            AssetEntryServiceSoap aesssSoap = aesssLocator.getPortlet_Asset_AssetEntryService(generateUrl(userId, password,"Portlet_Asset_AssetEntryService"));

            long[] categoryIds = new long[] {catId};
            String[] tagNames = new String[0];

            // This call is modeled on a call in AssetEntryLocalServiceImpl for just updating the cats
            aesssSoap.updateEntry(
                    newArticle.getGroupId(),
                    "com.liferay.portlet.journal.model.JournalArticle",
                    newArticle.getResourcePrimKey(),
                    null, // classUuid
                    categoryIds,
                    tagNames,
                    true, // visible
                    null, // start date
                    null, // endDate
                    null, // publishDate
                    null, // expirationDate
                    null, // mimeType
                    null, // title
                    null, // description
                    null, // summary
                    null, // url
                    0, // height
                    0, // width
                    0, // priority
                    false //sync
                );
12年前 に Fabien Fabien によって更新されました。

RE: Adding Article via Web Service with Published Status

New Member 投稿: 5 参加年月日: 11/05/17 最新の投稿
Hi.

I am actually having the same problem. Do you find an issue to published an article by webservice ?

Sincerely
thumbnail
12年前 に Hitoshi Ozawa によって更新されました。

RE: Adding Article via Web Service with Published Status

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
The easiest way if you're not using workflow, is to just disable a workflow from the control panel.

Control Panel -> Workflor Configuration -> set Web Content to "Default: No workflow" and save the change.
thumbnail
11年前 に Kousik Kumar Das によって更新されました。

RE: Adding Article via Web Service with Published Status

New Member 投稿: 7 参加年月日: 11/05/09 最新の投稿
I'm working with LF 6.1.10 server, and have no workflow (kaleo) enabled.
While trying to publish the newly created article through webservice (soap api) implementation, its creating article with DRAFT status.

Code snippet, I tried:

articleSoap = journalArticleServiceSoap.addArticle(groupId, classNameId, classPK, articleId, autoArticleId, titleMapLanguageIds, titleMapValues, descriptionMapLanguageIds, descriptionMapValues, webContent, type, structureId, templateId, layoutUuid, displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview, indexable, articleURL, serviceContext);

articleSoap.setStatus(WorkflowConstants.STATUS_APPROVED);
articleSoap.setStatusByUserId(userId);
articleSoap.setStatusByUserName(username);
articleSoap.setStatusDate(GregorianCalendar.getInstance());

serviceContext.setUserId(userId);
serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH);

updateArticle(groupId, articleSoap.getArticleId(), new Double("1.0").doubleValue(), webContent, serviceContext);


Any help
thumbnail
11年前 に Kousik Kumar Das によって更新されました。

RE: Adding Article via Web Service with Published Status

New Member 投稿: 7 参加年月日: 11/05/09 最新の投稿
emoticon Here I made it to work !!!

All we need to prepare the ServiceContext properly before the call journalArticleServiceSoap.addArticle(...) method.
code:

ServiceContext serviceContext = new ServiceContext();
serviceContext.setAddGuestPermissions(true);
serviceContext.setAddGroupPermissions(true);
serviceContext.setScopeGroupId(groupId);
serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH);


The above bold line will create your journal article with APPROVED status.

Happy learning !!! folks !!!