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.sync.util.SyncDLObjectUpdate.java
License:Open Source License
@Override public String toString() { StringBundler sb = new StringBundler((_syncDLObjects.size() * 78) + 5); sb.append("{\"lastAccessTime\":"); sb.append(_lastAccessTime);//w ww . j a v a 2 s . c o m sb.append(",\"resultsTotal\":"); sb.append(_resultsTotal); sb.append(",\"syncDLObjects\":["); for (int i = 0; i < _syncDLObjects.size(); i++) { SyncDLObject syncDLObject = _syncDLObjects.get(i); sb.append("{\"changeLog\":"); append(sb, syncDLObject.getChangeLog(), true); sb.append(",\"checksum\":"); append(sb, syncDLObject.getChecksum(), false); sb.append(",\"companyId\":"); sb.append(syncDLObject.getCompanyId()); sb.append(",\"createTime\":"); sb.append(syncDLObject.getCreateTime()); sb.append(",\"description\":"); append(sb, syncDLObject.getDescription(), true); sb.append(",\"event\":"); append(sb, syncDLObject.getEvent(), false); sb.append(",\"extension\":"); append(sb, syncDLObject.getExtension(), true); sb.append(",\"extraSettings\":"); append(sb, syncDLObject.getExtraSettings(), true); sb.append(",\"lockExpirationDate\":"); Date lockExpirationDate = syncDLObject.getLockExpirationDate(); if (lockExpirationDate != null) { sb.append(lockExpirationDate.getTime()); } else { sb.append(StringPool.NULL); } sb.append(",\"lockUserId\":"); sb.append(syncDLObject.getLockUserId()); sb.append(",\"lockUserName\":"); append(sb, syncDLObject.getLockUserName(), true); sb.append(",\"mimeType\":"); append(sb, syncDLObject.getMimeType(), true); sb.append(",\"modifiedTime\":"); sb.append(syncDLObject.getModifiedTime()); sb.append(",\"name\":"); append(sb, syncDLObject.getName(), true); sb.append(",\"parentFolderId\":"); sb.append(syncDLObject.getParentFolderId()); sb.append(",\"repositoryId\":"); sb.append(syncDLObject.getRepositoryId()); sb.append(",\"size\":"); sb.append(syncDLObject.getSize()); sb.append(",\"syncDLObjectId\":"); sb.append(syncDLObject.getSyncDLObjectId()); sb.append(",\"type\":"); append(sb, syncDLObject.getType(), false); sb.append(",\"typePK\":"); sb.append(syncDLObject.getTypePK()); sb.append(",\"typeUuid\":"); append(sb, syncDLObject.getTypeUuid(), false); sb.append(",\"userId\":"); sb.append(syncDLObject.getUserId()); sb.append(",\"userName\":"); append(sb, syncDLObject.getUserName(), true); sb.append(",\"version\":"); append(sb, syncDLObject.getVersion(), false); sb.append(",\"versionId\":"); sb.append(syncDLObject.getVersionId()); sb.append(StringPool.CLOSE_CURLY_BRACE); if (i != (_syncDLObjects.size() - 1)) { sb.append(StringPool.COMMA); } } sb.append("]}"); return sb.toString(); }
From source file:com.liferay.tasks.service.persistence.impl.TasksEntryPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, TasksEntry> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/* w w w . j a v a 2 s .com*/ Map<Serializable, TasksEntry> map = new HashMap<Serializable, TasksEntry>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); TasksEntry tasksEntry = fetchByPrimaryKey(primaryKey); if (tasksEntry != null) { map.put(primaryKey, tasksEntry); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { TasksEntry tasksEntry = (TasksEntry) EntityCacheUtil.getResult(TasksEntryModelImpl.ENTITY_CACHE_ENABLED, TasksEntryImpl.class, primaryKey); if (tasksEntry == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, tasksEntry); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_TASKSENTRY_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 (TasksEntry tasksEntry : (List<TasksEntry>) q.list()) { map.put(tasksEntry.getPrimaryKeyObj(), tasksEntry); cacheResult(tasksEntry); uncachedPrimaryKeys.remove(tasksEntry.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(TasksEntryModelImpl.ENTITY_CACHE_ENABLED, TasksEntryImpl.class, primaryKey, _nullTasksEntry); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.testblob.service.persistence.impl.TestBlobEntryPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, TestBlobEntry> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }// w ww .ja va2s . com Map<Serializable, TestBlobEntry> map = new HashMap<Serializable, TestBlobEntry>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); TestBlobEntry testBlobEntry = fetchByPrimaryKey(primaryKey); if (testBlobEntry != null) { map.put(primaryKey, testBlobEntry); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { TestBlobEntry testBlobEntry = (TestBlobEntry) EntityCacheUtil .getResult(TestBlobEntryModelImpl.ENTITY_CACHE_ENABLED, TestBlobEntryImpl.class, primaryKey); if (testBlobEntry == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, testBlobEntry); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_TESTBLOBENTRY_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 (TestBlobEntry testBlobEntry : (List<TestBlobEntry>) q.list()) { map.put(testBlobEntry.getPrimaryKeyObj(), testBlobEntry); cacheResult(testBlobEntry); uncachedPrimaryKeys.remove(testBlobEntry.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(TestBlobEntryModelImpl.ENTITY_CACHE_ENABLED, TestBlobEntryImpl.class, primaryKey, _nullTestBlobEntry); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.testoauth.oauth.LiferayOAuthJSONWSClient.java
License:Open Source License
protected String formatJSON(String json) { StringBundler sb = new StringBundler(); for (String token : json.split(StringPool.COMMA)) { if (token.startsWith(StringPool.OPEN_CURLY_BRACE)) { sb.append(StringPool.OPEN_CURLY_BRACE); sb.append(StringPool.NEW_LINE); token = token.substring(1);// w ww . j a v a 2s . c om } sb.append(StringPool.DOUBLE_SPACE); if (token.endsWith(StringPool.CLOSE_CURLY_BRACE)) { sb.append(token.substring(0, token.length() - 1)); sb.append(StringPool.NEW_LINE); sb.append(StringPool.CLOSE_CURLY_BRACE); } else { sb.append(token); sb.append(StringPool.COMMA); sb.append(StringPool.NEW_LINE); } } return sb.toString(); }
From source file:com.liferay.testtransaction.service.persistence.impl.BarPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Bar> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from w w w . j a v a 2 s . com*/ Map<Serializable, Bar> map = new HashMap<Serializable, Bar>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Bar bar = fetchByPrimaryKey(primaryKey); if (bar != null) { map.put(primaryKey, bar); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Bar bar = (Bar) EntityCacheUtil.getResult(BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, primaryKey); if (bar == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, bar); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_BAR_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 (Bar bar : (List<Bar>) q.list()) { map.put(bar.getPrimaryKeyObj(), bar); cacheResult(bar); uncachedPrimaryKeys.remove(bar.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, primaryKey, _nullBar); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.todo.service.persistence.impl.TodoPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Todo> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from w ww. ja v a2 s . c o m*/ Map<Serializable, Todo> map = new HashMap<Serializable, Todo>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Todo todo = fetchByPrimaryKey(primaryKey); if (todo != null) { map.put(primaryKey, todo); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(TodoModelImpl.ENTITY_CACHE_ENABLED, TodoImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (Todo) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_TODO_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append((long) 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 (Todo todo : (List<Todo>) q.list()) { map.put(todo.getPrimaryKeyObj(), todo); cacheResult(todo); uncachedPrimaryKeys.remove(todo.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(TodoModelImpl.ENTITY_CACHE_ENABLED, TodoImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.todo.TodoPortlet.java
License:Open Source License
public void contact(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { if (_log.isInfoEnabled()) { _log.info("Process action for contact form works"); }//from w w w. j a v a2 s . co m String birthday = ParamUtil.getString(actionRequest, "birthday"); String comment = ParamUtil.getString(actionRequest, "comment"); String email = ParamUtil.getString(actionRequest, "email"); String lastName = ParamUtil.getString(actionRequest, "last-name"); String name = ParamUtil.getString(actionRequest, "name"); if (comment.isEmpty()) { SessionErrors.add(actionRequest, "formSubmissionFailed"); SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); } else { StringBundler sb = new StringBundler(9); sb.append(name); sb.append(StringPool.COMMA); sb.append(lastName); sb.append(StringPool.COMMA); sb.append(email); sb.append(StringPool.COMMA); sb.append(birthday); sb.append(StringPool.COMMA); sb.append(comment); if (_log.isInfoEnabled()) { _log.info(sb.toString()); } SessionMessages.add(actionRequest, "formSuccessfullySubmitted"); } actionResponse.setRenderParameter("mvcPath", "/contact.jsp"); }
From source file:com.liferay.tools.sourceformatter.BaseSourceProcessor.java
License:Open Source License
protected String fixSessionKey(String fileName, String content, Pattern pattern) { Matcher matcher = pattern.matcher(content); if (!matcher.find()) { return content; }/* www .j a va 2 s.com*/ String newContent = content; do { String match = matcher.group(); String s = null; if (pattern.equals(sessionKeyPattern)) { s = StringPool.COMMA; } else if (pattern.equals(taglibSessionKeyPattern)) { s = "key="; } int x = match.indexOf(s); if (x == -1) { continue; } x = x + s.length(); String substring = match.substring(x).trim(); String quote = StringPool.BLANK; if (substring.startsWith(StringPool.APOSTROPHE)) { quote = StringPool.APOSTROPHE; } else if (substring.startsWith(StringPool.QUOTE)) { quote = StringPool.QUOTE; } else { continue; } int y = match.indexOf(quote, x); int z = match.indexOf(quote, y + 1); if ((y == -1) || (z == -1)) { continue; } String prefix = match.substring(0, y + 1); String suffix = match.substring(z); String oldKey = match.substring(y + 1, z); boolean alphaNumericKey = true; for (char c : oldKey.toCharArray()) { if (!Validator.isChar(c) && !Validator.isDigit(c) && (c != CharPool.DASH) && (c != CharPool.UNDERLINE)) { alphaNumericKey = false; } } if (!alphaNumericKey) { continue; } String newKey = TextFormatter.format(oldKey, TextFormatter.O); newKey = TextFormatter.format(newKey, TextFormatter.M); if (newKey.equals(oldKey)) { continue; } String oldSub = prefix.concat(oldKey).concat(suffix); String newSub = prefix.concat(newKey).concat(suffix); newContent = StringUtil.replaceFirst(newContent, oldSub, newSub); } while (matcher.find()); return newContent; }
From source file:com.liferay.tools.sourceformatter.BaseSourceProcessor.java
License:Open Source License
protected List<String> getPropertyList(String key) { return ListUtil.fromString(GetterUtil.getString(getProperty(key)), StringPool.COMMA); }
From source file:com.liferay.tools.sourceformatter.BaseSourceProcessor.java
License:Open Source License
protected String stripRedundantParentheses(String s) { for (int x = 0;;) { x = s.indexOf(StringPool.OPEN_PARENTHESIS, x + 1); int y = s.indexOf(StringPool.CLOSE_PARENTHESIS, x); if ((x == -1) || (y == -1)) { return s; }//from w w w . ja v a2s . c o m String linePart = s.substring(x + 1, y); linePart = StringUtil.replace(linePart, StringPool.COMMA, StringPool.BLANK); if (Validator.isAlphanumericName(linePart) || Validator.isNull(linePart)) { s = s.substring(0, x) + s.substring(y + 1); } } }