List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_SCHEDULED
int STATUS_SCHEDULED
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_SCHEDULED.
Click Source Link
From source file:at.meduni.liferay.portlet.bbmrieric.model.D2BiobankClp.java
License:Open Source License
@Override public boolean isScheduled() { if (getStatus() == WorkflowConstants.STATUS_SCHEDULED) { return true; } else {/*w w w. j a va 2s . c om*/ return false; } }
From source file:com.liferay.asset.browser.web.internal.display.context.AssetBrowserDisplayContext.java
License:Open Source License
public int[] getStatuses() { int[] statuses = { WorkflowConstants.STATUS_APPROVED }; if (isShowScheduled()) { statuses = new int[] { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_SCHEDULED }; }/*from w w w .ja v a 2 s.c o m*/ return statuses; }
From source file:com.liferay.asset.tags.admin.web.internal.display.context.AssetTagsDisplayContext.java
License:Open Source License
public long getFullTagsCount(AssetTag tag) { int[] statuses = { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_PENDING, WorkflowConstants.STATUS_SCHEDULED }; ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); return AssetEntryLocalServiceUtil.searchCount(tag.getCompanyId(), null, themeDisplay.getUserId(), null, 0, null, null, null, null, tag.getName(), true, true, statuses, false); }
From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
@Override public void checkEntries() throws PortalException { Date now = new Date(); int count = blogsEntryPersistence.countByLtD_S(now, WorkflowConstants.STATUS_SCHEDULED); if (count == 0) { return;// ww w .jav a2 s.co m } List<BlogsEntry> entries = blogsEntryPersistence.findByLtD_S(now, WorkflowConstants.STATUS_SCHEDULED); for (BlogsEntry entry : entries) { ServiceContext serviceContext = new ServiceContext(); String[] trackbacks = StringUtil.split(entry.getTrackbacks()); serviceContext.setAttribute("trackbacks", trackbacks); serviceContext.setCommand(Constants.UPDATE); String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(), PortletProvider.Action.VIEW); if (Validator.isNotNull(portletId)) { String layoutFullURL = PortalUtil.getLayoutFullURL(entry.getGroupId(), portletId); serviceContext.setLayoutFullURL(layoutFullURL); } serviceContext.setScopeGroupId(entry.getGroupId()); blogsEntryLocalService.updateStatus(entry.getStatusByUserId(), entry.getEntryId(), WorkflowConstants.STATUS_APPROVED, serviceContext, new HashMap<String, Serializable>()); } }
From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
@Indexable(type = IndexableType.REINDEX) @Override// www . ja v a 2 s .com public BlogsEntry updateStatus(long userId, long entryId, int status, ServiceContext serviceContext, Map<String, Serializable> workflowContext) throws PortalException { // Entry User user = userPersistence.findByPrimaryKey(userId); Date now = new Date(); BlogsEntry entry = blogsEntryPersistence.findByPrimaryKey(entryId); int oldStatus = entry.getStatus(); if ((status == WorkflowConstants.STATUS_APPROVED) && now.before(entry.getDisplayDate())) { status = WorkflowConstants.STATUS_SCHEDULED; } entry.setStatus(status); entry.setStatusByUserId(user.getUserId()); entry.setStatusByUserName(user.getFullName()); entry.setStatusDate(serviceContext.getModifiedDate(now)); if ((status == WorkflowConstants.STATUS_APPROVED) && Validator.isNull(entry.getUrlTitle())) { entry.setUrlTitle(getUniqueUrlTitle(entryId, entry.getGroupId(), entry.getTitle())); } blogsEntryPersistence.update(entry); // Statistics blogsStatsUserLocalService.updateStatsUser(entry.getGroupId(), entry.getUserId(), entry.getDisplayDate()); AssetEntry assetEntry = assetEntryLocalService.fetchEntry(BlogsEntry.class.getName(), entryId); if ((assetEntry == null) || (assetEntry.getPublishDate() == null)) { serviceContext.setCommand(Constants.ADD); } JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", entry.getTitle()); if (status == WorkflowConstants.STATUS_APPROVED) { // Asset assetEntryLocalService.updateEntry(BlogsEntry.class.getName(), entryId, entry.getDisplayDate(), null, true, true); // Social if ((oldStatus != WorkflowConstants.STATUS_IN_TRASH) && (oldStatus != WorkflowConstants.STATUS_SCHEDULED)) { if (serviceContext.isCommandUpdate()) { SocialActivityManagerUtil.addActivity(user.getUserId(), entry, BlogsActivityKeys.UPDATE_ENTRY, extraDataJSONObject.toString(), 0); } else { SocialActivityManagerUtil.addUniqueActivity(user.getUserId(), entry, BlogsActivityKeys.ADD_ENTRY, extraDataJSONObject.toString(), 0); } } // Trash if (oldStatus == WorkflowConstants.STATUS_IN_TRASH) { if (PropsValues.BLOGS_ENTRY_COMMENTS_ENABLED) { CommentManagerUtil.restoreDiscussionFromTrash(BlogsEntry.class.getName(), entryId); } trashEntryLocalService.deleteEntry(BlogsEntry.class.getName(), entryId); } if (oldStatus != WorkflowConstants.STATUS_IN_TRASH) { // Subscriptions notifySubscribers(userId, entry, serviceContext, workflowContext); // Ping String[] trackbacks = (String[]) serviceContext.getAttribute("trackbacks"); Boolean pingOldTrackbacks = ParamUtil.getBoolean(serviceContext, "pingOldTrackbacks"); pingGoogle(entry, serviceContext); pingPingback(entry, serviceContext); pingTrackbacks(entry, trackbacks, pingOldTrackbacks, serviceContext); } } else { // Asset assetEntryLocalService.updateVisible(BlogsEntry.class.getName(), entryId, false); // Social if ((status == WorkflowConstants.STATUS_SCHEDULED) && (oldStatus != WorkflowConstants.STATUS_IN_TRASH)) { if (serviceContext.isCommandUpdate()) { SocialActivityManagerUtil.addActivity(user.getUserId(), entry, BlogsActivityKeys.UPDATE_ENTRY, extraDataJSONObject.toString(), 0); } else { SocialActivityManagerUtil.addUniqueActivity(user.getUserId(), entry, BlogsActivityKeys.ADD_ENTRY, extraDataJSONObject.toString(), 0); } } // Trash if (status == WorkflowConstants.STATUS_IN_TRASH) { if (PropsValues.BLOGS_ENTRY_COMMENTS_ENABLED) { CommentManagerUtil.moveDiscussionToTrash(BlogsEntry.class.getName(), entryId); } trashEntryLocalService.addTrashEntry(userId, entry.getGroupId(), BlogsEntry.class.getName(), entry.getEntryId(), entry.getUuid(), null, oldStatus, null, null); } else if (oldStatus == WorkflowConstants.STATUS_IN_TRASH) { if (PropsValues.BLOGS_ENTRY_COMMENTS_ENABLED) { CommentManagerUtil.restoreDiscussionFromTrash(BlogsEntry.class.getName(), entryId); } trashEntryLocalService.deleteEntry(BlogsEntry.class.getName(), entryId); } } return entry; }
From source file:com.liferay.blogs.web.social.BlogsActivityInterpreter.java
License:Open Source License
@Override protected Object[] getTitleArguments(String groupName, SocialActivity activity, String link, String title, ServiceContext serviceContext) throws Exception { String creatorUserName = getUserName(activity.getUserId(), serviceContext); String receiverUserName = getUserName(activity.getReceiverUserId(), serviceContext); BlogsEntry entry = _blogsEntryLocalService.getEntry(activity.getClassPK()); String displayDate = StringPool.BLANK; if ((activity.getType() == BlogsActivityKeys.ADD_ENTRY) && (entry.getStatus() == WorkflowConstants.STATUS_SCHEDULED)) { link = null;//w ww . j a v a 2 s . c o m Format dateFormatDate = FastDateFormatFactoryUtil.getSimpleDateFormat("MMMM d", serviceContext.getLocale(), serviceContext.getTimeZone()); displayDate = dateFormatDate.format(entry.getDisplayDate()); } return new Object[] { groupName, creatorUserName, receiverUserName, wrapLink(link, title), displayDate }; }
From source file:com.liferay.blogs.web.social.BlogsActivityInterpreter.java
License:Open Source License
@Override protected String getTitlePattern(String groupName, SocialActivity activity) throws Exception { int activityType = activity.getType(); if ((activityType == BlogsActivityKeys.ADD_COMMENT) || (activityType == SocialActivityConstants.TYPE_ADD_COMMENT)) { if (Validator.isNull(groupName)) { return "activity-blogs-entry-add-comment"; } else {/*from w ww . ja v a 2s. c om*/ return "activity-blogs-entry-add-comment-in"; } } else if (activityType == BlogsActivityKeys.ADD_ENTRY) { BlogsEntry entry = _blogsEntryLocalService.getEntry(activity.getClassPK()); if (entry.getStatus() == WorkflowConstants.STATUS_SCHEDULED) { if (Validator.isNull(groupName)) { return "activity-blogs-entry-schedule-entry"; } else { return "activity-blogs-entry-schedule-entry-in"; } } else { if (Validator.isNull(groupName)) { return "activity-blogs-entry-add-entry"; } else { return "activity-blogs-entry-add-entry-in"; } } } else if (activityType == SocialActivityConstants.TYPE_MOVE_TO_TRASH) { if (Validator.isNull(groupName)) { return "activity-blogs-entry-move-to-trash"; } else { return "activity-blogs-entry-move-to-trash-in"; } } else if (activityType == SocialActivityConstants.TYPE_RESTORE_FROM_TRASH) { if (Validator.isNull(groupName)) { return "activity-blogs-entry-restore-from-trash"; } else { return "activity-blogs-entry-restore-from-trash-in"; } } else if (activityType == BlogsActivityKeys.UPDATE_ENTRY) { if (Validator.isNull(groupName)) { return "activity-blogs-entry-update-entry"; } else { return "activity-blogs-entry-update-entry-in"; } } return null; }
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 w w.jav a 2 s . c o 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.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//from w w w . j a va 2s .c o 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; }