You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2015/06/17 17:50:00 UTC

incubator-usergrid git commit: fix index rebuild payload

Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o-dev 4b9a310ea -> 7a54134e5


fix index rebuild payload


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/7a54134e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/7a54134e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/7a54134e

Branch: refs/heads/two-dot-o-dev
Commit: 7a54134e575d4d91956552addc4de8de2bc47e94
Parents: 4b9a310
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Jun 17 09:49:38 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Jun 17 09:49:38 2015 -0600

----------------------------------------------------------------------
 .../org/apache/usergrid/rest/IndexResource.java     | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7a54134e/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
index 1a801f1..ca3f87d 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
@@ -21,6 +21,7 @@
 package org.apache.usergrid.rest;
 
 
+import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
@@ -38,6 +39,7 @@ import javax.ws.rs.core.UriInfo;
 import com.google.common.base.Optional;
 import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.index.utils.ConversionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Scope;
@@ -272,12 +274,18 @@ public class IndexResource extends AbstractContextResource {
                                                             final ReIndexRequestBuilder request,
                                                             final String callback ) {
 
-        Preconditions.checkArgument( payload.containsKey( UPDATED_FIELD ),
-            "You must specified the field \"updated\" in the payload" );
+        Map<String,Object> newPayload = payload;
+        if(newPayload == null ||  !payload.containsKey( UPDATED_FIELD )){
+            newPayload = new HashMap<>(1);
+            newPayload.put(UPDATED_FIELD,0);
+        }
+
+        Preconditions.checkArgument(payload.get(UPDATED_FIELD) instanceof Number,
+                "You must specified the field \"updated\" in the payload and it must be a timestamp" );
 
         //add our updated timestamp to the request
-        if ( !payload.containsKey( UPDATED_FIELD ) ) {
-            final long timestamp = ( long ) payload.get( UPDATED_FIELD );
+        if ( payload.containsKey( UPDATED_FIELD ) ) {
+            final long timestamp = ConversionUtils.getLong(payload.get(UPDATED_FIELD));
             request.withStartTimestamp( timestamp );
         }