You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by gr...@apache.org on 2014/12/04 21:11:12 UTC
[37/50] incubator-usergrid git commit: add more validation
add more validation
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/d28af0d8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/d28af0d8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/d28af0d8
Branch: refs/heads/USERGRID-256-ApiResponseImplementation
Commit: d28af0d8fa4fb97cdad51504f825d8cb3baec93a
Parents: e2c1a53
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Dec 2 15:19:26 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Dec 2 15:19:26 2014 -0700
----------------------------------------------------------------------
.../usergrid/persistence/index/impl/EsEntityIndexImpl.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d28af0d8/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 588a5a1..0b1cb0c 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -140,11 +140,12 @@ public class EsEntityIndexImpl implements EntityIndex {
@Override
public void addIndex(final String indexSuffix, final Map<String,Object> config) {
- if(!config.containsKey("replicas") || !config.containsKey("shards")){
- throw new IllegalArgumentException("config must contains 'replicas' and 'shards'");
+ if(!config.containsKey("replicas") || !config.containsKey("shards") ||
+ !(config.get("replicas") instanceof Integer) || !(config.get("shards") instanceof Integer)){
+ throw new IllegalArgumentException("config must contains 'replicas' of type int and 'shards' of type int");
}
String normalizedSuffix = StringUtils.isNotEmpty(indexSuffix) ? indexSuffix : null;
- addIndex(normalizedSuffix, (int) config.get("shards"),(int)config.get("replicas"));
+ addIndex(normalizedSuffix,(int) config.get("shards"),(int)config.get("replicas"));
}
private void addIndex(final String indexSuffix,final int numberOfShards, final int numberOfReplicas) {