Example usage for com.liferay.portal.kernel.language LanguageUtil format

List of usage examples for com.liferay.portal.kernel.language LanguageUtil format

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.language LanguageUtil format.

Prototype

public static String format(ResourceBundle resourceBundle, String pattern, Object[] arguments,
            boolean translateArguments) 

Source Link

Usage

From source file:com.liferay.dynamic.data.mapping.internal.search.DDMFormInstanceRecordIndexer.java

License:Open Source License

protected String getTitle(long ddmFormInstanceId, Locale locale) {
    try {//w  w  w .  j  a v  a  2  s  . c  o  m
        DDMFormInstance ddmFormInstance = ddmFormInstanceLocalService.getFormInstance(ddmFormInstanceId);

        DDMStructure ddmStructure = ddmFormInstance.getStructure();

        String ddmStructureName = ddmStructure.getName(locale);

        String ddmFormInstanceName = ddmFormInstance.getName(locale);

        return LanguageUtil.format(locale, "new-x-for-form-x",
                new Object[] { ddmStructureName, ddmFormInstanceName }, false);
    } catch (Exception e) {
        _log.error(e, e);
    }

    return StringPool.BLANK;
}

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

License:Open Source License

protected void updateAsset(long userId, DDMFormInstanceRecord formInstanceRecord,
        DDMFormInstanceRecordVersion formInstanceRecordVersion, long[] assetCategoryIds, String[] assetTagNames,
        Locale locale, Double priority) throws PortalException {

    boolean addDraftAssetEntry = false;

    if ((formInstanceRecordVersion != null) && !formInstanceRecordVersion.isApproved()) {

        String version = formInstanceRecordVersion.getVersion();

        if (!version.equals(_VERSION_DEFAULT)) {
            int approvedRecordVersionsCount = ddmFormInstanceRecordVersionPersistence.countByF_S(
                    formInstanceRecord.getFormInstanceRecordId(), WorkflowConstants.STATUS_APPROVED);

            if (approvedRecordVersionsCount > 0) {
                addDraftAssetEntry = true;
            }/*from   w  w  w  .  ja  va2s .  c  o  m*/
        }
    }

    DDMFormInstance formInstance = formInstanceRecord.getFormInstance();

    DDMStructure ddmStructure = formInstance.getStructure();

    String ddmStructureName = ddmStructure.getName(locale);

    String recordSetName = formInstance.getName(locale);

    String title = LanguageUtil.format(locale, "new-x-for-list-x",
            new Object[] { ddmStructureName, recordSetName }, false);

    if (addDraftAssetEntry) {
        assetEntryLocalService.updateEntry(userId, formInstanceRecord.getGroupId(),
                formInstanceRecord.getCreateDate(), formInstanceRecord.getModifiedDate(),
                DDMFormInstanceRecord.class.getName(),
                formInstanceRecordVersion.getFormInstanceRecordVersionId(), formInstanceRecord.getUuid(), 0,
                assetCategoryIds, assetTagNames, true, false, null, null, null, null, ContentTypes.TEXT_HTML,
                title, null, StringPool.BLANK, null, null, 0, 0, priority);
    } else {
        assetEntryLocalService.updateEntry(userId, formInstanceRecord.getGroupId(),
                formInstanceRecord.getCreateDate(), formInstanceRecord.getModifiedDate(),
                DDMFormInstanceRecord.class.getName(), formInstanceRecord.getFormInstanceRecordId(),
                formInstanceRecord.getUuid(), 0, assetCategoryIds, assetTagNames, true, false, null, null, null,
                null, ContentTypes.TEXT_HTML, title, null, StringPool.BLANK, null, null, 0, 0, priority);
    }
}

From source file:com.liferay.dynamic.data.mapping.util.BaseDDMDisplay.java

License:Open Source License

@Override
public String getEditTemplateTitle(DDMStructure structure, DDMTemplate template, Locale locale) {

    if ((structure != null) && (template != null)) {
        return StringUtil.appendParentheticalSuffix(template.getName(locale), structure.getName(locale));
    } else if (structure != null) {
        ResourceBundle resourceBundle = getResourceBundle(locale);

        return LanguageUtil.format(resourceBundle, "new-template-for-structure-x", structure.getName(locale),
                false);//from w  w  w  .j  av a  2s. c o  m
    } else if (template != null) {
        return template.getName(locale);
    }

    return getDefaultEditTemplateTitle(locale);
}

From source file:com.liferay.dynamic.data.mapping.util.BaseDDMDisplay.java

License:Open Source License

@Override
public String getViewTemplatesTitle(DDMStructure structure, boolean controlPanel, boolean search,
        Locale locale) {/*from   ww w . ja va 2 s .co  m*/

    if (structure != null) {
        ResourceBundle resourceBundle = getResourceBundle(locale);

        return LanguageUtil.format(resourceBundle, "templates-for-structure-x", structure.getName(locale),
                false);
    }

    return getDefaultViewTemplateTitle(locale);
}

From source file:com.liferay.exportimport.staging.StagingImpl.java

License:Open Source License

@Override
public JSONArray getErrorMessagesJSONArray(Locale locale, Map<String, MissingReference> missingReferences) {

    JSONArray errorMessagesJSONArray = JSONFactoryUtil.createJSONArray();

    for (Map.Entry<String, MissingReference> missingReferenceEntry : missingReferences.entrySet()) {

        MissingReference missingReference = missingReferenceEntry.getValue();

        JSONObject errorMessageJSONObject = JSONFactoryUtil.createJSONObject();

        String className = missingReference.getClassName();
        Map<String, String> referrers = missingReference.getReferrers();

        if (className.equals(StagedTheme.class.getName())) {
            errorMessageJSONObject.put("info",
                    LanguageUtil.format(locale,
                            "the-referenced-theme-x-is-not-deployed-in-the-" + "current-environment",
                            missingReference.getClassPK(), false));
        } else if (referrers.size() == 1) {
            Set<Map.Entry<String, String>> referrerDisplayNames = referrers.entrySet();

            Iterator<Map.Entry<String, String>> iterator = referrerDisplayNames.iterator();

            Map.Entry<String, String> entry = iterator.next();

            String referrerDisplayName = entry.getKey();
            String referrerClassName = entry.getValue();

            if (referrerClassName.equals(Portlet.class.getName())) {
                referrerDisplayName = _portal.getPortletTitle(referrerDisplayName, locale);
            }/*from   w  w w  . j  a v  a2 s  . c  o m*/

            errorMessageJSONObject.put("info",
                    LanguageUtil.format(locale, "referenced-by-a-x-x",
                            new String[] { ResourceActionsUtil.getModelResource(locale, referrerClassName),
                                    referrerDisplayName },
                            false));
        } else {
            errorMessageJSONObject.put("info",
                    LanguageUtil.format(locale, "referenced-by-x-elements", referrers.size(), true));
        }

        errorMessageJSONObject.put("name", missingReferenceEntry.getKey());

        Group group = _groupLocalService.fetchGroup(missingReference.getGroupId());

        if (group != null) {
            errorMessageJSONObject.put("site",
                    LanguageUtil.format(locale, "in-site-x", missingReference.getGroupId(), false));
        }

        errorMessageJSONObject.put("type",
                ResourceActionsUtil.getModelResource(locale, missingReference.getClassName()));

        errorMessagesJSONArray.put(errorMessageJSONObject);
    }

    return errorMessagesJSONArray;
}

From source file:com.liferay.exportimport.staging.StagingImpl.java

License:Open Source License

