usergrid git commit: Added tests and read repair to the guts of 1.0

2015-11-10 Thread grey
Repository: usergrid
Updated Branches:
  refs/heads/readRepairForIndexValues [created] a67057909


Added tests and read repair to the guts of 1.0


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

Branch: refs/heads/readRepairForIndexValues
Commit: a67057909e480c97273c9f6c366643069f24e114
Parents: 7db5769
Author: George Reyes 
Authored: Tue Nov 10 09:06:15 2015 -0800
Committer: George Reyes 
Committed: Tue Nov 10 09:06:15 2015 -0800

--
 .../cassandra/EntityManagerImpl.java|  32 
 .../usergrid/persistence/EntityManagerIT.java   |   2 +
 .../usergrid/services/ServiceRequestIT.java | 169 ++-
 3 files changed, 202 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/usergrid/blob/a6705790/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
--
diff --git 
a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
 
b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
index 4a6e2ea..ecd0f0a 100644
--- 
a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
+++ 
b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
@@ -109,6 +109,7 @@ import static java.lang.String.CASE_INSENSITIVE_ORDER;
 import static java.util.Arrays.asList;
 
 import static 
me.prettyprint.hector.api.factory.HFactory.createCounterSliceQuery;
+import static me.prettyprint.hector.api.factory.HFactory.createMutator;
 import static org.apache.commons.lang.StringUtils.capitalize;
 import static org.apache.commons.lang.StringUtils.isBlank;
 import static org.apache.usergrid.locking.LockHelper.getUniqueUpdateLock;
@@ -156,6 +157,7 @@ import static 
org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtil
 import static 
org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.key;
 import static 
org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.toStorableBinaryValue;
 import static 
org.apache.usergrid.persistence.cassandra.CassandraService.ALL_COUNT;
+import static 
org.apache.usergrid.persistence.cassandra.CassandraService.MANAGEMENT_APPLICATION_ID;
 import static org.apache.usergrid.persistence.cassandra.Serializers.be;
 import static org.apache.usergrid.persistence.cassandra.Serializers.le;
 import static org.apache.usergrid.persistence.cassandra.Serializers.se;
@@ -538,6 +540,8 @@ public class EntityManagerImpl implements EntityManager {
 
 Object key = createUniqueIndexKey( ownerEntityId, 
collectionNameInternal, propertyName, propertyValue );
 
+//need to fix by asking todd as to why 2.
+//why is this set to 2?
 List> cols =
 cass.getColumns( cass.getApplicationKeyspace( applicationId ), 
ENTITY_UNIQUE, key, null, null, 2,
 false );
@@ -549,12 +553,40 @@ public class EntityManagerImpl implements EntityManager {
 }
 
 //shouldn't happen, but it's an error case
+
 if ( cols.size() > 1 ) {
 logger.error( "INDEX CORRUPTION: More than 1 unique value exists 
for entities in ownerId {} of type {} on "
 + "property {} with value {}",
 new Object[] { ownerEntityId, collectionNameInternal, 
propertyName, propertyValue } );
+
+//retreive up to 100 columns
+List> indexingColumns = 
cass.getColumns( cass.getApplicationKeyspace( applicationId ), ENTITY_UNIQUE, 
key, null, null, 100,
+false );
+
+
+
+//go through it column
+for ( HColumn col : indexingColumns ) {
+UUID indexCorruptionUuid = ue.fromByteBuffer( col.getName());
+if (get( indexCorruptionUuid ) == null ) {
+UUID timestampUuid = newTimeUUID();
+long timestamp = getTimestampInMicros( timestampUuid );
+Keyspace ko = cass.getApplicationKeyspace( ownerEntityId );
+Mutator mutator = createMutator( ko, be );
+
+addDeleteToMutator( mutator, ENTITY_UNIQUE, key, 
indexCorruptionUuid, timestamp );
+mutator.execute();
+cols.remove( col );
+}
+else{
+
+}
+}
 }
 
+cols = cass.getColumns( cass.getApplicationKeyspace( applicationId ), 

usergrid git commit: Added message that indicates it has completed

2015-11-10 Thread grey
Repository: usergrid
Updated Branches:
  refs/heads/USERGRID-1076 0ba197e43 -> 7db57696f


Added message that indicates it has completed


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

Branch: refs/heads/USERGRID-1076
Commit: 7db57696f70859c73cde5c32773e0339f17790bf
Parents: 0ba197e
Author: George Reyes 
Authored: Tue Nov 10 09:05:21 2015 -0800
Committer: George Reyes 
Committed: Tue Nov 10 09:05:21 2015 -0800

--
 .../src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java | 1 +
 1 file changed, 1 insertion(+)
--


http://git-wip-us.apache.org/repos/asf/usergrid/blob/7db57696/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
--
diff --git 
a/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java 
b/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
index fe3a74e..e835bec 100644
--- 
a/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
+++ 
b/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
@@ -217,6 +217,7 @@ public class UniqueIndexCleanup extends ToolBase {
 }
 }
 }
