Example usage for com.liferay.portal.kernel.model Group getDescriptiveName

List of usage examples for com.liferay.portal.kernel.model Group getDescriptiveName

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model Group getDescriptiveName.

Prototype

public String getDescriptiveName(java.util.Locale locale)
            throws com.liferay.portal.kernel.exception.PortalException;

Source Link

Usage

From source file:com.liferay.announcements.web.internal.display.context.DefaultAnnouncementsAdminViewDisplayContext.java

License:Open Source License

@Override
public Map<String, String> getDistributionScopes() throws Exception {
    Map<String, String> distributionScopes = new LinkedHashMap<>();

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

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (PortalPermissionUtil.contains(permissionChecker, ActionKeys.ADD_GENERAL_ANNOUNCEMENTS)) {

        distributionScopes.put("general", "0,0");
    }//from  w w w. j  a  v  a2 s.c  o m

    List<Group> groups = AnnouncementsUtil.getGroups(themeDisplay);

    for (Group group : groups) {
        distributionScopes.put(
                StringBundler.concat(group.getDescriptiveName(themeDisplay.getLocale()), " (",
                        LanguageUtil.get(_request, "site"), ")"),
                PortalUtil.getClassNameId(Group.class) + StringPool.COMMA + group.getGroupId());
    }

    List<Organization> organizations = AnnouncementsUtil.getOrganizations(themeDisplay);

    for (Organization organization : organizations) {
        String name = StringBundler.concat(organization.getName(), " (",
                LanguageUtil.get(_request, "organization"), ")");

        distributionScopes.put(name, PortalUtil.getClassNameId(Organization.class) + StringPool.COMMA
                + organization.getOrganizationId());
    }

    List<Role> roles = AnnouncementsUtil.getRoles(themeDisplay);

    for (Role role : roles) {
        distributionScopes.put(
                StringBundler.concat(role.getDescriptiveName(), " (", LanguageUtil.get(_request, "role"), ")"),
                PortalUtil.getClassNameId(Role.class) + StringPool.COMMA + role.getRoleId());
    }

    List<UserGroup> userGroups = AnnouncementsUtil.getUserGroups(themeDisplay);

    for (UserGroup userGroup : userGroups) {
        distributionScopes.put(
                StringBundler.concat(userGroup.getName(), " (", LanguageUtil.get(_request, "user-group"), ")"),
                PortalUtil.getClassNameId(UserGroup.class) + StringPool.COMMA + userGroup.getUserGroupId());
    }

    return distributionScopes;
}

From source file:com.liferay.asset.browser.web.internal.display.context.AssetBrowserDisplayContext.java

License:Open Source License

public List<ManagementBarFilterItem> getManagementBarFilterItem() throws PortalException {

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

    List<ManagementBarFilterItem> managementBarFilterItems = new ArrayList<>();

    String label = LanguageUtil.get(_request, "all");

    PortletURL groupURL = getPortletURL();

    groupURL.setParameter("groupId", "0");

    ManagementBarFilterItem managementBarFilterItem = new ManagementBarFilterItem(false, label,
            groupURL.toString());//from   w  w  w . j a  va2 s  .  c  o m

    managementBarFilterItems.add(managementBarFilterItem);

    List<Group> groups = GroupLocalServiceUtil.getGroups(getSelectedGroupIds());

    for (Group curGroup : groups) {
        boolean active = false;

        if (getGroupId() == curGroup.getGroupId()) {
            active = true;
        }

        label = HtmlUtil.escape(curGroup.getDescriptiveName(themeDisplay.getLocale()));

        groupURL.setParameter("groupId", String.valueOf(curGroup.getGroupId()));

        managementBarFilterItem = new ManagementBarFilterItem(active, label, groupURL.toString());

        managementBarFilterItems.add(managementBarFilterItem);
    }

    return managementBarFilterItems;
}

From source file:com.liferay.asset.browser.web.internal.display.context.AssetBrowserDisplayContext.java

License:Open Source License

public String getManagementBarFilterLabel() throws PortalException {
    if (getGroupId() <= 0) {
        return LanguageUtil.get(_request, "all");
    }/*from   w ww. j a  va2 s  .  c  o m*/

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

    Group group = GroupLocalServiceUtil.fetchGroup(getGroupId());

    return group.getDescriptiveName(themeDisplay.getLocale());
}

From source file:com.liferay.asset.categories.selector.web.display.context.AssetCategoriesSelectorDisplayContext.java

License:Open Source License

public String getVocabularyTitle(long vocabularyId) throws PortalException {
    ThemeDisplay themeDisplay = (ThemeDisplay) _renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    AssetVocabulary assetVocabulary = AssetVocabularyLocalServiceUtil.fetchAssetVocabulary(vocabularyId);

    StringBundler sb = new StringBundler(4);

    String title = assetVocabulary.getTitle(themeDisplay.getLocale());

    sb.append(HtmlUtil.escape(title));//w w  w.  j a v  a2 s .com

    sb.append(StringPool.OPEN_PARENTHESIS);

    if (assetVocabulary.getGroupId() == themeDisplay.getCompanyGroupId()) {
        sb.append(LanguageUtil.get(_request, "global"));
    } else {
        Group group = GroupLocalServiceUtil.fetchGroup(assetVocabulary.getGroupId());

        sb.append(group.getDescriptiveName(themeDisplay.getLocale()));
    }

    sb.append(StringPool.CLOSE_PARENTHESIS);

    return sb.toString();
}

