List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants ACTION_PUBLISH
int ACTION_PUBLISH
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants ACTION_PUBLISH.
Click Source Link
From source file:com.liferay.journal.search.test.JournalIndexerTest.java
License:Open Source License
protected void articleVersions(boolean delete, boolean all) throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); SearchContext searchContext1 = SearchContextTestUtil.getSearchContext(_group.getGroupId()); searchContext1.setKeywords("Architectural"); assertSearchCount(0, _group.getGroupId(), searchContext1); SearchContext searchContext2 = SearchContextTestUtil.getSearchContext(_group.getGroupId()); searchContext2.setKeywords("Apple"); assertSearchCount(0, _group.getGroupId(), searchContext2); JournalFolder folder = JournalTestUtil.addFolder(_group.getGroupId(), RandomTestUtil.randomString()); JournalArticle article = JournalTestUtil.addArticleWithWorkflow(_group.getGroupId(), folder.getFolderId(), "title", "Liferay Architectural Approach", true); assertSearchCount(1, _group.getGroupId(), searchContext1); String content = DDMStructureTestUtil.getSampleStructuredContent("Apple tablet"); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); article = JournalTestUtil.updateArticle(article, article.getTitleMap(), content, false, true, serviceContext);/* w w w . j av a2 s . c o m*/ assertSearchCount(0, _group.getGroupId(), searchContext1); assertSearchCount(1, _group.getGroupId(), searchContext2); if (all) { if (delete) { JournalArticleLocalServiceUtil.deleteArticle(_group.getGroupId(), article.getArticleId(), serviceContext); } else { JournalArticleLocalServiceUtil.expireArticle(TestPropsValues.getUserId(), _group.getGroupId(), article.getArticleId(), article.getUrlTitle(), serviceContext); } assertSearchCount(0, _group.getGroupId(), searchContext1); } else { if (delete) { JournalArticleLocalServiceUtil.deleteArticle(article); } else { JournalArticleLocalServiceUtil.expireArticle(TestPropsValues.getUserId(), _group.getGroupId(), article.getArticleId(), article.getVersion(), article.getUrlTitle(), serviceContext); } assertSearchCount(1, _group.getGroupId(), searchContext1); } assertSearchCount(0, _group.getGroupId(), searchContext2); }
From source file:com.liferay.journal.search.test.JournalIndexerTest.java
License:Open Source License
protected void indexVersions(boolean delete, boolean all) throws Exception { SearchContext searchContext = SearchContextTestUtil.getSearchContext(_group.getGroupId()); assertSearchCount(0, _group.getGroupId(), searchContext); JournalFolder folder = JournalTestUtil.addFolder(_group.getGroupId(), RandomTestUtil.randomString()); String content = "Liferay Architectural Approach"; JournalArticle article = JournalTestUtil.addArticleWithWorkflow(_group.getGroupId(), folder.getFolderId(), "title", content, true); assertSearchCount(1, _group.getGroupId(), searchContext); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); article = JournalTestUtil.updateArticle(article, article.getTitleMap(), article.getContent(), false, true, serviceContext);//from www.j av a2s.c o m assertSearchCount(2, _group.getGroupId(), false, WorkflowConstants.STATUS_ANY, searchContext); if (delete) { if (all) { JournalArticleLocalServiceUtil.deleteArticle(_group.getGroupId(), article.getArticleId(), serviceContext); assertSearchCount(0, _group.getGroupId(), false, WorkflowConstants.STATUS_ANY, searchContext); } else { JournalArticleLocalServiceUtil.deleteArticle(article); assertSearchCount(1, _group.getGroupId(), false, WorkflowConstants.STATUS_ANY, searchContext); } } else { if (all) { JournalArticleLocalServiceUtil.expireArticle(TestPropsValues.getUserId(), _group.getGroupId(), article.getArticleId(), article.getUrlTitle(), serviceContext); } else { JournalArticleLocalServiceUtil.expireArticle(TestPropsValues.getUserId(), _group.getGroupId(), article.getArticleId(), article.getVersion(), article.getUrlTitle(), serviceContext); } assertSearchCount(2, _group.getGroupId(), false, WorkflowConstants.STATUS_ANY, searchContext); } }
From source file:com.liferay.journal.search.test.JournalIndexerTest.java
License:Open Source License
protected void updateArticle(boolean approve) throws Exception { SearchContext searchContext1 = SearchContextTestUtil.getSearchContext(_group.getGroupId()); searchContext1.setKeywords("Architectural"); assertSearchCount(0, _group.getGroupId(), searchContext1); SearchContext searchContext2 = SearchContextTestUtil.getSearchContext(_group.getGroupId()); searchContext2.setKeywords("Apple"); assertSearchCount(0, _group.getGroupId(), searchContext2); JournalFolder folder = JournalTestUtil.addFolder(_group.getGroupId(), RandomTestUtil.randomString()); JournalArticle article = JournalTestUtil.addArticleWithWorkflow(_group.getGroupId(), folder.getFolderId(), "title", "Liferay Architectural Approach", true); assertSearchCount(1, _group.getGroupId(), searchContext1); String content = DDMStructureTestUtil.getSampleStructuredContent("Apple tablet"); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); if (!approve) { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); } else {// ww w. j av a 2 s .c om serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); } JournalTestUtil.updateArticle(article, article.getTitleMap(), content, false, true, serviceContext); if (approve) { assertSearchCount(0, _group.getGroupId(), searchContext1); assertSearchCount(1, _group.getGroupId(), searchContext2); } else { assertSearchCount(1, _group.getGroupId(), searchContext1); assertSearchCount(0, _group.getGroupId(), searchContext2); } }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Updates the web content article with additional parameters. * * @param userId the primary key of the user updating the web content * article/*from w w w.j av a 2 s.c o m*/ * @param groupId the primary key of the web content article's group * @param folderId the primary key of the web content article folder * @param articleId the primary key of the web content article * @param version the web content article's version * @param titleMap the web content article's locales and localized titles * @param descriptionMap the web content article's locales and localized * descriptions * @param content the HTML content wrapped in XML. For more information, * see the content example in the {@link #addArticle(long, long, * long, long, long, String, boolean, double, Map, Map, String, * String, String, String, int, int, int, int, int, int, int, int, * int, int, boolean, int, int, int, int, int, boolean, boolean, * boolean, String, File, Map, String, ServiceContext)} description. * @param ddmStructureKey the primary key of the web content article's DDM * structure, if the article is related to a DDM structure, or * <code>null</code> otherwise * @param ddmTemplateKey the primary key of the web content article's DDM * template * @param layoutUuid the unique string identifying the web content * article's display page * @param displayDateMonth the month the web content article is set to * display * @param displayDateDay the calendar day the web content article is set to * display * @param displayDateYear the year the web content article is set to * display * @param displayDateHour the hour the web content article is set to * display * @param displayDateMinute the minute the web content article is set to * display * @param expirationDateMonth the month the web content article is set to * expire * @param expirationDateDay the calendar day the web content article is set * to expire * @param expirationDateYear the year the web content article is set to * expire * @param expirationDateHour the hour the web content article is set to * expire * @param expirationDateMinute the minute the web content article is set to * expire * @param neverExpire whether the web content article is not set to auto * expire * @param reviewDateMonth the month the web content article is set for * review * @param reviewDateDay the calendar day the web content article is set for * review * @param reviewDateYear the year the web content article is set for review * @param reviewDateHour the hour the web content article is set for review * @param reviewDateMinute the minute the web content article is set for * review * @param neverReview whether the web content article is not set for review * @param indexable whether the web content is searchable * @param smallImage whether to update web content article's a small image. * A file must be passed in as <code>smallImageFile</code> value, * otherwise the current small image is deleted. * @param smallImageURL the web content article's small image URL * (optionally <code>null</code>) * @param smallImageFile the web content article's new small image file * (optionally <code>null</code>). Must pass in * <code>smallImage</code> value of <code>true</code> to replace the * article's small image file. * @param images the web content's images (optionally <code>null</code>) * @param articleURL the web content article's accessible URL (optionally * <code>null</code>) * @param serviceContext the service context to be applied. Can set the * modification date, expando bridge attributes, asset category IDs, * asset tag names, asset link entry IDs, asset priority, workflow * actions, URL title , and can set whether to add the default * command update for the web content article. With respect to * social activities, by setting the service context's command to * {@link Constants#UPDATE}, the invocation is considered a web * content update activity; otherwise it is considered a web content * add activity. * @return the updated web content article */ @Indexable(type = IndexableType.REINDEX) @Override public JournalArticle updateArticle(long userId, long groupId, long folderId, String articleId, double version, Map<Locale, String> titleMap, Map<Locale, String> descriptionMap, String content, String ddmStructureKey, String ddmTemplateKey, String layoutUuid, int displayDateMonth, int displayDateDay, int displayDateYear, int displayDateHour, int displayDateMinute, int expirationDateMonth, int expirationDateDay, int expirationDateYear, int expirationDateHour, int expirationDateMinute, boolean neverExpire, int reviewDateMonth, int reviewDateDay, int reviewDateYear, int reviewDateHour, int reviewDateMinute, boolean neverReview, boolean indexable, boolean smallImage, String smallImageURL, File smallImageFile, Map<String, byte[]> images, String articleURL, ServiceContext serviceContext) throws PortalException { // Article User user = userLocalService.getUser(userId); articleId = StringUtil.toUpperCase(StringUtil.trim(articleId)); byte[] smallImageBytes = null; try { smallImageBytes = FileUtil.getBytes(smallImageFile); } catch (IOException ioe) { } JournalArticle latestArticle = getLatestArticle(groupId, articleId, WorkflowConstants.STATUS_ANY); JournalArticle article = latestArticle; boolean imported = ExportImportThreadLocal.isImportInProcess(); double latestVersion = latestArticle.getVersion(); boolean addNewVersion = false; if (imported) { article = getArticle(groupId, articleId, version); } else { if ((version > 0) && (version != latestVersion)) { StringBundler sb = new StringBundler(4); sb.append("Version "); sb.append(version); sb.append(" is not the same as "); sb.append(latestVersion); throw new ArticleVersionException(sb.toString()); } serviceContext.validateModifiedDate(latestArticle, ArticleVersionException.class); if (latestArticle.isApproved() || latestArticle.isExpired() || latestArticle.isScheduled()) { addNewVersion = true; version = getNextVersion(article); } } Date displayDate = null; Date expirationDate = null; Date reviewDate = null; if (article.getClassNameId() == JournalArticleConstants.CLASSNAME_ID_DEFAULT) { displayDate = PortalUtil.getDate(displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, user.getTimeZone(), null); if (!neverExpire) { expirationDate = PortalUtil.getDate(expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, user.getTimeZone(), ArticleExpirationDateException.class); } if (!neverReview) { reviewDate = PortalUtil.getDate(reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, user.getTimeZone(), ArticleReviewDateException.class); } } Date now = new Date(); boolean expired = false; if ((expirationDate != null) && expirationDate.before(now)) { expired = true; } validate(user.getCompanyId(), groupId, latestArticle.getClassNameId(), titleMap, content, ddmStructureKey, ddmTemplateKey, displayDate, expirationDate, smallImage, smallImageURL, smallImageFile, smallImageBytes, serviceContext); validateReferences(groupId, ddmStructureKey, ddmTemplateKey, layoutUuid, smallImage, smallImageURL, smallImageBytes, latestArticle.getSmallImageId(), content); if (addNewVersion) { long id = counterLocalService.increment(); article = journalArticlePersistence.create(id); article.setResourcePrimKey(latestArticle.getResourcePrimKey()); article.setGroupId(latestArticle.getGroupId()); article.setCompanyId(latestArticle.getCompanyId()); article.setUserId(user.getUserId()); article.setUserName(user.getFullName()); article.setCreateDate(latestArticle.getCreateDate()); article.setClassNameId(latestArticle.getClassNameId()); article.setClassPK(latestArticle.getClassPK()); article.setArticleId(articleId); article.setVersion(version); article.setSmallImageId(latestArticle.getSmallImageId()); _addArticleLocalizedFields(article.getCompanyId(), article.getId(), titleMap, descriptionMap); } else { _updateArticleLocalizedFields(article.getCompanyId(), article.getId(), titleMap, descriptionMap); } Locale locale = getArticleDefaultLocale(content); String title = titleMap.get(locale); content = format(user, groupId, article, content); article.setFolderId(folderId); article.setTreePath(article.buildTreePath()); article.setUrlTitle(getUniqueUrlTitle(article.getId(), groupId, article.getArticleId(), title, latestArticle.getUrlTitle(), serviceContext)); article.setContent(content); article.setDDMStructureKey(ddmStructureKey); article.setDDMTemplateKey(ddmTemplateKey); article.setDefaultLanguageId(LocaleUtil.toLanguageId(locale)); article.setLayoutUuid(layoutUuid); article.setDisplayDate(displayDate); article.setExpirationDate(expirationDate); article.setReviewDate(reviewDate); article.setIndexable(indexable); article.setSmallImage(smallImage); if (smallImage) { if ((smallImageFile != null) && (smallImageBytes != null)) { article.setSmallImageId(counterLocalService.increment()); } } else { article.setSmallImageId(0); } article.setSmallImageURL(smallImageURL); if (latestArticle.isPending()) { article.setStatus(latestArticle.getStatus()); } else if (!expired) { article.setStatus(WorkflowConstants.STATUS_DRAFT); } else { article.setStatus(WorkflowConstants.STATUS_EXPIRED); } ExpandoBridgeUtil.setExpandoBridgeAttributes(latestArticle.getExpandoBridge(), article.getExpandoBridge(), serviceContext); journalArticlePersistence.update(article); // Asset if (hasModifiedLatestApprovedVersion(groupId, articleId, version)) { updateAsset(userId, article, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds(), serviceContext.getAssetPriority()); } // Dynamic data mapping if (classNameLocalService.getClassNameId(DDMStructure.class) == article.getClassNameId()) { updateDDMStructurePredefinedValues(article.getClassPK(), content, serviceContext); } else { updateDDMLinks(article.getId(), groupId, ddmStructureKey, ddmTemplateKey, addNewVersion); } // Small image saveImages(smallImage, article.getSmallImageId(), smallImageFile, smallImageBytes); // Email PortletPreferences preferences = ServiceContextUtil.getPortletPreferences(serviceContext); // Workflow if (expired && imported) { updateStatus(userId, article, article.getStatus(), articleURL, serviceContext, new HashMap<String, Serializable>()); } if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_PUBLISH) { articleURL = buildArticleURL(articleURL, groupId, folderId, articleId); serviceContext.setAttribute("articleURL", articleURL); sendEmail(article, articleURL, preferences, "requested", serviceContext); startWorkflowInstance(userId, article, serviceContext); } return journalArticlePersistence.findByPrimaryKey(article.getId()); }
From source file:com.liferay.journal.service.test.JournalArticleExpirationTest.java
License:Open Source License
protected JournalArticle addArticle(long groupId, boolean approved) throws Exception { Map<Locale, String> titleMap = new HashMap<>(); titleMap.put(LocaleUtil.getDefault(), RandomTestUtil.randomString()); Map<Locale, String> descriptionMap = new HashMap<>(); descriptionMap.put(LocaleUtil.getDefault(), RandomTestUtil.randomString()); String content = DDMStructureTestUtil.getSampleStructuredContent(); DDMStructure ddmStructure = DDMStructureTestUtil.addStructure(groupId, JournalArticle.class.getName()); DDMTemplate ddmTemplate = DDMTemplateTestUtil.addTemplate(groupId, ddmStructure.getStructureId(), PortalUtil.getClassNameId(JournalArticle.class)); Calendar displayDateCalendar = new GregorianCalendar(); displayDateCalendar.setTime(new Date()); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(groupId); if (approved) { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); } else {/*from w w w . ja v a2s . co m*/ serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); } Calendar expirationDateCalendar = getExpirationCalendar(Time.HOUR, 1); return JournalArticleLocalServiceUtil.addArticle(TestPropsValues.getUserId(), groupId, JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID, JournalArticleConstants.CLASSNAME_ID_DEFAULT, 0, StringPool.BLANK, true, JournalArticleConstants.VERSION_DEFAULT, titleMap, descriptionMap, content, ddmStructure.getStructureKey(), ddmTemplate.getTemplateKey(), null, displayDateCalendar.get(Calendar.MONTH), displayDateCalendar.get(Calendar.DAY_OF_MONTH), displayDateCalendar.get(Calendar.YEAR), displayDateCalendar.get(Calendar.HOUR_OF_DAY), displayDateCalendar.get(Calendar.MINUTE), expirationDateCalendar.get(Calendar.MONTH), expirationDateCalendar.get(Calendar.DAY_OF_MONTH), expirationDateCalendar.get(Calendar.YEAR), expirationDateCalendar.get(Calendar.HOUR_OF_DAY), expirationDateCalendar.get(Calendar.MINUTE), false, 0, 0, 0, 0, 0, true, true, false, null, null, null, null, serviceContext); }
From source file:com.liferay.journal.service.test.JournalArticleExpirationTest.java
License:Open Source License
protected JournalArticle updateArticle(JournalArticle article, int mode) throws Exception { if (mode == _MODE_POSTPONE_EXPIRIRATION) { Calendar displayDateCalendar = new GregorianCalendar(); displayDateCalendar.setTime(article.getDisplayDate()); Calendar expirationDateCalendar = getExpirationCalendar(Time.YEAR, 1); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(article.getGroupId()); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); return JournalArticleLocalServiceUtil.updateArticle(TestPropsValues.getUserId(), article.getGroupId(), article.getFolderId(), article.getArticleId(), article.getVersion(), article.getTitleMap(), article.getDescriptionMap(), article.getContent(), article.getDDMStructureKey(), article.getDDMTemplateKey(), article.getLayoutUuid(), displayDateCalendar.get(Calendar.MONTH), displayDateCalendar.get(Calendar.DAY_OF_MONTH), displayDateCalendar.get(Calendar.YEAR), displayDateCalendar.get(Calendar.HOUR_OF_DAY), displayDateCalendar.get(Calendar.MINUTE), expirationDateCalendar.get(Calendar.MONTH), expirationDateCalendar.get(Calendar.DAY_OF_MONTH), expirationDateCalendar.get(Calendar.YEAR), expirationDateCalendar.get(Calendar.HOUR_OF_DAY), expirationDateCalendar.get(Calendar.MINUTE), false, 0, 0, 0, 0, 0, true, article.getIndexable(), article.isSmallImage(), article.getSmallImageURL(), null, null, null, serviceContext); }//from ww w . j a v a 2s . com return article; }
From source file:com.liferay.journal.service.test.JournalArticleScheduledTest.java
License:Open Source License
protected JournalArticle addArticle(long groupId, Date displayDate, int when, boolean approved) throws Exception { Map<Locale, String> titleMap = new HashMap<>(); titleMap.put(LocaleUtil.getDefault(), RandomTestUtil.randomString()); Map<Locale, String> descriptionMap = new HashMap<>(); descriptionMap.put(LocaleUtil.getDefault(), RandomTestUtil.randomString()); String content = DDMStructureTestUtil.getSampleStructuredContent(); DDMForm ddmForm = DDMStructureTestUtil.getSampleDDMForm(); DDMStructure ddmStructure = DDMStructureTestUtil.addStructure(groupId, JournalArticle.class.getName(), ddmForm);/*from w ww . j a va2 s . c o m*/ DDMTemplate ddmTemplate = DDMTemplateTestUtil.addTemplate(groupId, ddmStructure.getStructureId(), PortalUtil.getClassNameId(JournalArticle.class)); Calendar displayDateCalendar = getCalendar(displayDate, when); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(groupId); if (approved) { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); } else { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); } return JournalArticleLocalServiceUtil.addArticle(TestPropsValues.getUserId(), groupId, JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID, JournalArticleConstants.CLASSNAME_ID_DEFAULT, 0, StringPool.BLANK, true, JournalArticleConstants.VERSION_DEFAULT, titleMap, descriptionMap, content, ddmStructure.getStructureKey(), ddmTemplate.getTemplateKey(), null, displayDateCalendar.get(Calendar.MONTH), displayDateCalendar.get(Calendar.DAY_OF_MONTH), displayDateCalendar.get(Calendar.YEAR), displayDateCalendar.get(Calendar.HOUR_OF_DAY), displayDateCalendar.get(Calendar.MINUTE), 0, 0, 0, 0, 0, true, 0, 0, 0, 0, 0, true, true, false, null, null, null, null, serviceContext); }
From source file:com.liferay.journal.service.test.JournalArticleServiceTest.java
License:Open Source License
protected JournalArticle updateArticleStatus(JournalArticle article, int status) throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(); if (status == WorkflowConstants.STATUS_DRAFT) { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); } else {//from w ww .j a va 2s .c o m serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); } return JournalTestUtil.updateArticle(article, "Version 2", article.getContent(), false, true, serviceContext); }
From source file:com.liferay.journal.test.util.JournalTestUtil.java
License:Open Source License
public static JournalArticle addArticle(long groupId, long folderId, long classNameId, String articleId, boolean autoArticleId, Map<Locale, String> titleMap, Map<Locale, String> descriptionMap, Map<Locale, String> contentMap, String layoutUuid, Locale defaultLocale, Date expirationDate, boolean workflowEnabled, boolean approved, ServiceContext serviceContext) throws Exception { String content = DDMStructureTestUtil.getSampleStructuredContent(contentMap, LocaleUtil.toLanguageId(defaultLocale)); DDMForm ddmForm = DDMStructureTestUtil.getSampleDDMForm(_locales, defaultLocale); long ddmGroupId = GetterUtil.getLong(serviceContext.getAttribute("ddmGroupId"), groupId); DDMStructure ddmStructure = DDMStructureTestUtil.addStructure(ddmGroupId, JournalArticle.class.getName(), ddmForm, defaultLocale);/*from ww w .j ava 2 s . c o m*/ DDMTemplate ddmTemplate = DDMTemplateTestUtil.addTemplate(ddmGroupId, ddmStructure.getStructureId(), PortalUtil.getClassNameId(JournalArticle.class)); boolean neverExpire = true; int expirationDateDay = 0; int expirationDateMonth = 0; int expirationDateYear = 0; int expirationDateHour = 0; int expirationDateMinute = 0; if (expirationDate != null) { neverExpire = false; Calendar expirationCal = CalendarFactoryUtil.getCalendar(TestPropsValues.getUser().getTimeZone()); expirationCal.setTime(expirationDate); expirationDateMonth = expirationCal.get(Calendar.MONTH); expirationDateDay = expirationCal.get(Calendar.DATE); expirationDateYear = expirationCal.get(Calendar.YEAR); expirationDateHour = expirationCal.get(Calendar.HOUR_OF_DAY); expirationDateMinute = expirationCal.get(Calendar.MINUTE); } Calendar displayCal = CalendarFactoryUtil.getCalendar(TestPropsValues.getUser().getTimeZone()); int displayDateDay = displayCal.get(Calendar.DATE); int displayDateMonth = displayCal.get(Calendar.MONTH); int displayDateYear = displayCal.get(Calendar.YEAR); int displayDateHour = displayCal.get(Calendar.HOUR_OF_DAY); int displayDateMinute = displayCal.get(Calendar.MINUTE); if (workflowEnabled) { serviceContext = (ServiceContext) serviceContext.clone(); if (approved) { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); } else { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); } } return JournalArticleLocalServiceUtil.addArticle(serviceContext.getUserId(), groupId, folderId, classNameId, 0, articleId, autoArticleId, JournalArticleConstants.VERSION_DEFAULT, titleMap, descriptionMap, content, ddmStructure.getStructureKey(), ddmTemplate.getTemplateKey(), layoutUuid, displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, 0, 0, 0, 0, 0, true, true, false, null, null, null, null, serviceContext); }
From source file:com.liferay.journal.test.util.JournalTestUtil.java
License:Open Source License
public static JournalArticle updateArticle(long userId, JournalArticle article, Map<Locale, String> titleMap, String content, boolean workflowEnabled, boolean approved, ServiceContext serviceContext) throws Exception { if (workflowEnabled) { serviceContext = (ServiceContext) serviceContext.clone(); if (approved) { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); } else {//from w ww .j a va 2 s. c o m serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); } } Date displayDate = article.getDisplayDate(); int displayDateMonth = 0; int displayDateDay = 0; int displayDateYear = 0; int displayDateHour = 0; int displayDateMinute = 0; if (displayDate != null) { Calendar displayCal = CalendarFactoryUtil.getCalendar(TestPropsValues.getUser().getTimeZone()); displayCal.setTime(displayDate); displayDateMonth = displayCal.get(Calendar.MONTH); displayDateDay = displayCal.get(Calendar.DATE); displayDateYear = displayCal.get(Calendar.YEAR); displayDateHour = displayCal.get(Calendar.HOUR_OF_DAY); displayDateMinute = displayCal.get(Calendar.MINUTE); } serviceContext.setCommand(Constants.UPDATE); serviceContext.setLayoutFullURL("http://localhost"); return JournalArticleLocalServiceUtil.updateArticle(userId, article.getGroupId(), article.getFolderId(), article.getArticleId(), article.getVersion(), titleMap, article.getDescriptionMap(), content, article.getDDMStructureKey(), article.getDDMTemplateKey(), article.getLayoutUuid(), displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, 0, 0, 0, 0, 0, true, 0, 0, 0, 0, 0, true, article.getIndexable(), article.isSmallImage(), article.getSmallImageURL(), null, null, null, serviceContext); }