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.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Adds a web content article with additional parameters. * * <p>/* ww w . j a va 2s.c o m*/ * The web content articles hold HTML content wrapped in XML. The XML lets * you specify the article's default locale and available locales. Here is a * content example: * </p> * * <p> * <pre> * <code> * <?xml version='1.0' encoding='UTF-8'?> * <root default-locale="en_US" available-locales="en_US"> * <static-content language-id="en_US"> * <![CDATA[<p><b><i>test<i> content<b></p>]]> * </static-content> * </root> * </code> * </pre> * </p> * * @param userId the primary key of the web content article's creator/owner * @param groupId the primary key of the web content article's group * @param folderId the primary key of the web content article folder * @param classNameId the primary key of the DDMStructure class if the web * content article is related to a DDM structure, the primary key of * the class name associated with the article, or * JournalArticleConstants.CLASSNAME_ID_DEFAULT in the journal-api * module otherwise * @param classPK the primary key of the DDM structure, if the primary key * of the DDMStructure class is given as the * <code>classNameId</code> parameter, the primary key of the class * associated with the web content article, or <code>0</code> * otherwise * @param articleId the primary key of the web content article * @param autoArticleId whether to auto generate the web content article ID * @param version the web content article's version * @param titleMap the web content article's locales and localized titles * @param descriptionMap the web content article's locales and localized * descriptions * @param content the HTML content wrapped in XML * @param ddmStructureKey the primary key of the web content article's DDM * structure, if the article is related to a DDM structure, or * <code>null</code> otherwise * @param ddmTemplateKey the primary key of the web content article's DDM * template * @param layoutUuid the unique string identifying the web content * article's display page * @param displayDateMonth the month the web content article is set to * display * @param displayDateDay the calendar day the web content article is set to * display * @param displayDateYear the year the web content article is set to * display * @param displayDateHour the hour the web content article is set to * display * @param displayDateMinute the minute the web content article is set to * display * @param expirationDateMonth the month the web content article is set to * expire * @param expirationDateDay the calendar day the web content article is set * to expire * @param expirationDateYear the year the web content article is set to * expire * @param expirationDateHour the hour the web content article is set to * expire * @param expirationDateMinute the minute the web content article is set to * expire * @param neverExpire whether the web content article is not set to auto * expire * @param reviewDateMonth the month the web content article is set for * review * @param reviewDateDay the calendar day the web content article is set for * review * @param reviewDateYear the year the web content article is set for review * @param reviewDateHour the hour the web content article is set for review * @param reviewDateMinute the minute the web content article is set for * review * @param neverReview whether the web content article is not set for review * @param indexable whether the web content article is searchable * @param smallImage whether the web content article has a small image * @param smallImageURL the web content article's small image URL * @param smallImageFile the web content article's small image file * @param images the web content's images * @param articleURL the web content article's accessible URL * @param serviceContext the service context to be applied. Can set the * UUID, creation date, modification date, expando bridge * attributes, guest permissions, group permissions, asset category * IDs, asset tag names, asset link entry IDs, URL title, and * workflow actions for the web content article. Can also set * whether to add the default guest and group permissions. * @return the web content article */ @Indexable(type = IndexableType.REINDEX) @Override public JournalArticle addArticle(long userId, long groupId, long folderId, long classNameId, long classPK, String articleId, boolean autoArticleId, double version, Map<Locale, String> titleMap, Map<Locale, String> descriptionMap, String content, String ddmStructureKey, String ddmTemplateKey, String layoutUuid, int displayDateMonth, int displayDateDay, int displayDateYear, int displayDateHour, int displayDateMinute, int expirationDateMonth, int expirationDateDay, int expirationDateYear, int expirationDateHour, int expirationDateMinute, boolean neverExpire, int reviewDateMonth, int reviewDateDay, int reviewDateYear, int reviewDateHour, int reviewDateMinute, boolean neverReview, boolean indexable, boolean smallImage, String smallImageURL, File smallImageFile, Map<String, byte[]> images, String articleURL, ServiceContext serviceContext) throws PortalException { // Article User user = userLocalService.getUser(userId); articleId = StringUtil.toUpperCase(StringUtil.trim(articleId)); Date displayDate = null; Date expirationDate = null; Date reviewDate = null; if (classNameId == JournalArticleConstants.CLASSNAME_ID_DEFAULT) { displayDate = PortalUtil.getDate(displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, user.getTimeZone(), null); if (!neverExpire) { expirationDate = PortalUtil.getDate(expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, user.getTimeZone(), ArticleExpirationDateException.class); } if (!neverReview) { reviewDate = PortalUtil.getDate(reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, user.getTimeZone(), ArticleReviewDateException.class); } } byte[] smallImageBytes = null; try { smallImageBytes = FileUtil.getBytes(smallImageFile); } catch (IOException ioe) { } Date now = new Date(); validateDDMStructureId(groupId, folderId, ddmStructureKey); if (autoArticleId) { articleId = String.valueOf(counterLocalService.increment()); } validate(user.getCompanyId(), groupId, classNameId, articleId, autoArticleId, version, titleMap, content, ddmStructureKey, ddmTemplateKey, displayDate, expirationDate, smallImage, smallImageURL, smallImageFile, smallImageBytes, serviceContext); validateReferences(groupId, ddmStructureKey, ddmTemplateKey, layoutUuid, smallImage, smallImageURL, smallImageBytes, 0, content); serviceContext.setAttribute("articleId", articleId); long id = counterLocalService.increment(); String articleResourceUuid = GetterUtil.getString(serviceContext.getAttribute("articleResourceUuid")); long resourcePrimKey = journalArticleResourceLocalService.getArticleResourcePrimKey(articleResourceUuid, groupId, articleId); JournalArticle article = journalArticlePersistence.create(id); Locale locale = getArticleDefaultLocale(content); String title = titleMap.get(locale); article.setUuid(serviceContext.getUuid()); article.setResourcePrimKey(resourcePrimKey); article.setGroupId(groupId); article.setCompanyId(user.getCompanyId()); article.setUserId(user.getUserId()); article.setUserName(user.getFullName()); article.setFolderId(folderId); article.setClassNameId(classNameId); article.setClassPK(classPK); article.setTreePath(article.buildTreePath()); article.setArticleId(articleId); article.setVersion(version); article.setUrlTitle(getUniqueUrlTitle(id, groupId, articleId, title, null, serviceContext)); content = format(user, groupId, article, content); article.setContent(content); article.setDDMStructureKey(ddmStructureKey); article.setDDMTemplateKey(ddmTemplateKey); article.setDefaultLanguageId(LocaleUtil.toLanguageId(locale)); article.setLayoutUuid(layoutUuid); article.setDisplayDate(displayDate); article.setExpirationDate(expirationDate); article.setReviewDate(reviewDate); article.setIndexable(indexable); article.setSmallImage(smallImage); article.setSmallImageId(counterLocalService.increment()); article.setSmallImageURL(smallImageURL); if ((expirationDate == null) || expirationDate.after(now)) { article.setStatus(WorkflowConstants.STATUS_DRAFT); } else { article.setStatus(WorkflowConstants.STATUS_EXPIRED); } article.setStatusByUserId(userId); article.setStatusDate(serviceContext.getModifiedDate(now)); article.setExpandoBridgeAttributes(serviceContext); journalArticlePersistence.update(article); // Article localization _addArticleLocalizedFields(user.getCompanyId(), article.getId(), titleMap, descriptionMap); // Resources if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) { addArticleResources(article, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions()); } else { addArticleResources(article, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions()); } // Small image saveImages(smallImage, article.getSmallImageId(), smallImageFile, smallImageBytes); // Asset updateAsset(userId, article, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds(), serviceContext.getAssetPriority()); // Dynamic data mapping if (classNameLocalService.getClassNameId(DDMStructure.class) == classNameId) { updateDDMStructurePredefinedValues(classPK, content, serviceContext); } else { updateDDMLinks(id, groupId, ddmStructureKey, ddmTemplateKey, true); } // Email PortletPreferences preferences = ServiceContextUtil.getPortletPreferences(serviceContext); articleURL = buildArticleURL(articleURL, groupId, folderId, articleId); serviceContext.setAttribute("articleURL", articleURL); sendEmail(article, articleURL, preferences, "requested", serviceContext); // Workflow if (classNameId == JournalArticleConstants.CLASSNAME_ID_DEFAULT) { startWorkflowInstance(userId, article, serviceContext); } else { updateStatus(userId, article, WorkflowConstants.STATUS_APPROVED, null, serviceContext, new HashMap<String, Serializable>()); } return journalArticlePersistence.findByPrimaryKey(article.getId()); }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Deletes the web content article and its resources, optionally sending * email notifying denial of the article if it had not yet been approved. * * @param article the web content article * @param articleURL the web content article's accessible URL to include in * email notifications (optionally <code>null</code>) * @param serviceContext the service context to be applied (optionally * <code>null</code>). Can set the portlet preferences that include * email information to notify recipients of the unapproved web * content's denial./* ww w . ja v a2 s . co m*/ * @return the deleted web content article */ @Indexable(type = IndexableType.DELETE) @Override @SystemEvent(action = SystemEventConstants.ACTION_SKIP, send = false, type = SystemEventConstants.TYPE_DELETE) public JournalArticle deleteArticle(JournalArticle article, String articleURL, ServiceContext serviceContext) throws PortalException { JournalArticleResource articleResource = journalArticleResourceLocalService .fetchArticleResource(article.getGroupId(), article.getArticleId()); if (article.isApproved() && isLatestVersion(article.getGroupId(), article.getArticleId(), article.getVersion(), WorkflowConstants.STATUS_APPROVED)) { updatePreviousApprovedArticle(article); } // Article localization journalArticleLocalizationPersistence.removeByArticlePK(article.getId()); // Email if ((serviceContext != null) && Validator.isNotNull(articleURL)) { PortletPreferences preferences = ServiceContextUtil.getPortletPreferences(serviceContext); if ((preferences != null) && !article.isApproved() && isLatestVersion(article.getGroupId(), article.getArticleId(), article.getVersion())) { articleURL = buildArticleURL(articleURL, article.getGroupId(), article.getFolderId(), article.getArticleId()); sendEmail(article, articleURL, preferences, "denied", serviceContext); } } // Dynamic data mapping if (article.getClassNameId() != classNameLocalService.getClassNameId(DDMStructure.class)) { ddmStorageLinkLocalService.deleteClassStorageLink(article.getId()); ddmTemplateLinkLocalService.deleteTemplateLink( classNameLocalService.getClassNameId(JournalArticle.class), article.getId()); } // Expando expandoRowLocalService.deleteRows(article.getId()); // Trash if (article.isInTrash()) { TrashEntry trashEntry = article.getTrashEntry(); if (trashEntry != null) { trashVersionLocalService.deleteTrashVersion(JournalArticle.class.getName(), article.getId()); } } // Workflow if (!article.isDraft()) { workflowInstanceLinkLocalService.deleteWorkflowInstanceLink(article.getCompanyId(), article.getGroupId(), JournalArticle.class.getName(), article.getId()); } int articlesCount = journalArticlePersistence.countByG_A(article.getGroupId(), article.getArticleId()); if (articlesCount == 1) { // Asset assetEntryLocalService.deleteEntry(JournalArticle.class.getName(), article.getResourcePrimKey()); // Comment CommentManagerUtil.deleteDiscussion(JournalArticle.class.getName(), article.getResourcePrimKey()); // Content searches journalContentSearchLocalService.deleteArticleContentSearches(article.getGroupId(), article.getArticleId()); // Images long folderId = article.getImagesFolderId(); if (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) { PortletFileRepositoryUtil.deletePortletFolder(folderId); } // Ratings ratingsStatsLocalService.deleteStats(JournalArticle.class.getName(), article.getResourcePrimKey()); // Small image imageLocalService.deleteImage(article.getSmallImageId()); // Trash trashEntryLocalService.deleteEntry(JournalArticle.class.getName(), article.getResourcePrimKey()); // Resources resourceLocalService.deleteResource(article.getCompanyId(), JournalArticle.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, article.getResourcePrimKey()); // Resource if (articleResource != null) { journalArticleResourceLocalService.deleteJournalArticleResource(articleResource); } } // Article journalArticlePersistence.remove(article); // System event if (articleResource != null) { JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("uuid", article.getUuid()); extraDataJSONObject.put("version", article.getVersion()); systemEventLocalService.addSystemEvent(0, article.getGroupId(), article.getModelClassName(), article.getPrimaryKey(), articleResource.getUuid(), null, SystemEventConstants.TYPE_DELETE, extraDataJSONObject.toString()); } return article; }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Expires the web content article matching the group and article ID, * expiring all of its versions if the//from w w w .j a va 2s.c o m * <code>journal.article.expire.all.versions</code> portal property is * <code>true</code>, otherwise expiring only its latest approved version. * * @param userId the primary key of the user updating the web content * article * @param groupId the primary key of the web content article's group * @param articleId the primary key of the web content article * @param articleURL the web content article's accessible URL * @param serviceContext the service context to be applied. Can set the * modification date, status date, portlet preferences, and can set * whether to add the default command update for the web content * article. 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. */ @Override public void expireArticle(long userId, long groupId, String articleId, String articleURL, ServiceContext serviceContext) throws PortalException { User user = userLocalService.getUser(userId); if (isExpireAllArticleVersions(user.getCompanyId())) { List<JournalArticle> articles = journalArticlePersistence.findByG_A(groupId, articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new ArticleVersionComparator(true)); for (JournalArticle article : articles) { journalArticleLocalService.expireArticle(userId, groupId, article.getArticleId(), article.getVersion(), articleURL, serviceContext); } } else { JournalArticle article = getLatestArticle(groupId, articleId, WorkflowConstants.STATUS_APPROVED); journalArticleLocalService.expireArticle(userId, groupId, article.getArticleId(), article.getVersion(), articleURL, serviceContext); } }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
@Override public JournalArticle fetchArticle(long groupId, String articleId) { // Get the latest article that is approved, if none are approved, get // the latest unapproved article JournalArticle article = fetchLatestArticle(groupId, articleId, WorkflowConstants.STATUS_APPROVED); if (article != null) { return article; }//from w ww.ja v a 2 s . c o m return fetchLatestArticle(groupId, articleId, WorkflowConstants.STATUS_ANY); }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
@Override public JournalArticle fetchArticleByUrlTitle(long groupId, String urlTitle) { JournalArticle article = fetchLatestArticleByUrlTitle(groupId, urlTitle, WorkflowConstants.STATUS_APPROVED); if (article != null) { return article; }/*from w w w . j a v a2 s .c o m*/ return fetchLatestArticleByUrlTitle(groupId, urlTitle, WorkflowConstants.STATUS_ANY); }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
@Override public JournalArticle fetchDisplayArticle(long groupId, String articleId) { List<JournalArticle> articles = journalArticlePersistence.findByG_A_ST(groupId, articleId, WorkflowConstants.STATUS_APPROVED); if (articles.isEmpty()) { return null; }/* ww w . jav a 2 s .co m*/ Date now = new Date(); for (JournalArticle article : articles) { Date displayDate = article.getDisplayDate(); Date expirationDate = article.getExpirationDate(); if (((displayDate == null) || displayDate.before(now)) && ((expirationDate == null) || expirationDate.after(now))) { return article; } } return articles.get(0); }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Returns the latest web content article matching the resource primary key * and workflow status, optionally preferring articles with approved * workflow status./*w w w .j av a 2 s .c o m*/ * * @param resourcePrimKey the primary key of the resource instance * @param status the web content article's workflow status. For more * information see {@link WorkflowConstants} for constants starting * with the "STATUS_" prefix. * @param preferApproved whether to prefer returning the latest matching * article that has workflow status {@link * WorkflowConstants#STATUS_APPROVED} over returning one that has a * different status * @return the latest web content article matching the resource primary key * and workflow status, optionally preferring articles with an * approved workflow status, or <code>null</code> if no matching web * content article could be found */ @Override public JournalArticle fetchLatestArticle(long resourcePrimKey, int status, boolean preferApproved) { JournalArticle article = null; OrderByComparator<JournalArticle> orderByComparator = new ArticleVersionComparator(); if (status == WorkflowConstants.STATUS_ANY) { if (preferApproved) { article = journalArticlePersistence.fetchByR_ST_First(resourcePrimKey, WorkflowConstants.STATUS_APPROVED, orderByComparator); } if (article == null) { article = journalArticlePersistence.fetchByResourcePrimKey_First(resourcePrimKey, orderByComparator); } } else { article = journalArticlePersistence.fetchByR_ST_First(resourcePrimKey, status, orderByComparator); } return article; }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Returns the latest indexable web content article matching the resource * primary key./*from w ww. j ava 2 s . c o m*/ * * @param resourcePrimKey the primary key of the resource instance * @return the latest indexable web content article matching the resource * primary key, or <code>null</code> if no matching web content * article could be found */ @Override public JournalArticle fetchLatestIndexableArticle(long resourcePrimKey) { OrderByComparator<JournalArticle> orderByComparator = new ArticleVersionComparator(); int[] statuses = new int[] { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_IN_TRASH }; List<JournalArticle> articles = journalArticlePersistence.findByR_I_S(resourcePrimKey, true, statuses, 0, 1, orderByComparator); if (articles.isEmpty()) { return null; } return articles.get(0); }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Returns the latest approved web content article, or the latest unapproved * article if none are approved. Both approved and unapproved articles must * match the group and article ID./*from www . j a v a 2 s . c om*/ * * @param groupId the primary key of the web content article's group * @param articleId the primary key of the web content article * @return the matching web content article */ @Override public JournalArticle getArticle(long groupId, String articleId) throws PortalException { // Get the latest article that is approved, if none are approved, get // the latest unapproved article JournalArticle article = fetchLatestArticle(groupId, articleId, WorkflowConstants.STATUS_APPROVED); if (article != null) { return article; } return getLatestArticle(groupId, articleId, WorkflowConstants.STATUS_ANY); }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Returns the latest web content article that is approved, or the latest * unapproved article if none are approved. Both approved and unapproved * articles must match the group and URL title. * * @param groupId the primary key of the web content article's group * @param urlTitle the web content article's accessible URL title * @return the matching web content article *///from w w w. jav a 2s. c o m @Override public JournalArticle getArticleByUrlTitle(long groupId, String urlTitle) throws PortalException { // Get the latest article that is approved, if none are approved, get // the latest unapproved article JournalArticle article = fetchLatestArticleByUrlTitle(groupId, urlTitle, WorkflowConstants.STATUS_APPROVED); if (article != null) { return article; } return getLatestArticleByUrlTitle(groupId, urlTitle, WorkflowConstants.STATUS_ANY); }