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.dynamicdatamapping.service.persistence.DDMStructureFinderImpl.java
License:Open Source License
public List<DDMStructure> findByC_G_C_N_D_S_T(long companyId, long[] groupIds, long[] classNameIds, String[] names, String[] descriptions, String[] storageTypes, int type, boolean andOperator, int start, int end, OrderByComparator orderByComparator) throws SystemException { String[] classNameIdsString = null; if (classNameIds == null) { classNameIdsString = new String[] { null }; } else {//from www . j a v a 2 s.c om classNameIdsString = ArrayUtil.toStringArray(classNameIds); } names = CustomSQLUtil.keywords(names); descriptions = CustomSQLUtil.keywords(descriptions, false); storageTypes = CustomSQLUtil.keywords(storageTypes, false); Session session = null; try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_C_G_C_N_D_S_T); sql = StringUtil.replace(sql, "[$GROUP_ID$]", getGroupIds(groupIds)); sql = CustomSQLUtil.replaceKeywords(sql, "classNameId", StringPool.EQUAL, false, classNameIdsString); sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, false, names); sql = CustomSQLUtil.replaceKeywords(sql, "description", StringPool.LIKE, false, descriptions); sql = CustomSQLUtil.replaceKeywords(sql, "storageType", StringPool.LIKE, true, storageTypes); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); if (orderByComparator != null) { String orderByFields = StringUtil.merge(orderByComparator.getOrderByFields(), StringPool.COMMA); sql = StringUtil.replace(sql, "structureId DESC", orderByFields.concat(" DESC")); } SQLQuery q = session.createSQLQuery(sql); q.addEntity("DDMStructure", DDMStructureImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupIds); qPos.add(classNameIds, 2); qPos.add(names, 2); qPos.add(descriptions, 2); qPos.add(storageTypes, 2); qPos.add(type); return (List<DDMStructure>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.dynamicdatamapping.service.persistence.DDMTemplateFinderImpl.java
License:Open Source License
public List<DDMTemplate> findByC_G_S_N_D_T_M_L(long companyId, long groupId, long structureId, String[] names, String[] descriptions, String[] types, String[] modes, String[] languages, boolean andOperator, int start, int end, OrderByComparator orderByComparator) throws SystemException { names = CustomSQLUtil.keywords(names); descriptions = CustomSQLUtil.keywords(descriptions, false); types = CustomSQLUtil.keywords(types, false); modes = CustomSQLUtil.keywords(modes, false); languages = CustomSQLUtil.keywords(languages, false); Session session = null;/*from w w w .j a va 2s. c o m*/ try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_C_G_S_N_D_T_M_L); if (groupId <= 0) { sql = StringUtil.replace(sql, "(groupId = ?) AND", ""); } if (structureId <= 0) { sql = StringUtil.replace(sql, "(structureId = ?) AND", ""); } sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, false, names); sql = CustomSQLUtil.replaceKeywords(sql, "description", StringPool.LIKE, false, descriptions); sql = CustomSQLUtil.replaceKeywords(sql, "type", StringPool.LIKE, false, types); sql = CustomSQLUtil.replaceKeywords(sql, "mode", StringPool.LIKE, false, modes); sql = CustomSQLUtil.replaceKeywords(sql, "language", StringPool.LIKE, false, languages); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); if (orderByComparator != null) { String orderByFields = StringUtil.merge(orderByComparator.getOrderByFields(), StringPool.COMMA); sql = StringUtil.replace(sql, "templateId DESC", orderByFields.concat(" DESC")); } SQLQuery q = session.createSQLQuery(sql); q.addEntity("DDMTemplate", DDMTemplateImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (groupId > 0) { qPos.add(groupId); } if (structureId > 0) { qPos.add(structureId); } qPos.add(names, 2); qPos.add(descriptions, 2); qPos.add(types, 2); qPos.add(modes, 2); qPos.add(languages, 2); return (List<DDMTemplate>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.expando.action.EditExpandoAction.java
License:Open Source License
protected Serializable getValue(PortletRequest portletRequest, String name, int type) throws PortalException, SystemException { String delimiter = StringPool.COMMA; Serializable value = null;/* www. j av a2s . c o m*/ if (type == ExpandoColumnConstants.BOOLEAN) { value = ParamUtil.getBoolean(portletRequest, name); } else if (type == ExpandoColumnConstants.BOOLEAN_ARRAY) { } else if (type == ExpandoColumnConstants.DATE) { User user = PortalUtil.getUser(portletRequest); int valueDateMonth = ParamUtil.getInteger(portletRequest, name + "Month"); int valueDateDay = ParamUtil.getInteger(portletRequest, name + "Day"); int valueDateYear = ParamUtil.getInteger(portletRequest, name + "Year"); int valueDateHour = ParamUtil.getInteger(portletRequest, name + "Hour"); int valueDateMinute = ParamUtil.getInteger(portletRequest, name + "Minute"); int valueDateAmPm = ParamUtil.getInteger(portletRequest, name + "AmPm"); if (valueDateAmPm == Calendar.PM) { valueDateHour += 12; } value = PortalUtil.getDate(valueDateMonth, valueDateDay, valueDateYear, valueDateHour, valueDateMinute, user.getTimeZone(), new ValueDataException()); } else if (type == ExpandoColumnConstants.DATE_ARRAY) { } else if (type == ExpandoColumnConstants.DOUBLE) { value = ParamUtil.getDouble(portletRequest, name); } else if (type == ExpandoColumnConstants.DOUBLE_ARRAY) { String paramValue = ParamUtil.getString(portletRequest, name); if (paramValue.contains(StringPool.NEW_LINE)) { delimiter = StringPool.NEW_LINE; } String[] values = StringUtil.split(paramValue, delimiter); value = GetterUtil.getDoubleValues(values); } else if (type == ExpandoColumnConstants.FLOAT) { value = ParamUtil.getFloat(portletRequest, name); } else if (type == ExpandoColumnConstants.FLOAT_ARRAY) { String paramValue = ParamUtil.getString(portletRequest, name); if (paramValue.contains(StringPool.NEW_LINE)) { delimiter = StringPool.NEW_LINE; } String[] values = StringUtil.split(paramValue, delimiter); value = GetterUtil.getFloatValues(values); } else if (type == ExpandoColumnConstants.INTEGER) { value = ParamUtil.getInteger(portletRequest, name); } else if (type == ExpandoColumnConstants.INTEGER_ARRAY) { String paramValue = ParamUtil.getString(portletRequest, name); if (paramValue.contains(StringPool.NEW_LINE)) { delimiter = StringPool.NEW_LINE; } String[] values = StringUtil.split(paramValue, delimiter); value = GetterUtil.getIntegerValues(values); } else if (type == ExpandoColumnConstants.LONG) { value = ParamUtil.getLong(portletRequest, name); } else if (type == ExpandoColumnConstants.LONG_ARRAY) { String paramValue = ParamUtil.getString(portletRequest, name); if (paramValue.contains(StringPool.NEW_LINE)) { delimiter = StringPool.NEW_LINE; } String[] values = StringUtil.split(paramValue, delimiter); value = GetterUtil.getLongValues(values); } else if (type == ExpandoColumnConstants.SHORT) { value = ParamUtil.getShort(portletRequest, name); } else if (type == ExpandoColumnConstants.SHORT_ARRAY) { String paramValue = ParamUtil.getString(portletRequest, name); if (paramValue.contains(StringPool.NEW_LINE)) { delimiter = StringPool.NEW_LINE; } String[] values = StringUtil.split(paramValue, delimiter); value = GetterUtil.getShortValues(values); } else if (type == ExpandoColumnConstants.STRING_ARRAY) { String paramValue = ParamUtil.getString(portletRequest, name); if (paramValue.contains(StringPool.NEW_LINE)) { delimiter = StringPool.NEW_LINE; } value = StringUtil.split(paramValue, delimiter); } else { value = ParamUtil.getString(portletRequest, name); } return value; }
From source file:com.liferay.portlet.expando.model.impl.ExpandoValueImpl.java
License:Open Source License
public String[] getStringArray() throws PortalException, SystemException { validate(ExpandoColumnConstants.STRING_ARRAY); String[] dataArray = StringUtil.split(getData()); for (int i = 0; i < dataArray.length; i++) { dataArray[i] = StringUtil.replace(dataArray[i], _EXPANDO_COMMA, StringPool.COMMA); }/*from ww w .ja v a 2 s.c om*/ return dataArray; }
From source file:com.liferay.portlet.expando.model.impl.ExpandoValueImpl.java
License:Open Source License
public void setStringArray(String[] data) throws PortalException, SystemException { validate(ExpandoColumnConstants.STRING_ARRAY); if (data != null) { for (int i = 0; i < data.length; i++) { data[i] = StringUtil.replace(data[i], StringPool.COMMA, _EXPANDO_COMMA); }// w ww .j a v a2 s . co m } setData(StringUtil.merge(data)); }
From source file:com.liferay.portlet.journal.search.StructureDisplayTerms.java
License:Open Source License
public String getGroupIds(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); String strutsAction = ParamUtil.getString(portletRequest, "struts_action"); StringBundler sb = new StringBundler(); long groupId = ParamUtil.getLong(portletRequest, "groupId"); if (groupId > 0) { sb.append(groupId);/*from www . j a va 2 s.c o m*/ } else { sb.append(themeDisplay.getScopeGroupId()); } if (strutsAction.equalsIgnoreCase("/journal/select_structure")) { sb.append(StringPool.COMMA); sb.append(themeDisplay.getCompanyGroupId()); } return sb.toString(); }
From source file:com.liferay.portlet.journal.search.TemplateDisplayTerms.java
License:Open Source License
public String getGroupIds(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); String strutsAction = ParamUtil.getString(portletRequest, "struts_action"); long groupId = ParamUtil.getLong(portletRequest, "groupId"); StringBundler sb = new StringBundler(); if (groupId > 0) { sb.append(groupId);// ww w . j a v a2 s . c o m } else { sb.append(themeDisplay.getScopeGroupId()); } if (strutsAction.equalsIgnoreCase("/journal/select_template")) { sb.append(StringPool.COMMA); sb.append(themeDisplay.getCompanyGroupId()); } return sb.toString(); }
From source file:com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
protected void checkStructureField(Element el, Document contentDoc) throws PortalException { StringBuilder elPath = new StringBuilder(); elPath.append(el.attributeValue("name")); Element elParent = el.getParent(); for (;;) {/*w w w . ja va2 s . c o m*/ if ((elParent == null) || (elParent.getName().equals("root"))) { break; } elPath.insert(0, elParent.attributeValue("name") + StringPool.COMMA); elParent = elParent.getParent(); } String[] elPathNames = StringUtil.split(elPath.toString()); Element contentEl = contentDoc.getRootElement(); for (String _elPathName : elPathNames) { boolean foundEl = false; for (Element tempEl : contentEl.elements()) { if (_elPathName.equals(tempEl.attributeValue("name", StringPool.BLANK))) { contentEl = tempEl; foundEl = true; break; } } if (!foundEl) { String elType = contentEl.attributeValue("type", StringPool.BLANK); if (!elType.equals("list") && !elType.equals("multi-list")) { throw new StructureXsdException(elPath.toString()); } break; } } }
From source file:com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
protected void validate(long companyId, long groupId, long classNameId, Map<Locale, String> titleMap, String content, String type, String structureId, String templateId, boolean smallImage, String smallImageURL, File smallImageFile, byte[] smallImageBytes) throws PortalException, SystemException { Locale defaultLocale = LocaleUtil.fromLanguageId(LocalizationUtil.getDefaultLocale(content)); if ((classNameId == 0) && (titleMap.isEmpty() || Validator.isNull(titleMap.get(defaultLocale)))) { throw new ArticleTitleException(); } else if (Validator.isNull(type)) { throw new ArticleTypeException(); }//from www . j av a2s .com validateContent(content); if (Validator.isNotNull(structureId)) { Group companyGroup = groupLocalService.getCompanyGroup(companyId); try { journalStructurePersistence.findByG_S(groupId, structureId); } catch (NoSuchStructureException nsse) { journalStructurePersistence.findByG_S(companyGroup.getGroupId(), structureId); } JournalTemplate template = null; if (Validator.isNotNull(templateId)) { try { template = journalTemplatePersistence.findByG_T(groupId, templateId); } catch (NoSuchTemplateException nste) { template = journalTemplatePersistence.findByG_T(companyGroup.getGroupId(), templateId); } if (!template.getStructureId().equals(structureId)) { throw new NoSuchTemplateException(); } } else if (classNameId == 0) { throw new NoSuchTemplateException(); } } String[] imageExtensions = PrefsPropsUtil.getStringArray(PropsKeys.JOURNAL_IMAGE_EXTENSIONS, StringPool.COMMA); if (smallImage && Validator.isNull(smallImageURL) && (smallImageFile != null) && (smallImageBytes != null)) { String smallImageName = smallImageFile.getName(); if (smallImageName != null) { boolean validSmallImageExtension = false; for (String _imageExtension : imageExtensions) { if (StringPool.STAR.equals(_imageExtension) || StringUtil.endsWith(smallImageName, _imageExtension)) { validSmallImageExtension = true; break; } } if (!validSmallImageExtension) { throw new ArticleSmallImageNameException(smallImageName); } } long smallImageMaxSize = PrefsPropsUtil.getLong(PropsKeys.JOURNAL_IMAGE_SMALL_MAX_SIZE); if ((smallImageMaxSize > 0) && ((smallImageBytes == null) || (smallImageBytes.length > smallImageMaxSize))) { throw new ArticleSmallImageSizeException(); } } }
From source file:com.liferay.portlet.journal.service.impl.JournalTemplateLocalServiceImpl.java
License:Open Source License
protected void validate(Map<Locale, String> nameMap, String xsl, boolean smallImage, String smallImageURL, File smallImageFile, byte[] smallImageBytes) throws PortalException, SystemException { Locale locale = LocaleUtil.getDefault(); if (nameMap.isEmpty() || Validator.isNull(nameMap.get(locale))) { throw new TemplateNameException(); } else if (Validator.isNull(xsl)) { throw new TemplateXslException(); }/*from w ww . ja va2 s . c om*/ String[] imageExtensions = PrefsPropsUtil.getStringArray(PropsKeys.JOURNAL_IMAGE_EXTENSIONS, StringPool.COMMA); 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 TemplateSmallImageNameException(smallImageName); } } long smallImageMaxSize = PrefsPropsUtil.getLong(PropsKeys.JOURNAL_IMAGE_SMALL_MAX_SIZE); if ((smallImageMaxSize > 0) && ((smallImageBytes == null) || (smallImageBytes.length > smallImageMaxSize))) { throw new TemplateSmallImageSizeException(); } } }