List of usage examples for com.liferay.portal.kernel.util StringPool AMPERSAND
String AMPERSAND
To view the source code for com.liferay.portal.kernel.util StringPool AMPERSAND.
Click Source Link
From source file:com.liferay.portlet.asset.service.impl.AssetEntryLocalServiceImpl.java
License:Open Source License
@Override public AssetEntry updateEntry(long userId, long groupId, Date createDate, Date modifiedDate, String className, long classPK, String classUuid, long classTypeId, long[] categoryIds, String[] tagNames, boolean visible, Date startDate, Date endDate, Date expirationDate, String mimeType, String title, String description, String summary, String url, String layoutUuid, int height, int width, Integer priority, boolean sync) throws PortalException, SystemException { // Entry//from w w w.j a v a 2 s . c om User user = userPersistence.findByPrimaryKey(userId); long classNameId = PortalUtil.getClassNameId(className); List<String> newTagsList = new ArrayList<String>(); if (!Validator.isNull(tagNames) && className.equalsIgnoreCase(JournalArticle.class.getName())) { for (String tag : tagNames) { if (PropsUtil.get("stoxx-contentmanagement-all-region").equalsIgnoreCase(tag)) { ClassLoader classLoader = (ClassLoader) PortletBeanLocatorUtil .locate(ClpSerializer.getServletContextName(), "portletClassLoader"); DynamicQuery query = DynamicQueryFactoryUtil.forClass(IndexDB.class, classLoader); query.setProjection( ProjectionFactoryUtil.distinct(ProjectionFactoryUtil.property("superRegion"))); query.addOrder(OrderFactoryUtil.asc("superRegion")); query.add(RestrictionsFactoryUtil.eq("data1", "1")); newTagsList.addAll(new ArrayList<String>(IndexDBLocalServiceUtil.dynamicQuery(query))); } else if (PropsUtil.get("stoxx-contentmanagement-all-type").equalsIgnoreCase(tag)) { ClassLoader classLoader = (ClassLoader) PortletBeanLocatorUtil .locate(ClpSerializer.getServletContextName(), "portletClassLoader"); DynamicQuery query = DynamicQueryFactoryUtil.forClass(IndexDB.class, classLoader); query.setProjection( ProjectionFactoryUtil.distinct(ProjectionFactoryUtil.property("superType"))); query.addOrder(OrderFactoryUtil.asc("superType")); query.add(RestrictionsFactoryUtil.eq("data1", "1")); newTagsList.addAll(new ArrayList<String>(IndexDBLocalServiceUtil.dynamicQuery(query))); } else { List<String> regionSuperTypeList = getRegionandTypeList(tag); if (regionSuperTypeList.size() > 0) { newTagsList.addAll(regionSuperTypeList); } } } } if (newTagsList.size() > 0) { int arraySize = newTagsList.size() + tagNames.length; String[] newTagNames = new String[arraySize]; int count = 0; for (String tag : newTagsList) { tag = tag.replace(StringPool.SLASH, StringPool.BLANK); tag = tag.replace(StringPool.AMPERSAND, StringPool.BLANK); tag = tag.replace(StringPool.PERCENT, StringPool.BLANK); newTagNames[count] = tag; count++; } for (String tag : tagNames) { if (!PropsUtil.get("stoxx-contentmanagement-all-type").equalsIgnoreCase(tag) && !PropsUtil.get("stoxx-contentmanagement-all-region").equalsIgnoreCase(tag)) { newTagNames[count] = tag; count++; } } List<String> tagList = new ArrayList<String>(Arrays.asList(newTagNames)); tagList.removeAll(Collections.singleton(null)); tagNames = tagList.toArray(new String[tagList.size()]); } validate(groupId, className, categoryIds, tagNames); AssetEntry entry = assetEntryPersistence.fetchByC_C(classNameId, classPK); boolean oldVisible = false; if (entry != null) { oldVisible = entry.isVisible(); } if (modifiedDate == null) { modifiedDate = new Date(); } if (entry == null) { long entryId = counterLocalService.increment(); entry = assetEntryPersistence.create(entryId); entry.setCompanyId(user.getCompanyId()); entry.setUserId(user.getUserId()); entry.setUserName(user.getFullName()); if (createDate == null) { createDate = new Date(); } entry.setCreateDate(createDate); entry.setModifiedDate(modifiedDate); entry.setClassNameId(classNameId); entry.setClassPK(classPK); entry.setClassUuid(classUuid); entry.setVisible(visible); entry.setExpirationDate(expirationDate); if (priority == null) { entry.setPriority(0); } entry.setViewCount(0); } entry.setGroupId(groupId); entry.setModifiedDate(modifiedDate); entry.setClassTypeId(classTypeId); entry.setVisible(visible); entry.setStartDate(startDate); entry.setEndDate(endDate); entry.setExpirationDate(expirationDate); entry.setMimeType(mimeType); entry.setTitle(title); entry.setDescription(description); entry.setSummary(summary); entry.setUrl(url); entry.setLayoutUuid(layoutUuid); entry.setHeight(height); entry.setWidth(width); if (priority != null) { entry.setPriority(priority.intValue()); } // Categories if (categoryIds != null) { assetEntryPersistence.setAssetCategories(entry.getEntryId(), categoryIds); } // Tags if (tagNames != null) { long siteGroupId = PortalUtil.getSiteGroupId(groupId); Group siteGroup = groupLocalService.getGroup(siteGroupId); List<AssetTag> tags = assetTagLocalService.checkTags(userId, siteGroup, tagNames); List<AssetTag> oldTags = assetEntryPersistence.getAssetTags(entry.getEntryId()); assetEntryPersistence.setAssetTags(entry.getEntryId(), tags); if (entry.isVisible()) { boolean isNew = entry.isNew(); assetEntryPersistence.updateImpl(entry); if (isNew) { for (AssetTag tag : tags) { assetTagLocalService.incrementAssetCount(tag.getTagId(), classNameId); } } else { for (AssetTag oldTag : oldTags) { if (!tags.contains(oldTag)) { assetTagLocalService.decrementAssetCount(oldTag.getTagId(), classNameId); } } for (AssetTag tag : tags) { if (!oldTags.contains(tag)) { assetTagLocalService.incrementAssetCount(tag.getTagId(), classNameId); } } } } else if (oldVisible) { for (AssetTag oldTag : oldTags) { assetTagLocalService.decrementAssetCount(oldTag.getTagId(), classNameId); } } } // Update entry after tags so that entry listeners have access to the // saved categories and tags log.info("AssetEntryLocalServiceImpl.updateEntry() inside updateEntry"); if (entry.getClassName().equals(JournalArticle.class.getName())) { List<AssetCategory> assetCategory = entry.getCategories(); for (AssetCategory ae : assetCategory) { log.info("AssetEntryLocalServiceImpl.updateEntry() the asset category is " + ae.getName()); if (STOXXConstants.CATEGORY_STOXX_NEWS_PRESS_RELEASE.equalsIgnoreCase(ae.getName()) || STOXXConstants.CATEGORY_STOXX_NEWS_MARKET_NEWS.equalsIgnoreCase(ae.getName()) || STOXXConstants.CATEGORY_STOXX_RESEARCH_MARKET_TRENDS.equalsIgnoreCase(ae.getName()) || STOXXConstants.CATEGORY_STOXX_RESEARCH_WEBINARS.equalsIgnoreCase(ae.getName()) || STOXXConstants.CATEGORY_STOXX_RESEARCH_EXPERT_SPEAK.equalsIgnoreCase(ae.getName()) || STOXXConstants.CATEGORY_STOXX_RESEARCH_EVENTS.equalsIgnoreCase(ae.getName()) || STOXXConstants.CATEGORY_STOXX_RESEARCH_PULSE.equalsIgnoreCase(ae.getName())) { JournalArticle journalArticle = null; try { journalArticle = JournalArticleLocalServiceUtil.getLatestArticle(entry.getClassPK()); } catch (Exception e) { log.info("The exception in getting journalArticle " + e.getMessage()); break; } String strDate = getXmlDocument(journalArticle, "Date"); log.info("AssetEntryLocalServiceImpl.updateEntry() Date is strDate" + strDate); if (!Validator.isBlank(strDate)) { log.info("AssetEntryLocalServiceImpl.updateEntry() date is not null"); Date date = new Date(Long.parseLong(strDate)); entry.setModifiedDate(date); break; } } } } log.info("AssetEntryLocalServiceImpl.updateEntry() processing finished"); assetEntryPersistence.update(entry); // Synchronize if (!sync) { return entry; } if (className.equals(BlogsEntry.class.getName())) { BlogsEntry blogsEntry = blogsEntryPersistence.findByPrimaryKey(classPK); blogsEntry.setTitle(title); blogsEntryPersistence.update(blogsEntry); } else if (className.equals(BookmarksEntry.class.getName())) { BookmarksEntry bookmarksEntry = bookmarksEntryPersistence.findByPrimaryKey(classPK); bookmarksEntry.setName(title); bookmarksEntry.setDescription(description); bookmarksEntry.setUrl(url); bookmarksEntryPersistence.update(bookmarksEntry); } else if (className.equals(DLFileEntry.class.getName())) { DLFileEntry dlFileEntry = dlFileEntryPersistence.findByPrimaryKey(classPK); dlFileEntry.setTitle(title); dlFileEntry.setDescription(description); dlFileEntryPersistence.update(dlFileEntry); } else if (className.equals(JournalArticle.class.getName())) { JournalArticle journalArticle = journalArticlePersistence.findByPrimaryKey(classPK); journalArticle.setTitle(title); journalArticle.setDescription(description); journalArticlePersistence.update(journalArticle); } else if (className.equals(MBMessage.class.getName())) { MBMessage mbMessage = mbMessagePersistence.findByPrimaryKey(classPK); mbMessage.setSubject(title); mbMessagePersistence.update(mbMessage); } else if (className.equals(WikiPage.class.getName())) { WikiPage wikiPage = wikiPagePersistence.findByPrimaryKey(classPK); wikiPage.setTitle(title); wikiPagePersistence.update(wikiPage); } return entry; }
From source file:com.liferay.portlet.blogs.service.impl.BlogsEntryServiceImpl.java
License:Open Source License
protected String exportToRSS(String name, String description, String type, double version, String displayStyle, String feedURL, String entryURL, List<BlogsEntry> blogsEntries, ThemeDisplay themeDisplay) throws SystemException { SyndFeed syndFeed = new SyndFeedImpl(); syndFeed.setFeedType(RSSUtil.getFeedType(type, version)); syndFeed.setTitle(name);/*from www . ja v a 2 s . co m*/ syndFeed.setLink(feedURL); syndFeed.setDescription(description); List<SyndEntry> syndEntries = new ArrayList<SyndEntry>(); syndFeed.setEntries(syndEntries); for (BlogsEntry entry : blogsEntries) { String author = HtmlUtil.escape(PortalUtil.getUserName(entry.getUserId(), entry.getUserName())); StringBundler link = new StringBundler(4); if (entryURL.endsWith("/blogs/rss")) { link.append(entryURL.substring(0, entryURL.length() - 3)); link.append(entry.getUrlTitle()); } else { link.append(entryURL); if (!entryURL.endsWith(StringPool.QUESTION)) { link.append(StringPool.AMPERSAND); } link.append("entryId="); link.append(entry.getEntryId()); } String value = null; if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_ABSTRACT)) { value = StringUtil.shorten(HtmlUtil.extractText(entry.getDescription()), PropsValues.BLOGS_RSS_ABSTRACT_LENGTH, StringPool.BLANK); } else if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_TITLE)) { value = StringPool.BLANK; } else { value = StringUtil.replace(entry.getContent(), new String[] { "href=\"/", "src=\"/" }, new String[] { "href=\"" + themeDisplay.getURLPortal() + "/", "src=\"" + themeDisplay.getURLPortal() + "/" }); } SyndEntry syndEntry = new SyndEntryImpl(); syndEntry.setAuthor(author); syndEntry.setTitle(entry.getTitle()); syndEntry.setLink(link.toString()); syndEntry.setUri(syndEntry.getLink()); syndEntry.setPublishedDate(entry.getCreateDate()); syndEntry.setUpdatedDate(entry.getModifiedDate()); SyndContent syndContent = new SyndContentImpl(); syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT); syndContent.setValue(value); syndEntry.setDescription(syndContent); syndEntries.add(syndEntry); } try { return RSSUtil.export(syndFeed); } catch (FeedException fe) { throw new SystemException(fe); } }
From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java
License:Open Source License
public static String exportReferencedContent(PortletDataContext portletDataContext, Element dlFileEntryTypesElement, Element dlFoldersElement, Element dlFileEntriesElement, Element dlFileRanksElement, Element dlRepositoriesElement, Element dlRepositoryEntriesElement, Element entityElement, String content) throws Exception { content = exportDLFileEntries(portletDataContext, dlFileEntryTypesElement, dlFoldersElement, dlFileEntriesElement, dlFileRanksElement, dlRepositoriesElement, dlRepositoryEntriesElement, entityElement, content, false); content = exportLayoutFriendlyURLs(portletDataContext, content); content = exportLinksToLayout(portletDataContext, content); String entityElementName = entityElement.getName(); if (!entityElementName.equals("article")) { content = StringUtil.replace(content, StringPool.AMPERSAND_ENCODED, StringPool.AMPERSAND); }/*from ww w . ja va2 s.com*/ return content; }
From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java
License:Open Source License
protected static String exportDLFileEntries(PortletDataContext portletDataContext, Element dlFileEntryTypesElement, Element dlFoldersElement, Element dlFileEntriesElement, Element dlFileRanksElement, Element dlRepositoriesElement, Element dlRepositoryEntriesElement, Element entityElement, String content, boolean checkDateRange) throws Exception { Group group = GroupLocalServiceUtil.getGroup(portletDataContext.getGroupId()); if (group.isStagingGroup()) { group = group.getLiveGroup();/*from w w w . ja v a 2 s .c o m*/ } if (group.isStaged() && !group.isStagedRemotely() && !group.isStagedPortlet(PortletKeys.DOCUMENT_LIBRARY)) { return content; } StringBuilder sb = new StringBuilder(content); int beginPos = content.length(); int currentLocation = -1; while (true) { currentLocation = content.lastIndexOf("/c/document_library/get_file?", beginPos); if (currentLocation == -1) { currentLocation = content.lastIndexOf("/documents/", beginPos); } if (currentLocation == -1) { return sb.toString(); } beginPos = currentLocation; int endPos1 = content.indexOf(CharPool.APOSTROPHE, beginPos); int endPos2 = content.indexOf(CharPool.CLOSE_BRACKET, beginPos); int endPos3 = content.indexOf(CharPool.CLOSE_CURLY_BRACE, beginPos); int endPos4 = content.indexOf(CharPool.CLOSE_PARENTHESIS, beginPos); int endPos5 = content.indexOf(CharPool.LESS_THAN, beginPos); int endPos6 = content.indexOf(CharPool.QUESTION, beginPos); int endPos7 = content.indexOf(CharPool.QUOTE, beginPos); int endPos8 = content.indexOf(CharPool.SPACE, beginPos); int endPos = endPos1; if ((endPos == -1) || ((endPos2 != -1) && (endPos2 < endPos))) { endPos = endPos2; } if ((endPos == -1) || ((endPos3 != -1) && (endPos3 < endPos))) { endPos = endPos3; } if ((endPos == -1) || ((endPos4 != -1) && (endPos4 < endPos))) { endPos = endPos4; } if ((endPos == -1) || ((endPos5 != -1) && (endPos5 < endPos))) { endPos = endPos5; } if ((endPos == -1) || ((endPos6 != -1) && (endPos6 < endPos))) { endPos = endPos6; } if ((endPos == -1) || ((endPos7 != -1) && (endPos7 < endPos))) { endPos = endPos7; } if ((endPos == -1) || ((endPos8 != -1) && (endPos8 < endPos))) { endPos = endPos8; } if ((beginPos == -1) || (endPos == -1)) { break; } try { String oldParameters = content.substring(beginPos, endPos); while (oldParameters.contains(StringPool.AMPERSAND_ENCODED)) { oldParameters = oldParameters.replace(StringPool.AMPERSAND_ENCODED, StringPool.AMPERSAND); } Map<String, String[]> map = new HashMap<String, String[]>(); if (oldParameters.startsWith("/documents/")) { String[] pathArray = oldParameters.split(StringPool.SLASH); map.put("groupId", new String[] { pathArray[2] }); if (pathArray.length == 4) { map.put("uuid", new String[] { pathArray[3] }); } else if (pathArray.length == 5) { map.put("folderId", new String[] { pathArray[3] }); String name = HttpUtil.decodeURL(pathArray[4]); int pos = name.indexOf(StringPool.QUESTION); if (pos != -1) { name = name.substring(0, pos); } map.put("name", new String[] { name }); } else if (pathArray.length > 5) { String uuid = pathArray[5]; int pos = uuid.indexOf(StringPool.QUESTION); if (pos != -1) { uuid = uuid.substring(0, pos); } map.put("uuid", new String[] { uuid }); } } else { oldParameters = oldParameters.substring(oldParameters.indexOf(CharPool.QUESTION) + 1); map = HttpUtil.parameterMapFromString(oldParameters); } FileEntry fileEntry = null; String uuid = MapUtil.getString(map, "uuid"); if (Validator.isNotNull(uuid)) { String groupIdString = MapUtil.getString(map, "groupId"); long groupId = GetterUtil.getLong(groupIdString); if (groupIdString.equals("@group_id@")) { groupId = portletDataContext.getScopeGroupId(); } fileEntry = DLAppLocalServiceUtil.getFileEntryByUuidAndGroupId(uuid, groupId); } else { String folderIdString = MapUtil.getString(map, "folderId"); if (Validator.isNotNull(folderIdString)) { long folderId = GetterUtil.getLong(folderIdString); String name = MapUtil.getString(map, "name"); String groupIdString = MapUtil.getString(map, "groupId"); long groupId = GetterUtil.getLong(groupIdString); if (groupIdString.equals("@group_id@")) { groupId = portletDataContext.getScopeGroupId(); } fileEntry = DLAppLocalServiceUtil.getFileEntry(groupId, folderId, name); } } if (fileEntry == null) { beginPos--; continue; } DLPortletDataHandlerImpl.exportFileEntry(portletDataContext, dlFileEntryTypesElement, dlFoldersElement, dlFileEntriesElement, dlFileRanksElement, dlRepositoriesElement, dlRepositoryEntriesElement, fileEntry, checkDateRange); Element dlReferenceElement = entityElement.addElement("dl-reference"); dlReferenceElement.addAttribute("default-repository", String.valueOf(fileEntry.isDefaultRepository())); String path = null; if (fileEntry.isDefaultRepository()) { path = DLPortletDataHandlerImpl.getFileEntryPath(portletDataContext, fileEntry); } else { path = DLPortletDataHandlerImpl.getRepositoryEntryPath(portletDataContext, fileEntry.getFileEntryId()); } dlReferenceElement.addAttribute("path", path); String dlReference = "[$dl-reference=" + path + "$]"; sb.replace(beginPos, endPos, dlReference); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } else if (_log.isWarnEnabled()) { _log.warn(e.getMessage()); } } beginPos--; } return sb.toString(); }
From source file:com.liferay.portlet.PortletURLUtil.java
License:Open Source License
public static String getRefreshURL(HttpServletRequest request, ThemeDisplay themeDisplay) { StringBundler sb = new StringBundler(32); sb.append(themeDisplay.getPathMain()); sb.append("/portal/render_portlet?p_l_id="); long plid = themeDisplay.getPlid(); sb.append(plid);/*from www.j av a 2 s .c o m*/ Portlet portlet = (Portlet) request.getAttribute(WebKeys.RENDER_PORTLET); String portletId = portlet.getPortletId(); sb.append("&p_p_id="); sb.append(portletId); sb.append("&p_p_lifecycle=0&p_t_lifecycle="); sb.append(themeDisplay.getLifecycle()); WindowState windowState = WindowState.NORMAL; if (themeDisplay.isStatePopUp()) { windowState = LiferayWindowState.POP_UP; } else { LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet(); if (layoutTypePortlet.hasStateMaxPortletId(portletId)) { windowState = WindowState.MAXIMIZED; } else if (layoutTypePortlet.hasStateMinPortletId(portletId)) { windowState = WindowState.MINIMIZED; } } sb.append("&p_p_state="); sb.append(windowState); sb.append("&p_p_mode=view&p_p_col_id="); String columnId = (String) request.getAttribute(WebKeys.RENDER_PORTLET_COLUMN_ID); sb.append(columnId); Integer columnPos = (Integer) request.getAttribute(WebKeys.RENDER_PORTLET_COLUMN_POS); sb.append("&p_p_col_pos="); sb.append(columnPos); Integer columnCount = (Integer) request.getAttribute(WebKeys.RENDER_PORTLET_COLUMN_COUNT); sb.append("&p_p_col_count="); sb.append(columnCount); if (portlet.isStatic()) { sb.append("&p_p_static=1"); if (portlet.isStaticStart()) { sb.append("&p_p_static_start=1"); } } sb.append("&p_p_isolated=1"); String doAsUserId = themeDisplay.getDoAsUserId(); if (Validator.isNotNull(doAsUserId)) { sb.append("&doAsUserId="); sb.append(HttpUtil.encodeURL(doAsUserId)); } String currentURL = PortalUtil.getCurrentURL(request); sb.append("¤tURL="); sb.append(HttpUtil.encodeURL(currentURL)); String ppid = ParamUtil.getString(request, "p_p_id"); if (ppid.equals(portletId)) { String namespace = PortalUtil.getPortletNamespace(portletId); Map<String, String[]> parameters = request.getParameterMap(); for (Map.Entry<String, String[]> entry : parameters.entrySet()) { String name = entry.getKey(); if (!PortalUtil.isReservedParameter(name) && !name.equals("currentURL") && !isRefreshURLReservedParameter(name, namespace)) { String[] values = entry.getValue(); for (int i = 0; i < values.length; i++) { sb.append(StringPool.AMPERSAND); sb.append(name); sb.append(StringPool.EQUAL); sb.append(HttpUtil.encodeURL(values[i])); } } } } String outerPortletId = PortalUtil.getOuterPortletId(request); if (outerPortletId != null) { sb.append(StringPool.AMPERSAND); sb.append("p_o_p_id"); sb.append(StringPool.EQUAL); sb.append(HttpUtil.encodeURL(outerPortletId)); } return sb.toString(); }
From source file:com.liferay.portlet.wiki.service.impl.WikiPageServiceImpl.java
License:Open Source License
protected String exportToRSS(long companyId, String name, String description, String type, double version, String displayStyle, String feedURL, String entryURL, List<WikiPage> pages, boolean diff, Locale locale) throws SystemException { SyndFeed syndFeed = new SyndFeedImpl(); syndFeed.setFeedType(RSSUtil.getFeedType(type, version)); syndFeed.setTitle(name);/*from w ww .ja va 2 s . c o m*/ syndFeed.setLink(feedURL); syndFeed.setDescription(description); List<SyndEntry> syndEntries = new ArrayList<SyndEntry>(); syndFeed.setEntries(syndEntries); WikiPage latestPage = null; StringBundler link = new StringBundler(7); for (WikiPage page : pages) { String author = HtmlUtil.escape(PortalUtil.getUserName(page.getUserId(), page.getUserName())); 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; } link.setIndex(0); link.append(entryURL); link.append(StringPool.AMPERSAND); link.append(HttpUtil.encodeURL(page.getTitle())); SyndEntry syndEntry = new SyndEntryImpl(); syndEntry.setAuthor(author); syndEntry.setTitle(title); syndEntry.setPublishedDate(page.getCreateDate()); syndEntry.setUpdatedDate(page.getModifiedDate()); SyndContent syndContent = new SyndContentImpl(); syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT); if (diff) { if (latestPage != null) { link.append(StringPool.QUESTION); link.append(PortalUtil.getPortletNamespace(PortletKeys.WIKI)); link.append("version="); link.append(page.getVersion()); String value = getPageDiff(companyId, latestPage, page, locale); syndContent.setValue(value); syndEntry.setDescription(syndContent); syndEntries.add(syndEntry); } } else { String value = null; if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_ABSTRACT)) { value = StringUtil.shorten(HtmlUtil.extractText(page.getContent()), PropsValues.WIKI_RSS_ABSTRACT_LENGTH, StringPool.BLANK); } else if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_TITLE)) { value = StringPool.BLANK; } else { value = page.getContent(); } syndContent.setValue(value); syndEntry.setDescription(syndContent); syndEntries.add(syndEntry); } syndEntry.setLink(link.toString()); syndEntry.setUri(syndEntry.getLink()); latestPage = page; } try { return RSSUtil.export(syndFeed); } catch (FeedException fe) { throw new SystemException(fe); } }
From source file:com.liferay.taglib.security.EncryptTag.java
License:Open Source License
@Override public int doStartTag() throws JspException { try {//from www . j a v a2s .c o m StringBundler sb = new StringBundler(); // Open anchor sb.append("<a "); // Class if (Validator.isNotNull(_className)) { sb.append("class=\""); sb.append(_className); sb.append("\" "); } // HREF sb.append("href=\""); sb.append(_protocol); sb.append(Http.PROTOCOL_DELIMITER); int pos = _url.indexOf(CharPool.QUESTION); if (pos == -1) { sb.append(_url); } else { sb.append(_url.substring(0, pos)); sb.append(StringPool.QUESTION); Company company = PortalUtil.getCompany((HttpServletRequest) pageContext.getRequest()); Key key = company.getKeyObj(); StringTokenizer st = new StringTokenizer(_url.substring(pos + 1, _url.length()), StringPool.AMPERSAND); while (st.hasMoreTokens()) { String paramAndValue = st.nextToken(); int x = paramAndValue.indexOf(CharPool.EQUAL); String param = paramAndValue.substring(0, x); String value = paramAndValue.substring(x + 1, paramAndValue.length()); sb.append(param).append(StringPool.EQUAL); if (_unencryptedParamsSet.contains(param)) { sb.append(HttpUtil.encodeURL(value)); } else { try { sb.append(HttpUtil.encodeURL(Encryptor.encrypt(key, value))); } catch (EncryptorException ee) { _log.error(ee.getMessage()); } if (st.hasMoreTokens()) { sb.append(StringPool.AMPERSAND); } } } sb.append("&shuo=1"); } sb.append("\" "); // Style if (Validator.isNotNull(_style)) { sb.append("style=\""); sb.append(_style); sb.append("\" "); } // Target if (Validator.isNotNull(_target)) { sb.append("target=\"" + _target + "\""); } // Close anchor sb.append(">"); JspWriter jspWriter = pageContext.getOut(); jspWriter.write(sb.toString()); return EVAL_BODY_INCLUDE; } catch (Exception e) { throw new JspException(e); } }
From source file:com.liferay.util.bridges.php.PHPServletRequest.java
License:Open Source License
public PHPServletRequest(HttpServletRequest request, ServletConfig servletConfig, RenderRequest renderRequest, RenderResponse renderResponse, PortletConfig portletConfig, String phpURI, boolean addPortletParams) { super(request); _servletConfig = servletConfig;/*from w ww. j a v a 2 s . c o m*/ _renderRequest = renderRequest; _renderResponse = renderResponse; _portletConfig = portletConfig; StringBundler sb = new StringBundler(); int pos = phpURI.indexOf(CharPool.QUESTION); if (pos != -1) { _path = phpURI.substring(0, pos); sb.append(phpURI.substring(pos + 1)); } else { _path = phpURI; } if (addPortletParams) { sb.append(StringPool.AMPERSAND); sb.append("portlet_namespace"); sb.append(StringPool.EQUAL); sb.append(_renderResponse.getNamespace()); sb.append(StringPool.AMPERSAND); sb.append("portlet_name"); sb.append(StringPool.EQUAL); sb.append(_portletConfig.getPortletName()); } _queryString = sb.toString(); request.setAttribute(JavaConstants.JAVAX_SERVLET_INCLUDE_QUERY_STRING, getQueryString()); request.setAttribute(JavaConstants.JAVAX_SERVLET_INCLUDE_PATH_INFO, getPathInfo()); request.setAttribute(JavaConstants.JAVAX_SERVLET_INCLUDE_REQUEST_URI, getRequestURI()); request.setAttribute(JavaConstants.JAVAX_SERVLET_INCLUDE_SERVLET_PATH, _path); }
From source file:com.liferay.wsrp.bind.MarkupServiceImpl.java
License:Open Source License
protected String getURL(String lifecycle, String resourceId, MimeRequest mimeRequest, PortletContext portletContext, WSRPProducer wsrpProducer) throws Exception { StringBuilder sb = new StringBuilder(); sb.append(getWidgetPath());/*from ww w . jav a 2 s. c om*/ sb.append(StringPool.QUESTION); String propertiesAuthenticatonTokenSharedSecret = Encryptor .digest(PropsUtil.get(PropsKeys.AUTH_TOKEN_SHARED_SECRET)); sb.append("p_auth_secret="); sb.append(HttpUtil.encodeURL(propertiesAuthenticatonTokenSharedSecret)); Layout layout = getLayout(portletContext, wsrpProducer); sb.append("&p_l_id="); sb.append(layout.getPlid()); NavigationalContext navigationalContext = mimeRequest.getNavigationalContext(); String portletId = getPortletId(portletContext, navigationalContext); sb.append("&p_p_id="); sb.append(HttpUtil.encodeURL(portletId)); sb.append("&p_p_lifecycle="); sb.append(lifecycle); String windowState = getWindowState(mimeRequest); sb.append("&p_p_state="); sb.append(HttpUtil.encodeURL(windowState)); String portletMode = getPortletMode(mimeRequest); sb.append("&p_p_mode="); sb.append(HttpUtil.encodeURL(portletMode)); if (lifecycle.equals("2") && Validator.isNotNull(resourceId)) { sb.append("&p_p_resource_id="); sb.append(resourceId); } sb.append("&p_p_isolated=1"); String opaqueValue = null; if (navigationalContext != null) { opaqueValue = navigationalContext.getOpaqueValue(); } if (Validator.isNotNull(opaqueValue)) { sb.append(StringPool.AMPERSAND); sb.append(opaqueValue); } if (lifecycle.equals("0")) { MessageElement[] formParameters = ExtensionUtil.getMessageElements(mimeRequest.getExtensions()); if (formParameters != null) { String namespace = PortalUtil.getPortletNamespace(portletId); for (MessageElement formParameter : formParameters) { sb.append(StringPool.AMPERSAND); sb.append(namespace + formParameter.getName()); sb.append(StringPool.EQUAL); sb.append(HttpUtil.encodeURL(formParameter.getValue())); } } } if (windowState.equals(LiferayWindowState.EXCLUSIVE.toString())) { sb.append("&ensureContentLength=1"); } sb.append("&wsrp=1"); if (_log.isInfoEnabled()) { _log.info("URL " + sb.toString()); } return sb.toString(); }
From source file:com.liferay.wsrp.bind.V2MarkupServiceImpl.java
License:Open Source License
protected String getURL(String lifecycle, String resourceID, MimeRequest mimeRequest, PortletContext portletContext, WSRPProducer wsrpProducer) throws Exception { StringBundler sb = new StringBundler(); String[] locales = mimeRequest.getLocales(); if (locales.length > 0) { sb.append(getWidgetPath(locales[0])); } else {/*from w w w. j a v a 2 s . c om*/ sb.append(getWidgetPath()); } sb.append(StringPool.QUESTION); String propertiesAuthenticatonTokenSharedSecret = Encryptor .digest(PropsUtil.get(PropsKeys.AUTH_TOKEN_SHARED_SECRET)); sb.append("p_auth_secret="); sb.append(HttpUtil.encodeURL(propertiesAuthenticatonTokenSharedSecret)); Layout layout = getLayout(portletContext, wsrpProducer); sb.append("&p_l_id="); sb.append(layout.getPlid()); NavigationalContext navigationalContext = mimeRequest.getNavigationalContext(); String portletId = getPortletId(portletContext, navigationalContext); sb.append("&p_p_id="); sb.append(HttpUtil.encodeURL(portletId)); sb.append("&p_p_lifecycle="); sb.append(lifecycle); String windowState = getWindowState(mimeRequest); sb.append("&p_p_state="); sb.append(HttpUtil.encodeURL(windowState)); String portletMode = getPortletMode(mimeRequest); sb.append("&p_p_mode="); sb.append(HttpUtil.encodeURL(portletMode)); if (lifecycle.equals("2") && Validator.isNotNull(resourceID)) { sb.append("&p_p_resource_id="); sb.append(resourceID); } sb.append("&p_p_isolated=1"); String opaqueValue = null; if (navigationalContext != null) { opaqueValue = navigationalContext.getOpaqueValue(); } if (Validator.isNotNull(opaqueValue)) { sb.append(StringPool.AMPERSAND); opaqueValue = new String(Base64.decode(Base64.fromURLSafe(opaqueValue)), StringPool.UTF8); sb.append(opaqueValue); } if (lifecycle.equals("0")) { MessageElement[] formParameters = ExtensionHelperUtil.getMessageElements(mimeRequest.getExtensions()); if (formParameters != null) { String namespace = PortalUtil.getPortletNamespace(portletId); for (MessageElement formParameter : formParameters) { sb.append(StringPool.AMPERSAND); String name = namespace.concat(ExtensionHelperUtil.getNameAttribute(formParameter)); sb.append(name); sb.append(StringPool.EQUAL); sb.append(HttpUtil.encodeURL(formParameter.getValue())); } } } if (windowState.equals(LiferayWindowState.EXCLUSIVE.toString())) { sb.append("&ensureContentLength=1"); } sb.append("&wsrp=1"); if (_log.isInfoEnabled()) { _log.info("URL " + sb.toString()); } return sb.toString(); }