diff --git a/pom.xml b/pom.xml
index c44d43dea..3fcf60214 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,6 +56,7 @@
commons-lang
commons-lang
${commonslang}
+ test
diff --git a/src/main/java/org/springframework/data/elasticsearch/client/NodeClientFactoryBean.java b/src/main/java/org/springframework/data/elasticsearch/client/NodeClientFactoryBean.java
index 7371c45e8..6c47d7d10 100644
--- a/src/main/java/org/springframework/data/elasticsearch/client/NodeClientFactoryBean.java
+++ b/src/main/java/org/springframework/data/elasticsearch/client/NodeClientFactoryBean.java
@@ -18,7 +18,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
-import org.apache.commons.lang.StringUtils;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.settings.Settings;
@@ -31,6 +30,8 @@
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.StringUtils;
+
import static java.util.Arrays.*;
/**
@@ -95,7 +96,7 @@ public void afterPropertiesSet() throws Exception {
}
private Settings loadConfig() throws IOException {
- if (StringUtils.isNotBlank(pathConfiguration)) {
+ if (!StringUtils.isEmpty(pathConfiguration)) {
InputStream stream = getClass().getClassLoader().getResourceAsStream(pathConfiguration);
if (stream != null) {
return Settings.builder().loadFromStream(pathConfiguration, getClass().getClassLoader().getResourceAsStream(pathConfiguration), false).build();
diff --git a/src/main/java/org/springframework/data/elasticsearch/client/TransportClientFactoryBean.java b/src/main/java/org/springframework/data/elasticsearch/client/TransportClientFactoryBean.java
index a3bc1ab00..c049a804a 100644
--- a/src/main/java/org/springframework/data/elasticsearch/client/TransportClientFactoryBean.java
+++ b/src/main/java/org/springframework/data/elasticsearch/client/TransportClientFactoryBean.java
@@ -15,8 +15,6 @@
*/
package org.springframework.data.elasticsearch.client;
-import static org.apache.commons.lang.StringUtils.*;
-
import java.net.InetAddress;
import java.util.Properties;
@@ -30,6 +28,7 @@
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
/**
* TransportClientFactoryBean
@@ -91,13 +90,19 @@ protected void buildClient() throws Exception {
client = new PreBuiltTransportClient(settings());
Assert.hasText(clusterNodes, "[Assertion failed] clusterNodes settings missing.");
- for (String clusterNode : split(clusterNodes, COMMA)) {
- String hostName = substringBeforeLast(clusterNode, COLON);
- String port = substringAfterLast(clusterNode, COLON);
- Assert.hasText(hostName, "[Assertion failed] missing host name in 'clusterNodes'");
- Assert.hasText(port, "[Assertion failed] missing port in 'clusterNodes'");
- logger.info("adding transport node : " + clusterNode);
- client.addTransportAddress(new TransportAddress(InetAddress.getByName(hostName), Integer.valueOf(port)));
+ String[] clusterNodesArray = StringUtils.split(clusterNodes, COMMA);
+ if (clusterNodesArray != null) {
+ for (String clusterNode : clusterNodesArray) {
+ if (clusterNode != null) {
+ int colonPosition = clusterName.lastIndexOf(COLON);
+ String hostName = colonPosition != -1 ? clusterNode.substring(0, colonPosition) : clusterNode;
+ String port = colonPosition != -1 ? clusterNode.substring(colonPosition, clusterNode.length()) : "";
+ Assert.hasText(hostName, "[Assertion failed] missing host name in 'clusterNodes'");
+ Assert.hasText(port, "[Assertion failed] missing port in 'clusterNodes'");
+ logger.info("adding transport node : " + clusterNode);
+ client.addTransportAddress(new TransportAddress(InetAddress.getByName(hostName), Integer.valueOf(port)));
+ }
+ }
}
client.connectedNodes();
}
diff --git a/src/main/java/org/springframework/data/elasticsearch/core/AbstractResultMapper.java b/src/main/java/org/springframework/data/elasticsearch/core/AbstractResultMapper.java
index c558bb757..213a4f096 100644
--- a/src/main/java/org/springframework/data/elasticsearch/core/AbstractResultMapper.java
+++ b/src/main/java/org/springframework/data/elasticsearch/core/AbstractResultMapper.java
@@ -15,12 +15,11 @@
*/
package org.springframework.data.elasticsearch.core;
-import static org.apache.commons.lang.StringUtils.*;
-
import java.io.IOException;
import org.springframework.data.elasticsearch.ElasticsearchException;
import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
/**
* @author Artur Konczak
@@ -37,7 +36,7 @@ public AbstractResultMapper(EntityMapper entityMapper) {
}
public T mapEntity(String source, Class clazz) {
- if (isBlank(source)) {
+ if (StringUtils.isEmpty(source)) {
return null;
}
try {
diff --git a/src/main/java/org/springframework/data/elasticsearch/core/DefaultResultMapper.java b/src/main/java/org/springframework/data/elasticsearch/core/DefaultResultMapper.java
index efedfaa1d..318e2212d 100644
--- a/src/main/java/org/springframework/data/elasticsearch/core/DefaultResultMapper.java
+++ b/src/main/java/org/springframework/data/elasticsearch/core/DefaultResultMapper.java
@@ -23,7 +23,6 @@
import java.util.LinkedList;
import java.util.List;
-import org.apache.commons.lang.StringUtils;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.get.MultiGetItemResponse;
import org.elasticsearch.action.get.MultiGetResponse;
@@ -45,6 +44,7 @@
import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
+import org.springframework.util.StringUtils;
/**
* @author Artur Konczak
@@ -98,7 +98,7 @@ public AggregatedPage mapResults(SearchResponse response, Class clazz,
for (SearchHit hit : response.getHits()) {
if (hit != null) {
T result = null;
- if (StringUtils.isNotBlank(hit.getSourceAsString())) {
+ if (!StringUtils.isEmpty(hit.getSourceAsString())) {
result = mapEntity(hit.getSourceAsString(), clazz);
} else {
result = mapEntity(hit.getFields().values(), clazz);
diff --git a/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplate.java b/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplate.java
index e45875d68..ce0a33d66 100755
--- a/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplate.java
+++ b/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplate.java
@@ -15,7 +15,6 @@
*/
package org.springframework.data.elasticsearch.core;
-import static org.apache.commons.lang.StringUtils.*;
import static org.elasticsearch.client.Requests.*;
import static org.elasticsearch.index.VersionType.*;
import static org.elasticsearch.index.query.QueryBuilders.*;
@@ -115,6 +114,7 @@
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
import org.springframework.data.util.CloseableIterator;
import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
/**
* ElasticsearchTemplate
@@ -202,9 +202,9 @@ public boolean createIndex(String indexName) {
public boolean putMapping(Class clazz) {
if (clazz.isAnnotationPresent(Mapping.class)) {
String mappingPath = clazz.getAnnotation(Mapping.class).mappingPath();
- if (isNotBlank(mappingPath)) {
+ if (!StringUtils.isEmpty(mappingPath)) {
String mappings = readFileFromClasspath(mappingPath);
- if (isNotBlank(mappings)) {
+ if (!StringUtils.isEmpty(mappings)) {
return putMapping(clazz, mappings);
}
} else {
@@ -588,9 +588,9 @@ public UpdateResponse update(UpdateQuery query) {
}
private UpdateRequestBuilder prepareUpdate(UpdateQuery query) {
- String indexName = isNotBlank(query.getIndexName()) ? query.getIndexName()
+ String indexName = !StringUtils.isEmpty(query.getIndexName()) ? query.getIndexName()
: getPersistentEntityFor(query.getClazz()).getIndexName();
- String type = isNotBlank(query.getType()) ? query.getType()
+ String type = !StringUtils.isEmpty(query.getType()) ? query.getType()
: getPersistentEntityFor(query.getClazz()).getIndexType();
Assert.notNull(indexName, "No index defined for Query");
Assert.notNull(type, "No type define for Query");
@@ -690,9 +690,9 @@ public String delete(Class clazz, String id) {
@Override
public void delete(DeleteQuery deleteQuery, Class clazz) {
- String indexName = isNotBlank(deleteQuery.getIndex()) ? deleteQuery.getIndex()
+ String indexName = !StringUtils.isEmpty(deleteQuery.getIndex()) ? deleteQuery.getIndex()
: getPersistentEntityFor(clazz).getIndexName();
- String typeName = isNotBlank(deleteQuery.getType()) ? deleteQuery.getType()
+ String typeName = !StringUtils.isEmpty(deleteQuery.getType()) ? deleteQuery.getType()
: getPersistentEntityFor(clazz).getIndexType();
Integer pageSize = deleteQuery.getPageSize() != null ? deleteQuery.getPageSize() : 1000;
Long scrollTimeInMillis = deleteQuery.getScrollTimeInMillis() != null ? deleteQuery.getScrollTimeInMillis()
@@ -849,8 +849,8 @@ public void clearScroll(String scrollId) {
public Page moreLikeThis(MoreLikeThisQuery query, Class clazz) {
ElasticsearchPersistentEntity persistentEntity = getPersistentEntityFor(clazz);
- String indexName = isNotBlank(query.getIndexName()) ? query.getIndexName() : persistentEntity.getIndexName();
- String type = isNotBlank(query.getType()) ? query.getType() : persistentEntity.getIndexType();
+ String indexName = !StringUtils.isEmpty(query.getIndexName()) ? query.getIndexName() : persistentEntity.getIndexName();
+ String type = !StringUtils.isEmpty(query.getType()) ? query.getType() : persistentEntity.getIndexType();
Assert.notNull(indexName, "No 'indexName' defined for MoreLikeThisQuery");
Assert.notNull(type, "No 'type' defined for MoreLikeThisQuery");
@@ -945,9 +945,9 @@ private boolean createIndexIfNotCreated(Class clazz) {
private boolean createIndexWithSettings(Class clazz) {
if (clazz.isAnnotationPresent(Setting.class)) {
String settingPath = clazz.getAnnotation(Setting.class).settingPath();
- if (isNotBlank(settingPath)) {
+ if (!StringUtils.isEmpty(settingPath)) {
String settings = readFileFromClasspath(settingPath);
- if (isNotBlank(settings)) {
+ if (!StringUtils.isEmpty(settings)) {
return createIndex(getPersistentEntityFor(clazz).getIndexName(), settings);
}
} else {
@@ -1068,16 +1068,16 @@ private SearchRequestBuilder prepareSearch(Query query) {
private IndexRequestBuilder prepareIndex(IndexQuery query) {
try {
- String indexName = isBlank(query.getIndexName())
+ String indexName = StringUtils.isEmpty(query.getIndexName())
? retrieveIndexNameFromPersistentEntity(query.getObject().getClass())[0]
: query.getIndexName();
- String type = isBlank(query.getType()) ? retrieveTypeFromPersistentEntity(query.getObject().getClass())[0]
+ String type = StringUtils.isEmpty(query.getType()) ? retrieveTypeFromPersistentEntity(query.getObject().getClass())[0]
: query.getType();
IndexRequestBuilder indexRequestBuilder = null;
if (query.getObject() != null) {
- String id = isBlank(query.getId()) ? getPersistentEntityId(query.getObject()) : query.getId();
+ String id = StringUtils.isEmpty(query.getId()) ? getPersistentEntityId(query.getObject()) : query.getId();
// If we have a query id and a document id, do not ask ES to generate one.
if (id != null) {
indexRequestBuilder = client.prepareIndex(indexName, type, id);
@@ -1130,11 +1130,11 @@ public Boolean addAlias(AliasQuery query) {
aliasAction.filter(query.getFilterBuilder());
} else if (query.getFilter() != null) {
aliasAction.filter(query.getFilter());
- } else if (isNotBlank(query.getRouting())) {
+ } else if (!StringUtils.isEmpty(query.getRouting())) {
aliasAction.routing(query.getRouting());
- } else if (isNotBlank(query.getSearchRouting())) {
+ } else if (!StringUtils.isEmpty(query.getSearchRouting())) {
aliasAction.searchRouting(query.getSearchRouting());
- } else if (isNotBlank(query.getIndexRouting())) {
+ } else if (!StringUtils.isEmpty(query.getIndexRouting())) {
aliasAction.indexRouting(query.getIndexRouting());
}
return client.admin().indices().prepareAliases().addAliasAction(aliasAction).execute().actionGet().isAcknowledged();
diff --git a/src/main/java/org/springframework/data/elasticsearch/core/MappingBuilder.java b/src/main/java/org/springframework/data/elasticsearch/core/MappingBuilder.java
index 78fd60498..27fb73546 100644
--- a/src/main/java/org/springframework/data/elasticsearch/core/MappingBuilder.java
+++ b/src/main/java/org/springframework/data/elasticsearch/core/MappingBuilder.java
@@ -37,7 +37,8 @@
import org.springframework.data.mapping.model.SimpleTypeHolder;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
-import static org.apache.commons.lang.StringUtils.*;
+import org.springframework.util.StringUtils;
+
import static org.elasticsearch.common.xcontent.XContentFactory.*;
import static org.springframework.util.StringUtils.*;
@@ -88,7 +89,7 @@ static XContentBuilder buildMapping(Class clazz, String indexType, String idFiel
// Properties
XContentBuilder xContentBuilder = mapping.startObject(FIELD_PROPERTIES);
- mapEntity(xContentBuilder, clazz, true, idFieldName, EMPTY, false, FieldType.Auto, null);
+ mapEntity(xContentBuilder, clazz, true, idFieldName, "", false, FieldType.Auto, null);
return xContentBuilder.endObject().endObject().endObject();
}
@@ -119,7 +120,7 @@ private static void mapEntity(XContentBuilder xContentBuilder, Class clazz, bool
if (field.isAnnotationPresent(Mapping.class)) {
String mappingPath = field.getAnnotation(Mapping.class).mappingPath();
- if (isNotBlank(mappingPath)) {
+ if (!StringUtils.isEmpty(mappingPath)) {
ClassPathResource mappings = new ClassPathResource(mappingPath);
if (mappings.exists()) {
xContentBuilder.rawField(field.getName(), mappings.getInputStream());
@@ -137,7 +138,7 @@ private static void mapEntity(XContentBuilder xContentBuilder, Class clazz, bool
continue;
}
boolean nestedOrObject = isNestedOrObjectField(field);
- mapEntity(xContentBuilder, getFieldType(field), false, EMPTY, field.getName(), nestedOrObject, singleField.type(), field.getAnnotation(Field.class));
+ mapEntity(xContentBuilder, getFieldType(field), false, "", field.getName(), nestedOrObject, singleField.type(), field.getAnnotation(Field.class));
if (nestedOrObject) {
continue;
}
@@ -203,10 +204,10 @@ private static void applyCompletionFieldMapping(XContentBuilder xContentBuilder,
xContentBuilder.field(COMPLETION_MAX_INPUT_LENGTH, annotation.maxInputLength());
xContentBuilder.field(COMPLETION_PRESERVE_POSITION_INCREMENTS, annotation.preservePositionIncrements());
xContentBuilder.field(COMPLETION_PRESERVE_SEPARATORS, annotation.preserveSeparators());
- if (isNotBlank(annotation.searchAnalyzer())) {
+ if (!StringUtils.isEmpty(annotation.searchAnalyzer())) {
xContentBuilder.field(FIELD_SEARCH_ANALYZER, annotation.searchAnalyzer());
}
- if (isNotBlank(annotation.analyzer())) {
+ if (!StringUtils.isEmpty(annotation.analyzer())) {
xContentBuilder.field(FIELD_INDEX_ANALYZER, annotation.analyzer());
}
}
@@ -311,10 +312,10 @@ private static void addFieldMappingParameters(XContentBuilder builder, Object an
if (!index) {
builder.field(FIELD_INDEX, index);
}
- if (isNotBlank(analyzer)) {
+ if (!StringUtils.isEmpty(analyzer)) {
builder.field(FIELD_INDEX_ANALYZER, analyzer);
}
- if (isNotBlank(searchAnalyzer)) {
+ if (!StringUtils.isEmpty(searchAnalyzer)) {
builder.field(FIELD_SEARCH_ANALYZER, searchAnalyzer);
}
}
diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/HistogramFacetRequest.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/HistogramFacetRequest.java
index 6ba538155..eeae24238 100644
--- a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/HistogramFacetRequest.java
+++ b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/HistogramFacetRequest.java
@@ -16,14 +16,13 @@
package org.springframework.data.elasticsearch.core.facet.request;
-import org.apache.commons.lang.StringUtils;
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramAggregationBuilder;
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
import org.springframework.data.elasticsearch.core.facet.AbstractFacetRequest;
import org.springframework.util.Assert;
-
+import org.springframework.util.StringUtils;
/**
* @author Artur Konczak
@@ -54,7 +53,7 @@ public void setTimeUnit(DateHistogramInterval timeUnit) {
public AbstractAggregationBuilder getFacet() {
Assert.notNull(getName(), "Facet name can't be a null !!!");
- Assert.isTrue(StringUtils.isNotBlank(field), "Please select field on which to build the facet !!!");
+ Assert.isTrue(!StringUtils.isEmpty(field), "Please select field on which to build the facet !!!");
Assert.isTrue(interval > 0, "Please provide interval as positive value greater them zero !!!");
DateHistogramAggregationBuilder dateHistogramBuilder = AggregationBuilders.dateHistogram(getName());
diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/RangeFacetRequest.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/RangeFacetRequest.java
index 5f7139a27..d8d5e5b16 100644
--- a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/RangeFacetRequest.java
+++ b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/RangeFacetRequest.java
@@ -19,13 +19,12 @@
import java.util.ArrayList;
import java.util.List;
-import org.apache.commons.lang.StringUtils;
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.range.RangeAggregationBuilder;
import org.springframework.data.elasticsearch.core.facet.AbstractFacetRequest;
import org.springframework.util.Assert;
-
+import org.springframework.util.StringUtils;
/**
* Range facet for numeric fields
@@ -77,7 +76,7 @@ public AbstractAggregationBuilder getFacet() {
Assert.notNull(getName(), "Facet name can't be a null !!!");
RangeAggregationBuilder rangeBuilder = AggregationBuilders.range(getName());
- final String field = StringUtils.isNotBlank(keyField) ? keyField : this.field;
+ final String field = !StringUtils.isEmpty(keyField) ? keyField : this.field;
rangeBuilder.field(field);
for (Entry entry : entries) {
@@ -86,7 +85,7 @@ public AbstractAggregationBuilder getFacet() {
}
rangeBuilder.subAggregation(AggregationBuilders.extendedStats(INTERNAL_STATS).field(field));
- if(StringUtils.isNotBlank(valueField)){
+ if(!StringUtils.isEmpty(valueField)){
rangeBuilder.subAggregation(AggregationBuilders.sum(RANGE_INTERNAL_SUM).field(valueField));
}
diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/StatisticalFacetRequest.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/StatisticalFacetRequest.java
index 85496b349..d514becef 100644
--- a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/StatisticalFacetRequest.java
+++ b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/StatisticalFacetRequest.java
@@ -16,12 +16,11 @@
package org.springframework.data.elasticsearch.core.facet.request;
-import org.apache.commons.lang.StringUtils;
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.springframework.data.elasticsearch.core.facet.AbstractFacetRequest;
import org.springframework.util.Assert;
-
+import org.springframework.util.StringUtils;
/**
* @author Petar Tahchiev
@@ -47,7 +46,7 @@ public void setFields(String... fields) {
public AbstractAggregationBuilder getFacet() {
Assert.notNull(getName(), "Facet name can't be a null !!!");
- Assert.isTrue(StringUtils.isNotBlank(field) && fields == null, "Please select field or fields on which to build the facets !!!");
+ Assert.isTrue(!StringUtils.isEmpty(field) && fields == null, "Please select field or fields on which to build the facets !!!");
return AggregationBuilders.extendedStats(getName()).field(field);
}
}
\ No newline at end of file
diff --git a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/TermFacetRequest.java b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/TermFacetRequest.java
index caa652642..19bef1480 100644
--- a/src/main/java/org/springframework/data/elasticsearch/core/facet/request/TermFacetRequest.java
+++ b/src/main/java/org/springframework/data/elasticsearch/core/facet/request/TermFacetRequest.java
@@ -16,8 +16,6 @@
package org.springframework.data.elasticsearch.core.facet.request;
-import org.apache.commons.lang.ArrayUtils;
-import org.apache.commons.lang.StringUtils;
import org.apache.lucene.util.automaton.RegExp;
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
import org.elasticsearch.search.aggregations.AggregationBuilders;
@@ -26,6 +24,8 @@
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.springframework.data.elasticsearch.core.facet.AbstractFacetRequest;
import org.springframework.util.Assert;
+import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
/**
* Term facet
@@ -48,8 +48,8 @@ public TermFacetRequest(String name) {
}
public void setFields(String... fields) {
- Assert.isTrue(ArrayUtils.isNotEmpty(fields), "Term agg need one field only");
- Assert.isTrue(ArrayUtils.getLength(fields) == 1, "Term agg need one field only");
+ Assert.isTrue(!ObjectUtils.isEmpty(fields), "Term agg need one field only");
+ Assert.isTrue(fields.length == 1, "Term agg need one field only");
this.fields = fields;
}
@@ -92,7 +92,7 @@ public AbstractAggregationBuilder getFacet() {
default:
termsBuilder.order(BucketOrder.count(true));
}
- if (ArrayUtils.isNotEmpty(excludeTerms)) {
+ if (!ObjectUtils.isEmpty(excludeTerms)) {
termsBuilder.includeExclude(new IncludeExclude(null, excludeTerms));
}
@@ -100,7 +100,7 @@ public AbstractAggregationBuilder getFacet() {
termsBuilder.size(Integer.MAX_VALUE);
}
- if (StringUtils.isNotBlank(regex)) {
+ if (!StringUtils.isEmpty(regex)) {
termsBuilder.includeExclude(new IncludeExclude(new RegExp(regex), null));
}
diff --git a/src/main/java/org/springframework/data/elasticsearch/core/query/Criteria.java b/src/main/java/org/springframework/data/elasticsearch/core/query/Criteria.java
index 687cf7492..8da40560b 100644
--- a/src/main/java/org/springframework/data/elasticsearch/core/query/Criteria.java
+++ b/src/main/java/org/springframework/data/elasticsearch/core/query/Criteria.java
@@ -17,7 +17,8 @@
import java.util.*;
-import org.apache.commons.lang.StringUtils;
+import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.elasticsearch.core.geo.GeoBox;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
@@ -42,8 +43,8 @@ public String toString() {
"field=" + field.getName() +
", boost=" + boost +
", negating=" + negating +
- ", queryCriteria=" + StringUtils.join(queryCriteria, '|') +
- ", filterCriteria=" + StringUtils.join(filterCriteria, '|') +
+ ", queryCriteria=" + ObjectUtils.nullSafeToString(queryCriteria) +
+ ", filterCriteria=" + ObjectUtils.nullSafeToString(filterCriteria) +
'}';
}
@@ -437,7 +438,7 @@ public Criteria within(Point location, Distance distance) {
* @return
*/
public Criteria within(String geoLocation, String distance) {
- Assert.isTrue(StringUtils.isNotBlank(geoLocation), "geoLocation value must not be null");
+ Assert.isTrue(!StringUtils.isEmpty(geoLocation), "geoLocation value must not be null");
filterCriteria.add(new CriteriaEntry(OperationKey.WITHIN, new Object[]{geoLocation, distance}));
return this;
}
@@ -474,8 +475,8 @@ public Criteria boundedBy(Box boundingBox) {
* @return Criteria the chaind criteria with the new 'boundedBy' criteria included.
*/
public Criteria boundedBy(String topLeftGeohash, String bottomRightGeohash) {
- Assert.isTrue(StringUtils.isNotBlank(topLeftGeohash), "topLeftGeohash must not be empty");
- Assert.isTrue(StringUtils.isNotBlank(bottomRightGeohash), "bottomRightGeohash must not be empty");
+ Assert.isTrue(!StringUtils.isEmpty(topLeftGeohash), "topLeftGeohash must not be empty");
+ Assert.isTrue(!StringUtils.isEmpty(bottomRightGeohash), "bottomRightGeohash must not be empty");
filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{topLeftGeohash, bottomRightGeohash}));
return this;
}
@@ -502,7 +503,7 @@ public Criteria boundedBy(Point topLeftPoint, Point bottomRightPoint) {
}
private void assertNoBlankInWildcardedQuery(String searchString, boolean leadingWildcard, boolean trailingWildcard) {
- if (StringUtils.contains(searchString, CRITERIA_VALUE_SEPERATOR)) {
+ if (searchString != null && searchString.contains(CRITERIA_VALUE_SEPERATOR)) {
throw new InvalidDataAccessApiUsageException("Cannot constructQuery '" + (leadingWildcard ? "*" : "") + "\""
+ searchString + "\"" + (trailingWildcard ? "*" : "") + "'. Use expression or multiple clauses instead.");
}