Example usage for com.liferay.portal.kernel.util StringPool SPACE

List of usage examples for com.liferay.portal.kernel.util StringPool SPACE

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util StringPool SPACE.

Prototype

String SPACE

To view the source code for com.liferay.portal.kernel.util StringPool SPACE.

Click Source Link

Usage

From source file:com.liferay.portlet.mobiledevicerules.service.impl.MDRRuleGroupLocalServiceImpl.java

License:Open Source License

public MDRRuleGroup copyRuleGroup(MDRRuleGroup ruleGroup, long groupId, ServiceContext serviceContext)
        throws PortalException, SystemException {

    Group group = groupPersistence.findByPrimaryKey(groupId);

    Map<Locale, String> nameMap = ruleGroup.getNameMap();

    for (Map.Entry<Locale, String> entry : nameMap.entrySet()) {
        Locale locale = entry.getKey();
        String name = entry.getValue();

        if (Validator.isNull(name)) {
            continue;
        }//w w  w  .  ja  v  a2 s .  com

        String postfix = LanguageUtil.get(locale, PropsValues.MOBILE_DEVICE_RULES_RULE_GROUP_COPY_POSTFIX);

        nameMap.put(locale, name.concat(StringPool.SPACE).concat(postfix));
    }

    MDRRuleGroup newRuleGroup = addRuleGroup(group.getGroupId(), nameMap, ruleGroup.getDescriptionMap(),
            serviceContext);

    List<MDRRule> rules = mdrRulePersistence.findByRuleGroupId(ruleGroup.getRuleGroupId());

    for (MDRRule rule : rules) {
        serviceContext.setUuid(PortalUUIDUtil.generate());

        mdrRuleLocalService.copyRule(rule, newRuleGroup.getRuleGroupId(), serviceContext);
    }

    return newRuleGroup;
}

From source file:com.liferay.portlet.social.model.BaseSocialAchievement.java

License:Open Source License

public void setName(String name) {
    name = StringUtil.replace(name, StringPool.SPACE, StringPool.UNDERLINE);
    name = name.toLowerCase();

    _name = StringUtil.extract(name, _NAME_SUPPORTED_CHARS);
}

From source file:com.liferay.portlet.softwarecatalog.util.SCIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    SCProductEntry productEntry = (SCProductEntry) obj;

    Document document = getBaseModelDocument(PORTLET_ID, productEntry);

    StringBundler sb = new StringBundler(15);

    String longDescription = HtmlUtil.extractText(productEntry.getLongDescription());

    sb.append(longDescription);//from w ww. j  av  a  2s . co  m

    sb.append(StringPool.SPACE);
    sb.append(productEntry.getPageURL());
    sb.append(StringPool.SPACE);
    sb.append(productEntry.getRepoArtifactId());
    sb.append(StringPool.SPACE);
    sb.append(productEntry.getRepoGroupId());
    sb.append(StringPool.SPACE);

    String shortDescription = HtmlUtil.extractText(productEntry.getShortDescription());

    sb.append(shortDescription);

    sb.append(StringPool.SPACE);
    sb.append(productEntry.getType());
    sb.append(StringPool.SPACE);
    sb.append(productEntry.getUserId());
    sb.append(StringPool.SPACE);

    String userName = PortalUtil.getUserName(productEntry.getUserId(), productEntry.getUserName());

    sb.append(userName);

    document.addText(Field.CONTENT, sb.toString());

    document.addText(Field.TITLE, productEntry.getName());
    document.addKeyword(Field.TYPE, productEntry.getType());

    String version = StringPool.BLANK;

    SCProductVersion latestProductVersion = productEntry.getLatestVersion();

    if (latestProductVersion != null) {
        version = latestProductVersion.getVersion();
    }

    document.addKeyword(Field.VERSION, version);

    document.addText("longDescription", longDescription);
    document.addText("pageURL", productEntry.getPageURL());
    document.addKeyword("repoArtifactId", productEntry.getRepoArtifactId());
    document.addKeyword("repoGroupId", productEntry.getRepoGroupId());
    document.addText("shortDescription", shortDescription);

    return document;
}

