List of usage examples for com.liferay.portal.kernel.util StringPool UTF8
String UTF8
To view the source code for com.liferay.portal.kernel.util StringPool UTF8.
Click Source Link
From source file:com.liferay.mail.util.PasswordUtil.java
License:Open Source License
public static String encrypt(String unencryptedPassword) { String encryptedPassword = null; try {/*from w w w.jav a 2 s . c om*/ byte[] bytes = unencryptedPassword.getBytes(StringPool.UTF8); encryptedPassword = Base64.encode(bytes); } catch (UnsupportedEncodingException uee) { _log.error("Unable to encrypt the password", uee); } return encryptedPassword; }
From source file:com.liferay.meeting.webex.transport.HttpPostTransport.java
License:Open Source License
public String send(String hostURL, String requestXml) throws MeetingException { String responseXml = null;//from w w w .ja v a 2 s .c o m try { Http.Options options = new Http.Options(); options.setBody(requestXml, ContentTypes.TEXT_XML, StringPool.UTF8); options.setLocation(hostURL); options.setPost(true); responseXml = HttpUtil.URLtoString(options); } catch (Exception e) { throw new MeetingException(e.getMessage(), e); } if (Validator.isNull(responseXml)) { throw new MeetingException("No response from server"); } try { MessageDocument messageDocument = MessageDocument.Factory.parse(responseXml); MessageType messageType = messageDocument.getMessage(); MessageType.Header header = messageType.getHeader(); ResponseType responseType = header.getResponseArray(0); if (responseType.getResult() == Enum.forString("SUCCESS")) { return responseXml; } throw new MeetingException(responseType.getReason()); } catch (XmlException xe) { throw new MeetingException(xe); } }
From source file:com.liferay.message.boards.web.internal.portlet.action.RSSAction.java
License:Open Source License
@Override protected byte[] getRSS(HttpServletRequest request) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); long plid = ParamUtil.getLong(request, "p_l_id"); if (plid == LayoutConstants.DEFAULT_PLID) { plid = themeDisplay.getPlid();// w w w. j a v a2 s . c om } long companyId = ParamUtil.getLong(request, "companyId"); long groupId = ParamUtil.getLong(request, "groupId"); long userId = ParamUtil.getLong(request, "userId"); long categoryId = ParamUtil.getLong(request, "mbCategoryId"); long threadId = ParamUtil.getLong(request, "threadId"); int max = ParamUtil.getInteger(request, "max", SearchContainer.DEFAULT_DELTA); String type = ParamUtil.getString(request, "type", RSSUtil.FORMAT_DEFAULT); double version = ParamUtil.getDouble(request, "version", RSSUtil.VERSION_DEFAULT); String displayStyle = ParamUtil.getString(request, "displayStyle", RSSUtil.DISPLAY_STYLE_DEFAULT); String entryURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain() + "/message_boards/find_message?p_l_id=" + plid; String rss = StringPool.BLANK; if (companyId > 0) { String feedURL = StringPool.BLANK; rss = _mbMessageService.getCompanyMessagesRSS(companyId, WorkflowConstants.STATUS_APPROVED, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } else if (groupId > 0) { String mvcRenderCommandName = ParamUtil.getString(request, "mvcRenderCommandName"); String feedURL = null; if (mvcRenderCommandName.equals("/message_boards/view_recent_posts")) { feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain() + "/message_boards/find_recent_posts?p_l_id=" + plid; } else { feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain() + "/message_boards/find_category?p_l_id=" + plid + "&mbCategoryId=" + categoryId; } if (userId > 0) { rss = _mbMessageService.getGroupMessagesRSS(groupId, userId, WorkflowConstants.STATUS_APPROVED, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } else { rss = _mbMessageService.getGroupMessagesRSS(groupId, WorkflowConstants.STATUS_APPROVED, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } } else if (categoryId > 0) { String feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain() + "/message_boards/find_category?p_l_id=" + plid + "&mbCategoryId=" + categoryId; rss = _mbMessageService.getCategoryMessagesRSS(groupId, categoryId, WorkflowConstants.STATUS_APPROVED, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } else if (threadId > 0) { String feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain() + "/message_boards/find_thread?p_l_id=" + plid + "&threadId=" + threadId; rss = _mbMessageService.getThreadMessagesRSS(threadId, WorkflowConstants.STATUS_APPROVED, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } return rss.getBytes(StringPool.UTF8); }
From source file:com.liferay.opensocial.editor.portlet.EditorPortlet.java
License:Open Source License
protected void serveAddFileEntry(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); long folderId = ParamUtil.getLong(resourceRequest, "folderId"); Folder folder = DLAppServiceUtil.getFolder(folderId); String fileEntryTitle = ParamUtil.getString(resourceRequest, "fileEntryTitle"); String content = ParamUtil.getString(resourceRequest, "content"); byte[] bytes = content.getBytes(StringPool.UTF8); ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequest); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); serviceContext.setAttribute("sourceFileName", fileEntryTitle); serviceContext.setScopeGroupId(folder.getGroupId()); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); FileEntry fileEntry = DLAppServiceUtil.addFileEntry(folder.getRepositoryId(), folderId, fileEntryTitle, resourceRequest.getContentType(), fileEntryTitle, StringPool.BLANK, StringPool.BLANK, bytes, serviceContext);/* w w w .j a va 2s .co m*/ jsonObject.put("fileEntryId", fileEntry.getFileEntryId()); String portalURL = PortalUtil.getPortalURL(themeDisplay); String fileEntryURL = ShindigUtil.getFileEntryURL(portalURL, fileEntry.getFileEntryId()); jsonObject.put("fileEntryURL", fileEntryURL); writeJSON(resourceRequest, resourceResponse, jsonObject); }
From source file:com.liferay.opensocial.editor.portlet.EditorPortlet.java
License:Open Source License
protected void serveUpdateFileEntryContent(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { long fileEntryId = ParamUtil.getLong(resourceRequest, "fileEntryId"); FileEntry fileEntry = DLAppServiceUtil.getFileEntry(fileEntryId); String content = ParamUtil.getString(resourceRequest, "content"); byte[] bytes = content.getBytes(StringPool.UTF8); ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequest); DLAppServiceUtil.updateFileEntry(fileEntryId, fileEntry.getTitle(), resourceRequest.getContentType(), fileEntry.getTitle(), fileEntry.getDescription(), StringPool.BLANK, false, bytes, serviceContext); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); writeJSON(resourceRequest, resourceResponse, jsonObject); }
From source file:com.liferay.portlet.activities.action.RSSAction.java
License:Open Source License
protected byte[] getRSS(PortletRequest portletRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); SyndFeed syndFeed = new SyndFeedImpl(); String feedTitle = ParamUtil.getString(portletRequest, "feedTitle"); syndFeed.setDescription(feedTitle);//w w w .ja v a2 s .co m syndFeed.setFeedType(RSSUtil.FEED_TYPE_DEFAULT); String feedLink = PortalUtil.getLayoutFullURL(themeDisplay) + Portal.FRIENDLY_URL_SEPARATOR + "activities/rss"; syndFeed.setLink(feedLink); syndFeed.setTitle(feedTitle); List<SyndEntry> syndEntries = new ArrayList<SyndEntry>(); syndFeed.setEntries(syndEntries); List<SocialActivity> activities = getActivities(portletRequest); for (SocialActivity activity : activities) { SocialActivityFeedEntry activityFeedEntry = SocialActivityInterpreterLocalServiceUtil .interpret(activity, themeDisplay); if (activityFeedEntry == null) { continue; } SyndEntry syndEntry = new SyndEntryImpl(); SyndContent syndContent = new SyndContentImpl(); syndContent.setType(RSSUtil.FEED_TYPE_DEFAULT); syndContent.setValue(activityFeedEntry.getBody()); syndEntry.setDescription(syndContent); if (Validator.isNotNull(activityFeedEntry.getLink())) { syndEntry.setLink(activityFeedEntry.getLink()); } syndEntry.setPublishedDate(new Date(activity.getCreateDate())); syndEntry.setTitle(HtmlUtil.extractText(activityFeedEntry.getTitle())); syndEntries.add(syndEntry); } String rss = StringPool.BLANK; try { rss = RSSUtil.export(syndFeed); } catch (FeedException fe) { throw new SystemException(fe); } return rss.getBytes(StringPool.UTF8); }
From source file:com.liferay.portlet.assetpublisher.action.RSSAction.java
License:Open Source License
protected byte[] getRSS(PortletRequest portletRequest, PortletResponse portletResponse) throws Exception { PortletPreferences preferences = portletRequest.getPreferences(); String selectionStyle = preferences.getValue("selectionStyle", "dynamic"); if (!selectionStyle.equals("dynamic")) { return new byte[0]; }// www . j av a2 s. c om ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); long[] groupIds = AssetPublisherUtil.getGroupIds(preferences, themeDisplay.getScopeGroupId(), themeDisplay.getLayout()); boolean anyAssetType = GetterUtil.getBoolean(preferences.getValue("anyAssetType", Boolean.TRUE.toString())); String assetLinkBehavior = preferences.getValue("assetLinkBehavior", "showFullContent"); boolean excludeZeroViewCount = GetterUtil.getBoolean(preferences.getValue("excludeZeroViewCount", "0")); int rssDelta = GetterUtil.getInteger(preferences.getValue("rssDelta", "20")); String rssDisplayStyle = preferences.getValue("rssDisplayStyle", RSSUtil.DISPLAY_STYLE_ABSTRACT); String rssFormat = preferences.getValue("rssFormat", "atom10"); String rssName = preferences.getValue("rssName", null); String rssFormatType = RSSUtil.getFormatType(rssFormat); double rssFormatVersion = RSSUtil.getFormatVersion(rssFormat); AssetEntryQuery assetEntryQuery = AssetPublisherUtil.getAssetEntryQuery(preferences, new long[] { themeDisplay.getScopeGroupId() }); if (!anyAssetType) { long[] availableClassNameIds = AssetRendererFactoryRegistryUtil.getClassNameIds(); long[] classNameIds = AssetPublisherUtil.getClassNameIds(preferences, availableClassNameIds); assetEntryQuery.setClassNameIds(classNameIds); } assetEntryQuery.setEnd(rssDelta); assetEntryQuery.setExcludeZeroViewCount(excludeZeroViewCount); assetEntryQuery.setGroupIds(groupIds); assetEntryQuery.setStart(0); List<AssetEntry> assetEntries = AssetEntryServiceUtil.getEntries(assetEntryQuery); String rss = exportToRSS(portletRequest, portletResponse, rssName, null, rssFormatType, rssFormatVersion, rssDisplayStyle, assetLinkBehavior, assetEntries); return rss.getBytes(StringPool.UTF8); }
From source file:com.liferay.portlet.assetpublisher.util.AssetPublisherUtil.java
License:Open Source License
private static String _getAssetEntryXml(String assetEntryType, String assetEntryUuid) { String xml = null;/*w ww .ja v a 2s. c o m*/ try { Document document = SAXReaderUtil.createDocument(StringPool.UTF8); Element assetEntryElement = document.addElement("asset-entry"); Element assetEntryTypeElement = assetEntryElement.addElement("asset-entry-type"); assetEntryTypeElement.addText(assetEntryType); Element assetEntryUuidElement = assetEntryElement.addElement("asset-entry-uuid"); assetEntryUuidElement.addText(assetEntryUuid); xml = document.formattedString(StringPool.BLANK); } catch (IOException ioe) { if (_log.isWarnEnabled()) { _log.warn(ioe); } } return xml; }
From source file:com.liferay.portlet.blogs.action.RSSAction.java
License:Open Source License
protected byte[] getRSS(HttpServletRequest request) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); long plid = ParamUtil.getLong(request, "p_l_id"); long companyId = ParamUtil.getLong(request, "companyId"); long groupId = ParamUtil.getLong(request, "groupId"); long organizationId = ParamUtil.getLong(request, "organizationId"); int status = WorkflowConstants.STATUS_APPROVED; int max = ParamUtil.getInteger(request, "max", SearchContainer.DEFAULT_DELTA); String type = ParamUtil.getString(request, "type", RSSUtil.TYPE_DEFAULT); double version = ParamUtil.getDouble(request, "version", RSSUtil.VERSION_DEFAULT); String displayStyle = ParamUtil.getString(request, "displayStyle", RSSUtil.DISPLAY_STYLE_FULL_CONTENT); String feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain() + "/blogs/find_entry?"; String entryURL = feedURL;// w w w . ja v a2 s.c o m String rss = StringPool.BLANK; if (companyId > 0) { feedURL = StringPool.BLANK; rss = BlogsEntryServiceUtil.getCompanyEntriesRSS(companyId, new Date(), status, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } else if (groupId > 0) { feedURL += "p_l_id=" + plid; entryURL = feedURL; rss = BlogsEntryServiceUtil.getGroupEntriesRSS(groupId, new Date(), status, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } else if (organizationId > 0) { feedURL = StringPool.BLANK; rss = BlogsEntryServiceUtil.getOrganizationEntriesRSS(organizationId, new Date(), status, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } else if (layout != null) { groupId = themeDisplay.getScopeGroupId(); feedURL = PortalUtil.getLayoutFullURL(themeDisplay) + Portal.FRIENDLY_URL_SEPARATOR + "blogs/rss"; entryURL = feedURL; rss = BlogsEntryServiceUtil.getGroupEntriesRSS(groupId, new Date(), status, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } return rss.getBytes(StringPool.UTF8); }
From source file:com.liferay.portlet.documentlibrary.action.CompareVersionsAction.java
License:Open Source License
protected void compareVersions(RenderRequest renderRequest) throws Exception { long fileEntryId = ParamUtil.getLong(renderRequest, "fileEntryId"); String sourceVersion = ParamUtil.getString(renderRequest, "sourceVersion"); String targetVersion = ParamUtil.getString(renderRequest, "targetVersion"); FileEntry fileEntry = DLAppServiceUtil.getFileEntry(fileEntryId); String extension = fileEntry.getExtension(); FileVersion sourceFileVersion = fileEntry.getFileVersion(sourceVersion); String sourceTitle = sourceFileVersion.getTitle(); FileVersion targetFileVersion = fileEntry.getFileVersion(targetVersion); String targetTitle = targetFileVersion.getTitle(); InputStream sourceIs = fileEntry.getContentStream(sourceVersion); InputStream targetIs = fileEntry.getContentStream(targetVersion); if (extension.equals("htm") || extension.equals("html") || extension.equals("xml")) { String escapedSource = HtmlUtil.escape(StringUtil.read(sourceIs)); String escapedTarget = HtmlUtil.escape(StringUtil.read(targetIs)); sourceIs = new UnsyncByteArrayInputStream(escapedSource.getBytes(StringPool.UTF8)); targetIs = new UnsyncByteArrayInputStream(escapedTarget.getBytes(StringPool.UTF8)); }/* ww w. j a v a 2 s.com*/ if (DocumentConversionUtil.isEnabled() && DocumentConversionUtil.isConvertBeforeCompare(extension)) { String sourceTempFileId = DLUtil.getTempFileId(fileEntryId, sourceVersion); String targetTempFileId = DLUtil.getTempFileId(fileEntryId, targetVersion); sourceIs = new FileInputStream( DocumentConversionUtil.convert(sourceTempFileId, sourceIs, extension, "txt")); targetIs = new FileInputStream( DocumentConversionUtil.convert(targetTempFileId, targetIs, extension, "txt")); } List<DiffResult>[] diffResults = DiffUtil.diff(new InputStreamReader(sourceIs), new InputStreamReader(targetIs)); renderRequest.setAttribute(WebKeys.SOURCE_NAME, sourceTitle + StringPool.SPACE + sourceVersion); renderRequest.setAttribute(WebKeys.TARGET_NAME, targetTitle + StringPool.SPACE + targetVersion); renderRequest.setAttribute(WebKeys.DIFF_RESULTS, diffResults); }