List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants CONTEXT_COMMAND
String CONTEXT_COMMAND
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants CONTEXT_COMMAND.
Click Source Link
From source file:com.liferay.wiki.service.impl.WikiPageLocalServiceImpl.java
License:Open Source License
@Override public WikiPage updateStatus(long userId, WikiPage page, int status, ServiceContext serviceContext, Map<String, Serializable> workflowContext) throws PortalException { // Page/*from ww w. j a va2 s . c om*/ User user = userPersistence.findByPrimaryKey(userId); int oldStatus = page.getStatus(); page.setStatus(status); page.setStatusByUserId(userId); page.setStatusByUserName(user.getFullName()); page.setStatusDate(new Date()); wikiPagePersistence.update(page); if (status == WorkflowConstants.STATUS_APPROVED) { String cmd = GetterUtil.getString(workflowContext.get(WorkflowConstants.CONTEXT_COMMAND)); if (cmd.equals(Constants.RENAME)) { long resourcePrimKey = page.getResourcePrimKey(); WikiPage oldPage = getPage(resourcePrimKey, true); page = doRenamePage(userId, page.getNodeId(), oldPage.getTitle(), page.getTitle(), serviceContext); } // Asset if ((oldStatus != WorkflowConstants.STATUS_APPROVED) && (page.getVersion() != WikiPageConstants.VERSION_DEFAULT)) { AssetEntry draftAssetEntry = assetEntryLocalService.fetchEntry(WikiPage.class.getName(), page.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, page.getGroupId(), page.getCreateDate(), page.getModifiedDate(), WikiPage.class.getName(), page.getResourcePrimKey(), page.getUuid(), 0, assetCategoryIds, assetTagNames, true, true, null, null, page.getCreateDate(), null, ContentTypes.TEXT_HTML, page.getTitle(), null, null, null, null, 0, 0, null); // Asset Links assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds, AssetLinkConstants.TYPE_RELATED); SystemEventHierarchyEntryThreadLocal.push(WikiPage.class); try { assetEntryLocalService.deleteEntry(draftAssetEntry.getEntryId()); } finally { SystemEventHierarchyEntryThreadLocal.pop(WikiPage.class); } } } assetEntryLocalService.updateVisible(WikiPage.class.getName(), page.getResourcePrimKey(), true); // Social WikiGroupServiceOverriddenConfiguration wikiGroupServiceOverriddenConfiguration = configurationProvider .getConfiguration(WikiGroupServiceOverriddenConfiguration.class, new GroupServiceSettingsLocator(page.getGroupId(), WikiConstants.SERVICE_NAME)); if ((oldStatus != WorkflowConstants.STATUS_IN_TRASH) && (!page.isMinorEdit() || wikiGroupServiceOverriddenConfiguration.pageMinorEditAddSocialActivity())) { JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", page.getTitle()); extraDataJSONObject.put("version", page.getVersion()); int type = WikiActivityKeys.UPDATE_PAGE; if (serviceContext.isCommandAdd()) { type = WikiActivityKeys.ADD_PAGE; } SocialActivityManagerUtil.addActivity(userId, page, type, extraDataJSONObject.toString(), 0); } // Subscriptions if (NotificationThreadLocal.isEnabled() && (!page.isMinorEdit() || wikiGroupServiceOverriddenConfiguration.pageMinorEditSendEmail())) { notifySubscribers(userId, page, (String) workflowContext.get(WorkflowConstants.CONTEXT_URL), serviceContext); } // Cache clearPageCache(page); } // Head if (status == WorkflowConstants.STATUS_APPROVED) { page.setHead(true); List<WikiPage> pages = wikiPagePersistence.findByN_T_H(page.getNodeId(), page.getTitle(), true); for (WikiPage curPage : pages) { if (!curPage.equals(page)) { curPage.setHead(false); wikiPagePersistence.update(curPage); } } } else if (status != WorkflowConstants.STATUS_IN_TRASH) { page.setHead(false); List<WikiPage> pages = wikiPagePersistence.findByN_T_S(page.getNodeId(), page.getTitle(), WorkflowConstants.STATUS_APPROVED); for (WikiPage curPage : pages) { if (!curPage.equals(page)) { curPage.setHead(true); wikiPagePersistence.update(curPage); break; } } } // Indexer Indexer<WikiPage> indexer = IndexerRegistryUtil.nullSafeGetIndexer(WikiPage.class); indexer.reindex(page); return wikiPagePersistence.update(page); }
From source file:com.liferay.wiki.service.impl.WikiPageLocalServiceImpl.java
License:Open Source License
protected WikiPage startWorkflowInstance(long userId, WikiPage page, ServiceContext serviceContext) throws PortalException { Map<String, Serializable> workflowContext = new HashMap<>(); workflowContext.put(WorkflowConstants.CONTEXT_COMMAND, serviceContext.getCommand()); workflowContext.put(WorkflowConstants.CONTEXT_URL, getPageURL(page, serviceContext)); return WorkflowHandlerRegistryUtil.startWorkflowInstance(page.getCompanyId(), page.getGroupId(), userId, WikiPage.class.getName(), page.getPageId(), page, serviceContext, workflowContext); }