List of usage examples for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS
String CLOSE_PARENTHESIS
To view the source code for com.liferay.portal.kernel.util StringPool CLOSE_PARENTHESIS.
Click Source Link
From source file:com.liferay.twitter.service.persistence.impl.FeedPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Feed> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from w w w.j av a2 s. co m*/ Map<Serializable, Feed> map = new HashMap<Serializable, Feed>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Feed feed = fetchByPrimaryKey(primaryKey); if (feed != null) { map.put(primaryKey, feed); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Feed feed = (Feed) EntityCacheUtil.getResult(FeedModelImpl.ENTITY_CACHE_ENABLED, FeedImpl.class, primaryKey); if (feed == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, feed); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_FEED_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (Feed feed : (List<Feed>) q.list()) { map.put(feed.getPrimaryKeyObj(), feed); cacheResult(feed); uncachedPrimaryKeys.remove(feed.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(FeedModelImpl.ENTITY_CACHE_ENABLED, FeedImpl.class, primaryKey, _nullFeed); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.video.library.service.persistence.impl.VideoPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Video> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from ww w .j av a 2s. com Map<Serializable, Video> map = new HashMap<Serializable, Video>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Video video = fetchByPrimaryKey(primaryKey); if (video != null) { map.put(primaryKey, video); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(VideoModelImpl.ENTITY_CACHE_ENABLED, VideoImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (Video) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_VIDEO_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (Video video : (List<Video>) q.list()) { map.put(video.getPrimaryKeyObj(), video); cacheResult(video); uncachedPrimaryKeys.remove(video.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(VideoModelImpl.ENTITY_CACHE_ENABLED, VideoImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.wiki.engine.markdown.pegdown.ast.LiferayPegDownProcessor.java
License:Open Source License
protected String stripIds(String content) { int index = content.indexOf("[](id="); if (index == -1) { return content; }//from w ww. j av a 2 s .co m StringBundler sb = new StringBundler(); do { int x = content.indexOf(StringPool.EQUAL, index); int y = content.indexOf(StringPool.CLOSE_PARENTHESIS, x); if (y != -1) { int z = content.indexOf("</h", y); if (z != (y + 1)) { sb.append(content.substring(0, y + 1)); } else { sb.append(StringUtil.trimTrailing(content.substring(0, index))); } content = content.substring(y + 1); } else { if (_log.isWarnEnabled()) { String msg = content.substring(index); // Get the invalid id text from the content int spaceIndex = content.indexOf(StringPool.SPACE); if (spaceIndex != -1) { msg = content.substring(index, spaceIndex); } _log.warn("Missing ')' for web content containing header id " + msg); } // Since no close parenthesis remains in the content, stop // stripping out IDs and simply include all of the remaining // content break; } } while ((index = content.indexOf("[](id=")) != -1); sb.append(content); return sb.toString(); }
From source file:com.liferay.wiki.service.impl.WikiPageServiceImpl.java
License:Open Source License
protected String exportToRSS(String name, String description, String type, double version, String displayStyle, String feedURL, String entryURL, String attachmentURLPrefix, List<WikiPage> pages, boolean diff, Locale locale) throws PortalException { SyndFeed syndFeed = new SyndFeedImpl(); syndFeed.setDescription(description); List<SyndEntry> syndEntries = new ArrayList<>(); syndFeed.setEntries(syndEntries);/*from ww w .j a v a 2 s .co m*/ WikiPage latestPage = null; StringBundler sb = new StringBundler(6); for (WikiPage page : pages) { SyndEntry syndEntry = new SyndEntryImpl(); String author = PortalUtil.getUserName(page); syndEntry.setAuthor(author); SyndContent syndContent = new SyndContentImpl(); syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT); sb.setIndex(0); sb.append(entryURL); if (entryURL.endsWith(StringPool.SLASH)) { sb.append(HttpUtil.encodeURL(page.getTitle())); } if (diff) { if ((latestPage != null) || (pages.size() == 1)) { sb.append(StringPool.QUESTION); sb.append(PortalUtil.getPortletNamespace(WikiPortletKeys.WIKI)); sb.append("version="); sb.append(page.getVersion()); String value = null; if (latestPage == null) { value = wikiEngineRenderer.convert(page, null, null, attachmentURLPrefix); } else { try { value = wikiEngineRenderer.diffHtml(latestPage, page, null, null, attachmentURLPrefix); } catch (PortalException pe) { throw pe; } catch (SystemException se) { throw se; } catch (Exception e) { throw new SystemException(e); } } syndContent.setValue(value); syndEntry.setDescription(syndContent); syndEntries.add(syndEntry); } } else { String value = null; WikiGroupServiceOverriddenConfiguration wikiGroupServiceOverriddenConfiguration = configurationProvider .getConfiguration(WikiGroupServiceOverriddenConfiguration.class, new GroupServiceSettingsLocator(page.getGroupId(), WikiConstants.SERVICE_NAME)); if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_ABSTRACT)) { value = StringUtil.shorten(HtmlUtil.extractText(page.getContent()), wikiGroupServiceOverriddenConfiguration.rssAbstractLength(), StringPool.BLANK); } else if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_TITLE)) { value = StringPool.BLANK; } else { value = wikiEngineRenderer.convert(page, null, null, attachmentURLPrefix); } syndContent.setValue(value); syndEntry.setDescription(syndContent); syndEntries.add(syndEntry); } syndEntry.setLink(sb.toString()); syndEntry.setPublishedDate(page.getCreateDate()); String title = page.getTitle() + StringPool.SPACE + page.getVersion(); if (page.isMinorEdit()) { title += StringPool.SPACE + StringPool.OPEN_PARENTHESIS + LanguageUtil.get(locale, "minor-edit") + StringPool.CLOSE_PARENTHESIS; } syndEntry.setTitle(title); syndEntry.setUpdatedDate(page.getModifiedDate()); syndEntry.setUri(sb.toString()); latestPage = page; } syndFeed.setFeedType(RSSUtil.getFeedType(type, version)); List<SyndLink> syndLinks = new ArrayList<>(); syndFeed.setLinks(syndLinks); SyndLink syndLinkSelf = new SyndLinkImpl(); syndLinks.add(syndLinkSelf); syndLinkSelf.setHref(feedURL); syndLinkSelf.setRel("self"); syndFeed.setPublishedDate(new Date()); syndFeed.setTitle(name); syndFeed.setUri(feedURL); try { return RSSUtil.export(syndFeed); } catch (FeedException fe) { throw new SystemException(fe); } }
From source file:com.liferay.wiki.service.persistence.impl.WikiNodePersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, WikiNode> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from ww w .jav a 2s . c om*/ Map<Serializable, WikiNode> map = new HashMap<Serializable, WikiNode>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); WikiNode wikiNode = fetchByPrimaryKey(primaryKey); if (wikiNode != null) { map.put(primaryKey, wikiNode); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED, WikiNodeImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (WikiNode) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_WIKINODE_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (WikiNode wikiNode : (List<WikiNode>) q.list()) { map.put(wikiNode.getPrimaryKeyObj(), wikiNode); cacheResult(wikiNode); uncachedPrimaryKeys.remove(wikiNode.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED, WikiNodeImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.wiki.service.persistence.impl.WikiPagePersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, WikiPage> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from ww w . j a va 2s . com Map<Serializable, WikiPage> map = new HashMap<Serializable, WikiPage>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); WikiPage wikiPage = fetchByPrimaryKey(primaryKey); if (wikiPage != null) { map.put(primaryKey, wikiPage); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED, WikiPageImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (WikiPage) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_WIKIPAGE_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (WikiPage wikiPage : (List<WikiPage>) q.list()) { map.put(wikiPage.getPrimaryKeyObj(), wikiPage); cacheResult(wikiPage); uncachedPrimaryKeys.remove(wikiPage.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(WikiPageModelImpl.ENTITY_CACHE_ENABLED, WikiPageImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.wiki.service.persistence.impl.WikiPageResourcePersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, WikiPageResource> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from w ww. j ava2 s.com*/ Map<Serializable, WikiPageResource> map = new HashMap<Serializable, WikiPageResource>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); WikiPageResource wikiPageResource = fetchByPrimaryKey(primaryKey); if (wikiPageResource != null) { map.put(primaryKey, wikiPageResource); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED, WikiPageResourceImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (WikiPageResource) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_WIKIPAGERESOURCE_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (WikiPageResource wikiPageResource : (List<WikiPageResource>) q.list()) { map.put(wikiPageResource.getPrimaryKeyObj(), wikiPageResource); cacheResult(wikiPageResource); uncachedPrimaryKeys.remove(wikiPageResource.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(WikiPageResourceModelImpl.ENTITY_CACHE_ENABLED, WikiPageResourceImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.wsrp.service.persistence.impl.WSRPConsumerPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, WSRPConsumer> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from w w w. j a v a 2 s . c o m*/ Map<Serializable, WSRPConsumer> map = new HashMap<Serializable, WSRPConsumer>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); WSRPConsumer wsrpConsumer = fetchByPrimaryKey(primaryKey); if (wsrpConsumer != null) { map.put(primaryKey, wsrpConsumer); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { WSRPConsumer wsrpConsumer = (WSRPConsumer) EntityCacheUtil .getResult(WSRPConsumerModelImpl.ENTITY_CACHE_ENABLED, WSRPConsumerImpl.class, primaryKey); if (wsrpConsumer == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, wsrpConsumer); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_WSRPCONSUMER_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (WSRPConsumer wsrpConsumer : (List<WSRPConsumer>) q.list()) { map.put(wsrpConsumer.getPrimaryKeyObj(), wsrpConsumer); cacheResult(wsrpConsumer); uncachedPrimaryKeys.remove(wsrpConsumer.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(WSRPConsumerModelImpl.ENTITY_CACHE_ENABLED, WSRPConsumerImpl.class, primaryKey, _nullWSRPConsumer); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.wsrp.service.persistence.impl.WSRPConsumerPortletPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, WSRPConsumerPortlet> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from w ww . j av a 2 s. c o m Map<Serializable, WSRPConsumerPortlet> map = new HashMap<Serializable, WSRPConsumerPortlet>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); WSRPConsumerPortlet wsrpConsumerPortlet = fetchByPrimaryKey(primaryKey); if (wsrpConsumerPortlet != null) { map.put(primaryKey, wsrpConsumerPortlet); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { WSRPConsumerPortlet wsrpConsumerPortlet = (WSRPConsumerPortlet) EntityCacheUtil.getResult( WSRPConsumerPortletModelImpl.ENTITY_CACHE_ENABLED, WSRPConsumerPortletImpl.class, primaryKey); if (wsrpConsumerPortlet == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, wsrpConsumerPortlet); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_WSRPCONSUMERPORTLET_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (WSRPConsumerPortlet wsrpConsumerPortlet : (List<WSRPConsumerPortlet>) q.list()) { map.put(wsrpConsumerPortlet.getPrimaryKeyObj(), wsrpConsumerPortlet); cacheResult(wsrpConsumerPortlet); uncachedPrimaryKeys.remove(wsrpConsumerPortlet.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(WSRPConsumerPortletModelImpl.ENTITY_CACHE_ENABLED, WSRPConsumerPortletImpl.class, primaryKey, _nullWSRPConsumerPortlet); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }