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/09/12 01:11:17 UTC

[1/2] usergrid git commit: removing noop exceptions, removing failures due to bad location fields

Repository: usergrid
Updated Branches:
  refs/heads/two-dot-o-dev f24e7e40c -> c3c71c914


removing noop exceptions, removing failures due to bad location fields


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

Branch: refs/heads/two-dot-o-dev
Commit: 98e76ae897484fe8eae2cd0e215b365d23c4916a
Parents: cf6cf83
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Sep 11 17:10:59 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Sep 11 17:10:59 2015 -0600

----------------------------------------------------------------------
 .../model/entity/MapToEntityConverter.java      | 39 ++++++++------------
 .../exceptions/AbstractExceptionMapper.java     | 13 +++++--
 2 files changed, 25 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/98e76ae8/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
index 09cf1f2..e6744c4 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/MapToEntityConverter.java
@@ -163,14 +163,11 @@ public class MapToEntityConverter{
     }
 
 
-    private  void processMapValue(
-            Object value, String fieldName, Entity entity) {
+    private  void processMapValue( Object value, String fieldName, Entity entity) {
 
         // is the map really a location element?
         if ("location" .equals(fieldName.toString().toLowerCase()) ) {
             processLocationField((Map<String, Object>) value, fieldName, entity);
-
-
         } else {
             // not a location element, process it as map
             entity.setField(new EntityObjectField(fieldName,
@@ -187,48 +184,44 @@ public class MapToEntityConverter{
         Map<String, Object> m = new HashMap<String, Object>();
 
         // Tests expect us to treat "Longitude" the same as "longitude"
-        for ( String key : origMap.keySet() ) {
-            m.put( key.toLowerCase(), origMap.get(key) );
+        for (String key : origMap.keySet()) {
+            m.put(key.toLowerCase(), origMap.get(key));
         }
 
-        // Expect at least two fields in a Location object
-        if (m.size() >= 2) {
+        // Expect at least two fields in a Location object and must have lat lon
+        if (m.size() >= 2 && (
+            (m.containsKey("latitude")  && m.containsKey("longitude") )
+                || (m.containsKey("lat") && m.containsKey("lon") )
+        )) {
 
-            Double lat = null;
-            Double lon = null;
+            Double lat, lon;
 
             // check the properties to make sure they are set and are doubles
-            if (m.get("latitude") != null && m.get("longitude") != null) {
+            if (m.containsKey("latitude")  && m.containsKey("longitude")) {
                 try {
                     lat = Double.parseDouble(m.get("latitude").toString());
                     lon = Double.parseDouble(m.get("longitude").toString());
 
                 } catch (NumberFormatException ignored) {
                     throw new IllegalArgumentException(
-                            "Latitude and longitude must be doubles (e.g. 32.1234).");
+                        "Latitude and longitude must be doubles (e.g. 32.1234).");
                 }
-            } else if (m.get("lat") != null && m.get("lon") != null) {
+            } else if (m.containsKey("lat") && m.containsKey("lon")) {
                 try {
                     lat = Double.parseDouble(m.get("lat").toString());
                     lon = Double.parseDouble(m.get("lon").toString());
                 } catch (NumberFormatException ignored) {
                     throw new IllegalArgumentException(""
-                            + "Latitude and longitude must be doubles (e.g. 32.1234).");
+                        + "Latitude and longitude must be doubles (e.g. 32.1234).");
                 }
             } else {
                 throw new IllegalArgumentException("Location properties require two fields - "
-                        + "latitude and longitude, or lat and lon");
+                    + "latitude and longitude, or lat and lon");
             }
 
-            if (lat != null && lon != null) {
-                entity.setField( new LocationField(fieldName, new Location(lat, lon)));
-            } else {
-                throw new IllegalArgumentException( "Unable to parse location field properties "
-                        + "- make sure they conform - lat and lon, and should be doubles.");
-            }
+            entity.setField(new LocationField(fieldName, new Location(lat, lon)));
         } else {
-            throw new IllegalArgumentException("Location properties requires two fields - "
-                    + "latitude and longitude, or lat and lon.");
+            entity.setField(new EntityObjectField(fieldName,fromMap( value, false))); // recursion
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/98e76ae8/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/AbstractExceptionMapper.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/AbstractExceptionMapper.java b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/AbstractExceptionMapper.java
index 77760e0..1dbffbd 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/AbstractExceptionMapper.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/exceptions/AbstractExceptionMapper.java
@@ -49,7 +49,7 @@ public abstract class AbstractExceptionMapper<E extends java.lang.Throwable> imp
 
 
     public boolean isJSONP() {
-        return isJavascript( hh.getAcceptableMediaTypes() );
+        return isJavascript(hh.getAcceptableMediaTypes());
     }
 
 
@@ -71,13 +71,18 @@ public abstract class AbstractExceptionMapper<E extends java.lang.Throwable> imp
             // only log real errors as errors
             logger.error( e.getClass().getCanonicalName() + " Server Error (" + status + ")", e );
 
-        } else if ( logger.isDebugEnabled() ) {
-            logger.debug( e.getClass().getCanonicalName() + " Server Error (" + status + ")", e );
+        } else {
+            if (logger.isDebugEnabled()) {
+                logger.debug(e.getClass().getCanonicalName() + " Server Error (" + status + ")", e);
+            }
+            switch (status){
+                case 200 : logger.info("Uncaught Exception", e); break;
+                default: logger.error("Uncaught Exception", e);
+            }
         }
 
         ApiResponse response = new ApiResponse();
 
-        logger.error("Uncaught Exception", e);
 
         AuthErrorInfo authError = AuthErrorInfo.getForException( e );
 


[2/2] usergrid git commit: Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into two-dot-o-dev

Posted by sf...@apache.org.
Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/usergrid into two-dot-o-dev


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

Branch: refs/heads/two-dot-o-dev
Commit: c3c71c91472045789f06e525d1028061240e0613
Parents: 98e76ae f24e7e4
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Sep 11 17:11:07 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Sep 11 17:11:07 2015 -0600

----------------------------------------------------------------------
 .../asyncevents/AmazonAsyncEventService.java       |  6 +++---
 stack/scripts/migrate_entity_data.py               | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------