From source file:com.liferay.asset.taglib.internal.display.context.InputAssetLinksDisplayContext.java

License:Open Source License

public String getGroupDescriptiveName(AssetEntry assetEntry) throws PortalException {

    Group group = GroupLocalServiceUtil.getGroup(assetEntry.getGroupId());

    return group.getDescriptiveName(_themeDisplay.getLocale());
}

From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java

License:Open Source License

protected void notifySubscribers(long userId, BlogsEntry entry, ServiceContext serviceContext,
        Map<String, Serializable> workflowContext) throws PortalException {

    String entryURL = (String) workflowContext.get(WorkflowConstants.CONTEXT_URL);

    if (!entry.isApproved() || Validator.isNull(entryURL)) {
        return;//w  w  w. j  ava 2  s  . c o m
    }

    BlogsGroupServiceSettings blogsGroupServiceSettings = BlogsGroupServiceSettings
            .getInstance(entry.getGroupId());

    boolean sendEmailEntryUpdated = GetterUtil.getBoolean(serviceContext.getAttribute("sendEmailEntryUpdated"));

    if (serviceContext.isCommandAdd() && blogsGroupServiceSettings.isEmailEntryAddedEnabled()) {
    } else if (sendEmailEntryUpdated && serviceContext.isCommandUpdate()
            && blogsGroupServiceSettings.isEmailEntryUpdatedEnabled()) {
    } else {
        return;
    }

    Group group = groupPersistence.findByPrimaryKey(entry.getGroupId());

    String entryTitle = entry.getTitle();

    String fromName = blogsGroupServiceSettings.getEmailFromName();
    String fromAddress = blogsGroupServiceSettings.getEmailFromAddress();

    LocalizedValuesMap subjectLocalizedValuesMap = null;
    LocalizedValuesMap bodyLocalizedValuesMap = null;

    if (serviceContext.isCommandUpdate()) {
        subjectLocalizedValuesMap = blogsGroupServiceSettings.getEmailEntryUpdatedSubject();
        bodyLocalizedValuesMap = blogsGroupServiceSettings.getEmailEntryUpdatedBody();
    } else {
        subjectLocalizedValuesMap = blogsGroupServiceSettings.getEmailEntryAddedSubject();
        bodyLocalizedValuesMap = blogsGroupServiceSettings.getEmailEntryAddedBody();
    }

    SubscriptionSender subscriptionSender = new GroupSubscriptionCheckSubscriptionSender(
            BlogsPermission.RESOURCE_NAME);

    subscriptionSender.setClassPK(entry.getEntryId());
    subscriptionSender.setClassName(entry.getModelClassName());
    subscriptionSender.setCompanyId(entry.getCompanyId());
    subscriptionSender.setContextAttribute("[$BLOGS_ENTRY_CONTENT$]",
            StringUtil.shorten(HtmlUtil.stripHtml(entry.getContent()), 500), false);
    subscriptionSender.setContextAttributes("[$BLOGS_ENTRY_CREATE_DATE$]",
            Time.getSimpleDate(entry.getCreateDate(), "yyyy/MM/dd"), "[$BLOGS_ENTRY_DESCRIPTION$]",
            entry.getDescription(), "[$BLOGS_ENTRY_SITE_NAME$]",
            group.getDescriptiveName(serviceContext.getLocale()), "[$BLOGS_ENTRY_STATUS_BY_USER_NAME$]",
            entry.getStatusByUserName(), "[$BLOGS_ENTRY_TITLE$]", entryTitle, "[$BLOGS_ENTRY_UPDATE_COMMENT$]",
            HtmlUtil.replaceNewLine(
                    GetterUtil.getString(serviceContext.getAttribute("emailEntryUpdatedComment"))),
            "[$BLOGS_ENTRY_URL$]", entryURL, "[$BLOGS_ENTRY_USER_PORTRAIT_URL$]",
            workflowContext.get(WorkflowConstants.CONTEXT_USER_PORTRAIT_URL), "[$BLOGS_ENTRY_USER_URL$]",
            workflowContext.get(WorkflowConstants.CONTEXT_USER_URL));
    subscriptionSender.setContextCreatorUserPrefix("BLOGS_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("blogs_entry", entry.getEntryId());

    int notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_ADD_ENTRY;

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

    subscriptionSender.setNotificationType(notificationType);

    String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(),
            PortletProvider.Action.VIEW);

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

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

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

    subscriptionSender.flushNotificationsAsync();
}

From source file:com.liferay.flags.internal.messaging.FlagsRequestMessageListener.java

License:Open Source License