+System.out.println("Completed repair.");
 
 logger.info( "Completed audit of apps" );
 }



usergrid git commit: Bump portal version.

2015-11-10 Thread mrusso
Repository: usergrid
Updated Branches:
  refs/heads/master f7785c2ab -> 40e002b97


Bump portal version.


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

Branch: refs/heads/master
Commit: 40e002b971d01fe13a96f0d27a4a1d3959bb65eb
Parents: f7785c2
Author: Michael Russo 
Authored: Tue Nov 10 12:01:49 2015 -0800
Committer: Michael Russo 
Committed: Tue Nov 10 12:01:49 2015 -0800

--
 portal/bower.json   | 2 +-
 portal/package.json | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/usergrid/blob/40e002b9/portal/bower.json
--
diff --git a/portal/bower.json b/portal/bower.json
index 7ffb4ff..8179100 100644
--- a/portal/bower.json
+++ b/portal/bower.json
@@ -1,6 +1,6 @@
 {
   "name": "usergrid-portal",
-  "version": "2.0.18",
+  "version": "2.0.19",
   "ignore": [
 ".jshintrc",
 "**/*.txt",

http://git-wip-us.apache.org/repos/asf/usergrid/blob/40e002b9/portal/package.json
--
diff --git a/portal/package.json b/portal/package.json
index e36a910..74a68ac 100644
--- a/portal/package.json
+++ b/portal/package.json
@@ -1,6 +1,6 @@
 {
   "name": "usergrid", 
-  "version": "2.0.18",
+  "version": "2.0.19",
   "packageName": "appsvc-ui",
   "description": "full usergrid portal",
   "main": "./scripts/web-server.js",



usergrid git commit: Added ignore to test for use case that doesn't currently work. Added ability to filter out multiple entities with the same user name ( pick the one one modified last )

2015-11-10 Thread grey
Repository: usergrid
Updated Branches:
  refs/heads/USERGRID-1076 7db57696f -> 2e8bc4632


Added ignore to test for use case that doesn't currently work.
Added ability to filter out multiple entities with the same user name ( pick 
the one one modified last )


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

Branch: refs/heads/USERGRID-1076
Commit: 2e8bc46329b11d5e625d75aad1b3dbb1d39e91ee
Parents: 7db5769
Author: George Reyes 
Authored: Tue Nov 10 12:22:41 2015 -0800
Committer: George Reyes 
Committed: Tue Nov 10 12:22:41 2015 -0800

--
 .../usergrid/tools/UniqueIndexCleanup.java  | 104 +--
 .../usergrid/tools/UniqueIndexCleanupTest.java  |   2 +-
 2 files changed, 73 insertions(+), 33 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/usergrid/blob/2e8bc463/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
--
diff --git 
a/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java 
b/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
index e835bec..c385b50 100644
--- 
a/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
+++ 
b/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
@@ -31,6 +31,7 @@ import org.apache.commons.cli.OptionBuilder;
 import org.apache.commons.cli.Options;
 import org.apache.thrift.TBaseHelper;
 
+import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.cassandra.EntityManagerImpl;
 import org.apache.usergrid.utils.StringUtils;
 import org.apache.usergrid.utils.UUIDUtils;
@@ -138,9 +139,9 @@ public class UniqueIndexCleanup extends ToolBase {
 Keyspace ko = cass.getUsergridApplicationKeyspace();
 Mutator m = createMutator( ko, be );
 
-if (line.hasOption( APPLICATION_ARG ) || line.hasOption( 
COLLECTION_ARG ) ||
-line.hasOption( ENTITY_UNIQUE_PROPERTY_NAME ) || line.hasOption( 
ENTITY_UNIQUE_PROPERTY_VALUE ) ) {
-deleteInvalidValuesForUniqueProperty(m ,line );
+if ( line.hasOption( APPLICATION_ARG ) || line.hasOption( 
COLLECTION_ARG ) ||
+line.hasOption( ENTITY_UNIQUE_PROPERTY_NAME ) || 
line.hasOption( ENTITY_UNIQUE_PROPERTY_VALUE ) ) {
+deleteInvalidValuesForUniqueProperty( m, line );
 }
 else {
 
@@ -166,25 +167,22 @@ public class UniqueIndexCleanup extends ToolBase {
 Charset.defaultCharset() ).trim();
 
 
-
-
-
 //defensive programming, don't have to have to parse the 
string if it doesn't contain users.
-if(returnedRowKey.contains( "users" )) {
+if ( returnedRowKey.contains( "users" ) ) {
 
 String[] parsedRowKey = returnedRowKey.split( ":" );
 
 //if the rowkey contains more than 4 parts then it may 
have some garbage appended to the front.
 if ( parsedRowKey.length > 4 ) {
-parsedRowKey = garbageRowKeyParser(parsedRowKey);
+parsedRowKey = garbageRowKeyParser( parsedRowKey );
 
-if(parsedRowKey == null) {
+if ( parsedRowKey == null ) {
 System.out.println( returnedRowKey + " is a 
invalid row key, and unparseable. Skipped..." );
 continue;
 }
 }
 //if the rowkey contains less than four parts then it is 
completely invalid
-else if ( parsedRowKey.length < 4){
+else if ( parsedRowKey.length < 4 ) {
 System.out.println( returnedRowKey + " is a invalid 
row key and will be skipped" );
 continue;
 }
@@ -217,16 +215,17 @@ public class UniqueIndexCleanup extends ToolBase {
 }
 }
 }
-System.out.println("Completed repair.");
+System.out.println( "Completed repair." );
 
 logger.info( "Completed audit of apps" );
 }
 
+
 //Returns a functioning rowkey if it can otherwise returns null
-public String[] garbageRowKeyParser(String[] parsedRowKey){
+public String[] garbageRowKeyParser( String[] parsedRowKey ) {
 String[] modifiedRowKey = parsedRowKey.clone();
-while(modifiedRowKey!=null) {
-if(modifiedRowKey.length < 4){
+while ( modifiedRowKey != null ) {
+if ( modifiedRowKey.length < 4 ) {
  

usergrid git commit: Add simple status page to portal that displays Usergrid API /status.

2015-11-10 Thread mrusso
Repository: usergrid
Updated Branches:
  refs/heads/master 2b1f76130 -> bf5ef1518


Add simple status page to portal that displays Usergrid API /status.


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

Branch: refs/heads/master
Commit: bf5ef1518d3e7deda765f9d59e2fdacf10031251
Parents: 2b1f761
Author: Michael Russo 
Authored: Tue Nov 10 11:58:08 2015 -0800
Committer: Michael Russo 
Committed: Tue Nov 10 11:58:08 2015 -0800

--
 portal/Gruntfile.js |  5 +++--
 portal/getStatus.js | 38 ++
 portal/status.html  | 35 +++
 3 files changed, 76 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/usergrid/blob/bf5ef151/portal/Gruntfile.js
--
diff --git a/portal/Gruntfile.js b/portal/Gruntfile.js
index b3dfb7c..f0cdc94 100644
--- a/portal/Gruntfile.js
+++ b/portal/Gruntfile.js
@@ -190,7 +190,8 @@ module.exports = function(grunt) {
 '!css/main.min.css',
 '!js/libs/',
 '!js/generated/*.js',
-'!js/generated-templates/*.js'
+'!js/generated-templates/*.js',
+'getStatus.js'
   ],
   tasks: ['build-dev']
 },
@@ -302,7 +303,7 @@ module.exports = function(grunt) {
   // includes files within path
   {
 expand: true,
-src: ['*.html', 'config.js', '*.ico', 'helpJson.json'],
+src: ['*.html', 'config.js', '*.ico', 'helpJson.json', 
'getStatus.js'],
 dest: distPath,
 filter: 'isFile'
   }, {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/bf5ef151/portal/getStatus.js
--
diff --git a/portal/getStatus.js b/portal/getStatus.js
new file mode 100644
index 000..ae74119
--- /dev/null
+++ b/portal/getStatus.js
@@ -0,0 +1,38 @@
+/*
+ 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.
+ */
+
+var url = Usergrid.overrideUrl + '/status';
+
+var getStatus = function(){
+var http = new XMLHttpRequest();
+
+http.onload= function(){
+if (http.readyState==4 || http.readyState=="complete")
+{
+console.log('response: \n'+http.responseText);
+document.getElementById("statusResponse")
+.innerHTML=http.responseText;
+}
+};
+
+
+http.open("GET",url, true);
+http.send();
+
+};

http://git-wip-us.apache.org/repos/asf/usergrid/blob/bf5ef151/portal/status.html
--
diff --git a/portal/status.html b/portal/status.html
new file mode 100644
index 000..4b9ad1d
--- /dev/null
+++ b/portal/status.html
@@ -0,0 +1,35 @@
+
+
+
+
+
+Status Page
+
+
+
+
+
+
+
+ getStatus(); 
+
+
+
+



usergrid git commit: removing unnecessary logging

2015-11-10 Thread mrusso
Repository: usergrid
Updated Branches:
  refs/heads/master bf5ef1518 -> f7785c2ab


removing unnecessary logging


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

Branch: refs/heads/master
Commit: f7785c2abfe94e4075b9cb8d275959e2ba0f80f5
Parents: bf5ef15
Author: Michael Russo 
Authored: Tue Nov 10 12:00:34 2015 -0800
Committer: Michael Russo 
Committed: Tue Nov 10 12:00:34 2015 -0800

--
 portal/getStatus.js | 1 -
 1 file changed, 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/usergrid/blob/f7785c2a/portal/getStatus.js
--
diff --git a/portal/getStatus.js b/portal/getStatus.js
index ae74119..4ecccdb 100644
--- a/portal/getStatus.js
+++ b/portal/getStatus.js
@@ -25,7 +25,6 @@ var getStatus = function(){
 http.onload= function(){
 if (http.readyState==4 || http.readyState=="complete")
 {
-console.log('response: \n'+http.responseText);
 document.getElementById("statusResponse")
 .innerHTML=http.responseText;
 }



usergrid git commit: Fix annotations so that CORS and tracing filters work, and add JIRA issue for the TODO on the Metering Filter.

2015-11-10 Thread mdunker
Repository: usergrid
Updated Branches:
  refs/heads/master 40e002b97 -> de42b9cb0


Fix annotations so that CORS and tracing filters work, and add JIRA issue for 
the TODO on the Metering Filter.


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

Branch: refs/heads/master
Commit: de42b9cb0ee77ab40f2f0af5f34dc4d7df56dac5
Parents: 40e002b
Author: Dave Johnson 
Authored: Tue Nov 10 15:21:21 2015 -0500
Committer: Dave Johnson 
Committed: Tue Nov 10 15:21:21 2015 -0500

--
 .../org/apache/usergrid/rest/filters/MeteringFilter.java | 8 
 .../java/org/apache/usergrid/rest/filters/TracingFilter.java | 5 ++---
 .../usergrid/rest/security/CrossOriginRequestFilter.java | 4 ++--
 3 files changed, 8 insertions(+), 9 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/usergrid/blob/de42b9cb/stack/rest/src/main/java/org/apache/usergrid/rest/filters/MeteringFilter.java
--
diff --git 
a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/MeteringFilter.java 
b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/MeteringFilter.java
index 2735cdf..b8adc9a 100644
--- 
a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/MeteringFilter.java
+++ 
b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/MeteringFilter.java
@@ -36,6 +36,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.container.*;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.ext.Provider;
 import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -46,10 +47,9 @@ import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
 
-// TODO: Metering for Jersey 2
-@Resource
-@PreMatching
-@Component
+// TODO: Metering for Jersey 2 
(https://issues.apache.org/jira/browse/USERGRID-1103)
+
+@Provider
 public class MeteringFilter implements ContainerRequestFilter, 
ContainerResponseFilter {
 
 @Override

http://git-wip-us.apache.org/repos/asf/usergrid/blob/de42b9cb/stack/rest/src/main/java/org/apache/usergrid/rest/filters/TracingFilter.java
--
diff --git 
a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/TracingFilter.java 
b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/TracingFilter.java
index 64d0209..1c23f63 100644
--- 
a/stack/rest/src/main/java/org/apache/usergrid/rest/filters/TracingFilter.java
+++ 
b/stack/rest/src/main/java/org/apache/usergrid/rest/filters/TracingFilter.java
@@ -30,6 +30,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.container.*;
 import javax.ws.rs.core.Context;
+import javax.ws.rs.ext.Provider;
 
 
 /**
@@ -37,9 +38,7 @@ import javax.ws.rs.core.Context;
  *
  * @author zznate
  */
-@Resource
-@PreMatching
-@Component
+@Provider
 public class TracingFilter implements ContainerRequestFilter, 
ContainerResponseFilter {
 
 private Logger logger = LoggerFactory.getLogger( TracingFilter.class );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/de42b9cb/stack/rest/src/main/java/org/apache/usergrid/rest/security/CrossOriginRequestFilter.java
--
diff --git 
a/stack/rest/src/main/java/org/apache/usergrid/rest/security/CrossOriginRequestFilter.java
 
b/stack/rest/src/main/java/org/apache/usergrid/rest/security/CrossOriginRequestFilter.java
index 00c12d7..f150b2b 100644
--- 
a/stack/rest/src/main/java/org/apache/usergrid/rest/security/CrossOriginRequestFilter.java
+++ 
b/stack/rest/src/main/java/org/apache/usergrid/rest/security/CrossOriginRequestFilter.java
@@ -21,14 +21,14 @@ import org.apache.usergrid.rest.utils.CORSUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.annotation.Resource;
 import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.container.ContainerResponseContext;
 import javax.ws.rs.container.ContainerResponseFilter;
+import javax.ws.rs.ext.Provider;
 import java.io.IOException;
 
 
-@Resource
+@Provider
 public class CrossOriginRequestFilter implements ContainerResponseFilter {
 public static final Logger logger = LoggerFactory.getLogger( 
CrossOriginRequestFilter.class );
 



usergrid git commit: Added prints for values that end up getting cleaned.

2015-11-10 Thread grey
Repository: usergrid
Updated Branches:
  refs/heads/USERGRID-1076 2e8bc4632 -> 1fab1db94


Added prints for values that end up getting cleaned.


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

Branch: refs/heads/USERGRID-1076
Commit: 1fab1db945da08e4bd989aa44799133428cada5f
Parents: 2e8bc46
Author: George Reyes 
Authored: Tue Nov 10 14:15:30 2015 -0800
Committer: George Reyes 
Committed: Tue Nov 10 14:15:30 2015 -0800

--
 .../main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java| 2 ++
 1 file changed, 2 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/usergrid/blob/1fab1db9/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
--
diff --git 
a/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java 
b/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
index c385b50..d1a63b6 100644
--- 
a/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
+++ 
b/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
@@ -325,8 +325,10 @@ public class UniqueIndexCleanup extends ToolBase {
 for(Entity entity: entities){
 if(mostRecentEntity.getModified() > entity.getModified()){
 em.deleteEntity( entity.getUuid() );
+System.out.println("Deleting 
"+entity.getUuid().toString()+" because it shares older unique value with: 
"+uniqueValue);
 }
 else if (mostRecentEntity.getModified() < 
entity.getModified()){
+System.out.println("Deleting 
"+mostRecentEntity.getUuid().toString()+" because it shares older unique value 
with: "+uniqueValue);
 em.deleteEntity( mostRecentEntity.getUuid() );
 mostRecentEntity = entity;
 }



usergrid git commit: Added fix for rows that contain duplicate valid existing columns.

2015-11-10 Thread grey
Repository: usergrid
Updated Branches:
  refs/heads/readRepairForIndexValues 00171f07b -> 3d5ae4647


Added fix for rows that contain duplicate valid existing columns.


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

Branch: refs/heads/readRepairForIndexValues
Commit: 3d5ae464766a12b3fac1d82b67da667ef28d17fd
Parents: 00171f0
Author: George Reyes 
Authored: Tue Nov 10 14:49:40 2015 -0800
Committer: George Reyes 
Committed: Tue Nov 10 14:49:40 2015 -0800

--
 .../cassandra/EntityManagerImpl.java| 52 +++-
 1 file changed, 41 insertions(+), 11 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/usergrid/blob/3d5ae464/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
--
diff --git 
a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
 
b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
index ecd0f0a..76cb6d7 100644
--- 
a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
+++ 
b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
@@ -559,27 +559,45 @@ public class EntityManagerImpl implements EntityManager {
 + "property {} with value {}",
 new Object[] { ownerEntityId, collectionNameInternal, 
propertyName, propertyValue } );
 
-//retreive up to 100 columns
+//retrieve up to 100 columns
 List> indexingColumns = 
cass.getColumns( cass.getApplicationKeyspace( applicationId ), ENTITY_UNIQUE, 
key, null, null, 100,
 false );
 
 
+Entity[] entities = new Entity[cols.size()];
+int index = 0;
 
-//go through it column
 for ( HColumn col : indexingColumns ) {
 UUID indexCorruptionUuid = ue.fromByteBuffer( col.getName());
-if (get( indexCorruptionUuid ) == null ) {
-UUID timestampUuid = newTimeUUID();
-long timestamp = getTimestampInMicros( timestampUuid );
-Keyspace ko = cass.getApplicationKeyspace( ownerEntityId );
-Mutator mutator = createMutator( ko, be );
-
-addDeleteToMutator( mutator, ENTITY_UNIQUE, key, 
indexCorruptionUuid, timestamp );
-mutator.execute();
+
+entities[index] = get(indexCorruptionUuid);
+
+if (entities[index] == null ) {
+deleteUniqueColumn( ownerEntityId, key, 
indexCorruptionUuid );
 cols.remove( col );
 }
 else{
-
+index++;
+}
+}
+//this means that the same unique rowkey has two values associated 
with it
+if(entities[0]!=null && entities[1]!=null){
+Entity mostRecentEntity = entities[0];
+for(Entity entity: entities){
+if(mostRecentEntity.getModified() > entity.getModified()){
+deleteEntity( entity.getUuid() );
+logger.info( "Deleting " + entity.getUuid().toString()
++ " because it shares older unique value with: 
" + propertyValue );
+}
+else if (mostRecentEntity.getModified() < 
entity.getModified()){
+logger.info("Deleting 
"+mostRecentEntity.getUuid().toString()+" because it shares older unique value 
with: "+propertyValue);
+deleteEntity( mostRecentEntity.getUuid() );
+mostRecentEntity = entity;
+}
+else if (mostRecentEntity.getModified() == 
entity.getModified() && !mostRecentEntity.getUuid().equals( entity.getUuid() )){
+logger.info("Entities with unique value: 
"+propertyValue+" has two or more entities with the same modified time."
++ "Please manually resolve by query or 
changing names. ");
+}
 }
 }
 }
@@ -603,6 +621,18 @@ public class EntityManagerImpl implements EntityManager {
 }
 
 
+private void deleteUniqueColumn( final UUID ownerEntityId, final Object 
key, final UUID indexCorruptionUuid )
+throws Exception {
+UUID timestampUuid = newTimeUUID();
+long 

[4/5] usergrid git commit: Test for ascending geo-distance in three of the GeoIT tests.

2015-11-10 Thread snoopdave
Test for ascending geo-distance in three of the GeoIT tests.


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

Branch: refs/heads/master
Commit: 1c0b0a99c48ad86a964a0dcf4a914d9de3384d92
Parents: 73cbd2e
Author: Dave Johnson 
Authored: Tue Nov 10 09:29:35 2015 -0500
Committer: Dave Johnson 
Committed: Tue Nov 10 09:29:35 2015 -0500

--
 .../org/apache/usergrid/persistence/GeoIT.java  | 31 +++-
 1 file changed, 30 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/usergrid/blob/1c0b0a99/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
--
diff --git 
a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java 
b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
index fcc4c32..ae09f97 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
@@ -171,7 +171,7 @@ public class GeoIT extends AbstractCoreIT {
  */
 @Test
 public void validateDistanceQueryExists() throws Exception {
-LOG.info("GeoIT.testMovingTarget");
+LOG.info("GeoIT.validateDistanceQueryExists");
 //Get the EntityManager instance
 EntityManager em = app.getEntityManager();
 assertNotNull(em);
@@ -191,6 +191,7 @@ public class GeoIT extends AbstractCoreIT {
 
 final double lat = 37.776753;
 final double lon = -122.407846;
+
 //2. Query from a point near the entity's location
 Query query = Query.fromQL("select * where location within 100 of "
 + lat + "," + lon);
@@ -503,11 +504,20 @@ public class GeoIT extends AbstractCoreIT {
 int count = 0;
 Results results;
 
+double previousDistance = 0d;
 do {
 results = em.searchCollection(em.getApplicationRef(), "stores", 
query);
 
 for (Entity entity : results.getEntities()) {
 assertEquals(String.valueOf(count), entity.getName());
+
+Object distanceObject = entity.getMetadata("distance");
+assertNotNull( distanceObject );
+assertTrue( distanceObject instanceof Double );
+double distance = (Double)distanceObject;
+assertTrue( distance >= previousDistance );
+previousDistance = distance;
+
 count++;
 }
 
@@ -550,6 +560,8 @@ public class GeoIT extends AbstractCoreIT {
 int count = 0;
 Results results;
 
+
+double previousDistance = 0d;
 do {
 results = em.searchCollection(em.getApplicationRef(), "stores", 
query);
 
@@ -557,6 +569,13 @@ public class GeoIT extends AbstractCoreIT {
 //TODO:can we assert order
 final int expected = numEntities - count - 1;
 
+Object distanceObject = entity.getMetadata("distance");
+assertNotNull( distanceObject );
+assertTrue( distanceObject instanceof Double );
+double distance = (Double)distanceObject;
+assertTrue( distance >= previousDistance );
+previousDistance = distance;
+
 assertEquals(String.valueOf(expected), entity.getName());
 count++;
 }
@@ -616,8 +635,18 @@ public class GeoIT extends AbstractCoreIT {
 do {
 Results results = em.searchCollection(em.getApplicationRef(), 
"stores", query);
 
+double previousDistance = 0d;
+
 for (Entity entity : results.getEntities()) {
 assertEquals(String.valueOf(count), entity.getName());
+
+Object distanceObject = entity.getMetadata("distance");
+assertNotNull( distanceObject );
+assertTrue( distanceObject instanceof Double );
+double distance = (Double)distanceObject;
+assertTrue( distance >= previousDistance );
+previousDistance = distance;
+
 count++;
 }
 }



[3/5] usergrid git commit: Only exclude distance field when distance >= 0 (0 is a valid distance)

2015-11-10 Thread snoopdave
Only exclude distance field when distance >= 0 (0 is a valid distance)


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

Branch: refs/heads/master
Commit: 73cbd2ef2156cd494db60bdd3d63c90386ac13bf
Parents: 5cc0b38
Author: Dave Johnson 
Authored: Tue Nov 10 09:29:02 2015 -0500
Committer: Dave Johnson 
Committed: Tue Nov 10 09:29:02 2015 -0500

--
 .../org/apache/usergrid/persistence/index/impl/IndexingUtils.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/usergrid/blob/73cbd2ef/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
--
diff --git 
a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
 
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
index ae2a6e6..90840af 100644
--- 
a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
+++ 
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
@@ -256,7 +256,7 @@ public class IndexingUtils {
 
 Id entityId = new SimpleId(UUID.fromString(entityUUID), entityType);
 
-return distance>0
+return distance >= 0
 ? new GeoCandidateResult(entityId, UUID.fromString(versionUUID), 
documentId, distance)
 : new CandidateResult(entityId, UUID.fromString(versionUUID), 
documentId);
 }



[1/3] usergrid git commit: Added ignore to test for use case that doesn't currently work. Added ability to filter out multiple entities with the same user name ( pick the one one modified last )

2015-11-10 Thread grey
Repository: usergrid
Updated Branches:
  refs/heads/readRepairForIndexValues a67057909 -> 00171f07b


Added ignore to test for use case that doesn't currently work.
Added ability to filter out multiple entities with the same user name ( pick 
the one one modified last )


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

Branch: refs/heads/readRepairForIndexValues
Commit: 2e8bc46329b11d5e625d75aad1b3dbb1d39e91ee
Parents: 7db5769
Author: George Reyes 
Authored: Tue Nov 10 12:22:41 2015 -0800
Committer: George Reyes 
Committed: Tue Nov 10 12:22:41 2015 -0800

--
 .../usergrid/tools/UniqueIndexCleanup.java  | 104 +--
 .../usergrid/tools/UniqueIndexCleanupTest.java  |   2 +-
 2 files changed, 73 insertions(+), 33 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/usergrid/blob/2e8bc463/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
--
diff --git 
a/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java 
b/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
index e835bec..c385b50 100644
--- 
a/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
+++ 
b/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
@@ -31,6 +31,7 @@ import org.apache.commons.cli.OptionBuilder;
 import org.apache.commons.cli.Options;
 import org.apache.thrift.TBaseHelper;
 
+import org.apache.usergrid.persistence.Entity;
 import org.apache.usergrid.persistence.cassandra.EntityManagerImpl;
 import org.apache.usergrid.utils.StringUtils;
 import org.apache.usergrid.utils.UUIDUtils;
@@ -138,9 +139,9 @@ public class UniqueIndexCleanup extends ToolBase {
 Keyspace ko = cass.getUsergridApplicationKeyspace();
 Mutator m = createMutator( ko, be );
 
-if (line.hasOption( APPLICATION_ARG ) || line.hasOption( 
COLLECTION_ARG ) ||
-line.hasOption( ENTITY_UNIQUE_PROPERTY_NAME ) || line.hasOption( 
ENTITY_UNIQUE_PROPERTY_VALUE ) ) {
-deleteInvalidValuesForUniqueProperty(m ,line );
+if ( line.hasOption( APPLICATION_ARG ) || line.hasOption( 
COLLECTION_ARG ) ||
+line.hasOption( ENTITY_UNIQUE_PROPERTY_NAME ) || 
line.hasOption( ENTITY_UNIQUE_PROPERTY_VALUE ) ) {
+deleteInvalidValuesForUniqueProperty( m, line );
 }
 else {
 
@@ -166,25 +167,22 @@ public class UniqueIndexCleanup extends ToolBase {
 Charset.defaultCharset() ).trim();
 
 
-
-
-
 //defensive programming, don't have to have to parse the 
string if it doesn't contain users.
-if(returnedRowKey.contains( "users" )) {
+if ( returnedRowKey.contains( "users" ) ) {
 
 String[] parsedRowKey = returnedRowKey.split( ":" );
 
 //if the rowkey contains more than 4 parts then it may 
have some garbage appended to the front.
 if ( parsedRowKey.length > 4 ) {
-parsedRowKey = garbageRowKeyParser(parsedRowKey);
+parsedRowKey = garbageRowKeyParser( parsedRowKey );
 
-if(parsedRowKey == null) {
+if ( parsedRowKey == null ) {
 System.out.println( returnedRowKey + " is a 
invalid row key, and unparseable. Skipped..." );
 continue;
 }
 }
 //if the rowkey contains less than four parts then it is 
completely invalid
-else if ( parsedRowKey.length < 4){
+else if ( parsedRowKey.length < 4 ) {
 System.out.println( returnedRowKey + " is a invalid 
row key and will be skipped" );
 continue;
 }
@@ -217,16 +215,17 @@ public class UniqueIndexCleanup extends ToolBase {
 }
 }
 }
-System.out.println("Completed repair.");
+System.out.println( "Completed repair." );
 
 logger.info( "Completed audit of apps" );
 }
 
+
 //Returns a functioning rowkey if it can otherwise returns null
-public String[] garbageRowKeyParser(String[] parsedRowKey){
+public String[] garbageRowKeyParser( String[] parsedRowKey ) {
 String[] modifiedRowKey = parsedRowKey.clone();
-while(modifiedRowKey!=null) {
-if(modifiedRowKey.length < 4){
+while ( modifiedRowKey != null ) {
+if ( modifiedRowKey.length 

[2/3] usergrid git commit: Added prints for values that end up getting cleaned.

2015-11-10 Thread grey
Added prints for values that end up getting cleaned.


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

Branch: refs/heads/readRepairForIndexValues
Commit: 1fab1db945da08e4bd989aa44799133428cada5f
Parents: 2e8bc46
Author: George Reyes 
Authored: Tue Nov 10 14:15:30 2015 -0800
Committer: George Reyes 
Committed: Tue Nov 10 14:15:30 2015 -0800

--
 .../main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java| 2 ++
 1 file changed, 2 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/usergrid/blob/1fab1db9/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
--
diff --git 
a/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java 
b/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
index c385b50..d1a63b6 100644
--- 
a/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
+++ 
b/stack/tools/src/main/java/org/apache/usergrid/tools/UniqueIndexCleanup.java
@@ -325,8 +325,10 @@ public class UniqueIndexCleanup extends ToolBase {
 for(Entity entity: entities){
 if(mostRecentEntity.getModified() > entity.getModified()){
 em.deleteEntity( entity.getUuid() );
+System.out.println("Deleting 
"+entity.getUuid().toString()+" because it shares older unique value with: 
"+uniqueValue);
 }
 else if (mostRecentEntity.getModified() < 
entity.getModified()){
+System.out.println("Deleting 
"+mostRecentEntity.getUuid().toString()+" because it shares older unique value 
with: "+uniqueValue);
 em.deleteEntity( mostRecentEntity.getUuid() );
 mostRecentEntity = entity;
 }