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.chat.service.persistence.impl.StatusFinderImpl.java
License:Open Source License
protected String getFindByUsersGroups_SQL(String[] groupNames) { String sql = CustomSQLUtil.get(FIND_BY_USERS_GROUPS); if (groupNames.length == 0) { return StringUtil.replace(sql, new String[] { "[$USERS_GROUPS_JOIN$]", "[$USERS_GROUPS_WHERE$]" }, new String[] { StringPool.BLANK, StringPool.BLANK }); }// w ww. j av a 2s . co m StringBundler sb = new StringBundler(groupNames.length * 2 - 1); for (int i = 0; i < groupNames.length; i++) { sb.append(StringPool.QUESTION); if ((i + 1) < groupNames.length) { sb.append(StringPool.COMMA); } } return StringUtil.replace(sql, new String[] { "[$USERS_GROUPS_JOIN$]", "[$USERS_GROUPS_WHERE$]" }, new String[] { "INNER JOIN Group_ ON Group_.groupId = Users_Groups.groupId", "AND Group_.name NOT IN (" + sb.toString() + ")" }); }
From source file:com.liferay.chat.service.persistence.impl.StatusPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Status> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/* w ww .j av a 2 s. co m*/ Map<Serializable, Status> map = new HashMap<Serializable, Status>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Status status = fetchByPrimaryKey(primaryKey); if (status != null) { map.put(primaryKey, status); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Status status = (Status) EntityCacheUtil.getResult(StatusModelImpl.ENTITY_CACHE_ENABLED, StatusImpl.class, primaryKey); if (status == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, status); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_STATUS_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 (Status status : (List<Status>) q.list()) { map.put(status.getPrimaryKeyObj(), status); cacheResult(status); uncachedPrimaryKeys.remove(status.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(StatusModelImpl.ENTITY_CACHE_ENABLED, StatusImpl.class, primaryKey, _nullStatus); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.content.targeting.rule.weather.WeatherRule.java
License:Open Source License
protected String getCityFromIPAddress(String ipAddress) { IPInfo ipInfo = _ipGeocoder.getIPInfo(ipAddress); if (ipInfo == null) { return null; }//ww w . j ava 2 s .c o m return ipInfo.getCity() + StringPool.COMMA + ipInfo.getCountryCode(); }
From source file:com.liferay.content.targeting.rule.weather.WeatherRule.java
License:Open Source License
protected String getCityFromUserProfile(long contactId, long companyId) throws PortalException, SystemException { List<Address> addresses = AddressLocalServiceUtil.getAddresses(companyId, Contact.class.getName(), contactId);/* ww w.j a va2 s . com*/ if (addresses.isEmpty()) { return null; } Address address = addresses.get(0); return address.getCity() + StringPool.COMMA + address.getCountry().getA2(); }
From source file:com.liferay.content.targeting.tools.CTDataFactory.java
License:Open Source License
public String getPortletLayoutColumn(String portletIdPrefix, int count) { StringBundler sb = new StringBundler(3 * count); for (int i = 1; i <= count; i++) { sb.append(portletIdPrefix);// www. j a va 2s . c om sb.append(i); sb.append(StringPool.COMMA); } return sb.toString(); }
From source file:com.liferay.demo.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(); }// w w w.ja v a 2 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(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 (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.document.library.internal.verify.DLServiceVerifyProcess.java
License:Open Source License
protected void checkFileVersionMimeTypes(final String[] originalMimeTypes) throws Exception { ActionableDynamicQuery actionableDynamicQuery = _dlFileVersionLocalService.getActionableDynamicQuery(); actionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() { @Override/*from ww w.j ava 2 s .c om*/ public void addCriteria(DynamicQuery dynamicQuery) { Criterion criterion = RestrictionsFactoryUtil.eq("mimeType", originalMimeTypes[0]); for (int i = 1; i < originalMimeTypes.length; i++) { criterion = RestrictionsFactoryUtil.or(criterion, RestrictionsFactoryUtil.eq("mimeType", originalMimeTypes[i])); } dynamicQuery.add(criterion); } }); actionableDynamicQuery .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<DLFileVersion>() { @Override public void performAction(DLFileVersion dlFileVersion) { InputStream inputStream = null; try { inputStream = _dlFileEntryLocalService.getFileAsStream(dlFileVersion.getFileEntryId(), dlFileVersion.getVersion(), false); } catch (Exception e) { if (_log.isWarnEnabled()) { DLFileEntry dlFileEntry = _dlFileEntryLocalService .fetchDLFileEntry(dlFileVersion.getFileEntryId()); if (dlFileEntry == null) { _log.warn("Unable to find file entry associated " + "with file version " + dlFileVersion.getFileVersionId(), e); } else { StringBundler sb = new StringBundler(4); sb.append("Unable to find file version "); sb.append(dlFileVersion.getVersion()); sb.append(" for file entry "); sb.append(dlFileEntry.getName()); _log.warn(sb.toString(), e); } } return; } String title = DLUtil.getTitleWithExtension(dlFileVersion.getTitle(), dlFileVersion.getExtension()); String mimeType = getMimeType(inputStream, title); if (mimeType.equals(dlFileVersion.getMimeType())) { return; } dlFileVersion.setMimeType(mimeType); _dlFileVersionLocalService.updateDLFileVersion(dlFileVersion); try { DLFileEntry dlFileEntry = dlFileVersion.getFileEntry(); if (Objects.equals(dlFileEntry.getVersion(), dlFileVersion.getVersion())) { dlFileEntry.setMimeType(mimeType); _dlFileEntryLocalService.updateDLFileEntry(dlFileEntry); } } catch (PortalException pe) { if (_log.isWarnEnabled()) { _log.warn("Unable to get file entry " + dlFileVersion.getFileEntryId(), pe); } } } }); if (_log.isDebugEnabled()) { long count = actionableDynamicQuery.performCount(); _log.debug("Processing " + count + " file versions with mime types: " + StringUtil.merge(originalMimeTypes, StringPool.COMMA)); } actionableDynamicQuery.performActions(); }
From source file:com.liferay.document.library.web.internal.portlet.action.EditFileEntryMVCActionCommand.java
License:Open Source License
protected String[] getAllowedFileExtensions(PortletConfig portletConfig, PortletRequest portletRequest, PortletResponse portletResponse) throws PortalException { String portletName = portletConfig.getPortletName(); if (!portletName.equals(DLPortletKeys.MEDIA_GALLERY_DISPLAY)) { return PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA); } else {/* w w w.j a v a 2s . c o m*/ ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); DLPortletInstanceSettings dlPortletInstanceSettings = DLPortletInstanceSettings .getInstance(themeDisplay.getLayout(), portletDisplay.getId()); Set<String> extensions = new HashSet<>(); String[] mimeTypes = dlPortletInstanceSettings.getMimeTypes(); for (String mimeType : mimeTypes) { extensions.addAll(MimeTypesUtil.getExtensions(mimeType)); } return extensions.toArray(new String[extensions.size()]); } }
From source file:com.liferay.dynamic.data.lists.service.impl.DDLRecordLocalServiceImpl.java
License:Open Source License
protected Fields toFields(long ddmStructureId, Map<String, Serializable> fieldsMap, Locale locale, Locale defaultLocale, boolean create) { Fields fields = new Fields(); for (Map.Entry<String, Serializable> entry : fieldsMap.entrySet()) { Field field = new Field(); field.setDDMStructureId(ddmStructureId); field.setName(entry.getKey());/*from w ww. ja va2 s . c o m*/ field.addValue(locale, String.valueOf(entry.getValue())); if (create && !locale.equals(defaultLocale)) { field.addValue(defaultLocale, String.valueOf(entry.getValue())); } field.setDefaultLocale(defaultLocale); fields.put(field); } Field fieldsDisplayField = fields.get(_FIELDS_DISPLAY_NAME); if (fieldsDisplayField == null) { StringBundler fieldsDisplayFieldSB = new StringBundler(fieldsMap.size() * 4 - 1); for (String fieldName : fields.getNames()) { fieldsDisplayFieldSB.append(fieldName); fieldsDisplayFieldSB.append(_INSTANCE_SEPARATOR); fieldsDisplayFieldSB.append(StringUtil.randomString()); fieldsDisplayFieldSB.append(StringPool.COMMA); } if (fieldsDisplayFieldSB.index() > 0) { fieldsDisplayFieldSB.setIndex(fieldsDisplayFieldSB.index() - 1); } fieldsDisplayField = new Field(ddmStructureId, _FIELDS_DISPLAY_NAME, fieldsDisplayFieldSB.toString()); fields.put(fieldsDisplayField); } return fields; }
From source file:com.liferay.dynamic.data.lists.service.persistence.impl.DDLRecordPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, DDLRecord> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from www . j a v a 2 s . c om*/ Map<Serializable, DDLRecord> map = new HashMap<Serializable, DDLRecord>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); DDLRecord ddlRecord = fetchByPrimaryKey(primaryKey); if (ddlRecord != null) { map.put(primaryKey, ddlRecord); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(DDLRecordModelImpl.ENTITY_CACHE_ENABLED, DDLRecordImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (DDLRecord) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_DDLRECORD_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 (DDLRecord ddlRecord : (List<DDLRecord>) q.list()) { map.put(ddlRecord.getPrimaryKeyObj(), ddlRecord); cacheResult(ddlRecord); uncachedPrimaryKeys.remove(ddlRecord.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(DDLRecordModelImpl.ENTITY_CACHE_ENABLED, DDLRecordImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }