List of usage examples for com.liferay.portal.kernel.util StringUtil quote
public static String quote(String s)
From source file:com.liferay.document.library.repository.cmis.internal.CMISRepository.java
License:Open Source License
protected List<String> getCmisFolderIds(Session session, long folderId) throws PortalException { StringBundler sb = new StringBundler(4); sb.append("SELECT cmis:objectId FROM cmis:folder"); if (folderId > 0) { sb.append(" WHERE IN_FOLDER("); String objectId = toFolderId(session, folderId); sb.append(StringUtil.quote(objectId)); sb.append(StringPool.CLOSE_PARENTHESIS); }//from www .j ava2s .co m String query = sb.toString(); if (_log.isDebugEnabled()) { _log.debug("Calling query " + query); } ItemIterable<QueryResult> queryResults = session.query(query, isAllVersionsSearchableSupported(session)); List<String> cmsFolderIds = new ArrayList<>(); for (QueryResult queryResult : queryResults) { PropertyData<String> propertyData = queryResult.getPropertyById(PropertyIds.OBJECT_ID); List<String> values = propertyData.getValues(); String value = values.get(0); cmsFolderIds.add(value); } return cmsFolderIds; }
From source file:com.liferay.document.library.repository.cmis.internal.CMISRepository.java
License:Open Source License
protected List<String> getDocumentIds(Session session, long folderId, String[] mimeTypes) throws PortalException { StringBundler sb = new StringBundler(); sb.append("SELECT cmis:objectId FROM cmis:document"); if (ArrayUtil.isNotEmpty(mimeTypes)) { sb.append(" WHERE cmis:contentStreamMimeType IN ("); for (int i = 0; i < mimeTypes.length; i++) { sb.append(StringUtil.quote(mimeTypes[i])); if ((i + 1) < mimeTypes.length) { sb.append(", "); }/* w ww. j a va 2 s. c o m*/ } sb.append(StringPool.CLOSE_PARENTHESIS); } if (folderId > 0) { if (ArrayUtil.isNotEmpty(mimeTypes)) { sb.append(" AND "); } else { sb.append(" WHERE "); } sb.append("IN_FOLDER("); String objectId = toFolderId(session, folderId); sb.append(StringUtil.quote(objectId)); sb.append(StringPool.CLOSE_PARENTHESIS); } String query = sb.toString(); if (_log.isDebugEnabled()) { _log.debug("Calling query " + query); } ItemIterable<QueryResult> queryResults = session.query(query, false); List<String> cmisDocumentIds = new ArrayList<>(); for (QueryResult queryResult : queryResults) { String objectId = queryResult.getPropertyValueByQueryName(PropertyIds.OBJECT_ID); cmisDocumentIds.add(objectId); } return cmisDocumentIds; }
From source file:com.liferay.dynamic.data.lists.form.web.internal.converter.DDLFormRuleToDDMFormRuleConverter.java
License:Open Source License
protected String convertOperand(DDLFormRuleCondition.Operand operand) { if (Objects.equals("field", operand.getType())) { return String.format(_functionCallUnaryExpressionFormat, "getValue", StringUtil.quote(operand.getValue())); }/*from w w w .j a v a2 s .co m*/ return StringUtil.quote(operand.getValue()); }
From source file:com.liferay.dynamic.data.lists.form.web.internal.converter.serializer.AutoFillDDLFormRuleActionSerializer.java
License:Open Source License
@Override public String serialize() { return String.format(_functionCallTernaryExpressionFormat, "call", StringUtil.quote(_autoFillDDLFormRuleAction.getDDMDataProviderInstanceUUID()), convertAutoFillInputParameters(_autoFillDDLFormRuleAction.getInputParametersMapper()), convertAutoFillOutputParameters(_autoFillDDLFormRuleAction.getOutputParametersMapper())); }
From source file:com.liferay.dynamic.data.lists.form.web.internal.converter.serializer.AutoFillDDLFormRuleActionSerializer.java
License:Open Source License
protected String convertAutoFillInputParameters(Map<String, String> inputParametersMapper) { if (MapUtil.isEmpty(inputParametersMapper)) { return StringUtil.quote(StringPool.BLANK); }//from w ww . j ava2s . c om StringBundler sb = new StringBundler(inputParametersMapper.size() * 4 - 1); for (Entry<String, String> inputParameterMapper : inputParametersMapper.entrySet()) { sb.append(inputParameterMapper.getKey()); sb.append(CharPool.EQUAL); sb.append(inputParameterMapper.getValue()); sb.append(CharPool.SEMICOLON); } sb.setIndex(sb.index() - 1); return StringUtil.quote(sb.toString()); }
From source file:com.liferay.dynamic.data.lists.form.web.internal.converter.serializer.AutoFillDDLFormRuleActionSerializer.java
License:Open Source License
protected String convertAutoFillOutputParameters(Map<String, String> outputParametersMapper) { if (MapUtil.isEmpty(outputParametersMapper)) { return StringUtil.quote(StringPool.BLANK); }/*from w ww. j a va 2 s.c o m*/ StringBundler sb = new StringBundler(outputParametersMapper.size() * 4 - 1); for (Entry<String, String> outputParameterMapper : outputParametersMapper.entrySet()) { sb.append(outputParameterMapper.getValue()); sb.append(CharPool.EQUAL); sb.append(outputParameterMapper.getKey()); sb.append(CharPool.SEMICOLON); } sb.setIndex(sb.index() - 1); return StringUtil.quote(sb.toString()); }
From source file:com.liferay.dynamic.data.mapping.form.builder.internal.converter.DDMFormRuleConverter.java
License:Open Source License
protected String convertOperand(DDMFormRuleCondition.Operand operand) { if (Objects.equals("field", operand.getType())) { return String.format(_functionCallUnaryExpressionFormat, "getValue", StringUtil.quote(operand.getValue())); }/*from w ww .j ava 2 s . co m*/ String value = operand.getValue(); if (isNumericConstant(operand.getType())) { return value; } String[] values = StringUtil.split(value); UnaryOperator<String> quoteOperation = StringUtil::quote; UnaryOperator<String> trimOperation = StringUtil::trim; Stream<String> valuesStream = Stream.of(values); Stream<String> valueStream = valuesStream.map(trimOperation.andThen(quoteOperation)); return valueStream.collect(Collectors.joining(StringPool.COMMA_AND_SPACE)); }
From source file:com.liferay.dynamic.data.mapping.form.builder.internal.converter.serializer.AutoFillDDMFormRuleActionSerializer.java
License:Open Source License
@Override public String serialize(DDMFormRuleSerializerContext ddmFormRuleSerializerContext) { return String.format(_functionCallTernaryExpressionFormat, "call", StringUtil.quote(_autoFillDDMFormRuleAction.getDDMDataProviderInstanceUUID()), convertAutoFillInputParameters(_autoFillDDMFormRuleAction.getInputParametersMapper()), convertAutoFillOutputParameters(_autoFillDDMFormRuleAction.getOutputParametersMapper())); }
From source file:com.liferay.dynamic.data.mapping.internal.upgrade.v1_0_2.UpgradeDDMStructure.java
License:Open Source License
protected DDMFormRule getSetVisibleDDMFormRule(String ddmFormFieldName, String visibilityExpression) throws DDMExpressionException { try {//from w w w . j a va2 s. c o m DDMExpression<Boolean> ddmExpression = _ddmExpressionFactory .createBooleanDDMExpression(visibilityExpression); Map<String, VariableDependencies> variableDependencies = ddmExpression.getVariableDependenciesMap(); String condition = visibilityExpression; for (String variable : variableDependencies.keySet()) { condition = StringUtil.replace(condition, new String[] { variable }, new String[] { "getValue(" + StringUtil.quote(variable) + ")" }, true); } return new DDMFormRule(condition, "setVisible('" + ddmFormFieldName + "', true)"); } catch (DDMExpressionException ddmee) { _log.error(String.format("Unable to upgrade the visibility expression \"%s\" to a " + "form rule", visibilityExpression), ddmee); throw ddmee; } }
From source file:com.liferay.portlet.dynamicdatamapping.storage.ExpandoStorageAdapter.java
License:Open Source License
private String _toExpression(FieldCondition fieldCondition) { StringBundler sb = new StringBundler(5); sb.append("(@"); sb.append(fieldCondition.getName()); ComparisonOperator comparisonOperator = fieldCondition.getComparisonOperator(); if (comparisonOperator.equals(ComparisonOperator.LIKE)) { sb.append(".data matches "); } else {//w ww . ja v a 2 s. c o m sb.append(".data == "); } String value = StringUtil.quote(String.valueOf(fieldCondition.getValue())); sb.append(value); sb.append(StringPool.CLOSE_PARENTHESIS); return sb.toString(); }