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.liferay.portlet.messageboards.action.ConfigurationActionImpl.java
License:Open Source License
protected void updateThreadPriorities(ActionRequest actionRequest) throws Exception { Locale[] locales = LanguageUtil.getAvailableLocales(); for (int i = 0; i < locales.length; i++) { String languageId = LocaleUtil.toLanguageId(locales[i]); List<String> priorities = new ArrayList<String>(); for (int j = 0; j < 10; j++) { String name = ParamUtil.getString(actionRequest, "priorityName" + j + "_" + languageId); String image = ParamUtil.getString(actionRequest, "priorityImage" + j + "_" + languageId); double value = ParamUtil.getDouble(actionRequest, "priorityValue" + j + "_" + languageId); if (Validator.isNotNull(name) || Validator.isNotNull(image) || (value != 0.0)) { priorities.add(name + StringPool.COMMA + image + StringPool.COMMA + value); }/*from ww w .j av a 2 s . c o m*/ } String preferenceName = LocalizationUtil.getPreferencesKey("priorities", languageId); setPreference(actionRequest, preferenceName, priorities.toArray(new String[priorities.size()])); } }
From source file:com.liferay.portlet.Preference.java
License:Open Source License
@Override public String toString() { StringBundler sb = new StringBundler(6 + (_values.length * 2 - 1)); sb.append("{name="); sb.append(getName());//from ww w .j a va 2s . co m sb.append(",readOnly="); sb.append(_readOnly); sb.append(",values=["); for (int i = 0; i < _values.length; i++) { sb.append(_values[i]); if (i < _values.length - 1) { sb.append(StringPool.COMMA); } } sb.append("]}"); return sb.toString(); }
From source file:com.liferay.portlet.shopping.model.impl.ShoppingCartImpl.java
License:Open Source License
public void addItemId(long itemId, String fields) { setItemIds(StringUtil.add(getItemIds(), itemId + fields, StringPool.COMMA, true)); }
From source file:com.liferay.portlet.shopping.service.impl.ShoppingItemLocalServiceImpl.java
License:Open Source License
protected void validate(long companyId, long itemId, String sku, String name, boolean smallImage, String smallImageURL, File smallImageFile, byte[] smallImageBytes, boolean mediumImage, String mediumImageURL, File mediumImageFile, byte[] mediumImageBytes, boolean largeImage, String largeImageURL, File largeImageFile, byte[] largeImageBytes) throws PortalException, SystemException { if (Validator.isNull(sku)) { throw new ItemSKUException(); }//from w w w . j a v a2 s .co m ShoppingItem item = shoppingItemPersistence.fetchByC_S(companyId, sku); if (item != null) { if (itemId > 0) { if (item.getItemId() != itemId) { throw new DuplicateItemSKUException(); } } else { throw new DuplicateItemSKUException(); } } if (Validator.isNull(name)) { throw new ItemNameException(); } String[] imageExtensions = PrefsPropsUtil.getStringArray(PropsKeys.SHOPPING_IMAGE_EXTENSIONS, StringPool.COMMA); // Small image if (smallImage && Validator.isNull(smallImageURL) && smallImageFile != null && smallImageBytes != null) { String smallImageName = smallImageFile.getName(); if (smallImageName != null) { boolean validSmallImageExtension = false; for (int i = 0; i < imageExtensions.length; i++) { if (StringPool.STAR.equals(imageExtensions[i]) || StringUtil.endsWith(smallImageName, imageExtensions[i])) { validSmallImageExtension = true; break; } } if (!validSmallImageExtension) { throw new ItemSmallImageNameException(smallImageName); } } long smallImageMaxSize = PrefsPropsUtil.getLong(PropsKeys.SHOPPING_IMAGE_MEDIUM_MAX_SIZE); if ((smallImageMaxSize > 0) && ((smallImageBytes == null) || (smallImageBytes.length > smallImageMaxSize))) { throw new ItemSmallImageSizeException(); } } // Medium image if (mediumImage && Validator.isNull(mediumImageURL) && mediumImageFile != null && mediumImageBytes != null) { String mediumImageName = mediumImageFile.getName(); if (mediumImageName != null) { boolean validMediumImageExtension = false; for (int i = 0; i < imageExtensions.length; i++) { if (StringPool.STAR.equals(imageExtensions[i]) || StringUtil.endsWith(mediumImageName, imageExtensions[i])) { validMediumImageExtension = true; break; } } if (!validMediumImageExtension) { throw new ItemMediumImageNameException(mediumImageName); } } long mediumImageMaxSize = PrefsPropsUtil.getLong(PropsKeys.SHOPPING_IMAGE_MEDIUM_MAX_SIZE); if ((mediumImageMaxSize > 0) && ((mediumImageBytes == null) || (mediumImageBytes.length > mediumImageMaxSize))) { throw new ItemMediumImageSizeException(); } } // Large image if (largeImage && Validator.isNull(largeImageURL) && largeImageFile != null && largeImageBytes != null) { String largeImageName = largeImageFile.getName(); if (largeImageName != null) { boolean validLargeImageExtension = false; for (int i = 0; i < imageExtensions.length; i++) { if (StringPool.STAR.equals(imageExtensions[i]) || StringUtil.endsWith(largeImageName, imageExtensions[i])) { validLargeImageExtension = true; break; } } if (!validLargeImageExtension) { throw new ItemLargeImageNameException(largeImageName); } } long largeImageMaxSize = PrefsPropsUtil.getLong(PropsKeys.SHOPPING_IMAGE_LARGE_MAX_SIZE); if ((largeImageMaxSize > 0) && ((largeImageBytes == null) || (largeImageBytes.length > largeImageMaxSize))) { throw new ItemLargeImageSizeException(); } } }
From source file:com.liferay.portlet.social.service.persistence.SocialActivityCounterFinderImpl.java
License:Open Source License
protected String getNames(String[] names) { if (names.length == 0) { return StringPool.BLANK; }// w ww . j a v a2 s . co m StringBundler sb = new StringBundler(names.length * 2 - 1); for (int i = 0; i < names.length; i++) { sb.append(StringUtil.quote(names[i], StringPool.APOSTROPHE)); if ((i + 1) < names.length) { sb.append(StringPool.COMMA); } } return sb.toString(); }
From source file:com.liferay.portlet.tagscompiler.TagsCompilerFriendlyURLMapper.java
License:Open Source License
public void populateParams(String friendlyURLPath, Map<String, String[]> parameterMap, Map<String, Object> requestContext) { addParameter(parameterMap, "p_p_id", getPortletId()); addParameter(parameterMap, "p_p_lifecycle", "0"); addParameter(parameterMap, "p_p_state", WindowState.NORMAL); addParameter(parameterMap, "p_p_mode", PortletMode.VIEW); int x = friendlyURLPath.indexOf(CharPool.SLASH, 1); int y = friendlyURLPath.length(); String[] entries = StringUtil.split(friendlyURLPath.substring(x + 1, y), CharPool.SLASH); if (entries.length > 0) { StringBundler sb = new StringBundler(entries.length * 2 - 1); for (int i = 0; i < entries.length; i++) { String entry = StringUtil.replace(entries[i], CharPool.PLUS, CharPool.SPACE); if (i != 0) { sb.append(StringPool.COMMA); }/*from w w w.ja v a2s.com*/ sb.append(entry); } addParameter(parameterMap, "entries", sb.toString()); } }
From source file:com.liferay.portlet.usersadmin.action.ExportUsersAction.java
License:Open Source License
protected String getUserCSV(User user) { StringBundler sb = new StringBundler(PropsValues.USERS_EXPORT_CSV_FIELDS.length * 2); for (int i = 0; i < PropsValues.USERS_EXPORT_CSV_FIELDS.length; i++) { String field = PropsValues.USERS_EXPORT_CSV_FIELDS[i]; if (field.equals("fullName")) { sb.append(CSVUtil.encode(user.getFullName())); } else if (field.startsWith("expando:")) { String attributeName = field.substring(8); ExpandoBridge expandoBridge = user.getExpandoBridge(); sb.append(CSVUtil.encode(expandoBridge.getAttribute(attributeName))); } else {//from ww w .java 2 s . c o m sb.append(CSVUtil.encode(BeanPropertiesUtil.getString(user, field))); } if ((i + 1) < PropsValues.USERS_EXPORT_CSV_FIELDS.length) { sb.append(StringPool.COMMA); } } sb.append(StringPool.NEW_LINE); return sb.toString(); }
From source file:com.liferay.privatemessaging.portlet.PrivateMessagingPortlet.java
License:Open Source License
protected String getMessage(PortletRequest portletRequest, Exception key) throws Exception { String message = null;// w w w . j ava 2s .c o m if (key instanceof FileExtensionException) { message = translate(portletRequest, "document-names-must-end-with-one-of-the-following-extensions"); message += CharPool.SPACE + StringUtil.merge( PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA), StringPool.COMMA_AND_SPACE); } else if (key instanceof FileNameException) { message = translate(portletRequest, "please-enter-a-file-with-a-valid-file-name"); } else if (key instanceof FileSizeException) { long fileMaxSize = PrefsPropsUtil.getLong(PropsKeys.DL_FILE_MAX_SIZE); if (fileMaxSize == 0) { fileMaxSize = PrefsPropsUtil.getLong(PropsKeys.UPLOAD_SERVLET_REQUEST_IMPL_MAX_SIZE); } fileMaxSize /= 1024; message = translate(portletRequest, "please-enter-a-file-with-a-valid-file-size-no-larger-than-x", fileMaxSize); } else if (key instanceof UserScreenNameException) { message = translate(portletRequest, "the-following-users-were-not-found"); message += CharPool.SPACE + key.getMessage(); } else { message = translate(portletRequest, "your-request-failed-to-complete"); } return message; }
From source file:com.liferay.privatemessaging.portlet.PrivateMessagingPortlet.java
License:Open Source License
protected void validateAttachment(String fileName, InputStream inputStream) throws Exception { if (inputStream instanceof ByteArrayFileInputStream) { ByteArrayFileInputStream byteArrayFileInputStream = (ByteArrayFileInputStream) inputStream; File file = byteArrayFileInputStream.getFile(); if ((PrefsPropsUtil.getLong(PropsKeys.DL_FILE_MAX_SIZE) > 0) && ((file == null) || (file.length() > PrefsPropsUtil.getLong(PropsKeys.DL_FILE_MAX_SIZE)))) { throw new FileSizeException(fileName); }/*from w w w. j av a 2 s.c o m*/ } if (!isValidName(fileName)) { throw new FileNameException(fileName); } String[] fileExtensions = PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA); boolean validFileExtension = false; for (String fileExtension : fileExtensions) { if (StringPool.STAR.equals(fileExtension) || StringUtil.endsWith(fileName, fileExtension)) { validFileExtension = true; break; } } if (!validFileExtension) { throw new FileExtensionException(fileName); } }
From source file:com.liferay.privatemessaging.service.persistence.impl.UserThreadPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, UserThread> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//ww w .ja v a2 s . co m Map<Serializable, UserThread> map = new HashMap<Serializable, UserThread>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); UserThread userThread = fetchByPrimaryKey(primaryKey); if (userThread != null) { map.put(primaryKey, userThread); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { UserThread userThread = (UserThread) EntityCacheUtil.getResult(UserThreadModelImpl.ENTITY_CACHE_ENABLED, UserThreadImpl.class, primaryKey); if (userThread == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, userThread); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_USERTHREAD_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (UserThread userThread : (List<UserThread>) q.list()) { map.put(userThread.getPrimaryKeyObj(), userThread); cacheResult(userThread); uncachedPrimaryKeys.remove(userThread.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(UserThreadModelImpl.ENTITY_CACHE_ENABLED, UserThreadImpl.class, primaryKey, _nullUserThread); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }