Example usage for com.liferay.portal.kernel.settings GroupServiceSettingsLocator GroupServiceSettingsLocator

List of usage examples for com.liferay.portal.kernel.settings GroupServiceSettingsLocator GroupServiceSettingsLocator

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.settings GroupServiceSettingsLocator GroupServiceSettingsLocator.

Prototype

public GroupServiceSettingsLocator(long groupId, String settingsId) 

Source Link

Usage

From source file:com.liferay.blogs.settings.BlogsGroupServiceSettings.java

License:Open Source License

public static BlogsGroupServiceSettings getInstance(long groupId) throws PortalException {

    Settings settings = SettingsFactoryUtil
            .getSettings(new GroupServiceSettingsLocator(groupId, BlogsConstants.SERVICE_NAME));

    return new BlogsGroupServiceSettings(settings);
}

From source file:com.liferay.blogs.settings.BlogsGroupServiceSettings.java

License:Open Source License

public static BlogsGroupServiceSettings getInstance(long groupId, Map<String, String[]> parameterMap)
        throws PortalException {

    Settings settings = SettingsFactoryUtil
            .getSettings(new GroupServiceSettingsLocator(groupId, BlogsConstants.SERVICE_NAME));

    return new BlogsGroupServiceSettings(new ParameterMapSettings(parameterMap, settings));
}

From source file:com.liferay.blogs.web.internal.portlet.action.RSSAction.java

License:Open Source License

@Override
protected boolean isRSSFeedsEnabled(HttpServletRequest request) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    BlogsGroupServiceOverriddenConfiguration blogsGroupServiceOverridenConfiguration = _configurationProvider
            .getConfiguration(BlogsGroupServiceOverriddenConfiguration.class, new GroupServiceSettingsLocator(
                    themeDisplay.getSiteGroupId(), BlogsConstants.SERVICE_NAME));

    return blogsGroupServiceOverridenConfiguration.enableRss();
}

From source file:com.liferay.bookmarks.service.impl.BookmarksEntryLocalServiceImpl.java

License:Open Source License

protected void notifySubscribers(long userId, BookmarksEntry entry, ServiceContext serviceContext)
        throws PortalException {

    String layoutFullURL = serviceContext.getLayoutFullURL();

    if (!entry.isApproved() || Validator.isNull(layoutFullURL)) {
        return;//  w  w w.  j av a2  s  .  c  om
    }

    BookmarksGroupServiceOverriddenConfiguration bookmarksGroupServiceOverriddenConfiguration = configurationProvider
            .getConfiguration(BookmarksGroupServiceOverriddenConfiguration.class,
                    new GroupServiceSettingsLocator(entry.getGroupId(), BookmarksConstants.SERVICE_NAME));

    if ((serviceContext.isCommandAdd()
            && !bookmarksGroupServiceOverriddenConfiguration.emailEntryAddedEnabled())
            || (serviceContext.isCommandUpdate()
                    && !bookmarksGroupServiceOverriddenConfiguration.emailEntryUpdatedEnabled())) {

        return;
    }

    String statusByUserName = StringPool.BLANK;

    try {
        User user = userLocalService.getUserById(serviceContext.getGuestOrUserId());

        statusByUserName = user.getFullName();
    } catch (Exception e) {
        _log.error(e, e);
    }

    String entryTitle = entry.getName();

    StringBundler sb = new StringBundler(7);

    sb.append(layoutFullURL);
    sb.append(Portal.FRIENDLY_URL_SEPARATOR);
    sb.append("bookmarks");
    sb.append(StringPool.SLASH);
    sb.append("folder");
    sb.append(StringPool.SLASH);
    sb.append(entry.getFolderId());

    String entryURL = sb.toString();

    String fromName = bookmarksGroupServiceOverriddenConfiguration.emailFromName();
    String fromAddress = bookmarksGroupServiceOverriddenConfiguration.emailFromAddress();

    LocalizedValuesMap subjectLocalizedValuesMap = null;
    LocalizedValuesMap bodyLocalizedValuesMap = null;

    if (serviceContext.isCommandUpdate()) {
        subjectLocalizedValuesMap = bookmarksGroupServiceOverriddenConfiguration.emailEntryUpdatedSubject();
        bodyLocalizedValuesMap = bookmarksGroupServiceOverriddenConfiguration.emailEntryUpdatedBody();
    } else {
        subjectLocalizedValuesMap = bookmarksGroupServiceOverriddenConfiguration.emailEntryAddedSubject();
        bodyLocalizedValuesMap = bookmarksGroupServiceOverriddenConfiguration.emailEntryAddedBody();
    }

    SubscriptionSender subscriptionSender = new GroupSubscriptionCheckSubscriptionSender(
            BookmarksResourcePermissionChecker.RESOURCE_NAME);

    subscriptionSender.setClassName(entry.getModelClassName());
    subscriptionSender.setClassPK(entry.getEntryId());
    subscriptionSender.setCompanyId(entry.getCompanyId());
    subscriptionSender.setContextAttributes("[$BOOKMARKS_ENTRY_STATUS_BY_USER_NAME$]", statusByUserName,
            "[$BOOKMARKS_ENTRY_URL$]", entryURL);
    subscriptionSender.setContextCreatorUserPrefix("BOOKMARKS_ENTRY");
    subscriptionSender.setCreatorUserId(entry.getUserId());
    subscriptionSender.setCurrentUserId(userId);
    subscriptionSender.setEntryTitle(entryTitle);
    subscriptionSender.setEntryURL(entryURL);
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);

    if (bodyLocalizedValuesMap != null) {
        subscriptionSender.setLocalizedBodyMap(LocalizationUtil.getMap(bodyLocalizedValuesMap));
    }

    if (subjectLocalizedValuesMap != null) {
        subscriptionSender.setLocalizedSubjectMap(LocalizationUtil.getMap(subjectLocalizedValuesMap));
    }

    subscriptionSender.setMailId("bookmarks_entry", entry.getEntryId());

    int notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_ADD_ENTRY;

    if (serviceContext.isCommandUpdate()) {
        notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_UPDATE_ENTRY;
    }

    subscriptionSender.setNotificationType(notificationType);

    subscriptionSender.setPortletId(BookmarksPortletKeys.BOOKMARKS);
    subscriptionSender.setReplyToAddress(fromAddress);
    subscriptionSender.setScopeGroupId(entry.getGroupId());
    subscriptionSender.setServiceContext(serviceContext);

    BookmarksFolder folder = entry.getFolder();

    if (folder != null) {
        subscriptionSender.addPersistedSubscribers(BookmarksFolder.class.getName(), folder.getFolderId());

        for (Long ancestorFolderId : folder.getAncestorFolderIds()) {
            subscriptionSender.addPersistedSubscribers(BookmarksFolder.class.getName(), ancestorFolderId);
        }
    }

    subscriptionSender.addPersistedSubscribers(BookmarksFolder.class.getName(), entry.getGroupId());

    subscriptionSender.addPersistedSubscribers(BookmarksEntry.class.getName(), entry.getEntryId());

    subscriptionSender.flushNotificationsAsync();
}