@Override
public JSONObject getExceptionMessagesJSONObject(Locale locale, Exception e,
        ExportImportConfiguration exportImportConfiguration) {

    JSONObject exceptionMessagesJSONObject = JSONFactoryUtil.createJSONObject();

    String errorMessage = StringPool.BLANK;
    JSONArray errorMessagesJSONArray = null;
    int errorType = 0;
    JSONArray warningMessagesJSONArray = null;

    ResourceBundle resourceBundle = ResourceBundleUtil.getBundle("content.Language", locale, getClass());

    Throwable cause = e.getCause();

    if (e instanceof DuplicateFileEntryException) {
        errorMessage = LanguageUtil.get(locale, "please-enter-a-unique-document-name");
        errorType = ServletResponseConstants.SC_DUPLICATE_FILE_EXCEPTION;
    } else if (e instanceof FileExtensionException) {
        errorMessage = LanguageUtil.format(locale,
                "document-names-must-end-with-one-of-the-following-extensions", ".lar", false);
        errorType = ServletResponseConstants.SC_FILE_EXTENSION_EXCEPTION;
    } else if (e instanceof FileNameException) {
        errorMessage = LanguageUtil.get(locale, "please-enter-a-file-with-a-valid-file-name");
        errorType = ServletResponseConstants.SC_FILE_NAME_EXCEPTION;
    } else if (e instanceof FileSizeException || e instanceof LARFileSizeException) {

        if ((exportImportConfiguration != null) && ((exportImportConfiguration
                .getType() == ExportImportConfigurationConstants.TYPE_PUBLISH_LAYOUT_LOCAL)
                || (exportImportConfiguration
                        .getType() == ExportImportConfigurationConstants.TYPE_PUBLISH_LAYOUT_REMOTE)
                || (exportImportConfiguration
                        .getType() == ExportImportConfigurationConstants.TYPE_PUBLISH_PORTLET))) {

            errorMessage = LanguageUtil.get(locale,
                    "file-size-limit-exceeded.-please-ensure-that-the-file-"
                            + "does-not-exceed-the-file-size-limit-in-both-the-"
                            + "live-environment-and-the-staging-environment");
        } else {/*w  w w.j a va  2s  . c o m*/
            errorMessage = LanguageUtil.format(locale,
                    "please-enter-a-file-with-a-valid-file-size-no-larger-" + "than-x",
                    TextFormatter.formatStorageSize(_dlValidator.getMaxAllowableSize(), locale), false);
        }

        errorType = ServletResponseConstants.SC_FILE_SIZE_EXCEPTION;
    } else if (e instanceof LARTypeException) {
        LARTypeException lte = (LARTypeException) e;

        if (lte.getType() == LARTypeException.TYPE_COMPANY_GROUP) {
            errorMessage = LanguageUtil.format(resourceBundle, "a-x-can-only-be-imported-to-a-x",
                    "global-site");
        } else if (lte.getType() == LARTypeException.TYPE_LAYOUT_PROTOTYPE) {
            errorMessage = LanguageUtil.format(resourceBundle, "a-x-can-only-be-imported-to-a-x",
                    LanguageUtil.get(locale, "page-template"));
        } else if (lte.getType() == LARTypeException.TYPE_LAYOUT_SET) {
            errorMessage = LanguageUtil.format(resourceBundle, "a-x-can-only-be-imported-to-a-x", "site");
        } else if (lte.getType() == LARTypeException.TYPE_LAYOUT_SET_PROTOTYPE) {

            errorMessage = LanguageUtil.format(resourceBundle, "a-x-can-only-be-imported-to-a-x",
                    LanguageUtil.get(locale, "site-template"));
        } else {
            errorMessage = LanguageUtil.format(resourceBundle, "uploaded-lar-file-type-x-does-not-match-x",
                    new Object[] { lte.getActualLARType(),
                            StringUtil.merge(lte.getExpectedLARTypes(), StringPool.COMMA_AND_SPACE) });
        }

        errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION;
    } else if (e instanceof LARFileException) {
        LARFileException lfe = (LARFileException) e;

        if (lfe.getType() == LARFileException.TYPE_INVALID_MANIFEST) {
            errorMessage = LanguageUtil.format(resourceBundle, "invalid-manifest.xml-x", lfe.getMessage());
        } else if (lfe.getType() == LARFileException.TYPE_MISSING_MANIFEST) {
            errorMessage = LanguageUtil.get(resourceBundle, "missing-manifest.xml");
        } else {
            errorMessage = LanguageUtil.get(locale, "please-specify-a-lar-file-to-import");
        }

        errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION;
    } else if (e instanceof LayoutImportException || cause instanceof LayoutImportException) {

        LayoutImportException lie = null;

        if (e instanceof LayoutImportException) {
            lie = (LayoutImportException) e;
        } else {
            lie = (LayoutImportException) cause;
        }

        if (lie.getType() == LayoutImportException.TYPE_WRONG_BUILD_NUMBER) {

            errorMessage = LanguageUtil.format(resourceBundle,
                    "lar-build-number-x-does-not-match-portal-build-number-x", lie.getArguments());
        } else if (lie.getType() == LayoutImportException.TYPE_WRONG_LAR_SCHEMA_VERSION) {

            errorMessage = LanguageUtil.format(resourceBundle,
                    "lar-schema-version-x-does-not-match-deployed-export-" + "import-schema-version-x",
                    lie.getArguments());
        } else if (lie.getType() == LayoutImportException.TYPE_WRONG_PORTLET_SCHEMA_VERSION) {

            Object[] arguments = lie.getArguments();

            Portlet portlet = _portletLocalService.getPortletById((String) arguments[1]);

            arguments[1] = portlet.getDisplayName();

            errorMessage = LanguageUtil.format(resourceBundle,
                    "portlet's-schema-version-x-in-the-lar-is-not-valid-for-"
                            + "the-deployed-portlet-x-with-schema-version-x",
                    lie.getArguments());
        } else {
            errorMessage = e.getLocalizedMessage();
        }

        errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION;
    } else if (e instanceof LayoutPrototypeException) {
        LayoutPrototypeException lpe = (LayoutPrototypeException) e;

        StringBundler sb = new StringBundler(4);

        sb.append("the-lar-file-could-not-be-imported-because-it-");
        sb.append("requires-page-templates-or-site-templates-that-could-");
        sb.append("not-be-found.-please-import-the-following-templates-");
        sb.append("manually");

        errorMessage = LanguageUtil.get(resourceBundle, sb.toString());

        errorMessagesJSONArray = JSONFactoryUtil.createJSONArray();

        List<Tuple> missingLayoutPrototypes = lpe.getMissingLayoutPrototypes();

        for (Tuple missingLayoutPrototype : missingLayoutPrototypes) {
            JSONObject errorMessageJSONObject = JSONFactoryUtil.createJSONObject();

            String layoutPrototypeUuid = (String) missingLayoutPrototype.getObject(1);

            errorMessageJSONObject.put("info", layoutPrototypeUuid);

            String layoutPrototypeName = (String) missingLayoutPrototype.getObject(2);

            errorMessageJSONObject.put("name", layoutPrototypeName);

            String layoutPrototypeClassName = (String) missingLayoutPrototype.getObject(0);

            errorMessageJSONObject.put("type",
                    ResourceActionsUtil.getModelResource(locale, layoutPrototypeClassName));

            errorMessagesJSONArray.put(errorMessageJSONObject);
        }

        errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION;
    } else if (e instanceof LocaleException) {
        LocaleException le = (LocaleException) e;

        errorMessage = LanguageUtil.format(locale,
                "the-available-languages-in-the-lar-file-x-do-not-match-the-" + "site's-available-languages-x",
                new String[] { StringUtil.merge(le.getSourceAvailableLocales(), StringPool.COMMA_AND_SPACE),
                        StringUtil.merge(le.getTargetAvailableLocales(), StringPool.COMMA_AND_SPACE) },
                false);

        errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION;
    } else if (e instanceof MissingReferenceException) {
        MissingReferenceException mre = (MissingReferenceException) e;

        if ((exportImportConfiguration != null) && ((exportImportConfiguration
                .getType() == ExportImportConfigurationConstants.TYPE_PUBLISH_LAYOUT_LOCAL)
                || (exportImportConfiguration
                        .getType() == ExportImportConfigurationConstants.TYPE_PUBLISH_LAYOUT_REMOTE)
                || (exportImportConfiguration
                        .getType() == ExportImportConfigurationConstants.TYPE_PUBLISH_PORTLET))) {

            errorMessage = LanguageUtil.get(locale, "there-are-missing-references-that-could-not-be-found-in-"
                    + "the-live-environment-the-following-elements-are-" + "published-from-their-own-site");
        } else {
            errorMessage = LanguageUtil.get(locale,
                    "there-are-missing-references-that-could-not-be-found-in-" + "the-current-site");
        }

        MissingReferences missingReferences = mre.getMissingReferences();

        errorMessagesJSONArray = getErrorMessagesJSONArray(locale,
                missingReferences.getDependencyMissingReferences());

        errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION;
        warningMessagesJSONArray = getWarningMessagesJSONArray(locale,
                missingReferences.getWeakMissingReferences());
    } else if (e instanceof PortletDataException) {
        PortletDataException pde = (PortletDataException) e;

        String referrerClassName = pde.getStagedModelClassName();
        String referrerDisplayName = pde.getStagedModelDisplayName();

        String modelResource = ResourceActionsUtil.getModelResource(locale, referrerClassName);

        if (pde.getType() == PortletDataException.DELETE_PORTLET_DATA) {
            if (Validator.isNotNull(pde.getLocalizedMessage())) {
                errorMessage = LanguageUtil.format(locale,
                        "the-following-error-in-x-while-deleting-its-data-" + "has-stopped-the-process-x",
                        new String[] { _portal.getPortletTitle(pde.getPortletId(), locale),
                                pde.getLocalizedMessage() },
                        false);
            } else {
                errorMessage = LanguageUtil.format(locale,
                        "an-unexpected-error-in-x-while-deleting-its-data-" + "has-stopped-the-process",
                        new String[] { _portal.getPortletTitle(pde.getPortletId(), locale) }, false);
            }
        } else if (pde.getType() == PortletDataException.EXPORT_PORTLET_DATA) {

            if (Validator.isNotNull(pde.getLocalizedMessage())) {
                errorMessage = LanguageUtil.format(locale,
                        "the-following-error-in-x-while-exporting-its-data-" + "has-stopped-the-process-x",
                        new String[] { _portal.getPortletTitle(pde.getPortletId(), locale),
                                pde.getLocalizedMessage() },
                        false);
            } else {
                errorMessage = LanguageUtil.format(locale,
                        "an-unexpected-error-in-x-while-exporting-its-data-" + "has-stopped-the-process",
                        new String[] { _portal.getPortletTitle(pde.getPortletId(), locale) }, false);
            }
        } else if (pde.getType() == PortletDataException.IMPORT_PORTLET_DATA) {

            if (Validator.isNotNull(pde.getLocalizedMessage())) {
                errorMessage = LanguageUtil.format(locale,
                        "the-following-error-in-x-while-importing-its-data-" + "has-stopped-the-process-x",
                        new String[] { _portal.getPortletTitle(pde.getPortletId(), locale),
                                pde.getLocalizedMessage() },
                        false);
            } else {
                errorMessage = LanguageUtil.format(locale,
                        "an-unexpected-error-in-x-while-importing-its-data-" + "has-stopped-the-process",
                        new String[] { _portal.getPortletTitle(pde.getPortletId(), locale) }, false);
            }
        } else if (pde.getType() == PortletDataException.INVALID_GROUP) {
            errorMessage = LanguageUtil.format(locale,
                    "the-x-x-could-not-be-exported-because-it-is-not-in-the-" + "currently-exported-group",
                    new String[] { modelResource, referrerDisplayName }, false);
        } else if (pde.getType() == PortletDataException.MISSING_DEPENDENCY) {
            errorMessage = LanguageUtil.format(locale,
                    "the-x-x-has-missing-references-that-could-not-be-found-" + "during-the-process",
                    new String[] { modelResource, referrerDisplayName }, false);
        } else if (pde.getType() == PortletDataException.PREPARE_MANIFEST_SUMMARY) {

            if (Validator.isNotNull(pde.getLocalizedMessage())) {
                errorMessage = LanguageUtil.format(locale,
                        "the-following-error-in-x-while-preparing-its-" + "manifest-has-stopped-the-process-x",
                        new String[] { _portal.getPortletTitle(pde.getPortletId(), locale),
                                pde.getLocalizedMessage() },
                        false);
            } else {
                errorMessage = LanguageUtil.format(locale,
                        "an-unexpected-error-in-x-while-preparing-its-" + "manifest-has-stopped-the-process",
                        new String[] { _portal.getPortletTitle(pde.getPortletId(), locale) }, false);
            }
        } else if (pde.getType() == PortletDataException.STATUS_IN_TRASH) {
            errorMessage = LanguageUtil.format(locale,
                    "the-x-x-could-not-be-exported-because-it-is-in-the-" + "recycle-bin",
                    new String[] { modelResource, referrerDisplayName }, false);
        } else if (pde.getType() == PortletDataException.STATUS_UNAVAILABLE) {
            errorMessage = LanguageUtil.format(locale,
                    "the-x-x-could-not-be-exported-because-its-workflow-" + "status-is-not-exportable",
                    new String[] { modelResource, referrerDisplayName }, false);
        } else if (Validator.isNotNull(referrerDisplayName)) {
            errorMessage = LanguageUtil.format(resourceBundle,
                    "the-following-error-occurred-while-processing-the-x-x-x",
                    new String[] { modelResource, referrerDisplayName, e.getLocalizedMessage() });
        } else {
            errorMessage = e.getLocalizedMessage();
        }

        errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION;
    } else if (e instanceof PortletIdException) {
        PortletIdException pie = (PortletIdException) e;

        Portlet portlet = _portletLocalService.getPortletById(pie.getMessage());

        errorMessage = LanguageUtil.format(resourceBundle, "a-x-can-only-be-imported-to-a-x",
                portlet.getDisplayName() + " Portlet");

        errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION;
    } else {
        errorMessage = e.getLocalizedMessage();
        errorType = ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION;
    }

    exceptionMessagesJSONObject.put("message", errorMessage);

    if ((errorMessagesJSONArray != null) && (errorMessagesJSONArray.length() > 0)) {

        exceptionMessagesJSONObject.put("messageListItems", errorMessagesJSONArray);
    }

    exceptionMessagesJSONObject.put("status", errorType);

    if ((warningMessagesJSONArray != null) && (warningMessagesJSONArray.length() > 0)) {

        exceptionMessagesJSONObject.put("warningMessages", warningMessagesJSONArray);
    }

    return exceptionMessagesJSONObject;
}

