You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/08/29 20:47:04 UTC
[1/2] git commit: More JSON serialization fixes: EntityRef and
CredentialsInfo should not be serialized with type info.
Repository: incubator-usergrid
Updated Branches:
refs/heads/two-dot-o b1c70510b -> 985572799
More JSON serialization fixes: EntityRef and CredentialsInfo should not be serialized with type info.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/dc12e8b6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/dc12e8b6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/dc12e8b6
Branch: refs/heads/two-dot-o
Commit: dc12e8b60bad2709fc53c63ab7d92eed158a0144
Parents: b09b154
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Aug 29 13:47:13 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Aug 29 13:47:13 2014 -0400
----------------------------------------------------------------------
.../usergrid/persistence/CredentialsInfo.java | 13 +-
.../apache/usergrid/persistence/EntityRef.java | 4 -
.../persistence/GeoQueryBooleanTest.java | 64 ++--
.../common/src/test/resources/log4j.properties | 29 ++
.../persistence/model/field/AbstractField.java | 2 +-
.../usergrid/persistence/model/field/Field.java | 2 +-
.../model/src/test/resources/log4j.properties | 29 ++
.../usergrid/persistence/index/query/Query.java | 15 +-
.../persistence/index/utils/JsonUtils.java | 329 -------------------
9 files changed, 120 insertions(+), 367 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/dc12e8b6/stack/core/src/main/java/org/apache/usergrid/persistence/CredentialsInfo.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/CredentialsInfo.java b/stack/core/src/main/java/org/apache/usergrid/persistence/CredentialsInfo.java
index edfffcf..957f8a8 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/CredentialsInfo.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/CredentialsInfo.java
@@ -17,23 +17,16 @@
package org.apache.usergrid.persistence;
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.io.Serializable;
import java.util.Map;
import java.util.TreeMap;
-
import javax.xml.bind.annotation.XmlRootElement;
-//import org.codehaus.jackson.annotate.JsonAnyGetter;
-//import org.codehaus.jackson.annotate.JsonAnySetter;
-//import org.codehaus.jackson.annotate.JsonTypeInfo;
-//import org.codehaus.jackson.map.annotate.JsonSerialize;
-//import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
-import com.fasterxml.jackson.annotation.*;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
@XmlRootElement
-@JsonTypeInfo( use= JsonTypeInfo.Id.CLASS,include= JsonTypeInfo.As.WRAPPER_OBJECT,property="@class" )
public class CredentialsInfo implements Comparable<CredentialsInfo>,Serializable {
boolean recoverable;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/dc12e8b6/stack/core/src/main/java/org/apache/usergrid/persistence/EntityRef.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityRef.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityRef.java
index 8133840..56c75cc 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityRef.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityRef.java
@@ -16,12 +16,8 @@
*/
package org.apache.usergrid.persistence;
-
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-
import java.util.UUID;
-@JsonTypeInfo( use= JsonTypeInfo.Id.CLASS,include= JsonTypeInfo.As.WRAPPER_OBJECT,property="@class" )
public interface EntityRef {
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/dc12e8b6/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
index 8ba860a..0d9810f 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
@@ -123,6 +123,8 @@ public class GeoQueryBooleanTest extends AbstractCoreIT {
EntityManager em = setup.getEmf().getEntityManager( applicationId );
assertNotNull( em );
+ // define two users at a location
+
Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
put( "username", "bart" );
put( "email", "bart@example.com" );
@@ -132,6 +134,7 @@ public class GeoQueryBooleanTest extends AbstractCoreIT {
add( new LinkedHashMap<String, Object>() {{ put("name", "mina"); }});
}});
put( "blockedBy", new ArrayList<Object>() {{
+ add( new LinkedHashMap<String, Object>() {{ put("name", "gertrude"); }});
add( new LinkedHashMap<String, Object>() {{ put("name", "isabell"); }});
}});
put( "location", new LinkedHashMap<String, Object>() {{
@@ -142,25 +145,46 @@ public class GeoQueryBooleanTest extends AbstractCoreIT {
Entity userBart = em.create( "user", properties );
assertNotNull( userBart );
-//
-// properties = new LinkedHashMap<String, Object>() {{
-// put( "username", "fred" );
-// put( "email", "fred@example.com" );
-// put( "block", new ArrayList<Object>() {{
-// add( new LinkedHashMap<String, Object>() {{ put("name", "steve"); }});
-// add( new LinkedHashMap<String, Object>() {{ put("name", "mina"); }});
-// }});
-// put( "blockedBy", new ArrayList<Object>() {{
-// add( new LinkedHashMap<String, Object>() {{ put("name", "bart"); }});
-// }});
-// put( "location", new LinkedHashMap<String, Object>() {{
-// put("latitude", 37.776753 );
-// put("longitude", -122.407846 );
-// }} );
-// }};
-//
-// Entity userFred = em.create( "user", properties );
-// assertNotNull( userFred );
- }
+
+ properties = new LinkedHashMap<String, Object>() {{
+ put( "username", "fred" );
+ put( "email", "fred@example.com" );
+ put( "block", new ArrayList<Object>() {{
+ add( new LinkedHashMap<String, Object>() {{ put("name", "steve"); }});
+ add( new LinkedHashMap<String, Object>() {{ put("name", "mina"); }});
+ }});
+ put( "blockedBy", new ArrayList<Object>() {{
+ add( new LinkedHashMap<String, Object>() {{ put("name", "bart"); }});
+ add( new LinkedHashMap<String, Object>() {{ put("name", "beth"); }});
+ }});
+ put( "location", new LinkedHashMap<String, Object>() {{
+ put("latitude", 37.776753 );
+ put("longitude", -122.407846 );
+ }} );
+ }};
+
+ Entity userFred = em.create( "user", properties );
+ assertNotNull( userFred );
+
+ em.refreshIndex();
+
+ // define center point about 300m from that location
+ Point center = new Point( 37.774277, -122.404744 );
+
+ // one user within 400 meters IS NOT blocked by bart
+ Query query = Query.fromQL(
+ "select * where NOT blockedBy.name='bart' and location within 400 of "
+ + center.getLat() + "," + center.getLon());
+ Results listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ assertEquals( 2, listResults.size() );
+
+ // one user within 400 meters IS blocked by bart
+ query = Query.fromQL(
+ "select * where blockedBy.name='bart' and location within 400 of "
+ + center.getLat() + "," + center.getLon());
+ listResults = em.searchCollection( em.getApplicationRef(), "users", query );
+ assertEquals( 2, listResults.size() );
+
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/dc12e8b6/stack/corepersistence/common/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/test/resources/log4j.properties b/stack/corepersistence/common/src/test/resources/log4j.properties
new file mode 100644
index 0000000..6f6d1be
--- /dev/null
+++ b/stack/corepersistence/common/src/test/resources/log4j.properties
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# for production, you should probably set the root to INFO
+# and the pattern to %c instead of %l. (%l is slower.)
+
+# output messages into a rolling log file as well as stdout
+log4j.rootLogger=INFO,stdout
+
+# stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+#log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %p (%t) %c{1} - %m%n
+
+log4j.logger.org.apache.usergrid=INFO
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/dc12e8b6/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/AbstractField.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/AbstractField.java b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/AbstractField.java
index 17af18c..0283277 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/AbstractField.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/AbstractField.java
@@ -25,7 +25,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
/**
* Base class for data information
*/
-@JsonTypeInfo( use= JsonTypeInfo.Id.CLASS,include= JsonTypeInfo.As.WRAPPER_OBJECT,property="@class" )
+@JsonTypeInfo( use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class" )
public abstract class AbstractField<T> implements Field<T> {
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/dc12e8b6/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/Field.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/Field.java b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/Field.java
index 8419b6b..9da0d4e 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/Field.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/field/Field.java
@@ -29,7 +29,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
* (in the java runtime) The V is the value of the field
* @param <T>
*/
-@JsonTypeInfo( use= JsonTypeInfo.Id.CLASS,include= JsonTypeInfo.As.WRAPPER_OBJECT,property="@class" )
+@JsonTypeInfo( use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class" )
public interface Field<T> extends Serializable {
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/dc12e8b6/stack/corepersistence/model/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/test/resources/log4j.properties b/stack/corepersistence/model/src/test/resources/log4j.properties
new file mode 100644
index 0000000..6f6d1be
--- /dev/null
+++ b/stack/corepersistence/model/src/test/resources/log4j.properties
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# for production, you should probably set the root to INFO
+# and the pattern to %c instead of %l. (%l is slower.)
+
+# output messages into a rolling log file as well as stdout
+log4j.rootLogger=INFO,stdout
+
+# stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+#log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %p (%t) %c{1} - %m%n
+
+log4j.logger.org.apache.usergrid=INFO
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/dc12e8b6/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
index 569c08d..f845e63 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
@@ -30,6 +30,8 @@ import java.util.Set;
import java.util.UUID;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.ClassicToken;
import org.antlr.runtime.CommonTokenStream;
@@ -55,7 +57,6 @@ import org.apache.usergrid.persistence.index.query.tree.Operand;
import org.apache.usergrid.persistence.index.query.tree.QueryVisitor;
import org.apache.usergrid.persistence.index.utils.ClassUtils;
import org.apache.usergrid.persistence.index.utils.ConversionUtils;
-import org.apache.usergrid.persistence.index.utils.JsonUtils;
import org.apache.usergrid.persistence.index.utils.ListUtils;
import org.apache.usergrid.persistence.index.utils.MapUtils;
import org.elasticsearch.index.query.FilterBuilder;
@@ -102,6 +103,9 @@ public class Query {
private String collection;
private String ql;
+ private static ObjectMapper mapper = new ObjectMapper();
+
+
List<Operand> filterClauses = new ArrayList<Operand>();
public Query() {
@@ -232,7 +236,14 @@ public class Query {
public static Query fromJsonString( String json ) throws QueryParseException {
- Object o = JsonUtils.parse( json );
+
+ Object o;
+ try {
+ o = mapper.readValue( json, Object.class );
+ } catch (IOException ex) {
+ throw new QueryParseException("Error parsing JSON query string " + json, ex);
+ }
+
if ( o instanceof Map ) {
@SuppressWarnings({ "unchecked", "rawtypes" }) Map<String, List<String>> params =
ClassUtils.cast( MapUtils.toMapList( ( Map ) o ) );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/dc12e8b6/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/JsonUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/JsonUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/JsonUtils.java
deleted file mode 100644
index f44be17..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/JsonUtils.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.persistence.index.utils;
-
-
-import java.io.File;
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.usergrid.persistence.index.exceptions.JsonReadException;
-import org.apache.usergrid.persistence.index.exceptions.JsonWriteException;
-
-import com.fasterxml.jackson.core.io.JsonStringEncoder;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.dataformat.smile.SmileFactory;
-
-//import org.codehaus.jackson.JsonNode;
-//import org.codehaus.jackson.io.JsonStringEncoder;
-//import org.codehaus.jackson.map.ObjectMapper;
-//import org.codehaus.jackson.map.SerializationConfig.Feature;
-//import org.codehaus.jackson.smile.SmileFactory;
-
-
-public class JsonUtils {
-
- private static final Logger LOG = LoggerFactory.getLogger( JsonUtils.class );
-
- static ObjectMapper mapper = new ObjectMapper();
-
- static SmileFactory smile = new SmileFactory();
-
- static ObjectMapper smileMapper = new ObjectMapper( smile );
-
- private static ObjectMapper indentObjectMapper = new ObjectMapper();
-
-
- static {
- indentObjectMapper.getSerializationConfig().with( SerializationFeature.INDENT_OUTPUT);
- }
-
-
- /** Converts object to JSON string, throws runtime exception JsonWriteException on failure. */
- public static String mapToJsonString( Object obj ) {
- try {
- return mapper.writeValueAsString( obj );
- }
- catch ( Throwable t ) {
- LOG.debug( "Error generating JSON", t );
- throw new JsonWriteException( "Error generating JSON", t );
- }
- }
-
-
- /** Converts object to JSON string, throws runtime exception JsonWriteException on failure. */
- public static String mapToFormattedJsonString( Object obj ) {
- try {
- return indentObjectMapper.writeValueAsString( obj );
- }
- catch ( Throwable t ) {
- LOG.debug( "Error generating JSON", t );
- throw new JsonWriteException( "Error generating JSON", t );
- }
- }
-
-
- /** Parses JSON string and returns object, throws runtime exception JsonReadException on failure. */
- public static Object parse( String json ) {
- try {
- return mapper.readValue( json, Object.class );
- }
- catch ( Throwable t ) {
- LOG.debug( "Error parsing JSON", t );
- throw new JsonReadException( "Error parsing JSON", t );
- }
- }
-
-
- public static String quoteString( String s ) {
- JsonStringEncoder encoder = new JsonStringEncoder();
- return new String( encoder.quoteAsUTF8( s ) );
- }
-
-
- public static ByteBuffer toByteBuffer( Object obj ) {
- if ( obj == null ) {
- return null;
- }
-
- byte[] bytes = null;
- try {
- bytes = smileMapper.writeValueAsBytes( obj );
- }
- catch ( Exception e ) {
- LOG.error( "Error getting SMILE bytes", e );
- }
- if ( bytes != null ) {
- return ByteBuffer.wrap( bytes );
- }
- return null;
- }
-
-
- public static Object fromByteBuffer( ByteBuffer byteBuffer ) {
- return fromByteBuffer( byteBuffer, Object.class );
- }
-
-
- public static Object fromByteBuffer( ByteBuffer byteBuffer, Class<?> clazz ) {
- if ( ( byteBuffer == null ) || !byteBuffer.hasRemaining() ) {
- return null;
- }
- if ( clazz == null ) {
- clazz = Object.class;
- }
-
- Object obj = null;
- try {
- obj = smileMapper.readValue( byteBuffer.array(), byteBuffer.arrayOffset() + byteBuffer.position(),
- byteBuffer.remaining(), clazz );
- }
- catch ( Exception e ) {
- LOG.error( "Error parsing SMILE bytes", e );
- }
- return obj;
- }
-
-
- public static JsonNode toJsonNode( Object obj ) {
- if ( obj == null ) {
- return null;
- }
- return mapper.convertValue( obj, JsonNode.class );
- }
-
-
- @SuppressWarnings("unchecked")
- public static Map<String, Object> toJsonMap( Object obj ) {
- if ( obj == null ) {
- return null;
- }
-
- return ( Map<String, Object> ) mapper.convertValue( obj, Map.class );
- }
-
-
- private static UUID tryConvertToUUID( Object o ) {
- if ( o instanceof String ) {
- String s = ( String ) o;
- if ( s.length() == 36 ) {
- try {
- return UUID.fromString( s );
- }
- catch ( IllegalArgumentException e ) {
- LOG.warn( "Argument to UUID.fromString({}) was invalid.", s, e );
- }
- }
- }
- return null;
- }
-
-
- public static Object normalizeJsonTree( Object obj ) {
- if ( obj instanceof Map ) {
- @SuppressWarnings("unchecked") Map<Object, Object> m = ( Map<Object, Object> ) obj;
- Object o;
- UUID uuid;
- for ( Object k : m.keySet() ) {
- if ( k instanceof String && ( ( String ) k ).equalsIgnoreCase( "name" ) ) {
- continue;
- }
-
- o = m.get( k );
- uuid = tryConvertToUUID( o );
- if ( uuid != null ) {
- m.put( k, uuid );
- }
- else if ( o instanceof Integer ) {
- m.put( k, ( ( Integer ) o ).longValue() );
- }
- else if ( o instanceof BigInteger ) {
- m.put( k, ( ( BigInteger ) o ).longValue() );
- }
- }
- }
- else if ( obj instanceof List ) {
- @SuppressWarnings("unchecked") List<Object> l = ( List<Object> ) obj;
- Object o;
- UUID uuid;
- for ( int i = 0; i < l.size(); i++ ) {
- o = l.get( i );
- uuid = tryConvertToUUID( o );
- if ( uuid != null ) {
- l.set( i, uuid );
- }
- else if ( ( o instanceof Map ) || ( o instanceof List ) ) {
- normalizeJsonTree( o );
- }
- else if ( o instanceof Integer ) {
- l.set( i, ( ( Integer ) o ).longValue() );
- }
- else if ( o instanceof BigInteger ) {
- l.set( i, ( ( BigInteger ) o ).longValue() );
- }
- }
- }
- else if ( obj instanceof String ) {
- UUID uuid = tryConvertToUUID( obj );
- if ( uuid != null ) {
- return uuid;
- }
- }
- else if ( obj instanceof Integer ) {
- return ( ( Integer ) obj ).longValue();
- }
- else if ( obj instanceof BigInteger ) {
- return ( ( BigInteger ) obj ).longValue();
- }
- else if ( obj instanceof JsonNode ) {
- return mapper.convertValue( obj, Object.class );
- }
- return obj;
- }
-
-
-// public static Object select( Object obj, String path ) {
-// return select( obj, path, false );
-// }
-//
-//
-// public static Object select( Object obj, String path, boolean buildResultTree ) {
-//
-// if ( obj == null ) {
-// return null;
-// }
-//
-// if ( org.apache.commons.lang.StringUtils.isBlank( path ) ) {
-// return obj;
-// }
-//
-// String segment = stringOrSubstringBeforeFirst( path, '.' );
-// String remaining = substringAfter( path, "." );
-//
-// if ( obj instanceof Map ) {
-// Map<?, ?> map = ( Map<?, ?> ) obj;
-// Object child = map.get( segment );
-// Object result = select( child, remaining, buildResultTree );
-// if ( result != null ) {
-// if ( buildResultTree ) {
-// Map<Object, Object> results = new LinkedHashMap<Object, Object>();
-// results.put( segment, result );
-// return results;
-// }
-// else {
-// return result;
-// }
-// }
-// return null;
-// }
-// if ( obj instanceof List ) {
-// List<Object> results = new ArrayList<Object>();
-// List<?> list = ( List<?> ) obj;
-// for ( Object i : list ) {
-// Object result = select( i, path, buildResultTree );
-// if ( result != null ) {
-// results.add( result );
-// }
-// }
-// if ( !results.isEmpty() ) {
-// return results;
-// }
-// return null;
-// }
-//
-// if ( obj instanceof Entity ) {
-// Object child = ( ( Entity ) obj ).getProperty( segment );
-// Object result = select( child, remaining, buildResultTree );
-// if ( result != null ) {
-// if ( buildResultTree ) {
-// Map<Object, Object> results = new LinkedHashMap<Object, Object>();
-// results.put( segment, result );
-// return results;
-// }
-// else {
-// return result;
-// }
-// }
-// else {
-// return result;
-// }
-// }
-//
-// return obj;
-// }
-
-
- public static Object loadFromFilesystem( String filename ) {
- Object json = null;
- try {
- File file = new File( filename );
- json = mapper.readValue( file, Object.class );
- }
- catch ( Exception e ) {
- LOG.error( "Error loading JSON", e );
- }
- return json;
- }
-}
[2/2] git commit: Merge branch 'two-dot-o' of
https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o
Posted by sn...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o
Conflicts:
stack/corepersistence/common/src/test/resources/log4j.properties
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/98557279
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/98557279
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/98557279
Branch: refs/heads/two-dot-o
Commit: 9855727992a46bddba05dcbff7d820abe468023a
Parents: dc12e8b b1c7051
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Aug 29 13:48:51 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Aug 29 13:48:51 2014 -0400
----------------------------------------------------------------------
.gitignore | 4 +-
.../corepersistence/CpRelationManager.java | 27 +-
.../exception/WriteUniqueVerifyException.java | 18 -
.../mvcc/entity/impl/MvccLogEntryImpl.java | 3 +-
.../UniqueValueSerializationStrategyImpl.java | 2 +-
.../mvcc/stage/write/WriteUniqueVerify.java | 7 +-
.../collection/guice/TestModule.java | 2 +
.../mvcc/stage/delete/MarkStartTest.java | 3 +
.../collection/mvcc/stage/load/LoadTest.java | 7 +
.../collection/util/InvalidIdGenerator.java | 14 -
.../src/test/resources/usergrid-UNIT.properties | 1 +
.../core/astyanax/ColumnNameIterator.java | 27 +-
.../persistence/core/astyanax/ColumnSearch.java | 46 +
.../persistence/core/astyanax/ColumnTypes.java | 3 +
.../astyanax/MultiKeyColumnNameIterator.java | 235 ++++
.../core/astyanax/MultiRowColumnIterator.java | 253 +++++
.../core/astyanax/MultiTennantColumnFamily.java | 13 +-
.../core/hystrix/HystrixCassandra.java | 73 +-
.../persistence/core/rx/ObservableIterator.java | 2 +-
.../persistence/core/rx/OrderedMerge.java | 194 ++--
.../core/scope/ApplicationScopeImpl.java | 3 +-
.../core/astyanax/ColumnNameIteratorTest.java | 205 ++++
.../MultiKeyColumnNameIteratorTest.java | 330 ++++++
.../astyanax/MultiRowColumnIteratorTest.java | 502 +++++++++
.../persistence/core/astyanax/TestUtils.java | 76 ++
.../core/cassandra/CassandraRule.java | 24 +-
.../persistence/core/rx/OrderedMergeTest.java | 146 ++-
.../common/src/test/resources/log4j.properties | 38 +-
.../src/test/resources/usergrid.properties | 1 +
stack/corepersistence/graph/pom.xml | 7 +
.../apache/usergrid/persistence/graph/Edge.java | 1 -
.../usergrid/persistence/graph/GraphFig.java | 90 +-
.../persistence/graph/SearchByEdge.java | 8 +-
.../persistence/graph/SearchByEdgeType.java | 18 +-
.../persistence/graph/guice/GraphModule.java | 51 +-
.../persistence/graph/guice/MergedProxy.java | 34 -
.../graph/guice/StorageEdgeSerialization.java | 34 -
.../graph/impl/CollectionIndexObserver.java | 2 +-
.../graph/impl/GraphManagerImpl.java | 54 +-
.../persistence/graph/impl/SimpleEdge.java | 7 +-
.../graph/impl/SimpleMarkedEdge.java | 4 +-
.../graph/impl/SimpleSearchByEdge.java | 20 +-
.../graph/impl/SimpleSearchByEdgeType.java | 22 +-
.../graph/impl/SimpleSearchByIdType.java | 6 +-
.../impl/stage/EdgeDeleteListenerImpl.java | 3 -
.../graph/impl/stage/EdgeDeleteRepairImpl.java | 16 +-
.../graph/impl/stage/EdgeMetaRepair.java | 2 -
.../graph/impl/stage/EdgeMetaRepairImpl.java | 67 +-
.../impl/stage/NodeDeleteListenerImpl.java | 26 +-
.../EdgeMetadataSerialization.java | 3 +-
.../graph/serialization/EdgeSerialization.java | 3 +-
.../graph/serialization/NodeSerialization.java | 3 +-
.../impl/EdgeMetadataSerializationImpl.java | 8 +-
.../impl/EdgeSerializationImpl.java | 1037 ++++--------------
.../impl/NodeSerializationImpl.java | 86 +-
.../serialization/impl/shard/DirectedEdge.java | 41 +
.../impl/shard/DirectedEdgeMeta.java | 575 ++++++++++
.../impl/shard/EdgeColumnFamilies.java | 60 +
.../serialization/impl/shard/EdgeRowKey.java | 44 +
.../impl/shard/EdgeShardSerialization.java | 24 +-
.../impl/shard/EdgeShardStrategy.java | 45 +-
.../impl/shard/NodeShardAllocation.java | 21 +-
.../impl/shard/NodeShardApproximation.java | 31 +-
.../impl/shard/NodeShardCache.java | 21 +-
.../serialization/impl/shard/NodeType.java | 66 ++
.../graph/serialization/impl/shard/RowKey.java | 55 +
.../serialization/impl/shard/RowKeyType.java | 66 ++
.../graph/serialization/impl/shard/Shard.java | 143 +++
.../impl/shard/ShardEntryGroup.java | 324 ++++++
.../impl/shard/ShardGroupCompaction.java | 71 ++
.../impl/shard/ShardedEdgeSerialization.java | 186 ++++
.../serialization/impl/shard/count/Counter.java | 8 +-
.../shard/count/NodeShardApproximationImpl.java | 177 +--
.../count/NodeShardCounterSerialization.java | 2 +-
.../NodeShardCounterSerializationImpl.java | 98 +-
.../impl/shard/count/ShardKey.java | 53 +-
.../impl/shard/impl/EdgeRowKey.java | 46 -
.../impl/shard/impl/EdgeRowKeySerializer.java | 58 -
.../impl/shard/impl/EdgeSearcher.java | 162 +++
.../shard/impl/EdgeShardSerializationImpl.java | 90 +-
.../shard/impl/NodeShardAllocationImpl.java | 288 +++--
.../impl/shard/impl/NodeShardCacheImpl.java | 254 +++--
.../shard/impl/ShardEntryGroupIterator.java | 123 +++
.../shard/impl/ShardGroupColumnIterator.java | 130 +++
.../shard/impl/ShardGroupCompactionImpl.java | 618 +++++++++++
.../impl/ShardedEdgeSerializationImpl.java | 1006 +++++++++++++++++
.../impl/shard/impl/ShardsColumnIterator.java | 127 +++
.../shard/impl/SizebasedEdgeColumnFamilies.java | 154 +++
.../shard/impl/SizebasedEdgeShardStrategy.java | 51 +-
.../impl/shard/impl/SourceEdgeSearcher.java | 22 +
.../DescendingTimestampComparator.java | 43 +
.../DirectedEdgeDescendingComparator.java | 69 ++
.../impl/comparators/OrderedComparator.java | 52 +
.../SourceDirectedEdgeDescendingComparator.java | 42 +
.../TargetDirectedEdgeDescendingComparator.java | 42 +
.../impl/serialize/EdgeRowKeySerializer.java | 63 ++
.../shard/impl/serialize/EdgeSerializer.java | 77 ++
.../serialize/EdgeShardRowKeySerializer.java | 103 ++
.../shard/impl/serialize/RowSerializer.java | 63 ++
.../shard/impl/serialize/RowTypeSerializer.java | 62 ++
.../graph/serialization/util/EdgeHasher.java | 86 --
.../graph/serialization/util/EdgeUtils.java | 132 ---
.../serialization/util/GraphValidation.java | 189 ++++
.../graph/ComittedGraphManagerIT.java | 138 ---
.../graph/CommittedGraphManagerIT.java | 135 +++
.../persistence/graph/GraphManagerIT.java | 3 -
.../persistence/graph/GraphManagerLoadTest.java | 7 +-
.../graph/GraphManagerShardConsistencyIT.java | 563 ++++++++++
.../graph/GraphManagerShardingIT.java | 48 +-
.../graph/GraphManagerStressTest.java | 9 +-
.../usergrid/persistence/graph/SimpleTest.java | 18 +-
.../graph/StorageGraphManagerIT.java | 2 +-
.../graph/impl/EdgeDeleteListenerTest.java | 4 +-
.../graph/impl/NodeDeleteListenerTest.java | 2 -
.../graph/impl/stage/EdgeDeleteRepairTest.java | 7 +-
.../graph/impl/stage/EdgeMetaRepairTest.java | 2 -
.../EdgeMetadataSerializationTest.java | 2 +-
.../EdgeSerializationChopTest.java | 7 +-
.../serialization/NodeSerializationTest.java | 3 +-
.../PermanentSerializationTest.java | 3 -
.../graph/serialization/TestCount.java | 1 -
.../impl/shard/EdgeShardSerializationTest.java | 108 +-
.../impl/shard/NodeShardAllocationTest.java | 620 ++++++++---
.../impl/shard/NodeShardCacheTest.java | 235 ++--
.../impl/shard/ShardEntryGroupTest.java | 409 +++++++
.../impl/shard/ShardGroupCompactionTest.java | 226 ++++
.../shard/count/NodeShardApproximationTest.java | 130 ++-
.../NodeShardCounterSerializationTest.java | 8 +-
.../shard/impl/ShardEntryGroupIteratorTest.java | 276 +++++
...rceDirectedEdgeDescendingComparatorTest.java | 136 +++
...getDirectedEdgeDescendingComparatorTest.java | 136 +++
.../serialization/util/EdgeHasherTest.java | 501 ---------
.../graph/test/util/EdgeTestUtils.java | 12 +-
.../graph/src/test/resources/log4j.properties | 1 +
.../test/resources/usergrid-SHARD.properties | 23 +
.../src/test/resources/usergrid-UNIT.properties | 3 +
.../persistence/model/entity/SimpleIdTest.java | 73 ++
stack/corepersistence/pom.xml | 6 +-
138 files changed, 10787 insertions(+), 3204 deletions(-)
----------------------------------------------------------------------