List of usage examples for com.liferay.portal.kernel.util ListUtil toString
public static String toString(List<?> list, String param, String delimiter)
From source file:com.liferay.asset.publisher.web.internal.messaging.AssetEntriesCheckerUtil.java
License:Open Source License
private static SubscriptionSender _getSubscriptionSender(PortletPreferences portletPreferences, List<AssetEntry> assetEntries) { if (assetEntries.isEmpty()) { return null; }/*from w ww . jav a 2 s .c o m*/ AssetEntry assetEntry = assetEntries.get(0); String fromName = _assetPublisherWebUtil.getEmailFromName(portletPreferences, assetEntry.getCompanyId()); String fromAddress = _assetPublisherWebUtil.getEmailFromAddress(portletPreferences, assetEntry.getCompanyId()); Map<Locale, String> localizedSubjectMap = _assetPublisherWebUtil .getEmailAssetEntryAddedSubjectMap(portletPreferences); Map<Locale, String> localizedBodyMap = _assetPublisherWebUtil .getEmailAssetEntryAddedBodyMap(portletPreferences); SubscriptionSender subscriptionSender = new SubscriptionSender(); subscriptionSender.setCompanyId(assetEntry.getCompanyId()); subscriptionSender.setContextAttributes("[$ASSET_ENTRIES$]", ListUtil.toString(assetEntries, _titleAccessor, StringPool.COMMA_AND_SPACE)); subscriptionSender.setFrom(fromAddress, fromName); subscriptionSender.setHtmlFormat(true); subscriptionSender.setLocalizedBodyMap(localizedBodyMap); subscriptionSender .setLocalizedPortletTitleMap(PortletConfigurationUtil.getPortletTitleMap(portletPreferences)); subscriptionSender.setLocalizedSubjectMap(localizedSubjectMap); subscriptionSender.setMailId("asset_entry", assetEntry.getEntryId()); subscriptionSender.setPortletId(AssetPublisherPortletKeys.ASSET_PUBLISHER); subscriptionSender.setReplyToAddress(fromAddress); return subscriptionSender; }
From source file:com.liferay.dynamic.data.mapping.render.BaseDDMFormFieldValueRenderer.java
License:Open Source License
@Override public String render(List<DDMFormFieldValue> ddmFormFieldValues, Locale locale) { ValueAccessor valueAccessor = getValueAcessor(locale); return ListUtil.toString(ddmFormFieldValues, valueAccessor, StringPool.COMMA_AND_SPACE); }
From source file:com.liferay.dynamic.data.mapping.test.util.search.TestOrderHelper.java
License:Open Source License
protected String getValue(AssetRenderer<?> assetRenderer) throws Exception { DDMFormValuesReader ddmFormValuesReader = assetRenderer.getDDMFormValuesReader(); DDMFormValues ddmFormValues = DDMBeanTranslatorUtil.translate(ddmFormValuesReader.getDDMFormValues()); Map<String, List<DDMFormFieldValue>> ddmFormFieldValuesMap = ddmFormValues.getDDMFormFieldValuesMap(); return ListUtil.toString(ddmFormFieldValuesMap.get("name"), new ValueAccessor(LocaleUtil.getDefault()) { @Override//from ww w . j a va 2 s . c o m public String get(DDMFormFieldValue ddmFormFieldValue) { Value value = ddmFormFieldValue.getValue(); return value.getString(locale); } }, StringPool.PIPE); }
From source file:com.liferay.frontend.js.spa.web.internal.servlet.taglib.util.SPAUtil.java
License:Open Source License
@Activate protected void activate(BundleContext bundleContext, Map<String, Object> properties) throws InvalidSyntaxException { _spaConfiguration = ConfigurableUtil.createConfigurable(SPAConfiguration.class, properties); _cacheExpirationTime = _getCacheExpirationTime(_spaConfiguration); Collections.addAll(_navigationExceptionSelectors, _spaConfiguration.navigationExceptionSelectors()); _navigationExceptionSelectorsString = ListUtil.toString(_navigationExceptionSelectors, (String) null, StringPool.BLANK);//from www . j a va 2 s .c o m Filter filter = bundleContext.createFilter( "(&(objectClass=java.lang.Object)(" + _SPA_NAVIGATION_EXCEPTION_SELECTOR_KEY + "=*))"); _navigationExceptionSelectorTracker = new ServiceTracker<>(bundleContext, filter, new NavigationExceptionSelectorTrackerCustomizer(bundleContext)); _navigationExceptionSelectorTracker.open(); }
From source file:com.liferay.frontend.js.spa.web.internal.servlet.taglib.util.SPAUtil.java
License:Open Source License
@Modified protected void modified(Map<String, Object> properties) { _navigationExceptionSelectors.removeAll(Arrays.asList(_spaConfiguration.navigationExceptionSelectors())); _spaConfiguration = ConfigurableUtil.createConfigurable(SPAConfiguration.class, properties); _cacheExpirationTime = _getCacheExpirationTime(_spaConfiguration); Collections.addAll(_navigationExceptionSelectors, _spaConfiguration.navigationExceptionSelectors()); _navigationExceptionSelectorsString = ListUtil.toString(_navigationExceptionSelectors, (String) null, StringPool.BLANK);//from w ww .j av a 2 s. c o m }
From source file:com.liferay.portlet.tags.service.impl.TagsAssetLocalServiceImpl.java
License:Open Source License
protected TagsAssetDisplay[] getAssetDisplays(List<TagsAsset> assets, String languageId) throws SystemException { TagsAssetDisplay[] assetDisplays = new TagsAssetDisplay[assets.size()]; for (int i = 0; i < assets.size(); i++) { TagsAsset asset = assets.get(i); String className = PortalUtil.getClassName(asset.getClassNameId()); String portletId = PortalUtil.getClassNamePortletId(className); String portletTitle = PortalUtil.getPortletTitle(portletId, asset.getCompanyId(), languageId); List<TagsEntry> tagsEntriesList = tagsAssetPersistence.getTagsEntries(asset.getAssetId()); String tagsEntries = ListUtil.toString(tagsEntriesList, "name", ", "); TagsAssetDisplay assetDisplay = new TagsAssetDisplay(); assetDisplay.setAssetId(asset.getAssetId()); assetDisplay.setCompanyId(asset.getCompanyId()); assetDisplay.setUserId(asset.getUserId()); assetDisplay.setUserName(asset.getUserName()); assetDisplay.setCreateDate(asset.getCreateDate()); assetDisplay.setModifiedDate(asset.getModifiedDate()); assetDisplay.setClassNameId(asset.getClassNameId()); assetDisplay.setClassName(className); assetDisplay.setClassPK(asset.getClassPK()); assetDisplay.setPortletId(portletId); assetDisplay.setPortletTitle(portletTitle); assetDisplay.setStartDate(asset.getStartDate()); assetDisplay.setEndDate(asset.getEndDate()); assetDisplay.setPublishDate(asset.getPublishDate()); assetDisplay.setExpirationDate(asset.getExpirationDate()); assetDisplay.setMimeType(asset.getMimeType()); assetDisplay.setTitle(asset.getTitle()); assetDisplay.setDescription(asset.getDescription()); assetDisplay.setSummary(asset.getSummary()); assetDisplay.setUrl(asset.getUrl()); assetDisplay.setHeight(asset.getHeight()); assetDisplay.setWidth(asset.getWidth()); assetDisplay.setPriority(asset.getPriority()); assetDisplay.setViewCount(asset.getViewCount()); assetDisplay.setTagsEntries(tagsEntries); assetDisplays[i] = assetDisplay; }//from w ww.j av a2 s .co m return assetDisplays; }
From source file:com.liferay.site.admin.web.internal.portlet.SiteAdminPortlet.java
License:Open Source License
protected Group updateGroup(ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long userId = portal.getUserId(actionRequest); long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId"); long parentGroupId = ParamUtil.getLong(actionRequest, "parentGroupSearchContainerPrimaryKeys", GroupConstants.DEFAULT_PARENT_GROUP_ID); Map<Locale, String> nameMap = null; Map<Locale, String> descriptionMap = null; int type = 0; String friendlyURL = null;/*from w w w .jav a 2 s. c o m*/ boolean inheritContent = false; boolean active = false; boolean manualMembership = true; int membershipRestriction = GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION; boolean actionRequestMembershipRestriction = ParamUtil.getBoolean(actionRequest, "membershipRestriction"); if (actionRequestMembershipRestriction && (parentGroupId != GroupConstants.DEFAULT_PARENT_GROUP_ID)) { membershipRestriction = GroupConstants.MEMBERSHIP_RESTRICTION_TO_PARENT_SITE_MEMBERS; } ServiceContext serviceContext = ServiceContextFactory.getInstance(Group.class.getName(), actionRequest); ServiceContextThreadLocal.pushServiceContext(serviceContext); Group liveGroup = null; if (liveGroupId <= 0) { // Add group nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name"); descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description"); type = ParamUtil.getInteger(actionRequest, "type"); friendlyURL = ParamUtil.getString(actionRequest, "friendlyURL"); manualMembership = ParamUtil.getBoolean(actionRequest, "manualMembership"); inheritContent = ParamUtil.getBoolean(actionRequest, "inheritContent"); active = ParamUtil.getBoolean(actionRequest, "active"); liveGroup = groupService.addGroup(parentGroupId, GroupConstants.DEFAULT_LIVE_GROUP_ID, nameMap, descriptionMap, type, manualMembership, membershipRestriction, friendlyURL, true, inheritContent, active, serviceContext); LiveUsers.joinGroup(themeDisplay.getCompanyId(), liveGroup.getGroupId(), userId); } else { // Update group liveGroup = groupLocalService.getGroup(liveGroupId); nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name", liveGroup.getNameMap()); descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description", liveGroup.getDescriptionMap()); type = ParamUtil.getInteger(actionRequest, "type", liveGroup.getType()); manualMembership = ParamUtil.getBoolean(actionRequest, "manualMembership", liveGroup.isManualMembership()); friendlyURL = ParamUtil.getString(actionRequest, "friendlyURL", liveGroup.getFriendlyURL()); inheritContent = ParamUtil.getBoolean(actionRequest, "inheritContent", liveGroup.getInheritContent()); active = ParamUtil.getBoolean(actionRequest, "active", liveGroup.getActive()); liveGroup = groupService.updateGroup(liveGroupId, parentGroupId, nameMap, descriptionMap, type, manualMembership, membershipRestriction, friendlyURL, inheritContent, active, serviceContext); if (type == GroupConstants.TYPE_SITE_OPEN) { List<MembershipRequest> membershipRequests = membershipRequestLocalService.search(liveGroupId, MembershipRequestConstants.STATUS_PENDING, QueryUtil.ALL_POS, QueryUtil.ALL_POS); for (MembershipRequest membershipRequest : membershipRequests) { membershipRequestService.updateStatus(membershipRequest.getMembershipRequestId(), themeDisplay.translate("your-membership-has-been-approved"), MembershipRequestConstants.STATUS_APPROVED, serviceContext); LiveUsers.joinGroup(themeDisplay.getCompanyId(), membershipRequest.getGroupId(), new long[] { membershipRequest.getUserId() }); } } } // Settings UnicodeProperties typeSettingsProperties = liveGroup.getTypeSettingsProperties(); String customJspServletContextName = ParamUtil.getString(actionRequest, "customJspServletContextName", typeSettingsProperties.getProperty("customJspServletContextName")); typeSettingsProperties.setProperty("customJspServletContextName", customJspServletContextName); typeSettingsProperties.setProperty("defaultSiteRoleIds", ListUtil.toString(getRoles(actionRequest), Role.ROLE_ID_ACCESSOR, StringPool.COMMA)); typeSettingsProperties.setProperty("defaultTeamIds", ListUtil.toString(getTeams(actionRequest), Team.TEAM_ID_ACCESSOR, StringPool.COMMA)); String[] analyticsTypes = PrefsPropsUtil.getStringArray(themeDisplay.getCompanyId(), PropsKeys.ADMIN_ANALYTICS_TYPES, StringPool.NEW_LINE); for (String analyticsType : analyticsTypes) { if (StringUtil.equalsIgnoreCase(analyticsType, "google")) { String googleAnalyticsId = ParamUtil.getString(actionRequest, "googleAnalyticsId", typeSettingsProperties.getProperty("googleAnalyticsId")); typeSettingsProperties.setProperty("googleAnalyticsId", googleAnalyticsId); } else { String analyticsScript = ParamUtil.getString(actionRequest, Sites.ANALYTICS_PREFIX + analyticsType, typeSettingsProperties.getProperty(analyticsType)); typeSettingsProperties.setProperty(Sites.ANALYTICS_PREFIX + analyticsType, analyticsScript); } } boolean trashEnabled = ParamUtil.getBoolean(actionRequest, "trashEnabled", GetterUtil.getBoolean(typeSettingsProperties.getProperty("trashEnabled"), true)); typeSettingsProperties.setProperty("trashEnabled", String.valueOf(trashEnabled)); int trashEntriesMaxAgeCompany = PrefsPropsUtil.getInteger(themeDisplay.getCompanyId(), PropsKeys.TRASH_ENTRIES_MAX_AGE); int trashEntriesMaxAgeGroup = ParamUtil.getInteger(actionRequest, "trashEntriesMaxAge"); if (trashEntriesMaxAgeGroup <= 0) { trashEntriesMaxAgeGroup = GetterUtil.getInteger( typeSettingsProperties.getProperty("trashEntriesMaxAge"), trashEntriesMaxAgeCompany); } if (trashEntriesMaxAgeGroup != trashEntriesMaxAgeCompany) { typeSettingsProperties.setProperty("trashEntriesMaxAge", String.valueOf(GetterUtil.getInteger(trashEntriesMaxAgeGroup))); } else { typeSettingsProperties.remove("trashEntriesMaxAge"); } int contentSharingWithChildrenEnabled = ParamUtil.getInteger(actionRequest, "contentSharingWithChildrenEnabled", GetterUtil.getInteger(typeSettingsProperties.getProperty("contentSharingWithChildrenEnabled"), Sites.CONTENT_SHARING_WITH_CHILDREN_DEFAULT_VALUE)); typeSettingsProperties.setProperty("contentSharingWithChildrenEnabled", String.valueOf(contentSharingWithChildrenEnabled)); UnicodeProperties formTypeSettingsProperties = PropertiesParamUtil.getProperties(actionRequest, "TypeSettingsProperties--"); typeSettingsProperties.putAll(formTypeSettingsProperties); // Virtual hosts LayoutSet publicLayoutSet = liveGroup.getPublicLayoutSet(); String publicVirtualHost = ParamUtil.getString(actionRequest, "publicVirtualHost", publicLayoutSet.getVirtualHostname()); layoutSetService.updateVirtualHost(liveGroup.getGroupId(), false, publicVirtualHost); LayoutSet privateLayoutSet = liveGroup.getPrivateLayoutSet(); String privateVirtualHost = ParamUtil.getString(actionRequest, "privateVirtualHost", privateLayoutSet.getVirtualHostname()); layoutSetService.updateVirtualHost(liveGroup.getGroupId(), true, privateVirtualHost); // Staging if (liveGroup.hasStagingGroup()) { Group stagingGroup = liveGroup.getStagingGroup(); friendlyURL = ParamUtil.getString(actionRequest, "stagingFriendlyURL", stagingGroup.getFriendlyURL()); groupService.updateFriendlyURL(stagingGroup.getGroupId(), friendlyURL); LayoutSet stagingPublicLayoutSet = stagingGroup.getPublicLayoutSet(); publicVirtualHost = ParamUtil.getString(actionRequest, "stagingPublicVirtualHost", stagingPublicLayoutSet.getVirtualHostname()); layoutSetService.updateVirtualHost(stagingGroup.getGroupId(), false, publicVirtualHost); LayoutSet stagingPrivateLayoutSet = stagingGroup.getPrivateLayoutSet(); privateVirtualHost = ParamUtil.getString(actionRequest, "stagingPrivateVirtualHost", stagingPrivateLayoutSet.getVirtualHostname()); layoutSetService.updateVirtualHost(stagingGroup.getGroupId(), true, privateVirtualHost); UnicodeProperties stagedGroupTypeSettingsProperties = stagingGroup.getTypeSettingsProperties(); stagedGroupTypeSettingsProperties.putAll(formTypeSettingsProperties); groupService.updateGroup(stagingGroup.getGroupId(), stagedGroupTypeSettingsProperties.toString()); } liveGroup = groupService.updateGroup(liveGroup.getGroupId(), typeSettingsProperties.toString()); // Layout set prototypes long privateLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "privateLayoutSetPrototypeId"); long publicLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "publicLayoutSetPrototypeId"); boolean privateLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest, "privateLayoutSetPrototypeLinkEnabled", privateLayoutSet.isLayoutSetPrototypeLinkEnabled()); boolean publicLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest, "publicLayoutSetPrototypeLinkEnabled", publicLayoutSet.isLayoutSetPrototypeLinkEnabled()); if ((privateLayoutSetPrototypeId == 0) && (publicLayoutSetPrototypeId == 0) && !privateLayoutSetPrototypeLinkEnabled && !publicLayoutSetPrototypeLinkEnabled) { long layoutSetPrototypeId = ParamUtil.getLong(actionRequest, "layoutSetPrototypeId"); int layoutSetVisibility = ParamUtil.getInteger(actionRequest, "layoutSetVisibility"); boolean layoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest, "layoutSetPrototypeLinkEnabled", layoutSetPrototypeId > 0); if (layoutSetVisibility == _LAYOUT_SET_VISIBILITY_PRIVATE) { privateLayoutSetPrototypeId = layoutSetPrototypeId; privateLayoutSetPrototypeLinkEnabled = layoutSetPrototypeLinkEnabled; } else { publicLayoutSetPrototypeId = layoutSetPrototypeId; publicLayoutSetPrototypeLinkEnabled = layoutSetPrototypeLinkEnabled; } } if (!liveGroup.isStaged() || liveGroup.isStagedRemotely()) { SitesUtil.updateLayoutSetPrototypesLinks(liveGroup, publicLayoutSetPrototypeId, privateLayoutSetPrototypeId, publicLayoutSetPrototypeLinkEnabled, privateLayoutSetPrototypeLinkEnabled); } else { SitesUtil.updateLayoutSetPrototypesLinks(liveGroup.getStagingGroup(), publicLayoutSetPrototypeId, privateLayoutSetPrototypeId, publicLayoutSetPrototypeLinkEnabled, privateLayoutSetPrototypeLinkEnabled); } themeDisplay.setSiteGroupId(liveGroup.getGroupId()); return liveGroup; }
From source file:com.rivetlogic.ecommerce.portlet.ShoppingCartPortlet.java
License:Open Source License
private void doUpdateCartItem(ResourceRequest request, ResourceResponse response) throws SystemException { String itemId = ParamUtil.getString(request, ShoppingCartPortletConstants.WEB_CONTENT_ITEM_ID); Integer count = ParamUtil.getInteger(request, ShoppingCartPortletConstants.WEB_CONTENT_ITEM_COUNT); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (!themeDisplay.isSignedIn()) { List<String> currentCartItems = getOrderItemsIdsFromSession(request); if (null != currentCartItems && currentCartItems.contains(itemId)) { List<String> newCartItems = new ArrayList<>(); for (String cartItemId : currentCartItems) { if (!cartItemId.equals(itemId)) newCartItems.add(cartItemId); }//w w w.j a va 2s .co m for (int i = 0; i < count; i++) { newCartItems.add(itemId); } setSessionOrderItemsIds(request, ListUtil.toString(newCartItems, StringPool.BLANK, StringPool.COMMA)); } } else { Long cartItemId = Long.valueOf(itemId); ShoppingOrderItem shoppingOrderItem = ShoppingOrderItemLocalServiceUtil .fetchShoppingOrderItem(cartItemId); shoppingOrderItem.setQuantity(count); ShoppingOrderItemLocalServiceUtil.updateShoppingOrderItem(shoppingOrderItem); } }
From source file:com.rivetlogic.ecommerce.portlet.ShoppingCartPortlet.java
License:Open Source License
private void doRemoveCartItem(ResourceRequest request, ResourceResponse response) throws PortalException, SystemException { String itemId = ParamUtil.getString(request, ShoppingCartPortletConstants.WEB_CONTENT_ITEM_ID); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (!themeDisplay.isSignedIn()) { List<String> currentCartItems = getOrderItemsIdsFromSession(request); if (null != currentCartItems) { List<String> newCartItems = new ArrayList<>(); for (String cartItemId : currentCartItems) { if (!cartItemId.equals(itemId)) newCartItems.add(cartItemId); }/*from w w w. j a v a 2 s .c om*/ setSessionOrderItemsIds(request, ListUtil.toString(newCartItems, StringPool.BLANK, StringPool.COMMA)); } } else { Long cartItemId = Long.valueOf(itemId); ShoppingOrderItemLocalServiceUtil.deleteShoppingOrderItem(cartItemId); } }
From source file:com.rivetlogic.ecommerce.portlet.ShoppingCartPortlet.java
License:Open Source License
private void doAddItemToCart(ResourceRequest request, ResourceResponse response) throws SystemException { String itemId = ParamUtil.getString(request, ShoppingCartPortletConstants.WEB_CONTENT_ITEM_ID); int count = ParamUtil.getInteger(request, ShoppingCartPortletConstants.WEB_CONTENT_ITEM_COUNT, 1); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (isValidItemId(themeDisplay.getScopeGroupId(), itemId)) { List<String> itemsIdsList = new ArrayList<String>(); for (int i = 0; i < count; i++) { itemsIdsList.add(itemId);/* w w w . ja va 2 s . co m*/ } if (!themeDisplay.isSignedIn()) { if (null != getOrderItemsIdsFromSession(request)) itemsIdsList.addAll(getOrderItemsIdsFromSession(request)); setSessionOrderItemsIds(request, ListUtil.toString(itemsIdsList, StringPool.BLANK, StringPool.COMMA)); } else { ShoppingOrder activeShoppingOrder = ShoppingOrderLocalServiceUtil.getUserActiveOrder( themeDisplay.getUserId(), themeDisplay.getCompanyGroupId(), themeDisplay.getCompanyId(), Boolean.TRUE); ShoppingOrderItemLocalServiceUtil.saveOrderItemsByProductId(itemsIdsList, activeShoppingOrder); } } else { logger.warn(String.format(ERROR_ITEM_ID_NOT_VALID_LOG, itemId, StringPool.BLANK)); printJsonResponse(ERROR_ITEM_ID_NOT_VALID_MESSAGE, String.valueOf(HttpServletResponse.SC_NOT_FOUND), response); } }