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.appadder.portlet.AppAdderPortlet.java
License:Open Source License
public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { try {//from w w w. j a v a 2 s . c o m int amount = ParamUtil.getInteger(actionRequest, "amount"); String title = ParamUtil.getString(actionRequest, "title"); for (int i = 0; i < amount; i++) { AppEntry appEntry = addAppEntry(actionRequest, title + " " + i); appEntry = updateAppVersion(appEntry.getAppEntryId()); AppVersion appVersion = AppVersionLocalServiceUtil.getLatestAppVersion(appEntry.getAppEntryId()); addAppPackage(appVersion); AppEntryServiceUtil.updateStatus(appEntry.getAppEntryId(), WorkflowConstants.STATUS_APPROVED, StringPool.BLANK); } } catch (Exception e) { throw new PortletException(e); } }
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 ww 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.internal.atom.BlogsEntryAtomCollectionAdapter.java
License:Open Source License
@Override protected Iterable<BlogsEntry> doGetFeedEntries(AtomRequestContext atomRequestContext) throws Exception { long groupId = atomRequestContext.getLongParameter("groupId"); int status = WorkflowConstants.STATUS_APPROVED; int max = atomRequestContext.getIntParameter("max", SearchContainer.DEFAULT_DELTA); if (groupId > 0) { int page = atomRequestContext.getIntParameter("page"); if (page == 0) { return _blogsEntryService.getGroupEntries(groupId, status, max); }/*from w ww. j a va2 s . c om*/ int count = _blogsEntryService.getGroupEntriesCount(groupId, new Date(), status); AtomPager atomPager = new AtomPager(page, max, count); AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager); return _blogsEntryService.getGroupEntries(groupId, new Date(), status, atomPager.getStart(), atomPager.getEnd() + 1); } long organizationId = atomRequestContext.getLongParameter("organizationId"); if (organizationId > 0) { return _blogsEntryService.getOrganizationEntries(organizationId, new Date(), status, max); } long companyId = CompanyThreadLocal.getCompanyId(); if (companyId > 0) { return _blogsEntryService.getCompanyEntries(companyId, new Date(), status, max); } return Collections.emptyList(); }
From source file:com.liferay.blogs.internal.search.BlogsEntryIndexer.java
License:Open Source License
protected void reindexEntries(long companyId) throws PortalException { final IndexableActionableDynamicQuery indexableActionableDynamicQuery = _blogsEntryLocalService .getIndexableActionableDynamicQuery(); indexableActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() { @Override/*from w w w .j a va 2 s. c o m*/ public void addCriteria(DynamicQuery dynamicQuery) { Property displayDateProperty = PropertyFactoryUtil.forName("displayDate"); dynamicQuery.add(displayDateProperty.lt(new Date())); Property statusProperty = PropertyFactoryUtil.forName("status"); Integer[] statuses = { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_IN_TRASH }; dynamicQuery.add(statusProperty.in(statuses)); } }); indexableActionableDynamicQuery.setCompanyId(companyId); indexableActionableDynamicQuery .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<BlogsEntry>() { @Override public void performAction(BlogsEntry entry) { try { Document document = getDocument(entry); indexableActionableDynamicQuery.addDocuments(document); } catch (PortalException pe) { if (_log.isWarnEnabled()) { _log.warn("Unable to index blogs entry " + entry.getEntryId(), pe); } } } }); indexableActionableDynamicQuery.setSearchEngineId(getSearchEngineId()); indexableActionableDynamicQuery.performActions(); }
From source file:com.liferay.blogs.internal.verify.BlogsServiceVerifyProcess.java
License:Open Source License
protected void verifyStatus() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer()) { runSQL("update BlogsEntry set status = " + WorkflowConstants.STATUS_APPROVED + " where status is null"); }/* w w w .j ava 2 s.co m*/ }
From source file:com.liferay.blogs.internal.verify.VerifyBlogsTrackbacks.java
License:Open Source License
protected void verifyMBDiscussions() { try (LoggingTimer loggingTimer = new LoggingTimer()) { List<MBDiscussion> mbDiscussions = _mbDiscussionLocalService.getDiscussions(BlogsEntry.class.getName()); for (MBDiscussion mbDiscussion : mbDiscussions) { try { BlogsEntry entry = _blogsEntryLocalService.getEntry(mbDiscussion.getClassPK()); List<MBMessage> mbMessages = _mbMessageLocalService .getThreadMessages(mbDiscussion.getThreadId(), WorkflowConstants.STATUS_APPROVED); for (MBMessage mbMessage : mbMessages) { _verifyPost(entry, mbMessage); }/*from ww w . j a va 2s . com*/ } catch (Exception e) { _log.error(e, e); } } } }
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;/*from w ww . j a v a 2s . c o 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
@Override public BlogsEntry[] getEntriesPrevAndNext(long entryId) throws PortalException { BlogsEntry entry = blogsEntryPersistence.findByPrimaryKey(entryId); BlogsEntry[] entries = blogsEntryPersistence.findByG_D_S_PrevAndNext(entryId, entry.getGroupId(), entry.getDisplayDate(), WorkflowConstants.STATUS_APPROVED, new EntryIdComparator(true)); if (entries[0] == null) { entries[0] = blogsEntryPersistence.fetchByG_LtD_S_Last(entry.getGroupId(), entry.getDisplayDate(), WorkflowConstants.STATUS_APPROVED, new EntryDisplayDateComparator(true)); }//from w w w.j ava 2 s .c o m if (entries[2] == null) { entries[2] = blogsEntryPersistence.fetchByG_GtD_S_First(entry.getGroupId(), entry.getDisplayDate(), WorkflowConstants.STATUS_APPROVED, new EntryDisplayDateComparator(true)); } return entries; }
From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
@Indexable(type = IndexableType.REINDEX) @Override/*from ww w. j a v a2 s .c o m*/ 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; }