List of usage examples for com.liferay.portal.kernel.util StringPool COMMA
String COMMA
To view the source code for com.liferay.portal.kernel.util StringPool COMMA.
Click Source Link
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); }// ww w. j a va2s .c o 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 ww.ja v a2 s .c o m*/ 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);/*from w w w. j a va 2s. c o 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); } }
From source file:com.rivetlogic.ecommerce.portlet.ShoppingCartPortlet.java
License:Open Source License
private List<String> getOrderItemsIdsFromSession(PortletRequest request) { List<String> orderItemsIdsList = null; PortletSession portletSession = request.getPortletSession(); if (null != portletSession) { String cartItemsStrVal = (String) portletSession .getAttribute(ShoppingCartPortletConstants.COOKIE_SHOPPING_CART_ITEMS); if (null != cartItemsStrVal && !cartItemsStrVal.isEmpty()) { orderItemsIdsList = (Arrays.asList(StringUtil.split(cartItemsStrVal, StringPool.COMMA))); }//from w w w .j a va 2 s . com } return orderItemsIdsList; }
From source file:com.rivetlogic.ecommerce.service.persistence.NotificationPK.java
License:Open Source License
@Override public String toString() { StringBundler sb = new StringBundler(10); sb.append(StringPool.OPEN_CURLY_BRACE); sb.append("orderId"); sb.append(StringPool.EQUAL);/*w w w . j a v a 2 s . c o m*/ sb.append(orderId); sb.append(StringPool.COMMA); sb.append(StringPool.SPACE); sb.append("recipients"); sb.append(StringPool.EQUAL); sb.append(recipients); sb.append(StringPool.CLOSE_CURLY_BRACE); return sb.toString(); }
From source file:com.rivetlogic.elasticsearch.portlet.util.ElasticsearchPropsValues.java
License:Open Source License
/** * Gets the transport hosts.//from w ww . j av a 2 s. c o m * * @return the transport hosts */ public InetSocketTransportAddress[] getTransportHosts() { String csNodeList = PropsUtil.get(ElasticsearchPortletConstants.ES_KEY_NODE); InetSocketTransportAddress[] transportAddresses = null; if (Validator.isNotNull(csNodeList)) { String[] nodeList = csNodeList.split(StringPool.COMMA); transportAddresses = new InetSocketTransportAddress[nodeList.length]; /** Prepare a list of Hosts */ for (int i = 0; i < nodeList.length; i++) { String[] hostnames = nodeList[i].split(StringPool.COLON); InetSocketTransportAddress transportAddress = new InetSocketTransportAddress(hostnames[0], Integer.parseInt(hostnames[1])); transportAddresses[i] = transportAddress; } } else { _log.error("Elastic search nodes are missing from properties..."); } return transportAddresses; }
From source file:com.rivetlogic.elasticsearch.portlet.util.ElasticsearchPropsValues.java
License:Open Source License
/** * Sets the suggestion excluded types./*from www.j av a 2 s .c o m*/ */ private void setSuggestionExcludedTypes() { suggestionExcludedTypes = new HashSet<String>(); String csExcludedTypes = getPortletProperty(ElasticsearchPortletConstants.SUGGESTION_EXCLUDED_TYPES_KEY); if (Validator.isNotNull(csExcludedTypes)) { String[] excludedTypes = csExcludedTypes.split(StringPool.COMMA); /** Iterate over the fields and add to Querybuilder */ for (String type : excludedTypes) { String elasticsearchType = type.replace(StringPool.PERIOD, StringPool.UNDERLINE); suggestionExcludedTypes.add(elasticsearchType); } } else { if (_log.isDebugEnabled()) { _log.debug("Suggestion query excluded index types are not defined....."); } } }
From source file:com.rivetlogic.elasticsearch.portlet.util.ElasticsearchPropsValues.java
License:Open Source License
/** * Sets the suggestion query fields.// w w w.ja v a2s . c o m */ private void setSuggestionQueryFields() { suggestionQueryFields = new HashMap<String, Float>(); String csFields = getPortletProperty(ElasticsearchPortletConstants.SUGGESTION_QUERY_FIELDS_KEY); if (Validator.isNotNull(csFields)) { String[] fieldList = csFields.split(StringPool.COMMA); /** Iterate over the fields and add to Querybuilder */ for (String field : fieldList) { String[] fieldWithBoostValue = field.split(ElasticsearchPortletConstants.CARET_SPLITCHAR); String filedName = fieldWithBoostValue[0] + ElasticsearchPortletConstants.NGRAMS_WITH_PERIOD; float boost = ElasticsearchPortletConstants.FLOAT_ZERO_VALUE; if (fieldWithBoostValue.length > ElasticsearchPortletConstants.INTEGER_ONE_VALUE) { boost = GetterUtil.getFloat(fieldWithBoostValue[1], boost); } suggestionQueryFields.put(filedName, boost); } } else { _log.error("Query fields to get suggestions is missing from properties..."); } }
From source file:com.rivetlogic.geo.service.persistence.GeoBlocksPK.java
License:Open Source License
@Override public String toString() { StringBundler sb = new StringBundler(10); sb.append(StringPool.OPEN_CURLY_BRACE); sb.append("geonameId"); sb.append(StringPool.EQUAL);/*from w w w . j a v a2s . co m*/ sb.append(geonameId); sb.append(StringPool.COMMA); sb.append(StringPool.SPACE); sb.append("startIp"); sb.append(StringPool.EQUAL); sb.append(startIp); sb.append(StringPool.CLOSE_CURLY_BRACE); return sb.toString(); }
From source file:com.rivetlogic.hangouts.portlet.HangoutsPortlet.java
License:Open Source License
private void addGroup(PortletRequest request, PortletResponse response, JSONObject jsonResponse) { try {// w ww .jav a2s . c o m List<String> errors = new ArrayList<String>(); HangoutsGroup sg = hangoutsGroupFromRequest(request); if (HangoutsPortletValidator.validateCreateGroup(sg, errors)) { HangoutsGroupLocalServiceUtil.createHangoutsGroup(sg); jsonResponse.put(Constants.HANGOUTS_GROUP_ID, sg.getHangoutsGroupId()); jsonResponse.put(Constants.CMD_SUCCESS, true); } else { jsonResponse.put(Constants.ERRORS, ListUtil.toString(errors, StringPool.BLANK, StringPool.COMMA)); jsonResponse.put(Constants.CMD_SUCCESS, false); } } catch (JSONException e) { jsonResponse.put(Constants.CMD_SUCCESS, false); LOG.error("Wrong format in ids: ", e); } catch (Exception se) { jsonResponse.put(Constants.CMD_SUCCESS, false); LOG.error(se); } }