List of usage examples for com.liferay.portal.kernel.language LanguageUtil get
public static String get(ResourceBundle resourceBundle, String key)
From source file:com.liferay.content.targeting.rule.facebook.FacebookEducationRule.java
License:Open Source License
@Override public String getSummary(RuleInstance ruleInstance, Locale locale) { String typeSettings = ruleInstance.getTypeSettings(); String summary = StringPool.BLANK; try {//from ww w .j a v a 2s . c o m JSONObject jsonObj = JSONFactoryUtil.createJSONObject(typeSettings); String educationLevel = jsonObj.getString("educationLevel"); String schoolName = jsonObj.getString("schoolName"); StringBundler sb = new StringBundler(); if (Validator.isNotNull(educationLevel)) { sb.append(LanguageUtil.get(locale, "education-level")); sb.append(StringPool.COLON); sb.append(LanguageUtil.get(locale, educationLevel)); sb.append(StringPool.PERIOD); sb.append(StringPool.SPACE); } if (Validator.isNotNull(schoolName)) { sb.append(LanguageUtil.get(locale, "college-high-school-name")); sb.append(StringPool.COLON); sb.append(schoolName); } } catch (JSONException jse) { } return summary; }
From source file:com.liferay.content.targeting.util.UserSegmentUtil.java
License:Open Source License
public static Map<Locale, String> getAssetVocabularyDescription() { Map<Locale, String> descriptionMap = new HashMap<Locale, String>(); Locale[] locales = LanguageUtil.getAvailableLocales(); for (Locale locale : locales) { descriptionMap.put(locale, LanguageUtil.get(locale, UserSegmentConstants.VOCABULARY_DESCRIPTION)); }/* ww w .j av a 2 s . c o m*/ return descriptionMap; }
From source file:com.liferay.content.targeting.util.UserSegmentUtil.java
License:Open Source License
public static String getAssetVocabularyName() { return LanguageUtil.get(LocaleUtil.getDefault(), UserSegmentConstants.VOCABULARY_NAME); }
From source file:com.liferay.content.targeting.util.UserSegmentUtil.java
License:Open Source License
public static Map<Locale, String> getAssetVocabularyTitle() { Map<Locale, String> titleMap = new HashMap<Locale, String>(); Locale[] locales = LanguageUtil.getAvailableLocales(); for (Locale locale : locales) { titleMap.put(locale, LanguageUtil.get(locale, UserSegmentConstants.VOCABULARY_NAME)); }/*from w w w .j a v a 2 s .c om*/ return titleMap; }
From source file:com.liferay.document.library.internal.instance.lifecycle.AddDefaultDocumentLibraryStructuresPortalInstanceLifecycleListener.java
License:Open Source License
protected void addDLFileEntryType(long userId, long groupId, String languageKey, String dlFileEntryTypeKey, List<String> ddmStructureNames, ServiceContext serviceContext) throws Exception { List<Long> ddmStructureIds = new ArrayList<>(); for (String ddmStructureName : ddmStructureNames) { String ddmStructureKey = ddmStructureName; DDMStructure ddmStructure = _ddmStructureLocalService.fetchStructure(groupId, _portal.getClassNameId(DLFileEntryMetadata.class), ddmStructureKey); if (ddmStructure == null) { continue; }/* ww w .j a v a2 s .c o m*/ ddmStructureIds.add(ddmStructure.getStructureId()); } Locale locale = _portal.getSiteDefaultLocale(groupId); String definition = _defaultDDMStructureHelper.getDynamicDDMStructureDefinition(getClassLoader(), "com/liferay/document/library/events/dependencies" + "/document-library-structures.xml", languageKey, locale); DDMForm ddmForm = _ddmFormXSDDeserializer.deserialize(definition); serviceContext.setAttribute("ddmForm", _ddmBeanTranslator.translate(ddmForm)); DLFileEntryType dlFileEntryType = _dlFileEntryTypeLocalService.fetchFileEntryType(groupId, dlFileEntryTypeKey); if (dlFileEntryType == null) { Map<Locale, String> localizationMap = new HashMap<>(); for (Locale curLocale : LanguageUtil.getAvailableLocales(groupId)) { localizationMap.put(curLocale, LanguageUtil.get(curLocale, languageKey)); } _dlFileEntryTypeLocalService.addFileEntryType(userId, groupId, dlFileEntryTypeKey, localizationMap, localizationMap, ArrayUtil.toArray(ddmStructureIds.toArray(new Long[ddmStructureIds.size()])), serviceContext); } }
From source file:com.liferay.document.library.internal.service.SubscriptionDLAppHelperLocalServiceWrapper.java
License:Open Source License
protected void notifySubscribers(long userId, FileVersion fileVersion, String entryURL, ServiceContext serviceContext) throws PortalException { if (!fileVersion.isApproved() || Validator.isNull(entryURL)) { return;/*from ww w . j a v a 2 s.c o m*/ } DLGroupServiceSettings dlGroupServiceSettings = DLGroupServiceSettings .getInstance(fileVersion.getGroupId()); boolean commandUpdate = false; if (serviceContext.isCommandUpdate() || Constants.CHECKIN.equals(serviceContext.getCommand())) { commandUpdate = true; } if (serviceContext.isCommandAdd() && dlGroupServiceSettings.isEmailFileEntryAddedEnabled()) { } else if (commandUpdate && dlGroupServiceSettings.isEmailFileEntryUpdatedEnabled()) { } else { return; } String entryTitle = fileVersion.getTitle(); String fromName = dlGroupServiceSettings.getEmailFromName(); String fromAddress = dlGroupServiceSettings.getEmailFromAddress(); LocalizedValuesMap subjectLocalizedValuesMap = null; LocalizedValuesMap bodyLocalizedValuesMap = null; if (commandUpdate) { subjectLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryUpdatedSubject(); bodyLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryUpdatedBody(); } else { subjectLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryAddedSubject(); bodyLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryAddedBody(); } FileEntry fileEntry = fileVersion.getFileEntry(); Folder folder = null; long folderId = fileEntry.getFolderId(); if (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) { folder = _dlAppLocalService.getFolder(folderId); } SubscriptionSender subscriptionSender = new GroupSubscriptionCheckSubscriptionSender( DLPermission.RESOURCE_NAME); DLFileEntry dlFileEntry = (DLFileEntry) fileEntry.getModel(); DLFileEntryType dlFileEntryType = _dlFileEntryTypeLocalService .getDLFileEntryType(dlFileEntry.getFileEntryTypeId()); subscriptionSender.setClassPK(fileVersion.getFileEntryId()); subscriptionSender.setClassName(DLFileEntryConstants.getClassName()); subscriptionSender.setCompanyId(fileVersion.getCompanyId()); if (folder != null) { subscriptionSender.setContextAttribute("[$FOLDER_NAME$]", folder.getName(), true); } else { subscriptionSender.setLocalizedContextAttribute("[$FOLDER_NAME$]", new EscapableLocalizableFunction(locale -> LanguageUtil.get(locale, "home"))); } subscriptionSender.setContextAttributes("[$DOCUMENT_STATUS_BY_USER_NAME$]", fileVersion.getStatusByUserName(), "[$DOCUMENT_TITLE$]", entryTitle, "[$DOCUMENT_URL$]", entryURL); subscriptionSender.setContextCreatorUserPrefix("DOCUMENT"); subscriptionSender.setCreatorUserId(fileVersion.getUserId()); subscriptionSender.setCurrentUserId(userId); subscriptionSender.setEntryTitle(entryTitle); subscriptionSender.setEntryURL(entryURL); subscriptionSender.setFrom(fromAddress, fromName); subscriptionSender.setHtmlFormat(true); subscriptionSender.setLocalizedBodyMap(LocalizationUtil.getMap(bodyLocalizedValuesMap)); subscriptionSender.setLocalizedContextAttribute("[$DOCUMENT_TYPE$]", new EscapableLocalizableFunction(locale -> dlFileEntryType.getName(locale))); subscriptionSender.setLocalizedSubjectMap(LocalizationUtil.getMap(subjectLocalizedValuesMap)); subscriptionSender.setMailId("file_entry", fileVersion.getFileEntryId()); int notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_ADD_ENTRY; if (commandUpdate) { notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_UPDATE_ENTRY; } subscriptionSender.setNotificationType(notificationType); String portletId = PortletProviderUtil.getPortletId(FileEntry.class.getName(), PortletProvider.Action.VIEW); subscriptionSender.setPortletId(portletId); subscriptionSender.setReplyToAddress(fromAddress); subscriptionSender.setScopeGroupId(fileVersion.getGroupId()); subscriptionSender.setServiceContext(serviceContext); subscriptionSender.addPersistedSubscribers(DLFolder.class.getName(), fileVersion.getGroupId()); if (folder != null) { subscriptionSender.addPersistedSubscribers(DLFolder.class.getName(), folder.getFolderId()); for (Long ancestorFolderId : folder.getAncestorFolderIds()) { subscriptionSender.addPersistedSubscribers(DLFolder.class.getName(), ancestorFolderId); } } if (dlFileEntryType.getFileEntryTypeId() == DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT) { subscriptionSender.addPersistedSubscribers(DLFileEntryType.class.getName(), fileVersion.getGroupId()); } else { subscriptionSender.addPersistedSubscribers(DLFileEntryType.class.getName(), dlFileEntryType.getFileEntryTypeId()); } subscriptionSender.addPersistedSubscribers(DLFileEntry.class.getName(), fileEntry.getFileEntryId()); subscriptionSender.flushNotificationsAsync(); }
From source file:com.liferay.document.library.web.asset.DLFileEntryAssetRendererFactory.java
License:Open Source License
@Override public String getSubtypeTitle(Locale locale) { return LanguageUtil.get(locale, "type"); }
From source file:com.liferay.document.library.web.internal.display.context.DefaultDLViewFileVersionDisplayContext.java
License:Open Source License
@Override public String getDiscussionLabel(Locale locale) { return LanguageUtil.get(_resourceBundle, "comments"); }
From source file:com.liferay.document.library.web.internal.display.context.logic.DLPortletInstanceSettingsHelper.java
License:Open Source License
private void _populateDisplayViews() { DLPortletInstanceSettings dlPortletInstanceSettings = _dlRequestHelper.getDLPortletInstanceSettings(); String[] displayViews = dlPortletInstanceSettings.getDisplayViews(); _currentDisplayViews = new ArrayList<>(); for (String displayView : displayViews) { _currentDisplayViews.add(//from www . j ava 2 s .c om new KeyValuePair(displayView, LanguageUtil.get(_dlRequestHelper.getLocale(), displayView))); } Arrays.sort(displayViews); _availableDisplayViews = new ArrayList<>(); Set<String> allDisplayViews = SetUtil.fromArray(PropsValues.DL_DISPLAY_VIEWS); for (String displayView : allDisplayViews) { if (Arrays.binarySearch(displayViews, displayView) < 0) { _availableDisplayViews.add( new KeyValuePair(displayView, LanguageUtil.get(_dlRequestHelper.getLocale(), displayView))); } } _availableDisplayViews = ListUtil.sort(_availableDisplayViews, new KeyValuePairComparator(false, true)); }
From source file:com.liferay.document.library.web.internal.display.context.logic.DLPortletInstanceSettingsHelper.java
License:Open Source License
private void _populateEntryColumns() { DLPortletInstanceSettings dlPortletInstanceSettings = _dlRequestHelper.getDLPortletInstanceSettings(); String[] entryColumns = dlPortletInstanceSettings.getEntryColumns(); _currentEntryColumns = new ArrayList<>(); for (String entryColumn : entryColumns) { _currentEntryColumns.add(// w ww. ja va2 s. co m new KeyValuePair(entryColumn, LanguageUtil.get(_dlRequestHelper.getLocale(), entryColumn))); } Arrays.sort(entryColumns); _availableEntryColumns = new ArrayList<>(); Set<String> allEntryColumns = SetUtil.fromArray(_getAllEntryColumns()); for (String entryColumn : allEntryColumns) { if (Arrays.binarySearch(entryColumns, entryColumn) < 0) { _availableEntryColumns.add( new KeyValuePair(entryColumn, LanguageUtil.get(_dlRequestHelper.getLocale(), entryColumn))); } } _availableEntryColumns = ListUtil.sort(_availableEntryColumns, new KeyValuePairComparator(false, true)); }