List of usage examples for com.liferay.portal.kernel.util StringPool DOUBLE_CLOSE_BRACKET
String DOUBLE_CLOSE_BRACKET
To view the source code for com.liferay.portal.kernel.util StringPool DOUBLE_CLOSE_BRACKET.
Click Source Link
From source file:com.liferay.portlet.wiki.importers.mediawiki.MediaWikiImporter.java
License:Open Source License
protected void importPage(long userId, String author, WikiNode node, String title, String content, String summary, Map<String, String> usersMap, boolean strictImportMode) throws PortalException { try {//from w w w . ja v a 2 s.c o m long authorUserId = getUserId(userId, node, author, usersMap); String parentTitle = readParentTitle(content); String redirectTitle = readRedirectTitle(content); ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); serviceContext.setAssetTagNames(readAssetTagNames(userId, node, content)); if (Validator.isNull(redirectTitle)) { _translator.setStrictImportMode(strictImportMode); content = _translator.translate(content); } else { content = StringPool.DOUBLE_OPEN_BRACKET + redirectTitle + StringPool.DOUBLE_CLOSE_BRACKET; } WikiPage page = null; try { page = WikiPageLocalServiceUtil.getPage(node.getNodeId(), title); } catch (NoSuchPageException nspe) { page = WikiPageLocalServiceUtil.addPage(authorUserId, node.getNodeId(), title, WikiPageConstants.NEW, null, true, serviceContext); } WikiPageLocalServiceUtil.updatePage(authorUserId, node.getNodeId(), title, page.getVersion(), content, summary, true, "creole", parentTitle, redirectTitle, serviceContext); } catch (Exception e) { throw new PortalException("Error importing page " + title, e); } }
From source file:com.liferay.portlet.wiki.service.impl.WikiPageLocalServiceImpl.java
License:Open Source License
public void movePage(long userId, long nodeId, String title, String newTitle, boolean strict, ServiceContext serviceContext) throws PortalException, SystemException { validateTitle(newTitle);//from w ww. jav a 2 s .c o m // Check if the new title already exists if (title.equalsIgnoreCase(newTitle)) { throw new DuplicatePageException(newTitle); } if (isUsedTitle(nodeId, newTitle)) { WikiPage page = getPage(nodeId, newTitle); // Support moving back to a previously moved title if (((page.getVersion() == WikiPageConstants.VERSION_DEFAULT) && (page.getContent().length() < 200)) || !strict) { deletePage(nodeId, newTitle); } else { throw new DuplicatePageException(newTitle); } } // All versions List<WikiPage> pageVersions = wikiPagePersistence.findByN_T(nodeId, title); if (pageVersions.size() == 0) { return; } for (WikiPage page : pageVersions) { page.setTitle(newTitle); wikiPagePersistence.update(page, false); } // Children List<WikiPage> children = wikiPagePersistence.findByN_P(nodeId, title); for (WikiPage page : children) { page.setParentTitle(newTitle); wikiPagePersistence.update(page, false); } WikiPage page = pageVersions.get(pageVersions.size() - 1); long resourcePrimKey = page.getResourcePrimKey(); // Page resource WikiPageResource wikiPageResource = wikiPageResourcePersistence.findByPrimaryKey(resourcePrimKey); wikiPageResource.setTitle(newTitle); wikiPageResourcePersistence.update(wikiPageResource, false); // Create stub page at the old location double version = WikiPageConstants.VERSION_DEFAULT; String summary = WikiPageConstants.MOVED + " to " + title; String format = page.getFormat(); boolean head = true; String parentTitle = page.getParentTitle(); String redirectTitle = page.getTitle(); String content = StringPool.DOUBLE_OPEN_BRACKET + redirectTitle + StringPool.DOUBLE_CLOSE_BRACKET; serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); AssetEntry assetEntry = assetEntryLocalService.getEntry(WikiPage.class.getName(), page.getResourcePrimKey()); List<AssetLink> assetLinks = assetLinkLocalService.getDirectLinks(assetEntry.getEntryId(), AssetLinkConstants.TYPE_RELATED); long[] assetLinkEntryIds = StringUtil.split(ListUtil.toString(assetLinks, AssetLink.ENTRY_ID2_ACCESSOR), 0L); serviceContext.setAssetLinkEntryIds(assetLinkEntryIds); addPage(userId, nodeId, title, version, content, summary, false, format, head, parentTitle, redirectTitle, serviceContext); // Move redirects to point to the page with the new title List<WikiPage> redirectedPages = wikiPagePersistence.findByN_R(nodeId, title); for (WikiPage redirectedPage : redirectedPages) { redirectedPage.setRedirectTitle(newTitle); wikiPagePersistence.update(redirectedPage, false); } // Asset updateAsset(userId, page, null, null, null); // Indexer Indexer indexer = IndexerRegistryUtil.getIndexer(WikiPage.class); indexer.delete(new Object[] { page.getCompanyId(), page.getNodeId(), title }); indexer.reindex(page); }
From source file:com.liferay.wiki.importer.impl.mediawiki.MediaWikiImporter.java
License:Open Source License
protected String getCreoleRedirectContent(String redirectTitle) { return StringPool.DOUBLE_OPEN_BRACKET + redirectTitle + StringPool.DOUBLE_CLOSE_BRACKET; }
From source file:com.liferay.wiki.service.impl.WikiPageLocalServiceImpl.java
License:Open Source License
protected WikiPage doRenamePage(long userId, long nodeId, String title, String newTitle, ServiceContext serviceContext) throws PortalException { // Version pages List<WikiPage> versionPages = wikiPagePersistence.findByN_T(nodeId, title, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new PageVersionComparator()); WikiPage page = fetchLatestPage(nodeId, newTitle, WorkflowConstants.STATUS_ANY, false); if (page == null) { page = getLatestPage(nodeId, title, WorkflowConstants.STATUS_ANY, false); }/*from w w w . ja va 2s .c o m*/ for (WikiPage versionPage : versionPages) { versionPage.setRedirectTitle(page.getRedirectTitle()); versionPage.setTitle(newTitle); wikiPagePersistence.update(versionPage); } // Page resource long resourcePrimKey = page.getResourcePrimKey(); WikiPageResource pageResource = wikiPageResourcePersistence.findByPrimaryKey(resourcePrimKey); pageResource.setTitle(newTitle); wikiPageResourcePersistence.update(pageResource); // Create stub page at the old location double version = WikiPageConstants.VERSION_DEFAULT; String summary = LanguageUtil.format(serviceContext.getLocale(), "renamed-as-x", newTitle); String format = page.getFormat(); boolean head = true; String parentTitle = page.getParentTitle(); String redirectTitle = page.getTitle(); String content = StringPool.DOUBLE_OPEN_BRACKET + redirectTitle + StringPool.DOUBLE_CLOSE_BRACKET; serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); populateServiceContext(serviceContext, page); boolean workflowEnabled = WorkflowThreadLocal.isEnabled(); WorkflowThreadLocal.setEnabled(false); serviceContext.setCommand(Constants.ADD); addPage(userId, nodeId, title, version, content, summary, false, format, head, parentTitle, redirectTitle, serviceContext); WorkflowThreadLocal.setEnabled(workflowEnabled); // Child pages List<WikiPage> childPages = wikiPagePersistence.findByN_P(nodeId, title); for (WikiPage childPage : childPages) { childPage.setParentTitle(newTitle); wikiPagePersistence.update(childPage); } // Redirect pages List<WikiPage> redirectorPages = getRedirectorPages(nodeId, title); for (WikiPage redirectorPage : redirectorPages) { redirectorPage.setRedirectTitle(newTitle); wikiPagePersistence.update(redirectorPage); } // Asset updateAsset(userId, page, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds(), serviceContext.getAssetPriority()); return page; }