List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_EXPIRED
int STATUS_EXPIRED
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_EXPIRED.
Click Source Link
From source file:com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
public JournalArticle updateStatus(long userId, JournalArticle article, int status, String articleURL, ServiceContext serviceContext) throws PortalException, SystemException { // Article/* w w w.j a va2 s .c o m*/ User user = userPersistence.findByPrimaryKey(userId); Date now = new Date(); int oldStatus = article.getStatus(); article.setModifiedDate(serviceContext.getModifiedDate(now)); boolean neverExpire = false; if (status == WorkflowConstants.STATUS_APPROVED) { Date expirationDate = article.getExpirationDate(); if ((expirationDate != null) && expirationDate.before(now)) { neverExpire = true; article.setExpirationDate(null); } } if (status == WorkflowConstants.STATUS_EXPIRED) { article.setExpirationDate(now); } article.setStatus(status); article.setStatusByUserId(user.getUserId()); article.setStatusByUserName(user.getFullName()); article.setStatusDate(serviceContext.getModifiedDate(now)); journalArticlePersistence.update(article, false); if (isLatestVersion(article.getGroupId(), article.getArticleId(), article.getVersion())) { if (status == WorkflowConstants.STATUS_APPROVED) { updateUrlTitles(article.getGroupId(), article.getArticleId(), article.getUrlTitle()); // Asset if ((oldStatus != WorkflowConstants.STATUS_APPROVED) && (article.getVersion() != JournalArticleConstants.VERSION_DEFAULT)) { AssetEntry draftAssetEntry = null; try { draftAssetEntry = assetEntryLocalService.getEntry(JournalArticle.class.getName(), article.getPrimaryKey()); Date[] dateInterval = getDateInterval(article.getGroupId(), article.getArticleId(), article.getDisplayDate(), article.getExpirationDate()); Date displayDate = dateInterval[0]; Date expirationDate = dateInterval[1]; long[] assetCategoryIds = draftAssetEntry.getCategoryIds(); String[] assetTagNames = draftAssetEntry.getTagNames(); List<AssetLink> assetLinks = assetLinkLocalService .getDirectLinks(draftAssetEntry.getEntryId(), AssetLinkConstants.TYPE_RELATED); long[] assetLinkEntryIds = StringUtil .split(ListUtil.toString(assetLinks, AssetLink.ENTRY_ID2_ACCESSOR), 0L); boolean visible = true; if (article.getClassNameId() > 0) { visible = false; } AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, article.getGroupId(), JournalArticle.class.getName(), article.getResourcePrimKey(), article.getUuid(), getClassTypeId(article), assetCategoryIds, assetTagNames, visible, null, null, displayDate, expirationDate, ContentTypes.TEXT_HTML, article.getTitle(), article.getDescription(), article.getDescription(), null, article.getLayoutUuid(), 0, 0, null, false); assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds, AssetLinkConstants.TYPE_RELATED); assetEntryLocalService.deleteEntry(JournalArticle.class.getName(), article.getPrimaryKey()); } catch (NoSuchEntryException nsee) { } } if (article.getClassNameId() == 0) { AssetEntry assetEntry = assetEntryLocalService.updateVisible(JournalArticle.class.getName(), article.getResourcePrimKey(), true); if (neverExpire) { assetEntry.setExpirationDate(null); assetEntryLocalService.updateAssetEntry(assetEntry, false); } } // Expando ExpandoBridge expandoBridge = article.getExpandoBridge(); expandoBridge.setAttributes(serviceContext); // Indexer Indexer indexer = IndexerRegistryUtil.getIndexer(JournalArticle.class); indexer.reindex(article); } else if (oldStatus == WorkflowConstants.STATUS_APPROVED) { updatePreviousApprovedArticle(article); } } if (article.getClassNameId() == 0) { // 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); 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 notifySubscribers(article, serviceContext); } return article; }