From source file:com.liferay.exportimport.staging.StagingImpl.java

License:Open Source License

@Override
public JSONArray getWarningMessagesJSONArray(Locale locale, Map<String, MissingReference> missingReferences) {

    JSONArray warningMessagesJSONArray = JSONFactoryUtil.createJSONArray();

    for (Map.Entry<String, MissingReference> entry : missingReferences.entrySet()) {

        MissingReference missingReference = entry.getValue();

        Map<String, String> referrers = missingReference.getReferrers();

        JSONObject errorMessageJSONObject = JSONFactoryUtil.createJSONObject();

        if (Validator.isNotNull(missingReference.getClassName())) {
            errorMessageJSONObject.put("info",
                    LanguageUtil.format(locale, "the-original-x-does-not-exist-in-the-current-" + "environment",
                            ResourceActionsUtil.getModelResource(locale, missingReference.getClassName()),
                            false));/*from   w w  w. ja v  a  2s  . c om*/
        }

        errorMessageJSONObject.put("size", referrers.size());
        errorMessageJSONObject.put("type", ResourceActionsUtil.getModelResource(locale, entry.getKey()));

        warningMessagesJSONArray.put(errorMessageJSONObject);
    }

    return warningMessagesJSONArray;
}

From source file:com.liferay.journal.content.search.web.internal.display.context.JournalContentSearchDisplayContext.java

