List of usage examples for com.liferay.portal.kernel.systemevent SystemEventHierarchyEntryThreadLocal pop
public static SystemEventHierarchyEntry pop(String className)
From source file:com.liferay.document.library.internal.repository.capabilities.TemporaryFileEntriesCapabilityImpl.java
License:Open Source License
private void _runWithoutSystemEvents(UnsafeSupplier<Void, PortalException> unsafeSupplier) throws PortalException { SystemEventHierarchyEntryThreadLocal.push(DLFileEntry.class); try {//www. j a va 2 s. c o m unsafeSupplier.get(); } finally { SystemEventHierarchyEntryThreadLocal.pop(DLFileEntry.class); } }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Deletes all web content articles and their resources matching the group * and article ID, optionally sending email notifying denial of article if * it had not yet been approved.// ww w . j av a 2 s .com * * @param groupId the primary key of the web content article's group * @param articleId the primary key of the web content article * @param serviceContext the service context to be applied. Can set the * portlet preferences that include email information to notify * recipients of the unapproved web content article's denial. */ @Override public void deleteArticle(long groupId, String articleId, ServiceContext serviceContext) throws PortalException { SystemEventHierarchyEntryThreadLocal.push(JournalArticle.class); JournalArticleResource articleResource = journalArticleResourceLocalService.fetchArticleResource(groupId, articleId); try { List<JournalArticle> articles = journalArticlePersistence.findByG_A(groupId, articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new ArticleVersionComparator(true)); for (JournalArticle article : articles) { journalArticleLocalService.deleteArticle(article, null, serviceContext); } } finally { SystemEventHierarchyEntryThreadLocal.pop(JournalArticle.class); } if (articleResource != null) { systemEventLocalService.addSystemEvent(0, groupId, JournalArticle.class.getName(), articleResource.getResourcePrimKey(), articleResource.getUuid(), null, SystemEventConstants.TYPE_DELETE, StringPool.BLANK); } }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Deletes all the group's web content articles and resources. * * @param groupId the primary key of the web content article's group */// w w w. ja v a2 s . c om @Override public void deleteArticles(long groupId) throws PortalException { SystemEventHierarchyEntryThreadLocal.push(JournalArticle.class); List<JournalArticleResource> articleResources = new ArrayList<>(); try { JournalArticleResource articleResource = null; for (JournalArticle article : journalArticlePersistence.findByGroupId(groupId)) { if ((articleResource == null) || (articleResource.getPrimaryKey() != article.getResourcePrimKey())) { articleResource = journalArticleResourceLocalService .getArticleResource(article.getResourcePrimKey()); articleResources.add(articleResource); } journalArticleLocalService.deleteArticle(article, null, null); } } finally { SystemEventHierarchyEntryThreadLocal.pop(JournalArticle.class); } for (JournalArticleResource articleResource : articleResources) { systemEventLocalService.addSystemEvent(0, groupId, JournalArticle.class.getName(), articleResource.getResourcePrimKey(), articleResource.getUuid(), null, SystemEventConstants.TYPE_DELETE, StringPool.BLANK); } }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
/** * Deletes all the group's web content articles and resources in the folder, * optionally including recycled articles. * * @param groupId the primary key of the web content article's group * @param folderId the primary key of the web content article folder * @param includeTrashedEntries whether to include recycled web content * articles//from w w w . j a v a 2s . c om */ @Override public void deleteArticles(long groupId, long folderId, boolean includeTrashedEntries) throws PortalException { SystemEventHierarchyEntryThreadLocal.push(JournalArticle.class); List<JournalArticleResource> articleResources = new ArrayList<>(); try { JournalArticleResource articleResource = null; for (JournalArticle article : journalArticlePersistence.findByG_F(groupId, folderId)) { if ((articleResource == null) || (articleResource.getPrimaryKey() != article.getResourcePrimKey())) { articleResource = journalArticleResourceLocalService .getArticleResource(article.getResourcePrimKey()); articleResources.add(articleResource); } if (includeTrashedEntries || !article.isInTrashExplicitly()) { journalArticleLocalService.deleteArticle(article, null, null); } else { articleResources.remove(articleResource); } } } finally { SystemEventHierarchyEntryThreadLocal.pop(JournalArticle.class); } for (JournalArticleResource articleResource : articleResources) { systemEventLocalService.addSystemEvent(0, groupId, JournalArticle.class.getName(), articleResource.getResourcePrimKey(), articleResource.getUuid(), null, SystemEventConstants.TYPE_DELETE, StringPool.BLANK); } }
From source file:com.liferay.knowledgebase.service.impl.KBArticleLocalServiceImpl.java
License:Open Source License
@Override public KBArticle updateStatus(long userId, long resourcePrimKey, int status, ServiceContext serviceContext) throws PortalException { // KB article User user = userPersistence.findByPrimaryKey(userId); boolean main = false; Date now = new Date(); if (status == WorkflowConstants.STATUS_APPROVED) { main = true;//from w w w.j a v a 2s . c o m } KBArticle kbArticle = getLatestKBArticle(resourcePrimKey, WorkflowConstants.STATUS_ANY); kbArticle.setModifiedDate(serviceContext.getModifiedDate(now)); kbArticle.setMain(main); kbArticle.setStatus(status); kbArticle.setStatusByUserId(user.getUserId()); kbArticle.setStatusByUserName(user.getFullName()); kbArticle.setStatusDate(serviceContext.getModifiedDate(now)); kbArticlePersistence.update(kbArticle); if (status != WorkflowConstants.STATUS_APPROVED) { return kbArticle; } if (!kbArticle.isFirstVersion()) { KBArticle oldKBArticle = kbArticlePersistence.findByR_V(resourcePrimKey, kbArticle.getVersion() - 1); oldKBArticle.setMain(false); kbArticlePersistence.update(oldKBArticle); } // Asset AssetEntry assetEntry = assetEntryLocalService.getEntry(KBArticle.class.getName(), kbArticle.getKbArticleId()); List<AssetLink> assetLinks = assetLinkLocalService.getDirectLinks(assetEntry.getEntryId(), AssetLinkConstants.TYPE_RELATED); long[] assetLinkEntryIds = StringUtil.split(ListUtil.toString(assetLinks, AssetLink.ENTRY_ID2_ACCESSOR), 0L); updateKBArticleAsset(userId, kbArticle, assetEntry.getCategoryIds(), assetEntry.getTagNames(), assetLinkEntryIds); SystemEventHierarchyEntryThreadLocal.push(KBArticle.class); try { assetEntryLocalService.deleteEntry(KBArticle.class.getName(), kbArticle.getKbArticleId()); } finally { SystemEventHierarchyEntryThreadLocal.pop(KBArticle.class); } assetEntryLocalService.updateVisible(KBArticle.class.getName(), kbArticle.getResourcePrimKey(), true); // Social JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", kbArticle.getTitle()); if (!kbArticle.isFirstVersion()) { socialActivityLocalService.addActivity(userId, kbArticle.getGroupId(), KBArticle.class.getName(), resourcePrimKey, AdminActivityKeys.UPDATE_KB_ARTICLE, extraDataJSONObject.toString(), 0); } else { socialActivityLocalService.addActivity(userId, kbArticle.getGroupId(), KBArticle.class.getName(), resourcePrimKey, AdminActivityKeys.ADD_KB_ARTICLE, extraDataJSONObject.toString(), 0); } // Indexer Indexer indexer = IndexerRegistryUtil.getIndexer(KBArticle.class); indexer.reindex(kbArticle); // Subscriptions notifySubscribers(kbArticle, serviceContext); return kbArticle; }
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 w w w . j av a 2 s . c o m 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); }