List of usage examples for com.liferay.portal.kernel.util StringPool QUESTION
String QUESTION
To view the source code for com.liferay.portal.kernel.util StringPool QUESTION.
Click Source Link
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);// w w w .j ava2 s . c o 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
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. j av a 2 s .com*/ } 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.journal.util.JournalConverterImpl.java
License:Open Source License
protected Serializable getDocumentLibraryValue(String url) { try {/* ww w . j a v a 2 s.co m*/ _log.info("url in new getDocumentLibraryValue &&&&&& " + url); String initialUrl = url; FileEntry fileEntry = null; JSONObject jsonObject = null; if (Validator.isNotNull(url)) { int x = url.indexOf("/documents/"); if (x == -1) { return null; } int y = url.indexOf(StringPool.QUESTION); if (y == -1) { y = url.length(); } url = url.substring(x, y); String[] parts = StringUtil.split(url, CharPool.SLASH); String groupIdOrName = parts[2]; _log.info("groupIdOrName is " + groupIdOrName); _log.info("Boolean is " + groupIdOrName.contains(STOXXNET)); if (!(groupIdOrName.contains(STOXXNET))) { long groupId = GetterUtil.getLong(parts[2]); _log.info("Normal flow"); if (StringUtils.isNumeric(String.valueOf(groupId)) && 0 != groupId) { fileEntry = DLAppLocalServiceUtil.getFileEntry(groupId, Long.valueOf(parts[3]), parts[4]); } if (Validator.isNotNull(fileEntry)) { jsonObject = JSONFactoryUtil.createJSONObject(); jsonObject.put("groupId", fileEntry.getGroupId()); jsonObject.put("uuid", fileEntry.getUuid()); jsonObject.put("version", fileEntry.getVersion()); jsonObject.put("fileUrl", initialUrl); } } else { _log.info("Customized flow"); long groupId = GroupLocalServiceUtil.fetchGroup(PortalUtil.getDefaultCompanyId(), groupIdOrName) .getGroupId(); _log.info("groupId is " + groupId); jsonObject = createJsonArray(initialUrl, groupId); } _log.info("jsonObject.toString() url is " + jsonObject.toString()); return jsonObject.toString(); } } catch (Exception e) { _log.info(e.getMessage()); if (_log.isWarnEnabled()) { _log.warn("Error retrieving file entry", e); } } return StringPool.BLANK; }
From source file:com.liferay.portlet.language.action.ViewAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest); HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse); HttpSession session = request.getSession(); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); String languageId = ParamUtil.getString(actionRequest, "languageId"); Locale locale = LocaleUtil.fromLanguageId(languageId); List<Locale> availableLocales = ListUtil.fromArray(LanguageUtil.getAvailableLocales()); if (availableLocales.contains(locale)) { if (themeDisplay.isSignedIn()) { User user = themeDisplay.getUser(); Contact contact = user.getContact(); AdminUtil.updateUser(actionRequest, user.getUserId(), user.getScreenName(), user.getEmailAddress(), user.getFacebookId(), user.getOpenId(), languageId, user.getTimeZoneId(), user.getGreeting(), user.getComments(), contact.getSmsSn(), contact.getAimSn(), contact.getFacebookSn(), contact.getIcqSn(), contact.getJabberSn(), contact.getMsnSn(), contact.getMySpaceSn(), contact.getSkypeSn(), contact.getTwitterSn(), contact.getYmSn()); }//from w w w. ja v a2s . c o m session.setAttribute(Globals.LOCALE_KEY, locale); LanguageUtil.updateCookie(request, response, locale); } // Send redirect String redirect = ParamUtil.getString(actionRequest, "redirect"); if (PropsValues.LOCALE_PREPEND_FRIENDLY_URL_STYLE == 0) { redirect = PortalUtil.getLayoutURL(layout, themeDisplay); if (themeDisplay.isI18n()) { redirect = layout.getFriendlyURL(); } } else { String layoutURL = PortalUtil.getLayoutFriendlyURL(layout, themeDisplay, locale); int pos = redirect.indexOf(Portal.FRIENDLY_URL_SEPARATOR); if (pos == -1) { pos = redirect.indexOf(StringPool.QUESTION); } if (pos != -1) { redirect = layoutURL + redirect.substring(pos); } else { redirect = layoutURL; } } actionResponse.sendRedirect(redirect); }
From source file:com.liferay.portlet.PortletBagFactory.java
License:Open Source License
protected String getContent(String fileName) throws Exception { String queryString = HttpUtil.getQueryString(fileName); if (Validator.isNull(queryString)) { return StringUtil.read(_classLoader, fileName); }/*from ww w.ja v a2 s . c om*/ int pos = fileName.indexOf(StringPool.QUESTION); String xml = StringUtil.read(_classLoader, fileName.substring(0, pos)); Map<String, String[]> parameterMap = HttpUtil.getParameterMap(queryString); if (parameterMap == null) { return xml; } for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) { String name = entry.getKey(); String[] values = entry.getValue(); if (values.length == 0) { continue; } String value = values[0]; xml = StringUtil.replace(xml, "@" + name + "@", value); } return xml; }
From source file:com.liferay.portlet.PortletSessionImpl.java
License:Open Source License
public static final String getPortletScopeName(String portletName, long plid, String name) { return getPortletScope(portletName, plid).concat(StringPool.QUESTION).concat(name); }
From source file:com.liferay.portlet.search.action.OpenSearchAction.java
License:Open Source License
protected byte[] getXML(HttpServletRequest request) throws Exception { OpenSearch search = new PortalOpenSearchImpl(); String xml = search.search(request, request.getRequestURL().toString() + StringPool.QUESTION + request.getQueryString()); return xml.getBytes(); }
From source file:com.liferay.portlet.wiki.engines.jspwiki.LiferayURLConstructor.java
License:Open Source License
public String makeURL(String context, String name, boolean absolute, String parameters) { if (Validator.isNotNull(parameters)) { if (context.equals(WikiContext.ATTACH)) { parameters = StringPool.QUESTION + parameters; } else if (context.equals(WikiContext.NONE)) { if (name.indexOf(CharPool.QUESTION) != -1) { parameters = "&" + parameters; } else { parameters = StringPool.QUESTION + parameters; }//w ww . jav a2 s. c o m } else { parameters = "&" + parameters; } } else { parameters = StringPool.BLANK; } String path; if (context.equals(WikiContext.EDIT)) { path = "[$BEGIN_PAGE_TITLE_EDIT$]" + JSPWikiEngine.decodeJSPWikiName(name) + "[$END_PAGE_TITLE_EDIT$]"; } else if (context.equals(WikiContext.VIEW)) { path = "[$BEGIN_PAGE_TITLE$]" + JSPWikiEngine.decodeJSPWikiName(name) + "[$END_PAGE_TITLE$]"; } else if (context.equals(WikiContext.ATTACH)) { if (name.indexOf(CharPool.SLASH) == -1) { path = "[$ATTACHMENT_URL_PREFIX$][$WIKI_PAGE_NAME$]/" + HttpUtil.encodeURL(JSPWikiEngine.decodeJSPWikiName(name)); } else { path = "[$ATTACHMENT_URL_PREFIX$]" + HttpUtil.encodeURL(JSPWikiEngine.decodeJSPWikiName(name)); } } else { path = JSPWikiEngine.decodeJSPWikiName(name); } return path + parameters; }
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);// w w w. j a va2s .co 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.rtl.servlet.filters.ComboServletFilter.java
License:Open Source License
protected byte[] getResourceContent(HttpServletRequest request, HttpServletResponse response, URL resourceURL, String resourcePath, String minifierType) throws IOException { String fileContentKey = resourcePath.concat(StringPool.QUESTION).concat(minifierType); FileContentBag fileContentBag = _fileContentBagPortalCache.get(fileContentKey); if ((fileContentBag != null) && !PropsValues.COMBO_CHECK_TIMESTAMP) { return fileContentBag._fileContent; }/* w ww . java2 s. c o m*/ URLConnection urlConnection = null; if (resourceURL != null) { urlConnection = resourceURL.openConnection(); } if ((fileContentBag != null) && PropsValues.COMBO_CHECK_TIMESTAMP) { long elapsedTime = System.currentTimeMillis() - fileContentBag._lastModified; if ((urlConnection != null) && (elapsedTime <= PropsValues.COMBO_CHECK_TIMESTAMP_INTERVAL) && (urlConnection.getLastModified() == fileContentBag._lastModified)) { return fileContentBag._fileContent; } _fileContentBagPortalCache.remove(fileContentKey); } if (resourceURL == null) { fileContentBag = _EMPTY_FILE_CONTENT_BAG; } else { String stringFileContent = StringUtil.read(urlConnection.getInputStream()); if (!StringUtil.endsWith(resourcePath, _CSS_MINIFIED_SUFFIX) && !StringUtil.endsWith(resourcePath, _JAVASCRIPT_MINIFIED_SUFFIX)) { if (minifierType.equals("css")) { try { stringFileContent = DynamicCSSUtil.parseSass(_servletContext, request, resourcePath, stringFileContent); } catch (Exception e) { _log.error("Unable to parse SASS on CSS " + resourceURL.getPath(), e); if (_log.isDebugEnabled()) { _log.debug(stringFileContent); } response.setHeader(HttpHeaders.CACHE_CONTROL, HttpHeaders.CACHE_CONTROL_NO_CACHE_VALUE); } String baseURL = StringPool.BLANK; int index = resourcePath.lastIndexOf(CharPool.SLASH); if (index != -1) { baseURL = resourcePath.substring(0, index + 1); } stringFileContent = AggregateUtil.updateRelativeURLs(stringFileContent, baseURL); stringFileContent = MinifierUtil.minifyCss(stringFileContent); } else if (minifierType.equals("js")) { stringFileContent = MinifierUtil.minifyJavaScript(stringFileContent); } } fileContentBag = new FileContentBag(stringFileContent.getBytes(StringPool.UTF8), urlConnection.getLastModified()); } if (PropsValues.COMBO_CHECK_TIMESTAMP) { int timeToLive = (int) (PropsValues.COMBO_CHECK_TIMESTAMP_INTERVAL / Time.SECOND); _fileContentBagPortalCache.put(fileContentKey, fileContentBag, timeToLive); } return fileContentBag._fileContent; }