List of usage examples for com.liferay.portal.kernel.language LanguageUtil format
public static String format(ResourceBundle resourceBundle, String pattern, Object[] arguments, boolean translateArguments)
From source file:com.liferay.document.library.repository.external.ExtRepositoryAdapter.java
License:Open Source License
@Override public void revertFileEntry(long userId, long fileEntryId, String version, ServiceContext serviceContext) throws PortalException { String extRepositoryFileEntryKey = getExtRepositoryObjectKey(fileEntryId); ExtRepositoryFileEntry extRepositoryFileEntry = _extRepository .getExtRepositoryObject(ExtRepositoryObjectType.FILE, extRepositoryFileEntryKey); ExtRepositoryFileVersion extRepositoryFileVersion = null; List<ExtRepositoryFileVersion> extRepositoryFileVersions = _extRepository .getExtRepositoryFileVersions(extRepositoryFileEntry); for (ExtRepositoryFileVersion curExtRepositoryFileVersion : extRepositoryFileVersions) { String curVersion = curExtRepositoryFileVersion.getVersion(); if (curVersion.equals(version)) { extRepositoryFileVersion = curExtRepositoryFileVersion; break; }/*w w w .j a va2 s. com*/ } if (extRepositoryFileVersion != null) { InputStream inputStream = _extRepository.getContentStream(extRepositoryFileVersion); boolean needsCheckIn = false; if (!isCheckedOut(extRepositoryFileEntry)) { try { _extRepository.checkOutExtRepositoryFileEntry(extRepositoryFileEntryKey); needsCheckIn = true; } catch (UnsupportedOperationException uoe) { } } _extRepository.updateExtRepositoryFileEntry(extRepositoryFileEntryKey, extRepositoryFileVersion.getMimeType(), inputStream); String changeLog = LanguageUtil.format(serviceContext.getLocale(), "reverted-to-x", version, false); if (needsCheckIn) { try { _extRepository.checkInExtRepositoryFileEntry(extRepositoryFileEntryKey, true, changeLog); } catch (UnsupportedOperationException uoe) { } } } else { throw new NoSuchFileVersionException("No file version with {extRepositoryModelKey=" + extRepositoryFileEntry.getExtRepositoryModelKey() + ", version: " + version + "}"); } }
From source file:com.liferay.dynamic.data.lists.form.web.internal.notification.DDLFormEmailNotificationSender.java
License:Open Source License
protected String getEmailSubject(DDLRecordSet recordSet) throws PortalException { DDLRecordSetSettings recordSettings = recordSet.getSettingsModel(); DDMStructure ddmStructure = recordSet.getDDMStructure(); DDMForm ddmForm = ddmStructure.getDDMForm(); Locale locale = ddmForm.getDefaultLocale(); ResourceBundle resourceBundle = ResourceBundleUtil.getBundle("content.Language", locale, getClass()); String defaultEmailSubject = LanguageUtil.format(resourceBundle, "new-x-form-submitted", recordSet.getName(locale), false); return GetterUtil.getString(recordSettings.emailSubject(), defaultEmailSubject); }
From source file:com.liferay.dynamic.data.lists.internal.search.DDLRecordIndexer.java
License:Open Source License
protected String getTitle(long recordSetId, Locale locale) { try {/*from w w w . j av a 2 s .c o m*/ DDLRecordSet recordSet = ddlRecordSetLocalService.getRecordSet(recordSetId); DDMStructure ddmStructure = recordSet.getDDMStructure(); String ddmStructureName = ddmStructure.getName(locale); String recordSetName = recordSet.getName(locale); return LanguageUtil.format(locale, "new-x-for-list-x", new Object[] { ddmStructureName, recordSetName }, false); } catch (Exception e) { _log.error(e, e); } return StringPool.BLANK; }
From source file:com.liferay.dynamic.data.lists.service.impl.DDLRecordLocalServiceImpl.java
License:Open Source License
/** * Updates the record's asset with new asset categories, tag names, and link * entries, removing and adding them as necessary. * * @param userId the primary key of the user updating the record's asset * @param record the record//from ww w .j a v a 2s. c o m * @param recordVersion the record version * @param assetCategoryIds the primary keys of the new asset categories * @param assetTagNames the new asset tag names * @param locale the locale to apply to the asset * @param priority the new priority * @throws PortalException if a portal exception occurred */ @Override public void updateAsset(long userId, DDLRecord record, DDLRecordVersion recordVersion, long[] assetCategoryIds, String[] assetTagNames, Locale locale, Double priority) throws PortalException { DDLRecordSet recordSet = record.getRecordSet(); int scope = recordSet.getScope(); if ((scope != DDLRecordSetConstants.SCOPE_DYNAMIC_DATA_LISTS) && (scope != DDLRecordSetConstants.SCOPE_FORMS) && (scope != DDLRecordSetConstants.SCOPE_KALEO_FORMS)) { return; } boolean addDraftAssetEntry = false; boolean visible = true; if ((recordVersion != null) && !recordVersion.isApproved()) { String version = recordVersion.getVersion(); if (!version.equals(DDLRecordConstants.VERSION_DEFAULT)) { int approvedRecordVersionsCount = ddlRecordVersionPersistence.countByR_S(record.getRecordId(), WorkflowConstants.STATUS_APPROVED); if (approvedRecordVersionsCount > 0) { addDraftAssetEntry = true; } } visible = false; } if (scope == DDLRecordSetConstants.SCOPE_FORMS) { visible = false; } DDMStructure ddmStructure = recordSet.getDDMStructure(); String ddmStructureName = ddmStructure.getName(locale); String recordSetName = recordSet.getName(locale); String title = LanguageUtil.format(locale, "new-x-for-list-x", new Object[] { ddmStructureName, recordSetName }, false); if (addDraftAssetEntry) { assetEntryLocalService.updateEntry(userId, record.getGroupId(), record.getCreateDate(), record.getModifiedDate(), DDLRecordConstants.getClassName(scope), recordVersion.getRecordVersionId(), record.getUuid(), 0, assetCategoryIds, assetTagNames, true, false, null, null, null, null, ContentTypes.TEXT_HTML, title, null, StringPool.BLANK, null, null, 0, 0, priority); } else { Date publishDate = null; if (visible) { publishDate = record.getCreateDate(); } assetEntryLocalService.updateEntry(userId, record.getGroupId(), record.getCreateDate(), record.getModifiedDate(), DDLRecordConstants.getClassName(scope), record.getRecordId(), record.getUuid(), 0, assetCategoryIds, assetTagNames, true, visible, null, null, publishDate, null, ContentTypes.TEXT_HTML, title, null, StringPool.BLANK, null, null, 0, 0, priority); } }
From source file:com.liferay.dynamic.data.lists.web.asset.DDLRecordAssetRenderer.java
License:Open Source License
@Override public String getTitle(Locale locale) { String ddmStructureName = _ddmStructure.getName(locale); String recordSetName = _recordSet.getName(locale); return LanguageUtil.format(locale, "new-x-for-list-x", new Object[] { ddmStructureName, recordSetName }, false);//from w w w . jav a2 s . co m }
From source file:com.liferay.dynamic.data.lists.web.internal.display.context.DDLDisplayContext.java
License:Open Source License
public String getAddRecordLabel() throws PortalException { DDLRecordSet recordSet = getRecordSet(); String structureName = StringPool.BLANK; if (recordSet != null) { DDMStructure ddmStructure = recordSet.getDDMStructure(); structureName = ddmStructure.getName(_ddlRequestHelper.getLocale()); }/*from w w w . ja va2s .c om*/ return LanguageUtil.format(_ddlRequestHelper.getRequest(), "add-x", HtmlUtil.escape(structureName), false); }
From source file:com.liferay.dynamic.data.mapping.data.provider.instance.WorkflowDefinitionsDataProvider.java
License:Open Source License
@Override public DDMDataProviderResponse getData(DDMDataProviderRequest ddmDataProviderRequest) throws DDMDataProviderException { List<KeyValuePair> data = new ArrayList<>(); Locale locale = getLocale(ddmDataProviderRequest.getHttpServletRequest()); data.add(new KeyValuePair("no-workflow", LanguageUtil.get(locale, "no-workflow"))); if (_workflowDefinitionManager == null) { return DDMDataProviderResponse.of(DDMDataProviderResponseOutput.of("Default-Output", "list", data)); }//from w w w . ja v a2 s . co m try { long companyId = getCompanyId(ddmDataProviderRequest.getHttpServletRequest()); List<WorkflowDefinition> workflowDefinitions = _workflowDefinitionManager .getActiveWorkflowDefinitions(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); String languageId = LocaleUtil.toLanguageId(locale); for (WorkflowDefinition workflowDefinition : workflowDefinitions) { String version = LanguageUtil.format(locale, "version-x", workflowDefinition.getVersion(), false); String label = StringBundler.concat(workflowDefinition.getTitle(languageId), " (", version, ")"); String value = workflowDefinition.getName() + StringPool.AT + workflowDefinition.getVersion(); data.add(new KeyValuePair(value, label)); } } catch (WorkflowException we) { throw new DDMDataProviderException(we); } return DDMDataProviderResponse.of(DDMDataProviderResponseOutput.of("Default-Output", "list", data)); }
From source file:com.liferay.dynamic.data.mapping.form.renderer.internal.DDMFormTemplateContextFactoryImpl.java
License:Open Source License
protected String getRequiredFieldsWarningMessageHTML(ResourceBundle resourceBundle) { StringBundler sb = new StringBundler(3); sb.append("<label class=\"required-warning\">"); sb.append(LanguageUtil.format(resourceBundle, "all-fields-marked-with-x-are-required", "<i class=\"icon-asterisk text-warning\"></i>", false)); sb.append("</label>"); return sb.toString(); }
From source file:com.liferay.dynamic.data.mapping.form.web.internal.display.context.DDMFormViewFormInstanceRecordDisplayContext.java
License:Open Source License
protected void setDDMFormFieldRemovedLabel(DDMFormField formField) { Locale locale = _ddmFormAdminRequestHelper.getLocale(); LocalizedValue label = formField.getLabel(); String labelString = label.getString(locale); ResourceBundle resourceBundle = ResourceBundleUtil.getBundle("content.Language", locale, getClass()); label.addString(locale, LanguageUtil.format(resourceBundle, "x-removed", labelString, false)); }
From source file:com.liferay.dynamic.data.mapping.form.web.internal.notification.DDMFormEmailNotificationSender.java
License:Open Source License
protected String getEmailSubject(DDMFormInstance ddmFormInstance) throws PortalException { DDMFormInstanceSettings formInstancetings = ddmFormInstance.getSettingsModel(); DDMStructure ddmStructure = ddmFormInstance.getStructure(); DDMForm ddmForm = ddmStructure.getDDMForm(); Locale locale = ddmForm.getDefaultLocale(); ResourceBundle resourceBundle = ResourceBundleUtil.getBundle("content.Language", locale, getClass()); String defaultEmailSubject = LanguageUtil.format(resourceBundle, "new-x-form-submitted", ddmFormInstance.getName(locale), false); return GetterUtil.getString(formInstancetings.emailSubject(), defaultEmailSubject); }