From source file:com.liferay.bookmarks.web.internal.portlet.toolbar.contributor.BookmarksPortletToolbarContributor.java

License:Open Source License

private BookmarksFolder _getFolder(ThemeDisplay themeDisplay, PortletRequest portletRequest) {

    BookmarksFolder folder = (BookmarksFolder) portletRequest.getAttribute(BookmarksWebKeys.BOOKMARKS_FOLDER);

    if (folder != null) {
        return folder;
    }/*from  w w  w . j a va2  s .  c  o  m*/

    long rootFolderId = BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID;

    try {
        BookmarksGroupServiceOverriddenConfiguration bookmarksGroupServiceOverriddenConfiguration = ConfigurationProviderUtil
                .getConfiguration(BookmarksGroupServiceOverriddenConfiguration.class,
                        new GroupServiceSettingsLocator(themeDisplay.getScopeGroupId(),
                                BookmarksConstants.SERVICE_NAME));

        rootFolderId = bookmarksGroupServiceOverriddenConfiguration.rootFolderId();
    } catch (ConfigurationException ce) {
        _log.error("Unable to obtain bookmarks root folder ID for group " + themeDisplay.getScopeGroupId());
    }

    long folderId = BeanParamUtil.getLong(folder, portletRequest, "folderId", rootFolderId);

    if (folderId != BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        try {
            folder = _bookmarksFolderService.getFolder(folderId);
        } catch (NoSuchFolderException nsfe) {
            folder = null;
        } catch (PortalException pe) {
            _log.error(pe, pe);
        }
    }

    return folder;
}

From source file:com.liferay.dynamic.data.mapping.service.impl.DDMTemplateLocalServiceImpl.java

License:Open Source License

protected DDMGroupServiceConfiguration getDDMGroupServiceConfiguration(long groupId)
        throws ConfigurationException {

    return configurationProvider.getConfiguration(DDMGroupServiceConfiguration.class,
            new GroupServiceSettingsLocator(groupId, DDMConstants.SERVICE_NAME));
}

From source file:com.liferay.dynamic.data.mapping.web.internal.context.util.DDMWebRequestHelper.java

License:Open Source License

