List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED
int STATUS_APPROVED
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED.
Click Source Link
From source file:com.liferay.journal.content.web.internal.portlet.JournalContentPortlet.java
License:Open Source License
@Override public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { PortletPreferences portletPreferences = renderRequest.getPreferences(); ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); long articleGroupId = PrefsParamUtil.getLong(portletPreferences, renderRequest, "groupId", themeDisplay.getScopeGroupId()); String articleId = PrefsParamUtil.getString(portletPreferences, renderRequest, "articleId"); String ddmTemplateKey = PrefsParamUtil.getString(portletPreferences, renderRequest, "ddmTemplateKey"); JournalArticle article = null;/*from ww w . java 2 s . co m*/ JournalArticleDisplay articleDisplay = null; if ((articleGroupId > 0) && Validator.isNotNull(articleId)) { String viewMode = ParamUtil.getString(renderRequest, "viewMode"); String languageId = LanguageUtil.getLanguageId(renderRequest); int page = ParamUtil.getInteger(renderRequest, "page", 1); article = _journalArticleLocalService.fetchLatestArticle(articleGroupId, articleId, WorkflowConstants.STATUS_APPROVED); try { if (article == null) { article = _journalArticleLocalService.getLatestArticle(articleGroupId, articleId, WorkflowConstants.STATUS_ANY); } if (Validator.isNull(ddmTemplateKey)) { ddmTemplateKey = article.getDDMTemplateKey(); } articleDisplay = _journalContent.getDisplay(article, ddmTemplateKey, viewMode, languageId, page, new PortletRequestModel(renderRequest, renderResponse), themeDisplay); } catch (Exception e) { renderRequest.removeAttribute(WebKeys.JOURNAL_ARTICLE); } } if (article != null) { renderRequest.setAttribute(WebKeys.JOURNAL_ARTICLE, article); } if (articleDisplay != null) { renderRequest.setAttribute(WebKeys.JOURNAL_ARTICLE_DISPLAY, articleDisplay); } else { renderRequest.removeAttribute(WebKeys.JOURNAL_ARTICLE_DISPLAY); } super.doView(renderRequest, renderResponse); }
From source file:com.liferay.journal.exportimport.data.handler.JournalArticleStagedModelDataHandler.java
License:Open Source License
@Override public int[] getExportableStatuses() { return new int[] { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_EXPIRED, WorkflowConstants.STATUS_SCHEDULED }; }
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.ja v a 2 s . co m } 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.model.impl.JournalArticleImpl.java
License:Open Source License
@Override public List<FileEntry> getImagesFileEntries(int start, int end, OrderByComparator obc) throws PortalException { long imagesFolderId = getImagesFolderId(); if (imagesFolderId == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) { return new ArrayList<>(); }//ww w .ja v a 2 s . c om return PortletFileRepositoryUtil.getPortletFileEntries(getGroupId(), imagesFolderId, WorkflowConstants.STATUS_APPROVED, start, end, obc); }
From source file:com.liferay.journal.model.impl.JournalArticleImpl.java
License:Open Source License
@Override public int getImagesFileEntriesCount() throws PortalException { long imagesFolderId = getImagesFolderId(); if (imagesFolderId == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) { return 0; }//from w w w . j av a 2 s.c o m return PortletFileRepositoryUtil.getPortletFileEntriesCount(getGroupId(), imagesFolderId, WorkflowConstants.STATUS_APPROVED); }
From source file:com.liferay.journal.model.impl.JournalArticleImpl.java
License:Open Source License
@Override public boolean hasApprovedVersion() { JournalArticle article = JournalArticleLocalServiceUtil.fetchLatestArticle(getGroupId(), getArticleId(), WorkflowConstants.STATUS_APPROVED); if (article == null) { return false; }//from w w w . ja v a 2 s. c o m return true; }
From source file:com.liferay.journal.search.JournalArticleIndexer.java
License:Open Source License
@Override public void reindexDDMStructures(List<Long> ddmStructureIds) throws SearchException { if (_indexStatusManager.isIndexReadOnly() || !isIndexerEnabled()) { return;//w ww . ja v a2 s. c o m } try { final String[] ddmStructureKeys = new String[ddmStructureIds.size()]; for (int i = 0; i < ddmStructureIds.size(); i++) { long ddmStructureId = ddmStructureIds.get(i); DDMStructure ddmStructure = _ddmStructureLocalService.getDDMStructure(ddmStructureId); ddmStructureKeys[i] = ddmStructure.getStructureKey(); } final Indexer<JournalArticle> indexer = _indexerRegistry.nullSafeGetIndexer(JournalArticle.class); final ActionableDynamicQuery actionableDynamicQuery = _journalArticleLocalService .getActionableDynamicQuery(); actionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() { @Override public void addCriteria(DynamicQuery dynamicQuery) { Property ddmStructureKey = PropertyFactoryUtil.forName("DDMStructureKey"); dynamicQuery.add(ddmStructureKey.in(ddmStructureKeys)); if (!isIndexAllArticleVersions()) { Property statusProperty = PropertyFactoryUtil.forName("status"); Integer[] statuses = { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_IN_TRASH }; dynamicQuery.add(statusProperty.in(statuses)); } } }); actionableDynamicQuery .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<JournalArticle>() { @Override public void performAction(JournalArticle article) throws PortalException { try { indexer.reindex(indexer.getClassName(), article.getResourcePrimKey()); } catch (Exception e) { throw new PortalException(e); } } }); actionableDynamicQuery.performActions(); } catch (Exception e) { throw new SearchException(e); } }
From source file:com.liferay.journal.search.JournalArticleIndexer.java
License:Open Source License
protected JournalArticle fetchLatestIndexableArticleVersion(long resourcePrimKey) { JournalArticle latestIndexableArticle = _journalArticleLocalService.fetchLatestArticle(resourcePrimKey, new int[] { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_IN_TRASH }); if (latestIndexableArticle == null) { latestIndexableArticle = _journalArticleLocalService.fetchLatestArticle(resourcePrimKey); }//from w ww . j a va2 s . c om return latestIndexableArticle; }
From source file:com.liferay.journal.search.test.JournalArticleSearchTest.java
License:Open Source License
@Override protected Hits searchGroupEntries(long groupId, long creatorUserId) throws Exception { return JournalArticleServiceUtil.search(groupId, creatorUserId, WorkflowConstants.STATUS_APPROVED, QueryUtil.ALL_POS, QueryUtil.ALL_POS); }
From source file:com.liferay.journal.search.test.JournalIndexerTest.java
License:Open Source License
protected Hits search(long groupId, SearchContext searchContext) throws Exception { return search(groupId, true, WorkflowConstants.STATUS_APPROVED, searchContext); }