License:Open Source License

public SearchContainer getSearchContainer() throws Exception {
    if (_searchContainer != null) {
        return _searchContainer;
    }//from  w  ww . j ava  2  s . co  m

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

    Layout layout = themeDisplay.getLayout();

    PortletURL renderURL = _liferayPortletResponse.createRenderURL();

    renderURL.setParameter("mvcPath", "/search.jsp");
    renderURL.setParameter("keywords", getKeywords());

    String originalKeywords = ParamUtil.getString(_request, "keywords", getKeywords());

    _searchContainer = new SearchContainer(_liferayPortletRequest, null, null,
            SearchContainer.DEFAULT_CUR_PARAM, SearchContainer.DEFAULT_DELTA, renderURL, null,
            LanguageUtil.format(_request, "no-pages-were-found-that-matched-the-keywords-x",
                    "<strong>" + HtmlUtil.escape(originalKeywords) + "</strong>", false));

    Hits hits = getHits();

    ContentHits contentHits = new ContentHits();

    contentHits.setShowListed(_journalContentSearchPortletInstanceConfiguration.showListed());

    contentHits.recordHits(hits, layout.getGroupId(), layout.isPrivateLayout(), _searchContainer.getStart(),
            _searchContainer.getEnd());

    _searchContainer.setTotal(hits.getLength());
    _searchContainer.setResults(ListUtil.toList(hits.getDocs()));

    return _searchContainer;
}

