List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants ACTION_SAVE_DRAFT
int ACTION_SAVE_DRAFT
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants ACTION_SAVE_DRAFT.
Click Source Link
From source file:com.liferay.dynamic.data.mapping.form.web.internal.portlet.action.AddFormInstanceRecordMVCResourceCommand.java
License:Open Source License
protected ServiceContext createServiceContext(ResourceRequest resourceRequest) throws PortalException { ServiceContext serviceContext = ServiceContextFactory.getInstance(DDMFormInstanceRecord.class.getName(), resourceRequest);/* w w w .j a v a2 s . c o m*/ serviceContext.setAttribute("status", WorkflowConstants.STATUS_DRAFT); serviceContext.setAttribute("validateDDMFormValues", Boolean.FALSE); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); return serviceContext; }
From source file:com.liferay.dynamic.data.mapping.form.web.internal.portlet.action.SaveFormInstanceMVCCommandHelper.java
License:Open Source License
protected DDMFormInstance updateFormInstance(PortletRequest portletRequest, long ddmStructureId, Set<Locale> availableLocales, Locale defaultLocale, DDMFormValues settingsDDMFormValues) throws Exception { long formInstanceId = ParamUtil.getLong(portletRequest, "formInstanceId"); String name = ParamUtil.getString(portletRequest, "name"); String description = ParamUtil.getString(portletRequest, "description"); ServiceContext serviceContext = ServiceContextFactory.getInstance(DDMFormInstance.class.getName(), portletRequest);//from w ww. j a v a 2 s .co m if (ParamUtil.getBoolean(portletRequest, "autoSave")) { serviceContext.setAttribute("status", WorkflowConstants.ACTION_SAVE_DRAFT); } return formInstanceService.updateFormInstance(formInstanceId, ddmStructureId, getLocalizedMap(name, availableLocales, defaultLocale), getLocalizedMap(description, availableLocales, defaultLocale), settingsDDMFormValues, serviceContext); }
From source file:com.liferay.dynamic.data.mapping.service.impl.DDMFormInstanceRecordLocalServiceImpl.java
License:Open Source License
protected boolean isKeepFormInstanceRecordVersionLabel( DDMFormInstanceRecordVersion lastDDMFormInstanceRecordVersion, DDMFormInstanceRecordVersion latestDDMFormInstanceRecordVersion, ServiceContext serviceContext) throws PortalException { if (Objects.equals(serviceContext.getCommand(), Constants.REVERT)) { return false; }/*from w ww . j av a 2 s .co m*/ if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_SAVE_DRAFT) { return false; } if (Objects.equals(lastDDMFormInstanceRecordVersion.getVersion(), latestDDMFormInstanceRecordVersion.getVersion())) { return false; } StorageEngine storageEngine = storageEngineAccessor.getStorageEngine(); DDMFormValues lastDDMFormValues = storageEngine .getDDMFormValues(lastDDMFormInstanceRecordVersion.getStorageId()); DDMFormValues latestDDMFormValues = storageEngine .getDDMFormValues(latestDDMFormInstanceRecordVersion.getStorageId()); if (!lastDDMFormValues.equals(latestDDMFormValues)) { return false; } ExpandoBridge lastExpandoBridge = lastDDMFormInstanceRecordVersion.getExpandoBridge(); ExpandoBridge latestExpandoBridge = latestDDMFormInstanceRecordVersion.getExpandoBridge(); Map<String, Serializable> lastAttributes = lastExpandoBridge.getAttributes(); Map<String, Serializable> latestAttributes = latestExpandoBridge.getAttributes(); if (!lastAttributes.equals(latestAttributes)) { return false; } return true; }
From source file:com.liferay.exportimport.lar.PortletDataContextImpl.java
License:Open Source License
protected ServiceContext createServiceContext(Element element, String path, ClassedModel classedModel, Class<?> clazz) {/* w w w.jav a2s . com*/ ServiceContext serviceContext = new ServiceContext(); // Theme display serviceContext.setCompanyId(getCompanyId()); serviceContext.setScopeGroupId(getScopeGroupId()); // Dates if (classedModel instanceof AuditedModel) { AuditedModel auditedModel = (AuditedModel) classedModel; serviceContext.setUserId(getUserId(auditedModel)); serviceContext.setCreateDate(auditedModel.getCreateDate()); serviceContext.setModifiedDate(auditedModel.getModifiedDate()); } // Permissions if (!MapUtil.getBoolean(_parameterMap, PortletDataHandlerKeys.PERMISSIONS)) { serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); } // Asset if (isResourceMain(classedModel)) { Serializable classPKObj = ExportImportClassedModelUtil.getPrimaryKeyObj(classedModel); long[] assetCategoryIds = getAssetCategoryIds(clazz, classPKObj); serviceContext.setAssetCategoryIds(assetCategoryIds); String[] assetTagNames = getAssetTagNames(clazz, classPKObj); serviceContext.setAssetTagNames(assetTagNames); } if (element != null) { Attribute assetPriorityAttribute = element.attribute("asset-entry-priority"); if (assetPriorityAttribute != null) { double assetPriority = GetterUtil.getDouble(assetPriorityAttribute.getValue()); serviceContext.setAssetPriority(assetPriority); } } // Expando String expandoPath = null; if (element != null) { expandoPath = element.attributeValue("expando-path"); } else { expandoPath = ExportImportPathUtil.getExpandoPath(path); } if (Validator.isNotNull(expandoPath)) { try { Map<String, Serializable> expandoBridgeAttributes = (Map<String, Serializable>) getZipEntryAsObject( expandoPath); if (expandoBridgeAttributes != null) { serviceContext.setExpandoBridgeAttributes(expandoBridgeAttributes); } } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } } } // Workflow if (classedModel instanceof WorkflowedModel) { WorkflowedModel workflowedModel = (WorkflowedModel) classedModel; if (workflowedModel.getStatus() == WorkflowConstants.STATUS_APPROVED) { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); } else if (workflowedModel.getStatus() == WorkflowConstants.STATUS_DRAFT) { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); } } return serviceContext; }
From source file:com.liferay.journal.exportimport.data.handler.JournalArticleStagedModelDataHandler.java
License:Open Source License
@Override protected void doImportStagedModel(PortletDataContext portletDataContext, JournalArticle article) throws Exception { long userId = portletDataContext.getUserId(article.getUserUuid()); long authorId = _journalCreationStrategy.getAuthorUserId(portletDataContext, article); if (authorId != JournalCreationStrategy.USE_DEFAULT_USER_ID_STRATEGY) { userId = authorId;//w ww . j a v a 2 s .c om } User user = _userLocalService.getUser(userId); Map<Long, Long> folderIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(JournalFolder.class); long folderId = MapUtil.getLong(folderIds, article.getFolderId(), article.getFolderId()); String articleId = article.getArticleId(); boolean autoArticleId = false; if (Validator.isNumber(articleId) || (_journalArticleLocalService.fetchArticle(portletDataContext.getScopeGroupId(), articleId, JournalArticleConstants.VERSION_DEFAULT) != null)) { autoArticleId = true; } Map<String, String> articleIds = (Map<String, String>) portletDataContext .getNewPrimaryKeysMap(JournalArticle.class + ".articleId"); String newArticleId = articleIds.get(articleId); if (Validator.isNotNull(newArticleId)) { // A sibling of a different version was already assigned a new // article id articleId = newArticleId; autoArticleId = false; } String content = article.getContent(); content = _journalArticleExportImportContentProcessor.replaceImportContentReferences(portletDataContext, article, content); article.setContent(content); String newContent = _journalCreationStrategy.getTransformedContent(portletDataContext, article); if (newContent != JournalCreationStrategy.ARTICLE_CONTENT_UNCHANGED) { article.setContent(newContent); } 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(user.getTimeZone()); displayCal.setTime(displayDate); displayDateMonth = displayCal.get(Calendar.MONTH); displayDateDay = displayCal.get(Calendar.DATE); displayDateYear = displayCal.get(Calendar.YEAR); displayDateHour = displayCal.get(Calendar.HOUR); displayDateMinute = displayCal.get(Calendar.MINUTE); if (displayCal.get(Calendar.AM_PM) == Calendar.PM) { displayDateHour += 12; } } Date expirationDate = article.getExpirationDate(); int expirationDateMonth = 0; int expirationDateDay = 0; int expirationDateYear = 0; int expirationDateHour = 0; int expirationDateMinute = 0; boolean neverExpire = true; if (expirationDate != null) { Calendar expirationCal = CalendarFactoryUtil.getCalendar(user.getTimeZone()); expirationCal.setTime(expirationDate); expirationDateMonth = expirationCal.get(Calendar.MONTH); expirationDateDay = expirationCal.get(Calendar.DATE); expirationDateYear = expirationCal.get(Calendar.YEAR); expirationDateHour = expirationCal.get(Calendar.HOUR); expirationDateMinute = expirationCal.get(Calendar.MINUTE); neverExpire = false; if (expirationCal.get(Calendar.AM_PM) == Calendar.PM) { expirationDateHour += 12; } } Date reviewDate = article.getReviewDate(); int reviewDateMonth = 0; int reviewDateDay = 0; int reviewDateYear = 0; int reviewDateHour = 0; int reviewDateMinute = 0; boolean neverReview = true; if (reviewDate != null) { Calendar reviewCal = CalendarFactoryUtil.getCalendar(user.getTimeZone()); reviewCal.setTime(reviewDate); reviewDateMonth = reviewCal.get(Calendar.MONTH); reviewDateDay = reviewCal.get(Calendar.DATE); reviewDateYear = reviewCal.get(Calendar.YEAR); reviewDateHour = reviewCal.get(Calendar.HOUR); reviewDateMinute = reviewCal.get(Calendar.MINUTE); neverReview = false; if (reviewCal.get(Calendar.AM_PM) == Calendar.PM) { reviewDateHour += 12; } } Map<String, String> ddmStructureKeys = (Map<String, String>) portletDataContext .getNewPrimaryKeysMap(DDMStructure.class + ".ddmStructureKey"); String parentDDMStructureKey = MapUtil.getString(ddmStructureKeys, article.getDDMStructureKey(), article.getDDMStructureKey()); Map<String, Long> ddmStructureIds = (Map<String, Long>) portletDataContext .getNewPrimaryKeysMap(DDMStructure.class); long ddmStructureId = 0; if (article.getClassNameId() != 0) { ddmStructureId = ddmStructureIds.get(article.getClassPK()); } Map<String, String> ddmTemplateKeys = (Map<String, String>) portletDataContext .getNewPrimaryKeysMap(DDMTemplate.class + ".ddmTemplateKey"); String parentDDMTemplateKey = MapUtil.getString(ddmTemplateKeys, article.getDDMTemplateKey(), article.getDDMTemplateKey()); File smallFile = null; try { Element articleElement = portletDataContext.getImportDataStagedModelElement(article); if (article.isSmallImage()) { String smallImagePath = articleElement.attributeValue("small-image-path"); if (Validator.isNotNull(article.getSmallImageURL())) { String smallImageURL = _journalArticleExportImportContentProcessor .replaceImportContentReferences(portletDataContext, article, article.getSmallImageURL()); article.setSmallImageURL(smallImageURL); } else if (Validator.isNotNull(smallImagePath)) { byte[] bytes = portletDataContext.getZipEntryAsByteArray(smallImagePath); if (bytes != null) { smallFile = FileUtil.createTempFile(article.getSmallImageType()); FileUtil.write(smallFile, bytes); } } } JournalArticle latestArticle = _journalArticleLocalService .fetchLatestArticle(article.getResourcePrimKey()); if ((latestArticle != null) && (latestArticle.getId() == article.getId())) { List<Element> attachmentElements = portletDataContext.getReferenceDataElements(article, DLFileEntry.class, PortletDataContext.REFERENCE_TYPE_WEAK); for (Element attachmentElement : attachmentElements) { String path = attachmentElement.attributeValue("path"); FileEntry fileEntry = (FileEntry) portletDataContext.getZipEntryAsObject(path); InputStream inputStream = null; try { String binPath = attachmentElement.attributeValue("bin-path"); if (Validator.isNull(binPath) && portletDataContext.isPerformDirectBinaryImport()) { try { inputStream = FileEntryUtil.getContentStream(fileEntry); } catch (NoSuchFileException nsfe) { } } else { inputStream = portletDataContext.getZipEntryAsInputStream(binPath); } if (inputStream == null) { if (_log.isWarnEnabled()) { _log.warn("Unable to import attachment for file " + "entry " + fileEntry.getFileEntryId()); } continue; } TempFileEntryUtil.addTempFileEntry(portletDataContext.getScopeGroupId(), userId, JournalArticleStagedModelDataHandler.class.getName(), fileEntry.getFileName(), inputStream, fileEntry.getMimeType()); } finally { StreamUtil.cleanUp(inputStream); } } } String articleURL = null; boolean addGroupPermissions = _journalCreationStrategy.addGroupPermissions(portletDataContext, article); boolean addGuestPermissions = _journalCreationStrategy.addGuestPermissions(portletDataContext, article); ServiceContext serviceContext = portletDataContext.createServiceContext(article); serviceContext.setAddGroupPermissions(addGroupPermissions); serviceContext.setAddGuestPermissions(addGuestPermissions); if ((expirationDate != null) && expirationDate.before(new Date())) { article.setStatus(WorkflowConstants.STATUS_EXPIRED); } if ((article.getStatus() != WorkflowConstants.STATUS_APPROVED) && (article.getStatus() != WorkflowConstants.STATUS_SCHEDULED)) { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); } JournalArticle importedArticle = null; String articleResourceUuid = articleElement.attributeValue("article-resource-uuid"); // Used when importing LARs with journal schemas under 1.1.0 _setLegacyValues(article); if (portletDataContext.isDataStrategyMirror()) { serviceContext.setUuid(article.getUuid()); serviceContext.setAttribute("articleResourceUuid", articleResourceUuid); serviceContext.setAttribute("urlTitle", article.getUrlTitle()); boolean preloaded = GetterUtil.getBoolean(articleElement.attributeValue("preloaded")); JournalArticle existingArticle = fetchExistingArticle(articleResourceUuid, portletDataContext.getScopeGroupId(), articleId, newArticleId, preloaded); JournalArticle existingArticleVersion = null; if (existingArticle != null) { existingArticleVersion = fetchExistingArticleVersion(article.getUuid(), portletDataContext.getScopeGroupId(), existingArticle.getArticleId(), article.getVersion()); } if ((existingArticle != null) && (existingArticleVersion == null)) { autoArticleId = false; articleId = existingArticle.getArticleId(); } if (existingArticleVersion == null) { importedArticle = _journalArticleLocalService.addArticle(userId, portletDataContext.getScopeGroupId(), folderId, article.getClassNameId(), ddmStructureId, articleId, autoArticleId, article.getVersion(), article.getTitleMap(), article.getDescriptionMap(), article.getContent(), parentDDMStructureKey, parentDDMTemplateKey, article.getLayoutUuid(), displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview, article.isIndexable(), article.isSmallImage(), article.getSmallImageURL(), smallFile, null, articleURL, serviceContext); } else { importedArticle = _journalArticleLocalService.updateArticle(userId, existingArticle.getGroupId(), folderId, existingArticle.getArticleId(), article.getVersion(), article.getTitleMap(), article.getDescriptionMap(), article.getContent(), parentDDMStructureKey, parentDDMTemplateKey, article.getLayoutUuid(), displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview, article.isIndexable(), article.isSmallImage(), article.getSmallImageURL(), smallFile, null, articleURL, serviceContext); String articleUuid = article.getUuid(); String importedArticleUuid = importedArticle.getUuid(); if (!articleUuid.equals(importedArticleUuid)) { importedArticle.setUuid(articleUuid); _journalArticleLocalService.updateJournalArticle(importedArticle); } } } else { importedArticle = _journalArticleLocalService.addArticle(userId, portletDataContext.getScopeGroupId(), folderId, article.getClassNameId(), ddmStructureId, articleId, autoArticleId, article.getVersion(), article.getTitleMap(), article.getDescriptionMap(), article.getContent(), parentDDMStructureKey, parentDDMTemplateKey, article.getLayoutUuid(), displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview, article.isIndexable(), article.isSmallImage(), article.getSmallImageURL(), smallFile, null, articleURL, serviceContext); } portletDataContext.importClassedModel(article, importedArticle); if (Validator.isNull(newArticleId)) { articleIds.put(article.getArticleId(), importedArticle.getArticleId()); } Map<Long, Long> articlePrimaryKeys = (Map<Long, Long>) portletDataContext .getNewPrimaryKeysMap(JournalArticle.class + ".primaryKey"); articlePrimaryKeys.put(article.getPrimaryKey(), importedArticle.getPrimaryKey()); } finally { if (smallFile != null) { smallFile.delete(); } } }
From source file:com.liferay.journal.search.test.JournalIndexerTest.java
License:Open Source License
@Test public void testIndexVersions() 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(), false, WorkflowConstants.STATUS_ANY, searchContext); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); article = JournalTestUtil.updateArticle(article, article.getTitleMap(), article.getContent(), false, true, serviceContext);/*from w w w . j a v a 2s . c om*/ assertSearchCount(2, _group.getGroupId(), false, WorkflowConstants.STATUS_ANY, searchContext); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); JournalTestUtil.updateArticle(article, article.getTitleMap(), article.getContent(), false, true, serviceContext); assertSearchCount(3, _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 {//www . j a v a 2 s . c o m 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.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 . j a v a 2s . c o 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.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 ww w .ja va 2s . co 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 v a 2 s. co m serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); } return JournalTestUtil.updateArticle(article, "Version 2", article.getContent(), false, true, serviceContext); }