private String _getGroupDescriptiveName(Group group, Locale locale) {
    try {/*  ww  w .  j  ava 2 s. c  om*/
        return group.getDescriptiveName(locale);
    } catch (PortalException pe) {
        _log.error("Unable to get descriptive name for group " + group.getGroupId(), pe);
    }

    return StringPool.BLANK;
}

From source file:com.liferay.invitation.invite.members.service.impl.MemberRequestLocalServiceImpl.java

License:Open Source License

protected void sendEmail(String emailAddress, MemberRequest memberRequest, ServiceContext serviceContext)
        throws Exception {

    long companyId = memberRequest.getCompanyId();

    Group group = groupLocalService.getGroup(memberRequest.getGroupId());

    User user = userLocalService.getUser(memberRequest.getUserId());

    User receiverUser = null;//from w ww .j  a v  a2 s. com

    if (memberRequest.getReceiverUserId() > 0) {
        receiverUser = userLocalService.getUser(memberRequest.getReceiverUserId());
    }

    String fromName = PrefsPropsUtil.getString(companyId, PropsKeys.ADMIN_EMAIL_FROM_NAME);
    String fromAddress = PrefsPropsUtil.getString(companyId, PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);

    String toName = StringPool.BLANK;
    String toAddress = emailAddress;

    if (receiverUser != null) {
        toName = receiverUser.getFullName();
    }

    String subject = StringUtil.read(getClassLoader(),
            "com/liferay/invitation/invite/members/dependencies/subject.tmpl");

    String body = StringPool.BLANK;

    if (memberRequest.getReceiverUserId() > 0) {
        body = StringUtil.read(getClassLoader(),
                "com/liferay/invitation/invite/members/dependencies" + "/existing_user_body.tmpl");
    } else {
        body = StringUtil.read(getClassLoader(),
                "com/liferay/invitation/invite/members/dependencies" + "/new_user_body.tmpl");
    }

    subject = StringUtil.replace(subject,
            new String[] { "[$MEMBER_REQUEST_GROUP$]", "[$MEMBER_REQUEST_USER$]" },
            new String[] { group.getDescriptiveName(serviceContext.getLocale()), user.getFullName() });

    body = StringUtil.replace(body,
            new String[] { "[$ADMIN_ADDRESS$]", "[$ADMIN_NAME$]", "[$MEMBER_REQUEST_CREATE_ACCOUNT_URL$]",
                    "[$MEMBER_REQUEST_GROUP$]", "[$MEMBER_REQUEST_LOGIN_URL$]", "[$MEMBER_REQUEST_USER$]" },
            new String[] { fromAddress, fromName, getCreateAccountURL(memberRequest, serviceContext),
                    group.getDescriptiveName(serviceContext.getLocale()),
                    getLoginURL(memberRequest, serviceContext), user.getFullName() });

    InternetAddress from = new InternetAddress(fromAddress, fromName);

    InternetAddress to = new InternetAddress(toAddress, toName);

    MailMessage mailMessage = new MailMessage(from, to, subject, body, true);

    mailService.sendEmail(mailMessage);
}

From source file:com.liferay.invitation.invite.members.web.internal.notifications.InviteMembersUserNotificationHandler.java

License:Open Source License

protected String getSiteDescriptiveName(long groupId, ServiceContext serviceContext) throws Exception {

    Group group = _groupLocalService.getGroup(groupId);

    StringBundler sb = new StringBundler(6);

    sb.append("<a");

    if (group.hasPublicLayouts()) {
        sb.append(" href=\"");

        String groupFriendlyURL = _portal.getGroupFriendlyURL(group.getPublicLayoutSet(),
                serviceContext.getThemeDisplay());

        sb.append(groupFriendlyURL);/*  w  ww  .jav  a 2  s  .  c om*/

        sb.append("\">");
    } else {
        sb.append(">");
    }

    sb.append(HtmlUtil.escape(group.getDescriptiveName(serviceContext.getLocale())));
    sb.append("</a>");

    return sb.toString();
}

From source file:com.liferay.item.selector.taglib.internal.util.ItemSelectorRepositoryEntryBrowserUtil.java

License:Open Source License

public static void addPortletBreadcrumbEntries(long folderId, String displayStyle, HttpServletRequest request,
        LiferayPortletResponse liferayPortletResponse, PortletURL portletURL) throws Exception {

    addGroupSelectorBreadcrumbEntry(request, liferayPortletResponse, portletURL);

    portletURL.setParameter("displayStyle", displayStyle);

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

    Group scopeGroup = themeDisplay.getScopeGroup();

    addPortletBreadcrumbEntry(DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, request,
            scopeGroup.getDescriptiveName(request.getLocale()), portletURL);

    if (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        Folder folder = DLAppServiceUtil.getFolder(folderId);

        List<Folder> ancestorFolders = folder.getAncestors();

        Collections.reverse(ancestorFolders);

        for (Folder ancestorFolder : ancestorFolders) {
            addPortletBreadcrumbEntry(ancestorFolder.getFolderId(), request, ancestorFolder.getName(),
                    portletURL);//from w w w  . ja  v a2 s. c o m
        }

        addPortletBreadcrumbEntry(folder.getFolderId(), request, folder.getName(), portletURL);
    }
}