List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_PENDING
int STATUS_PENDING
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_PENDING.
Click Source Link
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Updates the workflow status of the web content article. * * @param userId the primary key of the user updating the web content * article's status/*w w w. ja v a2 s .co m*/ * @param article the web content article * @param status the web content article's workflow status. For more * information see {@link WorkflowConstants} for constants starting * with the "STATUS_" prefix. * @param articleURL the web content article's accessible URL * @param serviceContext the service context to be applied. Can set the * modification date, status date, and portlet preferences. 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. * @param workflowContext the web content article's configured workflow * context * @return the updated web content article */ @Indexable(type = IndexableType.REINDEX) @Override public JournalArticle updateStatus(long userId, JournalArticle article, int status, String articleURL, ServiceContext serviceContext, Map<String, Serializable> workflowContext) throws PortalException { // Article User user = userLocalService.getUser(userId); Date now = new Date(); if ((status == WorkflowConstants.STATUS_APPROVED) && (article.getClassNameId() == JournalArticleConstants.CLASSNAME_ID_DEFAULT) && (article.getDisplayDate() != null) && now.before(article.getDisplayDate())) { status = WorkflowConstants.STATUS_SCHEDULED; } int oldStatus = article.getStatus(); Date modifiedDate = serviceContext.getModifiedDate(now); article.setModifiedDate(modifiedDate); if (status == WorkflowConstants.STATUS_APPROVED) { Date expirationDate = article.getExpirationDate(); if ((expirationDate != null) && expirationDate.before(now)) { article.setExpirationDate(null); } } if (status == WorkflowConstants.STATUS_EXPIRED) { article.setExpirationDate(now); } article.setStatus(status); article.setStatusByUserId(user.getUserId()); article.setStatusByUserName(user.getFullName()); article.setStatusDate(modifiedDate); journalArticlePersistence.update(article); if (isExpireAllArticleVersions(article.getCompanyId())) { setArticlesExpirationDate(article); } if (hasModifiedLatestApprovedVersion(article.getGroupId(), article.getArticleId(), article.getVersion())) { if (status == WorkflowConstants.STATUS_APPROVED) { updateUrlTitles(article.getGroupId(), article.getArticleId(), article.getUrlTitle()); // Asset String title = article.getTitleMapAsXML(); String description = article.getDescriptionMapAsXML(); if ((oldStatus != WorkflowConstants.STATUS_APPROVED) && (article.getVersion() != JournalArticleConstants.VERSION_DEFAULT)) { AssetEntry draftAssetEntry = assetEntryLocalService.fetchEntry(JournalArticle.class.getName(), article.getPrimaryKey()); if (draftAssetEntry != null) { long[] assetCategoryIds = draftAssetEntry.getCategoryIds(); String[] assetTagNames = draftAssetEntry.getTagNames(); List<AssetLink> assetLinks = assetLinkLocalService.getDirectLinks( draftAssetEntry.getEntryId(), AssetLinkConstants.TYPE_RELATED, false); long[] assetLinkEntryIds = ListUtil.toLongArray(assetLinks, AssetLink.ENTRY_ID2_ACCESSOR); AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, article.getGroupId(), article.getCreateDate(), article.getModifiedDate(), JournalArticle.class.getName(), article.getResourcePrimKey(), article.getUuid(), getClassTypeId(article), assetCategoryIds, assetTagNames, isListable(article), false, null, null, null, null, ContentTypes.TEXT_HTML, title, description, description, null, article.getLayoutUuid(), 0, 0, draftAssetEntry.getPriority()); assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds, AssetLinkConstants.TYPE_RELATED); assetEntryLocalService.deleteEntry(draftAssetEntry); } } if (article.getClassNameId() == JournalArticleConstants.CLASSNAME_ID_DEFAULT) { assetEntryLocalService.updateEntry(JournalArticle.class.getName(), article.getResourcePrimKey(), article.getDisplayDate(), article.getExpirationDate(), isListable(article), true); } // Social JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", title); if (serviceContext.isCommandUpdate()) { SocialActivityManagerUtil.addActivity(user.getUserId(), article, JournalActivityKeys.UPDATE_ARTICLE, extraDataJSONObject.toString(), 0); } else { SocialActivityManagerUtil.addUniqueActivity(user.getUserId(), article, JournalActivityKeys.ADD_ARTICLE, extraDataJSONObject.toString(), 0); } } else if (oldStatus == WorkflowConstants.STATUS_APPROVED) { updatePreviousApprovedArticle(article); } } if ((article.getClassNameId() == JournalArticleConstants.CLASSNAME_ID_DEFAULT) && (oldStatus != WorkflowConstants.STATUS_IN_TRASH) && (status != WorkflowConstants.STATUS_IN_TRASH)) { // Email if ((oldStatus == WorkflowConstants.STATUS_PENDING) && ((status == WorkflowConstants.STATUS_APPROVED) || (status == WorkflowConstants.STATUS_DENIED))) { String msg = "granted"; if (status == WorkflowConstants.STATUS_DENIED) { msg = "denied"; } try { PortletPreferences preferences = ServiceContextUtil.getPortletPreferences(serviceContext); articleURL = buildArticleURL(articleURL, article.getGroupId(), article.getFolderId(), article.getArticleId()); sendEmail(article, articleURL, preferences, msg, serviceContext); } catch (Exception e) { _log.error("Unable to send email to notify the change of status " + "to " + msg + " for article " + article.getId() + ": " + e.getMessage()); } } // Subscriptions String action = "update"; if (article.getVersion() == 1.0) { action = "add"; } notifySubscribers(user.getUserId(), article, action, serviceContext); } return article; }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
protected List<ObjectValuePair<Long, Integer>> getArticleVersionStatuses(List<JournalArticle> articles) { List<ObjectValuePair<Long, Integer>> articleVersionStatusOVPs = new ArrayList<>(articles.size()); for (JournalArticle article : articles) { int status = article.getStatus(); if (status == WorkflowConstants.STATUS_PENDING) { status = WorkflowConstants.STATUS_DRAFT; }//from www . ja v a 2s. c o m ObjectValuePair<Long, Integer> articleVersionStatusOVP = new ObjectValuePair<>(article.getId(), status); articleVersionStatusOVPs.add(articleVersionStatusOVP); } return articleVersionStatusOVPs; }
From source file:com.liferay.journal.service.impl.JournalFolderLocalServiceImpl.java
License:Open Source License
protected void moveDependentsToTrash(List<Object> foldersAndArticles, long trashEntryId) throws PortalException { for (Object object : foldersAndArticles) { if (object instanceof JournalArticle) { // Article JournalArticle article = (JournalArticle) object; if (article.getStatus() == WorkflowConstants.STATUS_IN_TRASH) { continue; }//w ww .j a va 2 s . co m // Articles List<JournalArticle> articles = journalArticlePersistence.findByG_A(article.getGroupId(), article.getArticleId()); for (JournalArticle curArticle : articles) { // Article int curArticleOldStatus = curArticle.getStatus(); curArticle.setStatus(WorkflowConstants.STATUS_IN_TRASH); journalArticlePersistence.update(curArticle); // Trash int status = curArticleOldStatus; if (curArticleOldStatus == WorkflowConstants.STATUS_PENDING) { status = WorkflowConstants.STATUS_DRAFT; } if (curArticleOldStatus != WorkflowConstants.STATUS_APPROVED) { trashVersionLocalService.addTrashVersion(trashEntryId, JournalArticle.class.getName(), curArticle.getId(), status, null); } // Workflow if (curArticleOldStatus == WorkflowConstants.STATUS_PENDING) { workflowInstanceLinkLocalService.deleteWorkflowInstanceLink(curArticle.getCompanyId(), curArticle.getGroupId(), JournalArticle.class.getName(), curArticle.getId()); } } // Asset assetEntryLocalService.updateVisible(JournalArticle.class.getName(), article.getResourcePrimKey(), false); // Indexer Indexer<JournalArticle> indexer = IndexerRegistryUtil.nullSafeGetIndexer(JournalArticle.class); indexer.reindex(article); } else if (object instanceof JournalFolder) { // Folder JournalFolder folder = (JournalFolder) object; if (folder.isInTrashExplicitly()) { continue; } int oldStatus = folder.getStatus(); folder.setStatus(WorkflowConstants.STATUS_IN_TRASH); journalFolderPersistence.update(folder); // Trash if (oldStatus != WorkflowConstants.STATUS_APPROVED) { trashVersionLocalService.addTrashVersion(trashEntryId, JournalFolder.class.getName(), folder.getFolderId(), oldStatus, null); } // Folders and articles List<Object> curFoldersAndArticles = getFoldersAndArticles(folder.getGroupId(), folder.getFolderId()); moveDependentsToTrash(curFoldersAndArticles, trashEntryId); // Asset assetEntryLocalService.updateVisible(JournalFolder.class.getName(), folder.getFolderId(), false); // Indexer Indexer<JournalFolder> indexer = IndexerRegistryUtil.nullSafeGetIndexer(JournalFolder.class); indexer.reindex(folder); } } }
From source file:com.liferay.journal.web.internal.display.context.JournalDisplayContext.java
License:Open Source License
public List<ManagementBarFilterItem> getManagementBarStatusFilterItems() throws PortalException, PortletException { List<ManagementBarFilterItem> managementBarFilterItems = new ArrayList<>(); managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_ANY)); managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_DRAFT)); ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); int workflowDefinitionLinksCount = WorkflowDefinitionLinkLocalServiceUtil.getWorkflowDefinitionLinksCount( themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId(), JournalFolder.class.getName()); if (workflowDefinitionLinksCount > 0) { managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_PENDING)); managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_DENIED)); }/*from w w w . j a va2 s .c o m*/ managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_SCHEDULED)); managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_APPROVED)); managementBarFilterItems.add(getManagementBarFilterItem(WorkflowConstants.STATUS_EXPIRED)); return managementBarFilterItems; }
From source file:com.liferay.journal.web.internal.search.ArticleSearchTerms.java
License:Open Source License
public Date getReviewDate() { if (status == WorkflowConstants.STATUS_PENDING) { return new Date(); } else {//from ww w .j av a2 s. c o m return null; } }
From source file:com.liferay.knowledgebase.service.impl.KBArticleLocalServiceImpl.java
License:Open Source License
@Override public KBArticle fetchKBArticleByUrlTitle(long groupId, long kbFolderId, String urlTitle) { urlTitle = StringUtil.replaceFirst(urlTitle, StringPool.SLASH, StringPool.BLANK); KBArticle kbArticle = fetchLatestKBArticleByUrlTitle(groupId, kbFolderId, urlTitle, WorkflowConstants.STATUS_APPROVED); if (kbArticle == null) { kbArticle = fetchLatestKBArticleByUrlTitle(groupId, kbFolderId, urlTitle, WorkflowConstants.STATUS_PENDING); }/*ww w . j av a2 s .com*/ return kbArticle; }
From source file:com.liferay.knowledgebase.service.impl.KBArticleLocalServiceImpl.java
License:Open Source License
@Override public KBArticle updateKBArticle(long userId, long resourcePrimKey, String title, String content, String description, String sourceURL, String[] sections, String[] selectedFileNames, long[] removeFileEntryIds, ServiceContext serviceContext) throws PortalException { // KB article User user = userPersistence.findByPrimaryKey(userId); validate(title, content, sourceURL); KBArticle oldKBArticle = getLatestKBArticle(resourcePrimKey, WorkflowConstants.STATUS_ANY); int oldVersion = oldKBArticle.getVersion(); KBArticle kbArticle = null;//from w w w. jav a2 s . com if (oldKBArticle.isApproved()) { long kbArticleId = counterLocalService.increment(); kbArticle = kbArticlePersistence.create(kbArticleId); kbArticle.setUuid(serviceContext.getUuid()); kbArticle.setResourcePrimKey(oldKBArticle.getResourcePrimKey()); kbArticle.setGroupId(oldKBArticle.getGroupId()); kbArticle.setCompanyId(user.getCompanyId()); kbArticle.setUserId(user.getUserId()); kbArticle.setUserName(user.getFullName()); kbArticle.setCreateDate(oldKBArticle.getCreateDate()); kbArticle.setRootResourcePrimKey(oldKBArticle.getRootResourcePrimKey()); kbArticle.setParentResourceClassNameId(oldKBArticle.getParentResourceClassNameId()); kbArticle.setParentResourcePrimKey(oldKBArticle.getParentResourcePrimKey()); kbArticle.setKbFolderId(oldKBArticle.getKbFolderId()); kbArticle.setVersion(oldVersion + 1); kbArticle.setUrlTitle(oldKBArticle.getUrlTitle()); kbArticle.setPriority(oldKBArticle.getPriority()); kbArticle.setViewCount(oldKBArticle.getViewCount()); } else { kbArticle = oldKBArticle; } if (oldKBArticle.isPending()) { kbArticle.setStatus(WorkflowConstants.STATUS_PENDING); } else { kbArticle.setStatus(WorkflowConstants.STATUS_DRAFT); } kbArticle.setModifiedDate(serviceContext.getModifiedDate(null)); kbArticle.setTitle(title); kbArticle.setContent(content); kbArticle.setDescription(description); kbArticle.setSourceURL(sourceURL); kbArticle.setSections(StringUtil.merge(AdminUtil.escapeSections(sections))); kbArticle.setLatest(true); kbArticle.setMain(false); kbArticlePersistence.update(kbArticle); if (oldKBArticle.isApproved()) { oldKBArticle.setLatest(false); kbArticlePersistence.update(oldKBArticle); } // Resources if ((serviceContext.getGroupPermissions() != null) || (serviceContext.getGuestPermissions() != null)) { updateKBArticleResources(kbArticle, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions()); } // Asset updateKBArticleAsset(userId, kbArticle, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds()); // Attachments addKBArticleAttachments(userId, kbArticle, selectedFileNames); removeKBArticleAttachments(removeFileEntryIds); // Workflow WorkflowHandlerRegistryUtil.startWorkflowInstance(user.getCompanyId(), kbArticle.getGroupId(), userId, KBArticle.class.getName(), resourcePrimKey, kbArticle, serviceContext); return kbArticle; }
From source file:com.liferay.portlet.directory.workflow.UserWorkflowHandler.java
License:Open Source License
public Object updateStatus(int status, Map<String, Serializable> workflowContext) throws PortalException, SystemException { long userId = GetterUtil.getLong((String) workflowContext.get(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK)); ServiceContext serviceContext = (ServiceContext) workflowContext .get(WorkflowConstants.CONTEXT_SERVICE_CONTEXT); User user = UserLocalServiceUtil.getUser(userId); if (((user.getStatus() == WorkflowConstants.STATUS_DRAFT) || (user.getStatus() == WorkflowConstants.STATUS_PENDING)) && (status == WorkflowConstants.STATUS_APPROVED)) { UserLocalServiceUtil.completeUserRegistration(user, serviceContext); serviceContext.setAttribute("passwordUnencrypted", user.getPasswordUnencrypted()); }/*from w w w.ja v a 2s . c o m*/ return UserLocalServiceUtil.updateStatus(userId, status); }
From source file:com.liferay.portlet.journal.search.ArticleSearchTerms.java
License:Open Source License
public int getStatusCode() { if (status.equals("approved")) { return WorkflowConstants.STATUS_APPROVED; } else if (status.equals("draft")) { return WorkflowConstants.STATUS_DRAFT; } else if (status.equals("expired")) { return WorkflowConstants.STATUS_EXPIRED; } else if (status.equals("pending")) { return WorkflowConstants.STATUS_PENDING; } else {//from ww w . jav a 2s .co m return WorkflowConstants.STATUS_ANY; } }
From source file:com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
public JournalArticle getArticleByUrlTitle(long groupId, String urlTitle) throws PortalException, SystemException { // Get the latest article that is approved, if none are approved, get // the latest unapproved article try {/* w ww. ja v a2 s. c o m*/ return getLatestArticleByUrlTitle(groupId, urlTitle, WorkflowConstants.STATUS_APPROVED); } catch (NoSuchArticleException nsae) { return getLatestArticleByUrlTitle(groupId, urlTitle, WorkflowConstants.STATUS_PENDING); } }