List of usage examples for com.liferay.portal.kernel.util PortalUtil getScopeGroupId
public static long getScopeGroupId(PortletRequest portletRequest) throws PortalException
From source file:ca.efendi.datafeeds.web.internal.portlet.DatafeedsPortlet.java
License:Apache License
protected void deleteMessage(final ActionRequest actionRequest) throws Exception { final long groupId = PortalUtil.getScopeGroupId(actionRequest); final String className = ParamUtil.getString(actionRequest, "className"); final long classPK = ParamUtil.getLong(actionRequest, "classPK"); final String permissionClassName = ParamUtil.getString(actionRequest, "permissionClassName"); final long permissionClassPK = ParamUtil.getLong(actionRequest, "permissionClassPK"); final long permissionOwnerId = ParamUtil.getLong(actionRequest, "permissionOwnerId"); final long messageId = ParamUtil.getLong(actionRequest, "messageId"); MBMessageServiceUtil.deleteDiscussionMessage(groupId, className, classPK, permissionClassName, permissionClassPK, permissionOwnerId, messageId); }
From source file:com.liferay.blogs.internal.util.PingbackMethodImpl.java
License:Open Source License
protected BlogsEntry getBlogsEntry(long companyId) throws Exception { BlogsEntry entry = null;//from w ww.ja v a 2 s. c o m URL url = new URL(_targetURI); String friendlyURL = url.getPath(); int end = friendlyURL.indexOf(Portal.FRIENDLY_URL_SEPARATOR); if (end != -1) { friendlyURL = friendlyURL.substring(0, end); } long plid = PortalUtil.getPlidFromFriendlyURL(companyId, friendlyURL); long groupId = PortalUtil.getScopeGroupId(plid); Map<String, String[]> params = new HashMap<>(); FriendlyURLMapperThreadLocal.setPRPIdentifiers(new HashMap<String, String>()); String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(), PortletProvider.Action.VIEW); Portlet portlet = _portletLocalService.getPortletById(portletId); FriendlyURLMapper friendlyURLMapper = portlet.getFriendlyURLMapperInstance(); friendlyURL = url.getPath(); end = friendlyURL.indexOf(Portal.FRIENDLY_URL_SEPARATOR); if (end != -1) { friendlyURL = friendlyURL.substring(end + Portal.FRIENDLY_URL_SEPARATOR.length() - 1); } Map<String, Object> requestContext = new HashMap<>(); friendlyURLMapper.populateParams(friendlyURL, params, requestContext); String param = getParam(params, "entryId"); if (Validator.isNotNull(param)) { long entryId = GetterUtil.getLong(param); entry = _blogsEntryLocalService.getEntry(entryId); } else { String urlTitle = getParam(params, "urlTitle"); entry = _blogsEntryLocalService.getEntry(groupId, urlTitle); } return entry; }
From source file:org.lsug.quota.web.internal.portlet.SiteConfigurationQuotaWebPortlet.java
License:Open Source License
@Override public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { Quota quota = null;/*from w ww . j ava2 s . c o m*/ try { long groupId = PortalUtil.getScopeGroupId(renderRequest); Group group = _groupLocalService.getGroup(groupId); if (QuotaUtil.isValidGroupQuota(group)) { long classNameId = group.getClassNameId(); if (group.isStagingGroup()) { groupId = group.getLiveGroupId(); } if (classNameId > 0) { quota = _quotaLocalService.getQuotaByClassNameIdClassPK(classNameId, groupId); } } } catch (Exception e) { LOGGER.error(e); throw new PortletException(e); } renderRequest.setAttribute("quota", quota); super.doView(renderRequest, renderResponse); }
From source file:org.lsug.quota.web.internal.portlet.SiteConfigurationQuotaWebPortlet.java
License:Open Source License
@Override public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, PortletException { StringBundler sb = new StringBundler(5); JFreeChart jFreeChart = null;/*from w w w . j ava 2s .c om*/ DefaultPieDataset pieDataset = new DefaultPieDataset(); try { long groupId = PortalUtil.getScopeGroupId(resourceRequest); Group group = _groupLocalService.getGroup(groupId); long classNameId = 0; if (QuotaUtil.isValidGroupQuota(group)) { classNameId = group.getClassNameId(); if (group.isStagingGroup()) { groupId = group.getLiveGroupId(); } } Quota siteQuota = _quotaLocalService.getQuotaByClassNameIdClassPK(classNameId, groupId); ResourceBundle resourceBundle = ResourceBundleUtil.getBundle("content.Language", resourceRequest.getLocale(), getClass()); if (siteQuota.isEnabled()) { pieDataset.setValue(LanguageUtil.get(resourceBundle, "used-space"), siteQuota.getQuotaUsedPercentage()); pieDataset.setValue(LanguageUtil.get(resourceBundle, "unused-space"), 100 - siteQuota.getQuotaUsedPercentage()); } sb.append(LanguageUtil.get(resourceBundle, "sites-quota-enabled-sites-used-diagram-title")); jFreeChart = getCurrentSizeJFreeChart(sb.toString(), pieDataset); resourceResponse.setContentType(ContentTypes.IMAGE_PNG); OutputStream outputStream = null; try { outputStream = resourceResponse.getPortletOutputStream(); ChartUtilities.writeChartAsPNG(outputStream, jFreeChart, 400, 200); } finally { if (outputStream != null) { outputStream.close(); } } } catch (Exception e) { LOGGER.error(e); throw new PortletException(e); } }