From source file:com.liferay.knowledgebase.admin.util.AdminSubscriptionSender.java

License:Open Source License

@Override
protected String replaceContent(String content, Locale locale) throws Exception {

    String kbArticleAttachments = getEmailKBArticleAttachments(locale);
    String kbArticleURL = KnowledgeBaseUtil.getKBArticleURL(_serviceContext.getPlid(),
            _kbArticle.getResourcePrimKey(), _kbArticle.getStatus(), _serviceContext.getPortalURL(), false);
    String kbArticleVersion = LanguageUtil.format(locale, "version-x", String.valueOf(_kbArticle.getVersion()),
            false);/*from  w ww  .  j  av  a2s. com*/
    String categoryTitle = LanguageUtil.get(locale, "category.kb");

    setContextAttribute("[$ARTICLE_ATTACHMENTS$]", kbArticleAttachments);
    setContextAttribute("[$ARTICLE_URL$]", kbArticleURL);
    setContextAttribute("[$ARTICLE_VERSION$]", kbArticleVersion);
    setContextAttribute("[$CATEGORY_TITLE$]", categoryTitle);

    return super.replaceContent(content, locale);
}

From source file:com.liferay.mentions.portlet.notifications.MentionsUserNotificationHandler.java

License:Open Source License

@Override
protected String getTitle(JSONObject jsonObject, AssetRenderer assetRenderer, ServiceContext serviceContext) {

    MBMessage mbMessage = MBMessageLocalServiceUtil.fetchMBMessage(jsonObject.getLong("classPK"));

    AssetRendererFactory assetRendererFactory = AssetRendererFactoryRegistryUtil
            .getAssetRendererFactoryByClassName(assetRenderer.getClassName());

    String typeName = assetRendererFactory.getTypeName(serviceContext.getLocale());

    if ((mbMessage != null) && mbMessage.isDiscussion()) {
        return LanguageUtil.format(serviceContext.getLocale(), "x-mentioned-you-in-a-comment-in-a-x",
                new String[] { HtmlUtil.escape(assetRenderer.getUserName()),
                        StringUtil.toLowerCase(HtmlUtil.escape(typeName)) },
                false);//w  w w.  j  a  v a 2 s  .  c  o m
    } else {
        return LanguageUtil.format(serviceContext.getLocale(), "x-mentioned-you-in-a-x",
                new String[] { HtmlUtil.escape(assetRenderer.getUserName()),
                        StringUtil.toLowerCase(HtmlUtil.escape(typeName)) },
                false);
    }
}