List of usage examples for com.liferay.portal.kernel.model Group getDescriptiveName
@com.liferay.portal.kernel.json.JSON
public String getDescriptiveName() throws com.liferay.portal.kernel.exception.PortalException;
From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
protected void pingGoogle(BlogsEntry entry, ServiceContext serviceContext) throws PortalException { if (!PropsValues.BLOGS_PING_GOOGLE_ENABLED || !entry.isApproved()) { return;/* ww w . ja v a 2s. c om*/ } String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(), PortletProvider.Action.MANAGE); if (Validator.isNull(portletId)) { if (_log.isDebugEnabled()) { _log.debug("Not pinging Google because there is no blogs portlet " + "provider"); } return; } String layoutFullURL = PortalUtil.getLayoutFullURL(serviceContext.getScopeGroupId(), portletId); if (Validator.isNull(layoutFullURL)) { return; } if (layoutFullURL.contains("://localhost")) { if (_log.isDebugEnabled()) { _log.debug("Not pinging Google because of localhost URL " + layoutFullURL); } return; } Group group = groupPersistence.findByPrimaryKey(entry.getGroupId()); StringBundler sb = new StringBundler(6); String name = group.getDescriptiveName(); String url = layoutFullURL + Portal.FRIENDLY_URL_SEPARATOR + "blogs"; String changesURL = serviceContext.getPathMain() + "/blogs/rss"; sb.append("http://blogsearch.google.com/ping?name="); sb.append(HttpUtil.encodeURL(name)); sb.append("&url="); sb.append(HttpUtil.encodeURL(url)); sb.append("&changesURL="); sb.append(HttpUtil.encodeURL(changesURL)); String location = sb.toString(); if (_log.isInfoEnabled()) { _log.info("Pinging Google at " + location); } try { String response = HttpUtil.URLtoString(sb.toString()); if (_log.isInfoEnabled()) { _log.info("Google ping response: " + response); } } catch (IOException ioe) { _log.error("Unable to ping Google at " + location, ioe); } }
From source file:com.liferay.blogs.service.impl.BlogsEntryServiceImpl.java
License:Open Source License
@Override public String getGroupEntriesRSS(long groupId, Date displayDate, int status, int max, String type, double version, String displayStyle, String feedURL, String entryURL, ThemeDisplay themeDisplay) throws PortalException { Group group = groupPersistence.findByPrimaryKey(groupId); String name = group.getDescriptiveName(); List<BlogsEntry> blogsEntries = getGroupEntries(groupId, displayDate, status, max); return exportToRSS(name, name, type, version, displayStyle, feedURL, entryURL, blogsEntries, themeDisplay); }
From source file:com.liferay.calendar.internal.exportimport.data.handler.CalendarResourceStagedModelDataHandler.java
License:Open Source License
protected Map<Locale, String> getCalendarResourceNameMap(PortletDataContext portletDataContext, CalendarResource calendarResource) throws Exception { Group sourceGroup = _groupLocalService.fetchGroup(portletDataContext.getSourceGroupId()); String calendarResourceName = calendarResource.getName(LocaleUtil.getDefault()); if ((sourceGroup == null) || !calendarResourceName.equals(sourceGroup.getDescriptiveName())) { return calendarResource.getNameMap(); }/*from w w w .j a v a 2 s . c o m*/ Map<Locale, String> calendarResourceNameMap = new HashMap<>(); Group scopeGroup = _groupLocalService.getGroup(portletDataContext.getScopeGroupId()); calendarResourceNameMap.put(LocaleUtil.getDefault(), scopeGroup.getDescriptiveName()); return calendarResourceNameMap; }
From source file:com.liferay.calendar.internal.exportimport.data.handler.CalendarStagedModelDataHandler.java
License:Open Source License
protected Map<Locale, String> getCalendarNameMap(PortletDataContext portletDataContext, Calendar calendar) throws Exception { Group sourceGroup = _groupLocalService.fetchGroup(portletDataContext.getSourceGroupId()); String calendarName = calendar.getName(LocaleUtil.getDefault()); if ((sourceGroup == null) || !calendarName.equals(sourceGroup.getDescriptiveName())) { return calendar.getNameMap(); }//from ww w . j ava 2s . c om Map<Locale, String> calendarNameMap = new HashMap<>(); Group scopeGroup = _groupLocalService.getGroup(portletDataContext.getScopeGroupId()); calendarNameMap.put(LocaleUtil.getDefault(), scopeGroup.getDescriptiveName()); return calendarNameMap; }
From source file:com.liferay.calendar.internal.model.listener.GroupModelListener.java
License:Open Source License
@Override public void onAfterUpdate(Group group) throws ModelListenerException { try {/* w ww .j a va 2s.c o m*/ long classNameId = _portal.getClassNameId(Group.class); CalendarResource calendarResource = _calendarResourceLocalService.fetchCalendarResource(classNameId, group.getGroupId()); if (calendarResource == null) { return; } Map<Locale, String> nameMap = new HashMap<>(); nameMap.put(LocaleUtil.getDefault(), group.getDescriptiveName()); calendarResource.setNameMap(nameMap); _calendarResourceLocalService.updateCalendarResource(calendarResource); } catch (Exception e) { throw new ModelListenerException(e); } }
From source file:com.liferay.calendar.service.test.CalendarServiceTest.java
License:Open Source License
protected Calendar getGroupCalendar(Group group) throws Exception { CalendarResource calendarResource = CalendarResourceLocalServiceUtil .fetchCalendarResource(PortalUtil.getClassNameId(Group.class), group.getGroupId()); if (calendarResource == null) { Map<Locale, String> nameMap = new HashMap<>(); nameMap.put(LocaleUtil.getDefault(), group.getDescriptiveName()); Map<Locale, String> descriptionMap = new HashMap<>(); ServiceContext serviceContext = new ServiceContext(); calendarResource = CalendarResourceLocalServiceUtil.addCalendarResource(group.getCreatorUserId(), group.getGroupId(), PortalUtil.getClassNameId(Group.class), group.getGroupId(), null, null, nameMap, descriptionMap, true, serviceContext); }/* ww w . j av a 2 s. c om*/ return calendarResource.getDefaultCalendar(); }
From source file:com.liferay.flags.internal.messaging.FlagsRequestMessageListener.java
License:Open Source License
@Override protected void doReceive(Message message) throws Exception { FlagsRequest flagsRequest = (FlagsRequest) message.getPayload(); // Service context ServiceContext serviceContext = flagsRequest.getServiceContext(); // Company//from w w w.java 2s . co m long companyId = serviceContext.getCompanyId(); Company company = _companyLocalService.getCompany(serviceContext.getCompanyId()); // Group Layout layout = _layoutLocalService.getLayout(serviceContext.getPlid()); Group group = layout.getGroup(); // Reporter user String reporterUserName = null; String reporterEmailAddress = null; User reporterUser = _userLocalService.getUserById(serviceContext.getUserId()); Locale locale = LocaleUtil.getDefault(); if (reporterUser.isDefaultUser()) { reporterUserName = LanguageUtil.get(locale, "anonymous"); } else { reporterUserName = reporterUser.getFullName(); reporterEmailAddress = reporterUser.getEmailAddress(); } // Reported user String reportedUserName = StringPool.BLANK; String reportedEmailAddress = StringPool.BLANK; String reportedURL = StringPool.BLANK; User reportedUser = _userLocalService.getUserById(flagsRequest.getReportedUserId()); if (reportedUser.isDefaultUser()) { reportedUserName = group.getDescriptiveName(); } else { reportedUserName = reportedUser.getFullName(); reportedEmailAddress = reportedUser.getEmailAddress(); reportedURL = reportedUser.getDisplayURL(serviceContext.getThemeDisplay()); } // Content String contentType = ResourceActionsUtil.getModelResource(locale, flagsRequest.getClassName()); // Reason String reason = LanguageUtil.get(locale, flagsRequest.getReason()); // Email FlagsGroupServiceConfiguration flagsGroupServiceConfiguration = ConfigurationProviderUtil .getCompanyConfiguration(FlagsGroupServiceConfiguration.class, companyId); String fromName = flagsGroupServiceConfiguration.emailFromName(); String fromAddress = flagsGroupServiceConfiguration.emailFromAddress(); String subject = ContentUtil.get(FlagsRequestMessageListener.class.getClassLoader(), flagsGroupServiceConfiguration.emailSubject()); String body = ContentUtil.get(FlagsRequestMessageListener.class.getClassLoader(), flagsGroupServiceConfiguration.emailBody()); // Recipients Set<User> recipients = getRecipients(companyId, serviceContext.getScopeGroupId()); for (User recipient : recipients) { try { notify(reporterUser.getUserId(), company, group, reporterEmailAddress, reporterUserName, reportedEmailAddress, reportedUserName, reportedURL, flagsRequest.getClassPK(), flagsRequest.getContentTitle(), contentType, flagsRequest.getContentURL(), reason, fromName, fromAddress, recipient.getFullName(), recipient.getEmailAddress(), subject, body, serviceContext); } catch (IOException ioe) { if (_log.isWarnEnabled()) { _log.warn(ioe); } } } }
From source file:com.liferay.message.boards.internal.util.MBSubscriptionHelper.java
License:Open Source License
public List<MBCategory> addSubscribedRootCategory(long groupId, long userId, List<MBCategory> categories) throws PortalException { Group group = _groupLocalService.getGroup(groupId); Subscription subscription = _subscriptionLocalService.fetchSubscription(group.getCompanyId(), userId, MBCategory.class.getName(), groupId); if (subscription != null) { int threadCount = _mbThreadLocalService.getCategoryThreadsCount(groupId, MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED); int messageCount = _mbMessageLocalService.getCategoryMessagesCount(groupId, MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED); MBCategory category = new MBCategoryImpl(); category.setGroupId(group.getGroupId()); category.setCompanyId(group.getCompanyId()); category.setName(group.getDescriptiveName()); category.setDescription(HtmlUtil.extractText(group.getDescription())); category.setThreadCount(threadCount); category.setMessageCount(messageCount); List<MBCategory> list = new ArrayList<>(categories); list.add(category);/* www . ja v a2 s . com*/ return Collections.unmodifiableList(list); } return categories; }