From source file:com.liferay.portlet.tags.service.persistence.TagsAssetFinderImpl.java

License:Open Source License

public List<TagsAsset> findAssets(long groupId, long[] classNameIds, String orderByCol1, String orderByCol2,
        String orderByType1, String orderByType2, boolean excludeZeroViewCount, Date publishDate,
        Date expirationDate, int start, int end) throws SystemException {

    orderByCol1 = checkOrderByCol(orderByCol1);
    orderByCol2 = checkOrderByCol(orderByCol2);
    orderByType1 = checkOrderByType(orderByType1);
    orderByType2 = checkOrderByType(orderByType2);

    Session session = null;/*from  w ww  .j a v a2 s.c  om*/

    try {
        session = openSession();

        StringBuilder sb = new StringBuilder();

        sb.append("SELECT {TagsAsset.*} ");
        sb.append("FROM TagsAsset WHERE");
        sb.append(" (visible = ?)");

        if (excludeZeroViewCount) {
            sb.append(" AND (TagsAsset.viewCount > 0)");
        }

        sb.append("[$DATES$]");

        if (groupId > 0) {
            sb.append(" AND (TagsAsset.groupId = ?)");
        }

        sb.append(getClassNameIds(classNameIds));

        sb.append(" ORDER BY TagsAsset.");
        sb.append(orderByCol1);
        sb.append(StringPool.SPACE);
        sb.append(orderByType1);

        if (Validator.isNotNull(orderByCol2) && !orderByCol1.equals(orderByCol2)) {

            sb.append(", TagsAsset.");
            sb.append(orderByCol2);
            sb.append(StringPool.SPACE);
            sb.append(orderByType2);
        }

        String sql = sb.toString();

        sql = getDates(sql, publishDate, expirationDate);

        SQLQuery q = session.createSQLQuery(sql);

        q.addEntity("TagsAsset", TagsAssetImpl.class);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(true);

        setDates(qPos, publishDate, expirationDate);

        if (groupId > 0) {
            setGroupId(qPos, groupId);
        }

        setClassNamedIds(qPos, classNameIds);

        return (List<TagsAsset>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
        throw new SystemException(e);
    } finally {
        closeSession(session);
    }
}

From source file:com.liferay.portlet.tags.service.persistence.TagsAssetFinderImpl.java

License:Open Source License

public List<TagsAsset> findByAndEntryIds(long groupId, long[] classNameIds, long[] entryIds, long[] notEntryIds,
        String orderByCol1, String orderByCol2, String orderByType1, String orderByType2,
        boolean excludeZeroViewCount, Date publishDate, Date expirationDate, int start, int end)
        throws SystemException {

    orderByCol1 = checkOrderByCol(orderByCol1);
    orderByCol2 = checkOrderByCol(orderByCol2);
    orderByType1 = checkOrderByType(orderByType1);
    orderByType2 = checkOrderByType(orderByType2);

    Session session = null;/*  ww w. j av a2 s .c  o m*/

    try {
        session = openSession();

        StringBuilder sb = new StringBuilder();

        sb.append("SELECT DISTINCT {TagsAsset.*} ");
        sb.append("FROM TagsAsset WHERE");
        sb.append(" (visible = ?)");

        if (entryIds.length > 0) {
            sb.append(" AND TagsAsset.assetId IN (");

            for (int i = 0; i < entryIds.length; i++) {
                sb.append(CustomSQLUtil.get(FIND_BY_AND_ENTRY_IDS));

                if ((i + 1) < entryIds.length) {
                    sb.append(" AND TagsAsset.assetId IN (");
                }
            }

            for (int i = 0; i < entryIds.length; i++) {
                if ((i + 1) < entryIds.length) {
                    sb.append(StringPool.CLOSE_PARENTHESIS);
                }
            }

            if (excludeZeroViewCount) {
                sb.append(" AND (TagsAsset.viewCount > 0)");
            }

            sb.append(StringPool.CLOSE_PARENTHESIS);
        }

        if (notEntryIds.length > 0) {
            sb.append(" AND (");

            for (int i = 0; i < notEntryIds.length; i++) {
                sb.append("TagsAsset.assetId NOT IN (");
                sb.append(CustomSQLUtil.get(FIND_BY_AND_ENTRY_IDS));
                sb.append(StringPool.CLOSE_PARENTHESIS);

                if ((i + 1) < notEntryIds.length) {
                    sb.append(" OR ");
                }
            }

            sb.append(StringPool.CLOSE_PARENTHESIS);
        }

        sb.append("[$DATES$]");

        if (groupId > 0) {
            sb.append(" AND (TagsAsset.groupId = ?)");
        }

        sb.append(getClassNameIds(classNameIds));

        sb.append(" ORDER BY TagsAsset.");
        sb.append(orderByCol1);
        sb.append(StringPool.SPACE);
        sb.append(orderByType1);

        if (Validator.isNotNull(orderByCol2) && !orderByCol1.equals(orderByCol2)) {

            sb.append(", TagsAsset.");
            sb.append(orderByCol2);
            sb.append(StringPool.SPACE);
            sb.append(orderByType2);
        }

        String sql = sb.toString();

        sql = getDates(sql, publishDate, expirationDate);

        SQLQuery q = session.createSQLQuery(sql);

        q.addEntity("TagsAsset", TagsAssetImpl.class);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(true);

        setEntryIds(qPos, entryIds);
        setEntryIds(qPos, notEntryIds);
        setDates(qPos, publishDate, expirationDate);

        if (groupId > 0) {
            setGroupId(qPos, groupId);
        }

        setClassNamedIds(qPos, classNameIds);

        return (List<TagsAsset>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
        throw new SystemException(e);
    } finally {
        closeSession(session);
    }
}

From source file:com.liferay.portlet.tags.service.persistence.TagsAssetFinderImpl.java

License:Open Source License

public List<TagsAsset> findByOrEntryIds(long groupId, long[] classNameIds, long[] entryIds, long[] notEntryIds,
        String orderByCol1, String orderByCol2, String orderByType1, String orderByType2,
        boolean excludeZeroViewCount, Date publishDate, Date expirationDate, int start, int end)
        throws SystemException {

    orderByCol1 = checkOrderByCol(orderByCol1);
    orderByCol2 = checkOrderByCol(orderByCol2);
    orderByType1 = checkOrderByType(orderByType1);
    orderByType2 = checkOrderByType(orderByType2);

    Session session = null;//from w  w w .j  a v a  2 s .c  o m

    try {
        session = openSession();

        String sql = CustomSQLUtil.get(FIND_BY_OR_ENTRY_IDS);

        sql = StringUtil.replace(sql, "[$ENTRY_ID$]", getEntryIds(entryIds, StringPool.EQUAL));

        if (notEntryIds.length > 0) {
            StringBuilder sb = new StringBuilder();

            sb.append(" AND (");

            for (int i = 0; i < notEntryIds.length; i++) {
                sb.append("TagsAsset.assetId NOT IN (");
                sb.append(CustomSQLUtil.get(FIND_BY_AND_ENTRY_IDS));
                sb.append(StringPool.CLOSE_PARENTHESIS);

                if ((i + 1) < notEntryIds.length) {
                    sb.append(" AND ");
                }
            }

            sb.append(StringPool.CLOSE_PARENTHESIS);

            sql = StringUtil.replace(sql, "[$NOT_ENTRY_ID$]", sb.toString());
        } else {
            sql = StringUtil.replace(sql, "[$NOT_ENTRY_ID$]", StringPool.BLANK);
        }

        sql = getDates(sql, publishDate, expirationDate);

        sql += " AND (visible = ?)";

        if (groupId > 0) {
            sql += " AND (TagsAsset.groupId = ?)";
        }

        sql += getClassNameIds(classNameIds);

        if (excludeZeroViewCount) {
            sql += " AND (TagsAsset.viewCount > 0)";
        }

        StringBuilder sb = new StringBuilder();

        sb.append(" ORDER BY TagsAsset.");
        sb.append(orderByCol1);
        sb.append(StringPool.SPACE);
        sb.append(orderByType1);

        if (Validator.isNotNull(orderByCol2) && !orderByCol1.equals(orderByCol2)) {

            sb.append(", TagsAsset.");
            sb.append(orderByCol2);
            sb.append(StringPool.SPACE);
            sb.append(orderByType2);
        }

        sql += sb.toString();

        SQLQuery q = session.createSQLQuery(sql);

        q.addEntity("TagsAsset", TagsAssetImpl.class);

        QueryPos qPos = QueryPos.getInstance(q);

        setEntryIds(qPos, entryIds);
        setEntryIds(qPos, notEntryIds);
        setDates(qPos, publishDate, expirationDate);

        qPos.add(true);

        if (groupId > 0) {
            setGroupId(qPos, groupId);
        }

        setClassNamedIds(qPos, classNameIds);

        return (List<TagsAsset>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
        throw new SystemException(e);
    } finally {
        closeSession(session);
    }
}

From source file:com.liferay.portlet.wiki.engines.antlrwiki.translator.XhtmlTranslator.java

License:Open Source License

protected String getHeadingMarkup(String prefix, String text) {
    StringBundler sb = new StringBundler(5);

    sb.append(_HEADING_ANCHOR_PREFIX);/* w  w w  . jav  a 2  s  .c om*/
    sb.append(prefix);
    sb.append(StringPool.DASH);
    sb.append(text.trim());

    return StringUtil.replace(sb.toString(), StringPool.SPACE, StringPool.PLUS);
}

From source file:com.liferay.portlet.wiki.lar.WikiPortletDataHandlerImpl.java

License:Open Source License

protected static String getNodeName(PortletDataContext portletDataContext, WikiNode node, String name,
        int count) throws Exception {

    WikiNode existingNode = WikiNodeUtil.fetchByG_N(portletDataContext.getScopeGroupId(), name);

    if (existingNode == null) {
        return name;
    }/*from  ww  w .  j a v  a2 s .  c  o  m*/

    String nodeName = node.getName();

    return getNodeName(portletDataContext, node,
            nodeName.concat(StringPool.SPACE).concat(String.valueOf(count)), ++count);
}

From source file:com.liferay.portlet.wiki.service.impl.WikiPageLocalServiceImpl.java

License:Open Source License

protected void notifySubscribers(WikiNode node, WikiPage page, ServiceContext serviceContext, boolean update)
        throws PortalException, SystemException {

    PortletPreferences preferences = ServiceContextUtil.getPortletPreferences(serviceContext);

    if (preferences == null) {
        long ownerId = node.getGroupId();
        int ownerType = PortletKeys.PREFS_OWNER_TYPE_GROUP;
        long plid = PortletKeys.PREFS_PLID_SHARED;
        String portletId = PortletKeys.WIKI;
        String defaultPreferences = null;

        preferences = portletPreferencesLocalService.getPreferences(node.getCompanyId(), ownerId, ownerType,
                plid, portletId, defaultPreferences);
    }/*from w  ww  .  ja  v  a2s .  c  o  m*/

    if (!update && WikiUtil.getEmailPageAddedEnabled(preferences)) {
    } else if (update && WikiUtil.getEmailPageUpdatedEnabled(preferences)) {
    } else {
        return;
    }

    String portalURL = serviceContext.getPortalURL();
    String layoutFullURL = serviceContext.getLayoutFullURL();

    WikiPage previousVersionPage = getPreviousVersionPage(page);

    String attachmentURLPrefix = portalURL + serviceContext.getPathMain() + "/wiki/get_page_attachment?p_l_id="
            + serviceContext.getPlid() + "&nodeId=" + page.getNodeId() + "&title="
            + HttpUtil.encodeURL(page.getTitle()) + "&fileName=";

    String pageDiffs = StringPool.BLANK;

    try {
        pageDiffs = WikiUtil.diffHtml(previousVersionPage, page, null, null, attachmentURLPrefix);
    } catch (Exception e) {
    }

    String pageContent = null;

    if (Validator.equals(page.getFormat(), "creole")) {
        pageContent = WikiUtil.convert(page, null, null, attachmentURLPrefix);
    } else {
        pageContent = page.getContent();
        pageContent = WikiUtil.processContent(pageContent);
    }

    String pageURL = StringPool.BLANK;
    String diffsURL = StringPool.BLANK;

    if (Validator.isNotNull(layoutFullURL)) {
        pageURL = layoutFullURL + Portal.FRIENDLY_URL_SEPARATOR + "wiki/" + node.getNodeId() + StringPool.SLASH
                + HttpUtil.encodeURL(page.getTitle());

        if (previousVersionPage != null) {
            StringBundler sb = new StringBundler(16);

            sb.append(layoutFullURL);
            sb.append("?p_p_id=");
            sb.append(PortletKeys.WIKI);
            sb.append("&p_p_state=");
            sb.append(WindowState.MAXIMIZED);
            sb.append("&struts_action=");
            sb.append(HttpUtil.encodeURL("/wiki/compare_versions"));
            sb.append("&nodeId=");
            sb.append(node.getNodeId());
            sb.append("&title=");
            sb.append(HttpUtil.encodeURL(page.getTitle()));
            sb.append("&sourceVersion=");
            sb.append(previousVersionPage.getVersion());
            sb.append("&targetVersion=");
            sb.append(page.getVersion());
            sb.append("&type=html");

            diffsURL = sb.toString();
        }
    }

    String fromName = WikiUtil.getEmailFromName(preferences, page.getCompanyId());
    String fromAddress = WikiUtil.getEmailFromAddress(preferences, page.getCompanyId());

    String subjectPrefix = null;
    String body = null;
    String signature = null;

    if (update) {
        subjectPrefix = WikiUtil.getEmailPageUpdatedSubjectPrefix(preferences);
        body = WikiUtil.getEmailPageUpdatedBody(preferences);
        signature = WikiUtil.getEmailPageUpdatedSignature(preferences);
    } else {
        subjectPrefix = WikiUtil.getEmailPageAddedSubjectPrefix(preferences);
        body = WikiUtil.getEmailPageAddedBody(preferences);
        signature = WikiUtil.getEmailPageAddedSignature(preferences);
    }

    String subject = page.getTitle();

    if (subject.indexOf(subjectPrefix) == -1) {
        subject = subjectPrefix + StringPool.SPACE + subject;
    }

    if (Validator.isNotNull(signature)) {
        body += "\n" + signature;
    }

    SubscriptionSender subscriptionSender = new SubscriptionSender();

    subscriptionSender.setBody(body);
    subscriptionSender.setCompanyId(page.getCompanyId());
    subscriptionSender.setContextAttributes("[$DIFFS_URL$]", diffsURL, "[$NODE_NAME$]", node.getName(),
            "[$PAGE_DATE_UPDATE$]", page.getModifiedDate(), "[$PAGE_ID$]", page.getPageId(), "[$PAGE_SUMMARY$]",
            page.getSummary(), "[$PAGE_TITLE$]", page.getTitle(), "[$PAGE_URL$]", pageURL);
    subscriptionSender.setContextAttribute("[$PAGE_CONTENT$]", pageContent, false);
    subscriptionSender.setContextAttribute("[$PAGE_DIFFS$]", replaceStyles(pageDiffs), false);
    subscriptionSender.setContextUserPrefix("PAGE");
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);
    subscriptionSender.setMailId("wiki_page", page.getNodeId(), page.getPageId());
    subscriptionSender.setPortletId(PortletKeys.WIKI);
    subscriptionSender.setReplyToAddress(fromAddress);
    subscriptionSender.setScopeGroupId(node.getGroupId());
    subscriptionSender.setServiceContext(serviceContext);
    subscriptionSender.setSubject(subject);
    subscriptionSender.setUserId(page.getUserId());

    subscriptionSender.addPersistedSubscribers(WikiNode.class.getName(), node.getNodeId());
    subscriptionSender.addPersistedSubscribers(WikiPage.class.getName(), page.getResourcePrimKey());

    subscriptionSender.flushNotificationsAsync();
}

From source file:com.liferay.portlet.wiki.service.impl.WikiPageServiceImpl.java

License:Open Source License

protected String exportToRSS(long companyId, String name, String description, String type, double version,
        String displayStyle, String feedURL, String entryURL, List<WikiPage> pages, boolean diff, Locale locale)
        throws SystemException {

    SyndFeed syndFeed = new SyndFeedImpl();

    syndFeed.setFeedType(RSSUtil.getFeedType(type, version));
    syndFeed.setTitle(name);/*from w  w  w . j a va  2s . c o m*/
    syndFeed.setLink(feedURL);
    syndFeed.setDescription(description);

    List<SyndEntry> syndEntries = new ArrayList<SyndEntry>();

    syndFeed.setEntries(syndEntries);

    WikiPage latestPage = null;

    StringBundler link = new StringBundler(7);

    for (WikiPage page : pages) {
        String author = HtmlUtil.escape(PortalUtil.getUserName(page.getUserId(), page.getUserName()));

        String title = page.getTitle() + StringPool.SPACE + page.getVersion();

        if (page.isMinorEdit()) {
            title += StringPool.SPACE + StringPool.OPEN_PARENTHESIS + LanguageUtil.get(locale, "minor-edit")
                    + StringPool.CLOSE_PARENTHESIS;
        }

        link.setIndex(0);

        link.append(entryURL);
        link.append(StringPool.AMPERSAND);
        link.append(HttpUtil.encodeURL(page.getTitle()));

        SyndEntry syndEntry = new SyndEntryImpl();

        syndEntry.setAuthor(author);
        syndEntry.setTitle(title);
        syndEntry.setPublishedDate(page.getCreateDate());
        syndEntry.setUpdatedDate(page.getModifiedDate());

        SyndContent syndContent = new SyndContentImpl();

        syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT);

        if (diff) {
            if (latestPage != null) {
                link.append(StringPool.QUESTION);
                link.append(PortalUtil.getPortletNamespace(PortletKeys.WIKI));
                link.append("version=");
                link.append(page.getVersion());

                String value = getPageDiff(companyId, latestPage, page, locale);

                syndContent.setValue(value);

                syndEntry.setDescription(syndContent);

                syndEntries.add(syndEntry);
            }
        } else {
            String value = null;

            if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_ABSTRACT)) {
                value = StringUtil.shorten(HtmlUtil.extractText(page.getContent()),
                        PropsValues.WIKI_RSS_ABSTRACT_LENGTH, StringPool.BLANK);
            } else if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_TITLE)) {
                value = StringPool.BLANK;
            } else {
                value = page.getContent();
            }

            syndContent.setValue(value);

            syndEntry.setDescription(syndContent);

            syndEntries.add(syndEntry);
        }

        syndEntry.setLink(link.toString());
        syndEntry.setUri(syndEntry.getLink());

        latestPage = page;
    }

    try {
        return RSSUtil.export(syndFeed);
    } catch (FeedException fe) {
        throw new SystemException(fe);
    }
}