protected <T> T getConfiguration(Class<T> clazz) throws ConfigurationException {

    if (Validator.isNotNull(getPortletResource())) {
        HttpServletRequest request = getRequest();

        return (T) ConfigurationProviderUtil.getConfiguration(clazz,
                new ParameterMapSettingsLocator(request.getParameterMap(),
                        new GroupServiceSettingsLocator(getSiteGroupId(), DDMConstants.SERVICE_NAME)));
    } else {/*  w  w  w. j  av a 2  s  . c o  m*/
        return (T) ConfigurationProviderUtil.getConfiguration(clazz,
                new GroupServiceSettingsLocator(getSiteGroupId(), DDMConstants.SERVICE_NAME));
    }
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

protected JournalGroupServiceConfiguration getJournalGroupServiceConfiguration(long groupId)
        throws ConfigurationException {

    return configurationProvider.getConfiguration(JournalGroupServiceConfiguration.class,
            new GroupServiceSettingsLocator(groupId, JournalConstants.SERVICE_NAME));
}

From source file:com.liferay.journal.web.internal.display.context.util.JournalWebRequestHelper.java

License:Open Source License

public JournalGroupServiceConfiguration getJournalGroupServiceConfiguration() {

    try {/*from w w  w  .j  a  va2s .c o  m*/
        if (_journalGroupServiceConfiguration == null) {
            ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

            PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

            if (Validator.isNotNull(portletDisplay.getPortletResource())) {
                _journalGroupServiceConfiguration = ConfigurationProviderUtil.getConfiguration(
                        JournalGroupServiceConfiguration.class,
                        new ParameterMapSettingsLocator(_request.getParameterMap(),
                                new GroupServiceSettingsLocator(themeDisplay.getSiteGroupId(),
                                        JournalConstants.SERVICE_NAME)));
            } else {
                _journalGroupServiceConfiguration = ConfigurationProviderUtil.getConfiguration(
                        JournalGroupServiceConfiguration.class, new GroupServiceSettingsLocator(
                                themeDisplay.getSiteGroupId(), JournalConstants.SERVICE_NAME));
            }
        }

        return _journalGroupServiceConfiguration;
    } catch (PortalException pe) {
        throw new SystemException(pe);
    }
}

From source file:com.liferay.mentions.internal.service.MentionsWikiPageServiceWrapper.java

License:Open Source License

@Override
public WikiPage updateStatus(long userId, WikiPage page, int status, ServiceContext serviceContext,
        Map<String, Serializable> workflowContext) throws PortalException {

    int oldStatus = page.getStatus();

    page = super.updateStatus(userId, page, status, serviceContext, workflowContext);

    WikiGroupServiceOverriddenConfiguration wikiGroupServiceOverriddenConfiguration = _configurationProvider
            .getConfiguration(WikiGroupServiceOverriddenConfiguration.class,
                    new GroupServiceSettingsLocator(page.getGroupId(), WikiConstants.SERVICE_NAME));

    // Subscriptions

    if (status == WorkflowConstants.STATUS_APPROVED) {
        if (NotificationThreadLocal.isEnabled()
                && (!page.isMinorEdit() || wikiGroupServiceOverriddenConfiguration.pageMinorEditSendEmail())) {

            notifySubscribers(userId, page, (String) workflowContext.get(WorkflowConstants.CONTEXT_URL),
                    serviceContext);/*ww  w.j av a 2s.  co m*/
        }
    }

    if ((status != WorkflowConstants.STATUS_APPROVED) || (oldStatus == WorkflowConstants.STATUS_IN_TRASH)) {

        return page;
    }

    long siteGroupId = PortalUtil.getSiteGroupId(page.getGroupId());

    if (!MentionsUtil.isMentionsEnabled(siteGroupId)) {
        return page;
    }

    String contentURL = (String) serviceContext.getAttribute("contentURL");

    if (Validator.isNull(contentURL)) {
        serviceContext.setAttribute("contentURL", workflowContext.get("url"));
    }

    String portalURL = serviceContext.getPortalURL();

    String attachmentURLPrefix = WikiUtil.getAttachmentURLPrefix(serviceContext.getPathMain(),
            serviceContext.getPlid(), page.getNodeId(), page.getTitle());

    attachmentURLPrefix = portalURL + attachmentURLPrefix;

    String pageContent = _wikiEngineRenderer.convert(page, null, null, attachmentURLPrefix);

    MentionsGroupServiceConfiguration mentionsGroupServiceConfiguration = _configurationProvider
            .getCompanyConfiguration(MentionsGroupServiceConfiguration.class, page.getCompanyId());

    _mentionsNotifier.notify(page.getUserId(), page.getGroupId(), page.getTitle(), pageContent,
            WikiPage.class.getName(), page.getPageId(),
            mentionsGroupServiceConfiguration.assetEntryMentionEmailSubject(),
            mentionsGroupServiceConfiguration.assetEntryMentionEmailBody(), serviceContext);

    return page;
}