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/03/28 17:20:54 UTC
[01/50] [abbrv] git commit: prepare new version
Repository: incubator-usergrid
Updated Branches:
refs/heads/asyncqueue 5ded6b529 -> 289d66c8d
prepare new version
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e820f5b2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e820f5b2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e820f5b2
Branch: refs/heads/asyncqueue
Commit: e820f5b2dadb613d4a73ab583c27091bffc96379
Parents: 88f37ce
Author: Scott Ganyo <sc...@ganyo.com>
Authored: Wed Mar 12 16:08:01 2014 -0700
Committer: Scott Ganyo <sc...@ganyo.com>
Committed: Wed Mar 12 16:08:01 2014 -0700
----------------------------------------------------------------------
sdks/ruby-on-rails/lib/usergrid_ironhorse/version.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e820f5b2/sdks/ruby-on-rails/lib/usergrid_ironhorse/version.rb
----------------------------------------------------------------------
diff --git a/sdks/ruby-on-rails/lib/usergrid_ironhorse/version.rb b/sdks/ruby-on-rails/lib/usergrid_ironhorse/version.rb
index 23d3598..6f80fd3 100644
--- a/sdks/ruby-on-rails/lib/usergrid_ironhorse/version.rb
+++ b/sdks/ruby-on-rails/lib/usergrid_ironhorse/version.rb
@@ -1,5 +1,5 @@
module Usergrid
module Ironhorse
- VERSION = '0.1.1'
+ VERSION = '0.1.2'
end
end
[14/50] [abbrv] git commit: Increased number of entities written to prove that a set number of organizations are not being created and nested. Ignored test due to it’s integration type nature of reading files, that can’t be deleted.
Posted by sn...@apache.org.
Increased number of entities written to prove that a set number of organizations are not being created and nested.
Ignored test due to it’s integration type nature of reading files, that can’t be deleted.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e88af5a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e88af5a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e88af5a0
Branch: refs/heads/asyncqueue
Commit: e88af5a0915b707e7177ca51186d1c2e03f16e00
Parents: 5717352
Author: grey <gr...@apigee.com>
Authored: Wed Mar 19 10:41:26 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Wed Mar 19 10:41:26 2014 -0700
----------------------------------------------------------------------
.../cassandra/ManagementServiceIT.java | 24 ++++++++++++--------
1 file changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e88af5a0/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index 39ba732..aa89f20 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -1271,11 +1271,11 @@ public class ManagementServiceIT {
f.delete();
}
- @Test
+ @Ignore("file created won't be deleted when running tests")
public void testExportOneOrganization() throws Exception {
//File f = new File( "exportOneOrganization.json" );
- int entitiesToCreate = 10;
+ int entitiesToCreate = 123;
File f = null;
try {
@@ -1287,7 +1287,7 @@ public class ManagementServiceIT {
}
EntityManager em = setup.getEmf().getEntityManager( applicationId);
- em.createApplicationCollection( "baconators" );
+ em.createApplicationCollection( "newOrg" );
//intialize user object to be posted
Map<String, Object> userProperties = null;
Entity[] entity;
@@ -1297,7 +1297,7 @@ public class ManagementServiceIT {
userProperties = new LinkedHashMap<String, Object>();
userProperties.put( "username", "billybob" + i );
userProperties.put( "email", "test" + i + "@anuff.com" );//String.format( "test%i@anuff.com", i ) );
- entity[i] = em.create( "baconators", userProperties );
+ entity[i] = em.create( "newOrg", userProperties );
}
S3Export s3Export = new MockS3ExportImpl();
@@ -1305,13 +1305,15 @@ public class ManagementServiceIT {
ExportService exportService = setup.getExportService();
HashMap<String, Object> payload = payloadBuilder();
- payload.put( "organizationId",organization.getUuid() );
- payload.put( "applicationId",applicationId);
+// payload.put( "organizationId",organization.getUuid() );
+// payload.put( "applicationId",applicationId);
//creates 100s of organizations with some entities in each one to make sure we don't actually apply it
+ OrganizationInfo orgMade = null;
+ ApplicationInfo appMade = null;
for(int i = 0; i < 100; i++) {
- OrganizationInfo orgMade =setup.getMgmtSvc().createOrganization( "superboss"+i,adminUser,true );
- ApplicationInfo appMade = setup.getMgmtSvc().createApplication( orgMade.getUuid(), "superapp"+i);
+ orgMade =setup.getMgmtSvc().createOrganization( "superboss"+i,adminUser,true );
+ appMade = setup.getMgmtSvc().createApplication( orgMade.getUuid(), "superapp"+i);
EntityManager customMaker = setup.getEmf().getEntityManager( appMade.getId() );
customMaker.createApplicationCollection( "superappCol"+i );
@@ -1320,13 +1322,15 @@ public class ManagementServiceIT {
Entity[] entNotCopied;
entNotCopied = new Entity[entitiesToCreate];
//creates entities
- for ( int index = 0; index < 10; index++ ) {
+ for ( int index = 0; index < 20; index++ ) {
entityLevelProperties = new LinkedHashMap<String, Object>();
entityLevelProperties.put( "username", "bobso" + index );
entityLevelProperties.put( "email", "derp" + index + "@anuff.com" );
entNotCopied[index] = customMaker.create( "superappCol", entityLevelProperties );
}
}
+ payload.put( "organizationId",orgMade.getUuid());
+ payload.put( "applicationId",appMade.getId());
UUID exportUUID = exportService.schedule( payload );
exportService.setS3Export( s3Export );
@@ -1346,7 +1350,7 @@ public class ManagementServiceIT {
org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
/*plus 3 for the default roles*/
- assertEquals( entitiesToCreate+3 , a.size() );
+ assertEquals( 23 , a.size() );
f.delete();
}
[38/50] [abbrv] git commit: Fixing invalid JSON,
comments not allowed (see http://rfc7159.net/rfc7159).
Posted by sn...@apache.org.
Fixing invalid JSON, comments not allowed (see http://rfc7159.net/rfc7159).
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/cf814a4e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/cf814a4e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/cf814a4e
Branch: refs/heads/asyncqueue
Commit: cf814a4eb0a2d818ecb600d88233ecb8f1cb2f64
Parents: 06f578f
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Mar 25 11:43:53 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Mar 25 11:43:53 2014 -0400
----------------------------------------------------------------------
stack/pom.xml | 1 +
.../src/main/resources/swagger/applications.json | 16 ----------------
.../rest/src/main/resources/swagger/management.json | 16 ----------------
.../rest/src/main/resources/swagger/resources.json | 16 ----------------
4 files changed, 1 insertion(+), 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf814a4e/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index 3a24790..2f2cec6 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -1768,6 +1768,7 @@
<exclude>**/README.md</exclude>
<exclude>**/CHANGES.txt</exclude>
+ <exclude>**/*.json</exclude>
<!-- git and IDE project files -->
<exclude>**/.git/**</exclude>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf814a4e/stack/rest/src/main/resources/swagger/applications.json
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/resources/swagger/applications.json b/stack/rest/src/main/resources/swagger/applications.json
index aa38597..06b93ee 100644
--- a/stack/rest/src/main/resources/swagger/applications.json
+++ b/stack/rest/src/main/resources/swagger/applications.json
@@ -1,19 +1,3 @@
-/*
- * 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.
- */
{
"basePath" : "${basePath}",
"swaggerVersion" : "1.1-SHAPSHOT.121026",
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf814a4e/stack/rest/src/main/resources/swagger/management.json
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/resources/swagger/management.json b/stack/rest/src/main/resources/swagger/management.json
index ae5ea1b..c19294f 100644
--- a/stack/rest/src/main/resources/swagger/management.json
+++ b/stack/rest/src/main/resources/swagger/management.json
@@ -1,19 +1,3 @@
-/*
- * 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.
- */
{
"basePath" : "${basePath}",
"swaggerVersion" : "1.1-SHAPSHOT.121026",
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf814a4e/stack/rest/src/main/resources/swagger/resources.json
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/resources/swagger/resources.json b/stack/rest/src/main/resources/swagger/resources.json
index 2e64bf9..e092651 100644
--- a/stack/rest/src/main/resources/swagger/resources.json
+++ b/stack/rest/src/main/resources/swagger/resources.json
@@ -1,19 +1,3 @@
-/*
- * 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.
- */
{
"basePath": "${basePath}",
"swaggerVersion": "1.1-SHAPSHOT.121026",
[49/50] [abbrv] git commit: Use 2.0.0-SNAPSHOT version in Core
Persistence too.
Posted by sn...@apache.org.
Use 2.0.0-SNAPSHOT version in Core Persistence too.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/9caf38bd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/9caf38bd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/9caf38bd
Branch: refs/heads/asyncqueue
Commit: 9caf38bdeee5363afa11f8dab7a49c843358c29a
Parents: 17c2ac4
Author: Dave Johnson <dm...@apigee.com>
Authored: Thu Mar 27 12:24:55 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Thu Mar 27 12:24:55 2014 -0400
----------------------------------------------------------------------
stack/corepersistence/collection/pom.xml | 2 +-
stack/corepersistence/graph/pom.xml | 3 ++-
stack/corepersistence/model/pom.xml | 2 +-
stack/corepersistence/perftest1/pom.xml | 2 +-
stack/corepersistence/perftest2/pom.xml | 4 ++--
stack/corepersistence/pom.xml | 2 +-
6 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9caf38bd/stack/corepersistence/collection/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/pom.xml b/stack/corepersistence/collection/pom.xml
index 038fb67..d442c6d 100644
--- a/stack/corepersistence/collection/pom.xml
+++ b/stack/corepersistence/collection/pom.xml
@@ -6,7 +6,7 @@
<parent>
<artifactId>persistence</artifactId>
<groupId>org.apache.usergrid</groupId>
- <version>1.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9caf38bd/stack/corepersistence/graph/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/pom.xml b/stack/corepersistence/graph/pom.xml
index 069962d..1abec48 100644
--- a/stack/corepersistence/graph/pom.xml
+++ b/stack/corepersistence/graph/pom.xml
@@ -24,8 +24,9 @@
<parent>
<artifactId>persistence</artifactId>
<groupId>org.apache.usergrid</groupId>
- <version>1.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
+
<modelVersion>4.0.0</modelVersion>
<artifactId>graph</artifactId>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9caf38bd/stack/corepersistence/model/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/pom.xml b/stack/corepersistence/model/pom.xml
index 8a7af5b..42d64ec 100644
--- a/stack/corepersistence/model/pom.xml
+++ b/stack/corepersistence/model/pom.xml
@@ -5,7 +5,7 @@
<parent>
<artifactId>persistence</artifactId>
<groupId>org.apache.usergrid</groupId>
- <version>1.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9caf38bd/stack/corepersistence/perftest1/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/perftest1/pom.xml b/stack/corepersistence/perftest1/pom.xml
index 64e76f7..08f5513 100644
--- a/stack/corepersistence/perftest1/pom.xml
+++ b/stack/corepersistence/perftest1/pom.xml
@@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.usergrid</groupId>
<artifactId>perftest1</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9caf38bd/stack/corepersistence/perftest2/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/perftest2/pom.xml b/stack/corepersistence/perftest2/pom.xml
index 34ef45f..979f427 100644
--- a/stack/corepersistence/perftest2/pom.xml
+++ b/stack/corepersistence/perftest2/pom.xml
@@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.usergrid</groupId>
<artifactId>perftest2</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
@@ -20,7 +20,7 @@
<dependency>
<groupId>org.apache.usergrid</groupId>
<artifactId>queryindex</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9caf38bd/stack/corepersistence/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/pom.xml b/stack/corepersistence/pom.xml
index 9a9b7d3..0d4f13f 100644
--- a/stack/corepersistence/pom.xml
+++ b/stack/corepersistence/pom.xml
@@ -10,7 +10,7 @@
<groupId>org.apache.usergrid</groupId>
<artifactId>persistence</artifactId>
<packaging>pom</packaging>
- <version>1.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<properties>
[15/50] [abbrv] git commit: Added integration test
Posted by sn...@apache.org.
Added integration test
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/5a5644e7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/5a5644e7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/5a5644e7
Branch: refs/heads/asyncqueue
Commit: 5a5644e75be38700f214d3fe993d092328dc0369
Parents: e88af5a
Author: grey <gr...@apigee.com>
Authored: Wed Mar 19 11:40:51 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Wed Mar 19 11:40:51 2014 -0700
----------------------------------------------------------------------
.../cassandra/ManagementServiceIT.java | 62 +++++++++++++++++++-
1 file changed, 61 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5a5644e7/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index aa89f20..15ece91 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -1508,6 +1508,66 @@ public class ManagementServiceIT {
exportService.doExport( jobExecution );
}
+ @Ignore //For this test please input your s3 credentials into payload builder.
+ public void testIntegration100EntitiesOnOneOrg() throws Exception {
+
+ S3Export s3Export = new S3ExportImpl();
+ ExportService exportService = setup.getExportService();
+ HashMap<String, Object> payload = payloadBuilder();
+
+ payload.put("organizationId",organization.getUuid());
+ payload.put("applicationId",applicationId);
+
+ OrganizationInfo orgMade = null;
+ ApplicationInfo appMade = null;
+ for(int i = 0; i < 100; i++) {
+ orgMade =setup.getMgmtSvc().createOrganization( "superboss"+i,adminUser,true );
+ appMade = setup.getMgmtSvc().createApplication( orgMade.getUuid(), "superapp"+i);
+
+ EntityManager customMaker = setup.getEmf().getEntityManager( appMade.getId() );
+ customMaker.createApplicationCollection( "superappCol"+i );
+ //intialize user object to be posted
+ Map<String, Object> entityLevelProperties = null;
+ Entity[] entNotCopied;
+ entNotCopied = new Entity[20];
+ //creates entities
+ for ( int index = 0; index < 20; index++ ) {
+ entityLevelProperties = new LinkedHashMap<String, Object>();
+ entityLevelProperties.put( "username", "bobso" + index );
+ entityLevelProperties.put( "email", "derp" + index + "@anuff.com" );
+ entNotCopied[index] = customMaker.create( "superappCol", entityLevelProperties );
+ }
+ }
+
+ EntityManager em = setup.getEmf().getEntityManager( applicationId );
+ //intialize user object to be posted
+ Map<String, Object> userProperties = null;
+ Entity[] entity;
+ entity = new Entity[100];
+ //creates entities
+ for ( int i = 0; i < 100; i++ ) {
+ userProperties = new LinkedHashMap<String, Object>();
+ userProperties.put( "username", "billybob" + i );
+ userProperties.put( "email", "test" + i + "@anuff.com" );
+
+ entity[i] = em.create( "user", userProperties );
+ }
+
+ UUID exportUUID = exportService.schedule( payload );
+ exportService.setS3Export( s3Export );
+
+ //create and initialize jobData returned in JobExecution.
+ JobData jobData = new JobData();
+ jobData.setProperty( "jobName", "exportJob" );
+ jobData.setProperty( "exportInfo", payload );
+ jobData.setProperty( "exportId", exportUUID );
+
+ JobExecution jobExecution = mock( JobExecution.class );
+ when( jobExecution.getJobData() ).thenReturn( jobData );
+
+ exportService.doExport( jobExecution );
+ }
+
/*Creates fake payload for testing purposes.*/
public HashMap<String, Object> payloadBuilder() {
HashMap<String, Object> payload = new HashMap<String, Object>();
@@ -1515,7 +1575,7 @@ public class ManagementServiceIT {
Map<String, Object> storage_info = new HashMap<String, Object>();
// TODO: always put dummy values here and ignore this test.
storage_info.put( "s3_key", "insert key here" );
- storage_info.put( "s3_accessId", "insert access id here" );
+ storage_info.put( "s3_access_id", "insert access id here" );
storage_info.put( "bucket_location", "insert bucket name here" );
properties.put( "storage_provider", "s3" );
[19/50] [abbrv] git commit: Added amazon s3 dependencies to get the
file back out of s3 to make sure it was transferred over. Removed smoke from
smoke tests,
they now properly get the file back from s3. Json validity is handled in other
tests so I only v
Posted by sn...@apache.org.
Added amazon s3 dependencies to get the file back out of s3 to make sure it was transferred over.
Removed smoke from smoke tests, they now properly get the file back from s3. Json validity is handled in other tests so I only verify that the object exists.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/a1b6124c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/a1b6124c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/a1b6124c
Branch: refs/heads/asyncqueue
Commit: a1b6124ccf6aed8de351693f184302381a777994
Parents: fe2b3d6
Author: grey <gr...@apigee.com>
Authored: Wed Mar 19 16:18:15 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Wed Mar 19 16:18:15 2014 -0700
----------------------------------------------------------------------
stack/services/pom.xml | 13 +++++++
.../management/export/S3ExportImpl.java | 10 +++--
.../cassandra/ManagementServiceIT.java | 39 +++++++++++++++++++-
.../management/cassandra/MockS3ExportImpl.java | 1 -
4 files changed, 58 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a1b6124c/stack/services/pom.xml
----------------------------------------------------------------------
diff --git a/stack/services/pom.xml b/stack/services/pom.xml
index 5c31d43..de02659 100644
--- a/stack/services/pom.xml
+++ b/stack/services/pom.xml
@@ -553,5 +553,18 @@
<artifactId>jul-to-slf4j</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.3.3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.amazonaws</groupId>
+ <artifactId>aws-java-sdk</artifactId>
+ <version>1.7.3</version>
+ </dependency>
+
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a1b6124c/stack/services/src/main/java/org/apache/usergrid/management/export/S3ExportImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/export/S3ExportImpl.java b/stack/services/src/main/java/org/apache/usergrid/management/export/S3ExportImpl.java
index 863a8f8..c6cfc37 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/export/S3ExportImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/export/S3ExportImpl.java
@@ -44,9 +44,12 @@ import com.google.inject.Module;
*/
public class S3ExportImpl implements S3Export {
+ String fn;
+
@Override
public void copyToS3( final InputStream inputStream, final Map<String,Object> exportInfo, String filename ) {
+ fn = filename;
Logger logger = LoggerFactory.getLogger( ExportServiceImpl.class );
/*won't need any of the properties as I have the export info*/
@@ -87,13 +90,14 @@ public class S3ExportImpl implements S3Export {
try {
AsyncBlobStore blobStore = context.getAsyncBlobStore();
BlobBuilder blobBuilder =
- blobStore.blobBuilder( filename ).payload( inputStream ).calculateMD5().contentType( "text/plain" );
+ blobStore.blobBuilder( fn ).payload( inputStream ).calculateMD5().contentType( "text/plain" );
Blob blob = blobBuilder.build();
ListenableFuture<String> futureETag = blobStore.putBlob( bucketName, blob, PutOptions.Builder.multipart() );
+
logger.info( "Uploaded file etag=" + futureETag.get() );
}
catch ( Exception e ) {
@@ -102,8 +106,8 @@ public class S3ExportImpl implements S3Export {
}
@Override
- public String getFilename () {return "";}
+ public String getFilename () {return fn;}
@Override
- public void setFilename(String givenName) {;}
+ public void setFilename(String givenName) {fn = givenName;}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a1b6124c/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index 6c0431b..310d46a 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -65,6 +65,13 @@ import org.apache.usergrid.security.tokens.exceptions.InvalidTokenException;
import org.apache.usergrid.utils.JsonUtils;
import org.apache.usergrid.utils.UUIDUtils;
+import com.amazonaws.auth.AWSCredentials;
+import com.amazonaws.auth.BasicAWSCredentials;
+import com.amazonaws.services.s3.AmazonS3;
+import com.amazonaws.services.s3.AmazonS3Client;
+import com.amazonaws.services.s3.model.GetObjectRequest;
+import com.amazonaws.services.s3.model.S3Object;
+
import static org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString;
import static org.apache.usergrid.persistence.Schema.DICTIONARY_CREDENTIALS;
import static org.apache.usergrid.persistence.cassandra.CassandraService.MANAGEMENT_APPLICATION_ID;
@@ -1473,6 +1480,9 @@ public class ManagementServiceIT {
@Test //For this test please input your s3 credentials into payload builder.
public void testIntegration100EntitiesOn() throws Exception {
+ //s3client.putObject(new PutObjectRequest(bucketName, keyName, file));
+
+
S3Export s3Export = new S3ExportImpl();
ExportService exportService = setup.getExportService();
HashMap<String, Object> payload = payloadBuilder();
@@ -1507,9 +1517,24 @@ public class ManagementServiceIT {
when( jobExecution.getJobData() ).thenReturn( jobData );
exportService.doExport( jobExecution );
+ Thread.sleep(1000);
+
+ AWSCredentials myCredentials = new BasicAWSCredentials(
+ System.getProperty( "accessKey" ), System.getProperty("secretKey"));
+ AmazonS3 s3client = new AmazonS3Client(myCredentials);
+ S3Object sd = null;
+ try {
+ sd = s3client.getObject( new GetObjectRequest( System.getProperty( "bucketName" ),
+ s3Export.getFilename()) );
+ }catch(Exception e) {
+ assert(false);
+ }
+ assertNotNull( sd );
+
}
- @Test //For this test please input your s3 credentials into payload builder.
+ //@Ignore("I'd have to add some overhead such that I loop through all files or keep track of them all ")
+ @Test
public void testIntegration100EntitiesOnOneOrg() throws Exception {
S3Export s3Export = new S3ExportImpl();
@@ -1567,6 +1592,18 @@ public class ManagementServiceIT {
when( jobExecution.getJobData() ).thenReturn( jobData );
exportService.doExport( jobExecution );
+
+ AWSCredentials myCredentials = new BasicAWSCredentials(
+ System.getProperty( "accessKey" ), System.getProperty("secretKey"));
+ AmazonS3 s3client = new AmazonS3Client(myCredentials);
+ S3Object sd = null;
+ try {
+ sd = s3client.getObject( new GetObjectRequest( System.getProperty( "bucketName" ),
+ s3Export.getFilename()) );
+ }catch(Exception e) {
+ assert(false);
+ }
+ assertNotNull( sd );
}
/*Creates fake payload for testing purposes.*/
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a1b6124c/stack/services/src/test/java/org/apache/usergrid/management/cassandra/MockS3ExportImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/MockS3ExportImpl.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/MockS3ExportImpl.java
index 8ef1c19..a1814fd 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/MockS3ExportImpl.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/MockS3ExportImpl.java
@@ -42,7 +42,6 @@ public class MockS3ExportImpl implements S3Export {
int read = 0;
byte[] bytes = new byte[1024];
OutputStream outputStream = null;
- //FileInputStream fis = new PrintWriter( inputStream );
try {
outputStream = new FileOutputStream( new File( getFilename() ) );
[23/50] [abbrv] git commit: Updating version to 0.10.8. Updating
references to point to apache documentation
Posted by sn...@apache.org.
Updating version to 0.10.8. Updating references to point to apache documentation
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/3007b554
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/3007b554
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/3007b554
Branch: refs/heads/asyncqueue
Commit: 3007b554a435e1a09f4dc3ee3b21065fb094fc2d
Parents: 0b584f7
Author: ryan bridges <rb...@apigee.com>
Authored: Thu Mar 20 09:26:22 2014 -0400
Committer: ryan bridges <rb...@apigee.com>
Committed: Thu Mar 20 09:26:22 2014 -0400
----------------------------------------------------------------------
sdks/html5-javascript/README.md | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3007b554/sdks/html5-javascript/README.md
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/README.md b/sdks/html5-javascript/README.md
index 820edf9..cfba38c 100755
--- a/sdks/html5-javascript/README.md
+++ b/sdks/html5-javascript/README.md
@@ -6,7 +6,7 @@ Detailed instructions follow but if you just want a quick example of how to get
<html>
<head>
<!-- Don't forget to include the SDK -->
- <script src="https://apigee.com/usergrid/sdk/usergrid.0.10.5.js"></script>
+ <script src="https://apigee.com/usergrid/sdk/usergrid.0.10.8.js"></script>
<!-- If you prefer a local copy, you can find the file at the root the SDK’s github repo
github.com/apigee/usergrid-javascript-sdk -->
@@ -27,7 +27,8 @@ Detailed instructions follow but if you just want a quick example of how to get
var books;
- client.createCollection(options, function (err, books) {
+ client.createCollection(options, function (err, collection) {
+ books = collection;
if (err) {
alert("Couldn't get the list of books.");
} else {
@@ -52,11 +53,11 @@ Detailed instructions follow but if you just want a quick example of how to get
##Version
-Current Version: **0.10.7**
+Current Version: **0.10.8**
See change log:
-<https://github.com/apigee/usergrid-javascript-sdk/blob/master/changelog.md>
+<https://github.com/usergrid/usergrid/blob/master/sdks/html5-javascript/changelog.md>
##Comments / questions
For help using this SDK, reach out on the Usergrid google group:
@@ -70,13 +71,14 @@ Or just open github issues.
##Overview
This open source SDK simplifies writing JavaScript / HTML5 applications that connect to App Services. The repo is located here:
-<https://github.com/apigee/usergrid-javascript-sdk>
+<https://github.com/usergrid/usergrid/tree/master/sdks/html5-javascript>
You can download this package here:
-* Download as a zip file: <https://github.com/apigee/usergrid-javascript-sdk/archive/master.zip>
-* Download as a tar.gz file: <https://github.com/apigee/usergrid-javascript-sdk/archive/master.tar.gz>
+* Download as a zip file: <https://github.com/usergrid/usergrid/archive/master.zip>
+* Download as a tar.gz file: <https://github.com/usergrid/usergrid/archive/master.tar.gz>
+The Javascript SDK is in the sdks/html5-javascript folder.
To find out more about Apigee App Services, see:
@@ -94,19 +96,17 @@ Want to use Node.js? No problem - use the Usergrid Node Module:
or on github:
-<https://github.com/apigee/usergrid-node-module>
+<https://github.com/usergrid/usergrid/tree/master/sdks/nodejs>
The syntax for this Javascript SDK and the Usergrid Node module are almost exactly the same so you can easily transition between them.
##About the samples
-This SDK comes with a variety of samples that you can use to learn how to connect your project to App Services (Usergrid). See these examples running live now:
+This SDK comes with a variety of samples that you can use to learn how to connect your project to App Services (Usergrid).
-<http://apigee.github.io/usergrid-javascript-sdk>
+**Note:** All the sample code in this file is pulled directly from the "test" example, so you can rest-assured that it will work! You can find it here:
-**Note:** All the sample code in this file is pulled directly from the "test" example, so you can rest-assured that it will work! You can run them yourself here:
-
-<http://apigee.github.io/usergrid-javascript-sdk/examples/test/test.html>
+<https://github.com/usergrid/usergrid/blob/master/sdks/html5-javascript/examples/test/test.html>
##Installing
@@ -189,7 +189,7 @@ Once your object is created, you can update properties on it by using the `set`
state:'hungry'
}
- // Set is additive, so previously set properties are not overwritten
+ // Set is additive, so previously set properties are not overwritten unless a property with the same name exists in the data object
dog.set(data);
// And save back to the database
[10/50] [abbrv] git commit: Merge pull request #59 from
amuramoto/master
Posted by sn...@apache.org.
Merge pull request #59 from amuramoto/master
added destroyToken and logoutAndDestroyToken functions
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/5a7915c5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/5a7915c5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/5a7915c5
Branch: refs/heads/asyncqueue
Commit: 5a7915c58e50c56619b24814c074304dcc445440
Parents: 0b584f7 55b1a64
Author: Rod Simpson <ro...@rodsimpson.com>
Authored: Mon Mar 17 10:32:50 2014 -0600
Committer: Rod Simpson <ro...@rodsimpson.com>
Committed: Mon Mar 17 10:32:50 2014 -0600
----------------------------------------------------------------------
sdks/html5-javascript/lib/modules/Client.js | 64 ++++++++++++++++++++++++
1 file changed, 64 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5a7915c5/sdks/html5-javascript/lib/modules/Client.js
----------------------------------------------------------------------
[41/50] [abbrv] git commit: Change version to 2.0.0-SNAPSHOT so
modules do not conflict with old Usergrid modules in the repo.
Posted by sn...@apache.org.
Change version to 2.0.0-SNAPSHOT so modules do not conflict with old Usergrid modules in the repo.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/8043bf32
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/8043bf32
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/8043bf32
Branch: refs/heads/asyncqueue
Commit: 8043bf321f58bb221ce115070dd2bb786447ebc1
Parents: e7d8ece
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Mar 25 12:40:31 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Mar 25 12:40:31 2014 -0400
----------------------------------------------------------------------
stack/build-tools/pom.xml | 2 +-
stack/config/pom.xml | 2 +-
stack/core/pom.xml | 2 +-
stack/corepersistence/perftest1/pom.xml | 6 +++---
stack/launcher/pom.xml | 2 +-
stack/mongo-emulator/pom.xml | 2 +-
stack/pom.xml | 9 ++++++---
stack/query-validator/pom.xml | 2 +-
stack/rest/pom.xml | 4 ++--
stack/services/pom.xml | 2 +-
stack/test-utils/pom.xml | 2 +-
stack/tools/pom.xml | 4 ++--
stack/websocket/pom.xml | 2 +-
13 files changed, 22 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8043bf32/stack/build-tools/pom.xml
----------------------------------------------------------------------
diff --git a/stack/build-tools/pom.xml b/stack/build-tools/pom.xml
index 83d4ffe..fdd152b 100644
--- a/stack/build-tools/pom.xml
+++ b/stack/build-tools/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>build-tools</artifactId>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8043bf32/stack/config/pom.xml
----------------------------------------------------------------------
diff --git a/stack/config/pom.xml b/stack/config/pom.xml
index 16cd0ee..249b91b 100644
--- a/stack/config/pom.xml
+++ b/stack/config/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>usergrid-config</artifactId>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8043bf32/stack/core/pom.xml
----------------------------------------------------------------------
diff --git a/stack/core/pom.xml b/stack/core/pom.xml
index dad4a6b..7088e40 100644
--- a/stack/core/pom.xml
+++ b/stack/core/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<properties>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8043bf32/stack/corepersistence/perftest1/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/perftest1/pom.xml b/stack/corepersistence/perftest1/pom.xml
index 0307bde..64e76f7 100644
--- a/stack/corepersistence/perftest1/pom.xml
+++ b/stack/corepersistence/perftest1/pom.xml
@@ -20,20 +20,20 @@
<dependency>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid-core</artifactId>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid-test-utils</artifactId>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid-tools</artifactId>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<scope>test</scope>
<type>jar</type>
</dependency>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8043bf32/stack/launcher/pom.xml
----------------------------------------------------------------------
diff --git a/stack/launcher/pom.xml b/stack/launcher/pom.xml
index 9132aa0..56ad912 100644
--- a/stack/launcher/pom.xml
+++ b/stack/launcher/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>usergrid-launcher</artifactId>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8043bf32/stack/mongo-emulator/pom.xml
----------------------------------------------------------------------
diff --git a/stack/mongo-emulator/pom.xml b/stack/mongo-emulator/pom.xml
index 7592654..79e278e 100644
--- a/stack/mongo-emulator/pom.xml
+++ b/stack/mongo-emulator/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>usergrid-mongo-emulator</artifactId>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8043bf32/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index a02adfb..55f5059 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -27,7 +27,7 @@
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<name>Usergrid Parent</name>
<description>Usergrid Project</description>
<packaging>pom</packaging>
@@ -1769,6 +1769,7 @@
<exclude>**/README.md</exclude>
<exclude>**/CHANGES.txt</exclude>
<exclude>**/*.json</exclude>
+ <exclude>**/*.properties</exclude>
<!-- git and IDE project files -->
<exclude>**/.git/**</exclude>
@@ -1796,9 +1797,11 @@
<!-- other -->
<exclude>**/m2/**</exclude>
<exclude>**/*.asc</exclude>
- <exclude>**/src/test/resources/**</exclude>
<exclude>**/cloudbees.xml</exclude>
- <exclude>**/aws.properties</exclude>
+
+ <exclude>**/src/test/resources/**</exclude>
+ <exclude>**/src/main/dist/lib/**</exclude>
+ <exclude>**/src/main/dist/webapps/**</exclude>
<!-- TODO: need to add headers to many files in corepersistence -->
<exclude>**/corepersistence/**</exclude>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8043bf32/stack/query-validator/pom.xml
----------------------------------------------------------------------
diff --git a/stack/query-validator/pom.xml b/stack/query-validator/pom.xml
index ec37b93..ec04eda 100644
--- a/stack/query-validator/pom.xml
+++ b/stack/query-validator/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8043bf32/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 90311e5..e9cd2e0 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>usergrid-rest</artifactId>
@@ -586,7 +586,7 @@
<dependency>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid-services</artifactId>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8043bf32/stack/services/pom.xml
----------------------------------------------------------------------
diff --git a/stack/services/pom.xml b/stack/services/pom.xml
index 4c9f802..8d0126a 100644
--- a/stack/services/pom.xml
+++ b/stack/services/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<!-- Override these properties in your settings.xml in an active profile -->
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8043bf32/stack/test-utils/pom.xml
----------------------------------------------------------------------
diff --git a/stack/test-utils/pom.xml b/stack/test-utils/pom.xml
index 4be950b..d2f729b 100644
--- a/stack/test-utils/pom.xml
+++ b/stack/test-utils/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>usergrid-test-utils</artifactId>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8043bf32/stack/tools/pom.xml
----------------------------------------------------------------------
diff --git a/stack/tools/pom.xml b/stack/tools/pom.xml
index 062dcf7..7c002c0 100644
--- a/stack/tools/pom.xml
+++ b/stack/tools/pom.xml
@@ -21,14 +21,14 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>usergrid-tools</artifactId>
<name>Usergrid Tools</name>
<description>Command line tools for Usergrid system.</description>
<packaging>jar</packaging>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<reporting>
<plugins>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8043bf32/stack/websocket/pom.xml
----------------------------------------------------------------------
diff --git a/stack/websocket/pom.xml b/stack/websocket/pom.xml
index 665ba18..e26de6e 100644
--- a/stack/websocket/pom.xml
+++ b/stack/websocket/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.usergrid</groupId>
<artifactId>usergrid</artifactId>
- <version>0.0.29-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>usergrid-websocket</artifactId>
[18/50] [abbrv] git commit: Removed commented out code with no
function.
Posted by sn...@apache.org.
Removed commented out code with no function.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/fe2b3d6b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/fe2b3d6b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/fe2b3d6b
Branch: refs/heads/asyncqueue
Commit: fe2b3d6b4e24b4fa07215e66a46da6ccf1d4b510
Parents: 7b94845
Author: grey <gr...@apigee.com>
Authored: Wed Mar 19 15:00:41 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Wed Mar 19 15:00:41 2014 -0700
----------------------------------------------------------------------
.../cassandra/ManagementServiceIT.java | 26 +-------------------
1 file changed, 1 insertion(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/fe2b3d6b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index 7860847..6c0431b 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -772,7 +772,6 @@ public class ManagementServiceIT {
try {
f = new File( "testFileConnections.json" );
- //f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
@@ -844,7 +843,6 @@ public class ManagementServiceIT {
assertNotNull( objVibrations );
- //f.delete();
f.deleteOnExit();
}
@@ -856,7 +854,6 @@ public class ManagementServiceIT {
try {
f = new File( "testConnectionsOnApplicationEndpoint.json" );
- //f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
@@ -931,7 +928,6 @@ public class ManagementServiceIT {
assertNotNull( objVibrations );
- //f.delete();
f.deleteOnExit();
}
@@ -944,7 +940,6 @@ public class ManagementServiceIT {
try {
f = new File( "fileValidity.json" );
- //f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
@@ -981,7 +976,6 @@ public class ManagementServiceIT {
org.json.simple.JSONObject entityData = ( JSONObject ) entity.get( "Metadata" );
assertNotNull( entityData );
}
- //f.delete();
f.deleteOnExit();
}
@@ -993,7 +987,6 @@ public class ManagementServiceIT {
try {
f = new File( "testValidityOfApplicationExport.json" );
- //f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
@@ -1029,7 +1022,6 @@ public class ManagementServiceIT {
org.json.simple.JSONObject entityData = ( JSONObject ) entity.get( "Metadata" );
assertNotNull( entityData );
}
- //f.delete();
f.deleteOnExit();
}
@@ -1042,7 +1034,6 @@ public class ManagementServiceIT {
try {
f = new File( "exportOneOrg.json" );
- //f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
@@ -1085,7 +1076,6 @@ public class ManagementServiceIT {
// assertNotEquals( "NotEqual","junkRealName",entityName );
assertFalse( "junkRealName".equals( entityName ) );
}
- //f.delete();
f.deleteOnExit();
}
@@ -1100,7 +1090,6 @@ public class ManagementServiceIT {
try {
f = new File( "exportOneApp.json" );
- //f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't, don't do anything and carry on.
@@ -1155,8 +1144,6 @@ public class ManagementServiceIT {
assertFalse( "junkRealName".equals( entityName ) );
}
f.deleteOnExit();
-
- //f.delete();
}
//
@Test
@@ -1168,7 +1155,6 @@ public class ManagementServiceIT {
try {
f = new File( "exportOneApp.json" );
- // f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't, don't do anything and carry on.
@@ -1222,7 +1208,7 @@ public class ManagementServiceIT {
String entityName = ( String ) entityData.get( "name" );
assertFalse( "junkRealName".equals( entityName ) );
}
- //f.delete();
+
f.deleteOnExit();
}
@@ -1235,7 +1221,6 @@ public class ManagementServiceIT {
try {
f = new File( "exportOneCollection.json" );
- // f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't, don't do anything and carry on.
@@ -1282,7 +1267,6 @@ public class ManagementServiceIT {
org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
assertEquals( entitiesToCreate , a.size() );
- //f.delete();
f.deleteOnExit();
}
@@ -1298,7 +1282,6 @@ public class ManagementServiceIT {
try {
f = new File( "exportOneOrganization.json" );
- // f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't, don't do anything and carry on.
@@ -1370,9 +1353,6 @@ public class ManagementServiceIT {
/*plus 3 for the default roles*/
assertEquals( 23 , a.size() );
f.deleteOnExit();
-
-
- //f.delete();
}
@Test
@@ -1594,10 +1574,6 @@ public class ManagementServiceIT {
HashMap<String, Object> payload = new HashMap<String, Object>();
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> storage_info = new HashMap<String, Object>();
- // TODO: always put dummy values here and ignore this test.
-// storage_info.put( "s3_key", "insert key here" );
-// storage_info.put( "s3_access_id", "insert access id here" );
-// storage_info.put( "bucket_location", "insert bucket name here" );
storage_info.put( "s3_key", System.getProperty( "secretKey" ) );
storage_info.put( "s3_access_id", System.getProperty( "accessKey" ));
storage_info.put( "bucket_location", System.getProperty( "bucketName" ) );
[28/50] [abbrv] git commit: tweaking formatting in readme
Posted by sn...@apache.org.
tweaking formatting in readme
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/63ac9ccd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/63ac9ccd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/63ac9ccd
Branch: refs/heads/asyncqueue
Commit: 63ac9ccd1ff6e19e1f343612dc6b1ae709431084
Parents: 97a2ac0
Author: ryan bridges <rb...@apigee.com>
Authored: Thu Mar 20 16:45:02 2014 -0400
Committer: ryan bridges <rb...@apigee.com>
Committed: Thu Mar 20 16:45:02 2014 -0400
----------------------------------------------------------------------
sdks/html5-javascript/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/63ac9ccd/sdks/html5-javascript/README.md
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/README.md b/sdks/html5-javascript/README.md
index a46e19f..c5699be 100755
--- a/sdks/html5-javascript/README.md
+++ b/sdks/html5-javascript/README.md
@@ -504,7 +504,7 @@ An asset is created in the same manner as any Usergrid entity
// Success - the asset was created properly
}
});
-###Adding data
+##Adding data
You can upload data to your asset from a File input or by retrieving it via another request.
**Note:** Due to security concerns, you cannot browse and select a file programmatically from the local filesystem via javascript
[34/50] [abbrv] git commit: Update README.md
Posted by sn...@apache.org.
Update README.md
Moving docs to the website.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/3ccd913b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/3ccd913b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/3ccd913b
Branch: refs/heads/asyncqueue
Commit: 3ccd913b692bea8902ee40e18d6d03c94318e60d
Parents: 3f93ca7
Author: Dave Johnson <da...@rollerweblogger.org>
Authored: Sun Mar 23 18:03:51 2014 -0400
Committer: Dave Johnson <da...@rollerweblogger.org>
Committed: Sun Mar 23 18:03:51 2014 -0400
----------------------------------------------------------------------
README.md | 62 ----------------------------------------------------------
1 file changed, 62 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3ccd913b/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index faaf832..533f593 100644
--- a/README.md
+++ b/README.md
@@ -10,66 +10,4 @@ This repository contains all the code for Apache Usergrid, including the server
* the admin portal and the many SDKs. A pure HTML5+JavaScript app allowing you to register developers and let them manage their apps in a multi-tenant cluster. Located under [`/portal`](portal)
* SDKs for [iOS](sdks/ios), [Android](sdks/android), [HTML5/JavaScript](sdks/html5-javascript), [node.js](sdks/nodejs), [Ruby on Rails](ruby-on-rails), [pure Ruby](sdks/ruby), [PHP](sdks/php), (server-side) [Java](sdks/java) and [.Net / Windows](sdks/dotnet), located in their respective subdirectories under [`/sdks`](sdks).
-How to build and run Usergrid locally
--------------------------------------
-It's easy to build and run Usergrid locally. All you need is the Java JDK 1.7 and Maven 3.0.5 installed and on your path. Here's how you do it. First you get the source code like this:
-
- git clone git@github.com:usergrid/usergrid.git
-
-Next, you change directories into the Java SDK package and build the SDK:
-
- cd usergrid/sdks/java
- mvn clean install
-
-Next, you change directory into the stack directory and build the Usergrid WAR and launcher:
-
- cd ../..
- cd stack
- mvn clean install
-
-Finally, you can run Usergrid locally by using the all-in-one launcher, which includes a web server (Grizzly) and the database (Cassandra):
-
- cd launcher
- java -jar target/usergrid-launcher-0.0.29-SNAPSHOT.jar
-
-(you might have to substitute 0.0.29-SNAPSHOT with something newer)
-
-You should see the Usergrid launcher UI and from there you can start Usergrid and access the admin console.
-
-If not, subscribe to the [user mailing list](mailto:user-subscribe@usergrid.incubator.apache.org) and we can help you out.
-
-
-Backwards compatibility
------------------------
-
-If you previously developed with Apache Usergrid, you know our code used to be structured into _separate_ repositories: usergrid-stack, usergrid-portal, etc. We are now using a _merged_ repository.
-
-### How to update your code setup & pull changes from your old forks
-
-You just need to clone this repository, and use [git subtree (usually requires git 1.8+)](http://engineeredweb.com/blog/how-to-install-git-subtree/) to merge your changes under the new structure. Here’s an example for a portal fork. Adjust the prefix, repository address and branch you want to pull from as necessary.
-
- git clone git@github.com:usergrid/usergrid.git
- cd usergrid
- git subtree pull --prefix=portal git@github.com:my-github-account/my-usergrid-portal-fork.git master
-
-This will pull (i.e. merge) the changes you made from the master branch of github.com/my-github-account/my-usergrid-portal-fork into the portal/ subfolder. It should ask you to provide a commit message for the merge. There’s lot of flexibility on how to fetch and merge, [please see the git subtree manual](https://github.com/git/git/blob/master/contrib/subtree/git-subtree.txt) for details. Then please do consider sending us a pull request with these changes ;)
-
-
-### How to pull commits made on this repo into your old forks
-
-You should really update your old repositories to the new structure with the instructions above, but the following may work for you, although we make no guarantee they will work in the future.
-
-You can produce a branch compatible with the old repos by using [git subtree (usually requires git 1.8+)](http://engineeredweb.com/blog/how-to-install-git-subtree/). Then from this repository you can
-
- git clone git@github.com:usergrid/usergrid.git
- cd usergrid
- git checkout master
- git subtree split --prefix=portal -b portal
- git checkout portal
-
-This will create a “portal” branch that is compatible with the old usergrid-portal repository, from the code under the portal/ directory. You can pull from that branch (or push changes to it, although we will not accept pull requests sent thusly).
-
-The `git subtree split` above should function for portal, ugc, and any of the SDKs, but will not work for the stack, due to some anonymous comments left in the tree that prevent a split, and cannot be corrected lest we break the history and force a rebase on all forks.
-
-**Please update your code setup as soon as possible and [ask the dev list](https://mail-archives.apache.org/mod_mbox/incubator-usergrid-dev/) if you have any questions!**
[21/50] [abbrv] git commit: Replaced amazon libs with JCLOUD libs.
Amazon lib broke the rest tier and cannot be used until further testing is
done.
Posted by sn...@apache.org.
Replaced amazon libs with JCLOUD libs. Amazon lib broke the rest tier and cannot be used until further testing is done.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/f9456169
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/f9456169
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/f9456169
Branch: refs/heads/asyncqueue
Commit: f9456169437d940c4ab3e3a12c9f91cdccff758d
Parents: 79dc2c5
Author: grey <gr...@apigee.com>
Authored: Wed Mar 19 23:03:00 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Wed Mar 19 23:03:00 2014 -0700
----------------------------------------------------------------------
stack/services/pom.xml | 12 ---
.../cassandra/ManagementServiceIT.java | 87 +++++++++++++++-----
2 files changed, 66 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f9456169/stack/services/pom.xml
----------------------------------------------------------------------
diff --git a/stack/services/pom.xml b/stack/services/pom.xml
index de02659..4c9f802 100644
--- a/stack/services/pom.xml
+++ b/stack/services/pom.xml
@@ -448,7 +448,6 @@
<artifactId>tika-core</artifactId>
</dependency>
-
<!-- Testing and Logging Dependencies -->
<dependency>
<!--
@@ -554,17 +553,6 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.3.3</version>
- </dependency>
-
- <dependency>
- <groupId>com.amazonaws</groupId>
- <artifactId>aws-java-sdk</artifactId>
- <version>1.7.3</version>
- </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f9456169/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index 44e0277..8000b25 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -23,8 +23,17 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.UUID;
-
+import java.util.concurrent.TimeUnit;
+
+import org.jclouds.ContextBuilder;
+import org.jclouds.blobstore.AsyncBlobStore;
+import org.jclouds.blobstore.BlobStoreContext;
+import org.jclouds.blobstore.domain.Blob;
+import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
+import org.jclouds.logging.log4j.config.Log4JLoggingModule;
+import org.jclouds.netty.config.NettyPayloadModule;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.junit.BeforeClass;
@@ -65,12 +74,9 @@ import org.apache.usergrid.security.tokens.exceptions.InvalidTokenException;
import org.apache.usergrid.utils.JsonUtils;
import org.apache.usergrid.utils.UUIDUtils;
-import com.amazonaws.auth.AWSCredentials;
-import com.amazonaws.auth.BasicAWSCredentials;
-import com.amazonaws.services.s3.AmazonS3;
-import com.amazonaws.services.s3.AmazonS3Client;
-import com.amazonaws.services.s3.model.GetObjectRequest;
-import com.amazonaws.services.s3.model.S3Object;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.inject.Module;
import static org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString;
import static org.apache.usergrid.persistence.Schema.DICTIONARY_CREDENTIALS;
@@ -83,6 +89,13 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+//import com.amazonaws.auth.AWSCredentials;
+//import com.amazonaws.auth.BasicAWSCredentials;
+//import com.amazonaws.services.s3.AmazonS3;
+//import com.amazonaws.services.s3.AmazonS3Client;
+//import com.amazonaws.services.s3.model.GetObjectRequest;
+//import com.amazonaws.services.s3.model.S3Object;
+
/** @author zznate */
@@ -1519,18 +1532,34 @@ public class ManagementServiceIT {
exportService.doExport( jobExecution );
while (!exportService.getState( applicationId,exportUUID ).equals("FINISHED"));
- AWSCredentials myCredentials = new BasicAWSCredentials(
- System.getProperty( "accessKey" ), System.getProperty("secretKey"));
- AmazonS3 s3client = new AmazonS3Client(myCredentials);
- S3Object sd = null;
+ String bucketName = System.getProperty( "bucketName" );
+ String accessId = System.getProperty( "accessKey" );
+ String secretKey = System.getProperty("secretKey");
+
+ Properties overrides = new Properties();
+ overrides.setProperty( "s3" + ".identity", accessId );
+ overrides.setProperty( "s3" + ".credential", secretKey );
+
+ Blob bo = null;
+
try {
- sd = s3client.getObject( new GetObjectRequest( System.getProperty( "bucketName" ),
- s3Export.getFilename()) );
+ final Iterable<? extends Module> MODULES = ImmutableSet
+ .of( new JavaUrlHttpCommandExecutorServiceModule(), new Log4JLoggingModule(), new NettyPayloadModule
+ () );
+
+ BlobStoreContext context =
+ ContextBuilder.newBuilder( "s3" ).credentials( accessId, secretKey ).modules( MODULES )
+ .overrides( overrides ).buildView( BlobStoreContext.class );
+
+
+ AsyncBlobStore blobStore = context.getAsyncBlobStore();
+ ListenableFuture<Blob> futureETag = blobStore.getBlob( bucketName,s3Export.getFilename() );
+ bo = futureETag.get( 1, TimeUnit.SECONDS );
}catch(Exception e) {
assert(false);
}
- assertNotNull( sd );
+ assertNotNull( bo );
}
//@Ignore("I'd have to add some overhead such that I loop through all files or keep track of them all ")
@@ -1594,17 +1623,33 @@ public class ManagementServiceIT {
exportService.doExport( jobExecution );
while (!exportService.getState( applicationId,exportUUID ).equals("FINISHED"));
- AWSCredentials myCredentials = new BasicAWSCredentials(
- System.getProperty( "accessKey" ), System.getProperty("secretKey"));
- AmazonS3 s3client = new AmazonS3Client(myCredentials);
- S3Object sd = null;
+ String bucketName = System.getProperty( "bucketName" );
+ String accessId = System.getProperty( "accessKey" );
+ String secretKey = System.getProperty("secretKey");
+
+ Properties overrides = new Properties();
+ overrides.setProperty( "s3" + ".identity", accessId );
+ overrides.setProperty( "s3" + ".credential", secretKey );
+ Blob bo = null;
+
try {
- sd = s3client.getObject( new GetObjectRequest( System.getProperty( "bucketName" ),
- s3Export.getFilename()) );
+ final Iterable<? extends Module> MODULES = ImmutableSet
+ .of( new JavaUrlHttpCommandExecutorServiceModule(), new Log4JLoggingModule(), new NettyPayloadModule
+ () );
+
+ BlobStoreContext context =
+ ContextBuilder.newBuilder( "s3" ).credentials( accessId, secretKey ).modules( MODULES )
+ .overrides( overrides ).buildView( BlobStoreContext.class );
+
+
+ AsyncBlobStore blobStore = context.getAsyncBlobStore();
+ ListenableFuture<Blob> futureETag = blobStore.getBlob( bucketName,s3Export.getFilename() );
+ bo = futureETag.get( 1, TimeUnit.SECONDS );
}catch(Exception e) {
assert(false);
}
- assertNotNull( sd );
+
+ assertNotNull( bo );
}
/*Creates fake payload for testing purposes.*/
[27/50] [abbrv] git commit: Changing script reference to local path
Posted by sn...@apache.org.
Changing script reference to local path
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/97a2ac06
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/97a2ac06
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/97a2ac06
Branch: refs/heads/asyncqueue
Commit: 97a2ac064d196595e8ec7bd7106f77785b45926d
Parents: a96c3ac
Author: ryan bridges <rb...@apigee.com>
Authored: Thu Mar 20 16:31:15 2014 -0400
Committer: ryan bridges <rb...@apigee.com>
Committed: Thu Mar 20 16:42:07 2014 -0400
----------------------------------------------------------------------
sdks/html5-javascript/README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/97a2ac06/sdks/html5-javascript/README.md
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/README.md b/sdks/html5-javascript/README.md
index 2d7bdf6..a46e19f 100755
--- a/sdks/html5-javascript/README.md
+++ b/sdks/html5-javascript/README.md
@@ -6,9 +6,9 @@ Detailed instructions follow but if you just want a quick example of how to get
<html>
<head>
<!-- Don't forget to include the SDK -->
- <script src="https://apigee.com/usergrid/sdk/usergrid.0.10.8.js"></script>
- <!-- If you prefer a local copy, you can find the file at the root the SDK’s github repo
- github.com/apigee/usergrid-javascript-sdk -->
+ <script src="/path/to/usergrid.js"></script>
+ <!-- You can find the file in the Usergrid github repo
+ https://github.com/usergrid/usergrid/blob/master/sdks/html5-javascript/usergrid.js -->
<script type="text/javascript">
[24/50] [abbrv] git commit: Merge branch 'DPS-846' of
github.com:r3b/usergrid-1
Posted by sn...@apache.org.
Merge branch 'DPS-846' of github.com:r3b/usergrid-1
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/d9e8698c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/d9e8698c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/d9e8698c
Branch: refs/heads/asyncqueue
Commit: d9e8698c2a93da8ef11d96a4c7322943f3540a09
Parents: 24425d5 3007b55
Author: ryan bridges <rb...@apigee.com>
Authored: Thu Mar 20 16:33:46 2014 -0400
Committer: ryan bridges <rb...@apigee.com>
Committed: Thu Mar 20 16:33:46 2014 -0400
----------------------------------------------------------------------
sdks/html5-javascript/README.md | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
[09/50] [abbrv] git commit: Merge pull request #71 from r3b/DPS-865
Posted by sn...@apache.org.
Merge pull request #71 from r3b/DPS-865
Dps 865
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/0b584f73
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/0b584f73
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/0b584f73
Branch: refs/heads/asyncqueue
Commit: 0b584f7351896e2df62c04c8b6a4f24ac1cdd3b9
Parents: 7ea7503 13ab2bd
Author: Rod Simpson <ro...@rodsimpson.com>
Authored: Mon Mar 17 06:57:21 2014 -0600
Committer: Rod Simpson <ro...@rodsimpson.com>
Committed: Mon Mar 17 06:57:21 2014 -0600
----------------------------------------------------------------------
sdks/html5-javascript/lib/Usergrid.js | 13 +++++++++++-
sdks/html5-javascript/lib/modules/Client.js | 10 ++++++++--
sdks/html5-javascript/package.json | 2 +-
sdks/html5-javascript/tests/mocha/test.js | 25 ++++++++++++++++++++++++
sdks/html5-javascript/usergrid.js | 24 +++++++++++++++++++++--
sdks/html5-javascript/usergrid.min.js | 6 +++---
6 files changed, 71 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
[22/50] [abbrv] git commit: extended time to wait for 3 seconds to
have more give.
Posted by sn...@apache.org.
extended time to wait for 3 seconds to have more give.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/1f716040
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/1f716040
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/1f716040
Branch: refs/heads/asyncqueue
Commit: 1f71604016d0c04d99e820015b5818e64f2fc735
Parents: f945616
Author: grey <gr...@apigee.com>
Authored: Wed Mar 19 23:56:50 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Wed Mar 19 23:56:50 2014 -0700
----------------------------------------------------------------------
.../usergrid/management/cassandra/ManagementServiceIT.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1f716040/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index 8000b25..0c0e8e1 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -1554,7 +1554,7 @@ public class ManagementServiceIT {
AsyncBlobStore blobStore = context.getAsyncBlobStore();
ListenableFuture<Blob> futureETag = blobStore.getBlob( bucketName,s3Export.getFilename() );
- bo = futureETag.get( 1, TimeUnit.SECONDS );
+ bo = futureETag.get( 3, TimeUnit.SECONDS );
}catch(Exception e) {
assert(false);
}
@@ -1644,7 +1644,7 @@ public class ManagementServiceIT {
AsyncBlobStore blobStore = context.getAsyncBlobStore();
ListenableFuture<Blob> futureETag = blobStore.getBlob( bucketName,s3Export.getFilename() );
- bo = futureETag.get( 1, TimeUnit.SECONDS );
+ bo = futureETag.get( 3, TimeUnit.SECONDS );
}catch(Exception e) {
assert(false);
}
[46/50] [abbrv] Put queryindex classes all under one top-level
"index" package to eliminate conflict with old persistence classes.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/FloatLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/FloatLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/FloatLiteral.java
deleted file mode 100644
index 518e39f..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/FloatLiteral.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.ClassicToken;
-import org.antlr.runtime.Token;
-
-
-/** @author tnine */
-public class FloatLiteral extends Literal<Float> implements NumericLiteral {
-
- private float value;
-
-
- /**
- * @param t
- */
- public FloatLiteral( Token t ) {
- super( t );
- value = Float.valueOf( t.getText() );
- }
-
-
- public FloatLiteral( float f ) {
- super( new ClassicToken( 0, String.valueOf( f ) ) );
- value = f;
- }
-
-
- /** @return the value */
- public Float getValue() {
- return value;
- }
-
-
- /* (non-Javadoc)
- * @see org.apache.usergrid.persistence.query.tree.NumericLiteral#getFloatValue()
- */
- @Override
- public float getFloatValue() {
- return value;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/GreaterThan.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/GreaterThan.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/GreaterThan.java
deleted file mode 100644
index 966fbb2..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/GreaterThan.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.CommonToken;
-import org.antlr.runtime.Token;
-import org.apache.usergrid.persistence.exceptions.NoIndexException;
-
-
-/** @author tnine */
-public class GreaterThan extends EqualityOperand {
-
- /**
- * @param property
- * @param literal
- */
- public GreaterThan( Token t ) {
- super( t );
- }
-
-
- public GreaterThan() {
- super( new CommonToken( 0, ">" ) );
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
- * .query.tree.QueryVisitor)
- */
- @Override
- public void visit( QueryVisitor visitor ) throws NoIndexException {
- visitor.visit( this );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/GreaterThanEqual.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/GreaterThanEqual.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/GreaterThanEqual.java
deleted file mode 100644
index d561010..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/GreaterThanEqual.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.CommonToken;
-import org.antlr.runtime.Token;
-import org.apache.usergrid.persistence.exceptions.NoIndexException;
-
-
-/** @author tnine */
-public class GreaterThanEqual extends EqualityOperand {
-
- /**
- * @param property
- * @param literal
- */
- public GreaterThanEqual( Token t ) {
- super( t );
- }
-
-
- /**
- * @param property
- * @param literal
- */
- public GreaterThanEqual() {
- super( new CommonToken( 0, ">=" ) );
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
- * .query.tree.QueryVisitor)
- */
- @Override
- public void visit( QueryVisitor visitor ) throws NoIndexException {
- visitor.visit( this );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LessThan.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LessThan.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LessThan.java
deleted file mode 100644
index 008abf5..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LessThan.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.CommonToken;
-import org.antlr.runtime.Token;
-import org.apache.usergrid.persistence.exceptions.NoIndexException;
-
-
-/** @author tnine */
-public class LessThan extends EqualityOperand {
-
- /**
- * @param property
- * @param literal
- */
- public LessThan( Token t ) {
- super( t );
- }
-
-
- public LessThan() {
- super( new CommonToken( 0, "<" ) );
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
- * .query.tree.QueryVisitor)
- */
- @Override
- public void visit( QueryVisitor visitor ) throws NoIndexException {
- visitor.visit( this );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LessThanEqual.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LessThanEqual.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LessThanEqual.java
deleted file mode 100644
index 1ea5d81..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LessThanEqual.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.CommonToken;
-import org.antlr.runtime.Token;
-import org.apache.usergrid.persistence.exceptions.NoIndexException;
-
-
-/** @author tnine */
-public class LessThanEqual extends EqualityOperand {
-
- /**
- * @param property
- * @param literal
- */
- public LessThanEqual( Token t ) {
- super( t );
- }
-
-
- /**
- */
- public LessThanEqual() {
- super( new CommonToken( 0, "<=" ) );
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
- * .query.tree.QueryVisitor)
- */
- @Override
- public void visit( QueryVisitor visitor ) throws NoIndexException {
- visitor.visit( this );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Literal.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Literal.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Literal.java
deleted file mode 100644
index acd9ac4..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Literal.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.Token;
-import org.antlr.runtime.tree.CommonTree;
-
-
-/**
- * Abstract class for literals
- *
- * @author tnine
- */
-public abstract class Literal<V> extends CommonTree {
-
-
- protected Literal( Token t ) {
- super( t );
- }
-
-
- /** Return the value of the literal the user has passed in */
- public abstract V getValue();
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LiteralFactory.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LiteralFactory.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LiteralFactory.java
deleted file mode 100644
index 2895797..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LiteralFactory.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.query.tree;
-
-
-import java.util.UUID;
-
-
-/**
- * Simple factory for generating literal instance based on the runtime value
- *
- * @author tnine
- */
-public class LiteralFactory {
-
- /** Generate the correct literal subclass based on the runtime instance. */
- public static final Literal<?> getLiteral( Object value ) {
- if ( value instanceof Integer ) {
- return new LongLiteral( ( Integer ) value );
- }
- if ( value instanceof Long ) {
- return new LongLiteral( ( Long ) value );
- }
-
- if ( value instanceof String ) {
- return new StringLiteral( ( String ) value );
- }
-
- if ( value instanceof Float ) {
- return new FloatLiteral( ( Float ) value );
- }
-
- if ( value instanceof UUID ) {
- return new UUIDLiteral( ( UUID ) value );
- }
-
- if ( value instanceof Boolean ) {
- return new BooleanLiteral( ( Boolean ) value );
- }
-
- throw new UnsupportedOperationException(
- String.format( "Unsupported type of %s was passed when trying to construct a literal",
- value.getClass() ) );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LongLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LongLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LongLiteral.java
deleted file mode 100644
index 609e11c..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/LongLiteral.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.ClassicToken;
-import org.antlr.runtime.Token;
-
-
-/** @author tnine */
-public class LongLiteral extends Literal<Long> implements NumericLiteral {
-
- private long value;
-
-
- /**
- * @param t
- */
- public LongLiteral( Token t ) {
- super( t );
- this.value = Long.valueOf( t.getText() );
- }
-
-
- /**
- *
- * @param value
- */
- public LongLiteral( long value ) {
- super( new ClassicToken( 0, String.valueOf( value ) ) );
- this.value = value;
- }
-
-
- /**
- *
- * @return
- */
- public Long getValue() {
- return this.value;
- }
-
-
- /* (non-Javadoc)
- * @see org.apache.usergrid.persistence.query.tree.NumericLiteral#getFloatValue()
- */
- @Override
- public float getFloatValue() {
- return value;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/NotOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/NotOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/NotOperand.java
deleted file mode 100644
index 8388e5d..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/NotOperand.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright 2012 Apigee Corporation
- *
- * Licensed 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.query.tree;
-
-
-import org.antlr.runtime.Token;
-import org.apache.usergrid.persistence.exceptions.PersistenceException;
-
-
-/** @author tnine */
-public class NotOperand extends Operand {
-
-
- public NotOperand( Token t ) {
- super( t );
- }
-
-
- /** get the only child operation */
- public Operand getOperation() {
- return ( Operand ) this.children.get( 0 );
- }
-
-
- /* (non-Javadoc)
- * @see org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence.query.tree.QueryVisitor)
- */
- @Override
- public void visit( QueryVisitor visitor ) throws PersistenceException {
- visitor.visit( this );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/NumericLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/NumericLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/NumericLiteral.java
deleted file mode 100644
index 9ec5b0c..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/NumericLiteral.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.query.tree;
-
-
-/** @author tnine */
-public interface NumericLiteral {
-
- /** Return the value of this numeric literal as a float */
- public float getFloatValue();
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Operand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Operand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Operand.java
deleted file mode 100644
index d3f5791..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Operand.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.Token;
-import org.antlr.runtime.tree.CommonTree;
-import org.apache.usergrid.persistence.exceptions.PersistenceException;
-
-
-/**
- * Any logical operation should subclass. Boolean logic, equality, not, contains, within and others are examples of
- * operands
- *
- * @author tnine
- */
-public abstract class Operand extends CommonTree {
-
-
- /** Default constructor to take a token */
- public Operand( Token t ) {
- super( t );
- }
-
-
- /** Get the pointer to the parent node */
- public Operand getParent() {
- return ( Operand ) super.getParent();
- }
-
-
- /** Visitor method */
- public abstract void visit( QueryVisitor visitor ) throws PersistenceException;
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/OrOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/OrOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/OrOperand.java
deleted file mode 100644
index 279c0f1..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/OrOperand.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.CommonToken;
-import org.antlr.runtime.Token;
-import org.apache.usergrid.persistence.exceptions.PersistenceException;
-
-
-/** @author tnine */
-public class OrOperand extends BooleanOperand {
-
- /**
- * @param left
- * @param token
- * @param right
- */
- public OrOperand( Token t ) {
- super( t );
- }
-
-
- public OrOperand() {
- super( new CommonToken( 0, "or" ) );
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
- * .query.tree.QueryVisitor)
- */
- @Override
- public void visit( QueryVisitor visitor ) throws PersistenceException {
- visitor.visit( this );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Property.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Property.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Property.java
deleted file mode 100644
index dee3d91..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Property.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.ClassicToken;
-import org.antlr.runtime.Token;
-
-
-/**
- * A property
- *
- * @author tnine
- */
-public class Property extends Literal<String> {
-
- private String property;
-
-
- public Property( Token t ) {
- super( t );
- this.property = t.getText();
- }
-
-
- public Property( String property ) {
- this( new ClassicToken( 0, property ) );
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.usergrid.persistence.query.tree.Literal#getValue()
- */
- @Override
- public String getValue() {
- return this.property;
- }
-
-
- /**
- * Subclasses an override. Indexed value could be different when stored internally. By default returns the same
- * property
- */
- public String getIndexedValue() {
- return this.property;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryVisitor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryVisitor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryVisitor.java
deleted file mode 100644
index 888f1cf..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/QueryVisitor.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.apache.usergrid.persistence.exceptions.NoFullTextIndexException;
-import org.apache.usergrid.persistence.exceptions.NoIndexException;
-import org.apache.usergrid.persistence.exceptions.PersistenceException;
-import org.elasticsearch.index.query.FilterBuilder;
-import org.elasticsearch.index.query.QueryBuilder;
-
-
-/**
- * Interface for visiting nodes in our AST as we produce
- *
- * @author tnine
- */
-public interface QueryVisitor {
-
- /**
- *
- * @param op
- * @throws PersistenceException
- */
- public void visit( AndOperand op ) throws PersistenceException;
-
- /**
- * @param op
- * @throws PersistenceException
- */
- public void visit( OrOperand op ) throws PersistenceException;
-
- /**
- * @param op
- * @throws PersistenceException
- */
- public void visit( NotOperand op ) throws PersistenceException;
-
- /**
- * @param op
- * @throws NoIndexException
- */
- public void visit( LessThan op ) throws NoIndexException;
-
- /**
- * @param op
- * @throws NoFullTextIndexException
- */
- public void visit( ContainsOperand op ) throws NoFullTextIndexException;
-
- /**
- * @param op
- */
- public void visit( WithinOperand op );
-
- /**
- * @param op
- * @throws NoIndexException
- */
- public void visit( LessThanEqual op ) throws NoIndexException;
-
- /**
- * @param op
- * @throws NoIndexException
- */
- public void visit( Equal op ) throws NoIndexException;
-
- /**
- * @param op
- * @throws NoIndexException
- */
- public void visit( GreaterThan op ) throws NoIndexException;
-
- /**
- * @param op
- * @throws NoIndexException
- */
- public void visit( GreaterThanEqual op ) throws NoIndexException;
-
- /**
- * Returns resulting query builder.
- */
- public QueryBuilder getQueryBuilder();
-
- public FilterBuilder getFilterBuilder();
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/StringLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/StringLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/StringLiteral.java
deleted file mode 100644
index 982cb8a..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/StringLiteral.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.ClassicToken;
-import org.antlr.runtime.Token;
-
-import static org.apache.commons.lang.StringUtils.removeEnd;
-
-
-/** @author tnine */
-public class StringLiteral extends Literal<String> {
-
- private String value;
- private String finishValue;
-
-
- /**
- * @param t
- */
- public StringLiteral( Token t ) {
- super( t );
- String newValue = t.getText();
- newValue = newValue.substring( 1, newValue.length() - 1 );
-
- parseValue( newValue );
- }
-
-
- public StringLiteral( String value ) {
- super( new ClassicToken( 0, value ) );
- parseValue( value );
- }
-
-
- /** Parse the value and set the optional end value */
- private void parseValue( String value ) {
-
- this.value = value.trim().toLowerCase();
-
- if ( "*".equals( value ) ) {
- this.value = null;
- this.finishValue = null;
- return;
- }
-
- if ( value != null && value.endsWith( "*" ) ) {
- this.value = removeEnd( value.toString(), "*" );
-
- finishValue = this.value + "\uFFFF";
- }
- // set the end value to the same as the start value
- else {
- finishValue = value;
- }
- }
-
-
- /** If this were a string literal */
- public String getEndValue() {
- return this.finishValue;
- }
-
-
- public String getValue() {
- return this.value;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/UUIDLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/UUIDLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/UUIDLiteral.java
deleted file mode 100644
index 1b60540..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/UUIDLiteral.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.query.tree;
-
-
-import java.util.UUID;
-
-import org.antlr.runtime.ClassicToken;
-import org.antlr.runtime.Token;
-
-
-/** @author tnine */
-public class UUIDLiteral extends Literal<UUID> {
-
- private UUID value;
-
-
- /**
- * @param t
- */
- public UUIDLiteral( Token t ) {
- super( t );
- value = UUID.fromString( t.getText() );
- }
-
-
- public UUIDLiteral( UUID value ) {
- super( new ClassicToken( 0, String.valueOf( value ) ) );
- this.value = value;
- }
-
-
- public UUID getValue() {
- return this.value;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/WithinOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/WithinOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/WithinOperand.java
deleted file mode 100644
index debf07c..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/WithinOperand.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright 2012 Apigee Corporation
- *
- * Licensed 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.query.tree;
-
-
-import org.antlr.runtime.Token;
-
-
-/** @author tnine */
-public class WithinOperand extends Operand {
-
- /**
- * @param property
- * @param literal
- */
- public WithinOperand( Token t ) {
- super( t );
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
- * .query.tree.QueryVisitor)
- */
- @Override
- public void visit( QueryVisitor visitor ) {
- visitor.visit( this );
- }
-
-
- /**
- * @param propName
- */
- public void setProperty( String propName ) {
- setChild( 0, new WithinProperty( propName ) );
- }
-
-
- /**
- * @param distance
- */
- public void setDistance( float distance ) {
- setChild( 1, new FloatLiteral( distance ) );
- }
-
-
- /**
- * @param Latitude
- */
- public void setLatitude( float Latitude ) {
- setChild( 2, new FloatLiteral( Latitude ) );
- }
-
-
- /**
- * @param longitude
- */
- public void setLongitude( float longitude ) {
- setChild( 3, new FloatLiteral( longitude ) );
- }
-
-
- /**
- *
- * @return
- */
- public WithinProperty getProperty() {
- return ( WithinProperty ) this.children.get( 0 );
- }
-
-
- /**
- *
- * @return
- */
- public NumericLiteral getDistance() {
- return ( NumericLiteral ) this.children.get( 1 );
- }
-
-
- /**
- * @return
- */
- public NumericLiteral getLatitude() {
- return ( NumericLiteral ) this.children.get( 2 );
- }
-
-
- /**
- * @return
- */
- public NumericLiteral getLongitude() {
- return ( NumericLiteral ) this.children.get( 3 );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/WithinProperty.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/WithinProperty.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/WithinProperty.java
deleted file mode 100644
index 2707e77..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/WithinProperty.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.ClassicToken;
-import org.antlr.runtime.Token;
-
-
-/**
- * A property
- *
- * @author tnine
- */
-public class WithinProperty extends Property {
-
- private String indexedName = null;
-
-
- public WithinProperty( Token t ) {
- super( t );
- this.indexedName = String.format( "%s.coordinates", super.getValue() );
- }
-
-
- public WithinProperty( String property ) {
- this( new ClassicToken( 0, property ) );
- }
-
-
- /** Get the */
- public String getIndexedName() {
- return this.indexedName;
- }
-
-
- /** @return the property */
- public WithinProperty getProperty() {
- return ( WithinProperty ) this.children.get( 0 );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/ClassUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/ClassUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/ClassUtils.java
deleted file mode 100644
index 6ce847e..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/ClassUtils.java
+++ /dev/null
@@ -1,58 +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.utils;
-
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-
-public class ClassUtils extends org.apache.commons.lang.ClassUtils {
-
- @SuppressWarnings("unchecked")
- public static <A, B> B cast( A a ) {
- return ( B ) a;
- }
-
-
- @SuppressWarnings("unchecked")
- private static final Set<Class<?>> WRAPPER_TYPES = new HashSet<Class<?>>(
- Arrays.asList( Boolean.class, Byte.class, Character.class, Double.class, Float.class, Integer.class,
- Long.class, Short.class, Void.class ) );
-
-
- public static boolean isWrapperType( Class<?> clazz ) {
- return WRAPPER_TYPES.contains( clazz );
- }
-
-
- public static boolean isPrimitiveType( Class<?> clazz ) {
- if ( clazz == null ) {
- return false;
- }
- return clazz.isPrimitive() || isWrapperType( clazz );
- }
-
-
- public static boolean isBasicType( Class<?> clazz ) {
- if ( clazz == null ) {
- return false;
- }
- return ( String.class.isAssignableFrom( clazz ) ) || isPrimitiveType( clazz );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/ConversionUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/ConversionUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/ConversionUtils.java
deleted file mode 100644
index 567a713..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/ConversionUtils.java
+++ /dev/null
@@ -1,765 +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.utils;
-
-
-import java.io.UnsupportedEncodingException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.commons.lang.math.NumberUtils;
-
-
-/** Convenience methods for converting to and from formats, primarily between byte arrays and UUIDs, Strings,
- * and Longs. */
-public class ConversionUtils {
-
- private static final Logger logger = LoggerFactory.getLogger( ConversionUtils.class );
-
- /**
- *
- */
- public static final String UTF8_ENCODING = "UTF-8";
-
- /**
- *
- */
- public static final String ASCII_ENCODING = "US-ASCII";
-
- public static final ByteBuffer HOLDER = ByteBuffer.wrap( new byte[] { 0 } );
-
-
- /**
- * @param uuid
- * @return
- */
- public static UUID uuid( byte[] uuid ) {
- return uuid( uuid, 0 );
- }
-
-
- /**
- * @param uuid
- * @param offset
- * @return
- */
- public static UUID uuid( byte[] uuid, int offset ) {
- ByteBuffer bb = ByteBuffer.wrap( uuid, offset, 16 );
- return new UUID( bb.getLong(), bb.getLong() );
- }
-
-
- public static UUID uuid( ByteBuffer bb ) {
- if ( bb == null ) {
- return null;
- }
- if ( bb.remaining() < 16 ) {
- return null;
- }
- bb = bb.slice();
- return new UUID( bb.getLong(), bb.getLong() );
- }
-
-
- /**
- * @param uuid
- * @return
- */
- public static UUID uuid( String uuid ) {
- try {
- return UUID.fromString( uuid );
- }
- catch ( Exception e ) {
- logger.error( "Bad UUID", e );
- }
- return UUIDUtils.ZERO_UUID;
- }
-
-
- /**
- * @param obj
- * @return
- */
- public static UUID uuid( Object obj ) {
- return uuid( obj, UUIDUtils.ZERO_UUID );
- }
-
-
- public static UUID uuid( Object obj, UUID defaultValue ) {
- if ( obj instanceof UUID ) {
- return ( UUID ) obj;
- }
- else if ( obj instanceof byte[] ) {
- return uuid( ( byte[] ) obj );
- }
- else if ( obj instanceof ByteBuffer ) {
- return uuid( ( ByteBuffer ) obj );
- }
- else if ( obj instanceof String ) {
- return uuid( ( String ) obj );
- }
- return defaultValue;
- }
-
-
- /**
- * @param uuid
- * @return
- */
- public static byte[] bytes( UUID uuid ) {
- if ( uuid == null ) {
- return null;
- }
- long msb = uuid.getMostSignificantBits();
- long lsb = uuid.getLeastSignificantBits();
- byte[] buffer = new byte[16];
-
- for ( int i = 0; i < 8; i++ ) {
- buffer[i] = ( byte ) ( msb >>> ( 8 * ( 7 - i ) ) );
- }
- for ( int i = 8; i < 16; i++ ) {
- buffer[i] = ( byte ) ( lsb >>> ( 8 * ( 7 - i ) ) );
- }
-
- return buffer;
- }
-
-
- public static ByteBuffer bytebuffer( UUID uuid ) {
- if ( uuid == null ) {
- return null;
- }
- return ByteBuffer.wrap( bytes( uuid ) );
- }
-
-
- /**
- * @param uuid
- * @return
- */
- public static byte[] uuidToBytesNullOk( UUID uuid ) {
- if ( uuid != null ) {
- return bytes( uuid );
- }
- return new byte[16];
- }
-
-
- /**
- * @param s
- * @return
- */
- public static byte[] bytes( String s ) {
- return bytes( s, UTF8_ENCODING );
- }
-
-
- public static ByteBuffer bytebuffer( String s ) {
- return ByteBuffer.wrap( bytes( s ) );
- }
-
-
- /**
- * @param s
- * @return
- */
- public static byte[] ascii( String s ) {
- if ( s == null ) {
- return new byte[0];
- }
- return bytes( s, ASCII_ENCODING );
- }
-
-
- public ByteBuffer asciibuffer( String s ) {
- return ByteBuffer.wrap( ascii( s ) );
- }
-
-
- /**
- * @param s
- * @param encoding
- * @return
- */
- public static byte[] bytes( String s, String encoding ) {
- try {
- return s.getBytes( encoding );
- }
- catch ( UnsupportedEncodingException e ) {
- // logger.log(Level.SEVERE, "UnsupportedEncodingException ", e);
- throw new RuntimeException( e );
- }
- }
-
-
- public static byte[] bytes( ByteBuffer bb ) {
- byte[] b = new byte[bb.remaining()];
- bb.duplicate().get( b );
- return b;
- }
-
-
- public static ByteBuffer bytebuffer( String s, String encoding ) {
- return ByteBuffer.wrap( bytes( s, encoding ) );
- }
-
-
- /**
- * @param b
- * @return
- */
- public static byte[] bytes( Boolean b ) {
- byte[] bytes = new byte[1];
- bytes[0] = b ? ( byte ) 1 : 0;
- return bytes;
- }
-
-
- public static ByteBuffer bytebuffer( Boolean b ) {
- return ByteBuffer.wrap( bytes( b ) );
- }
-
-
- /**
- * @param val
- * @return
- */
- public static byte[] bytes( Long val ) {
- ByteBuffer buf = ByteBuffer.allocate( 8 );
- buf.order( ByteOrder.BIG_ENDIAN );
- buf.putLong( val );
- return buf.array();
- }
-
-
- public static ByteBuffer bytebuffer( Long val ) {
- ByteBuffer buf = ByteBuffer.allocate( 8 );
- buf.order( ByteOrder.BIG_ENDIAN );
- buf.putLong( val );
- return ( ByteBuffer ) buf.rewind();
- }
-
-
- /**
- * @param obj
- * @return
- */
- public static byte[] bytes( Object obj ) {
- if ( obj == null ) {
- return new byte[0];
- }
- else if ( obj instanceof byte[] ) {
- return ( byte[] ) obj;
- }
- else if ( obj instanceof Long ) {
- return bytes( ( Long ) obj );
- }
- else if ( obj instanceof String ) {
- return bytes( ( String ) obj );
- }
- else if ( obj instanceof UUID ) {
- return bytes( ( UUID ) obj );
- }
- else if ( obj instanceof Boolean ) {
- return bytes( ( Boolean ) obj );
- }
- else if ( obj instanceof Date ) {
- return bytes( ( ( Date ) obj ).getTime() );
- }
- else {
- return bytes( obj.toString() );
- }
- }
-
-
- public static ByteBuffer bytebuffer( byte[] bytes ) {
- return ByteBuffer.wrap( bytes );
- }
-
-
- public static ByteBuffer bytebuffer( ByteBuffer bytes ) {
- return bytes.duplicate();
- }
-
-
- public static ByteBuffer bytebuffer( Object obj ) {
- if ( obj instanceof ByteBuffer ) {
- return ( ( ByteBuffer ) obj ).duplicate();
- }
- return ByteBuffer.wrap( bytes( obj ) );
- }
-
-
- public static List<ByteBuffer> bytebuffers( List<?> l ) {
- List<ByteBuffer> results = new ArrayList<ByteBuffer>( l.size() );
- for ( Object o : l ) {
- results.add( bytebuffer( o ) );
- }
- return results;
- }
-
-
- /**
- * @param bytes
- * @return
- */
- public static boolean getBoolean( byte[] bytes ) {
- return bytes[0] != 0;
- }
-
-
- public static boolean getBoolean( ByteBuffer bytes ) {
- return bytes.slice().get() != 0;
- }
-
-
- /**
- * @param bytes
- * @param offset
- * @return
- */
- public static boolean getBoolean( byte[] bytes, int offset ) {
- return bytes[offset] != 0;
- }
-
-
- public static boolean getBoolean( Object obj ) {
- if ( obj instanceof Boolean ) {
- return ( Boolean ) obj;
- }
- else if ( obj instanceof String ) {
- return Boolean.parseBoolean( ( String ) obj );
- }
- else if ( obj instanceof Number ) {
- return ( ( Number ) obj ).longValue() > 0;
- }
-
- return false;
- }
-
-
- /**
- * @param obj
- * @return
- */
- public static String string( Object obj ) {
- if ( obj instanceof String ) {
- return ( String ) obj;
- }
- else if ( obj instanceof byte[] ) {
- return string( ( byte[] ) obj );
- }
- else if ( obj instanceof ByteBuffer ) {
- return string( ( ByteBuffer ) obj );
- }
- else if ( obj != null ) {
- return obj.toString();
- }
- return null;
- }
-
-
- /**
- * @param bytes
- * @return
- */
- public static String string( byte[] bytes ) {
- if ( bytes == null ) {
- return null;
- }
- return string( bytes, 0, bytes.length, UTF8_ENCODING );
- }
-
-
- public static String string( ByteBuffer bytes ) {
- if ( bytes == null ) {
- return null;
- }
- return string( bytes.array(), bytes.arrayOffset() + bytes.position(), bytes.remaining(), UTF8_ENCODING );
- }
-
-
- /**
- * @param bytes
- * @param offset
- * @param length
- * @return
- */
- public static String string( byte[] bytes, int offset, int length ) {
- return string( bytes, offset, length, UTF8_ENCODING );
- }
-
-
- /**
- * @param bytes
- * @param offset
- * @param length
- * @param encoding
- * @return
- */
- public static String string( byte[] bytes, int offset, int length, String encoding ) {
-
- if ( length <= 0 ) {
- return "";
- }
-
- if ( bytes == null ) {
- return "";
- }
-
- try {
- return new String( bytes, offset, length, encoding );
- }
- catch ( UnsupportedEncodingException e ) {
- // logger.log(Level.SEVERE, "UnsupportedEncodingException ", e);
- throw new RuntimeException( e );
- }
- }
-
-
- public static <T> List<String> strings( Collection<T> items ) {
- List<String> strings = new ArrayList<String>();
- for ( T item : items ) {
- strings.add( string( item ) );
- }
- return strings;
- }
-
-
- /**
- * @param bytes
- * @param offset
- * @return
- */
- public static String stringFromLong( byte[] bytes, int offset ) {
- if ( bytes.length == 0 ) {
- return "";
- }
- if ( ( bytes.length - offset ) < 8 ) {
- throw new IllegalArgumentException( "A long is at least 8 bytes" );
- }
- return String.valueOf( ByteBuffer.wrap( bytes, offset, 8 ).getLong() );
- }
-
-
- /**
- * @param bytes
- * @return
- */
- public static long getLong( byte[] bytes ) {
- return ByteBuffer.wrap( bytes, 0, 8 ).getLong();
- }
-
-
- public static long getLong( ByteBuffer bytes ) {
- return bytes.slice().getLong();
- }
-
-
- public static long getLong( Object obj ) {
- if ( obj instanceof Long ) {
- return ( Long ) obj;
- }
- if ( obj instanceof Number ) {
- return ( ( Number ) obj ).longValue();
- }
- if ( obj instanceof String ) {
- return NumberUtils.toLong( ( String ) obj );
- }
- if ( obj instanceof Date ) {
- return ( ( Date ) obj ).getTime();
- }
- if ( obj instanceof byte[] ) {
- return getLong( ( byte[] ) obj );
- }
- if ( obj instanceof ByteBuffer ) {
- return getLong( ( ByteBuffer ) obj );
- }
- return 0;
- }
-
-
- /**
- * @param bytes
- * @return
- */
- public static int getInt( byte[] bytes ) {
- return ByteBuffer.wrap( bytes, 0, 4 ).getInt();
- }
-
-
- public static int getInt( ByteBuffer bytes ) {
- return bytes.slice().getInt();
- }
-
-
- public static int getInt( Object obj ) {
- if ( obj instanceof Integer ) {
- return ( Integer ) obj;
- }
- if ( obj instanceof Number ) {
- return ( ( Number ) obj ).intValue();
- }
- if ( obj instanceof String ) {
- return NumberUtils.toInt( ( String ) obj );
- }
- if ( obj instanceof Date ) {
- return ( int ) ( ( Date ) obj ).getTime();
- }
- if ( obj instanceof byte[] ) {
- return getInt( ( byte[] ) obj );
- }
- if ( obj instanceof ByteBuffer ) {
- return getInt( ( ByteBuffer ) obj );
- }
- return 0;
- }
-
-
- /**
- * @param bytes
- * @return
- */
- public static float getFloat( byte[] bytes ) {
- return ByteBuffer.wrap( bytes, 0, 4 ).getFloat();
- }
-
-
- public static float getFloat( ByteBuffer bytes ) {
- return bytes.slice().getFloat();
- }
-
-
- public static float getFloat( Object obj ) {
- if ( obj instanceof Float ) {
- return ( Float ) obj;
- }
- if ( obj instanceof Number ) {
- return ( ( Number ) obj ).floatValue();
- }
- if ( obj instanceof String ) {
- return NumberUtils.toFloat( ( String ) obj );
- }
- if ( obj instanceof Date ) {
- return ( ( Date ) obj ).getTime();
- }
- if ( obj instanceof byte[] ) {
- return getFloat( ( byte[] ) obj );
- }
- if ( obj instanceof ByteBuffer ) {
- return getFloat( ( ByteBuffer ) obj );
- }
- return 0;
- }
-
-
- public static double getDouble( byte[] bytes ) {
- return ByteBuffer.wrap( bytes, 0, 8 ).getDouble();
- }
-
-
- public static double getDouble( ByteBuffer bytes ) {
- return bytes.slice().getDouble();
- }
-
-
- public static double getDouble( Object obj ) {
- if ( obj instanceof Double ) {
- return ( Double ) obj;
- }
- if ( obj instanceof Number ) {
- return ( ( Number ) obj ).doubleValue();
- }
- if ( obj instanceof String ) {
- return NumberUtils.toDouble( ( String ) obj );
- }
- if ( obj instanceof Date ) {
- return ( ( Date ) obj ).getTime();
- }
- if ( obj instanceof byte[] ) {
- return getDouble( ( byte[] ) obj );
- }
- if ( obj instanceof ByteBuffer ) {
- return getDouble( ( ByteBuffer ) obj );
- }
- return 0;
- }
-
-
- /**
- * @param type
- * @param bytes
- * @return
- */
- public static Object object( Class<?> type, byte[] bytes ) {
-
- try {
- if ( Long.class.isAssignableFrom( type ) ) {
- return getLong( bytes );
- }
- else if ( UUID.class.isAssignableFrom( type ) ) {
- return uuid( bytes );
- }
- else if ( String.class.isAssignableFrom( type ) ) {
- return string( bytes );
- }
- else if ( Boolean.class.isAssignableFrom( type ) ) {
- return getBoolean( bytes );
- }
- else if ( Integer.class.isAssignableFrom( type ) ) {
- return getInt( bytes );
- }
- else if ( Double.class.isAssignableFrom( type ) ) {
- return getDouble( bytes );
- }
- else if ( Float.class.isAssignableFrom( type ) ) {
- return getFloat( bytes );
- }
- else if ( byte[].class.isAssignableFrom( type ) ) {
- return bytes;
- }
- }
- catch ( Exception e ) {
- logger.error( "Unable to get object from bytes for type " + type.getName(), e );
- }
- return null;
- }
-
-
- public static Object object( Class<?> type, ByteBuffer bytes ) {
-
- try {
- if ( Long.class.isAssignableFrom( type ) ) {
- return bytes.slice().getLong();
- }
- else if ( UUID.class.isAssignableFrom( type ) ) {
- return uuid( bytes );
- }
- else if ( String.class.isAssignableFrom( type ) ) {
- return string( bytes );
- }
- else if ( Boolean.class.isAssignableFrom( type ) ) {
- return bytes.slice().get() != 0;
- }
- else if ( Integer.class.isAssignableFrom( type ) ) {
- return bytes.slice().getInt();
- }
- else if ( Double.class.isAssignableFrom( type ) ) {
- return bytes.slice().getDouble();
- }
- else if ( Float.class.isAssignableFrom( type ) ) {
- return bytes.slice().getFloat();
- }
- else if ( ByteBuffer.class.isAssignableFrom( type ) ) {
- return bytes.duplicate();
- }
- else if ( byte[].class.isAssignableFrom( type ) ) {
- byte[] b = new byte[bytes.remaining()];
- bytes.slice().get( b );
- return b;
- }
- }
- catch ( Exception e ) {
- logger.error( "Unable to get object from bytes for type " + type.getName(), e );
- }
- return null;
- }
-
-
- /**
- * @param bb
- * @param bytes
- * @param len
- * @return
- */
- public static ByteBuffer appendToByteBuffer( ByteBuffer bb, byte[] bytes, int len ) {
- if ( len > bytes.length ) {
- int pos = bb.position();
- bb.put( bytes );
- bb.position( pos + len );
- }
- else {
- bb.put( bytes, 0, len );
- }
- return bb;
- }
-
-
- public static Object coerce( Class<?> type, Object obj ) {
-
- if ( obj == null ) {
- return null;
- }
-
- if ( type == null ) {
- return obj;
- }
-
- try {
- if ( Long.class.isAssignableFrom( type ) ) {
- return getLong( obj );
- }
- else if ( UUID.class.isAssignableFrom( type ) ) {
- return uuid( obj );
- }
- else if ( String.class.isAssignableFrom( type ) ) {
- return string( obj );
- }
- else if ( Boolean.class.isAssignableFrom( type ) ) {
- return getBoolean( obj );
- }
- else if ( Integer.class.isAssignableFrom( type ) ) {
- return getInt( obj );
- }
- else if ( Double.class.isAssignableFrom( type ) ) {
- return getDouble( obj );
- }
- else if ( Float.class.isAssignableFrom( type ) ) {
- return getFloat( obj );
- }
- else if ( byte[].class.isAssignableFrom( type ) ) {
- return bytes( obj );
- }
- else if ( ByteBuffer.class.isAssignableFrom( type ) ) {
- return bytebuffer( obj );
- }
- }
- catch ( Exception e ) {
- logger.error( "Unable to get object from bytes for type " + type.getName(), e );
- }
- return null;
- }
-
-
- public static Map<String, Object> coerceMap( Map<String, Class<?>> types, Map<String, Object> values ) {
- for ( Map.Entry<String, Object> entry : values.entrySet() ) {
- if ( types.containsKey( entry.getKey() ) ) {
- values.put( entry.getKey(), coerce( types.get( entry.getKey() ), entry.getValue() ) );
- }
- }
- return values;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/EntityBuilder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/EntityBuilder.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/EntityBuilder.java
deleted file mode 100644
index c9e1c84..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/EntityBuilder.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-
-package org.apache.usergrid.utils;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.field.BooleanField;
-import org.apache.usergrid.persistence.model.field.DoubleField;
-import org.apache.usergrid.persistence.model.field.EntityObjectField;
-import org.apache.usergrid.persistence.model.field.Field;
-import org.apache.usergrid.persistence.model.field.FloatField;
-import org.apache.usergrid.persistence.model.field.IntegerField;
-import org.apache.usergrid.persistence.model.field.ListField;
-import org.apache.usergrid.persistence.model.field.LocationField;
-import org.apache.usergrid.persistence.model.field.LongField;
-import org.apache.usergrid.persistence.model.field.StringField;
-import org.apache.usergrid.persistence.model.field.value.Location;
-
-
-public class EntityBuilder {
-
- public static Entity fromMap( String scope, Map<String, Object> item ) {
- return fromMap( scope, null, item );
- }
-
- public static Entity fromMap( String scope, Entity entity, Map<String, Object> map ) {
-
- if ( entity == null ) {
- entity = new Entity();
- }
-
- for ( String fieldName : map.keySet() ) {
-
- Object value = map.get( fieldName );
-
- if ( value instanceof String ) {
- entity.setField( new StringField( fieldName, (String)value ));
-
- } else if ( value instanceof Boolean ) {
- entity.setField( new BooleanField( fieldName, (Boolean)value ));
-
- } else if ( value instanceof Integer ) {
- entity.setField( new IntegerField( fieldName, (Integer)value ));
-
- } else if ( value instanceof Double ) {
- entity.setField( new DoubleField( fieldName, (Double)value ));
-
- } else if ( value instanceof Float ) {
- entity.setField( new FloatField( fieldName, (Float)value ));
-
- } else if ( value instanceof Long ) {
- entity.setField( new LongField( fieldName, (Long)value ));
-
- } else if ( value instanceof List) {
- entity.setField( listToListField( scope, fieldName, (List)value ));
-
- } else if ( value instanceof Map ) {
-
- Field field = null;
-
- // is the map really a location element?
- Map<String, Object> m = (Map<String, Object>)value;
- if ( m.size() == 2) {
- Double lat = null;
- Double lon = null;
- try {
- if ( m.get("latitude") != null && m.get("longitude") != null ) {
- lat = Double.parseDouble( m.get("latitude").toString() );
- lon = Double.parseDouble( m.get("longitude").toString() );
-
- } else if ( m.get("lat") != null && m.get("lon") != null ) {
- lat = Double.parseDouble( m.get("lat").toString() );
- lon = Double.parseDouble( m.get("lon").toString() );
- }
- } catch ( NumberFormatException ignored ) {}
-
- if ( lat != null && lon != null ) {
- field = new LocationField( fieldName, new Location( lat, lon ));
- }
- }
-
- if ( field == null ) {
-
- // not a location element, process it as map
- entity.setField( new EntityObjectField( fieldName,
- fromMap( scope, (Map<String, Object>)value ))); // recursion
-
- } else {
- entity.setField( field );
- }
-
- } else {
- throw new RuntimeException("Unknown type " + value.getClass().getName());
- }
- }
-
- return entity;
- }
-
-
- private static ListField listToListField( String scope, String fieldName, List list ) {
-
- if (list.isEmpty()) {
- return new ListField( fieldName );
- }
-
- Object sample = list.get(0);
-
- if ( sample instanceof Map ) {
- return new ListField<Entity>( fieldName, processListForField( scope, list ));
-
- } else if ( sample instanceof List ) {
- return new ListField<List>( fieldName, processListForField( scope, list ));
-
- } else if ( sample instanceof String ) {
- return new ListField<String>( fieldName, (List<String>)list );
-
- } else if ( sample instanceof Boolean ) {
- return new ListField<Boolean>( fieldName, (List<Boolean>)list );
-
- } else if ( sample instanceof Integer ) {
- return new ListField<Integer>( fieldName, (List<Integer>)list );
-
- } else if ( sample instanceof Double ) {
- return new ListField<Double>( fieldName, (List<Double>)list );
-
- } else if ( sample instanceof Long ) {
- return new ListField<Long>( fieldName, (List<Long>)list );
-
- } else {
- throw new RuntimeException("Unknown type " + sample.getClass().getName());
- }
- }
-
-
- private static List processListForField( String scope, List list ) {
- if ( list.isEmpty() ) {
- return list;
- }
- Object sample = list.get(0);
-
- if ( sample instanceof Map ) {
- List<Entity> newList = new ArrayList<Entity>();
- for ( Map<String, Object> map : (List<Map<String, Object>>)list ) {
- newList.add( fromMap( scope, map ) );
- }
- return newList;
-
- } else if ( sample instanceof List ) {
- return processListForField( scope, list ); // recursion
-
- } else {
- return list;
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/JsonUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/JsonUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/JsonUtils.java
deleted file mode 100644
index 4b3e40d..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/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.utils;
-
-
-import java.io.File;
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.usergrid.persistence.exceptions.JsonReadException;
-import org.apache.usergrid.persistence.exceptions.JsonWriteException;
-//import org.apache.usergrid.persistence.Entity;
-
-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;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.commons.lang.StringUtils.substringAfter;
-
-import static org.apache.usergrid.utils.StringUtils.stringOrSubstringBeforeFirst;
-
-
-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().set( Feature.INDENT_OUTPUT, true );
- }
-
-
- /** 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;
- }
-}
[31/50] [abbrv] git commit: Merge pull request #78 from r3b/DPS-846
Posted by sn...@apache.org.
Merge pull request #78 from r3b/DPS-846
Dps 846
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/3f93ca70
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/3f93ca70
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/3f93ca70
Branch: refs/heads/asyncqueue
Commit: 3f93ca70776988a4da4f276fc796431960677432
Parents: 0ed192f e925cc2
Author: Rod Simpson <ro...@rodsimpson.com>
Authored: Fri Mar 21 07:29:25 2014 -0600
Committer: Rod Simpson <ro...@rodsimpson.com>
Committed: Fri Mar 21 07:29:25 2014 -0600
----------------------------------------------------------------------
sdks/html5-javascript/README.md | 206 +++++++++++++++++++++++++++-----
sdks/html5-javascript/changelog.md | 10 +-
2 files changed, 181 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
[35/50] [abbrv] git commit: Update README.md
Posted by sn...@apache.org.
Update README.md
Adding link to the website
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/268250ee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/268250ee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/268250ee
Branch: refs/heads/asyncqueue
Commit: 268250ee7690ec1539b7eff15425bea30e31e7db
Parents: 3ccd913
Author: Dave Johnson <da...@rollerweblogger.org>
Authored: Sun Mar 23 18:05:17 2014 -0400
Committer: Dave Johnson <da...@rollerweblogger.org>
Committed: Sun Mar 23 18:05:17 2014 -0400
----------------------------------------------------------------------
README.md | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/268250ee/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 533f593..079ad0c 100644
--- a/README.md
+++ b/README.md
@@ -11,3 +11,7 @@ This repository contains all the code for Apache Usergrid, including the server
* SDKs for [iOS](sdks/ios), [Android](sdks/android), [HTML5/JavaScript](sdks/html5-javascript), [node.js](sdks/nodejs), [Ruby on Rails](ruby-on-rails), [pure Ruby](sdks/ruby), [PHP](sdks/php), (server-side) [Java](sdks/java) and [.Net / Windows](sdks/dotnet), located in their respective subdirectories under [`/sdks`](sdks).
+For more information
+===
+See the [Apache Usergrid web site](http://usergrid.incubator.apache.org/).
+
[44/50] [abbrv] git commit: Put queryindex classes all under one
top-level "index" package to eliminate conflict with old persistence classes.
Posted by sn...@apache.org.
Put queryindex classes all under one top-level "index" package to eliminate conflict with old persistence classes.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/8f969d8d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/8f969d8d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/8f969d8d
Branch: refs/heads/asyncqueue
Commit: 8f969d8d969a141a5705c141949e4841cfed8293
Parents: 8043bf3
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Mar 26 15:12:04 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Mar 26 15:17:08 2014 -0400
----------------------------------------------------------------------
stack/corepersistence/queryindex/pom.xml | 2 +-
.../persistence/index/query/tree/QueryFilter.g | 311 ++++++
.../index/EntityCollectionIndex.java | 4 +-
.../index/exceptions/IndexException.java | 41 +
.../index/exceptions/JsonReadException.java | 29 +
.../index/exceptions/JsonWriteException.java | 29 +
.../exceptions/NoFullTextIndexException.java | 52 +
.../index/exceptions/NoIndexException.java | 50 +
.../index/exceptions/PersistenceException.java | 47 +
.../index/exceptions/QueryException.java | 41 +
.../index/exceptions/QueryParseException.java | 65 ++
.../index/exceptions/QueryTokenException.java | 54 +
.../index/impl/EsEntityCollectionIndex.java | 6 +-
.../persistence/index/impl/EsQueryVistor.java | 28 +-
.../index/legacy/EntityManagerFacade.java | 8 +-
.../persistence/index/query/EntityRef.java | 30 +
.../usergrid/persistence/index/query/Query.java | 1015 ++++++++++++++++++
.../persistence/index/query/Results.java | 126 +++
.../index/query/SimpleEntityRef.java | 131 +++
.../index/query/tree/AndOperand.java | 50 +
.../index/query/tree/BooleanLiteral.java | 50 +
.../index/query/tree/BooleanOperand.java | 50 +
.../index/query/tree/ContainsOperand.java | 71 ++
.../index/query/tree/ContainsProperty.java | 59 +
.../persistence/index/query/tree/Equal.java | 54 +
.../index/query/tree/EqualityOperand.java | 90 ++
.../index/query/tree/FloatLiteral.java | 59 +
.../index/query/tree/GreaterThan.java | 55 +
.../index/query/tree/GreaterThanEqual.java | 59 +
.../persistence/index/query/tree/LessThan.java | 55 +
.../index/query/tree/LessThanEqual.java | 57 +
.../persistence/index/query/tree/Literal.java | 41 +
.../index/query/tree/LiteralFactory.java | 61 ++
.../index/query/tree/LongLiteral.java | 67 ++
.../index/query/tree/NotOperand.java | 45 +
.../index/query/tree/NumericLiteral.java | 27 +
.../persistence/index/query/tree/Operand.java | 50 +
.../persistence/index/query/tree/OrOperand.java | 56 +
.../persistence/index/query/tree/Property.java | 65 ++
.../index/query/tree/QueryVisitor.java | 102 ++
.../index/query/tree/StringLiteral.java | 85 ++
.../index/query/tree/UUIDLiteral.java | 52 +
.../index/query/tree/WithinOperand.java | 111 ++
.../index/query/tree/WithinProperty.java | 57 +
.../persistence/index/utils/ClassUtils.java | 58 +
.../index/utils/ConversionUtils.java | 765 +++++++++++++
.../persistence/index/utils/EntityBuilder.java | 177 +++
.../persistence/index/utils/JsonUtils.java | 329 ++++++
.../persistence/index/utils/ListUtils.java | 232 ++++
.../persistence/index/utils/MapUtils.java | 377 +++++++
.../persistence/index/utils/StringUtils.java | 172 +++
.../persistence/index/utils/UUIDUtils.java | 412 +++++++
.../persistence/index/impl/CollectionIT.java | 10 +-
.../index/impl/CorePerformanceIT.java | 4 +-
.../impl/EntityCollectionIndexStressTest.java | 4 +-
.../index/impl/EntityCollectionIndexTest.java | 6 +-
.../usergrid/persistence/index/impl/GeoIT.java | 10 +-
.../persistence/index/impl/IndexIT.java | 6 +-
.../persistence/index/legacy/Application.java | 4 +-
.../index/legacy/CoreApplication.java | 4 +-
.../index/legacy/CoreITSetupImpl.java | 2 +-
.../query/AbstractIteratingQueryIT.java | 2 +
.../query/AllInConnectionNoTypeIT.java | 2 +
.../query/IntersectionUnionPagingIT.java | 2 +
.../usergrid/persistence/query/QueryTest.java | 31 +-
.../persistence/query/tree/GrammarTreeTest.java | 20 +-
.../persistence/query/tree/LongLiteralTest.java | 1 +
.../query/tree/StringLiteralTest.java | 2 +-
68 files changed, 6162 insertions(+), 67 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/pom.xml b/stack/corepersistence/queryindex/pom.xml
index 9b9e67a..a6f8d43 100644
--- a/stack/corepersistence/queryindex/pom.xml
+++ b/stack/corepersistence/queryindex/pom.xml
@@ -12,7 +12,7 @@
<parent>
<artifactId>persistence</artifactId>
<groupId>org.apache.usergrid</groupId>
- <version>1.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<build>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/antlr3/org/apache/usergrid/persistence/index/query/tree/QueryFilter.g
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/antlr3/org/apache/usergrid/persistence/index/query/tree/QueryFilter.g b/stack/corepersistence/queryindex/src/main/antlr3/org/apache/usergrid/persistence/index/query/tree/QueryFilter.g
new file mode 100644
index 0000000..d8a5f8b
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/antlr3/org/apache/usergrid/persistence/index/query/tree/QueryFilter.g
@@ -0,0 +1,311 @@
+grammar QueryFilter;
+//NOTES: '^' denotes operator, all others in the string become operands
+
+options {
+ output=AST;
+// ASTLabelType=CommonTree;
+}
+
+@rulecatch { }
+
+
+@header {
+package org.apache.usergrid.persistence.index.query.tree;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.query.Query.SortPredicate;
+
+}
+
+
+@members {
+ Query query = new Query();
+
+ private static final Logger logger = LoggerFactory
+ .getLogger(QueryFilterLexer.class);
+
+ @Override
+ public void emitErrorMessage(String msg) {
+ logger.info(msg);
+ }
+}
+
+
+@lexer::header {
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.usergrid.persistence.index.exceptions.QueryTokenException;
+
+}
+
+@lexer::members {
+
+
+
+ private static final Logger logger = LoggerFactory
+ .getLogger(QueryFilterLexer.class);
+
+
+
+
+ @Override
+ public void emitErrorMessage(String msg) {
+ logger.info(msg);
+ }
+
+ @Override
+ public void recover(RecognitionException e) {
+ //We don't want to recover, we want to re-throw to the user since they passed us invalid input
+ throw new QueryTokenException(e);
+ }
+
+
+}
+
+//these must come before ID. Otherwise lt, lte, eq, etc will be returned as id tokens
+LT : '<' | 'lt';
+
+LTE : '<=' | 'lte';
+
+EQ : '=' | 'eq';
+
+GT : '>' | 'gt';
+
+GTE : '>=' | 'gte';
+
+
+//keywords before var ids
+BOOLEAN : (TRUE|FALSE);
+
+AND : ('A'|'a')('N'|'n')('D'|'d') | '&&';
+
+OR : ('O'|'o')('R'|'r') | '||' ;
+
+NOT : ('N'|'n')('O'|'o')('T'|'t');
+
+ASC : ('A'|'a')('S'|'s')('C'|'c');
+
+DESC : ('D'|'d')('E'|'e')('S'|'s')('C'|'c');
+
+CONTAINS : ('C'|'c')('O'|'o')('N'|'n')('T'|'t')('A'|'a')('I'|'i')('N'|'n')('S'|'s');
+
+WITHIN : ('W'|'w')('I'|'i')('T'|'t')('H'|'h')('I'|'i')('N'|'n');
+
+OF : ('O'|'o')('F'|'f');
+
+UUID : HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-'
+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-'
+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-'
+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-'
+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+ HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+ ;
+
+//ids and values
+ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'.'|'-')*
+ ;
+
+LONG : ('-')? '0'..'9'+
+ ;
+
+FLOAT
+ : ('-')? ( ('0'..'9')+ '.' ('0'..'9')* EXPONENT?
+ | '.' ('0'..'9')+ EXPONENT?
+ | ('0'..'9')+ EXPONENT)
+ ;
+
+STRING
+ : '\'' ( ESC_SEQ | ~('\\'|'\'') )* '\''
+ ;
+
+
+
+WS : (' ' | '\t' | '\n' | '\r' | '\f')+ {$channel=HIDDEN;};
+
+
+
+
+
+
+
+fragment TRUE : ('T'|'t')('R'|'r')('U'|'u')('E'|'e');
+
+fragment FALSE : ('F'|'f')('A'|'a')('L'|'l')('S'|'s')('E'|'e');
+
+
+fragment
+EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ;
+
+fragment
+HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ;
+
+fragment
+ESC_SEQ
+ : '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
+ | UNICODE_ESC
+ | OCTAL_ESC
+ ;
+
+fragment
+OCTAL_ESC
+ : '\\' ('0'..'3') ('0'..'7') ('0'..'7')
+ | '\\' ('0'..'7') ('0'..'7')
+ | '\\' ('0'..'7')
+ ;
+
+fragment
+UNICODE_ESC
+ : '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
+ ;
+
+
+
+
+//NE : '!=';
+
+
+
+property : ID<Property>;
+
+containsproperty : ID<ContainsProperty>;
+
+withinproperty : ID<WithinProperty>;
+
+booleanliteral: BOOLEAN<BooleanLiteral>;
+
+
+longliteral :
+ LONG<LongLiteral> ;
+
+uuidliteral :
+ UUID<UUIDLiteral>;
+
+stringliteral :
+ STRING<StringLiteral>;
+
+floatliteral :
+ FLOAT<FloatLiteral> ;
+
+//We delegate to each sub class literal so we can get each type
+value :
+ booleanliteral
+ | longliteral
+ | uuidliteral
+ | stringliteral
+ | floatliteral
+ ;
+
+
+
+//Every operand returns with the name of 'op'. This is used because all subtrees require operands,
+//this allows us to link the java code easily by using the same name as a converntion
+
+//begin search expressions
+
+//mathmatical equality operations
+equalityop :
+ property LT<LessThan>^ value
+ |property LTE<LessThanEqual>^ value
+ |property EQ<Equal>^ value
+ |property GT<GreaterThan>^ value
+ |property GTE<GreaterThanEqual>^ value
+ ;
+
+//geo location search
+locationop :
+ withinproperty WITHIN<WithinOperand>^ (floatliteral|longliteral) OF! (floatliteral|longliteral) ','! (floatliteral|longliteral);
+
+//string search
+containsop :
+ containsproperty CONTAINS<ContainsOperand>^ stringliteral;
+
+//
+operation :
+ '('! expression ')'!
+ | equalityop
+ | locationop
+ | containsop
+ ;
+
+//negations of expressions
+notexp :
+//only link if we have the not
+ NOT<NotOperand>^ operation
+ |operation
+ ;
+
+//and expressions contain operands. These should always be closer to the leaves of a tree, it allows
+//for faster result intersection sooner in the query execution
+andexp :
+ notexp (AND<AndOperand>^ notexp )*;
+
+
+//or expression should always be after AND expressions. This will give us a smaller result set to union when evaluating trees
+//also a root level expression
+expression :
+ andexp (OR<OrOperand>^ andexp )*;
+
+
+
+//end expressions
+
+//begin order clauses
+
+//direction for ordering
+direction : (ASC | DESC);
+
+//order clause
+order
+ : (property direction?){
+ String property = $property.text;
+ String direction = $direction.text;
+ query.addSort(new SortPredicate(property, direction));
+
+ };
+
+//end order clauses
+
+//Begin select clauses
+
+select_subject
+ : ID {
+
+ query.addSelect($ID.text);
+
+};
+
+
+
+select_assign
+ : target=ID ':' source=ID {
+
+ query.addSelect($target.text, $source.text);
+
+};
+
+select_expr
+ : ('*' | select_subject (',' select_subject) * | '{' select_assign (',' select_assign) * '}');
+
+//end select clauses
+
+ql returns [Query query]
+ : ('select'! select_expr!)? ('where'!? expression)? ('order by'! order! (','! order!)*)? {
+
+ if($expression.tree instanceof Operand){
+ query.setRootOperand((Operand)$expression.tree);
+ }
+
+ retval.query = query;
+
+
+};
+
+
+
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java
index 7cf318b..f4c04e6 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityCollectionIndex.java
@@ -22,8 +22,8 @@ package org.apache.usergrid.persistence.index;
import java.util.UUID;
import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.query.Query;
-import org.apache.usergrid.persistence.query.Results;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.query.Results;
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/IndexException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/IndexException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/IndexException.java
new file mode 100644
index 0000000..e492759
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/IndexException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.exceptions;
+
+
+public class IndexException extends RuntimeException {
+
+ public IndexException() {
+ super();
+ }
+
+
+ public IndexException( String message, Throwable cause ) {
+ super( message, cause );
+ }
+
+
+ public IndexException( String message ) {
+ super( message );
+ }
+
+
+ public IndexException( Throwable cause ) {
+ super( cause );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/JsonReadException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/JsonReadException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/JsonReadException.java
new file mode 100644
index 0000000..100d7e1
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/JsonReadException.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.exceptions;
+
+
+public class JsonReadException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+
+ public JsonReadException( String msg, Throwable t ) {
+ super( msg, t );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/JsonWriteException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/JsonWriteException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/JsonWriteException.java
new file mode 100644
index 0000000..a222f92
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/JsonWriteException.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.exceptions;
+
+
+public class JsonWriteException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+
+ public JsonWriteException( String msg, Throwable t ) {
+ super( msg, t );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/NoFullTextIndexException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/NoFullTextIndexException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/NoFullTextIndexException.java
new file mode 100644
index 0000000..ef36095
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/NoFullTextIndexException.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.exceptions;
+
+
+/**
+ * Thrown when the user attempts to perform a "contains" operation on a field that isn't full text indexed
+ *
+ * @author tnine
+ */
+public class NoFullTextIndexException extends PersistenceException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ final String entityType;
+ final String propertyName;
+
+
+ public NoFullTextIndexException( String entityType, String propertyName ) {
+ super( "Entity '" + entityType + "' with property named '" + propertyName
+ + "' is not full text indexed. You cannot use the 'contains' operand on this field" );
+ this.entityType = entityType;
+ this.propertyName = propertyName;
+ }
+
+
+ public String getEntityType() {
+ return entityType;
+ }
+
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/NoIndexException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/NoIndexException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/NoIndexException.java
new file mode 100644
index 0000000..ca9f9cb
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/NoIndexException.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed 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.exceptions;
+
+
+/**
+ * Thrown when the user attempts to perform a "contains" operation on a field that isn't full text indexed
+ *
+ * @author tnine
+ */
+public class NoIndexException extends PersistenceException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ final String entityType;
+ final String propertyName;
+
+
+ public NoIndexException( String entityType, String propertyName ) {
+ super( "Entity '" + entityType + "' with property named '" + propertyName
+ + "' is not indexed. You cannot use the this field in queries." );
+ this.entityType = entityType;
+ this.propertyName = propertyName;
+ }
+
+
+ public String getEntityType() {
+ return entityType;
+ }
+
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/PersistenceException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/PersistenceException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/PersistenceException.java
new file mode 100644
index 0000000..2f983b4
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/PersistenceException.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.exceptions;
+
+
+public class PersistenceException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+
+ public PersistenceException() {
+ super();
+ }
+
+
+ public PersistenceException( String message, Throwable cause ) {
+ super( message, cause );
+ }
+
+
+ public PersistenceException( String message ) {
+ super( message );
+ }
+
+
+ public PersistenceException( Throwable cause ) {
+ super( cause );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/QueryException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/QueryException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/QueryException.java
new file mode 100644
index 0000000..a9928ec
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/QueryException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.exceptions;
+
+
+public class QueryException extends RuntimeException {
+
+ public QueryException() {
+ super();
+ }
+
+
+ public QueryException( String message, Throwable cause ) {
+ super( message, cause );
+ }
+
+
+ public QueryException( String message ) {
+ super( message );
+ }
+
+
+ public QueryException( Throwable cause ) {
+ super( cause );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/QueryParseException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/QueryParseException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/QueryParseException.java
new file mode 100644
index 0000000..4e46bc5
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/QueryParseException.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.exceptions;
+
+
+/**
+ * An exception thrown when a query cannot be parsed
+ *
+ * @author tnine
+ */
+public class QueryParseException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+
+ /**
+ *
+ */
+ public QueryParseException() {
+ super();
+ }
+
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public QueryParseException( String arg0, Throwable arg1 ) {
+ super( arg0, arg1 );
+ }
+
+
+ /**
+ * @param arg0
+ */
+ public QueryParseException( String arg0 ) {
+ super( arg0 );
+ }
+
+
+ /**
+ * @param arg0
+ */
+ public QueryParseException( Throwable arg0 ) {
+ super( arg0 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/QueryTokenException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/QueryTokenException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/QueryTokenException.java
new file mode 100644
index 0000000..5bf45d7
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/exceptions/QueryTokenException.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.exceptions;
+
+
+/**
+ * An exception thrown when a query encounters a token it doesn't recognize
+ * @author tnine
+ */
+public class QueryTokenException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+
+
+
+ /**
+ * @param arg0
+ */
+ public QueryTokenException( Throwable arg0 ) {
+ super( arg0 );
+ }
+
+
+ @Override
+ public String getMessage() {
+ //antlr errors or strange. We have to do this, there's no message
+ return getCause().toString();
+ }
+
+
+ @Override
+ public String getLocalizedMessage() {
+ return getMessage();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityCollectionIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityCollectionIndex.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityCollectionIndex.java
index 8e16d88..3c0239c 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityCollectionIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityCollectionIndex.java
@@ -34,7 +34,7 @@ import org.apache.usergrid.persistence.collection.CollectionScope;
import org.apache.usergrid.persistence.collection.EntityCollectionManager;
import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
import org.apache.usergrid.persistence.collection.mvcc.entity.ValidationUtils;
-import org.apache.usergrid.persistence.exceptions.IndexException;
+import org.apache.usergrid.persistence.index.exceptions.IndexException;
import org.apache.usergrid.persistence.index.EntityCollectionIndex;
import org.apache.usergrid.persistence.index.IndexFig;
import org.apache.usergrid.persistence.model.entity.Entity;
@@ -47,8 +47,8 @@ import org.apache.usergrid.persistence.model.field.ListField;
import org.apache.usergrid.persistence.model.field.LocationField;
import org.apache.usergrid.persistence.model.field.SetField;
import org.apache.usergrid.persistence.model.field.StringField;
-import org.apache.usergrid.persistence.query.Query;
-import org.apache.usergrid.persistence.query.Results;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.query.Results;
import org.elasticsearch.action.admin.indices.exists.types.TypesExistsRequest;
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
index 5998bf2..332c47b 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
@@ -21,22 +21,22 @@ package org.apache.usergrid.persistence.index.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
-import org.apache.usergrid.persistence.exceptions.NoFullTextIndexException;
-import org.apache.usergrid.persistence.exceptions.NoIndexException;
-import org.apache.usergrid.persistence.exceptions.PersistenceException;
+import org.apache.usergrid.persistence.index.exceptions.NoFullTextIndexException;
+import org.apache.usergrid.persistence.index.exceptions.NoIndexException;
+import org.apache.usergrid.persistence.index.exceptions.PersistenceException;
import static org.apache.usergrid.persistence.index.impl.EsEntityCollectionIndex.ANALYZED_SUFFIX;
import static org.apache.usergrid.persistence.index.impl.EsEntityCollectionIndex.GEO_SUFFIX;
-import org.apache.usergrid.persistence.query.tree.AndOperand;
-import org.apache.usergrid.persistence.query.tree.ContainsOperand;
-import org.apache.usergrid.persistence.query.tree.Equal;
-import org.apache.usergrid.persistence.query.tree.GreaterThan;
-import org.apache.usergrid.persistence.query.tree.GreaterThanEqual;
-import org.apache.usergrid.persistence.query.tree.LessThan;
-import org.apache.usergrid.persistence.query.tree.LessThanEqual;
-import org.apache.usergrid.persistence.query.tree.NotOperand;
-import org.apache.usergrid.persistence.query.tree.OrOperand;
-import org.apache.usergrid.persistence.query.tree.QueryVisitor;
-import org.apache.usergrid.persistence.query.tree.WithinOperand;
+import org.apache.usergrid.persistence.index.query.tree.AndOperand;
+import org.apache.usergrid.persistence.index.query.tree.ContainsOperand;
+import org.apache.usergrid.persistence.index.query.tree.Equal;
+import org.apache.usergrid.persistence.index.query.tree.GreaterThan;
+import org.apache.usergrid.persistence.index.query.tree.GreaterThanEqual;
+import org.apache.usergrid.persistence.index.query.tree.LessThan;
+import org.apache.usergrid.persistence.index.query.tree.LessThanEqual;
+import org.apache.usergrid.persistence.index.query.tree.NotOperand;
+import org.apache.usergrid.persistence.index.query.tree.OrOperand;
+import org.apache.usergrid.persistence.index.query.tree.QueryVisitor;
+import org.apache.usergrid.persistence.index.query.tree.WithinOperand;
import org.elasticsearch.common.unit.DistanceUnit;
import org.elasticsearch.index.query.FilterBuilder;
import org.elasticsearch.index.query.FilterBuilders;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
index 5e57ace..912978f 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/legacy/EntityManagerFacade.java
@@ -17,7 +17,7 @@
*/
package org.apache.usergrid.persistence.index.legacy;
-import org.apache.usergrid.utils.EntityBuilder;
+import org.apache.usergrid.persistence.index.utils.EntityBuilder;
import java.util.HashMap;
import java.util.Map;
import org.apache.usergrid.persistence.collection.CollectionScope;
@@ -33,9 +33,9 @@ import org.apache.usergrid.persistence.model.field.LocationField;
import org.apache.usergrid.persistence.model.field.LongField;
import org.apache.usergrid.persistence.model.field.value.Location;
import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.apache.usergrid.persistence.query.EntityRef;
-import org.apache.usergrid.persistence.query.Query;
-import org.apache.usergrid.persistence.query.Results;
+import org.apache.usergrid.persistence.index.query.EntityRef;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.query.Results;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/EntityRef.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/EntityRef.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/EntityRef.java
new file mode 100644
index 0000000..2abbbe5
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/EntityRef.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.query;
+
+
+import java.util.UUID;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+
+public interface EntityRef {
+
+ public Id getId();
+
+ public UUID getVersion();
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/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
new file mode 100644
index 0000000..23aad8b
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
@@ -0,0 +1,1015 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.query;
+
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.UUID;
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.CommonTokenStream;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.Token;
+import org.antlr.runtime.TokenRewriteStream;
+import static org.apache.commons.codec.binary.Base64.decodeBase64;
+import org.apache.commons.lang.StringUtils;
+import static org.apache.commons.lang.StringUtils.isBlank;
+import static org.apache.commons.lang.StringUtils.split;
+import org.apache.usergrid.persistence.index.exceptions.PersistenceException;
+import org.apache.usergrid.persistence.index.exceptions.QueryParseException;
+import org.apache.usergrid.persistence.index.impl.EsQueryVistor;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.index.query.tree.AndOperand;
+import org.apache.usergrid.persistence.index.query.tree.ContainsOperand;
+import org.apache.usergrid.persistence.index.query.tree.Equal;
+import org.apache.usergrid.persistence.index.query.tree.EqualityOperand;
+import org.apache.usergrid.persistence.index.query.tree.GreaterThan;
+import org.apache.usergrid.persistence.index.query.tree.GreaterThanEqual;
+import org.apache.usergrid.persistence.index.query.tree.LessThan;
+import org.apache.usergrid.persistence.index.query.tree.LessThanEqual;
+import org.apache.usergrid.persistence.index.query.tree.Operand;
+import org.apache.usergrid.persistence.index.query.tree.QueryFilterLexer;
+import org.apache.usergrid.persistence.index.query.tree.QueryFilterParser;
+import org.apache.usergrid.persistence.index.query.tree.QueryVisitor;
+import static org.apache.usergrid.persistence.index.utils.ClassUtils.cast;
+import org.apache.usergrid.persistence.index.utils.JsonUtils;
+import org.apache.usergrid.persistence.index.utils.ListUtils;
+import static org.apache.usergrid.persistence.index.utils.ListUtils.first;
+import static org.apache.usergrid.persistence.index.utils.ListUtils.firstBoolean;
+import static org.apache.usergrid.persistence.index.utils.ListUtils.firstInteger;
+import static org.apache.usergrid.persistence.index.utils.ListUtils.firstLong;
+import static org.apache.usergrid.persistence.index.utils.ListUtils.firstUuid;
+import static org.apache.usergrid.persistence.index.utils.ListUtils.isEmpty;
+import static org.apache.usergrid.persistence.index.utils.MapUtils.toMapList;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.elasticsearch.index.query.FilterBuilder;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class Query {
+ private static final Logger logger = LoggerFactory.getLogger( Query.class );
+
+ public static final int PAGE_SIZE = 1000;
+
+ public static final int DEFAULT_LIMIT = 10;
+ public static final int MAX_LIMIT = 1000;
+ public static final String PROPERTY_ID = "id";
+
+ private String type;
+ private List<SortPredicate> sortPredicates = new ArrayList<SortPredicate>();
+ private Operand rootOperand;
+ private UUID startResult;
+ private String cursor;
+ private int limit = 0;
+
+ private Map<String, String> selectAssignments = new LinkedHashMap<String, String>();
+ private boolean mergeSelectResults = false;
+ private String connection;
+ private List<String> permissions;
+ private boolean reversed;
+ private boolean reversedSet = false;
+ private Long startTime;
+ private Long finishTime;
+ private boolean pad;
+ private List<Id> identifiers;
+ private String collection;
+ private String ql;
+
+
+ public Query() {
+ }
+
+
+ public Query( Query q ) {
+ if ( q != null ) {
+ type = q.type;
+ sortPredicates = q.sortPredicates != null
+ ? new ArrayList<SortPredicate>( q.sortPredicates ) : null;
+ startResult = q.startResult;
+ cursor = q.cursor;
+ limit = q.limit;
+ selectAssignments = q.selectAssignments != null
+ ? new LinkedHashMap<String, String>( q.selectAssignments ) : null;
+ mergeSelectResults = q.mergeSelectResults;
+ connection = q.connection;
+ permissions = q.permissions != null ? new ArrayList<String>( q.permissions ) : null;
+ reversed = q.reversed;
+ reversedSet = q.reversedSet;
+ startTime = q.startTime;
+ finishTime = q.finishTime;
+ pad = q.pad;
+ rootOperand = q.rootOperand;
+ identifiers = q.identifiers != null ? new ArrayList<Id>( q.identifiers ) : null;
+ collection = q.collection;
+ }
+ }
+
+
+ public QueryBuilder createQueryBuilder() {
+
+ QueryBuilder queryBuilder = null;
+
+ if ( getRootOperand() != null ) {
+ QueryVisitor v = new EsQueryVistor();
+ try {
+ getRootOperand().visit( v );
+
+ } catch ( PersistenceException ex ) {
+ throw new RuntimeException( "Error building ElasticSearch query", ex );
+ }
+ queryBuilder = v.getQueryBuilder();
+ }
+
+ if ( queryBuilder == null ) {
+ queryBuilder = QueryBuilders.matchAllQuery();
+ }
+
+ return queryBuilder;
+ }
+
+
+ public FilterBuilder createFilterBuilder() {
+ FilterBuilder filterBuilder = null;
+
+ if ( getRootOperand() != null ) {
+ QueryVisitor v = new EsQueryVistor();
+ try {
+ getRootOperand().visit( v );
+
+ } catch ( PersistenceException ex ) {
+ throw new RuntimeException( "Error building ElasticSearch query", ex );
+ }
+ filterBuilder = v.getFilterBuilder();
+ }
+
+ return filterBuilder;
+ }
+
+
+ public static Query fromQL( String ql ) throws QueryParseException {
+ if ( ql == null ) {
+ return null;
+ }
+ String originalQl = ql;
+ ql = ql.trim();
+
+ String qlt = ql.toLowerCase();
+ if ( !qlt.startsWith( "select" )
+ && !qlt.startsWith( "insert" )
+ && !qlt.startsWith( "update" )
+ && !qlt.startsWith( "delete" ) ) {
+ if ( qlt.startsWith( "order by" ) ) {
+ ql = "select * " + ql;
+ }
+ else {
+ ql = "select * where " + ql;
+ }
+ }
+
+ ANTLRStringStream in = new ANTLRStringStream( ql.trim() );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ CommonTokenStream tokens = new CommonTokenStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+
+ try {
+ Query q = parser.ql().query;
+ q.setQl( originalQl );
+ return q;
+
+ } catch ( RecognitionException e ) {
+ logger.error( "Unable to parse \"{}\"", ql, e );
+ int index = e.index;
+ int lineNumber = e.line;
+ Token token = e.token;
+ String message = String.format("The query cannot be parsed. "
+ + "The token '%s' at column %d on line %d cannot be parsed",
+ token.getText(), index, lineNumber );
+ throw new QueryParseException( message, e );
+ }
+ }
+
+
+ private static Query newQueryIfNull( Query query ) {
+ if ( query == null ) {
+ query = new Query();
+ }
+ return query;
+ }
+
+
+ public static Query fromJsonString( String json ) throws QueryParseException {
+ Object o = JsonUtils.parse( json );
+ if ( o instanceof Map ) {
+ @SuppressWarnings({ "unchecked", "rawtypes" }) Map<String, List<String>> params =
+ cast( toMapList( ( Map ) o ) );
+ return fromQueryParams( params );
+ }
+ return null;
+ }
+
+
+ public static Query fromQueryParams(
+ Map<String, List<String>> params ) throws QueryParseException {
+
+ Query q = null;
+ List<Id> identifiers = null;
+
+ String ql = Query.queryStrFrom( params );
+ String type = first( params.get( "type" ) );
+ Boolean reversed = firstBoolean( params.get( "reversed" ) );
+ String connection = first( params.get( "connection" ) );
+ UUID start = firstUuid( params.get( "start" ) );
+ String cursor = first( params.get( "cursor" ) );
+ Integer limit = firstInteger( params.get( "limit" ) );
+ List<String> permissions = params.get( "permission" );
+ Long startTime = firstLong( params.get( "start_time" ) );
+ Long finishTime = firstLong( params.get( "end_time" ) );
+
+ Boolean pad = firstBoolean( params.get( "pad" ) );
+
+ for ( Entry<String, List<String>> param : params.entrySet() ) {
+ Id identifier = null;
+ if ( ( param.getValue() == null ) || ( param.getValue().size() == 0 ) ) {
+ if ( identifier != null ) {
+ if ( identifiers == null ) {
+ identifiers = new ArrayList<Id>();
+ }
+ identifiers.add( identifier );
+ }
+ }
+ }
+
+ if ( ql != null ) {
+ q = Query.fromQL( decode( ql ) );
+ }
+
+ List<String> l = params.get( "filter" );
+
+ if ( !isEmpty( l ) ) {
+ q = newQueryIfNull( q );
+ for ( String s : l ) {
+ q.addFilter( decode( s ) );
+ }
+ }
+
+ l = params.get( "sort" );
+ if ( !isEmpty( l ) ) {
+ q = newQueryIfNull( q );
+ for ( String s : l ) {
+ q.addSort( decode( s ) );
+ }
+ }
+
+ if ( type != null ) {
+ q = newQueryIfNull( q );
+ q.setEntityType( type );
+ }
+
+ if ( connection != null ) {
+ q = newQueryIfNull( q );
+ q.setConnectionType( connection );
+ }
+
+ if ( permissions != null ) {
+ q = newQueryIfNull( q );
+ q.setPermissions( permissions );
+ }
+
+ if ( start != null ) {
+ q = newQueryIfNull( q );
+ q.setStartResult( start );
+ }
+
+ if ( cursor != null ) {
+ q = newQueryIfNull( q );
+ q.setCursor( cursor );
+ }
+
+ if ( limit != null ) {
+ q = newQueryIfNull( q );
+ q.setLimit( limit );
+ }
+
+ if ( startTime != null ) {
+ q = newQueryIfNull( q );
+ q.setStartTime( startTime );
+ }
+
+ if ( finishTime != null ) {
+ q = newQueryIfNull( q );
+ q.setFinishTime( finishTime );
+ }
+
+ if ( pad != null ) {
+ q = newQueryIfNull( q );
+ q.setPad( pad );
+ }
+
+ if ( identifiers != null ) {
+ q = newQueryIfNull( q );
+ q.setIdentifiers( identifiers );
+ }
+
+ if ( reversed != null ) {
+ q = newQueryIfNull( q );
+ q.setReversed( reversed );
+ }
+
+ return q;
+ }
+
+
+ public static Query searchForProperty( String propertyName, Object propertyValue ) {
+ Query q = new Query();
+ q.addEqualityFilter( propertyName, propertyValue );
+ return q;
+ }
+
+
+ public static Query findForProperty( String propertyName, Object propertyValue ) {
+ Query q = new Query();
+ q.addEqualityFilter( propertyName, propertyValue );
+ q.setLimit( 1 );
+ return q;
+ }
+
+
+ public static Query fromId( Id id ) {
+ Query q = new Query();
+ q.addIdentifier( id );
+ return q;
+ }
+
+ public boolean hasQueryPredicates() {
+ return rootOperand != null;
+ }
+
+ public Query addSort( SortPredicate sort ) {
+ if ( sort == null ) {
+ return this;
+ }
+
+ for ( SortPredicate s : sortPredicates ) {
+ if ( s.getPropertyName().equals( sort.getPropertyName() ) ) {
+ throw new QueryParseException(
+ String.format(
+ "Attempted to set sort order for %s more than once", s.getPropertyName()));
+ }
+ }
+ sortPredicates.add( sort );
+ return this;
+ }
+
+
+ public Query withReversed( boolean reversed ) {
+ setReversed( reversed );
+ return this;
+ }
+
+
+ public String getEntityType() {
+ return type;
+ }
+
+
+ public void setEntityType( String type ) {
+ this.type = type;
+ }
+
+
+ public String getConnectionType() {
+ return connection;
+ }
+
+
+ public void setConnectionType( String connection ) {
+ this.connection = connection;
+ }
+
+
+ public List<String> getPermissions() {
+ return permissions;
+ }
+
+
+ public void setPermissions( List<String> permissions ) {
+ this.permissions = permissions;
+ }
+
+
+ public Query addSelect( String select ) {
+
+ return addSelect( select, null );
+ }
+
+
+ public Query addSelect( String select, String output ) {
+ // be paranoid with the null checks because
+ // the query parser sometimes flakes out
+ if ( select == null ) {
+ return this;
+ }
+ select = select.trim();
+
+ if ( select.equals( "*" ) ) {
+ return this;
+ }
+
+ mergeSelectResults = StringUtils.isNotEmpty( output );
+
+ if ( output == null ) {
+ output = "";
+ }
+
+ selectAssignments.put( select, output );
+
+ return this;
+ }
+
+
+ public boolean hasSelectSubjects() {
+ return !selectAssignments.isEmpty();
+ }
+
+
+ @JsonIgnore
+ public Set<String> getSelectSubjects() {
+ return selectAssignments.keySet();
+ }
+
+
+ public Map<String, String> getSelectAssignments() {
+ return selectAssignments;
+ }
+
+
+ boolean isMergeSelectResults() {
+ return mergeSelectResults;
+ }
+
+
+ public Query addSort( String propertyName ) {
+ if ( isBlank( propertyName ) ) {
+ return this;
+ }
+ propertyName = propertyName.trim();
+ if ( propertyName.indexOf( ',' ) >= 0 ) {
+ String[] propertyNames = split( propertyName, ',' );
+ for ( String s : propertyNames ) {
+ addSort( s );
+ }
+ return this;
+ }
+
+ SortDirection direction = SortDirection.ASCENDING;
+ if ( propertyName.indexOf( ' ' ) >= 0 ) {
+ String[] parts = split( propertyName, ' ' );
+ if ( parts.length > 1 ) {
+ propertyName = parts[0];
+ direction = SortDirection.find( parts[1] );
+ }
+ }
+ else if ( propertyName.startsWith( "-" ) ) {
+ propertyName = propertyName.substring( 1 );
+ direction = SortDirection.DESCENDING;
+ }
+ else if ( propertyName.startsWith( "+" ) ) {
+ propertyName = propertyName.substring( 1 );
+ direction = SortDirection.ASCENDING;
+ }
+
+ return addSort( propertyName, direction );
+ }
+
+
+ public Query addSort( String propertyName, SortDirection direction ) {
+ if ( isBlank( propertyName ) ) {
+ return this;
+ }
+ propertyName = propertyName.trim();
+ for ( SortPredicate s : sortPredicates ) {
+ if ( s.getPropertyName().equals( propertyName ) ) {
+ logger.error(
+ "Attempted to set sort order for " + s.getPropertyName() + " more than once, discarding..." );
+ return this;
+ }
+ }
+ sortPredicates.add( new SortPredicate( propertyName, direction ) );
+ return this;
+ }
+
+
+ @JsonIgnore
+ public boolean isSortSet() {
+ return !sortPredicates.isEmpty();
+ }
+
+
+ public List<SortPredicate> getSortPredicates() {
+ return sortPredicates;
+ }
+
+
+ public Query addFilter( String filter ) {
+
+ ANTLRStringStream in = new ANTLRStringStream( filter );
+ QueryFilterLexer lexer = new QueryFilterLexer( in );
+ TokenRewriteStream tokens = new TokenRewriteStream( lexer );
+ QueryFilterParser parser = new QueryFilterParser( tokens );
+ Operand root = null;
+
+ try {
+ root = parser.ql().query.getRootOperand();
+ }
+ catch ( RecognitionException e ) {
+ // TODO: should we create a specific Exception for this? checked?
+ throw new RuntimeException( "Unknown operation: " + filter, e );
+ }
+
+ if ( root != null ) {
+ addClause( root );
+ }
+
+ return this;
+ }
+
+
+ /** Add a less than filter to this query. && with existing clauses */
+ public Query addLessThanFilter( String propName, Object value ) {
+ LessThan equality = new LessThan( null );
+
+ addClause( equality, propName, value );
+
+ return this;
+ }
+
+
+ /** Add a less than equal filter to this query. && with existing clauses */
+ public Query addLessThanEqualFilter( String propName, Object value ) {
+ LessThanEqual equality = new LessThanEqual( null );
+
+ addClause( equality, propName, value );
+
+ return this;
+ }
+
+
+ /** Add a equal filter to this query. && with existing clauses */
+ public Query addEqualityFilter( String propName, Object value ) {
+ Equal equality = new Equal( new ClassicToken( 0, "=" ) );
+
+ addClause( equality, propName, value );
+
+ return this;
+ }
+
+
+ /** Add a greater than equal filter to this query. && with existing clauses */
+ public Query addGreaterThanEqualFilter( String propName, Object value ) {
+ GreaterThanEqual equality = new GreaterThanEqual( null );
+
+ addClause( equality, propName, value );
+
+ return this;
+ }
+
+
+ /** Add a less than filter to this query. && with existing clauses */
+ public Query addGreaterThanFilter( String propName, Object value ) {
+ GreaterThan equality = new GreaterThan( null );
+
+ addClause( equality, propName, value );
+
+ return this;
+ }
+
+
+ public Query addContainsFilter( String propName, String keyword ) {
+ ContainsOperand equality = new ContainsOperand( new ClassicToken( 0, "contains" ) );
+
+ equality.setProperty( propName );
+ equality.setLiteral( keyword );
+
+ addClause( equality );
+
+ return this;
+ }
+
+
+ private void addClause( EqualityOperand equals, String propertyName, Object value ) {
+ equals.setProperty( propertyName );
+ equals.setLiteral( value );
+ addClause( equals );
+ }
+
+
+ private void addClause( Operand equals ) {
+
+ if ( rootOperand == null ) {
+ rootOperand = equals;
+ return;
+ }
+
+ AndOperand and = new AndOperand();
+ and.addChild( rootOperand );
+ and.addChild( equals );
+
+ // redirect the root to new && clause
+ rootOperand = and;
+ }
+
+
+ @JsonIgnore
+ public Operand getRootOperand() {
+ if ( rootOperand == null ) { // attempt deserialization
+ if ( ql != null ) {
+ try {
+ Query q = Query.fromQL( ql );
+ rootOperand = q.rootOperand;
+ }
+ catch ( QueryParseException e ) {
+ logger.error( "error parsing sql for rootOperand", e ); // shouldn't happen
+ }
+ }
+ }
+ return rootOperand;
+ }
+
+
+ public void setRootOperand( Operand root ) {
+ this.rootOperand = root;
+ }
+
+
+ void setStartResult( UUID startResult ) {
+ this.startResult = startResult;
+ }
+
+
+ public Query withStartResult( UUID startResult ) {
+ this.startResult = startResult;
+ return this;
+ }
+
+
+ public UUID getStartResult() {
+ if ( ( startResult == null ) && ( cursor != null ) ) {
+ byte[] cursorBytes = decodeBase64( cursor );
+ if ( ( cursorBytes != null ) && ( cursorBytes.length == 16 ) ) {
+ startResult = null;
+ }
+ }
+ return startResult;
+ }
+
+
+ public String getCursor() {
+ return cursor;
+ }
+
+
+ public void setCursor( String cursor ) {
+ this.cursor = cursor;
+ }
+
+
+ public Query withCursor( String cursor ) {
+ setCursor( cursor );
+ return this;
+ }
+
+
+ public int getLimit() {
+ return getLimit( DEFAULT_LIMIT );
+ }
+
+
+ public int getLimit( int defaultLimit ) {
+ if ( limit <= 0 ) {
+ if ( defaultLimit > 0 ) {
+ return defaultLimit;
+ }
+ else {
+ return DEFAULT_LIMIT;
+ }
+ }
+ return limit;
+ }
+
+
+ public void setLimit( int limit ) {
+
+ // tnine. After users have had time to change their query limits,
+ // this needs to be uncommented and enforced.
+ // if(limit > MAX_LIMIT){
+ // throw new IllegalArgumentException(String.format("Query limit must be <= to %d", MAX_LIMIT));
+ // }
+
+ if ( limit > MAX_LIMIT ) {
+ limit = MAX_LIMIT;
+ }
+
+ this.limit = limit;
+ }
+
+
+ public Query withLimit( int limit ) {
+ setLimit( limit );
+ return this;
+ }
+
+
+ public boolean isReversed() {
+ return reversed;
+ }
+
+
+ public void setReversed( boolean reversed ) {
+ reversedSet = true;
+ this.reversed = reversed;
+ }
+
+
+ public boolean isReversedSet() {
+ return reversedSet;
+ }
+
+
+ public Long getStartTime() {
+ return startTime;
+ }
+
+
+ public void setStartTime( Long startTime ) {
+ this.startTime = startTime;
+ }
+
+
+ public Long getFinishTime() {
+ return finishTime;
+ }
+
+
+ public void setFinishTime( Long finishTime ) {
+ this.finishTime = finishTime;
+ }
+
+
+ public boolean isPad() {
+ return pad;
+ }
+
+
+ public void setPad( boolean pad ) {
+ this.pad = pad;
+ }
+
+
+ public void addIdentifier( Id id ) {
+ if ( identifiers == null ) {
+ identifiers = new ArrayList<Id>();
+ }
+ identifiers.add( id );
+ }
+
+
+ void setIdentifiers( List<Id> identifiers ) {
+ this.identifiers = identifiers;
+ }
+
+
+ @Override
+ public String toString() {
+ if ( ql != null ) {
+ return ql;
+ }
+ StringBuilder s = new StringBuilder( "select " );
+ if ( selectAssignments.isEmpty() ) {
+ s.append( "*" );
+ }
+ else {
+ if ( mergeSelectResults ) {
+ s.append( "{ " );
+ boolean first = true;
+ for ( Map.Entry<String, String> select : selectAssignments.entrySet() ) {
+ if ( !first ) {
+ s.append( ", " );
+ }
+ s.append( select.getValue() ).append( " : " ).append( select.getKey() );
+ first = false;
+ }
+ s.append( " }" );
+ }
+ else {
+ boolean first = true;
+ for ( String select : selectAssignments.keySet() ) {
+ if ( !first ) {
+ s.append( ", " );
+ }
+ s.append( select );
+ first = false;
+ }
+ }
+ }
+ s.append( " from " );
+ s.append( type );
+ if ( !sortPredicates.isEmpty() ) {
+ boolean first = true;
+ s.append( " order by " );
+ for ( SortPredicate sp : sortPredicates ) {
+ if ( !first ) {
+ s.append( ", " );
+ }
+ s.append( sp );
+ first = false;
+ }
+ }
+ return s.toString();
+ }
+
+
+ public static enum SortDirection {
+ ASCENDING, DESCENDING;
+
+
+ public static SortDirection find( String s ) {
+ if ( s == null ) {
+ return ASCENDING;
+ }
+ s = s.toLowerCase();
+ if ( s.startsWith( "asc" ) ) {
+ return ASCENDING;
+ }
+ if ( s.startsWith( "des" ) ) {
+ return DESCENDING;
+ }
+ if ( s.equals( "+" ) ) {
+ return ASCENDING;
+ }
+ if ( s.equals( "-" ) ) {
+ return DESCENDING;
+ }
+ return ASCENDING;
+ }
+ }
+
+
+ public static final class SortPredicate implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private final String propertyName;
+ private final Query.SortDirection direction;
+
+
+ public SortPredicate( String propertyName, Query.SortDirection direction ) {
+ if ( propertyName == null ) {
+ throw new NullPointerException( "Property name was null" );
+ }
+
+ if ( direction == null ) {
+ direction = SortDirection.ASCENDING;
+ }
+
+ this.propertyName = propertyName.trim();
+ this.direction = direction;
+ }
+
+
+ public SortPredicate( String propertyName, String direction ) {
+ this( propertyName, SortDirection.find( direction ) );
+ }
+
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+
+ public Query.SortDirection getDirection() {
+ return direction;
+ }
+
+
+ @Override
+ public boolean equals( Object o ) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( ( o == null ) || ( super.getClass() != o.getClass() ) ) {
+ return false;
+ }
+
+ SortPredicate that = ( SortPredicate ) o;
+
+ if ( direction != that.direction ) {
+ return false;
+ }
+
+ return ( propertyName.equals( that.propertyName ) );
+ }
+
+
+ @Override
+ public int hashCode() {
+ int result = propertyName.hashCode();
+ result = ( 31 * result ) + direction.hashCode();
+ return result;
+ }
+
+
+ @Override
+ public String toString() {
+ return propertyName + ( ( direction == Query.SortDirection.DESCENDING ) ? " DESC" : "" );
+ }
+ }
+
+
+ private static String decode( String input ) {
+ try {
+ return URLDecoder.decode( input, "UTF-8" );
+ }
+ catch ( UnsupportedEncodingException e ) {
+ // shouldn't happen, but just in case
+ throw new RuntimeException( e );
+ }
+ }
+
+
+ // note: very likely to be null
+ public String getCollection() {
+ return collection;
+ }
+
+
+ public void setCollection( String collection ) {
+ this.collection = collection;
+ }
+
+
+ // may be null
+ public String getQl() {
+ return ql;
+ }
+
+
+ public void setQl( String ql ) {
+ this.ql = ql;
+ }
+
+
+ public List<Id> getIdentifiers() {
+ return identifiers;
+ }
+
+
+ public String getConnection() {
+ return connection;
+ }
+
+
+ public String getType() {
+ return type;
+ }
+
+
+ public static final String PARAM_QL = "ql";
+ public static final String PARAM_Q = "q";
+ public static final String PARAM_QUERY = "query";
+
+ public static String queryStrFrom( Map<String, List<String>> params ) {
+ if ( params.containsKey( PARAM_QL ) ) {
+ return ListUtils.first( params.get( PARAM_QL ) );
+ }
+ else if ( params.containsKey( PARAM_Q ) ) {
+ return ListUtils.first( params.get( PARAM_Q ) );
+ }
+ else if ( params.containsKey( PARAM_QUERY ) ) {
+ return ListUtils.first( params.get( PARAM_QUERY ) );
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Results.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Results.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Results.java
new file mode 100644
index 0000000..7be9f28
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Results.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.query;
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import org.apache.usergrid.persistence.collection.EntityCollectionManager;
+import org.apache.usergrid.persistence.index.exceptions.IndexException;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+
+@XmlRootElement
+public class Results implements Iterable<Entity> {
+
+ final List<Id> ids;
+ final Query query;
+ final EntityCollectionManager ecm;
+
+ String cursor = null;
+ List<Entity> entities = null;
+ List<EntityRef> refs = null;
+
+ public Results( EntityCollectionManager ecm, Query query, List<Id> ids ) {
+ this.ecm = ecm;
+ this.query = query;
+ this.ids = ids;
+ }
+
+
+ public boolean hasCursor() {
+ return cursor != null;
+ }
+
+
+ public String getCursor() {
+ return cursor;
+ }
+
+
+ public void setCursor(String cursor) {
+ this.cursor = cursor;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public Query getQuery() {
+ return query;
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<Id> getIds() {
+ return Collections.unmodifiableList( ids );
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ @SuppressWarnings("unchecked")
+ public List<EntityRef> getRefs() {
+ if ( entities == null ) {
+ getEntities();
+ }
+ return Collections.unmodifiableList( refs );
+ }
+
+
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ public List<Entity> getEntities() {
+ if ( entities == null ) {
+ entities = new ArrayList<Entity>();
+ refs = new ArrayList<EntityRef>();
+ for ( Id id : ids ) {
+ Entity entity = ecm.load( id ).toBlockingObservable().last();
+ if (entity == null) {
+ throw new IndexException("Entity id [" + id + "] not found");
+ }
+ entities.add( entity );
+ refs.add( new SimpleEntityRef( entity.getId(), entity.getVersion() ));
+ }
+ }
+ return Collections.unmodifiableList( entities );
+ }
+
+
+ public int size() {
+ return ids.size();
+ }
+
+
+ public boolean isEmpty() {
+ return ids.isEmpty();
+ }
+
+
+ @Override
+ public Iterator<Entity> iterator() {
+ return getEntities().iterator();
+ }
+
+ public void setIds(List<Id> ids) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/SimpleEntityRef.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/SimpleEntityRef.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/SimpleEntityRef.java
new file mode 100644
index 0000000..34cca44
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/SimpleEntityRef.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.query;
+
+
+import java.util.UUID;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+
+public class SimpleEntityRef implements EntityRef {
+
+ private final Id id;
+
+ private final UUID version;
+
+
+ public SimpleEntityRef( Id id, UUID version ) {
+ this.id = id;
+ this.version = version;
+ }
+
+
+ public SimpleEntityRef( EntityRef entityRef ) {
+ this.id = entityRef.getId();
+ this.version = entityRef.getVersion();
+ }
+
+
+ public static EntityRef ref() {
+ return new SimpleEntityRef( null, null );
+ }
+
+ public static EntityRef ref( Id id ) {
+ return new SimpleEntityRef( id, null );
+ }
+
+ public static EntityRef ref( Id id, UUID version ) {
+ return new SimpleEntityRef( id, version );
+ }
+
+
+ public static EntityRef ref( EntityRef ref ) {
+ return new SimpleEntityRef( ref );
+ }
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ( ( id == null ) ? 0 : id.hashCode() );
+ result = prime * result + ( ( version == null ) ? 0 : version.hashCode() );
+ return result;
+ }
+
+
+ @Override
+ public boolean equals( Object obj ) {
+ if ( this == obj ) {
+ return true;
+ }
+ if ( obj == null ) {
+ return false;
+ }
+ if ( getClass() != obj.getClass() ) {
+ return false;
+ }
+ SimpleEntityRef other = ( SimpleEntityRef ) obj;
+ if ( id == null ) {
+ if ( other.id != null ) {
+ return false;
+ }
+ }
+ else if ( !id.equals( other.id ) ) {
+ return false;
+ }
+ if ( version == null ) {
+ if ( other.version != null ) {
+ return false;
+ }
+ }
+ else if ( !version.equals( other.version ) ) {
+ return false;
+ }
+ return true;
+ }
+
+
+ @Override
+ public String toString() {
+ return id.toString() + "|" + version.toString();
+ }
+
+ public static Id getId( EntityRef ref ) {
+ if ( ref == null ) {
+ return null;
+ }
+ return ref.getId();
+ }
+
+
+ public static String getType( EntityRef ref ) {
+ if ( ref == null ) {
+ return null;
+ }
+ return ref.getId().getType();
+ }
+
+ public Id getId() {
+ return id;
+ }
+
+ public UUID getVersion() {
+ return version;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/AndOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/AndOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/AndOperand.java
new file mode 100644
index 0000000..88e1d38
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/AndOperand.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.index.exceptions.PersistenceException;
+
+
+/** @author tnine */
+public class AndOperand extends BooleanOperand {
+
+ public AndOperand() {
+ super( new CommonToken( 0, "and" ) );
+ }
+
+
+ public AndOperand( Token t ) {
+ super( t );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws PersistenceException {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/BooleanLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/BooleanLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/BooleanLiteral.java
new file mode 100644
index 0000000..87adeaf
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/BooleanLiteral.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+
+
+/** @author tnine */
+public class BooleanLiteral extends Literal<Boolean> {
+
+ private boolean value;
+
+
+ /**
+ * @param t
+ */
+ protected BooleanLiteral( Token t ) {
+ super( t );
+ value = Boolean.valueOf( t.getText() );
+ }
+
+
+ /** The boolean literal */
+ public BooleanLiteral( boolean value ) {
+ super( new ClassicToken( 0, String.valueOf( value ) ) );
+ this.value = value;
+ }
+
+
+ public Boolean getValue() {
+ return value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/BooleanOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/BooleanOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/BooleanOperand.java
new file mode 100644
index 0000000..9c5324c
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/BooleanOperand.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.Token;
+
+
+/**
+ * A base class for any equality expression. Expressions must have a property and a value. Examples are >=, >, =, <,
+ * <=,
+ *
+ * @author tnine
+ */
+public abstract class BooleanOperand extends Operand {
+
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public BooleanOperand( Token t ) {
+ super( t );
+ }
+
+
+ public Operand getLeft() {
+ return ( Operand ) this.children.get( 0 );
+ }
+
+
+ public Operand getRight() {
+ return ( Operand ) this.children.get( 1 );
+ }
+}
[39/50] [abbrv] git commit: Merge branch 'master' into two-dot-o
Posted by sn...@apache.org.
Merge branch 'master' into two-dot-o
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/f9d44a91
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/f9d44a91
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/f9d44a91
Branch: refs/heads/asyncqueue
Commit: f9d44a919fd4df70b116ec77eedb5fba7927804d
Parents: aae2a8d cf814a4
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Mar 25 11:45:36 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Mar 25 11:45:36 2014 -0400
----------------------------------------------------------------------
LICENSE | 65 +-
NOTICE | 11 +
README.md | 64 +-
portal/config.js | 11 +-
portal/index-debug.html | 18 +-
portal/index-template.html | 2 +-
portal/index.html | 18 +-
portal/js/app.js | 7 +-
portal/js/global/page-controller.js | 58 +-
portal/js/global/page-title.html | 2 +-
portal/js/global/ug-service.js | 74 +-
portal/js/libs/usergrid-libs.min.js | 22 +-
portal/js/libs/usergrid.sdk.js | 5 +
portal/js/login/forgot-password-controller.js | 1 -
portal/js/login/login-controller.js | 8 +-
portal/js/login/login.html | 6 +
portal/js/menus/appMenu.html | 7 +-
portal/js/menus/menu-directives.js | 1 -
portal/js/org-overview/org-overview.html | 4 +-
portal/js/templates.js | 57 +-
portal/js/usergrid-dev.min.js | 171 +-
portal/js/usergrid.min.js | 12 +-
portal/js/users/users-feed-controller.js | 29 +
portal/js/users/users-feed.html | 27 +
portal/js/users/users.html | 1 +
portal/package.json | 5 +-
portal/phantomjsdriver.log | 3869 ------------------
portal/seleniumLog.txt | 0
portal/tests/unit/sample.spec.js | 3 +-
sdks/html5-javascript/README.md | 206 +-
sdks/html5-javascript/changelog.md | 10 +-
sdks/html5-javascript/lib/Usergrid.js | 13 +-
sdks/html5-javascript/lib/modules/Asset.js | 4 +-
sdks/html5-javascript/lib/modules/Client.js | 74 +-
sdks/html5-javascript/lib/modules/Folder.js | 4 +-
sdks/html5-javascript/package.json | 2 +-
sdks/html5-javascript/tests/mocha/test.js | 25 +
sdks/html5-javascript/usergrid.js | 36 +-
sdks/html5-javascript/usergrid.min.js | 6 +-
sdks/ios/UGAPI/UGActivity.h | 17 +
sdks/ios/UGAPI/UGActivity.m | 17 +
sdks/ios/UGAPI/UGClient.h | 17 +
sdks/ios/UGAPI/UGClient.m | 17 +
sdks/ios/UGAPI/UGClientDelegate.h | 17 +
sdks/ios/UGAPI/UGClientResponse.h | 17 +
sdks/ios/UGAPI/UGClientResponse.m | 17 +
sdks/ios/UGAPI/UGHTTPManager.h | 17 +
sdks/ios/UGAPI/UGHTTPManager.m | 17 +
sdks/ios/UGAPI/UGMultiStepAction.h | 17 +
sdks/ios/UGAPI/UGMultiStepAction.m | 17 +
sdks/ios/UGAPI/UGQuery.h | 17 +
sdks/ios/UGAPI/UGQuery.m | 17 +
sdks/ios/UGAPI/UGUser.h | 17 +
sdks/ios/UGAPI/UGUser.m | 23 +-
sdks/ios/UGAPIApp/UGAPIApp-Prefix.pch | 17 +
sdks/ios/UGAPIApp/UGAppAppDelegate.h | 23 +-
sdks/ios/UGAPIApp/UGAppAppDelegate.m | 23 +-
sdks/ios/UGAPIApp/UGAppViewController.h | 23 +-
sdks/ios/UGAPIApp/UGAppViewController.m | 23 +-
sdks/ios/UGAPIApp/main.m | 23 +-
sdks/ios/UGAPIAppTests/UGAPIAppTests.h | 23 +-
sdks/ios/UGAPIAppTests/UGAPIAppTests.m | 23 +-
.../lib/usergrid_ironhorse/query.rb | 30 +-
.../lib/usergrid_ironhorse/version.rb | 2 +-
.../spec/usergrid_ironhorse/base_spec.rb | 8 +-
sdks/ruby-on-rails/usergrid_ironhorse.gemspec | 4 +-
.../1.5.4/AppleJavaExtensions-1.5.4.jar | Bin 0 -> 23531 bytes
.../1.5.4/AppleJavaExtensions-1.5.4.pom | 9 +
.../maven-metadata-local.xml | 12 +
stack/pom.xml | 5 +-
.../applications/ApplicationResource.java | 1 -
.../main/resources/swagger/applications.json | 16 -
.../src/main/resources/swagger/management.json | 16 -
.../src/main/resources/swagger/resources.json | 16 -
stack/services/pom.xml | 6 +-
.../management/export/ExportServiceImpl.java | 59 +-
.../management/export/S3ExportImpl.java | 10 +-
.../cassandra/ManagementServiceIT.java | 290 +-
.../management/cassandra/MockS3ExportImpl.java | 1 -
79 files changed, 1491 insertions(+), 4371 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f9d44a91/stack/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f9d44a91/stack/rest/src/main/resources/swagger/applications.json
----------------------------------------------------------------------
[50/50] [abbrv] git commit: Ignored test until mockito issues are
resolved
Posted by sn...@apache.org.
Ignored test until mockito issues are resolved
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/289d66c8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/289d66c8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/289d66c8
Branch: refs/heads/asyncqueue
Commit: 289d66c8d0de8d14b3ed60a6b5449bc06320a0bd
Parents: 9caf38b
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Mar 27 15:02:33 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Mar 27 15:02:33 2014 -0700
----------------------------------------------------------------------
.../usergrid/persistence/graph/GraphManagerTimeoutIT.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/289d66c8/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerTimeoutIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerTimeoutIT.java b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerTimeoutIT.java
index 8685b65..148d2a0 100644
--- a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerTimeoutIT.java
+++ b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerTimeoutIT.java
@@ -33,6 +33,7 @@ import org.jukito.JukitoRunner;
import org.jukito.UseModules;
import org.junit.Before;
import org.junit.ClassRule;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -65,12 +66,15 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Matchers.same;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith( JukitoRunner.class )
@UseModules( { TestGraphModule.class } )
+@Ignore("Mockings fail with mutliple threads, need to resolve this before enabling")
//@UseModules( { TestGraphModule.class, GraphManagerIT.InvalidInput.class } )
public class GraphManagerTimeoutIT {
@@ -134,7 +138,7 @@ public class GraphManagerTimeoutIT {
//TODO, T.N. replace this with a different mock, the spies don't work with multi threading like RX
//https://code.google.com/p/mockito/wiki/FAQ#Is_Mockito_thread-safe?
- when( serialization.getEdgesFromSource( scope, search ) ).thenReturn( itr );
+ when( serialization.getEdgesFromSource( same(scope), same(search) ) ).thenReturn( itr );
Observable<Edge> edges = em.loadEdgesFromSource( search );
@@ -179,6 +183,9 @@ public class GraphManagerTimeoutIT {
}
+
+
+
private class MockingIterator<T> implements Iterator<T> {
private final Iterator<T> items;
[47/50] [abbrv] git commit: Put queryindex classes all under one
top-level "index" package to eliminate conflict with old persistence classes.
Posted by sn...@apache.org.
Put queryindex classes all under one top-level "index" package to eliminate conflict with old persistence classes.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/b516f578
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/b516f578
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/b516f578
Branch: refs/heads/asyncqueue
Commit: b516f57899c8a53ddd2f170ca84faf10183b909a
Parents: 8f969d8
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Mar 26 15:12:58 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Mar 26 15:17:20 2014 -0400
----------------------------------------------------------------------
.../persistence/query/tree/QueryFilter.g | 311 ------
.../persistence/exceptions/IndexException.java | 41 -
.../exceptions/JsonReadException.java | 29 -
.../exceptions/JsonWriteException.java | 29 -
.../exceptions/NoFullTextIndexException.java | 52 -
.../exceptions/NoIndexException.java | 50 -
.../exceptions/PersistenceException.java | 47 -
.../persistence/exceptions/QueryException.java | 41 -
.../exceptions/QueryParseException.java | 65 --
.../exceptions/QueryTokenException.java | 54 -
.../usergrid/persistence/query/EntityRef.java | 30 -
.../usergrid/persistence/query/Query.java | 1015 ------------------
.../usergrid/persistence/query/Results.java | 126 ---
.../persistence/query/SimpleEntityRef.java | 131 ---
.../persistence/query/tree/AndOperand.java | 50 -
.../persistence/query/tree/BooleanLiteral.java | 50 -
.../persistence/query/tree/BooleanOperand.java | 50 -
.../persistence/query/tree/ContainsOperand.java | 71 --
.../query/tree/ContainsProperty.java | 59 -
.../usergrid/persistence/query/tree/Equal.java | 54 -
.../persistence/query/tree/EqualityOperand.java | 90 --
.../persistence/query/tree/FloatLiteral.java | 59 -
.../persistence/query/tree/GreaterThan.java | 55 -
.../query/tree/GreaterThanEqual.java | 59 -
.../persistence/query/tree/LessThan.java | 55 -
.../persistence/query/tree/LessThanEqual.java | 57 -
.../persistence/query/tree/Literal.java | 41 -
.../persistence/query/tree/LiteralFactory.java | 61 --
.../persistence/query/tree/LongLiteral.java | 67 --
.../persistence/query/tree/NotOperand.java | 45 -
.../persistence/query/tree/NumericLiteral.java | 27 -
.../persistence/query/tree/Operand.java | 50 -
.../persistence/query/tree/OrOperand.java | 56 -
.../persistence/query/tree/Property.java | 65 --
.../persistence/query/tree/QueryVisitor.java | 102 --
.../persistence/query/tree/StringLiteral.java | 85 --
.../persistence/query/tree/UUIDLiteral.java | 52 -
.../persistence/query/tree/WithinOperand.java | 111 --
.../persistence/query/tree/WithinProperty.java | 57 -
.../org/apache/usergrid/utils/ClassUtils.java | 58 -
.../apache/usergrid/utils/ConversionUtils.java | 765 -------------
.../apache/usergrid/utils/EntityBuilder.java | 177 ---
.../org/apache/usergrid/utils/JsonUtils.java | 329 ------
.../org/apache/usergrid/utils/ListUtils.java | 232 ----
.../org/apache/usergrid/utils/MapUtils.java | 377 -------
.../org/apache/usergrid/utils/StringUtils.java | 172 ---
.../org/apache/usergrid/utils/UUIDUtils.java | 412 -------
47 files changed, 6071 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/antlr3/org/apache/usergrid/persistence/query/tree/QueryFilter.g
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/antlr3/org/apache/usergrid/persistence/query/tree/QueryFilter.g b/stack/corepersistence/queryindex/src/main/antlr3/org/apache/usergrid/persistence/query/tree/QueryFilter.g
deleted file mode 100644
index d39069b..0000000
--- a/stack/corepersistence/queryindex/src/main/antlr3/org/apache/usergrid/persistence/query/tree/QueryFilter.g
+++ /dev/null
@@ -1,311 +0,0 @@
-grammar QueryFilter;
-//NOTES: '^' denotes operator, all others in the string become operands
-
-options {
- output=AST;
-// ASTLabelType=CommonTree;
-}
-
-@rulecatch { }
-
-
-@header {
-package org.apache.usergrid.persistence.query.tree;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.usergrid.persistence.query.Query;
-import org.apache.usergrid.persistence.query.Query.SortPredicate;
-
-}
-
-
-@members {
- Query query = new Query();
-
- private static final Logger logger = LoggerFactory
- .getLogger(QueryFilterLexer.class);
-
- @Override
- public void emitErrorMessage(String msg) {
- logger.info(msg);
- }
-}
-
-
-@lexer::header {
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.usergrid.persistence.exceptions.QueryTokenException;
-
-}
-
-@lexer::members {
-
-
-
- private static final Logger logger = LoggerFactory
- .getLogger(QueryFilterLexer.class);
-
-
-
-
- @Override
- public void emitErrorMessage(String msg) {
- logger.info(msg);
- }
-
- @Override
- public void recover(RecognitionException e) {
- //We don't want to recover, we want to re-throw to the user since they passed us invalid input
- throw new QueryTokenException(e);
- }
-
-
-}
-
-//these must come before ID. Otherwise lt, lte, eq, etc will be returned as id tokens
-LT : '<' | 'lt';
-
-LTE : '<=' | 'lte';
-
-EQ : '=' | 'eq';
-
-GT : '>' | 'gt';
-
-GTE : '>=' | 'gte';
-
-
-//keywords before var ids
-BOOLEAN : (TRUE|FALSE);
-
-AND : ('A'|'a')('N'|'n')('D'|'d') | '&&';
-
-OR : ('O'|'o')('R'|'r') | '||' ;
-
-NOT : ('N'|'n')('O'|'o')('T'|'t');
-
-ASC : ('A'|'a')('S'|'s')('C'|'c');
-
-DESC : ('D'|'d')('E'|'e')('S'|'s')('C'|'c');
-
-CONTAINS : ('C'|'c')('O'|'o')('N'|'n')('T'|'t')('A'|'a')('I'|'i')('N'|'n')('S'|'s');
-
-WITHIN : ('W'|'w')('I'|'i')('T'|'t')('H'|'h')('I'|'i')('N'|'n');
-
-OF : ('O'|'o')('F'|'f');
-
-UUID : HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
- HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-'
- HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-'
- HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-'
- HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT '-'
- HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
- HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
- HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
- ;
-
-//ids and values
-ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'.'|'-')*
- ;
-
-LONG : ('-')? '0'..'9'+
- ;
-
-FLOAT
- : ('-')? ( ('0'..'9')+ '.' ('0'..'9')* EXPONENT?
- | '.' ('0'..'9')+ EXPONENT?
- | ('0'..'9')+ EXPONENT)
- ;
-
-STRING
- : '\'' ( ESC_SEQ | ~('\\'|'\'') )* '\''
- ;
-
-
-
-WS : (' ' | '\t' | '\n' | '\r' | '\f')+ {$channel=HIDDEN;};
-
-
-
-
-
-
-
-fragment TRUE : ('T'|'t')('R'|'r')('U'|'u')('E'|'e');
-
-fragment FALSE : ('F'|'f')('A'|'a')('L'|'l')('S'|'s')('E'|'e');
-
-
-fragment
-EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ;
-
-fragment
-HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ;
-
-fragment
-ESC_SEQ
- : '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
- | UNICODE_ESC
- | OCTAL_ESC
- ;
-
-fragment
-OCTAL_ESC
- : '\\' ('0'..'3') ('0'..'7') ('0'..'7')
- | '\\' ('0'..'7') ('0'..'7')
- | '\\' ('0'..'7')
- ;
-
-fragment
-UNICODE_ESC
- : '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
- ;
-
-
-
-
-//NE : '!=';
-
-
-
-property : ID<Property>;
-
-containsproperty : ID<ContainsProperty>;
-
-withinproperty : ID<WithinProperty>;
-
-booleanliteral: BOOLEAN<BooleanLiteral>;
-
-
-longliteral :
- LONG<LongLiteral> ;
-
-uuidliteral :
- UUID<UUIDLiteral>;
-
-stringliteral :
- STRING<StringLiteral>;
-
-floatliteral :
- FLOAT<FloatLiteral> ;
-
-//We delegate to each sub class literal so we can get each type
-value :
- booleanliteral
- | longliteral
- | uuidliteral
- | stringliteral
- | floatliteral
- ;
-
-
-
-//Every operand returns with the name of 'op'. This is used because all subtrees require operands,
-//this allows us to link the java code easily by using the same name as a converntion
-
-//begin search expressions
-
-//mathmatical equality operations
-equalityop :
- property LT<LessThan>^ value
- |property LTE<LessThanEqual>^ value
- |property EQ<Equal>^ value
- |property GT<GreaterThan>^ value
- |property GTE<GreaterThanEqual>^ value
- ;
-
-//geo location search
-locationop :
- withinproperty WITHIN<WithinOperand>^ (floatliteral|longliteral) OF! (floatliteral|longliteral) ','! (floatliteral|longliteral);
-
-//string search
-containsop :
- containsproperty CONTAINS<ContainsOperand>^ stringliteral;
-
-//
-operation :
- '('! expression ')'!
- | equalityop
- | locationop
- | containsop
- ;
-
-//negations of expressions
-notexp :
-//only link if we have the not
- NOT<NotOperand>^ operation
- |operation
- ;
-
-//and expressions contain operands. These should always be closer to the leaves of a tree, it allows
-//for faster result intersection sooner in the query execution
-andexp :
- notexp (AND<AndOperand>^ notexp )*;
-
-
-//or expression should always be after AND expressions. This will give us a smaller result set to union when evaluating trees
-//also a root level expression
-expression :
- andexp (OR<OrOperand>^ andexp )*;
-
-
-
-//end expressions
-
-//begin order clauses
-
-//direction for ordering
-direction : (ASC | DESC);
-
-//order clause
-order
- : (property direction?){
- String property = $property.text;
- String direction = $direction.text;
- query.addSort(new SortPredicate(property, direction));
-
- };
-
-//end order clauses
-
-//Begin select clauses
-
-select_subject
- : ID {
-
- query.addSelect($ID.text);
-
-};
-
-
-
-select_assign
- : target=ID ':' source=ID {
-
- query.addSelect($target.text, $source.text);
-
-};
-
-select_expr
- : ('*' | select_subject (',' select_subject) * | '{' select_assign (',' select_assign) * '}');
-
-//end select clauses
-
-ql returns [Query query]
- : ('select'! select_expr!)? ('where'!? expression)? ('order by'! order! (','! order!)*)? {
-
- if($expression.tree instanceof Operand){
- query.setRootOperand((Operand)$expression.tree);
- }
-
- retval.query = query;
-
-
-};
-
-
-
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/IndexException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/IndexException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/IndexException.java
deleted file mode 100644
index ab625d2..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/IndexException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.exceptions;
-
-
-public class IndexException extends RuntimeException {
-
- public IndexException() {
- super();
- }
-
-
- public IndexException( String message, Throwable cause ) {
- super( message, cause );
- }
-
-
- public IndexException( String message ) {
- super( message );
- }
-
-
- public IndexException( Throwable cause ) {
- super( cause );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/JsonReadException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/JsonReadException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/JsonReadException.java
deleted file mode 100644
index f060a2f..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/JsonReadException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.exceptions;
-
-
-public class JsonReadException extends RuntimeException {
- private static final long serialVersionUID = 1L;
-
-
- public JsonReadException( String msg, Throwable t ) {
- super( msg, t );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/JsonWriteException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/JsonWriteException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/JsonWriteException.java
deleted file mode 100644
index 20dcacb..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/JsonWriteException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-
-package org.apache.usergrid.persistence.exceptions;
-
-
-public class JsonWriteException extends RuntimeException {
- private static final long serialVersionUID = 1L;
-
-
- public JsonWriteException( String msg, Throwable t ) {
- super( msg, t );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NoFullTextIndexException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NoFullTextIndexException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NoFullTextIndexException.java
deleted file mode 100644
index b4eb0e6..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NoFullTextIndexException.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.exceptions;
-
-
-/**
- * Thrown when the user attempts to perform a "contains" operation on a field that isn't full text indexed
- *
- * @author tnine
- */
-public class NoFullTextIndexException extends PersistenceException {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- final String entityType;
- final String propertyName;
-
-
- public NoFullTextIndexException( String entityType, String propertyName ) {
- super( "Entity '" + entityType + "' with property named '" + propertyName
- + "' is not full text indexed. You cannot use the 'contains' operand on this field" );
- this.entityType = entityType;
- this.propertyName = propertyName;
- }
-
-
- public String getEntityType() {
- return entityType;
- }
-
-
- public String getPropertyName() {
- return propertyName;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NoIndexException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NoIndexException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NoIndexException.java
deleted file mode 100644
index 2ee5107..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/NoIndexException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright 2012 Apigee Corporation
- *
- * Licensed 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.exceptions;
-
-
-/**
- * Thrown when the user attempts to perform a "contains" operation on a field that isn't full text indexed
- *
- * @author tnine
- */
-public class NoIndexException extends PersistenceException {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- final String entityType;
- final String propertyName;
-
-
- public NoIndexException( String entityType, String propertyName ) {
- super( "Entity '" + entityType + "' with property named '" + propertyName
- + "' is not indexed. You cannot use the this field in queries." );
- this.entityType = entityType;
- this.propertyName = propertyName;
- }
-
-
- public String getEntityType() {
- return entityType;
- }
-
-
- public String getPropertyName() {
- return propertyName;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/PersistenceException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/PersistenceException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/PersistenceException.java
deleted file mode 100644
index 6b008e1..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/PersistenceException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.exceptions;
-
-
-public class PersistenceException extends Exception {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
-
- public PersistenceException() {
- super();
- }
-
-
- public PersistenceException( String message, Throwable cause ) {
- super( message, cause );
- }
-
-
- public PersistenceException( String message ) {
- super( message );
- }
-
-
- public PersistenceException( Throwable cause ) {
- super( cause );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryException.java
deleted file mode 100644
index e8f9b43..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.exceptions;
-
-
-public class QueryException extends RuntimeException {
-
- public QueryException() {
- super();
- }
-
-
- public QueryException( String message, Throwable cause ) {
- super( message, cause );
- }
-
-
- public QueryException( String message ) {
- super( message );
- }
-
-
- public QueryException( Throwable cause ) {
- super( cause );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryParseException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryParseException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryParseException.java
deleted file mode 100644
index 3c2524b..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryParseException.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.exceptions;
-
-
-/**
- * An exception thrown when a query cannot be parsed
- *
- * @author tnine
- */
-public class QueryParseException extends RuntimeException {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
-
- /**
- *
- */
- public QueryParseException() {
- super();
- }
-
-
- /**
- * @param arg0
- * @param arg1
- */
- public QueryParseException( String arg0, Throwable arg1 ) {
- super( arg0, arg1 );
- }
-
-
- /**
- * @param arg0
- */
- public QueryParseException( String arg0 ) {
- super( arg0 );
- }
-
-
- /**
- * @param arg0
- */
- public QueryParseException( Throwable arg0 ) {
- super( arg0 );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryTokenException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryTokenException.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryTokenException.java
deleted file mode 100644
index 864dfea..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/exceptions/QueryTokenException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.exceptions;
-
-
-/**
- * An exception thrown when a query encounters a token it doesn't recognize
- * @author tnine
- */
-public class QueryTokenException extends RuntimeException {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
-
-
-
- /**
- * @param arg0
- */
- public QueryTokenException( Throwable arg0 ) {
- super( arg0 );
- }
-
-
- @Override
- public String getMessage() {
- //antlr errors or strange. We have to do this, there's no message
- return getCause().toString();
- }
-
-
- @Override
- public String getLocalizedMessage() {
- return getMessage();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/EntityRef.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/EntityRef.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/EntityRef.java
deleted file mode 100644
index b05b442..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/EntityRef.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.query;
-
-
-import java.util.UUID;
-import org.apache.usergrid.persistence.model.entity.Id;
-
-
-public interface EntityRef {
-
- public Id getId();
-
- public UUID getVersion();
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Query.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Query.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Query.java
deleted file mode 100644
index c82ff3b..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Query.java
+++ /dev/null
@@ -1,1015 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.query;
-
-import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.UUID;
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.ClassicToken;
-import org.antlr.runtime.CommonTokenStream;
-import org.antlr.runtime.RecognitionException;
-import org.antlr.runtime.Token;
-import org.antlr.runtime.TokenRewriteStream;
-import static org.apache.commons.codec.binary.Base64.decodeBase64;
-import org.apache.commons.lang.StringUtils;
-import static org.apache.commons.lang.StringUtils.isBlank;
-import static org.apache.commons.lang.StringUtils.split;
-import org.apache.usergrid.persistence.exceptions.PersistenceException;
-import org.apache.usergrid.persistence.exceptions.QueryParseException;
-import org.apache.usergrid.persistence.index.impl.EsQueryVistor;
-import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.query.tree.AndOperand;
-import org.apache.usergrid.persistence.query.tree.ContainsOperand;
-import org.apache.usergrid.persistence.query.tree.Equal;
-import org.apache.usergrid.persistence.query.tree.EqualityOperand;
-import org.apache.usergrid.persistence.query.tree.GreaterThan;
-import org.apache.usergrid.persistence.query.tree.GreaterThanEqual;
-import org.apache.usergrid.persistence.query.tree.LessThan;
-import org.apache.usergrid.persistence.query.tree.LessThanEqual;
-import org.apache.usergrid.persistence.query.tree.Operand;
-import org.apache.usergrid.persistence.query.tree.QueryFilterLexer;
-import org.apache.usergrid.persistence.query.tree.QueryFilterParser;
-import org.apache.usergrid.persistence.query.tree.QueryVisitor;
-import static org.apache.usergrid.utils.ClassUtils.cast;
-import org.apache.usergrid.utils.JsonUtils;
-import org.apache.usergrid.utils.ListUtils;
-import static org.apache.usergrid.utils.ListUtils.first;
-import static org.apache.usergrid.utils.ListUtils.firstBoolean;
-import static org.apache.usergrid.utils.ListUtils.firstInteger;
-import static org.apache.usergrid.utils.ListUtils.firstLong;
-import static org.apache.usergrid.utils.ListUtils.firstUuid;
-import static org.apache.usergrid.utils.ListUtils.isEmpty;
-import static org.apache.usergrid.utils.MapUtils.toMapList;
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.elasticsearch.index.query.FilterBuilder;
-import org.elasticsearch.index.query.QueryBuilder;
-import org.elasticsearch.index.query.QueryBuilders;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class Query {
- private static final Logger logger = LoggerFactory.getLogger( Query.class );
-
- public static final int PAGE_SIZE = 1000;
-
- public static final int DEFAULT_LIMIT = 10;
- public static final int MAX_LIMIT = 1000;
- public static final String PROPERTY_ID = "id";
-
- private String type;
- private List<SortPredicate> sortPredicates = new ArrayList<SortPredicate>();
- private Operand rootOperand;
- private UUID startResult;
- private String cursor;
- private int limit = 0;
-
- private Map<String, String> selectAssignments = new LinkedHashMap<String, String>();
- private boolean mergeSelectResults = false;
- private String connection;
- private List<String> permissions;
- private boolean reversed;
- private boolean reversedSet = false;
- private Long startTime;
- private Long finishTime;
- private boolean pad;
- private List<Id> identifiers;
- private String collection;
- private String ql;
-
-
- public Query() {
- }
-
-
- public Query( Query q ) {
- if ( q != null ) {
- type = q.type;
- sortPredicates = q.sortPredicates != null
- ? new ArrayList<SortPredicate>( q.sortPredicates ) : null;
- startResult = q.startResult;
- cursor = q.cursor;
- limit = q.limit;
- selectAssignments = q.selectAssignments != null
- ? new LinkedHashMap<String, String>( q.selectAssignments ) : null;
- mergeSelectResults = q.mergeSelectResults;
- connection = q.connection;
- permissions = q.permissions != null ? new ArrayList<String>( q.permissions ) : null;
- reversed = q.reversed;
- reversedSet = q.reversedSet;
- startTime = q.startTime;
- finishTime = q.finishTime;
- pad = q.pad;
- rootOperand = q.rootOperand;
- identifiers = q.identifiers != null ? new ArrayList<Id>( q.identifiers ) : null;
- collection = q.collection;
- }
- }
-
-
- public QueryBuilder createQueryBuilder() {
-
- QueryBuilder queryBuilder = null;
-
- if ( getRootOperand() != null ) {
- QueryVisitor v = new EsQueryVistor();
- try {
- getRootOperand().visit( v );
-
- } catch ( PersistenceException ex ) {
- throw new RuntimeException( "Error building ElasticSearch query", ex );
- }
- queryBuilder = v.getQueryBuilder();
- }
-
- if ( queryBuilder == null ) {
- queryBuilder = QueryBuilders.matchAllQuery();
- }
-
- return queryBuilder;
- }
-
-
- public FilterBuilder createFilterBuilder() {
- FilterBuilder filterBuilder = null;
-
- if ( getRootOperand() != null ) {
- QueryVisitor v = new EsQueryVistor();
- try {
- getRootOperand().visit( v );
-
- } catch ( PersistenceException ex ) {
- throw new RuntimeException( "Error building ElasticSearch query", ex );
- }
- filterBuilder = v.getFilterBuilder();
- }
-
- return filterBuilder;
- }
-
-
- public static Query fromQL( String ql ) throws QueryParseException {
- if ( ql == null ) {
- return null;
- }
- String originalQl = ql;
- ql = ql.trim();
-
- String qlt = ql.toLowerCase();
- if ( !qlt.startsWith( "select" )
- && !qlt.startsWith( "insert" )
- && !qlt.startsWith( "update" )
- && !qlt.startsWith( "delete" ) ) {
- if ( qlt.startsWith( "order by" ) ) {
- ql = "select * " + ql;
- }
- else {
- ql = "select * where " + ql;
- }
- }
-
- ANTLRStringStream in = new ANTLRStringStream( ql.trim() );
- QueryFilterLexer lexer = new QueryFilterLexer( in );
- CommonTokenStream tokens = new CommonTokenStream( lexer );
- QueryFilterParser parser = new QueryFilterParser( tokens );
-
- try {
- Query q = parser.ql().query;
- q.setQl( originalQl );
- return q;
-
- } catch ( RecognitionException e ) {
- logger.error( "Unable to parse \"{}\"", ql, e );
- int index = e.index;
- int lineNumber = e.line;
- Token token = e.token;
- String message = String.format("The query cannot be parsed. "
- + "The token '%s' at column %d on line %d cannot be parsed",
- token.getText(), index, lineNumber );
- throw new QueryParseException( message, e );
- }
- }
-
-
- private static Query newQueryIfNull( Query query ) {
- if ( query == null ) {
- query = new Query();
- }
- return query;
- }
-
-
- public static Query fromJsonString( String json ) throws QueryParseException {
- Object o = JsonUtils.parse( json );
- if ( o instanceof Map ) {
- @SuppressWarnings({ "unchecked", "rawtypes" }) Map<String, List<String>> params =
- cast( toMapList( ( Map ) o ) );
- return fromQueryParams( params );
- }
- return null;
- }
-
-
- public static Query fromQueryParams(
- Map<String, List<String>> params ) throws QueryParseException {
-
- Query q = null;
- List<Id> identifiers = null;
-
- String ql = Query.queryStrFrom( params );
- String type = first( params.get( "type" ) );
- Boolean reversed = firstBoolean( params.get( "reversed" ) );
- String connection = first( params.get( "connection" ) );
- UUID start = firstUuid( params.get( "start" ) );
- String cursor = first( params.get( "cursor" ) );
- Integer limit = firstInteger( params.get( "limit" ) );
- List<String> permissions = params.get( "permission" );
- Long startTime = firstLong( params.get( "start_time" ) );
- Long finishTime = firstLong( params.get( "end_time" ) );
-
- Boolean pad = firstBoolean( params.get( "pad" ) );
-
- for ( Entry<String, List<String>> param : params.entrySet() ) {
- Id identifier = null;
- if ( ( param.getValue() == null ) || ( param.getValue().size() == 0 ) ) {
- if ( identifier != null ) {
- if ( identifiers == null ) {
- identifiers = new ArrayList<Id>();
- }
- identifiers.add( identifier );
- }
- }
- }
-
- if ( ql != null ) {
- q = Query.fromQL( decode( ql ) );
- }
-
- List<String> l = params.get( "filter" );
-
- if ( !isEmpty( l ) ) {
- q = newQueryIfNull( q );
- for ( String s : l ) {
- q.addFilter( decode( s ) );
- }
- }
-
- l = params.get( "sort" );
- if ( !isEmpty( l ) ) {
- q = newQueryIfNull( q );
- for ( String s : l ) {
- q.addSort( decode( s ) );
- }
- }
-
- if ( type != null ) {
- q = newQueryIfNull( q );
- q.setEntityType( type );
- }
-
- if ( connection != null ) {
- q = newQueryIfNull( q );
- q.setConnectionType( connection );
- }
-
- if ( permissions != null ) {
- q = newQueryIfNull( q );
- q.setPermissions( permissions );
- }
-
- if ( start != null ) {
- q = newQueryIfNull( q );
- q.setStartResult( start );
- }
-
- if ( cursor != null ) {
- q = newQueryIfNull( q );
- q.setCursor( cursor );
- }
-
- if ( limit != null ) {
- q = newQueryIfNull( q );
- q.setLimit( limit );
- }
-
- if ( startTime != null ) {
- q = newQueryIfNull( q );
- q.setStartTime( startTime );
- }
-
- if ( finishTime != null ) {
- q = newQueryIfNull( q );
- q.setFinishTime( finishTime );
- }
-
- if ( pad != null ) {
- q = newQueryIfNull( q );
- q.setPad( pad );
- }
-
- if ( identifiers != null ) {
- q = newQueryIfNull( q );
- q.setIdentifiers( identifiers );
- }
-
- if ( reversed != null ) {
- q = newQueryIfNull( q );
- q.setReversed( reversed );
- }
-
- return q;
- }
-
-
- public static Query searchForProperty( String propertyName, Object propertyValue ) {
- Query q = new Query();
- q.addEqualityFilter( propertyName, propertyValue );
- return q;
- }
-
-
- public static Query findForProperty( String propertyName, Object propertyValue ) {
- Query q = new Query();
- q.addEqualityFilter( propertyName, propertyValue );
- q.setLimit( 1 );
- return q;
- }
-
-
- public static Query fromId( Id id ) {
- Query q = new Query();
- q.addIdentifier( id );
- return q;
- }
-
- public boolean hasQueryPredicates() {
- return rootOperand != null;
- }
-
- public Query addSort( SortPredicate sort ) {
- if ( sort == null ) {
- return this;
- }
-
- for ( SortPredicate s : sortPredicates ) {
- if ( s.getPropertyName().equals( sort.getPropertyName() ) ) {
- throw new QueryParseException(
- String.format(
- "Attempted to set sort order for %s more than once", s.getPropertyName()));
- }
- }
- sortPredicates.add( sort );
- return this;
- }
-
-
- public Query withReversed( boolean reversed ) {
- setReversed( reversed );
- return this;
- }
-
-
- public String getEntityType() {
- return type;
- }
-
-
- public void setEntityType( String type ) {
- this.type = type;
- }
-
-
- public String getConnectionType() {
- return connection;
- }
-
-
- public void setConnectionType( String connection ) {
- this.connection = connection;
- }
-
-
- public List<String> getPermissions() {
- return permissions;
- }
-
-
- public void setPermissions( List<String> permissions ) {
- this.permissions = permissions;
- }
-
-
- public Query addSelect( String select ) {
-
- return addSelect( select, null );
- }
-
-
- public Query addSelect( String select, String output ) {
- // be paranoid with the null checks because
- // the query parser sometimes flakes out
- if ( select == null ) {
- return this;
- }
- select = select.trim();
-
- if ( select.equals( "*" ) ) {
- return this;
- }
-
- mergeSelectResults = StringUtils.isNotEmpty( output );
-
- if ( output == null ) {
- output = "";
- }
-
- selectAssignments.put( select, output );
-
- return this;
- }
-
-
- public boolean hasSelectSubjects() {
- return !selectAssignments.isEmpty();
- }
-
-
- @JsonIgnore
- public Set<String> getSelectSubjects() {
- return selectAssignments.keySet();
- }
-
-
- public Map<String, String> getSelectAssignments() {
- return selectAssignments;
- }
-
-
- boolean isMergeSelectResults() {
- return mergeSelectResults;
- }
-
-
- public Query addSort( String propertyName ) {
- if ( isBlank( propertyName ) ) {
- return this;
- }
- propertyName = propertyName.trim();
- if ( propertyName.indexOf( ',' ) >= 0 ) {
- String[] propertyNames = split( propertyName, ',' );
- for ( String s : propertyNames ) {
- addSort( s );
- }
- return this;
- }
-
- SortDirection direction = SortDirection.ASCENDING;
- if ( propertyName.indexOf( ' ' ) >= 0 ) {
- String[] parts = split( propertyName, ' ' );
- if ( parts.length > 1 ) {
- propertyName = parts[0];
- direction = SortDirection.find( parts[1] );
- }
- }
- else if ( propertyName.startsWith( "-" ) ) {
- propertyName = propertyName.substring( 1 );
- direction = SortDirection.DESCENDING;
- }
- else if ( propertyName.startsWith( "+" ) ) {
- propertyName = propertyName.substring( 1 );
- direction = SortDirection.ASCENDING;
- }
-
- return addSort( propertyName, direction );
- }
-
-
- public Query addSort( String propertyName, SortDirection direction ) {
- if ( isBlank( propertyName ) ) {
- return this;
- }
- propertyName = propertyName.trim();
- for ( SortPredicate s : sortPredicates ) {
- if ( s.getPropertyName().equals( propertyName ) ) {
- logger.error(
- "Attempted to set sort order for " + s.getPropertyName() + " more than once, discarding..." );
- return this;
- }
- }
- sortPredicates.add( new SortPredicate( propertyName, direction ) );
- return this;
- }
-
-
- @JsonIgnore
- public boolean isSortSet() {
- return !sortPredicates.isEmpty();
- }
-
-
- public List<SortPredicate> getSortPredicates() {
- return sortPredicates;
- }
-
-
- public Query addFilter( String filter ) {
-
- ANTLRStringStream in = new ANTLRStringStream( filter );
- QueryFilterLexer lexer = new QueryFilterLexer( in );
- TokenRewriteStream tokens = new TokenRewriteStream( lexer );
- QueryFilterParser parser = new QueryFilterParser( tokens );
- Operand root = null;
-
- try {
- root = parser.ql().query.getRootOperand();
- }
- catch ( RecognitionException e ) {
- // TODO: should we create a specific Exception for this? checked?
- throw new RuntimeException( "Unknown operation: " + filter, e );
- }
-
- if ( root != null ) {
- addClause( root );
- }
-
- return this;
- }
-
-
- /** Add a less than filter to this query. && with existing clauses */
- public Query addLessThanFilter( String propName, Object value ) {
- LessThan equality = new LessThan( null );
-
- addClause( equality, propName, value );
-
- return this;
- }
-
-
- /** Add a less than equal filter to this query. && with existing clauses */
- public Query addLessThanEqualFilter( String propName, Object value ) {
- LessThanEqual equality = new LessThanEqual( null );
-
- addClause( equality, propName, value );
-
- return this;
- }
-
-
- /** Add a equal filter to this query. && with existing clauses */
- public Query addEqualityFilter( String propName, Object value ) {
- Equal equality = new Equal( new ClassicToken( 0, "=" ) );
-
- addClause( equality, propName, value );
-
- return this;
- }
-
-
- /** Add a greater than equal filter to this query. && with existing clauses */
- public Query addGreaterThanEqualFilter( String propName, Object value ) {
- GreaterThanEqual equality = new GreaterThanEqual( null );
-
- addClause( equality, propName, value );
-
- return this;
- }
-
-
- /** Add a less than filter to this query. && with existing clauses */
- public Query addGreaterThanFilter( String propName, Object value ) {
- GreaterThan equality = new GreaterThan( null );
-
- addClause( equality, propName, value );
-
- return this;
- }
-
-
- public Query addContainsFilter( String propName, String keyword ) {
- ContainsOperand equality = new ContainsOperand( new ClassicToken( 0, "contains" ) );
-
- equality.setProperty( propName );
- equality.setLiteral( keyword );
-
- addClause( equality );
-
- return this;
- }
-
-
- private void addClause( EqualityOperand equals, String propertyName, Object value ) {
- equals.setProperty( propertyName );
- equals.setLiteral( value );
- addClause( equals );
- }
-
-
- private void addClause( Operand equals ) {
-
- if ( rootOperand == null ) {
- rootOperand = equals;
- return;
- }
-
- AndOperand and = new AndOperand();
- and.addChild( rootOperand );
- and.addChild( equals );
-
- // redirect the root to new && clause
- rootOperand = and;
- }
-
-
- @JsonIgnore
- public Operand getRootOperand() {
- if ( rootOperand == null ) { // attempt deserialization
- if ( ql != null ) {
- try {
- Query q = Query.fromQL( ql );
- rootOperand = q.rootOperand;
- }
- catch ( QueryParseException e ) {
- logger.error( "error parsing sql for rootOperand", e ); // shouldn't happen
- }
- }
- }
- return rootOperand;
- }
-
-
- public void setRootOperand( Operand root ) {
- this.rootOperand = root;
- }
-
-
- void setStartResult( UUID startResult ) {
- this.startResult = startResult;
- }
-
-
- public Query withStartResult( UUID startResult ) {
- this.startResult = startResult;
- return this;
- }
-
-
- public UUID getStartResult() {
- if ( ( startResult == null ) && ( cursor != null ) ) {
- byte[] cursorBytes = decodeBase64( cursor );
- if ( ( cursorBytes != null ) && ( cursorBytes.length == 16 ) ) {
- startResult = null;
- }
- }
- return startResult;
- }
-
-
- public String getCursor() {
- return cursor;
- }
-
-
- public void setCursor( String cursor ) {
- this.cursor = cursor;
- }
-
-
- public Query withCursor( String cursor ) {
- setCursor( cursor );
- return this;
- }
-
-
- public int getLimit() {
- return getLimit( DEFAULT_LIMIT );
- }
-
-
- public int getLimit( int defaultLimit ) {
- if ( limit <= 0 ) {
- if ( defaultLimit > 0 ) {
- return defaultLimit;
- }
- else {
- return DEFAULT_LIMIT;
- }
- }
- return limit;
- }
-
-
- public void setLimit( int limit ) {
-
- // tnine. After users have had time to change their query limits,
- // this needs to be uncommented and enforced.
- // if(limit > MAX_LIMIT){
- // throw new IllegalArgumentException(String.format("Query limit must be <= to %d", MAX_LIMIT));
- // }
-
- if ( limit > MAX_LIMIT ) {
- limit = MAX_LIMIT;
- }
-
- this.limit = limit;
- }
-
-
- public Query withLimit( int limit ) {
- setLimit( limit );
- return this;
- }
-
-
- public boolean isReversed() {
- return reversed;
- }
-
-
- public void setReversed( boolean reversed ) {
- reversedSet = true;
- this.reversed = reversed;
- }
-
-
- public boolean isReversedSet() {
- return reversedSet;
- }
-
-
- public Long getStartTime() {
- return startTime;
- }
-
-
- public void setStartTime( Long startTime ) {
- this.startTime = startTime;
- }
-
-
- public Long getFinishTime() {
- return finishTime;
- }
-
-
- public void setFinishTime( Long finishTime ) {
- this.finishTime = finishTime;
- }
-
-
- public boolean isPad() {
- return pad;
- }
-
-
- public void setPad( boolean pad ) {
- this.pad = pad;
- }
-
-
- public void addIdentifier( Id id ) {
- if ( identifiers == null ) {
- identifiers = new ArrayList<Id>();
- }
- identifiers.add( id );
- }
-
-
- void setIdentifiers( List<Id> identifiers ) {
- this.identifiers = identifiers;
- }
-
-
- @Override
- public String toString() {
- if ( ql != null ) {
- return ql;
- }
- StringBuilder s = new StringBuilder( "select " );
- if ( selectAssignments.isEmpty() ) {
- s.append( "*" );
- }
- else {
- if ( mergeSelectResults ) {
- s.append( "{ " );
- boolean first = true;
- for ( Map.Entry<String, String> select : selectAssignments.entrySet() ) {
- if ( !first ) {
- s.append( ", " );
- }
- s.append( select.getValue() ).append( " : " ).append( select.getKey() );
- first = false;
- }
- s.append( " }" );
- }
- else {
- boolean first = true;
- for ( String select : selectAssignments.keySet() ) {
- if ( !first ) {
- s.append( ", " );
- }
- s.append( select );
- first = false;
- }
- }
- }
- s.append( " from " );
- s.append( type );
- if ( !sortPredicates.isEmpty() ) {
- boolean first = true;
- s.append( " order by " );
- for ( SortPredicate sp : sortPredicates ) {
- if ( !first ) {
- s.append( ", " );
- }
- s.append( sp );
- first = false;
- }
- }
- return s.toString();
- }
-
-
- public static enum SortDirection {
- ASCENDING, DESCENDING;
-
-
- public static SortDirection find( String s ) {
- if ( s == null ) {
- return ASCENDING;
- }
- s = s.toLowerCase();
- if ( s.startsWith( "asc" ) ) {
- return ASCENDING;
- }
- if ( s.startsWith( "des" ) ) {
- return DESCENDING;
- }
- if ( s.equals( "+" ) ) {
- return ASCENDING;
- }
- if ( s.equals( "-" ) ) {
- return DESCENDING;
- }
- return ASCENDING;
- }
- }
-
-
- public static final class SortPredicate implements Serializable {
- private static final long serialVersionUID = 1L;
- private final String propertyName;
- private final Query.SortDirection direction;
-
-
- public SortPredicate( String propertyName, Query.SortDirection direction ) {
- if ( propertyName == null ) {
- throw new NullPointerException( "Property name was null" );
- }
-
- if ( direction == null ) {
- direction = SortDirection.ASCENDING;
- }
-
- this.propertyName = propertyName.trim();
- this.direction = direction;
- }
-
-
- public SortPredicate( String propertyName, String direction ) {
- this( propertyName, SortDirection.find( direction ) );
- }
-
-
- public String getPropertyName() {
- return propertyName;
- }
-
-
- public Query.SortDirection getDirection() {
- return direction;
- }
-
-
- @Override
- public boolean equals( Object o ) {
- if ( this == o ) {
- return true;
- }
- if ( ( o == null ) || ( super.getClass() != o.getClass() ) ) {
- return false;
- }
-
- SortPredicate that = ( SortPredicate ) o;
-
- if ( direction != that.direction ) {
- return false;
- }
-
- return ( propertyName.equals( that.propertyName ) );
- }
-
-
- @Override
- public int hashCode() {
- int result = propertyName.hashCode();
- result = ( 31 * result ) + direction.hashCode();
- return result;
- }
-
-
- @Override
- public String toString() {
- return propertyName + ( ( direction == Query.SortDirection.DESCENDING ) ? " DESC" : "" );
- }
- }
-
-
- private static String decode( String input ) {
- try {
- return URLDecoder.decode( input, "UTF-8" );
- }
- catch ( UnsupportedEncodingException e ) {
- // shouldn't happen, but just in case
- throw new RuntimeException( e );
- }
- }
-
-
- // note: very likely to be null
- public String getCollection() {
- return collection;
- }
-
-
- public void setCollection( String collection ) {
- this.collection = collection;
- }
-
-
- // may be null
- public String getQl() {
- return ql;
- }
-
-
- public void setQl( String ql ) {
- this.ql = ql;
- }
-
-
- public List<Id> getIdentifiers() {
- return identifiers;
- }
-
-
- public String getConnection() {
- return connection;
- }
-
-
- public String getType() {
- return type;
- }
-
-
- public static final String PARAM_QL = "ql";
- public static final String PARAM_Q = "q";
- public static final String PARAM_QUERY = "query";
-
- public static String queryStrFrom( Map<String, List<String>> params ) {
- if ( params.containsKey( PARAM_QL ) ) {
- return ListUtils.first( params.get( PARAM_QL ) );
- }
- else if ( params.containsKey( PARAM_Q ) ) {
- return ListUtils.first( params.get( PARAM_Q ) );
- }
- else if ( params.containsKey( PARAM_QUERY ) ) {
- return ListUtils.first( params.get( PARAM_QUERY ) );
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Results.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Results.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Results.java
deleted file mode 100644
index 2dd3101..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/Results.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.query;
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import org.apache.usergrid.persistence.collection.EntityCollectionManager;
-import org.apache.usergrid.persistence.exceptions.IndexException;
-
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.entity.Id;
-
-
-@XmlRootElement
-public class Results implements Iterable<Entity> {
-
- final List<Id> ids;
- final Query query;
- final EntityCollectionManager ecm;
-
- String cursor = null;
- List<Entity> entities = null;
- List<EntityRef> refs = null;
-
- public Results( EntityCollectionManager ecm, Query query, List<Id> ids ) {
- this.ecm = ecm;
- this.query = query;
- this.ids = ids;
- }
-
-
- public boolean hasCursor() {
- return cursor != null;
- }
-
-
- public String getCursor() {
- return cursor;
- }
-
-
- public void setCursor(String cursor) {
- this.cursor = cursor;
- }
-
-
- @JsonSerialize(include = Inclusion.NON_NULL)
- public Query getQuery() {
- return query;
- }
-
-
- @JsonSerialize(include = Inclusion.NON_NULL)
- public List<Id> getIds() {
- return Collections.unmodifiableList( ids );
- }
-
-
- @JsonSerialize(include = Inclusion.NON_NULL)
- @SuppressWarnings("unchecked")
- public List<EntityRef> getRefs() {
- if ( entities == null ) {
- getEntities();
- }
- return Collections.unmodifiableList( refs );
- }
-
-
- @JsonSerialize(include = Inclusion.NON_NULL)
- public List<Entity> getEntities() {
- if ( entities == null ) {
- entities = new ArrayList<Entity>();
- refs = new ArrayList<EntityRef>();
- for ( Id id : ids ) {
- Entity entity = ecm.load( id ).toBlockingObservable().last();
- if (entity == null) {
- throw new IndexException("Entity id [" + id + "] not found");
- }
- entities.add( entity );
- refs.add( new SimpleEntityRef( entity.getId(), entity.getVersion() ));
- }
- }
- return Collections.unmodifiableList( entities );
- }
-
-
- public int size() {
- return ids.size();
- }
-
-
- public boolean isEmpty() {
- return ids.isEmpty();
- }
-
-
- @Override
- public Iterator<Entity> iterator() {
- return getEntities().iterator();
- }
-
- public void setIds(List<Id> ids) {
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/SimpleEntityRef.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/SimpleEntityRef.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/SimpleEntityRef.java
deleted file mode 100644
index e4cfcf7..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/SimpleEntityRef.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.query;
-
-
-import java.util.UUID;
-import org.apache.usergrid.persistence.model.entity.Id;
-
-
-public class SimpleEntityRef implements EntityRef {
-
- private final Id id;
-
- private final UUID version;
-
-
- public SimpleEntityRef( Id id, UUID version ) {
- this.id = id;
- this.version = version;
- }
-
-
- public SimpleEntityRef( EntityRef entityRef ) {
- this.id = entityRef.getId();
- this.version = entityRef.getVersion();
- }
-
-
- public static EntityRef ref() {
- return new SimpleEntityRef( null, null );
- }
-
- public static EntityRef ref( Id id ) {
- return new SimpleEntityRef( id, null );
- }
-
- public static EntityRef ref( Id id, UUID version ) {
- return new SimpleEntityRef( id, version );
- }
-
-
- public static EntityRef ref( EntityRef ref ) {
- return new SimpleEntityRef( ref );
- }
-
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ( ( id == null ) ? 0 : id.hashCode() );
- result = prime * result + ( ( version == null ) ? 0 : version.hashCode() );
- return result;
- }
-
-
- @Override
- public boolean equals( Object obj ) {
- if ( this == obj ) {
- return true;
- }
- if ( obj == null ) {
- return false;
- }
- if ( getClass() != obj.getClass() ) {
- return false;
- }
- SimpleEntityRef other = ( SimpleEntityRef ) obj;
- if ( id == null ) {
- if ( other.id != null ) {
- return false;
- }
- }
- else if ( !id.equals( other.id ) ) {
- return false;
- }
- if ( version == null ) {
- if ( other.version != null ) {
- return false;
- }
- }
- else if ( !version.equals( other.version ) ) {
- return false;
- }
- return true;
- }
-
-
- @Override
- public String toString() {
- return id.toString() + "|" + version.toString();
- }
-
- public static Id getId( EntityRef ref ) {
- if ( ref == null ) {
- return null;
- }
- return ref.getId();
- }
-
-
- public static String getType( EntityRef ref ) {
- if ( ref == null ) {
- return null;
- }
- return ref.getId().getType();
- }
-
- public Id getId() {
- return id;
- }
-
- public UUID getVersion() {
- return version;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/AndOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/AndOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/AndOperand.java
deleted file mode 100644
index 3377073..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/AndOperand.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.CommonToken;
-import org.antlr.runtime.Token;
-import org.apache.usergrid.persistence.exceptions.PersistenceException;
-
-
-/** @author tnine */
-public class AndOperand extends BooleanOperand {
-
- public AndOperand() {
- super( new CommonToken( 0, "and" ) );
- }
-
-
- public AndOperand( Token t ) {
- super( t );
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
- * .query.tree.QueryVisitor)
- */
- @Override
- public void visit( QueryVisitor visitor ) throws PersistenceException {
- visitor.visit( this );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/BooleanLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/BooleanLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/BooleanLiteral.java
deleted file mode 100644
index b2d4a36..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/BooleanLiteral.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.ClassicToken;
-import org.antlr.runtime.Token;
-
-
-/** @author tnine */
-public class BooleanLiteral extends Literal<Boolean> {
-
- private boolean value;
-
-
- /**
- * @param t
- */
- protected BooleanLiteral( Token t ) {
- super( t );
- value = Boolean.valueOf( t.getText() );
- }
-
-
- /** The boolean literal */
- public BooleanLiteral( boolean value ) {
- super( new ClassicToken( 0, String.valueOf( value ) ) );
- this.value = value;
- }
-
-
- public Boolean getValue() {
- return value;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/BooleanOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/BooleanOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/BooleanOperand.java
deleted file mode 100644
index 84e6951..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/BooleanOperand.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.Token;
-
-
-/**
- * A base class for any equality expression. Expressions must have a property and a value. Examples are >=, >, =, <,
- * <=,
- *
- * @author tnine
- */
-public abstract class BooleanOperand extends Operand {
-
-
- /**
- * @param property
- * @param literal
- */
- public BooleanOperand( Token t ) {
- super( t );
- }
-
-
- public Operand getLeft() {
- return ( Operand ) this.children.get( 0 );
- }
-
-
- public Operand getRight() {
- return ( Operand ) this.children.get( 1 );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/ContainsOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/ContainsOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/ContainsOperand.java
deleted file mode 100644
index f63745b..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/ContainsOperand.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.Token;
-import org.apache.usergrid.persistence.exceptions.PersistenceException;
-
-
-/** @author tnine */
-public class ContainsOperand extends EqualityOperand {
-
- /**
- * @param property
- * @param literal
- */
- public ContainsOperand( Token t ) {
- super( t );
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
- * .query.tree.QueryVisitor)
- */
- @Override
- public void visit( QueryVisitor visitor ) throws PersistenceException {
- visitor.visit( this );
- }
-
-
- public StringLiteral getString() {
- return ( StringLiteral ) getLiteral();
- }
-
-
- /* (non-Javadoc)
- * @see org.apache.usergrid.persistence.query.tree.EqualityOperand#newProperty(java.lang.String)
- */
- @Override
- protected Property newProperty( String name ) {
- return new ContainsProperty( name );
- }
-
-
- /* (non-Javadoc)
- * @see org.apache.usergrid.persistence.query.tree.EqualityOperand#getProperty()
- */
- @Override
- public ContainsProperty getProperty() {
- return ( ContainsProperty ) this.children.get( 0 );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/ContainsProperty.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/ContainsProperty.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/ContainsProperty.java
deleted file mode 100644
index c588c77..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/ContainsProperty.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.ClassicToken;
-import org.antlr.runtime.Token;
-
-
-/**
- * A property for full text searching that requires special renaming
- *
- * @author tnine
- */
-public class ContainsProperty extends Property {
-
- private String indexedName = null;
-
-
- public ContainsProperty( Token t ) {
- super( t );
- this.indexedName = String.format( "%s.keywords", super.getValue() );
- }
-
-
- public ContainsProperty( String property ) {
- this( new ClassicToken( 0, property ) );
- }
-
-
- /* (non-Javadoc)
- * @see org.apache.usergrid.persistence.query.tree.Property#getIndexedValue()
- */
- @Override
- public String getIndexedValue() {
- return this.indexedName;
- }
-
-
- /** @return the property */
- public ContainsProperty getProperty() {
- return ( ContainsProperty ) this.children.get( 0 );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Equal.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Equal.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Equal.java
deleted file mode 100644
index eedfbf0..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/Equal.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.ClassicToken;
-import org.antlr.runtime.Token;
-import org.apache.usergrid.persistence.exceptions.NoIndexException;
-
-
-/** @author tnine */
-public class Equal extends EqualityOperand {
-
- /**
- * @param property
- * @param literal
- */
- public Equal( Token t ) {
- super( t );
- }
-
-
- public Equal() {
- super( new ClassicToken( 0, "=" ) );
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
- * .query.tree.QueryVisitor)
- */
- @Override
- public void visit( QueryVisitor visitor ) throws NoIndexException {
- visitor.visit( this );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/EqualityOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/EqualityOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/EqualityOperand.java
deleted file mode 100644
index 121b1e9..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/query/tree/EqualityOperand.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. 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 additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.query.tree;
-
-
-import org.antlr.runtime.Token;
-
-
-/**
- * A base class for any equality expression. Expressions must have a property and a value. Examples are >=, >, =, <,
- * <=,
- *
- * @author tnine
- */
-public abstract class EqualityOperand extends Operand {
-
- /**
- * @param property
- * @param literal
- */
- public EqualityOperand( Token t ) {
- super( t );
- }
-
-
- public EqualityOperand( String propName, Literal<?> value ) {
- super( null );
- }
-
-
- /** Set the property on this operand */
- public void setProperty( String name ) {
- setAtIndex( 0, newProperty( name ) );
- }
-
-
- /** Get the property to set into the equality. Allows subclasses to override the type */
- protected Property newProperty( String name ) {
- return new Property( name );
- }
-
-
- /** Set the literal on this operand from the given value */
- public void setLiteral( Object value ) {
- setAtIndex( 1, LiteralFactory.getLiteral( value ) );
- }
-
-
- /** Set the child at the specified index. If it doesn't exist, it's added until it does */
- @SuppressWarnings("unchecked")
- private void setAtIndex( int index, Literal<?> value ) {
-
- if ( children == null ) {
- children = createChildrenList();
- }
-
- while ( children.size() - 1 < index ) {
- children.add( null );
- }
-
- setChild( index, value );
- }
-
-
- /** @return the property */
- public Property getProperty() {
- return ( Property ) this.children.get( 0 );
- }
-
-
- /** @return the literal */
- public Literal<?> getLiteral() {
- return ( Literal<?> ) this.children.get( 1 );
- }
-}
[37/50] [abbrv] git commit: Merge pull request #76 from
GERey/Export_Persistance_Integration
Posted by sn...@apache.org.
Merge pull request #76 from GERey/Export_Persistance_Integration
Export persistance integration
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/06f578f5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/06f578f5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/06f578f5
Branch: refs/heads/asyncqueue
Commit: 06f578f5f7d5da05984879eba585111cd6a52d45
Parents: 268250e 5475be2
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Mar 24 13:06:47 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Mar 24 13:06:47 2014 -0700
----------------------------------------------------------------------
.../applications/ApplicationResource.java | 1 -
stack/services/pom.xml | 6 +-
.../management/export/ExportServiceImpl.java | 59 +---
.../management/export/S3ExportImpl.java | 10 +-
.../cassandra/ManagementServiceIT.java | 290 +++++++++++++++++--
.../management/cassandra/MockS3ExportImpl.java | 1 -
6 files changed, 280 insertions(+), 87 deletions(-)
----------------------------------------------------------------------
[05/50] [abbrv] rebuilding artifacts after merge
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13ab2bd2/sdks/html5-javascript/usergrid.min.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/usergrid.min.js b/sdks/html5-javascript/usergrid.min.js
index 4edec05..13b9848 100644
--- a/sdks/html5-javascript/usergrid.min.js
+++ b/sdks/html5-javascript/usergrid.min.js
@@ -1,3 +1,3 @@
-/*! usergrid@0.10.8 2014-03-05 */
-function extend(subClass,superClass){var F=function(){};return F.prototype=superClass.prototype,subClass.prototype=new F,subClass.prototype.constructor=subClass,subClass.superclass=superClass.prototype,superClass.prototype.constructor==Object.prototype.constructor&&(superClass.prototype.constructor=superClass),subClass}function NOOP(){}function isValidUrl(url){if(!url)return!1;var doc,base,anchor,isValid=!1;try{doc=document.implementation.createHTMLDocument(""),base=doc.createElement("base"),base.href=base||window.lo,doc.head.appendChild(base),anchor=doc.createElement("a"),anchor.href=url,doc.body.appendChild(anchor),isValid=!(""===anchor.href)}catch(e){console.error(e)}finally{return doc.head.removeChild(base),doc.body.removeChild(anchor),base=null,anchor=null,doc=null,isValid}}function isUUID(uuid){return uuid?uuidValueRegex.test(uuid):!1}function encodeParams(params){var queryString;return params&&Object.keys(params)&&(queryString=[].slice.call(arguments).reduce(function(a,b){ret
urn a.concat(b instanceof Array?b:[b])},[]).filter(function(c){return"object"==typeof c}).reduce(function(p,c){return c instanceof Array?p.push(c):p=p.concat(Object.keys(c).map(function(key){return[key,c[key]]})),p},[]).reduce(function(p,c){return 2===c.length?p.push(c):p=p.concat(c),p},[]).reduce(function(p,c){return c[1]instanceof Array?c[1].forEach(function(v){p.push([c[0],v])}):p.push(c),p},[]).map(function(c){return c[1]=encodeURIComponent(c[1]),c.join("=")}).join("&")),queryString}function isFunction(f){return f&&null!==f&&"function"==typeof f}function doCallback(callback,params,context){var returnValue;return isFunction(callback)&&(params||(params=[]),context||(context=this),params.push(context),returnValue=callback.apply(context,params)),returnValue}var UsergridEventable=function(){throw Error("'UsergridEventable' is not intended to be invoked directly")};UsergridEventable.prototype={bind:function(event,fn){this._events=this._events||{},this._events[event]=this._events[event
]||[],this._events[event].push(fn)},unbind:function(event,fn){this._events=this._events||{},event in this._events!=!1&&this._events[event].splice(this._events[event].indexOf(fn),1)},trigger:function(event){if(this._events=this._events||{},event in this._events!=!1)for(var i=0;i<this._events[event].length;i++)this._events[event][i].apply(this,Array.prototype.slice.call(arguments,1))}},UsergridEventable.mixin=function(destObject){for(var props=["bind","unbind","trigger"],i=0;i<props.length;i++)props[i]in destObject.prototype&&(console.warn("overwriting '"+props[i]+"' on '"+destObject.name+"'."),console.warn("the previous version can be found at '_"+props[i]+"' on '"+destObject.name+"'."),destObject.prototype["_"+props[i]]=destObject.prototype[props[i]]),destObject.prototype[props[i]]=UsergridEventable.prototype[props[i]]},function(){function Logger(name){this.logEnabled=!0,this.init(name,!0)}var name="Logger",global=this,overwrittenName=global[name];return Logger.METHODS=["log","error
","warn","info","debug","assert","clear","count","dir","dirxml","exception","group","groupCollapsed","groupEnd","profile","profileEnd","table","time","timeEnd","trace"],Logger.prototype.init=function(name,logEnabled){this.name=name||"UNKNOWN",this.logEnabled=logEnabled||!0;var addMethod=function(method){this[method]=this.createLogMethod(method)}.bind(this);Logger.METHODS.forEach(addMethod)},Logger.prototype.createLogMethod=function(method){return Logger.prototype.log.bind(this,method)},Logger.prototype.prefix=function(method,args){var prepend="["+method.toUpperCase()+"]["+name+"]: ";return-1!==["log","error","warn","info"].indexOf(method)&&("string"==typeof args[0]?args[0]=prepend+args[0]:args.unshift(prepend)),args},Logger.prototype.log=function(){var args=[].slice.call(arguments);method=args.shift(),-1===Logger.METHODS.indexOf(method)&&(method="log"),this.logEnabled&&console&&console[method]&&(args=this.prefix(method,args),console[method].apply(console,args))},Logger.prototype.set
LogEnabled=function(logEnabled){this.logEnabled=logEnabled||!0},Logger.mixin=function(destObject){destObject.__logger=new Logger(destObject.name||"UNKNOWN");var addMethod=function(method){method in destObject.prototype&&(console.warn("overwriting '"+method+"' on '"+destObject.name+"'."),console.warn("the previous version can be found at '_"+method+"' on '"+destObject.name+"'."),destObject.prototype["_"+method]=destObject.prototype[method]),destObject.prototype[method]=destObject.__logger.createLogMethod(method)};Logger.METHODS.forEach(addMethod)},global[name]=Logger,global[name].noConflict=function(){return overwrittenName&&(global[name]=overwrittenName),Logger},global[name]}(),function(global){function Promise(){this.complete=!1,this.error=null,this.result=null,this.callbacks=[]}var name="Promise",overwrittenName=global[name];return Promise.prototype.create=function(){return new Promise},Promise.prototype.then=function(callback,context){var f=function(){return callback.apply(contex
t,arguments)};this.complete?f(this.error,this.result):this.callbacks.push(f)},Promise.prototype.done=function(error,result){if(this.complete=!0,this.error=error,this.result=result,this.callbacks){for(var i=0;i<this.callbacks.length;i++)this.callbacks[i](error,result);this.callbacks.length=0}},Promise.join=function(promises){function notifier(i){return function(error,result){completed+=1,errors[i]=error,results[i]=result,completed===total&&p.done(errors,results)}}for(var p=new Promise,total=promises.length,completed=0,errors=[],results=[],i=0;total>i;i++)promises[i]().then(notifier(i));return p},Promise.chain=function(promises,error,result){var p=new Promise;return null===promises||0===promises.length?p.done(error,result):promises[0](error,result).then(function(res,err){promises.splice(0,1),promises?Promise.chain(promises,res,err).then(function(r,e){p.done(r,e)}):p.done(res,err)}),p},global[name]=Promise,global[name].noConflict=function(){return overwrittenName&&(global[name]=overwri
ttenName),Promise},global[name]}(this),function(){function partial(){var args=Array.prototype.slice.call(arguments),fn=args.shift();return fn.bind(this,args)}function Ajax(){function encode(data){var result="";if("string"==typeof data)result=data;else{var e=encodeURIComponent;for(var i in data)data.hasOwnProperty(i)&&(result+="&"+e(i)+"="+e(data[i]))}return result}function request(m,u,d){var timeout,p=new Promise;return self.logger.time(m+" "+u),function(xhr){xhr.onreadystatechange=function(){4^this.readyState||(self.logger.timeEnd(m+" "+u),clearTimeout(timeout),p.done(null,this))},xhr.onerror=function(response){clearTimeout(timeout),p.done(response,null)},xhr.oncomplete=function(){clearTimeout(timeout),self.logger.timeEnd(m+" "+u),self.info("%s request to %s returned %s",m,u,this.status)},xhr.open(m,u),d&&("object"==typeof d&&(d=JSON.stringify(d)),xhr.setRequestHeader("Content-Type","application/json"),xhr.setRequestHeader("Accept","application/json")),timeout=setTimeout(function()
{xhr.abort(),p.done("API Call timed out.",null)},3e4),xhr.send(encode(d))}(new XMLHttpRequest),p}this.logger=new global.Logger(name);var self=this;this.request=request,this.get=partial(request,"GET"),this.post=partial(request,"POST"),this.put=partial(request,"PUT"),this.delete=partial(request,"DELETE")}var exports,name="Ajax",global=this,overwrittenName=global[name];return global[name]=new Ajax,global[name].noConflict=function(){return overwrittenName&&(global[name]=overwrittenName),exports},global[name]}(),window.console=window.console||{},window.console.log=window.console.log||function(){};var uuidValueRegex=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;!function(global){function Usergrid(){this.logger=new Logger(name)}var name="Usergrid",overwrittenName=global[name];Usergrid.isValidEndpoint=function(){return!0};var VALID_REQUEST_METHODS=["GET","POST","PUT","DELETE"];return Usergrid.Request=function(method,endpoint,query_params,data,callback){var
p=new Promise;if(this.logger=new global.Logger("Usergrid.Request"),this.logger.time("process request "+method+" "+endpoint),this.endpoint=endpoint+"?"+encodeParams(query_params),this.method=method.toUpperCase(),this.data="object"==typeof data?JSON.stringify(data):data,-1===VALID_REQUEST_METHODS.indexOf(this.method))throw new UsergridInvalidHTTPMethodError("invalid request method '"+this.method+"'");if(!isValidUrl(this.endpoint))throw this.logger.error(endpoint,this.endpoint,/^https:\/\//.test(endpoint)),new UsergridInvalidURIError("The provided endpoint is not valid: "+this.endpoint);var request=function(){return Ajax.request(this.method,this.endpoint,this.data)}.bind(this),response=function(err,request){return new Usergrid.Response(err,request)}.bind(this),oncomplete=function(err,response){p.done(err,response),this.logger.info("REQUEST",err,response),doCallback(callback,[err,response]),this.logger.timeEnd("process request "+method+" "+endpoint)}.bind(this);return Promise.chain([req
uest,response]).then(oncomplete),p},Usergrid.Response=function(err,response){var p=new Promise,data=null;try{data=JSON.parse(response.responseText)}catch(e){data={}}switch(Object.keys(data).forEach(function(key){Object.defineProperty(this,key,{value:data[key],enumerable:!0})}.bind(this)),Object.defineProperty(this,"logger",{enumerable:!1,configurable:!1,writable:!1,value:new global.Logger(name)}),Object.defineProperty(this,"success",{enumerable:!1,configurable:!1,writable:!0,value:!0}),Object.defineProperty(this,"err",{enumerable:!1,configurable:!1,writable:!0,value:err}),Object.defineProperty(this,"status",{enumerable:!1,configurable:!1,writable:!0,value:parseInt(response.status)}),Object.defineProperty(this,"statusGroup",{enumerable:!1,configurable:!1,writable:!0,value:this.status-this.status%100}),this.statusGroup){case 200:this.success=!0;break;case 400:case 500:case 300:case 100:default:this.success=!1}return this.success?p.done(null,this):p.done(UsergridError.fromResponse(data
),this),p},Usergrid.Response.prototype.getEntities=function(){var entities=[];return this.success&&(entities=this.data?this.data.entities:this.entities),entities},Usergrid.Response.prototype.getEntity=function(){var entities=this.getEntities();return entities[0]},Usergrid.VERSION=Usergrid.USERGRID_SDK_VERSION="0.10.08",global[name]=Usergrid,global[name].noConflict=function(){return overwrittenName&&(global[name]=overwrittenName),Usergrid},global[name]}(this),function(){var exports,name="Client",global=this,overwrittenName=global[name];return Usergrid.Client=function(options){this.URI=options.URI||"https://api.usergrid.com",options.orgName&&this.set("orgName",options.orgName),options.appName&&this.set("appName",options.appName),this.buildCurl=options.buildCurl||!1,this.logging=options.logging||!1,this._callTimeout=options.callTimeout||3e4,this._callTimeoutCallback=options.callTimeoutCallback||null,this.logoutCallback=options.logoutCallback||null},Usergrid.Client.prototype.request=fun
ction(options,callback){var uri,method=options.method||"GET",endpoint=options.endpoint,body=options.body||{},qs=options.qs||{},mQuery=options.mQuery||!1,orgName=this.get("orgName"),appName=this.get("appName"),logoutCallback=function(){return"function"==typeof this.logoutCallback?this.logoutCallback(!0,"no_org_or_app_name_specified"):void 0}.bind(this);if(!mQuery&&!orgName&&!appName)return logoutCallback();uri=mQuery?this.URI+"/"+endpoint:this.URI+"/"+orgName+"/"+appName+"/"+endpoint,this.getToken()&&(qs.access_token=this.getToken());new Usergrid.Request(method,uri,qs,body,function(err,response){return-1!==["auth_expired_session_token","auth_missing_credentials","auth_unverified_oath","expired_token","unauthorized","auth_invalid"].indexOf(response.error)?logoutCallback():void doCallback(callback,[err,response])})},Usergrid.Client.prototype.buildAssetURL=function(uuid){var self=this,qs={},assetURL=this.URI+"/"+this.orgName+"/"+this.appName+"/assets/"+uuid+"/data";self.getToken()&&(qs.
access_token=self.getToken());var encoded_params=encodeParams(qs);return encoded_params&&(assetURL+="?"+encoded_params),assetURL},Usergrid.Client.prototype.createGroup=function(options,callback){var getOnExist=options.getOnExist||!1;options={path:options.path,client:this,data:options};var group=new Usergrid.Group(options);group.fetch(function(err,data){var okToSave=err&&-1!==["service_resource_not_found","no_name_specified","null_pointer"].indexOf(err.name)||!err&&getOnExist;okToSave?group.save(function(err,data){doCallback(callback,[err,group,data])}):doCallback(callback,[null,group,data])})},Usergrid.Client.prototype.createEntity=function(options,callback){var getOnExist=options.getOnExist||!1;delete options.getOnExist;var entity_data={client:this,data:options},entity=new Usergrid.Entity(entity_data);entity.fetch(function(err,data){var common_errors=["service_resource_not_found","no_name_specified","null_pointer"],okToSave=!err&&getOnExist||err&&err.name&&-1!==common_errors.indexO
f(err.name);okToSave?(entity.set(entity_data.data),entity.save(function(err,data){doCallback(callback,[err,entity,data])})):doCallback(callback,[null,entity,data])})},Usergrid.Client.prototype.getEntity=function(options,callback){var options={client:this,data:options},entity=new Usergrid.Entity(options);entity.fetch(function(err,data){doCallback(callback,[err,entity,data])})},Usergrid.Client.prototype.restoreEntity=function(serializedObject){var data=JSON.parse(serializedObject),options={client:this,data:data},entity=new Usergrid.Entity(options);return entity},Usergrid.Client.prototype.createCollection=function(options,callback){options.client=this;var collection=new Usergrid.Collection(options,function(err,data){doCallback(callback,[err,collection,data])})},Usergrid.Client.prototype.restoreCollection=function(serializedObject){var data=JSON.parse(serializedObject);data.client=this;var collection=new Usergrid.Collection(data);return collection},Usergrid.Client.prototype.getFeedForUs
er=function(username,callback){var options={method:"GET",endpoint:"users/"+username+"/feed"};this.request(options,function(err,data){err?doCallback(callback,[err]):doCallback(callback,[err,data,data.getEntities()])})},Usergrid.Client.prototype.createUserActivity=function(user,options,callback){options.type="users/"+user+"/activities";var options={client:this,data:options},entity=new Usergrid.Entity(options);entity.save(function(err){doCallback(callback,[err,entity])})},Usergrid.Client.prototype.createUserActivityWithEntity=function(user,content,callback){var username=user.get("username"),options={actor:{displayName:username,uuid:user.get("uuid"),username:username,email:user.get("email"),picture:user.get("picture"),image:{duration:0,height:80,url:user.get("picture"),width:80}},verb:"post",content:content};this.createUserActivity(username,options,callback)},Usergrid.Client.prototype.calcTimeDiff=function(){var seconds=0,time=this._end-this._start;try{seconds=(time/10/60).toFixed(2)}ca
tch(e){return 0}return seconds},Usergrid.Client.prototype.setToken=function(token){this.set("token",token)},Usergrid.Client.prototype.getToken=function(){return this.get("token")},Usergrid.Client.prototype.setObject=function(key,value){value&&(value=JSON.stringify(value)),this.set(key,value)},Usergrid.Client.prototype.set=function(key,value){var keyStore="apigee_"+key;this[key]=value,"undefined"!=typeof Storage&&(value?localStorage.setItem(keyStore,value):localStorage.removeItem(keyStore))},Usergrid.Client.prototype.getObject=function(key){return JSON.parse(this.get(key))},Usergrid.Client.prototype.get=function(key){var keyStore="apigee_"+key,value=null;return this[key]?value=this[key]:"undefined"!=typeof Storage&&(value=localStorage.getItem(keyStore)),value},Usergrid.Client.prototype.signup=function(username,password,email,name,callback){var options={type:"users",username:username,password:password,email:email,name:name};this.createEntity(options,callback)},Usergrid.Client.prototyp
e.login=function(username,password,callback){var self=this,options={method:"POST",endpoint:"token",body:{username:username,password:password,grant_type:"password"}};self.request(options,function(err,data){var user={};if(err)self.logging&&console.log("error trying to log user in");else{var options={client:self,data:data.user};user=new Usergrid.Entity(options),self.setToken(data.access_token)}doCallback(callback,[err,data,user])})},Usergrid.Client.prototype.reAuthenticateLite=function(callback){var self=this,options={method:"GET",endpoint:"management/me",mQuery:!0};this.request(options,function(err,response){err&&self.logging?console.log("error trying to re-authenticate user"):self.setToken(response.data.access_token),doCallback(callback,[err])})},Usergrid.Client.prototype.reAuthenticate=function(email,callback){var self=this,options={method:"GET",endpoint:"management/users/"+email,mQuery:!0};this.request(options,function(err,response){var data,organizations={},applications={},user={}
;if(err&&self.logging)console.log("error trying to full authenticate user");else{data=response.data,self.setToken(data.token),self.set("email",data.email),localStorage.setItem("accessToken",data.token),localStorage.setItem("userUUID",data.uuid),localStorage.setItem("userEmail",data.email);var userData={username:data.username,email:data.email,name:data.name,uuid:data.uuid},options={client:self,data:userData};user=new Usergrid.Entity(options),organizations=data.organizations;var org="";try{var existingOrg=self.get("orgName");org=organizations[existingOrg]?organizations[existingOrg]:organizations[Object.keys(organizations)[0]],self.set("orgName",org.name)}catch(e){err=!0,self.logging&&console.log("error selecting org")}applications=self.parseApplicationsArray(org),self.selectFirstApp(applications),self.setObject("organizations",organizations),self.setObject("applications",applications)}doCallback(callback,[err,data,user,organizations,applications],self)})},Usergrid.Client.prototype.log
inFacebook=function(facebookToken,callback){var self=this,options={method:"GET",endpoint:"auth/facebook",qs:{fb_access_token:facebookToken}};this.request(options,function(err,data){var user={};if(err&&self.logging)console.log("error trying to log user in");else{var options={client:self,data:data.user};user=new Usergrid.Entity(options),self.setToken(data.access_token)}doCallback(callback,[err,data,user],self)})},Usergrid.Client.prototype.getLoggedInUser=function(callback){if(this.getToken()){var self=this,options={method:"GET",endpoint:"users/me"};this.request(options,function(err,data){if(err)self.logging&&console.log("error trying to log user in"),doCallback(callback,[err,data,null],self);else{var options={client:self,data:data.entities[0]},user=new Usergrid.Entity(options);doCallback(callback,[null,data,user],self)}})}else callback(!0,null,null)},Usergrid.Client.prototype.isLoggedIn=function(){var token=this.getToken();return"undefined"!=typeof token&&null!==token},Usergrid.Client
.prototype.logout=function(){this.setToken()},Usergrid.Client.prototype.buildCurlCall=function(options){var curl=["curl"],method=(options.method||"GET").toUpperCase(),body=options.body,uri=options.uri;return curl.push("-X"),curl.push(["POST","PUT","DELETE"].indexOf(method)>=0?method:"GET"),curl.push(uri),"object"==typeof body&&Object.keys(body).length>0&&-1!==["POST","PUT"].indexOf(method)&&(curl.push("-d"),curl.push("'"+JSON.stringify(body)+"'")),curl=curl.join(" "),console.log(curl),curl},Usergrid.Client.prototype.getDisplayImage=function(email,picture,size){size=size||50;var image="https://apigee.com/usergrid/images/user_profile.png";try{picture?image=picture:email.length&&(image="https://secure.gravatar.com/avatar/"+MD5(email)+"?s="+size+encodeURI("&d=https://apigee.com/usergrid/images/user_profile.png"))}catch(e){}finally{return image}},global[name]=Usergrid.Client,global[name].noConflict=function(){return overwrittenName&&(global[name]=overwrittenName),exports},global[name]}()
;var ENTITY_SYSTEM_PROPERTIES=["metadata","created","modified","oldpassword","newpassword","type","activated","uuid"];Usergrid.Entity=function(options){options&&(this._data=options.data||{},this._client=options.client||{})},Usergrid.Entity.isEntity=function(obj){return obj&&obj instanceof Usergrid.Entity},Usergrid.Entity.isPersistedEntity=function(obj){return isEntity(obj)&&isUUID(obj.get("uuid"))},Usergrid.Entity.prototype.serialize=function(){return JSON.stringify(this._data)},Usergrid.Entity.prototype.get=function(key){var value;if(0===arguments.length?value=this._data:arguments.length>1&&(key=[].slice.call(arguments).reduce(function(p,c){return c instanceof Array?p=p.concat(c):p.push(c),p},[])),key instanceof Array){var self=this;value=key.map(function(k){return self.get(k)})}else"undefined"!=typeof key&&(value=this._data[key]);return value},Usergrid.Entity.prototype.set=function(key,value){if("object"==typeof key)for(var field in key)this._data[field]=key[field];else"string"==t
ypeof key?null===value?delete this._data[key]:this._data[key]=value:this._data={}},Usergrid.Entity.prototype.getEndpoint=function(){var name,type=this.get("type"),nameProperties=["uuid","name"];if(void 0===type)throw new UsergridError("cannot fetch entity, no entity type specified","no_type_specified");("users"===type||"user"===type)&&nameProperties.unshift("username");var names=this.get(nameProperties).filter(function(x){return null!=x&&"undefined"!=typeof x});return 0===names.length?type:(name=names.shift(),[type,name].join("/"))},Usergrid.Entity.prototype.save=function(callback){var self=this,type=this.get("type"),method="POST",entityId=this.get("uuid"),data={},entityData=this.get(),password=this.get("password"),oldpassword=this.get("oldpassword"),newpassword=this.get("newpassword"),options={method:method,endpoint:type};entityId&&(options.method="PUT",options.endpoint+="/"+entityId),Object.keys(entityData).filter(function(key){return-1===ENTITY_SYSTEM_PROPERTIES.indexOf(key)}).fo
rEach(function(key){data[key]=entityData[key]}),options.body=data,this._client.request(options,function(err,response){var entity=response.getEntity();if(entity&&(self.set(entity),self.set("type",/^\//.test(response.path)?response.path.substring(1):response.path)),self.set("password",null),self.set("oldpassword",null),self.set("newpassword",null),err&&self._client.logging)console.log("could not save entity"),doCallback(callback,[err,response,self]);else if(/^users?/.test(self.get("type"))&&oldpassword&&newpassword){var options={method:"PUT",endpoint:type+"/"+self.get("uuid")+"/password",body:{uuid:self.get("uuid"),username:self.get("username"),password:password,oldpassword:oldpassword,newpassword:newpassword}};self._client.request(options,function(err,data){err&&self._client.logging&&console.log("could not update user"),self.set({password:null,oldpassword:null,newpassword:null}),doCallback(callback,[err,data,self])})}else doCallback(callback,[err,response,self])})},Usergrid.Entity.pr
ototype.fetch=function(callback){var endpoint,self=this;endpoint=this.getEndpoint();var options={method:"GET",endpoint:endpoint};this._client.request(options,function(err,response){var entity=response.getEntity();entity&&self.set(entity),doCallback(callback,[err,entity,self])})},Usergrid.Entity.prototype.destroy=function(callback){var self=this,endpoint=this.getEndpoint(),options={method:"DELETE",endpoint:endpoint};this._client.request(options,function(err,data){err||self.set(null),doCallback(callback,[err,data])})},Usergrid.Entity.prototype.connect=function(connection,entity,callback){var error,self=this,connecteeType=entity.get("type"),connectee=this.getEntityId(entity);if(!connectee)return void("function"==typeof callback&&(error="Error trying to delete object - no uuid specified.",self._client.logging&&console.log(error),doCallback(callback,[!0,error],self)));var connectorType=this.get("type"),connector=this.getEntityId(this);if(!connector)return void("function"==typeof callback
&&(error="Error in connect - no uuid specified.",self._client.logging&&console.log(error),doCallback(callback,[!0,error],self)));var endpoint=connectorType+"/"+connector+"/"+connection+"/"+connecteeType+"/"+connectee,options={method:"POST",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&console.log("entity could not be connected"),doCallback(callback,[err,data],self)})},Usergrid.Entity.prototype.getEntityId=function(entity){var id=!1;return isUUID(entity.get("uuid"))?id=entity.get("uuid"):"users"===this.get("type")?id=entity.get("username"):entity.get("name")&&(id=entity.get("name")),id},Usergrid.Entity.prototype.getConnections=function(connection,callback){var self=this,connectorType=this.get("type"),connector=this.getEntityId(this);if(connector){var endpoint=connectorType+"/"+connector+"/"+connection+"/",options={method:"GET",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&console.log("enti
ty could not be connected"),self[connection]={};for(var length=data&&data.entities?data.entities.length:0,i=0;length>i;i++)"user"===data.entities[i].type?self[connection][data.entities[i].username]=data.entities[i]:self[connection][data.entities[i].name]=data.entities[i];doCallback(callback,[err,data,data.entities],self)})}else if("function"==typeof callback){var error="Error in getConnections - no uuid specified.";self._client.logging&&console.log(error),doCallback(callback,[!0,error],self)}},Usergrid.Entity.prototype.getGroups=function(callback){var self=this,endpoint="users/"+this.get("uuid")+"/groups",options={method:"GET",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&console.log("entity could not be connected"),self.groups=data.entities,doCallback(callback,[err,data,data.entities],self)})},Usergrid.Entity.prototype.getActivities=function(callback){var self=this,endpoint=this.get("type")+"/"+this.get("uuid")+"/activities",options={
method:"GET",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&console.log("entity could not be connected");for(var entity in data.entities)data.entities[entity].createdDate=new Date(data.entities[entity].created).toUTCString();self.activities=data.entities,doCallback(callback,[err,data,data.entities],self)})},Usergrid.Entity.prototype.getFollowing=function(callback){var self=this,endpoint="users/"+this.get("uuid")+"/following",options={method:"GET",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&console.log("could not get user following");for(var entity in data.entities){data.entities[entity].createdDate=new Date(data.entities[entity].created).toUTCString();var image=self._client.getDisplayImage(data.entities[entity].email,data.entities[entity].picture);data.entities[entity]._portal_image_icon=image}self.following=data.entities,doCallback(callback,[err,data,data.entities],self)})},Usergrid.Ent
ity.prototype.getFollowers=function(callback){var self=this,endpoint="users/"+this.get("uuid")+"/followers",options={method:"GET",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&console.log("could not get user followers");for(var entity in data.entities){data.entities[entity].createdDate=new Date(data.entities[entity].created).toUTCString();var image=self._client.getDisplayImage(data.entities[entity].email,data.entities[entity].picture);data.entities[entity]._portal_image_icon=image}self.followers=data.entities,doCallback(callback,[err,data,data.entities],self)})},Usergrid.Entity.prototype.getRoles=function(callback){var self=this,endpoint=this.get("type")+"/"+this.get("uuid")+"/roles",options={method:"GET",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&console.log("could not get user roles"),self.roles=data.entities,doCallback(callback,[err,data,data.entities],self)})},Usergrid.Entity.proto
type.getPermissions=function(callback){var self=this,endpoint=this.get("type")+"/"+this.get("uuid")+"/permissions",options={method:"GET",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&console.log("could not get user permissions");var permissions=[];if(data.data){var perms=data.data,count=0;for(var i in perms){count++;var perm=perms[i],parts=perm.split(":"),ops_part="",path_part=parts[0];parts.length>1&&(ops_part=parts[0],path_part=parts[1]),ops_part.replace("*","get,post,put,delete");var ops=ops_part.split(","),ops_object={};ops_object.get="no",ops_object.post="no",ops_object.put="no",ops_object.delete="no";for(var j in ops)ops_object[ops[j]]="yes";permissions.push({operations:ops_object,path:path_part,perm:perm})}}self.permissions=permissions,doCallback(callback,[err,data,data.entities],self)})},Usergrid.Entity.prototype.disconnect=function(connection,entity,callback){var error,self=this,connecteeType=entity.get("type"),connectee=this.
getEntityId(entity);if(!connectee)return void("function"==typeof callback&&(error="Error trying to delete object - no uuid specified.",self._client.logging&&console.log(error),doCallback(callback,[!0,error],self)));var connectorType=this.get("type"),connector=this.getEntityId(this);if(!connector)return void("function"==typeof callback&&(error="Error in connect - no uuid specified.",self._client.logging&&console.log(error),doCallback(callback,[!0,error],self)));var endpoint=connectorType+"/"+connector+"/"+connection+"/"+connecteeType+"/"+connectee,options={method:"DELETE",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&console.log("entity could not be disconnected"),doCallback(callback,[err,data],self)})},Usergrid.Collection=function(options,callback){if(options&&(this._client=options.client,this._type=options.type,this.qs=options.qs||{},this._list=options.list||[],this._iterator=options.iterator||-1,this._previous=options.previous||[],th
is._next=options.next||null,this._cursor=options.cursor||null,options.list))for(var count=options.list.length,i=0;count>i;i++){var entity=this._client.restoreEntity(options.list[i]);this._list[i]=entity}callback&&this.fetch(callback)},Usergrid.isCollection=function(obj){return obj&&obj instanceof Usergrid.Collection},Usergrid.Collection.prototype.serialize=function(){var data={};data.type=this._type,data.qs=this.qs,data.iterator=this._iterator,data.previous=this._previous,data.next=this._next,data.cursor=this._cursor,this.resetEntityPointer();var i=0;for(data.list=[];this.hasNextEntity();){var entity=this.getNextEntity();data.list[i]=entity.serialize(),i++}return data=JSON.stringify(data)},Usergrid.Collection.prototype.addCollection=function(collectionName,options,callback){self=this,options.client=this._client;var collection=new Usergrid.Collection(options,function(err){if("function"==typeof callback){for(collection.resetEntityPointer();collection.hasNextEntity();){var user=collect
ion.getNextEntity(),image=(user.get("email"),self._client.getDisplayImage(user.get("email"),user.get("picture")));user._portal_image_icon=image}self[collectionName]=collection,doCallback(callback,[err,collection],self)}})},Usergrid.Collection.prototype.fetch=function(callback){var self=this,qs=this.qs;this._cursor?qs.cursor=this._cursor:delete qs.cursor;var options={method:"GET",endpoint:this._type,qs:this.qs};this._client.request(options,function(err,data){if(err&&self._client.logging)console.log("error getting collection");else{var cursor=data.cursor||null;if(self.saveCursor(cursor),data.entities){self.resetEntityPointer();var count=data.entities.length;self._list=[];for(var i=0;count>i;i++){var uuid=data.entities[i].uuid;if(uuid){var entityData=data.entities[i]||{};self._baseType=data.entities[i].type,entityData.type=self._type;var entityOptions={type:self._type,client:self._client,uuid:uuid,data:entityData},ent=new Usergrid.Entity(entityOptions);ent._json=JSON.stringify(entityDa
ta,null,2);var ct=self._list.length;self._list[ct]=ent}}}}doCallback(callback,[err,data],self)})},Usergrid.Collection.prototype.addEntity=function(options,callback){var self=this;
-options.type=this._type,this._client.createEntity(options,function(err,entity){if(!err){var count=self._list.length;self._list[count]=entity}doCallback(callback,[err,entity],self)})},Usergrid.Collection.prototype.addExistingEntity=function(entity){var count=this._list.length;this._list[count]=entity},Usergrid.Collection.prototype.destroyEntity=function(entity,callback){var self=this;entity.destroy(function(err,data){err?(self._client.logging&&console.log("could not destroy entity"),doCallback(callback,[err,data],self)):self.fetch(callback)}),this.removeEntity(entity)},Usergrid.Collection.prototype.removeEntity=function(entity){var uuid=entity.get("uuid");for(var key in this._list){var listItem=this._list[key];if(listItem.get("uuid")===uuid)return this._list.splice(key,1)}return!1},Usergrid.Collection.prototype.getEntityByUUID=function(uuid,callback){for(var key in this._list){var listItem=this._list[key];if(listItem.get("uuid")===uuid)return callback(null,listItem)}var options={data
:{type:this._type,uuid:uuid},client:this._client},entity=new Usergrid.Entity(options);entity.fetch(callback)},Usergrid.Collection.prototype.getFirstEntity=function(){var count=this._list.length;return count>0?this._list[0]:null},Usergrid.Collection.prototype.getLastEntity=function(){var count=this._list.length;return count>0?this._list[count-1]:null},Usergrid.Collection.prototype.hasNextEntity=function(){var next=this._iterator+1,hasNextElement=next>=0&&next<this._list.length;return hasNextElement?!0:!1},Usergrid.Collection.prototype.getNextEntity=function(){this._iterator++;var hasNextElement=this._iterator>=0&&this._iterator<=this._list.length;return hasNextElement?this._list[this._iterator]:!1},Usergrid.Collection.prototype.hasPrevEntity=function(){var previous=this._iterator-1,hasPreviousElement=previous>=0&&previous<this._list.length;return hasPreviousElement?!0:!1},Usergrid.Collection.prototype.getPrevEntity=function(){this._iterator--;var hasPreviousElement=this._iterator>=0&
&this._iterator<=this._list.length;return hasPreviousElement?this._list[this._iterator]:!1},Usergrid.Collection.prototype.resetEntityPointer=function(){this._iterator=-1},Usergrid.Collection.prototype.saveCursor=function(cursor){this._next!==cursor&&(this._next=cursor)},Usergrid.Collection.prototype.resetPaging=function(){this._previous=[],this._next=null,this._cursor=null},Usergrid.Collection.prototype.hasNextPage=function(){return this._next},Usergrid.Collection.prototype.getNextPage=function(callback){this.hasNextPage()&&(this._previous.push(this._cursor),this._cursor=this._next,this._list=[],this.fetch(callback))},Usergrid.Collection.prototype.hasPreviousPage=function(){return this._previous.length>0},Usergrid.Collection.prototype.getPreviousPage=function(callback){this.hasPreviousPage()&&(this._next=null,this._cursor=this._previous.pop(),this._list=[],this.fetch(callback))},Usergrid.Group=function(options){this._path=options.path,this._list=[],this._client=options.client,this._
data=options.data||{},this._data.type="groups"},Usergrid.Group.prototype=new Usergrid.Entity,Usergrid.Group.prototype.fetch=function(callback){var self=this,groupEndpoint="groups/"+this._path,memberEndpoint="groups/"+this._path+"/users",groupOptions={method:"GET",endpoint:groupEndpoint},memberOptions={method:"GET",endpoint:memberEndpoint};this._client.request(groupOptions,function(err,data){if(err)self._client.logging&&console.log("error getting group"),doCallback(callback,[err,data],self);else if(data.entities&&data.entities.length){var groupData=data.entities[0];self._data=groupData||{},self._client.request(memberOptions,function(err,data){if(err&&self._client.logging)console.log("error getting group users");else if(data.entities){var count=data.entities.length;self._list=[];for(var i=0;count>i;i++){var uuid=data.entities[i].uuid;if(uuid){var entityData=data.entities[i]||{},entityOptions={type:entityData.type,client:self._client,uuid:uuid,data:entityData},entity=new Usergrid.Entit
y(entityOptions);self._list.push(entity)}}}doCallback(callback,[err,data,self._list],self)})}})},Usergrid.Group.prototype.members=function(callback){doCallback(callback,[null,this._list],this)},Usergrid.Group.prototype.add=function(options,callback){var self=this,options={method:"POST",endpoint:"groups/"+this._path+"/users/"+options.user.get("username")};this._client.request(options,function(error,data){error?doCallback(callback,[error,data,data.entities],self):self.fetch(callback)})},Usergrid.Group.prototype.remove=function(options,callback){var self=this,options={method:"DELETE",endpoint:"groups/"+this._path+"/users/"+options.user.get("username")};this._client.request(options,function(error,data){error?doCallback(callback,[error,data],self):self.fetch(callback)})},Usergrid.Group.prototype.feed=function(callback){var self=this,endpoint="groups/"+this._path+"/feed",options={method:"GET",endpoint:endpoint};this._client.request(options,function(err,data){err&&self.logging&&console.log
("error trying to log user in"),doCallback(callback,[err,data,data.entities],self)})},Usergrid.Group.prototype.createGroupActivity=function(options,callback){var user=options.user;options={client:this._client,data:{actor:{displayName:user.get("username"),uuid:user.get("uuid"),username:user.get("username"),email:user.get("email"),picture:user.get("picture"),image:{duration:0,height:80,url:user.get("picture"),width:80}},verb:"post",content:options.content,type:"groups/"+this._path+"/activities"}};var entity=new Usergrid.Entity(options);entity.save(function(err){doCallback(callback,[err,entity])})},Usergrid.Counter=function(options,callback){var self=this;this._client=options.client,this._data=options.data||{},this._data.category=options.category||"UNKNOWN",this._data.timestamp=options.timestamp||0,this._data.type="events",this._data.counters=options.counters||{},doCallback(callback,[!1,self],self)};var COUNTER_RESOLUTIONS=["all","minute","five_minutes","half_hour","hour","six_day","da
y","week","month"];Usergrid.Counter.prototype=new Usergrid.Entity,Usergrid.Counter.prototype.fetch=function(callback){this.getData({},callback)},Usergrid.Counter.prototype.increment=function(options,callback){var self=this,name=options.name,value=options.value;return name?isNaN(value)?doCallback(callback,[!0,"'value' for increment, decrement must be a number"],self):(self._data.counters[name]=parseInt(value)||1,self.save(callback)):doCallback(callback,[!0,"'name' for increment, decrement must be a number"],self)},Usergrid.Counter.prototype.decrement=function(options,callback){var self=this,name=options.name,value=options.value;self.increment({name:name,value:-(parseInt(value)||1)},callback)},Usergrid.Counter.prototype.reset=function(options,callback){var self=this,name=options.name;self.increment({name:name,value:0},callback)},Usergrid.Counter.prototype.getData=function(options,callback){var start_time,end_time,start=options.start||0,end=options.end||Date.now(),resolution=(options.r
esolution||"all").toLowerCase(),counters=options.counters||Object.keys(this._data.counters),res=(resolution||"all").toLowerCase();if(-1===COUNTER_RESOLUTIONS.indexOf(res)&&(res="all"),start)switch(typeof start){case"undefined":start_time=0;break;case"number":start_time=start;break;case"string":start_time=isNaN(start)?Date.parse(start):parseInt(start);break;default:start_time=Date.parse(start.toString())}if(end)switch(typeof end){case"undefined":end_time=Date.now();break;case"number":end_time=end;break;case"string":end_time=isNaN(end)?Date.parse(end):parseInt(end);break;default:end_time=Date.parse(end.toString())}var self=this,params=Object.keys(counters).map(function(counter){return["counter",encodeURIComponent(counters[counter])].join("=")});params.push("resolution="+res),params.push("start_time="+String(start_time)),params.push("end_time="+String(end_time));var endpoint="counters?"+params.join("&");this._client.request({endpoint:endpoint},function(err,data){return data.counters&&d
ata.counters.length&&data.counters.forEach(function(counter){self._data.counters[counter.name]=counter.value||counter.values}),doCallback(callback,[err,data],self)})},Usergrid.Folder=function(options,callback){var self=this;console.log("FOLDER OPTIONS",options),self._client=options.client,self._data=options.data||{},self._data.type="folders";var missingData=["name","owner","path"].some(function(required){return!(required in self._data)});return missingData?doCallback(callback,[!0,new UsergridError("Invalid asset data: 'name', 'owner', and 'path' are required properties.")],self):void self.save(function(err,data){err?doCallback(callback,[!0,new UsergridError(data)],self):(data&&data.entities&&data.entities.length&&self.set(data.entities[0]),doCallback(callback,[!1,self],self))})},Usergrid.Folder.prototype=new Usergrid.Entity,Usergrid.Folder.prototype.fetch=function(callback){var self=this;Usergrid.Entity.prototype.fetch.call(self,function(err,data){console.log("self",self.get()),cons
ole.log("data",data),err?doCallback(callback,[!0,new UsergridError(data)],self):self.getAssets(function(err,data){err?doCallback(callback,[!0,new UsergridError(data)],self):doCallback(callback,[null,self],self)})})},Usergrid.Folder.prototype.addAsset=function(options,callback){var self=this;if("asset"in options){var asset=null;switch(typeof options.asset){case"object":asset=options.asset,asset instanceof Usergrid.Entity||(asset=new Usergrid.Asset(asset));break;case"string":isUUID(options.asset)&&(asset=new Usergrid.Asset({client:self._client,data:{uuid:options.asset,type:"assets"}}))}asset&&asset instanceof Usergrid.Entity&&asset.fetch(function(err,data){if(err)doCallback(callback,[err,new UsergridError(data)],self);else{var endpoint=["folders",self.get("uuid"),"assets",asset.get("uuid")].join("/"),options={method:"POST",endpoint:endpoint};self._client.request(options,callback)}})}else doCallback(callback,[!0,{error_description:"No asset specified"}],self)},Usergrid.Folder.prototype
.removeAsset=function(options,callback){var self=this;if("asset"in options){var asset=null;switch(typeof options.asset){case"object":asset=options.asset;break;case"string":isUUID(options.asset)&&(asset=new Usergrid.Asset({client:self._client,data:{uuid:options.asset,type:"assets"}}))}if(asset&&null!==asset){var endpoint=["folders",self.get("uuid"),"assets",asset.get("uuid")].join("/");self._client.request({method:"DELETE",endpoint:endpoint},callback)}}else doCallback(callback,[!0,{error_description:"No asset specified"}],self)},Usergrid.Folder.prototype.getAssets=function(callback){return this.getConnections("assets",callback)},XMLHttpRequest.prototype.sendAsBinary||(XMLHttpRequest.prototype.sendAsBinary=function(sData){for(var nBytes=sData.length,ui8Data=new Uint8Array(nBytes),nIdx=0;nBytes>nIdx;nIdx++)ui8Data[nIdx]=255&sData.charCodeAt(nIdx);this.send(ui8Data)}),Usergrid.Asset=function(options,callback){var self=this;self._client=options.client,self._data=options.data||{},self._da
ta.type="assets";var missingData=["name","owner","path"].some(function(required){return!(required in self._data)});return missingData?doCallback(callback,[!0,new UsergridError("Invalid asset data: 'name', 'owner', and 'path' are required properties.")],self):void self.save(function(err,data){err?doCallback(callback,[!0,new UsergridError(data)],self):(data&&data.entities&&data.entities.length&&self.set(data.entities[0]),doCallback(callback,[!1,self],self))})},Usergrid.Asset.prototype=new Usergrid.Entity,Usergrid.Asset.prototype.addToFolder=function(options,callback){var self=this;if("folder"in options&&isUUID(options.folder)){Usergrid.Folder({uuid:options.folder},function(err,folder){if(err)return callback.call(self,err,folder);var endpoint=["folders",folder.get("uuid"),"assets",self.get("uuid")].join("/"),options={method:"POST",endpoint:endpoint};this._client.request(options,callback)})}else doCallback(callback,[!0,new UsergridError("folder not specified")],self)},Usergrid.Asset.pro
totype.upload=function(data,callback){if(!(window.File&&window.FileReader&&window.FileList&&window.Blob))return doCallback(callback,[!0,new UsergridError("The File APIs are not fully supported by your browser.")],self);var self=this,endpoint=[this._client.URI,this._client.orgName,this._client.appName,"assets",self.get("uuid"),"data"].join("/"),xhr=new XMLHttpRequest;xhr.open("POST",endpoint,!0),xhr.onerror=function(){doCallback(callback,[!0,new UsergridError("The File APIs are not fully supported by your browser.")],self)},xhr.onload=function(){xhr.status>=300?doCallback(callback,[!0,new UsergridError(JSON.parse(xhr.responseText))],self):doCallback(callback,[null,self],self)};var fr=new FileReader;fr.onload=function(){var binary=fr.result;xhr.overrideMimeType("application/octet-stream"),setTimeout(function(){xhr.sendAsBinary(binary)},1e3)},fr.readAsBinaryString(data)},Usergrid.Asset.prototype.download=function(callback){var self=this,endpoint=[this._client.URI,this._client.orgName,t
his._client.appName,"assets",self.get("uuid"),"data"].join("/"),xhr=new XMLHttpRequest;xhr.open("GET",endpoint,!0),xhr.responseType="blob",xhr.onload=function(){var blob=xhr.response;doCallback(callback,[!1,blob],self)},xhr.onerror=function(err){callback(!0,err),doCallback(callback,[!0,new UsergridError(err)],self)},xhr.send()},function(global){function UsergridError(message,name,timestamp,duration,exception){this.message=message,this.name=name,this.timestamp=timestamp||Date.now(),this.duration=duration||0,this.exception=exception}function UsergridHTTPResponseError(message,name,timestamp,duration,exception){this.message=message,this.name=name,this.timestamp=timestamp||Date.now(),this.duration=duration||0,this.exception=exception}function UsergridInvalidHTTPMethodError(message,name,timestamp,duration,exception){this.message=message,this.name=name,this.timestamp=timestamp||Date.now(),this.duration=duration||0,this.exception=exception}function UsergridInvalidURIError(message,name,times
tamp,duration,exception){this.message=message,this.name=name,this.timestamp=timestamp||Date.now(),this.duration=duration||0,this.exception=exception}function UsergridKeystoreDatabaseUpgradeNeededError(message,name,timestamp,duration,exception){this.message=message,this.name=name,this.timestamp=timestamp||Date.now(),this.duration=duration||0,this.exception=exception}var short,name="UsergridError",_name=global[name],_short=short&&void 0!==short?global[short]:void 0;return UsergridError.prototype=new Error,UsergridError.prototype.constructor=UsergridError,UsergridError.fromResponse=function(response){return response&&"undefined"!=typeof response?new UsergridError(response.error_description,response.error,response.timestamp,response.duration,response.exception):new UsergridError},UsergridError.createSubClass=function(name){return name in global&&global[name]?global[name]:(global[name]=function(){},global[name].name=name,global[name].prototype=new UsergridError,global[name])},UsergridHTT
PResponseError.prototype=new UsergridError,UsergridInvalidHTTPMethodError.prototype=new UsergridError,UsergridInvalidURIError.prototype=new UsergridError,UsergridKeystoreDatabaseUpgradeNeededError.prototype=new UsergridError,global.UsergridHTTPResponseError=UsergridHTTPResponseError,global.UsergridInvalidHTTPMethodError=UsergridInvalidHTTPMethodError,global.UsergridInvalidURIError=UsergridInvalidURIError,global.UsergridKeystoreDatabaseUpgradeNeededError=UsergridKeystoreDatabaseUpgradeNeededError,global[name]=UsergridError,void 0!==short&&(global[short]=UsergridError),global[name].noConflict=function(){return _name&&(global[name]=_name),void 0!==short&&(global[short]=_short),UsergridError},global[name]}(this);
\ No newline at end of file
+/*! usergrid@0.10.8 2014-03-13 */
+function extend(subClass,superClass){var F=function(){};return F.prototype=superClass.prototype,subClass.prototype=new F,subClass.prototype.constructor=subClass,subClass.superclass=superClass.prototype,superClass.prototype.constructor==Object.prototype.constructor&&(superClass.prototype.constructor=superClass),subClass}function propCopy(from,to){for(var prop in from)from.hasOwnProperty(prop)&&(to[prop]="object"==typeof from[prop]&&"object"==typeof to[prop]?propCopy(from[prop],to[prop]):from[prop]);return to}function NOOP(){}function isValidUrl(url){if(!url)return!1;var doc,base,anchor,isValid=!1;try{doc=document.implementation.createHTMLDocument(""),base=doc.createElement("base"),base.href=base||window.lo,doc.head.appendChild(base),anchor=doc.createElement("a"),anchor.href=url,doc.body.appendChild(anchor),isValid=!(""===anchor.href)}catch(e){console.error(e)}finally{return doc.head.removeChild(base),doc.body.removeChild(anchor),base=null,anchor=null,doc=null,isValid}}function isUUID
(uuid){return uuid?uuidValueRegex.test(uuid):!1}function encodeParams(params){var queryString;return params&&Object.keys(params)&&(queryString=[].slice.call(arguments).reduce(function(a,b){return a.concat(b instanceof Array?b:[b])},[]).filter(function(c){return"object"==typeof c}).reduce(function(p,c){return c instanceof Array?p.push(c):p=p.concat(Object.keys(c).map(function(key){return[key,c[key]]})),p},[]).reduce(function(p,c){return 2===c.length?p.push(c):p=p.concat(c),p},[]).reduce(function(p,c){return c[1]instanceof Array?c[1].forEach(function(v){p.push([c[0],v])}):p.push(c),p},[]).map(function(c){return c[1]=encodeURIComponent(c[1]),c.join("=")}).join("&")),queryString}function isFunction(f){return f&&null!==f&&"function"==typeof f}function doCallback(callback,params,context){var returnValue;return isFunction(callback)&&(params||(params=[]),context||(context=this),params.push(context),returnValue=callback.apply(context,params)),returnValue}var UsergridEventable=function(){thro
w Error("'UsergridEventable' is not intended to be invoked directly")};UsergridEventable.prototype={bind:function(event,fn){this._events=this._events||{},this._events[event]=this._events[event]||[],this._events[event].push(fn)},unbind:function(event,fn){this._events=this._events||{},event in this._events!=!1&&this._events[event].splice(this._events[event].indexOf(fn),1)},trigger:function(event){if(this._events=this._events||{},event in this._events!=!1)for(var i=0;i<this._events[event].length;i++)this._events[event][i].apply(this,Array.prototype.slice.call(arguments,1))}},UsergridEventable.mixin=function(destObject){for(var props=["bind","unbind","trigger"],i=0;i<props.length;i++)props[i]in destObject.prototype&&(console.warn("overwriting '"+props[i]+"' on '"+destObject.name+"'."),console.warn("the previous version can be found at '_"+props[i]+"' on '"+destObject.name+"'."),destObject.prototype["_"+props[i]]=destObject.prototype[props[i]]),destObject.prototype[props[i]]=UsergridEven
table.prototype[props[i]]},function(){function Logger(name){this.logEnabled=!0,this.init(name,!0)}var name="Logger",global=this,overwrittenName=global[name];return Logger.METHODS=["log","error","warn","info","debug","assert","clear","count","dir","dirxml","exception","group","groupCollapsed","groupEnd","profile","profileEnd","table","time","timeEnd","trace"],Logger.prototype.init=function(name,logEnabled){this.name=name||"UNKNOWN",this.logEnabled=logEnabled||!0;var addMethod=function(method){this[method]=this.createLogMethod(method)}.bind(this);Logger.METHODS.forEach(addMethod)},Logger.prototype.createLogMethod=function(method){return Logger.prototype.log.bind(this,method)},Logger.prototype.prefix=function(method,args){var prepend="["+method.toUpperCase()+"]["+name+"]: ";return-1!==["log","error","warn","info"].indexOf(method)&&("string"==typeof args[0]?args[0]=prepend+args[0]:args.unshift(prepend)),args},Logger.prototype.log=function(){var args=[].slice.call(arguments);method=args.
shift(),-1===Logger.METHODS.indexOf(method)&&(method="log"),this.logEnabled&&console&&console[method]&&(args=this.prefix(method,args),console[method].apply(console,args))},Logger.prototype.setLogEnabled=function(logEnabled){this.logEnabled=logEnabled||!0},Logger.mixin=function(destObject){destObject.__logger=new Logger(destObject.name||"UNKNOWN");var addMethod=function(method){method in destObject.prototype&&(console.warn("overwriting '"+method+"' on '"+destObject.name+"'."),console.warn("the previous version can be found at '_"+method+"' on '"+destObject.name+"'."),destObject.prototype["_"+method]=destObject.prototype[method]),destObject.prototype[method]=destObject.__logger.createLogMethod(method)};Logger.METHODS.forEach(addMethod)},global[name]=Logger,global[name].noConflict=function(){return overwrittenName&&(global[name]=overwrittenName),Logger},global[name]}(),function(global){function Promise(){this.complete=!1,this.error=null,this.result=null,this.callbacks=[]}var name="Prom
ise",overwrittenName=global[name];return Promise.prototype.create=function(){return new Promise},Promise.prototype.then=function(callback,context){var f=function(){return callback.apply(context,arguments)};this.complete?f(this.error,this.result):this.callbacks.push(f)},Promise.prototype.done=function(error,result){if(this.complete=!0,this.error=error,this.result=result,this.callbacks){for(var i=0;i<this.callbacks.length;i++)this.callbacks[i](error,result);this.callbacks.length=0}},Promise.join=function(promises){function notifier(i){return function(error,result){completed+=1,errors[i]=error,results[i]=result,completed===total&&p.done(errors,results)}}for(var p=new Promise,total=promises.length,completed=0,errors=[],results=[],i=0;total>i;i++)promises[i]().then(notifier(i));return p},Promise.chain=function(promises,error,result){var p=new Promise;return null===promises||0===promises.length?p.done(error,result):promises[0](error,result).then(function(res,err){promises.splice(0,1),prom
ises?Promise.chain(promises,res,err).then(function(r,e){p.done(r,e)}):p.done(res,err)}),p},global[name]=Promise,global[name].noConflict=function(){return overwrittenName&&(global[name]=overwrittenName),Promise},global[name]}(this),function(){function partial(){var args=Array.prototype.slice.call(arguments),fn=args.shift();return fn.bind(this,args)}function Ajax(){function encode(data){var result="";if("string"==typeof data)result=data;else{var e=encodeURIComponent;for(var i in data)data.hasOwnProperty(i)&&(result+="&"+e(i)+"="+e(data[i]))}return result}function request(m,u,d){var timeout,p=new Promise;return self.logger.time(m+" "+u),function(xhr){xhr.onreadystatechange=function(){4^this.readyState||(self.logger.timeEnd(m+" "+u),clearTimeout(timeout),p.done(null,this))},xhr.onerror=function(response){clearTimeout(timeout),p.done(response,null)},xhr.oncomplete=function(){clearTimeout(timeout),self.logger.timeEnd(m+" "+u),self.info("%s request to %s returned %s",m,u,this.status)},xhr.
open(m,u),d&&("object"==typeof d&&(d=JSON.stringify(d)),xhr.setRequestHeader("Content-Type","application/json"),xhr.setRequestHeader("Accept","application/json")),timeout=setTimeout(function(){xhr.abort(),p.done("API Call timed out.",null)},3e4),xhr.send(encode(d))}(new XMLHttpRequest),p}this.logger=new global.Logger(name);var self=this;this.request=request,this.get=partial(request,"GET"),this.post=partial(request,"POST"),this.put=partial(request,"PUT"),this.delete=partial(request,"DELETE")}var exports,name="Ajax",global=this,overwrittenName=global[name];return global[name]=new Ajax,global[name].noConflict=function(){return overwrittenName&&(global[name]=overwrittenName),exports},global[name]}(),window.console=window.console||{},window.console.log=window.console.log||function(){};var uuidValueRegex=/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;!function(global){function Usergrid(){this.logger=new Logger(name)}var name="Usergrid",overwrittenName=glob
al[name];Usergrid.isValidEndpoint=function(){return!0};var VALID_REQUEST_METHODS=["GET","POST","PUT","DELETE"];return Usergrid.Request=function(method,endpoint,query_params,data,callback){var p=new Promise;if(this.logger=new global.Logger("Usergrid.Request"),this.logger.time("process request "+method+" "+endpoint),this.endpoint=endpoint+"?"+encodeParams(query_params),this.method=method.toUpperCase(),this.data="object"==typeof data?JSON.stringify(data):data,-1===VALID_REQUEST_METHODS.indexOf(this.method))throw new UsergridInvalidHTTPMethodError("invalid request method '"+this.method+"'");if(!isValidUrl(this.endpoint))throw this.logger.error(endpoint,this.endpoint,/^https:\/\//.test(endpoint)),new UsergridInvalidURIError("The provided endpoint is not valid: "+this.endpoint);var request=function(){return Ajax.request(this.method,this.endpoint,this.data)}.bind(this),response=function(err,request){return new Usergrid.Response(err,request)}.bind(this),oncomplete=function(err,response){p.d
one(err,response),this.logger.info("REQUEST",err,response),doCallback(callback,[err,response]),this.logger.timeEnd("process request "+method+" "+endpoint)}.bind(this);return Promise.chain([request,response]).then(oncomplete),p},Usergrid.Response=function(err,response){var p=new Promise,data=null;try{data=JSON.parse(response.responseText)}catch(e){data={}}switch(Object.keys(data).forEach(function(key){Object.defineProperty(this,key,{value:data[key],enumerable:!0})}.bind(this)),Object.defineProperty(this,"logger",{enumerable:!1,configurable:!1,writable:!1,value:new global.Logger(name)}),Object.defineProperty(this,"success",{enumerable:!1,configurable:!1,writable:!0,value:!0}),Object.defineProperty(this,"err",{enumerable:!1,configurable:!1,writable:!0,value:err}),Object.defineProperty(this,"status",{enumerable:!1,configurable:!1,writable:!0,value:parseInt(response.status)}),Object.defineProperty(this,"statusGroup",{enumerable:!1,configurable:!1,writable:!0,value:this.status-this.status
%100}),this.statusGroup){case 200:this.success=!0;break;case 400:case 500:case 300:case 100:default:this.success=!1}return this.success?p.done(null,this):p.done(UsergridError.fromResponse(data),this),p},Usergrid.Response.prototype.getEntities=function(){var entities=[];return this.success&&(entities=this.data?this.data.entities:this.entities),entities},Usergrid.Response.prototype.getEntity=function(){var entities=this.getEntities();return entities[0]},Usergrid.VERSION=Usergrid.USERGRID_SDK_VERSION="0.10.08",global[name]=Usergrid,global[name].noConflict=function(){return overwrittenName&&(global[name]=overwrittenName),Usergrid},global[name]}(this),function(){var exports,name="Client",global=this,overwrittenName=global[name];return Usergrid.Client=function(options){this.URI=options.URI||"https://api.usergrid.com",options.orgName&&this.set("orgName",options.orgName),options.appName&&this.set("appName",options.appName),options.qs&&this.setObject("default_qs",options.qs),this.buildCurl=o
ptions.buildCurl||!1,this.logging=options.logging||!1,this._callTimeout=options.callTimeout||3e4,this._callTimeoutCallback=options.callTimeoutCallback||null,this.logoutCallback=options.logoutCallback||null},Usergrid.Client.prototype.request=function(options,callback){var uri,method=options.method||"GET",endpoint=options.endpoint,body=options.body||{},qs=options.qs||{},mQuery=options.mQuery||!1,orgName=this.get("orgName"),appName=this.get("appName"),default_qs=this.getObject("default_qs"),logoutCallback=function(){return"function"==typeof this.logoutCallback?this.logoutCallback(!0,"no_org_or_app_name_specified"):void 0}.bind(this);if(!mQuery&&!orgName&&!appName)return logoutCallback();uri=mQuery?this.URI+"/"+endpoint:this.URI+"/"+orgName+"/"+appName+"/"+endpoint,this.getToken()&&(qs.access_token=this.getToken()),default_qs&&(qs=propCopy(qs,default_qs));new Usergrid.Request(method,uri,qs,body,function(err,response){return-1!==["auth_expired_session_token","auth_missing_credentials","a
uth_unverified_oath","expired_token","unauthorized","auth_invalid"].indexOf(response.error)?logoutCallback():void doCallback(callback,[err,response])})},Usergrid.Client.prototype.buildAssetURL=function(uuid){var self=this,qs={},assetURL=this.URI+"/"+this.orgName+"/"+this.appName+"/assets/"+uuid+"/data";self.getToken()&&(qs.access_token=self.getToken());var encoded_params=encodeParams(qs);return encoded_params&&(assetURL+="?"+encoded_params),assetURL},Usergrid.Client.prototype.createGroup=function(options,callback){var getOnExist=options.getOnExist||!1;options={path:options.path,client:this,data:options};var group=new Usergrid.Group(options);group.fetch(function(err,data){var okToSave=err&&-1!==["service_resource_not_found","no_name_specified","null_pointer"].indexOf(err.name)||!err&&getOnExist;okToSave?group.save(function(err,data){doCallback(callback,[err,group,data])}):doCallback(callback,[null,group,data])})},Usergrid.Client.prototype.createEntity=function(options,callback){var g
etOnExist=options.getOnExist||!1;delete options.getOnExist;var entity_data={client:this,data:options},entity=new Usergrid.Entity(entity_data);entity.fetch(function(err,data){var common_errors=["service_resource_not_found","no_name_specified","null_pointer"],okToSave=!err&&getOnExist||err&&err.name&&-1!==common_errors.indexOf(err.name);okToSave?(entity.set(entity_data.data),entity.save(function(err,data){doCallback(callback,[err,entity,data])})):doCallback(callback,[null,entity,data])})},Usergrid.Client.prototype.getEntity=function(options,callback){var options={client:this,data:options},entity=new Usergrid.Entity(options);entity.fetch(function(err,data){doCallback(callback,[err,entity,data])})},Usergrid.Client.prototype.restoreEntity=function(serializedObject){var data=JSON.parse(serializedObject),options={client:this,data:data},entity=new Usergrid.Entity(options);return entity},Usergrid.Client.prototype.createCollection=function(options,callback){options.client=this,new Usergrid.Co
llection(options,function(err,data,collection){doCallback(callback,[err,collection,data])})},Usergrid.Client.prototype.restoreCollection=function(serializedObject){var data=JSON.parse(serializedObject);data.client=this;var collection=new Usergrid.Collection(data);return collection},Usergrid.Client.prototype.getFeedForUser=function(username,callback){var options={method:"GET",endpoint:"users/"+username+"/feed"};this.request(options,function(err,data){err?doCallback(callback,[err]):doCallback(callback,[err,data,data.getEntities()])})},Usergrid.Client.prototype.createUserActivity=function(user,options,callback){options.type="users/"+user+"/activities";var options={client:this,data:options},entity=new Usergrid.Entity(options);entity.save(function(err){doCallback(callback,[err,entity])})},Usergrid.Client.prototype.createUserActivityWithEntity=function(user,content,callback){var username=user.get("username"),options={actor:{displayName:username,uuid:user.get("uuid"),username:username,emai
l:user.get("email"),picture:user.get("picture"),image:{duration:0,height:80,url:user.get("picture"),width:80}},verb:"post",content:content};this.createUserActivity(username,options,callback)},Usergrid.Client.prototype.calcTimeDiff=function(){var seconds=0,time=this._end-this._start;try{seconds=(time/10/60).toFixed(2)}catch(e){return 0}return seconds},Usergrid.Client.prototype.setToken=function(token){this.set("token",token)},Usergrid.Client.prototype.getToken=function(){return this.get("token")},Usergrid.Client.prototype.setObject=function(key,value){value&&(value=JSON.stringify(value)),this.set(key,value)},Usergrid.Client.prototype.set=function(key,value){var keyStore="apigee_"+key;this[key]=value,"undefined"!=typeof Storage&&(value?localStorage.setItem(keyStore,value):localStorage.removeItem(keyStore))},Usergrid.Client.prototype.getObject=function(key){return JSON.parse(this.get(key))},Usergrid.Client.prototype.get=function(key){var keyStore="apigee_"+key,value=null;return this[ke
y]?value=this[key]:"undefined"!=typeof Storage&&(value=localStorage.getItem(keyStore)),value},Usergrid.Client.prototype.signup=function(username,password,email,name,callback){var options={type:"users",username:username,password:password,email:email,name:name};this.createEntity(options,callback)},Usergrid.Client.prototype.login=function(username,password,callback){var self=this,options={method:"POST",endpoint:"token",body:{username:username,password:password,grant_type:"password"}};self.request(options,function(err,data){var user={};if(err)self.logging&&console.log("error trying to log user in");else{var options={client:self,data:data.user};user=new Usergrid.Entity(options),self.setToken(data.access_token)}doCallback(callback,[err,data,user])})},Usergrid.Client.prototype.reAuthenticateLite=function(callback){var self=this,options={method:"GET",endpoint:"management/me",mQuery:!0};this.request(options,function(err,response){err&&self.logging?console.log("error trying to re-authenticate
user"):self.setToken(response.data.access_token),doCallback(callback,[err])})},Usergrid.Client.prototype.reAuthenticate=function(email,callback){var self=this,options={method:"GET",endpoint:"management/users/"+email,mQuery:!0};this.request(options,function(err,response){var data,organizations={},applications={},user={};if(err&&self.logging)console.log("error trying to full authenticate user");else{data=response.data,self.setToken(data.token),self.set("email",data.email),localStorage.setItem("accessToken",data.token),localStorage.setItem("userUUID",data.uuid),localStorage.setItem("userEmail",data.email);var userData={username:data.username,email:data.email,name:data.name,uuid:data.uuid},options={client:self,data:userData};user=new Usergrid.Entity(options),organizations=data.organizations;var org="";try{var existingOrg=self.get("orgName");org=organizations[existingOrg]?organizations[existingOrg]:organizations[Object.keys(organizations)[0]],self.set("orgName",org.name)}catch(e){err=!0
,self.logging&&console.log("error selecting org")}applications=self.parseApplicationsArray(org),self.selectFirstApp(applications),self.setObject("organizations",organizations),self.setObject("applications",applications)}doCallback(callback,[err,data,user,organizations,applications],self)})},Usergrid.Client.prototype.loginFacebook=function(facebookToken,callback){var self=this,options={method:"GET",endpoint:"auth/facebook",qs:{fb_access_token:facebookToken}};this.request(options,function(err,data){var user={};if(err&&self.logging)console.log("error trying to log user in");else{var options={client:self,data:data.user};user=new Usergrid.Entity(options),self.setToken(data.access_token)}doCallback(callback,[err,data,user],self)})},Usergrid.Client.prototype.getLoggedInUser=function(callback){if(this.getToken()){var self=this,options={method:"GET",endpoint:"users/me"};this.request(options,function(err,data){if(err)self.logging&&console.log("error trying to log user in"),doCallback(callback
,[err,data,null],self);else{var options={client:self,data:data.entities[0]},user=new Usergrid.Entity(options);doCallback(callback,[null,data,user],self)}})}else callback(!0,null,null)},Usergrid.Client.prototype.isLoggedIn=function(){var token=this.getToken();return"undefined"!=typeof token&&null!==token},Usergrid.Client.prototype.logout=function(){this.setToken()},Usergrid.Client.prototype.buildCurlCall=function(options){var curl=["curl"],method=(options.method||"GET").toUpperCase(),body=options.body,uri=options.uri;return curl.push("-X"),curl.push(["POST","PUT","DELETE"].indexOf(method)>=0?method:"GET"),curl.push(uri),"object"==typeof body&&Object.keys(body).length>0&&-1!==["POST","PUT"].indexOf(method)&&(curl.push("-d"),curl.push("'"+JSON.stringify(body)+"'")),curl=curl.join(" "),console.log(curl),curl},Usergrid.Client.prototype.getDisplayImage=function(email,picture,size){size=size||50;var image="https://apigee.com/usergrid/images/user_profile.png";try{picture?image=picture:email
.length&&(image="https://secure.gravatar.com/avatar/"+MD5(email)+"?s="+size+encodeURI("&d=https://apigee.com/usergrid/images/user_profile.png"))}catch(e){}finally{return image}},global[name]=Usergrid.Client,global[name].noConflict=function(){return overwrittenName&&(global[name]=overwrittenName),exports},global[name]}();var ENTITY_SYSTEM_PROPERTIES=["metadata","created","modified","oldpassword","newpassword","type","activated","uuid"];Usergrid.Entity=function(options){options&&(this._data=options.data||{},this._client=options.client||{})},Usergrid.Entity.isEntity=function(obj){return obj&&obj instanceof Usergrid.Entity},Usergrid.Entity.isPersistedEntity=function(obj){return isEntity(obj)&&isUUID(obj.get("uuid"))},Usergrid.Entity.prototype.serialize=function(){return JSON.stringify(this._data)},Usergrid.Entity.prototype.get=function(key){var value;if(0===arguments.length?value=this._data:arguments.length>1&&(key=[].slice.call(arguments).reduce(function(p,c){return c instanceof Array?
p=p.concat(c):p.push(c),p},[])),key instanceof Array){var self=this;value=key.map(function(k){return self.get(k)})}else"undefined"!=typeof key&&(value=this._data[key]);return value},Usergrid.Entity.prototype.set=function(key,value){if("object"==typeof key)for(var field in key)this._data[field]=key[field];else"string"==typeof key?null===value?delete this._data[key]:this._data[key]=value:this._data={}},Usergrid.Entity.prototype.getEndpoint=function(){var name,type=this.get("type"),nameProperties=["uuid","name"];if(void 0===type)throw new UsergridError("cannot fetch entity, no entity type specified","no_type_specified");("users"===type||"user"===type)&&nameProperties.unshift("username");var names=this.get(nameProperties).filter(function(x){return null!=x&&"undefined"!=typeof x});return 0===names.length?type:(name=names.shift(),[type,name].join("/"))},Usergrid.Entity.prototype.save=function(callback){var self=this,type=this.get("type"),method="POST",entityId=this.get("uuid"),data={},ent
ityData=this.get(),password=this.get("password"),oldpassword=this.get("oldpassword"),newpassword=this.get("newpassword"),options={method:method,endpoint:type};entityId&&(options.method="PUT",options.endpoint+="/"+entityId),Object.keys(entityData).filter(function(key){return-1===ENTITY_SYSTEM_PROPERTIES.indexOf(key)}).forEach(function(key){data[key]=entityData[key]}),options.body=data,this._client.request(options,function(err,response){var entity=response.getEntity();if(entity&&(self.set(entity),self.set("type",/^\//.test(response.path)?response.path.substring(1):response.path)),self.set("password",null),self.set("oldpassword",null),self.set("newpassword",null),err&&self._client.logging)console.log("could not save entity"),doCallback(callback,[err,response,self]);else if(/^users?/.test(self.get("type"))&&oldpassword&&newpassword){var options={method:"PUT",endpoint:type+"/"+self.get("uuid")+"/password",body:{uuid:self.get("uuid"),username:self.get("username"),password:password,oldpass
word:oldpassword,newpassword:newpassword}};self._client.request(options,function(err,data){err&&self._client.logging&&console.log("could not update user"),self.set({password:null,oldpassword:null,newpassword:null}),doCallback(callback,[err,data,self])})}else doCallback(callback,[err,response,self])})},Usergrid.Entity.prototype.fetch=function(callback){var endpoint,self=this;endpoint=this.getEndpoint();var options={method:"GET",endpoint:endpoint};this._client.request(options,function(err,response){var entity=response.getEntity();entity&&self.set(entity),doCallback(callback,[err,entity,self])})},Usergrid.Entity.prototype.destroy=function(callback){var self=this,endpoint=this.getEndpoint(),options={method:"DELETE",endpoint:endpoint};this._client.request(options,function(err,data){err||self.set(null),doCallback(callback,[err,data])})},Usergrid.Entity.prototype.connect=function(connection,entity,callback){var error,self=this,connecteeType=entity.get("type"),connectee=this.getEntityId(ent
ity);if(!connectee)return void("function"==typeof callback&&(error="Error trying to delete object - no uuid specified.",self._client.logging&&console.log(error),doCallback(callback,[!0,error],self)));var connectorType=this.get("type"),connector=this.getEntityId(this);if(!connector)return void("function"==typeof callback&&(error="Error in connect - no uuid specified.",self._client.logging&&console.log(error),doCallback(callback,[!0,error],self)));var endpoint=connectorType+"/"+connector+"/"+connection+"/"+connecteeType+"/"+connectee,options={method:"POST",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&console.log("entity could not be connected"),doCallback(callback,[err,data],self)})},Usergrid.Entity.prototype.getEntityId=function(entity){var id=!1;return isUUID(entity.get("uuid"))?id=entity.get("uuid"):"users"===this.get("type")?id=entity.get("username"):entity.get("name")&&(id=entity.get("name")),id},Usergrid.Entity.prototype.getConnec
tions=function(connection,callback){var self=this,connectorType=this.get("type"),connector=this.getEntityId(this);if(connector){var endpoint=connectorType+"/"+connector+"/"+connection+"/",options={method:"GET",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&console.log("entity could not be connected"),self[connection]={};for(var length=data&&data.entities?data.entities.length:0,i=0;length>i;i++)"user"===data.entities[i].type?self[connection][data.entities[i].username]=data.entities[i]:self[connection][data.entities[i].name]=data.entities[i];doCallback(callback,[err,data,data.entities],self)})}else if("function"==typeof callback){var error="Error in getConnections - no uuid specified.";self._client.logging&&console.log(error),doCallback(callback,[!0,error],self)}},Usergrid.Entity.prototype.getGroups=function(callback){var self=this,endpoint="users/"+this.get("uuid")+"/groups",options={method:"GET",endpoint:endpoint};this._client.request(o
ptions,function(err,data){err&&self._client.logging&&console.log("entity could not be connected"),self.groups=data.entities,doCallback(callback,[err,data,data.entities],self)})},Usergrid.Entity.prototype.getActivities=function(callback){var self=this,endpoint=this.get("type")+"/"+this.get("uuid")+"/activities",options={method:"GET",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&console.log("entity could not be connected");for(var entity in data.entities)data.entities[entity].createdDate=new Date(data.entities[entity].created).toUTCString();self.activities=data.entities,doCallback(callback,[err,data,data.entities],self)})},Usergrid.Entity.prototype.getFollowing=function(callback){var self=this,endpoint="users/"+this.get("uuid")+"/following",options={method:"GET",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&console.log("could not get user following");for(var entity in data.entities){data.en
tities[entity].createdDate=new Date(data.entities[entity].created).toUTCString();var image=self._client.getDisplayImage(data.entities[entity].email,data.entities[entity].picture);data.entities[entity]._portal_image_icon=image}self.following=data.entities,doCallback(callback,[err,data,data.entities],self)})},Usergrid.Entity.prototype.getFollowers=function(callback){var self=this,endpoint="users/"+this.get("uuid")+"/followers",options={method:"GET",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&console.log("could not get user followers");for(var entity in data.entities){data.entities[entity].createdDate=new Date(data.entities[entity].created).toUTCString();var image=self._client.getDisplayImage(data.entities[entity].email,data.entities[entity].picture);data.entities[entity]._portal_image_icon=image}self.followers=data.entities,doCallback(callback,[err,data,data.entities],self)})},Usergrid.Entity.prototype.getRoles=function(callback){var s
elf=this,endpoint=this.get("type")+"/"+this.get("uuid")+"/roles",options={method:"GET",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&console.log("could not get user roles"),self.roles=data.entities,doCallback(callback,[err,data,data.entities],self)})},Usergrid.Entity.prototype.getPermissions=function(callback){var self=this,endpoint=this.get("type")+"/"+this.get("uuid")+"/permissions",options={method:"GET",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&console.log("could not get user permissions");var permissions=[];if(data.data){var perms=data.data,count=0;for(var i in perms){count++;var perm=perms[i],parts=perm.split(":"),ops_part="",path_part=parts[0];parts.length>1&&(ops_part=parts[0],path_part=parts[1]),ops_part.replace("*","get,post,put,delete");var ops=ops_part.split(","),ops_object={};ops_object.get="no",ops_object.post="no",ops_object.put="no",ops_object.delete="no";for(var j in o
ps)ops_object[ops[j]]="yes";permissions.push({operations:ops_object,path:path_part,perm:perm})}}self.permissions=permissions,doCallback(callback,[err,data,data.entities],self)})},Usergrid.Entity.prototype.disconnect=function(connection,entity,callback){var error,self=this,connecteeType=entity.get("type"),connectee=this.getEntityId(entity);if(!connectee)return void("function"==typeof callback&&(error="Error trying to delete object - no uuid specified.",self._client.logging&&console.log(error),doCallback(callback,[!0,error],self)));var connectorType=this.get("type"),connector=this.getEntityId(this);if(!connector)return void("function"==typeof callback&&(error="Error in connect - no uuid specified.",self._client.logging&&console.log(error),doCallback(callback,[!0,error],self)));var endpoint=connectorType+"/"+connector+"/"+connection+"/"+connecteeType+"/"+connectee,options={method:"DELETE",endpoint:endpoint};this._client.request(options,function(err,data){err&&self._client.logging&&cons
ole.log("entity could not be disconnected"),doCallback(callback,[err,data],self)})},Usergrid.Collection=function(options,callback){if(options&&(this._client=options.client,this._type=options.type,this.qs=options.qs||{},this._list=options.list||[],this._iterator=options.iterator||-1,this._previous=options.previous||[],this._next=options.next||null,this._cursor=options.cursor||null,options.list))for(var count=options.list.length,i=0;count>i;i++){var entity=this._client.restoreEntity(options.list[i]);this._list[i]=entity}callback&&this.fetch(callback)},Usergrid.isCollection=function(obj){return obj&&obj instanceof Usergrid.Collection},Usergrid.Collection.prototype.serialize=function(){var data={};data.type=this._type,data.qs=this.qs,data.iterator=this._iterator,data.previous=this._previous,data.next=this._next,data.cursor=this._cursor,this.resetEntityPointer();var i=0;for(data.list=[];this.hasNextEntity();){var entity=this.getNextEntity();data.list[i]=entity.serialize(),i++}return data
=JSON.stringify(data)},Usergrid.Collection.prototype.addCollection=function(collectionName,options,callback){self=this,options.client=this._client;var collection=new Usergrid.Collection(options,function(err){if("function"==typeof callback){for(collection.resetEntityPointer();collection.hasNextEntity();){var user=collection.getNextEntity(),image=(user.get("email"),self._client.getDisplayImage(user.get("email"),user.get("picture")));user._portal_image_icon=image}self[collectionName]=collection,doCallback(callback,[err,collection],self)}})},Usergrid.Collection.prototype.fetch=function(callback){var self=this,qs=this.qs;this._cursor?qs.cursor=this._cursor:delete qs.cursor;var options={method:"GET",endpoint:this._type,qs:this.qs};this._client.request(options,function(err,data){if(err&&self._client.logging)console.log("error getting collection");else{var cursor=data.cursor||null;if(self.saveCursor(cursor),data.entities){self.resetEntityPointer();var count=data.entities.length;self._list=[
];for(var i=0;count>i;i++){var uuid=data.entities[i].uuid;if(uuid){var entityData=data.entities[i]||{};
+self._baseType=data.entities[i].type,entityData.type=self._type;var entityOptions={type:self._type,client:self._client,uuid:uuid,data:entityData},ent=new Usergrid.Entity(entityOptions);ent._json=JSON.stringify(entityData,null,2);var ct=self._list.length;self._list[ct]=ent}}}}doCallback(callback,[err,data],self)})},Usergrid.Collection.prototype.addEntity=function(options,callback){var self=this;options.type=this._type,this._client.createEntity(options,function(err,entity){if(!err){var count=self._list.length;self._list[count]=entity}doCallback(callback,[err,entity],self)})},Usergrid.Collection.prototype.addExistingEntity=function(entity){var count=this._list.length;this._list[count]=entity},Usergrid.Collection.prototype.destroyEntity=function(entity,callback){var self=this;entity.destroy(function(err,data){err?(self._client.logging&&console.log("could not destroy entity"),doCallback(callback,[err,data],self)):self.fetch(callback)}),this.removeEntity(entity)},Usergrid.Collection.proto
type.removeEntity=function(entity){var uuid=entity.get("uuid");for(var key in this._list){var listItem=this._list[key];if(listItem.get("uuid")===uuid)return this._list.splice(key,1)}return!1},Usergrid.Collection.prototype.getEntityByUUID=function(uuid,callback){for(var key in this._list){var listItem=this._list[key];if(listItem.get("uuid")===uuid)return callback(null,listItem)}var options={data:{type:this._type,uuid:uuid},client:this._client},entity=new Usergrid.Entity(options);entity.fetch(callback)},Usergrid.Collection.prototype.getFirstEntity=function(){var count=this._list.length;return count>0?this._list[0]:null},Usergrid.Collection.prototype.getLastEntity=function(){var count=this._list.length;return count>0?this._list[count-1]:null},Usergrid.Collection.prototype.hasNextEntity=function(){var next=this._iterator+1,hasNextElement=next>=0&&next<this._list.length;return hasNextElement?!0:!1},Usergrid.Collection.prototype.getNextEntity=function(){this._iterator++;var hasNextElement
=this._iterator>=0&&this._iterator<=this._list.length;return hasNextElement?this._list[this._iterator]:!1},Usergrid.Collection.prototype.hasPrevEntity=function(){var previous=this._iterator-1,hasPreviousElement=previous>=0&&previous<this._list.length;return hasPreviousElement?!0:!1},Usergrid.Collection.prototype.getPrevEntity=function(){this._iterator--;var hasPreviousElement=this._iterator>=0&&this._iterator<=this._list.length;return hasPreviousElement?this._list[this._iterator]:!1},Usergrid.Collection.prototype.resetEntityPointer=function(){this._iterator=-1},Usergrid.Collection.prototype.saveCursor=function(cursor){this._next!==cursor&&(this._next=cursor)},Usergrid.Collection.prototype.resetPaging=function(){this._previous=[],this._next=null,this._cursor=null},Usergrid.Collection.prototype.hasNextPage=function(){return this._next},Usergrid.Collection.prototype.getNextPage=function(callback){this.hasNextPage()&&(this._previous.push(this._cursor),this._cursor=this._next,this._list=
[],this.fetch(callback))},Usergrid.Collection.prototype.hasPreviousPage=function(){return this._previous.length>0},Usergrid.Collection.prototype.getPreviousPage=function(callback){this.hasPreviousPage()&&(this._next=null,this._cursor=this._previous.pop(),this._list=[],this.fetch(callback))},Usergrid.Group=function(options){this._path=options.path,this._list=[],this._client=options.client,this._data=options.data||{},this._data.type="groups"},Usergrid.Group.prototype=new Usergrid.Entity,Usergrid.Group.prototype.fetch=function(callback){var self=this,groupEndpoint="groups/"+this._path,memberEndpoint="groups/"+this._path+"/users",groupOptions={method:"GET",endpoint:groupEndpoint},memberOptions={method:"GET",endpoint:memberEndpoint};this._client.request(groupOptions,function(err,data){if(err)self._client.logging&&console.log("error getting group"),doCallback(callback,[err,data],self);else if(data.entities&&data.entities.length){var groupData=data.entities[0];self._data=groupData||{},self
._client.request(memberOptions,function(err,data){if(err&&self._client.logging)console.log("error getting group users");else if(data.entities){var count=data.entities.length;self._list=[];for(var i=0;count>i;i++){var uuid=data.entities[i].uuid;if(uuid){var entityData=data.entities[i]||{},entityOptions={type:entityData.type,client:self._client,uuid:uuid,data:entityData},entity=new Usergrid.Entity(entityOptions);self._list.push(entity)}}}doCallback(callback,[err,data,self._list],self)})}})},Usergrid.Group.prototype.members=function(callback){doCallback(callback,[null,this._list],this)},Usergrid.Group.prototype.add=function(options,callback){var self=this,options={method:"POST",endpoint:"groups/"+this._path+"/users/"+options.user.get("username")};this._client.request(options,function(error,data){error?doCallback(callback,[error,data,data.entities],self):self.fetch(callback)})},Usergrid.Group.prototype.remove=function(options,callback){var self=this,options={method:"DELETE",endpoint:"gr
oups/"+this._path+"/users/"+options.user.get("username")};this._client.request(options,function(error,data){error?doCallback(callback,[error,data],self):self.fetch(callback)})},Usergrid.Group.prototype.feed=function(callback){var self=this,endpoint="groups/"+this._path+"/feed",options={method:"GET",endpoint:endpoint};this._client.request(options,function(err,data){err&&self.logging&&console.log("error trying to log user in"),doCallback(callback,[err,data,data.entities],self)})},Usergrid.Group.prototype.createGroupActivity=function(options,callback){var user=options.user;options={client:this._client,data:{actor:{displayName:user.get("username"),uuid:user.get("uuid"),username:user.get("username"),email:user.get("email"),picture:user.get("picture"),image:{duration:0,height:80,url:user.get("picture"),width:80}},verb:"post",content:options.content,type:"groups/"+this._path+"/activities"}};var entity=new Usergrid.Entity(options);entity.save(function(err){doCallback(callback,[err,entity])}
)},Usergrid.Counter=function(options,callback){var self=this;this._client=options.client,this._data=options.data||{},this._data.category=options.category||"UNKNOWN",this._data.timestamp=options.timestamp||0,this._data.type="events",this._data.counters=options.counters||{},doCallback(callback,[!1,self],self)};var COUNTER_RESOLUTIONS=["all","minute","five_minutes","half_hour","hour","six_day","day","week","month"];Usergrid.Counter.prototype=new Usergrid.Entity,Usergrid.Counter.prototype.fetch=function(callback){this.getData({},callback)},Usergrid.Counter.prototype.increment=function(options,callback){var self=this,name=options.name,value=options.value;return name?isNaN(value)?doCallback(callback,[!0,"'value' for increment, decrement must be a number"],self):(self._data.counters[name]=parseInt(value)||1,self.save(callback)):doCallback(callback,[!0,"'name' for increment, decrement must be a number"],self)},Usergrid.Counter.prototype.decrement=function(options,callback){var self=this,nam
e=options.name,value=options.value;self.increment({name:name,value:-(parseInt(value)||1)},callback)},Usergrid.Counter.prototype.reset=function(options,callback){var self=this,name=options.name;self.increment({name:name,value:0},callback)},Usergrid.Counter.prototype.getData=function(options,callback){var start_time,end_time,start=options.start||0,end=options.end||Date.now(),resolution=(options.resolution||"all").toLowerCase(),counters=options.counters||Object.keys(this._data.counters),res=(resolution||"all").toLowerCase();if(-1===COUNTER_RESOLUTIONS.indexOf(res)&&(res="all"),start)switch(typeof start){case"undefined":start_time=0;break;case"number":start_time=start;break;case"string":start_time=isNaN(start)?Date.parse(start):parseInt(start);break;default:start_time=Date.parse(start.toString())}if(end)switch(typeof end){case"undefined":end_time=Date.now();break;case"number":end_time=end;break;case"string":end_time=isNaN(end)?Date.parse(end):parseInt(end);break;default:end_time=Date.pa
rse(end.toString())}var self=this,params=Object.keys(counters).map(function(counter){return["counter",encodeURIComponent(counters[counter])].join("=")});params.push("resolution="+res),params.push("start_time="+String(start_time)),params.push("end_time="+String(end_time));var endpoint="counters?"+params.join("&");this._client.request({endpoint:endpoint},function(err,data){return data.counters&&data.counters.length&&data.counters.forEach(function(counter){self._data.counters[counter.name]=counter.value||counter.values}),doCallback(callback,[err,data],self)})},Usergrid.Folder=function(options,callback){var self=this;console.log("FOLDER OPTIONS",options),self._client=options.client,self._data=options.data||{},self._data.type="folders";var missingData=["name","owner","path"].some(function(required){return!(required in self._data)});return missingData?doCallback(callback,[!0,new UsergridError("Invalid asset data: 'name', 'owner', and 'path' are required properties.")],self):void self.save
(function(err,data){err?doCallback(callback,[!0,new UsergridError(data)],self):(data&&data.entities&&data.entities.length&&self.set(data.entities[0]),doCallback(callback,[!1,self],self))})},Usergrid.Folder.prototype=new Usergrid.Entity,Userg
<TRUNCATED>
[11/50] [abbrv] git commit: Merge pull request #73 from
usergrid/usergrid-93
Posted by sn...@apache.org.
Merge pull request #73 from usergrid/usergrid-93
Usergrid 93
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/24425d5e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/24425d5e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/24425d5e
Branch: refs/heads/asyncqueue
Commit: 24425d5e61fabb08e632fcfbdfbb423b7ff6acaa
Parents: 5a7915c e820f5b
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Mar 18 09:05:45 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Mar 18 09:05:45 2014 -0700
----------------------------------------------------------------------
.../lib/usergrid_ironhorse/query.rb | 30 ++++++++++++++------
.../lib/usergrid_ironhorse/version.rb | 2 +-
.../spec/usergrid_ironhorse/base_spec.rb | 8 ++++--
sdks/ruby-on-rails/usergrid_ironhorse.gemspec | 4 +--
4 files changed, 29 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
[30/50] [abbrv] git commit: Added Counters section to readme
Posted by sn...@apache.org.
Added Counters section to readme
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e925cc2f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e925cc2f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e925cc2f
Branch: refs/heads/asyncqueue
Commit: e925cc2f06617c83e986365f1d2b6a18e9196c34
Parents: 63ac9cc
Author: ryan bridges <rb...@apigee.com>
Authored: Fri Mar 21 09:03:45 2014 -0400
Committer: ryan bridges <rb...@apigee.com>
Committed: Fri Mar 21 09:03:45 2014 -0400
----------------------------------------------------------------------
sdks/html5-javascript/README.md | 63 ++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e925cc2f/sdks/html5-javascript/README.md
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/README.md b/sdks/html5-javascript/README.md
index c5699be..6e9f348 100755
--- a/sdks/html5-javascript/README.md
+++ b/sdks/html5-javascript/README.md
@@ -479,6 +479,69 @@ You can also limit the results returned such that only the fields you specify ar
You can find more information on custom queries here:
<http://usergrid.incubator.apache.org/docs/query-language/>
+##Counters
+Counters can be used by an application to create custom statistics, such as how many times an a file has been downloaded or how many instances of an application are in use.
+
+###Create the counter instance
+
+**Note:** The count is not altered upon instantiation
+
+ var counter = new Usergrid.Counter({
+ client: client,
+ data: {
+ category: 'usage',
+ //a timestamp of '0' defaults to the current time
+ timestamp: 0,
+ counters: {
+ running_instances: 0,
+ total_instances: 0
+ }
+ }
+ }, function(err, data) {
+ if (err) {
+ // Error - there was a problem creating the counter
+ } else {
+ // Success - the counter was created properly
+ }
+ });
+
+###Updating counters
+
+When an application starts, we want to increment the 'running_instances' and 'total_instances' counters.
+
+ // add 1 running instance
+ counter.increment({
+ name: 'running_instances',
+ value: 1
+ }, function(err, data) {
+ // ...
+ });
+
+ // add 1 total instance
+ counter.increment({
+ name: 'total_instances',
+ value: 1
+ }, function(err, data) {
+ // ...
+ });
+
+When the application exits, we want to decrement 'running_instances'
+
+ // subtract 1 total instance
+ counter.decrement({
+ name: 'total_instances',
+ value: 1
+ }, function(err, data) {
+ // ...
+ });
+
+Once you have completed your testing, you can reset these values to 0.
+
+ counter.reset({
+ name: 'total_instances'
+ }, function(err, data) {
+ // ...
+ });
##Assets
Assets are used to model binary resources. This can be used by your application to store images and other file types.
[25/50] [abbrv] git commit: Update changelog for 0.10.8
Posted by sn...@apache.org.
Update changelog for 0.10.8
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/840320d1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/840320d1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/840320d1
Branch: refs/heads/asyncqueue
Commit: 840320d184be55f52953208cf8850874a1bcba40
Parents: d9e8698
Author: ryan bridges <rb...@apigee.com>
Authored: Thu Mar 20 16:41:36 2014 -0400
Committer: ryan bridges <rb...@apigee.com>
Committed: Thu Mar 20 16:41:36 2014 -0400
----------------------------------------------------------------------
sdks/html5-javascript/changelog.md | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/840320d1/sdks/html5-javascript/changelog.md
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/changelog.md b/sdks/html5-javascript/changelog.md
index 3abc0f9..4b9003e 100644
--- a/sdks/html5-javascript/changelog.md
+++ b/sdks/html5-javascript/changelog.md
@@ -1,4 +1,10 @@
##Change log
+###0.10.8
+- Added support for Events and Counters
+- Added support for Folders and Assets
+- Improved asynchronous call support
+- Improved callback handling
+- Numerous bug fixes
###0.10.7
- Bug fixes
@@ -7,8 +13,8 @@
- added some methods to pull related data and append to an entity
- helper method to remove an entity from a collection without hitting the database (you would use the .destroy method if you do want to hit the db)
-###0.10.4
-
+###0.10.4
+
- Added new functions for creating, getting, and deleting connections
- Added test cases for said functions
- Added logout call to client create to clear out any remnant token from a past session
[17/50] [abbrv] git commit: Addressed all of Todd’s comments and readded in all integration and commented out tests.
Posted by sn...@apache.org.
Addressed all of Todd’s comments and readded in all integration and commented out tests.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/7b94845f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/7b94845f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/7b94845f
Branch: refs/heads/asyncqueue
Commit: 7b94845fd825d5126fba53f230d0f5094cf30cff
Parents: 4431562
Author: grey <gr...@apigee.com>
Authored: Wed Mar 19 14:56:13 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Wed Mar 19 14:56:13 2014 -0700
----------------------------------------------------------------------
.../applications/ApplicationResource.java | 1 -
stack/services/pom.xml | 3 +
.../management/export/ExportServiceImpl.java | 2 +
.../cassandra/ManagementServiceIT.java | 98 ++++++++++++--------
4 files changed, 66 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7b94845f/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
index 40f5f4d..60ae26a 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationResource.java
@@ -226,7 +226,6 @@ public class ApplicationResource extends AbstractContextResource {
Map<String,Object> properties;
Map<String, Object> storage_info;
-//TODO: do input verification here! make sure json map has all correct values.
try {
if((properties = ( Map<String, Object> ) json.get( "properties" )) == null){
throw new NullPointerException("Could not find 'properties'");
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7b94845f/stack/services/pom.xml
----------------------------------------------------------------------
diff --git a/stack/services/pom.xml b/stack/services/pom.xml
index fd38296..5c31d43 100644
--- a/stack/services/pom.xml
+++ b/stack/services/pom.xml
@@ -156,6 +156,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
+ <accessKey>${aws.s3.key}</accessKey>
+ <secretKey>${aws.s3.secret}</secretKey>
+ <bucketName>${aws.s3.bucket}</bucketName>
<systemPropertyVariables>
<storage-config>${basedir}/src/test/conf</storage-config>
<target.directory>${project.build.directory}</target.directory>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7b94845f/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
index 0a11660..7a114dd 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
@@ -191,6 +191,8 @@ public class ExportServiceImpl implements ExportService {
if(config.get( "organizationId" ) == null){
logger.error( "No organization could be found" );
+ export.setState( Export.State.FAILED );
+ em.update( export );
return;
}
exportApplicationsForOrg( ( UUID ) config.get( "organizationId" ), config, jobExecution );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7b94845f/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index 15ece91..7860847 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -451,7 +451,7 @@ public class ManagementServiceIT {
}
- @Test
+ @Ignore
public void superUserGetOrganizationsPage() throws Exception {
int beforeSize = setup.getMgmtSvc().getOrganizations().size() - 1;
// create 15 orgs
@@ -772,7 +772,7 @@ public class ManagementServiceIT {
try {
f = new File( "testFileConnections.json" );
- f.delete();
+ //f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
@@ -844,17 +844,19 @@ public class ManagementServiceIT {
assertNotNull( objVibrations );
- f.delete();
+ //f.delete();
+ f.deleteOnExit();
+
}
- @Ignore //Connections won't save when run with maven, but on local builds it will.
+ @Test //Connections won't save when run with maven, but on local builds it will.
public void testConnectionsOnApplicationEndpoint() throws Exception {
File f = null;
try {
f = new File( "testConnectionsOnApplicationEndpoint.json" );
- f.delete();
+ //f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
@@ -929,18 +931,20 @@ public class ManagementServiceIT {
assertNotNull( objVibrations );
- f.delete();
+ //f.delete();
+ f.deleteOnExit();
+
}
//
////need to add tests for the other endpoint as well.
- @Ignore
+ @Test
public void testValidityOfCollectionExport() throws Exception {
File f = null;
try {
f = new File( "fileValidity.json" );
- f.delete();
+ //f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
@@ -977,17 +981,19 @@ public class ManagementServiceIT {
org.json.simple.JSONObject entityData = ( JSONObject ) entity.get( "Metadata" );
assertNotNull( entityData );
}
- f.delete();
+ //f.delete();
+ f.deleteOnExit();
+
}
//
- @Ignore
+ @Test
public void testValidityOfApplicationExport() throws Exception {
File f = null;
try {
f = new File( "testValidityOfApplicationExport.json" );
- f.delete();
+ //f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
@@ -1023,10 +1029,12 @@ public class ManagementServiceIT {
org.json.simple.JSONObject entityData = ( JSONObject ) entity.get( "Metadata" );
assertNotNull( entityData );
}
- f.delete();
+ //f.delete();
+ f.deleteOnExit();
+
}
//
- @Ignore
+ @Test
public void testExportOneOrgCollectionEndpoint() throws Exception {
File f = null;
@@ -1034,7 +1042,7 @@ public class ManagementServiceIT {
try {
f = new File( "exportOneOrg.json" );
- f.delete();
+ //f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't then don't do anything and carry on.
@@ -1077,11 +1085,13 @@ public class ManagementServiceIT {
// assertNotEquals( "NotEqual","junkRealName",entityName );
assertFalse( "junkRealName".equals( entityName ) );
}
- f.delete();
+ //f.delete();
+ f.deleteOnExit();
+
}
//
//creation of files doesn't always delete itself
- @Ignore
+ @Test
public void testExportOneAppOnCollectionEndpoint() throws Exception {
File f = null;
@@ -1090,7 +1100,7 @@ public class ManagementServiceIT {
try {
f = new File( "exportOneApp.json" );
- f.delete();
+ //f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't, don't do anything and carry on.
@@ -1144,10 +1154,12 @@ public class ManagementServiceIT {
String entityName = ( String ) entityData.get( "name" );
assertFalse( "junkRealName".equals( entityName ) );
}
- f.delete();
+ f.deleteOnExit();
+
+ //f.delete();
}
//
- @Ignore
+ @Test
public void testExportOneAppOnApplicationEndpoint() throws Exception {
File f = null;
@@ -1156,7 +1168,7 @@ public class ManagementServiceIT {
try {
f = new File( "exportOneApp.json" );
- f.delete();
+ // f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't, don't do anything and carry on.
@@ -1210,10 +1222,12 @@ public class ManagementServiceIT {
String entityName = ( String ) entityData.get( "name" );
assertFalse( "junkRealName".equals( entityName ) );
}
- f.delete();
+ //f.delete();
+ f.deleteOnExit();
+
}
//
- @Ignore
+ @Test
public void testExportOneCollection() throws Exception {
File f = null;
@@ -1221,7 +1235,7 @@ public class ManagementServiceIT {
try {
f = new File( "exportOneCollection.json" );
- f.delete();
+ // f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't, don't do anything and carry on.
@@ -1268,19 +1282,23 @@ public class ManagementServiceIT {
org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
assertEquals( entitiesToCreate , a.size() );
- f.delete();
+ //f.delete();
+ f.deleteOnExit();
+
}
- @Ignore("file created won't be deleted when running tests")
+ //@Ignore("file created won't be deleted when running tests")
+ @Test
public void testExportOneOrganization() throws Exception {
//File f = new File( "exportOneOrganization.json" );
int entitiesToCreate = 123;
File f = null;
+
try {
f = new File( "exportOneOrganization.json" );
- f.delete();
+ // f.delete();
}
catch ( Exception e ) {
//consumed because this checks to see if the file exists. If it doesn't, don't do anything and carry on.
@@ -1351,7 +1369,10 @@ public class ManagementServiceIT {
/*plus 3 for the default roles*/
assertEquals( 23 , a.size() );
- f.delete();
+ f.deleteOnExit();
+
+
+ //f.delete();
}
@Test
@@ -1469,7 +1490,7 @@ public class ManagementServiceIT {
}
- @Ignore //For this test please input your s3 credentials into payload builder.
+ @Test //For this test please input your s3 credentials into payload builder.
public void testIntegration100EntitiesOn() throws Exception {
S3Export s3Export = new S3ExportImpl();
@@ -1487,8 +1508,8 @@ public class ManagementServiceIT {
//creates entities
for ( int i = 0; i < 100; i++ ) {
userProperties = new LinkedHashMap<String, Object>();
- userProperties.put( "username", "billybob" + i );
- userProperties.put( "email", "test" + i + "@anuff.com" );
+ userProperties.put( "username", "bojangles" + i );
+ userProperties.put( "email", "bojangles" + i + "@anuff.com" );
entity[i] = em.create( "user", userProperties );
}
@@ -1508,7 +1529,7 @@ public class ManagementServiceIT {
exportService.doExport( jobExecution );
}
- @Ignore //For this test please input your s3 credentials into payload builder.
+ @Test //For this test please input your s3 credentials into payload builder.
public void testIntegration100EntitiesOnOneOrg() throws Exception {
S3Export s3Export = new S3ExportImpl();
@@ -1521,7 +1542,7 @@ public class ManagementServiceIT {
OrganizationInfo orgMade = null;
ApplicationInfo appMade = null;
for(int i = 0; i < 100; i++) {
- orgMade =setup.getMgmtSvc().createOrganization( "superboss"+i,adminUser,true );
+ orgMade =setup.getMgmtSvc().createOrganization( "minorboss"+i,adminUser,true );
appMade = setup.getMgmtSvc().createApplication( orgMade.getUuid(), "superapp"+i);
EntityManager customMaker = setup.getEmf().getEntityManager( appMade.getId() );
@@ -1547,8 +1568,8 @@ public class ManagementServiceIT {
//creates entities
for ( int i = 0; i < 100; i++ ) {
userProperties = new LinkedHashMap<String, Object>();
- userProperties.put( "username", "billybob" + i );
- userProperties.put( "email", "test" + i + "@anuff.com" );
+ userProperties.put( "username", "bido" + i );
+ userProperties.put( "email", "bido" + i + "@anuff.com" );
entity[i] = em.create( "user", userProperties );
}
@@ -1574,9 +1595,12 @@ public class ManagementServiceIT {
Map<String, Object> properties = new HashMap<String, Object>();
Map<String, Object> storage_info = new HashMap<String, Object>();
// TODO: always put dummy values here and ignore this test.
- storage_info.put( "s3_key", "insert key here" );
- storage_info.put( "s3_access_id", "insert access id here" );
- storage_info.put( "bucket_location", "insert bucket name here" );
+// storage_info.put( "s3_key", "insert key here" );
+// storage_info.put( "s3_access_id", "insert access id here" );
+// storage_info.put( "bucket_location", "insert bucket name here" );
+ storage_info.put( "s3_key", System.getProperty( "secretKey" ) );
+ storage_info.put( "s3_access_id", System.getProperty( "accessKey" ));
+ storage_info.put( "bucket_location", System.getProperty( "bucketName" ) );
properties.put( "storage_provider", "s3" );
properties.put( "storage_info", storage_info );
[16/50] [abbrv] git commit: Merge branch 'master' of
https://github.com/usergrid/usergrid into Export_Persistance_Integration
Posted by sn...@apache.org.
Merge branch 'master' of https://github.com/usergrid/usergrid into Export_Persistance_Integration
# By Shawn Feldman (8) and others
# Via Dave Johnson (5) and others
* 'master' of https://github.com/usergrid/usergrid: (27 commits)
rebuilding artifacts after merge
Test case for default query string options
[DPS-865] Client will accept a 'default_qs' object with the options that will automatically populate the query string for each subsequent request. any query params passed directly to the request method will override these defaults in the event of a conflict.
prepare new version
fix issue with querying specific fields instead of entire object
fix issue with find_by using exclamation point
lock down rails version to 3.2.x
test for names with spaces
fix bug with analytics
reset version number add built files, so site doesn't initially have to be built
removing another reference to angularitics
missed angularitics reference
remove s3 and angularticis
Ignore two-dot-o's ignored files.
Renamed PR to match org.apache
USERGRID-86: Remove restriction on 10 apps in the portal, add build files
USERGRID-86: Remove restriction on 10 apps in the portal
USERGRID-86: Remove restriction on 10 apps in the portal
Fixing regression bug in Assets
Updating build artifacts
...
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/4431562a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/4431562a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/4431562a
Branch: refs/heads/asyncqueue
Commit: 4431562ac799429e8ccbe33b057a48e2181072de
Parents: 5a5644e 24425d5
Author: grey <gr...@apigee.com>
Authored: Wed Mar 19 12:04:48 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Wed Mar 19 12:04:48 2014 -0700
----------------------------------------------------------------------
.gitignore | 9 +-
portal/config.js | 11 +-
portal/index-debug.html | 18 +-
portal/index-template.html | 2 +-
portal/index.html | 18 +-
portal/js/app.js | 7 +-
portal/js/global/page-controller.js | 58 +-
portal/js/global/page-title.html | 2 +-
portal/js/global/ug-service.js | 74 +-
portal/js/libs/usergrid-libs.min.js | 22 +-
portal/js/libs/usergrid.sdk.js | 5 +
portal/js/login/forgot-password-controller.js | 1 -
portal/js/login/login-controller.js | 8 +-
portal/js/login/login.html | 6 +
portal/js/menus/appMenu.html | 7 +-
portal/js/menus/menu-directives.js | 1 -
portal/js/org-overview/org-overview.html | 4 +-
portal/js/templates.js | 57 +-
portal/js/usergrid-dev.min.js | 171 +-
portal/js/usergrid.min.js | 12 +-
portal/js/users/users-feed-controller.js | 29 +
portal/js/users/users-feed.html | 27 +
portal/js/users/users.html | 1 +
portal/package.json | 5 +-
portal/phantomjsdriver.log | 3869 ------------------
portal/seleniumLog.txt | 0
portal/tests/unit/sample.spec.js | 3 +-
sdks/html5-javascript/lib/Usergrid.js | 13 +-
sdks/html5-javascript/lib/modules/Asset.js | 4 +-
sdks/html5-javascript/lib/modules/Client.js | 74 +-
sdks/html5-javascript/lib/modules/Folder.js | 4 +-
sdks/html5-javascript/package.json | 2 +-
sdks/html5-javascript/tests/mocha/test.js | 25 +
sdks/html5-javascript/usergrid.js | 36 +-
sdks/html5-javascript/usergrid.min.js | 6 +-
.../lib/usergrid_ironhorse/query.rb | 30 +-
.../lib/usergrid_ironhorse/version.rb | 2 +-
.../spec/usergrid_ironhorse/base_spec.rb | 8 +-
sdks/ruby-on-rails/usergrid_ironhorse.gemspec | 4 +-
.../1.5.4/AppleJavaExtensions-1.5.4.jar | Bin 0 -> 23531 bytes
.../1.5.4/AppleJavaExtensions-1.5.4.pom | 9 +
.../maven-metadata-local.xml | 12 +
stack/pom.xml | 7 +-
.../services/AbstractCollectionService.java | 3 +
.../RepairingMismatchedApplicationMetadata.java | 73 +
45 files changed, 655 insertions(+), 4084 deletions(-)
----------------------------------------------------------------------
[33/50] [abbrv] git commit: Added @Ignore tag to all integration
tests.
Posted by sn...@apache.org.
Added @Ignore tag to all integration tests.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/86da615b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/86da615b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/86da615b
Branch: refs/heads/asyncqueue
Commit: 86da615b0e1bb076fe8dc9580361b61ea9f6ae45
Parents: 153cf71
Author: grey <gr...@apigee.com>
Authored: Fri Mar 21 12:18:07 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Fri Mar 21 12:18:07 2014 -0700
----------------------------------------------------------------------
.../usergrid/management/cassandra/ManagementServiceIT.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/86da615b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index 0c0e8e1..1edc59e 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -1490,7 +1490,7 @@ public class ManagementServiceIT {
}
- @Test //For this test please input your s3 credentials into payload builder.
+ @Ignore //For this test please input your s3 credentials into settings.xml or Attach a -D with relevant fields.
public void testIntegration100EntitiesOn() throws Exception {
//s3client.putObject(new PutObjectRequest(bucketName, keyName, file));
@@ -1562,8 +1562,7 @@ public class ManagementServiceIT {
assertNotNull( bo );
}
- //@Ignore("I'd have to add some overhead such that I loop through all files or keep track of them all ")
- @Test
+ @Ignore
public void testIntegration100EntitiesOnOneOrg() throws Exception {
S3Export s3Export = new S3ExportImpl();
[07/50] [abbrv] git commit: Partial fix for USERGRID-100: Add the
correct A.L. headers to the ios sdk files.
Posted by sn...@apache.org.
Partial fix for USERGRID-100: Add the correct A.L. headers to the ios sdk files.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/0ec48b49
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/0ec48b49
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/0ec48b49
Branch: refs/heads/asyncqueue
Commit: 0ec48b49a23dc10247ef83a12805e1e50e5e47a5
Parents: 7ea7503
Author: Lieven Govaerts <lg...@mobsol.be>
Authored: Sat Mar 15 20:49:05 2014 +0100
Committer: Lieven Govaerts <lg...@mobsol.be>
Committed: Sat Mar 15 20:49:05 2014 +0100
----------------------------------------------------------------------
sdks/ios/UGAPI/UGActivity.h | 17 +++++++++++++++++
sdks/ios/UGAPI/UGActivity.m | 17 +++++++++++++++++
sdks/ios/UGAPI/UGClient.h | 17 +++++++++++++++++
sdks/ios/UGAPI/UGClient.m | 17 +++++++++++++++++
sdks/ios/UGAPI/UGClientDelegate.h | 17 +++++++++++++++++
sdks/ios/UGAPI/UGClientResponse.h | 17 +++++++++++++++++
sdks/ios/UGAPI/UGClientResponse.m | 17 +++++++++++++++++
sdks/ios/UGAPI/UGHTTPManager.h | 17 +++++++++++++++++
sdks/ios/UGAPI/UGHTTPManager.m | 17 +++++++++++++++++
sdks/ios/UGAPI/UGMultiStepAction.h | 17 +++++++++++++++++
sdks/ios/UGAPI/UGMultiStepAction.m | 17 +++++++++++++++++
sdks/ios/UGAPI/UGQuery.h | 17 +++++++++++++++++
sdks/ios/UGAPI/UGQuery.m | 17 +++++++++++++++++
sdks/ios/UGAPI/UGUser.h | 17 +++++++++++++++++
sdks/ios/UGAPI/UGUser.m | 23 ++++++++++++++++-------
sdks/ios/UGAPIApp/UGAPIApp-Prefix.pch | 17 +++++++++++++++++
sdks/ios/UGAPIApp/UGAppAppDelegate.h | 23 ++++++++++++++++-------
sdks/ios/UGAPIApp/UGAppAppDelegate.m | 23 ++++++++++++++++-------
sdks/ios/UGAPIApp/UGAppViewController.h | 23 ++++++++++++++++-------
sdks/ios/UGAPIApp/UGAppViewController.m | 23 ++++++++++++++++-------
sdks/ios/UGAPIApp/main.m | 23 ++++++++++++++++-------
sdks/ios/UGAPIAppTests/UGAPIAppTests.h | 23 ++++++++++++++++-------
sdks/ios/UGAPIAppTests/UGAPIAppTests.m | 23 ++++++++++++++++-------
23 files changed, 383 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPI/UGActivity.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/UGActivity.h b/sdks/ios/UGAPI/UGActivity.h
index a8b809c..1139518 100755
--- a/sdks/ios/UGAPI/UGActivity.h
+++ b/sdks/ios/UGAPI/UGActivity.h
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
+
#import <Foundation/Foundation.h>
@interface UGActivity : NSObject
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPI/UGActivity.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/UGActivity.m b/sdks/ios/UGAPI/UGActivity.m
index daf9988..3eaea00 100755
--- a/sdks/ios/UGAPI/UGActivity.m
+++ b/sdks/ios/UGAPI/UGActivity.m
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
+
#import "UGActivity.h"
// the way they have set up the object info
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPI/UGClient.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/UGClient.h b/sdks/ios/UGAPI/UGClient.h
index 4358d83..4e6a31f 100755
--- a/sdks/ios/UGAPI/UGClient.h
+++ b/sdks/ios/UGAPI/UGClient.h
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
+
#import <Foundation/Foundation.h>
#import "UGClientResponse.h"
#import "UGQuery.h"
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPI/UGClient.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/UGClient.m b/sdks/ios/UGAPI/UGClient.m
index 4ffc829..9d6407a 100755
--- a/sdks/ios/UGAPI/UGClient.m
+++ b/sdks/ios/UGAPI/UGClient.m
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
+
#import "UGClient.h"
#import "UGHTTPManager.h"
#import "SBJson.h"
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPI/UGClientDelegate.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/UGClientDelegate.h b/sdks/ios/UGAPI/UGClientDelegate.h
index 15a080c..28bc996 100644
--- a/sdks/ios/UGAPI/UGClientDelegate.h
+++ b/sdks/ios/UGAPI/UGClientDelegate.h
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
+
#import <Foundation/Foundation.h>
#import "UGClientResponse.h"
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPI/UGClientResponse.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/UGClientResponse.h b/sdks/ios/UGAPI/UGClientResponse.h
index 3432008..01bc5a1 100755
--- a/sdks/ios/UGAPI/UGClientResponse.h
+++ b/sdks/ios/UGAPI/UGClientResponse.h
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
+
#import <Foundation/Foundation.h>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPI/UGClientResponse.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/UGClientResponse.m b/sdks/ios/UGAPI/UGClientResponse.m
index 6519ef0..dc49fb4 100755
--- a/sdks/ios/UGAPI/UGClientResponse.m
+++ b/sdks/ios/UGAPI/UGClientResponse.m
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
+
#import "UGClientResponse.h"
@implementation UGClientResponse
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPI/UGHTTPManager.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/UGHTTPManager.h b/sdks/ios/UGAPI/UGHTTPManager.h
index 1110d8a..d6c1822 100755
--- a/sdks/ios/UGAPI/UGHTTPManager.h
+++ b/sdks/ios/UGAPI/UGHTTPManager.h
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
+
#import <Foundation/Foundation.h>
enum
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPI/UGHTTPManager.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/UGHTTPManager.m b/sdks/ios/UGAPI/UGHTTPManager.m
index 692f2e7..5d62fe9 100755
--- a/sdks/ios/UGAPI/UGHTTPManager.m
+++ b/sdks/ios/UGAPI/UGHTTPManager.m
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
+
#import "UGHTTPManager.h"
// all transaction IDs are unique across all UGHTTPManagers.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPI/UGMultiStepAction.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/UGMultiStepAction.h b/sdks/ios/UGAPI/UGMultiStepAction.h
index 6fbe888..fbc1259 100755
--- a/sdks/ios/UGAPI/UGMultiStepAction.h
+++ b/sdks/ios/UGAPI/UGMultiStepAction.h
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
+
#import <Foundation/Foundation.h>
// an enumeration for multi-step processes.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPI/UGMultiStepAction.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/UGMultiStepAction.m b/sdks/ios/UGAPI/UGMultiStepAction.m
index 3f5ff69..6a1b7c7 100755
--- a/sdks/ios/UGAPI/UGMultiStepAction.m
+++ b/sdks/ios/UGAPI/UGMultiStepAction.m
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
+
#import "UGMultiStepAction.h"
@implementation UGMultiStepAction
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPI/UGQuery.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/UGQuery.h b/sdks/ios/UGAPI/UGQuery.h
index 0a8c94c..b77e0a4 100755
--- a/sdks/ios/UGAPI/UGQuery.h
+++ b/sdks/ios/UGAPI/UGQuery.h
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
+
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPI/UGQuery.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/UGQuery.m b/sdks/ios/UGAPI/UGQuery.m
index 0dff0f6..740ec5c 100755
--- a/sdks/ios/UGAPI/UGQuery.m
+++ b/sdks/ios/UGAPI/UGQuery.m
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
+
#import "UGQuery.h"
#import "UGHTTPManager.h"
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPI/UGUser.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/UGUser.h b/sdks/ios/UGAPI/UGUser.h
index 6012eb7..58e3b99 100755
--- a/sdks/ios/UGAPI/UGUser.h
+++ b/sdks/ios/UGAPI/UGUser.h
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
+
#import <Foundation/Foundation.h>
@interface UGUser : NSObject
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPI/UGUser.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/UGUser.m b/sdks/ios/UGAPI/UGUser.m
index 6d4ef76..d683b6d 100755
--- a/sdks/ios/UGAPI/UGUser.m
+++ b/sdks/ios/UGAPI/UGUser.m
@@ -1,10 +1,19 @@
-//
-// UGUser.m
-// testproject1
-//
-// Created by Donica Patel on 3/2/12.
-// Copyright (c) 2012 Apigee Corporation. All rights reserved.
-//
+/*
+ * 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.
+ */
#import "UGUser.h"
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPIApp/UGAPIApp-Prefix.pch
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPIApp/UGAPIApp-Prefix.pch b/sdks/ios/UGAPIApp/UGAPIApp-Prefix.pch
index 9cde3b9..b497ab1 100644
--- a/sdks/ios/UGAPIApp/UGAPIApp-Prefix.pch
+++ b/sdks/ios/UGAPIApp/UGAPIApp-Prefix.pch
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
+
//
// Prefix header for all source files of the 'UGAPIApp' target in the 'UGAPIApp' project
//
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPIApp/UGAppAppDelegate.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPIApp/UGAppAppDelegate.h b/sdks/ios/UGAPIApp/UGAppAppDelegate.h
index 0d2f6b4..15c3ced 100644
--- a/sdks/ios/UGAPIApp/UGAppAppDelegate.h
+++ b/sdks/ios/UGAPIApp/UGAppAppDelegate.h
@@ -1,10 +1,19 @@
-//
-// UGAppAppDelegate.h
-// UGAPIApp
-//
-// Created by Ed Anuff on 3/12/12.
-// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
-//
+/*
+ * 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.
+ */
#import <UIKit/UIKit.h>
@class UGHTTPManager;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPIApp/UGAppAppDelegate.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPIApp/UGAppAppDelegate.m b/sdks/ios/UGAPIApp/UGAppAppDelegate.m
index ccff41f..2e7d6de 100644
--- a/sdks/ios/UGAPIApp/UGAppAppDelegate.m
+++ b/sdks/ios/UGAPIApp/UGAppAppDelegate.m
@@ -1,10 +1,19 @@
-//
-// UGAppAppDelegate.m
-// UGAPIApp
-//
-// Created by Ed Anuff on 3/12/12.
-// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
-//
+/*
+ * 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.
+ */
#import "UGAppAppDelegate.h"
#import "UGHTTPManager.h"
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPIApp/UGAppViewController.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPIApp/UGAppViewController.h b/sdks/ios/UGAPIApp/UGAppViewController.h
index 24b104e..9846c31 100644
--- a/sdks/ios/UGAPIApp/UGAppViewController.h
+++ b/sdks/ios/UGAPIApp/UGAppViewController.h
@@ -1,10 +1,19 @@
-//
-// UGAppViewController.h
-// UGAPIApp
-//
-// Created by Ed Anuff on 3/12/12.
-// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
-//
+/*
+ * 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.
+ */
#import <UIKit/UIKit.h>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPIApp/UGAppViewController.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPIApp/UGAppViewController.m b/sdks/ios/UGAPIApp/UGAppViewController.m
index 2dddf84..b7c5424 100644
--- a/sdks/ios/UGAPIApp/UGAppViewController.m
+++ b/sdks/ios/UGAPIApp/UGAppViewController.m
@@ -1,10 +1,19 @@
-//
-// UGAppViewController.m
-// UGAPIApp
-//
-// Created by Ed Anuff on 3/12/12.
-// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
-//
+/*
+ * 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.
+ */
#import "UGAppViewController.h"
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPIApp/main.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPIApp/main.m b/sdks/ios/UGAPIApp/main.m
index 3848b41..f547811 100644
--- a/sdks/ios/UGAPIApp/main.m
+++ b/sdks/ios/UGAPIApp/main.m
@@ -1,10 +1,19 @@
-//
-// main.m
-// UGAPIApp
-//
-// Created by Ed Anuff on 3/12/12.
-// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
-//
+/*
+ * 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.
+ */
#import <UIKit/UIKit.h>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPIAppTests/UGAPIAppTests.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPIAppTests/UGAPIAppTests.h b/sdks/ios/UGAPIAppTests/UGAPIAppTests.h
index 6de8009..abaf125 100644
--- a/sdks/ios/UGAPIAppTests/UGAPIAppTests.h
+++ b/sdks/ios/UGAPIAppTests/UGAPIAppTests.h
@@ -1,10 +1,19 @@
-//
-// UGAPIAppTests.h
-// UGAPIAppTests
-//
-// Created by Ed Anuff on 3/12/12.
-// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
-//
+/*
+ * 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.
+ */
#import <SenTestingKit/SenTestingKit.h>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ec48b49/sdks/ios/UGAPIAppTests/UGAPIAppTests.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPIAppTests/UGAPIAppTests.m b/sdks/ios/UGAPIAppTests/UGAPIAppTests.m
index 4a657de..0cda4c0 100644
--- a/sdks/ios/UGAPIAppTests/UGAPIAppTests.m
+++ b/sdks/ios/UGAPIAppTests/UGAPIAppTests.m
@@ -1,10 +1,19 @@
-//
-// UGAPIAppTests.m
-// UGAPIAppTests
-//
-// Created by Ed Anuff on 3/12/12.
-// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
-//
+/*
+ * 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.
+ */
#import "UGAPIAppTests.h"
[20/50] [abbrv] git commit: Removed thread waiting in favor of the
get state command.
Posted by sn...@apache.org.
Removed thread waiting in favor of the get state command.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/79dc2c54
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/79dc2c54
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/79dc2c54
Branch: refs/heads/asyncqueue
Commit: 79dc2c5402c3f2cc8e6f48fd5ad5c93695492dea
Parents: a1b6124
Author: grey <gr...@apigee.com>
Authored: Wed Mar 19 16:33:55 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Wed Mar 19 16:33:55 2014 -0700
----------------------------------------------------------------------
.../apache/usergrid/management/cassandra/ManagementServiceIT.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/79dc2c54/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index 310d46a..44e0277 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -1517,7 +1517,7 @@ public class ManagementServiceIT {
when( jobExecution.getJobData() ).thenReturn( jobData );
exportService.doExport( jobExecution );
- Thread.sleep(1000);
+ while (!exportService.getState( applicationId,exportUUID ).equals("FINISHED"));
AWSCredentials myCredentials = new BasicAWSCredentials(
System.getProperty( "accessKey" ), System.getProperty("secretKey"));
@@ -1592,6 +1592,7 @@ public class ManagementServiceIT {
when( jobExecution.getJobData() ).thenReturn( jobData );
exportService.doExport( jobExecution );
+ while (!exportService.getState( applicationId,exportUUID ).equals("FINISHED"));
AWSCredentials myCredentials = new BasicAWSCredentials(
System.getProperty( "accessKey" ), System.getProperty("secretKey"));
[04/50] [abbrv] git commit: [DPS-865] Client will accept a
'default_qs' object with the options that will automatically populate the
query string for each subsequent request. any query params passed directly to
the request method will override these defa
Posted by sn...@apache.org.
[DPS-865] Client will accept a 'default_qs' object with the options that will automatically populate the query string for each subsequent request. any query params passed directly to the request method will override these defaults in the event of a conflict.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/00afe2c1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/00afe2c1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/00afe2c1
Branch: refs/heads/asyncqueue
Commit: 00afe2c166956681c1c1145989ca9d83942b63f8
Parents: dee2ca9
Author: ryan bridges <rb...@apigee.com>
Authored: Thu Mar 13 09:08:24 2014 -0400
Committer: ryan bridges <rb...@apigee.com>
Committed: Thu Mar 13 10:28:48 2014 -0400
----------------------------------------------------------------------
sdks/html5-javascript/lib/Usergrid.js | 13 ++++++++++++-
sdks/html5-javascript/lib/modules/Client.js | 10 ++++++++--
2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/00afe2c1/sdks/html5-javascript/lib/Usergrid.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/lib/Usergrid.js b/sdks/html5-javascript/lib/Usergrid.js
index a4dbe9b..2595e7c 100644
--- a/sdks/html5-javascript/lib/Usergrid.js
+++ b/sdks/html5-javascript/lib/Usergrid.js
@@ -40,7 +40,18 @@ function extend(subClass, superClass) {
}
return subClass;
}
-
+function propCopy(from, to){
+ for(var prop in from){
+ if(from.hasOwnProperty(prop)){
+ if("object"===typeof from[prop] && "object"===typeof to[prop]){
+ to[prop]=propCopy(from[prop], to[prop]);
+ }else{
+ to[prop]=from[prop];
+ }
+ }
+ }
+ return to;
+}
function NOOP(){}
//Usergrid namespace encapsulates this SDK
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/00afe2c1/sdks/html5-javascript/lib/modules/Client.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/lib/modules/Client.js b/sdks/html5-javascript/lib/modules/Client.js
index 38db3b1..242b08b 100644
--- a/sdks/html5-javascript/lib/modules/Client.js
+++ b/sdks/html5-javascript/lib/modules/Client.js
@@ -12,7 +12,9 @@
if (options.appName) {
this.set('appName', options.appName);
}
-
+ if(options.qs){
+ this.setObject('default_qs', options.qs);
+ }
//other options
this.buildCurl = options.buildCurl || false;
this.logging = options.logging || false;
@@ -48,6 +50,7 @@
var mQuery = options.mQuery || false; //is this a query to the management endpoint?
var orgName = this.get('orgName');
var appName = this.get('appName');
+ var default_qs=this.get('default_qs');
var uri;
var logoutCallback=function(){
if (typeof(this.logoutCallback) === 'function') {
@@ -69,6 +72,9 @@
xhr.withCredentials = true;
*/
}
+ if(default_qs){
+ qs=propCopy(qs, default_qs);
+ }
var req = new Usergrid.Request(method, uri, qs, body, function (err, response) {
if ([
"auth_expired_session_token",
@@ -238,7 +244,7 @@
*/
Usergrid.Client.prototype.createCollection = function (options, callback) {
options.client = this;
- var collection = new Usergrid.Collection(options, function(err, data) {
+ new Usergrid.Collection(options, function(err, data, collection) {
doCallback(callback, [err, collection, data]);
});
};
[26/50] [abbrv] git commit: Adding basic asset documentation to README
Posted by sn...@apache.org.
Adding basic asset documentation to README
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/a96c3ac9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/a96c3ac9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/a96c3ac9
Branch: refs/heads/asyncqueue
Commit: a96c3ac90489142e090d4c269eb8fa826386b480
Parents: 840320d
Author: ryan bridges <rb...@apigee.com>
Authored: Thu Mar 20 12:04:23 2014 -0400
Committer: ryan bridges <rb...@apigee.com>
Committed: Thu Mar 20 16:42:07 2014 -0400
----------------------------------------------------------------------
sdks/html5-javascript/README.md | 113 +++++++++++++++++++++++++++++------
1 file changed, 95 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a96c3ac9/sdks/html5-javascript/README.md
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/README.md b/sdks/html5-javascript/README.md
index cfba38c..2d7bdf6 100755
--- a/sdks/html5-javascript/README.md
+++ b/sdks/html5-javascript/README.md
@@ -8,7 +8,7 @@ Detailed instructions follow but if you just want a quick example of how to get
<!-- Don't forget to include the SDK -->
<script src="https://apigee.com/usergrid/sdk/usergrid.0.10.8.js"></script>
<!-- If you prefer a local copy, you can find the file at the root the SDK’s github repo
- github.com/apigee/usergrid-javascript-sdk -->
+ github.com/apigee/usergrid-javascript-sdk -->
<script type="text/javascript">
@@ -29,15 +29,15 @@ Detailed instructions follow but if you just want a quick example of how to get
client.createCollection(options, function (err, collection) {
books = collection;
- if (err) {
- alert("Couldn't get the list of books.");
- } else {
- while(books.hasNextEntity()) {
- var book = books.getNextEntity();
- alert(book.get("title")); // Output the title of the book
- }
- }
- });
+ if (err) {
+ alert("Couldn't get the list of books.");
+ } else {
+ while(books.hasNextEntity()) {
+ var book = books.getNextEntity();
+ alert(book.get("title")); // Output the title of the book
+ }
+ }
+ });
// Uncomment the next 4 lines if you want to write data
@@ -69,7 +69,7 @@ Or just open github issues.
##Overview
-This open source SDK simplifies writing JavaScript / HTML5 applications that connect to App Services. The repo is located here:
+This open source SDK simplifies writing JavaScript / HTML5 applications that connect to Usergrid. The repo is located here:
<https://github.com/usergrid/usergrid/tree/master/sdks/html5-javascript>
@@ -80,13 +80,13 @@ You can download this package here:
The Javascript SDK is in the sdks/html5-javascript folder.
-To find out more about Apigee App Services, see:
+To find out more about Usergrid, see:
-<http://developers.apigee.com>
+<http://usergrid.incubator.apache.org>
-To view the Apigee App Services documentation, see:
+To view the Usergrid documentation, see:
-<http://apigee.com/docs/app_services>
+<http://usergrid.incubator.apache.org/docs/>
##Node.js
@@ -478,7 +478,83 @@ You can also limit the results returned such that only the fields you specify ar
You can find more information on custom queries here:
-<http://apigee.com/docs/usergrid/content/queries-and-parameters>
+<http://usergrid.incubator.apache.org/docs/query-language/>
+
+##Assets
+Assets are used to model binary resources. This can be used by your application to store images and other file types.
+
+####Creating an asset
+
+An asset is created in the same manner as any Usergrid entity
+
+ var imageName='test_image.jpg';
+ var options = {
+ type:'asset',
+ name:imageName,
+ path: '/uploads/'+imageName,
+ owner:user.get("uuid")
+ };
+
+ var asset=new Usergrid.Asset(
+ {client:client, data:options},
+ function(err, asset){
+ if (err) {
+ // Error - there was a problem creating the asset
+ } else {
+ // Success - the asset was created properly
+ }
+ });
+###Adding data
+
+You can upload data to your asset from a File input or by retrieving it via another request.
+**Note:** Due to security concerns, you cannot browse and select a file programmatically from the local filesystem via javascript
+
+On your page, you would have an input element:
+
+ <input type="file" id="upload"/>
+
+Once a file is selected, read the data and upload it to the asset.
+
+ var files = document.getElementById('upload').files;
+ if(files.length===0){
+ //No files have been selected
+ }else{
+ //take the first file off the front of the array
+ var file=files.unshift();
+ asset.upload(file, function(err, asset){
+ if (err) {
+ // Error - there was a problem uploading the data
+ } else {
+ // Success - the data was uploaded successfully
+ }
+ })
+ }
+
+To retrieve the data and display it via HTML
+
+ asset.download(function(err, file){
+ if (err) {
+ // Error - there was a problem retrieving the data
+ } else {
+ // Success - the entity was found
+ // and retrieved by the Apigee API
+
+ // Create an image tag to hold our downloaded image data
+ var img = document.createElement("img");
+ // Create a FileReader to feed the image
+ // into our newly-created element
+ var reader = new FileReader();
+ reader.onload = (function(aImg) {
+ return function(e) {
+ aImg.src = e.target.result;
+ };
+ })(img);
+ reader.readAsDataURL(file);
+ // Append the img element to our page
+ document.body.appendChild(img);
+ }
+ })
+
##Modeling users with the entity object
@@ -613,7 +689,7 @@ This creates a one-way connection between marty and einstein, where marty "likes
Complete documentation on the entity relationships API can be found here:
-<http://apigee.com/docs/usergrid/content/entity-relationships>
+<http://usergrid.incubator.apache.org/docs/relationships/>
For example, say we have a new dog named einstein:
@@ -812,10 +888,11 @@ Like [Usergrid](https://github.com/apigee/usergrid-node-module), the Usergrid Ja
5. Create new Pull Request (make sure you describe what you did and why your mod is needed).
##More information
+For more information on Usergrid, visit <http://usergrid.incubator.apache.org/>.
For more information on Apigee App Services, visit <http://developers.apigee.com>.
## Copyright
-Copyright 2013 Apigee Corporation
+Copyright 2014 Apigee Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
[13/50] [abbrv] git commit: Fixed test to prove issue.
Posted by sn...@apache.org.
Fixed test to prove issue.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/57173521
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/57173521
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/57173521
Branch: refs/heads/asyncqueue
Commit: 57173521982af5199e071320a38d373d566af5ab
Parents: 9baec83
Author: grey <gr...@apigee.com>
Authored: Wed Mar 19 09:45:29 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Wed Mar 19 09:45:29 2014 -0700
----------------------------------------------------------------------
.../management/cassandra/ManagementServiceIT.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/57173521/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index 59ce4ad..39ba732 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -1275,7 +1275,7 @@ public class ManagementServiceIT {
public void testExportOneOrganization() throws Exception {
//File f = new File( "exportOneOrganization.json" );
- int entitiesToCreate = 10000;
+ int entitiesToCreate = 10;
File f = null;
try {
@@ -1307,7 +1307,6 @@ public class ManagementServiceIT {
payload.put( "organizationId",organization.getUuid() );
payload.put( "applicationId",applicationId);
- payload.put( "collectionName","baconators");
//creates 100s of organizations with some entities in each one to make sure we don't actually apply it
for(int i = 0; i < 100; i++) {
@@ -1323,9 +1322,9 @@ public class ManagementServiceIT {
//creates entities
for ( int index = 0; index < 10; index++ ) {
entityLevelProperties = new LinkedHashMap<String, Object>();
- entityLevelProperties.put( "username", "bobso" + i );
- entityLevelProperties.put( "email", "derp" + i + "@anuff.com" );
- entNotCopied[i] = customMaker.create( "superappCol", entityLevelProperties );
+ entityLevelProperties.put( "username", "bobso" + index );
+ entityLevelProperties.put( "email", "derp" + index + "@anuff.com" );
+ entNotCopied[index] = customMaker.create( "superappCol", entityLevelProperties );
}
}
@@ -1346,7 +1345,8 @@ public class ManagementServiceIT {
org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
- assertEquals( entitiesToCreate , a.size() );
+ /*plus 3 for the default roles*/
+ assertEquals( entitiesToCreate+3 , a.size() );
f.delete();
}
[06/50] [abbrv] git commit: rebuilding artifacts after merge
Posted by sn...@apache.org.
rebuilding artifacts after merge
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/13ab2bd2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/13ab2bd2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/13ab2bd2
Branch: refs/heads/asyncqueue
Commit: 13ab2bd2e770543c1f35e6243ea5c732fa3d6a4e
Parents: 55462ea
Author: ryan bridges <rb...@apigee.com>
Authored: Thu Mar 13 10:30:32 2014 -0400
Committer: ryan bridges <rb...@apigee.com>
Committed: Thu Mar 13 10:30:32 2014 -0400
----------------------------------------------------------------------
sdks/html5-javascript/usergrid.js | 24 ++++++++++++++++++++++--
sdks/html5-javascript/usergrid.min.js | 6 +++---
2 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/13ab2bd2/sdks/html5-javascript/usergrid.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/usergrid.js b/sdks/html5-javascript/usergrid.js
index 517908f..cb83d0c 100644
--- a/sdks/html5-javascript/usergrid.js
+++ b/sdks/html5-javascript/usergrid.js
@@ -1,4 +1,4 @@
-/*! usergrid@0.10.8 2014-03-05 */
+/*! usergrid@0.10.8 2014-03-13 */
var UsergridEventable = function() {
throw Error("'UsergridEventable' is not intended to be invoked directly");
};
@@ -293,6 +293,19 @@ function extend(subClass, superClass) {
return subClass;
}
+function propCopy(from, to) {
+ for (var prop in from) {
+ if (from.hasOwnProperty(prop)) {
+ if ("object" === typeof from[prop] && "object" === typeof to[prop]) {
+ to[prop] = propCopy(from[prop], to[prop]);
+ } else {
+ to[prop] = from[prop];
+ }
+ }
+ }
+ return to;
+}
+
function NOOP() {}
//Usergrid namespace encapsulates this SDK
@@ -563,6 +576,9 @@ function doCallback(callback, params, context) {
if (options.appName) {
this.set("appName", options.appName);
}
+ if (options.qs) {
+ this.setObject("default_qs", options.qs);
+ }
//other options
this.buildCurl = options.buildCurl || false;
this.logging = options.logging || false;
@@ -598,6 +614,7 @@ function doCallback(callback, params, context) {
//is this a query to the management endpoint?
var orgName = this.get("orgName");
var appName = this.get("appName");
+ var default_qs = this.getObject("default_qs");
var uri;
var logoutCallback = function() {
if (typeof this.logoutCallback === "function") {
@@ -615,6 +632,9 @@ function doCallback(callback, params, context) {
if (this.getToken()) {
qs.access_token = this.getToken();
}
+ if (default_qs) {
+ qs = propCopy(qs, default_qs);
+ }
var req = new Usergrid.Request(method, uri, qs, body, function(err, response) {
if ([ "auth_expired_session_token", "auth_missing_credentials", "auth_unverified_oath", "expired_token", "unauthorized", "auth_invalid" ].indexOf(response.error) !== -1) {
return logoutCallback();
@@ -767,7 +787,7 @@ function doCallback(callback, params, context) {
*/
Usergrid.Client.prototype.createCollection = function(options, callback) {
options.client = this;
- var collection = new Usergrid.Collection(options, function(err, data) {
+ new Usergrid.Collection(options, function(err, data, collection) {
doCallback(callback, [ err, collection, data ]);
});
};
[12/50] [abbrv] git commit: Fixed multiple orbs being exported bug.
Added test proving issue.
Posted by sn...@apache.org.
Fixed multiple orbs being exported bug.
Added test proving issue.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/9baec839
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/9baec839
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/9baec839
Branch: refs/heads/asyncqueue
Commit: 9baec8397933ec6fadcfd39247a8c723778f9ff0
Parents: 63fb1ca
Author: grey <gr...@apigee.com>
Authored: Wed Mar 19 09:31:31 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Wed Mar 19 09:31:31 2014 -0700
----------------------------------------------------------------------
.../management/export/ExportServiceImpl.java | 57 ++-----------
.../cassandra/ManagementServiceIT.java | 84 +++++++++++++++++++-
2 files changed, 90 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9baec839/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
index bab5660..0a11660 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/export/ExportServiceImpl.java
@@ -22,7 +22,6 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -39,7 +38,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.apache.usergrid.batch.JobExecution;
import org.apache.usergrid.batch.service.SchedulerService;
import org.apache.usergrid.management.ManagementService;
-import org.apache.usergrid.management.OrganizationInfo;
import org.apache.usergrid.persistence.ConnectionRef;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.persistence.EntityManager;
@@ -190,20 +188,13 @@ public class ExportServiceImpl implements ExportService {
if ( config.get("collectionName") == null) {
//exports all the applications for a given organization.
- Map<UUID, String> organizations = getOrgs();
- if(organizations == null){
- logger.error( "No organizations could be found" );
+
+ if(config.get( "organizationId" ) == null){
+ logger.error( "No organization could be found" );
return;
}
- for ( Map.Entry<UUID, String> organization : organizations.entrySet() ) {
- try {
- exportApplicationsForOrg( organization, config, jobExecution );
- }catch ( Exception e ) {
- export.setState( Export.State.FAILED );
- em.update( export );
- return;
- }
- }
+ exportApplicationsForOrg( ( UUID ) config.get( "organizationId" ), config, jobExecution );
+
}
else {
try {
@@ -222,36 +213,6 @@ public class ExportServiceImpl implements ExportService {
}
- /**
- * Loops through all the organizations and returns a Map with the corresponding information
- * @param
- * @return Map<UUID, String>
- * @throws Exception
- */
- private Map<UUID, String> getOrgs() throws Exception {
- // Loop through the organizations
- UUID orgId = null;
-
- Map<UUID, String> organizationNames = null;
-
- if ( orgId == null ) {
- organizationNames = managementService.getOrganizations();
- }
-
- else {//this case isn't used yet, but might be in the future.
- OrganizationInfo info = managementService.getOrganizationByUuid( orgId );
-
- if ( info == null ) {
- logger.error( "Organization info is null!" );
- return null;
- }
-
- organizationNames = new HashMap<UUID, String>();
- organizationNames.put( orgId, info.getName() );
- }
-
- return organizationNames;
- }
public SchedulerService getSch() {
return sch;
@@ -285,12 +246,12 @@ public class ExportServiceImpl implements ExportService {
/**
* Exports all applications for the given organization.
- * @param organization
+ * @param organizationUUID
* @param config
* @param jobExecution
* @throws Exception
*/
- private void exportApplicationsForOrg( Map.Entry<UUID, String> organization, final Map<String,Object> config,
+ private void exportApplicationsForOrg( UUID organizationUUID, final Map<String,Object> config,
final JobExecution jobExecution ) throws Exception {
//retrieves export entity
@@ -301,10 +262,8 @@ public class ExportServiceImpl implements ExportService {
//sets up a output stream for s3 backup.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- logger.info( "" + organization );
-
// Loop through the applications per organization
- BiMap<UUID, String> applications = managementService.getApplicationsForOrganization( organization.getKey() );
+ BiMap<UUID, String> applications = managementService.getApplicationsForOrganization( organizationUUID );
for ( Map.Entry<UUID, String> application : applications.entrySet() ) {
logger.info( application.getValue() + " : " + application.getKey() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9baec839/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index 9757546..59ce4ad 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -43,6 +43,7 @@ import org.apache.usergrid.cassandra.CassandraResource;
import org.apache.usergrid.cassandra.ClearShiroSubject;
import org.apache.usergrid.cassandra.Concurrent;
import org.apache.usergrid.count.SimpleBatcher;
+import org.apache.usergrid.management.ApplicationInfo;
import org.apache.usergrid.management.OrganizationInfo;
import org.apache.usergrid.management.UserInfo;
import org.apache.usergrid.management.export.ExportJob;
@@ -1271,6 +1272,85 @@ public class ManagementServiceIT {
}
@Test
+ public void testExportOneOrganization() throws Exception {
+
+ //File f = new File( "exportOneOrganization.json" );
+ int entitiesToCreate = 10000;
+ File f = null;
+
+ try {
+ f = new File( "exportOneOrganization.json" );
+ f.delete();
+ }
+ catch ( Exception e ) {
+ //consumed because this checks to see if the file exists. If it doesn't, don't do anything and carry on.
+ }
+
+ EntityManager em = setup.getEmf().getEntityManager( applicationId);
+ em.createApplicationCollection( "baconators" );
+ //intialize user object to be posted
+ Map<String, Object> userProperties = null;
+ Entity[] entity;
+ entity = new Entity[entitiesToCreate];
+ //creates entities
+ for ( int i = 0; i < entitiesToCreate; i++ ) {
+ userProperties = new LinkedHashMap<String, Object>();
+ userProperties.put( "username", "billybob" + i );
+ userProperties.put( "email", "test" + i + "@anuff.com" );//String.format( "test%i@anuff.com", i ) );
+ entity[i] = em.create( "baconators", userProperties );
+ }
+
+ S3Export s3Export = new MockS3ExportImpl();
+ s3Export.setFilename( "exportOneOrganization.json" );
+ ExportService exportService = setup.getExportService();
+ HashMap<String, Object> payload = payloadBuilder();
+
+ payload.put( "organizationId",organization.getUuid() );
+ payload.put( "applicationId",applicationId);
+ payload.put( "collectionName","baconators");
+
+ //creates 100s of organizations with some entities in each one to make sure we don't actually apply it
+ for(int i = 0; i < 100; i++) {
+ OrganizationInfo orgMade =setup.getMgmtSvc().createOrganization( "superboss"+i,adminUser,true );
+ ApplicationInfo appMade = setup.getMgmtSvc().createApplication( orgMade.getUuid(), "superapp"+i);
+
+ EntityManager customMaker = setup.getEmf().getEntityManager( appMade.getId() );
+ customMaker.createApplicationCollection( "superappCol"+i );
+ //intialize user object to be posted
+ Map<String, Object> entityLevelProperties = null;
+ Entity[] entNotCopied;
+ entNotCopied = new Entity[entitiesToCreate];
+ //creates entities
+ for ( int index = 0; index < 10; index++ ) {
+ entityLevelProperties = new LinkedHashMap<String, Object>();
+ entityLevelProperties.put( "username", "bobso" + i );
+ entityLevelProperties.put( "email", "derp" + i + "@anuff.com" );
+ entNotCopied[i] = customMaker.create( "superappCol", entityLevelProperties );
+ }
+ }
+
+ UUID exportUUID = exportService.schedule( payload );
+ exportService.setS3Export( s3Export );
+
+ JobData jobData = new JobData();
+ jobData.setProperty( "jobName", "exportJob" );
+ jobData.setProperty( "exportInfo", payload );
+ jobData.setProperty( "exportId", exportUUID );
+
+ JobExecution jobExecution = mock( JobExecution.class );
+ when( jobExecution.getJobData() ).thenReturn( jobData );
+
+ exportService.doExport( jobExecution );
+
+ JSONParser parser = new JSONParser();
+
+ org.json.simple.JSONArray a = ( org.json.simple.JSONArray ) parser.parse( new FileReader( f ) );
+
+ assertEquals( entitiesToCreate , a.size() );
+ f.delete();
+ }
+
+ @Test
public void testExportDoJob() throws Exception {
HashMap<String, Object> payload = payloadBuilder();
@@ -1392,6 +1472,7 @@ public class ManagementServiceIT {
ExportService exportService = setup.getExportService();
HashMap<String, Object> payload = payloadBuilder();
+ payload.put("organizationId",organization.getUuid());
payload.put("applicationId",applicationId);
EntityManager em = setup.getEmf().getEntityManager( applicationId );
@@ -1403,7 +1484,7 @@ public class ManagementServiceIT {
for ( int i = 0; i < 100; i++ ) {
userProperties = new LinkedHashMap<String, Object>();
userProperties.put( "username", "billybob" + i );
- userProperties.put( "email", "test" + i + "@anuff.com" );//String.format( "test%i@anuff.com", i ) );
+ userProperties.put( "email", "test" + i + "@anuff.com" );
entity[i] = em.create( "user", userProperties );
}
@@ -1423,7 +1504,6 @@ public class ManagementServiceIT {
exportService.doExport( jobExecution );
}
-
/*Creates fake payload for testing purposes.*/
public HashMap<String, Object> payloadBuilder() {
HashMap<String, Object> payload = new HashMap<String, Object>();
[08/50] [abbrv] git commit: For USERGRID-100,
add a NOTICE file and update LICENSE for the SBJson and SSKeychain
components in the iOS SDK..
Posted by sn...@apache.org.
For USERGRID-100, add a NOTICE file and update LICENSE for the SBJson and SSKeychain components in the iOS SDK..
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e02f3cf9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e02f3cf9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e02f3cf9
Branch: refs/heads/asyncqueue
Commit: e02f3cf9ffbac8bffa4906c37d050c2a38578645
Parents: 0ec48b4
Author: Lieven Govaerts <lg...@mobsol.be>
Authored: Sat Mar 15 21:28:58 2014 +0100
Committer: Lieven Govaerts <lg...@mobsol.be>
Committed: Sat Mar 15 21:28:58 2014 +0100
----------------------------------------------------------------------
LICENSE | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
NOTICE | 11 ++++++++++
2 files changed, 75 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e02f3cf9/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
index 7a4a3ea..9fc77ee 100644
--- a/LICENSE
+++ b/LICENSE
@@ -199,4 +199,67 @@
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.
\ No newline at end of file
+ limitations under the License.
+
+
+USERGRID SUBCOMPONENTS
+
+The Usergrid software includes a number of subcomponents with separate
+copyrights and license terms. Your use of the source code for these
+subcomponents is subject to the terms and conditions of the following
+licenses.
+
+IOS SDK
+-------
+For the SBJson component:
+
+ Copyright (C) 2009-2011 Stig Brautaset. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of the author nor the names of its contributors may be used
+ to endorse or promote products derived from this software without specific
+ prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+For the SSKeychain component:
+
+ Copyright (c) 2010-2014 Sam Soffes, http://soff.es
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e02f3cf9/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..ae48093
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,11 @@
+Apache Usergrid_
+Copyright 2014 The Apache Software Foundation.
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+This product bundles SBJson, which is available under a "3-clause BSD" license.
+For details, see sdks/ios/UGAPI/SBJson/ .
+
+This product bundles SSKeychain, which is available under a "MIT/X11" license.
+For details, see sdks/ios/UGAPI/SSKeychain/.
[48/50] [abbrv] git commit: Merge branch 'asyncqueue' into two-dot-o
Posted by sn...@apache.org.
Merge branch 'asyncqueue' into two-dot-o
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/17c2ac42
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/17c2ac42
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/17c2ac42
Branch: refs/heads/asyncqueue
Commit: 17c2ac42f1ad0b1523a42d0105a67cbfe5566dc4
Parents: b516f57 5ded6b5
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Mar 26 13:43:59 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Mar 26 13:43:59 2014 -0700
----------------------------------------------------------------------
stack/corepersistence/collection/pom.xml | 13 +
.../collection/guice/CollectionModule.java | 8 +-
.../impl/EntityCollectionManagerImpl.java | 19 +-
.../mvcc/stage/write/WriteUniqueVerify.java | 14 +-
.../collection/rx/CassandraThreadScheduler.java | 107 --
.../persistence/collection/rx/RxFig.java | 42 -
.../stage/write/WriteUniqueVerifyStageTest.java | 3 +-
.../mvcc/stage/write/WriteUniqueVerifyTest.java | 6 +-
.../rx/CassandraThreadSchedulerTest.java | 413 -----
.../persistence/collection/rx/ParallelTest.java | 6 +-
.../usergrid/persistence/graph/EdgeManager.java | 163 --
.../persistence/graph/EdgeManagerFactory.java | 40 -
.../usergrid/persistence/graph/GraphFig.java | 39 +-
.../persistence/graph/GraphManager.java | 169 ++
.../persistence/graph/GraphManagerFactory.java | 40 +
.../graph/consistency/AsyncProcessorImpl.java | 48 +-
.../graph/consistency/TimeoutTask.java | 2 +-
.../persistence/graph/guice/EdgeWrite.java | 37 -
.../persistence/graph/guice/GraphModule.java | 14 +-
.../graph/hystrix/HystrixGraphObservable.java | 71 +
.../graph/impl/CollectionIndexObserver.java | 14 +-
.../graph/impl/EdgeDeleteListener.java | 68 +-
.../persistence/graph/impl/EdgeManagerImpl.java | 408 -----
.../graph/impl/EdgeWriteListener.java | 103 --
.../graph/impl/GraphManagerImpl.java | 384 +++++
.../graph/impl/NodeDeleteListener.java | 216 ++-
.../graph/impl/SimpleSearchByEdgeType.java | 38 +
.../graph/impl/stage/AbstractEdgeRepair.java | 47 +-
.../graph/impl/stage/EdgeDeleteRepairImpl.java | 4 +-
.../graph/impl/stage/EdgeMetaRepairImpl.java | 33 +-
.../graph/impl/stage/EdgeWriteRepair.java | 44 -
.../graph/impl/stage/EdgeWriteRepairImpl.java | 76 -
.../graph/serialization/EdgeSerialization.java | 12 +-
.../impl/EdgeMetadataSerializationImpl.java | 19 +-
.../impl/EdgeSerializationImpl.java | 256 +--
.../impl/parse/ColumnNameIterator.java | 38 +-
.../impl/parse/ObservableIterator.java | 26 +-
.../persistence/graph/EdgeManagerIT.java | 1468 -----------------
.../graph/EdgeManagerStressTest.java | 313 ----
.../persistence/graph/GraphManagerIT.java | 1497 ++++++++++++++++++
.../graph/GraphManagerStressTest.java | 317 ++++
.../graph/GraphManagerTimeoutIT.java | 230 +++
.../graph/consistency/AsyncProcessorTest.java | 25 +-
.../consistency/LocalTimeoutQueueTest.java | 2 +-
.../graph/guice/TestGraphModule.java | 4 +-
.../graph/impl/NodeDeleteListenerTest.java | 221 ++-
.../graph/impl/stage/EdgeDeleteRepairTest.java | 6 +-
.../graph/impl/stage/EdgeMetaRepairTest.java | 83 +-
.../graph/impl/stage/EdgeWriteRepairTest.java | 220 ---
.../EdgeSerializationChopTest.java | 35 +-
.../serialization/EdgeSerializationTest.java | 206 ++-
.../serialization/NodeSerializationTest.java | 13 +-
.../graph/serialization/TestCount.java | 125 ++
.../serialization/util/EdgeHasherTest.java | 14 +-
.../graph/test/util/EdgeTestUtils.java | 7 +-
.../graph/src/test/resources/log4j.properties | 36 +
stack/corepersistence/pom.xml | 3 +
57 files changed, 3858 insertions(+), 4007 deletions(-)
----------------------------------------------------------------------
[43/50] [abbrv] Put queryindex classes all under one top-level
"index" package to eliminate conflict with old persistence classes.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/ContainsOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/ContainsOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/ContainsOperand.java
new file mode 100644
index 0000000..b952d13
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/ContainsOperand.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.index.exceptions.PersistenceException;
+
+
+/** @author tnine */
+public class ContainsOperand extends EqualityOperand {
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public ContainsOperand( Token t ) {
+ super( t );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws PersistenceException {
+ visitor.visit( this );
+ }
+
+
+ public StringLiteral getString() {
+ return ( StringLiteral ) getLiteral();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.usergrid.persistence.query.tree.EqualityOperand#newProperty(java.lang.String)
+ */
+ @Override
+ protected Property newProperty( String name ) {
+ return new ContainsProperty( name );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.usergrid.persistence.query.tree.EqualityOperand#getProperty()
+ */
+ @Override
+ public ContainsProperty getProperty() {
+ return ( ContainsProperty ) this.children.get( 0 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/ContainsProperty.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/ContainsProperty.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/ContainsProperty.java
new file mode 100644
index 0000000..0c282ac
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/ContainsProperty.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+
+
+/**
+ * A property for full text searching that requires special renaming
+ *
+ * @author tnine
+ */
+public class ContainsProperty extends Property {
+
+ private String indexedName = null;
+
+
+ public ContainsProperty( Token t ) {
+ super( t );
+ this.indexedName = String.format( "%s.keywords", super.getValue() );
+ }
+
+
+ public ContainsProperty( String property ) {
+ this( new ClassicToken( 0, property ) );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.usergrid.persistence.query.tree.Property#getIndexedValue()
+ */
+ @Override
+ public String getIndexedValue() {
+ return this.indexedName;
+ }
+
+
+ /** @return the property */
+ public ContainsProperty getProperty() {
+ return ( ContainsProperty ) this.children.get( 0 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/Equal.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/Equal.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/Equal.java
new file mode 100644
index 0000000..0769f39
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/Equal.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.index.exceptions.NoIndexException;
+
+
+/** @author tnine */
+public class Equal extends EqualityOperand {
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public Equal( Token t ) {
+ super( t );
+ }
+
+
+ public Equal() {
+ super( new ClassicToken( 0, "=" ) );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws NoIndexException {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/EqualityOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/EqualityOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/EqualityOperand.java
new file mode 100644
index 0000000..3ae654d
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/EqualityOperand.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.Token;
+
+
+/**
+ * A base class for any equality expression. Expressions must have a property and a value. Examples are >=, >, =, <,
+ * <=,
+ *
+ * @author tnine
+ */
+public abstract class EqualityOperand extends Operand {
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public EqualityOperand( Token t ) {
+ super( t );
+ }
+
+
+ public EqualityOperand( String propName, Literal<?> value ) {
+ super( null );
+ }
+
+
+ /** Set the property on this operand */
+ public void setProperty( String name ) {
+ setAtIndex( 0, newProperty( name ) );
+ }
+
+
+ /** Get the property to set into the equality. Allows subclasses to override the type */
+ protected Property newProperty( String name ) {
+ return new Property( name );
+ }
+
+
+ /** Set the literal on this operand from the given value */
+ public void setLiteral( Object value ) {
+ setAtIndex( 1, LiteralFactory.getLiteral( value ) );
+ }
+
+
+ /** Set the child at the specified index. If it doesn't exist, it's added until it does */
+ @SuppressWarnings("unchecked")
+ private void setAtIndex( int index, Literal<?> value ) {
+
+ if ( children == null ) {
+ children = createChildrenList();
+ }
+
+ while ( children.size() - 1 < index ) {
+ children.add( null );
+ }
+
+ setChild( index, value );
+ }
+
+
+ /** @return the property */
+ public Property getProperty() {
+ return ( Property ) this.children.get( 0 );
+ }
+
+
+ /** @return the literal */
+ public Literal<?> getLiteral() {
+ return ( Literal<?> ) this.children.get( 1 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/FloatLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/FloatLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/FloatLiteral.java
new file mode 100644
index 0000000..eaec4d4
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/FloatLiteral.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+
+
+/** @author tnine */
+public class FloatLiteral extends Literal<Float> implements NumericLiteral {
+
+ private float value;
+
+
+ /**
+ * @param t
+ */
+ public FloatLiteral( Token t ) {
+ super( t );
+ value = Float.valueOf( t.getText() );
+ }
+
+
+ public FloatLiteral( float f ) {
+ super( new ClassicToken( 0, String.valueOf( f ) ) );
+ value = f;
+ }
+
+
+ /** @return the value */
+ public Float getValue() {
+ return value;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.usergrid.persistence.query.tree.NumericLiteral#getFloatValue()
+ */
+ @Override
+ public float getFloatValue() {
+ return value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/GreaterThan.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/GreaterThan.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/GreaterThan.java
new file mode 100644
index 0000000..fd8e628
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/GreaterThan.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.index.exceptions.NoIndexException;
+
+
+/** @author tnine */
+public class GreaterThan extends EqualityOperand {
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public GreaterThan( Token t ) {
+ super( t );
+ }
+
+
+ public GreaterThan() {
+ super( new CommonToken( 0, ">" ) );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws NoIndexException {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/GreaterThanEqual.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/GreaterThanEqual.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/GreaterThanEqual.java
new file mode 100644
index 0000000..075c3a8
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/GreaterThanEqual.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.index.exceptions.NoIndexException;
+
+
+/** @author tnine */
+public class GreaterThanEqual extends EqualityOperand {
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public GreaterThanEqual( Token t ) {
+ super( t );
+ }
+
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public GreaterThanEqual() {
+ super( new CommonToken( 0, ">=" ) );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws NoIndexException {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/LessThan.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/LessThan.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/LessThan.java
new file mode 100644
index 0000000..9113f20
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/LessThan.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.index.exceptions.NoIndexException;
+
+
+/** @author tnine */
+public class LessThan extends EqualityOperand {
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public LessThan( Token t ) {
+ super( t );
+ }
+
+
+ public LessThan() {
+ super( new CommonToken( 0, "<" ) );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws NoIndexException {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/LessThanEqual.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/LessThanEqual.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/LessThanEqual.java
new file mode 100644
index 0000000..bc75c78
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/LessThanEqual.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.index.exceptions.NoIndexException;
+
+
+/** @author tnine */
+public class LessThanEqual extends EqualityOperand {
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public LessThanEqual( Token t ) {
+ super( t );
+ }
+
+
+ /**
+ */
+ public LessThanEqual() {
+ super( new CommonToken( 0, "<=" ) );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws NoIndexException {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/Literal.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/Literal.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/Literal.java
new file mode 100644
index 0000000..cca51f8
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/Literal.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.Token;
+import org.antlr.runtime.tree.CommonTree;
+
+
+/**
+ * Abstract class for literals
+ *
+ * @author tnine
+ */
+public abstract class Literal<V> extends CommonTree {
+
+
+ protected Literal( Token t ) {
+ super( t );
+ }
+
+
+ /** Return the value of the literal the user has passed in */
+ public abstract V getValue();
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/LiteralFactory.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/LiteralFactory.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/LiteralFactory.java
new file mode 100644
index 0000000..672a6df
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/LiteralFactory.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import java.util.UUID;
+
+
+/**
+ * Simple factory for generating literal instance based on the runtime value
+ *
+ * @author tnine
+ */
+public class LiteralFactory {
+
+ /** Generate the correct literal subclass based on the runtime instance. */
+ public static final Literal<?> getLiteral( Object value ) {
+ if ( value instanceof Integer ) {
+ return new LongLiteral( ( Integer ) value );
+ }
+ if ( value instanceof Long ) {
+ return new LongLiteral( ( Long ) value );
+ }
+
+ if ( value instanceof String ) {
+ return new StringLiteral( ( String ) value );
+ }
+
+ if ( value instanceof Float ) {
+ return new FloatLiteral( ( Float ) value );
+ }
+
+ if ( value instanceof UUID ) {
+ return new UUIDLiteral( ( UUID ) value );
+ }
+
+ if ( value instanceof Boolean ) {
+ return new BooleanLiteral( ( Boolean ) value );
+ }
+
+ throw new UnsupportedOperationException(
+ String.format( "Unsupported type of %s was passed when trying to construct a literal",
+ value.getClass() ) );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/LongLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/LongLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/LongLiteral.java
new file mode 100644
index 0000000..690fb51
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/LongLiteral.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+
+
+/** @author tnine */
+public class LongLiteral extends Literal<Long> implements NumericLiteral {
+
+ private long value;
+
+
+ /**
+ * @param t
+ */
+ public LongLiteral( Token t ) {
+ super( t );
+ this.value = Long.valueOf( t.getText() );
+ }
+
+
+ /**
+ *
+ * @param value
+ */
+ public LongLiteral( long value ) {
+ super( new ClassicToken( 0, String.valueOf( value ) ) );
+ this.value = value;
+ }
+
+
+ /**
+ *
+ * @return
+ */
+ public Long getValue() {
+ return this.value;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.usergrid.persistence.query.tree.NumericLiteral#getFloatValue()
+ */
+ @Override
+ public float getFloatValue() {
+ return value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/NotOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/NotOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/NotOperand.java
new file mode 100644
index 0000000..e41e94b
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/NotOperand.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed 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.query.tree;
+
+
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.index.exceptions.PersistenceException;
+
+
+/** @author tnine */
+public class NotOperand extends Operand {
+
+
+ public NotOperand( Token t ) {
+ super( t );
+ }
+
+
+ /** get the only child operation */
+ public Operand getOperation() {
+ return ( Operand ) this.children.get( 0 );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence.query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws PersistenceException {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/NumericLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/NumericLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/NumericLiteral.java
new file mode 100644
index 0000000..493a211
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/NumericLiteral.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+/** @author tnine */
+public interface NumericLiteral {
+
+ /** Return the value of this numeric literal as a float */
+ public float getFloatValue();
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/Operand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/Operand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/Operand.java
new file mode 100644
index 0000000..1363941
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/Operand.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.Token;
+import org.antlr.runtime.tree.CommonTree;
+import org.apache.usergrid.persistence.index.exceptions.PersistenceException;
+
+
+/**
+ * Any logical operation should subclass. Boolean logic, equality, not, contains, within and others are examples of
+ * operands
+ *
+ * @author tnine
+ */
+public abstract class Operand extends CommonTree {
+
+
+ /** Default constructor to take a token */
+ public Operand( Token t ) {
+ super( t );
+ }
+
+
+ /** Get the pointer to the parent node */
+ public Operand getParent() {
+ return ( Operand ) super.getParent();
+ }
+
+
+ /** Visitor method */
+ public abstract void visit( QueryVisitor visitor ) throws PersistenceException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/OrOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/OrOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/OrOperand.java
new file mode 100644
index 0000000..97678bc
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/OrOperand.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.Token;
+import org.apache.usergrid.persistence.index.exceptions.PersistenceException;
+
+
+/** @author tnine */
+public class OrOperand extends BooleanOperand {
+
+ /**
+ * @param left
+ * @param token
+ * @param right
+ */
+ public OrOperand( Token t ) {
+ super( t );
+ }
+
+
+ public OrOperand() {
+ super( new CommonToken( 0, "or" ) );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) throws PersistenceException {
+ visitor.visit( this );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/Property.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/Property.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/Property.java
new file mode 100644
index 0000000..f9bf67c
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/Property.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+
+
+/**
+ * A property
+ *
+ * @author tnine
+ */
+public class Property extends Literal<String> {
+
+ private String property;
+
+
+ public Property( Token t ) {
+ super( t );
+ this.property = t.getText();
+ }
+
+
+ public Property( String property ) {
+ this( new ClassicToken( 0, property ) );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.usergrid.persistence.query.tree.Literal#getValue()
+ */
+ @Override
+ public String getValue() {
+ return this.property;
+ }
+
+
+ /**
+ * Subclasses an override. Indexed value could be different when stored internally. By default returns the same
+ * property
+ */
+ public String getIndexedValue() {
+ return this.property;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/QueryVisitor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/QueryVisitor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/QueryVisitor.java
new file mode 100644
index 0000000..e12c134
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/QueryVisitor.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.apache.usergrid.persistence.index.exceptions.NoFullTextIndexException;
+import org.apache.usergrid.persistence.index.exceptions.NoIndexException;
+import org.apache.usergrid.persistence.index.exceptions.PersistenceException;
+import org.elasticsearch.index.query.FilterBuilder;
+import org.elasticsearch.index.query.QueryBuilder;
+
+
+/**
+ * Interface for visiting nodes in our AST as we produce
+ *
+ * @author tnine
+ */
+public interface QueryVisitor {
+
+ /**
+ *
+ * @param op
+ * @throws PersistenceException
+ */
+ public void visit( AndOperand op ) throws PersistenceException;
+
+ /**
+ * @param op
+ * @throws PersistenceException
+ */
+ public void visit( OrOperand op ) throws PersistenceException;
+
+ /**
+ * @param op
+ * @throws PersistenceException
+ */
+ public void visit( NotOperand op ) throws PersistenceException;
+
+ /**
+ * @param op
+ * @throws NoIndexException
+ */
+ public void visit( LessThan op ) throws NoIndexException;
+
+ /**
+ * @param op
+ * @throws NoFullTextIndexException
+ */
+ public void visit( ContainsOperand op ) throws NoFullTextIndexException;
+
+ /**
+ * @param op
+ */
+ public void visit( WithinOperand op );
+
+ /**
+ * @param op
+ * @throws NoIndexException
+ */
+ public void visit( LessThanEqual op ) throws NoIndexException;
+
+ /**
+ * @param op
+ * @throws NoIndexException
+ */
+ public void visit( Equal op ) throws NoIndexException;
+
+ /**
+ * @param op
+ * @throws NoIndexException
+ */
+ public void visit( GreaterThan op ) throws NoIndexException;
+
+ /**
+ * @param op
+ * @throws NoIndexException
+ */
+ public void visit( GreaterThanEqual op ) throws NoIndexException;
+
+ /**
+ * Returns resulting query builder.
+ */
+ public QueryBuilder getQueryBuilder();
+
+ public FilterBuilder getFilterBuilder();
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/StringLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/StringLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/StringLiteral.java
new file mode 100644
index 0000000..196fcfa
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/StringLiteral.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+
+import static org.apache.commons.lang.StringUtils.removeEnd;
+
+
+/** @author tnine */
+public class StringLiteral extends Literal<String> {
+
+ private String value;
+ private String finishValue;
+
+
+ /**
+ * @param t
+ */
+ public StringLiteral( Token t ) {
+ super( t );
+ String newValue = t.getText();
+ newValue = newValue.substring( 1, newValue.length() - 1 );
+
+ parseValue( newValue );
+ }
+
+
+ public StringLiteral( String value ) {
+ super( new ClassicToken( 0, value ) );
+ parseValue( value );
+ }
+
+
+ /** Parse the value and set the optional end value */
+ private void parseValue( String value ) {
+
+ this.value = value.trim().toLowerCase();
+
+ if ( "*".equals( value ) ) {
+ this.value = null;
+ this.finishValue = null;
+ return;
+ }
+
+ if ( value != null && value.endsWith( "*" ) ) {
+ this.value = removeEnd( value.toString(), "*" );
+
+ finishValue = this.value + "\uFFFF";
+ }
+ // set the end value to the same as the start value
+ else {
+ finishValue = value;
+ }
+ }
+
+
+ /** If this were a string literal */
+ public String getEndValue() {
+ return this.finishValue;
+ }
+
+
+ public String getValue() {
+ return this.value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/UUIDLiteral.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/UUIDLiteral.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/UUIDLiteral.java
new file mode 100644
index 0000000..0cf91a3
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/UUIDLiteral.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import java.util.UUID;
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+
+
+/** @author tnine */
+public class UUIDLiteral extends Literal<UUID> {
+
+ private UUID value;
+
+
+ /**
+ * @param t
+ */
+ public UUIDLiteral( Token t ) {
+ super( t );
+ value = UUID.fromString( t.getText() );
+ }
+
+
+ public UUIDLiteral( UUID value ) {
+ super( new ClassicToken( 0, String.valueOf( value ) ) );
+ this.value = value;
+ }
+
+
+ public UUID getValue() {
+ return this.value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/WithinOperand.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/WithinOperand.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/WithinOperand.java
new file mode 100644
index 0000000..602fc34
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/WithinOperand.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright 2012 Apigee Corporation
+ *
+ * Licensed 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.query.tree;
+
+
+import org.antlr.runtime.Token;
+
+
+/** @author tnine */
+public class WithinOperand extends Operand {
+
+ /**
+ * @param property
+ * @param literal
+ */
+ public WithinOperand( Token t ) {
+ super( t );
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.usergrid.persistence.query.tree.Operand#visit(org.apache.usergrid.persistence
+ * .query.tree.QueryVisitor)
+ */
+ @Override
+ public void visit( QueryVisitor visitor ) {
+ visitor.visit( this );
+ }
+
+
+ /**
+ * @param propName
+ */
+ public void setProperty( String propName ) {
+ setChild( 0, new WithinProperty( propName ) );
+ }
+
+
+ /**
+ * @param distance
+ */
+ public void setDistance( float distance ) {
+ setChild( 1, new FloatLiteral( distance ) );
+ }
+
+
+ /**
+ * @param Latitude
+ */
+ public void setLatitude( float Latitude ) {
+ setChild( 2, new FloatLiteral( Latitude ) );
+ }
+
+
+ /**
+ * @param longitude
+ */
+ public void setLongitude( float longitude ) {
+ setChild( 3, new FloatLiteral( longitude ) );
+ }
+
+
+ /**
+ *
+ * @return
+ */
+ public WithinProperty getProperty() {
+ return ( WithinProperty ) this.children.get( 0 );
+ }
+
+
+ /**
+ *
+ * @return
+ */
+ public NumericLiteral getDistance() {
+ return ( NumericLiteral ) this.children.get( 1 );
+ }
+
+
+ /**
+ * @return
+ */
+ public NumericLiteral getLatitude() {
+ return ( NumericLiteral ) this.children.get( 2 );
+ }
+
+
+ /**
+ * @return
+ */
+ public NumericLiteral getLongitude() {
+ return ( NumericLiteral ) this.children.get( 3 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/WithinProperty.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/WithinProperty.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/WithinProperty.java
new file mode 100644
index 0000000..a9b5899
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/tree/WithinProperty.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.usergrid.persistence.index.query.tree;
+
+
+import org.antlr.runtime.ClassicToken;
+import org.antlr.runtime.Token;
+
+
+/**
+ * A property
+ *
+ * @author tnine
+ */
+public class WithinProperty extends Property {
+
+ private String indexedName = null;
+
+
+ public WithinProperty( Token t ) {
+ super( t );
+ this.indexedName = String.format( "%s.coordinates", super.getValue() );
+ }
+
+
+ public WithinProperty( String property ) {
+ this( new ClassicToken( 0, property ) );
+ }
+
+
+ /** Get the */
+ public String getIndexedName() {
+ return this.indexedName;
+ }
+
+
+ /** @return the property */
+ public WithinProperty getProperty() {
+ return ( WithinProperty ) this.children.get( 0 );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/ClassUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/ClassUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/ClassUtils.java
new file mode 100644
index 0000000..ab51d55
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/ClassUtils.java
@@ -0,0 +1,58 @@
+/*
+ * 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.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+
+public class ClassUtils extends org.apache.commons.lang.ClassUtils {
+
+ @SuppressWarnings("unchecked")
+ public static <A, B> B cast( A a ) {
+ return ( B ) a;
+ }
+
+
+ @SuppressWarnings("unchecked")
+ private static final Set<Class<?>> WRAPPER_TYPES = new HashSet<Class<?>>(
+ Arrays.asList( Boolean.class, Byte.class, Character.class, Double.class, Float.class, Integer.class,
+ Long.class, Short.class, Void.class ) );
+
+
+ public static boolean isWrapperType( Class<?> clazz ) {
+ return WRAPPER_TYPES.contains( clazz );
+ }
+
+
+ public static boolean isPrimitiveType( Class<?> clazz ) {
+ if ( clazz == null ) {
+ return false;
+ }
+ return clazz.isPrimitive() || isWrapperType( clazz );
+ }
+
+
+ public static boolean isBasicType( Class<?> clazz ) {
+ if ( clazz == null ) {
+ return false;
+ }
+ return ( String.class.isAssignableFrom( clazz ) ) || isPrimitiveType( clazz );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/ConversionUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/ConversionUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/ConversionUtils.java
new file mode 100644
index 0000000..503d597
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/ConversionUtils.java
@@ -0,0 +1,765 @@
+/*
+ * 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.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.commons.lang.math.NumberUtils;
+
+
+/** Convenience methods for converting to and from formats, primarily between byte arrays and UUIDs, Strings,
+ * and Longs. */
+public class ConversionUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger( ConversionUtils.class );
+
+ /**
+ *
+ */
+ public static final String UTF8_ENCODING = "UTF-8";
+
+ /**
+ *
+ */
+ public static final String ASCII_ENCODING = "US-ASCII";
+
+ public static final ByteBuffer HOLDER = ByteBuffer.wrap( new byte[] { 0 } );
+
+
+ /**
+ * @param uuid
+ * @return
+ */
+ public static UUID uuid( byte[] uuid ) {
+ return uuid( uuid, 0 );
+ }
+
+
+ /**
+ * @param uuid
+ * @param offset
+ * @return
+ */
+ public static UUID uuid( byte[] uuid, int offset ) {
+ ByteBuffer bb = ByteBuffer.wrap( uuid, offset, 16 );
+ return new UUID( bb.getLong(), bb.getLong() );
+ }
+
+
+ public static UUID uuid( ByteBuffer bb ) {
+ if ( bb == null ) {
+ return null;
+ }
+ if ( bb.remaining() < 16 ) {
+ return null;
+ }
+ bb = bb.slice();
+ return new UUID( bb.getLong(), bb.getLong() );
+ }
+
+
+ /**
+ * @param uuid
+ * @return
+ */
+ public static UUID uuid( String uuid ) {
+ try {
+ return UUID.fromString( uuid );
+ }
+ catch ( Exception e ) {
+ logger.error( "Bad UUID", e );
+ }
+ return UUIDUtils.ZERO_UUID;
+ }
+
+
+ /**
+ * @param obj
+ * @return
+ */
+ public static UUID uuid( Object obj ) {
+ return uuid( obj, UUIDUtils.ZERO_UUID );
+ }
+
+
+ public static UUID uuid( Object obj, UUID defaultValue ) {
+ if ( obj instanceof UUID ) {
+ return ( UUID ) obj;
+ }
+ else if ( obj instanceof byte[] ) {
+ return uuid( ( byte[] ) obj );
+ }
+ else if ( obj instanceof ByteBuffer ) {
+ return uuid( ( ByteBuffer ) obj );
+ }
+ else if ( obj instanceof String ) {
+ return uuid( ( String ) obj );
+ }
+ return defaultValue;
+ }
+
+
+ /**
+ * @param uuid
+ * @return
+ */
+ public static byte[] bytes( UUID uuid ) {
+ if ( uuid == null ) {
+ return null;
+ }
+ long msb = uuid.getMostSignificantBits();
+ long lsb = uuid.getLeastSignificantBits();
+ byte[] buffer = new byte[16];
+
+ for ( int i = 0; i < 8; i++ ) {
+ buffer[i] = ( byte ) ( msb >>> ( 8 * ( 7 - i ) ) );
+ }
+ for ( int i = 8; i < 16; i++ ) {
+ buffer[i] = ( byte ) ( lsb >>> ( 8 * ( 7 - i ) ) );
+ }
+
+ return buffer;
+ }
+
+
+ public static ByteBuffer bytebuffer( UUID uuid ) {
+ if ( uuid == null ) {
+ return null;
+ }
+ return ByteBuffer.wrap( bytes( uuid ) );
+ }
+
+
+ /**
+ * @param uuid
+ * @return
+ */
+ public static byte[] uuidToBytesNullOk( UUID uuid ) {
+ if ( uuid != null ) {
+ return bytes( uuid );
+ }
+ return new byte[16];
+ }
+
+
+ /**
+ * @param s
+ * @return
+ */
+ public static byte[] bytes( String s ) {
+ return bytes( s, UTF8_ENCODING );
+ }
+
+
+ public static ByteBuffer bytebuffer( String s ) {
+ return ByteBuffer.wrap( bytes( s ) );
+ }
+
+
+ /**
+ * @param s
+ * @return
+ */
+ public static byte[] ascii( String s ) {
+ if ( s == null ) {
+ return new byte[0];
+ }
+ return bytes( s, ASCII_ENCODING );
+ }
+
+
+ public ByteBuffer asciibuffer( String s ) {
+ return ByteBuffer.wrap( ascii( s ) );
+ }
+
+
+ /**
+ * @param s
+ * @param encoding
+ * @return
+ */
+ public static byte[] bytes( String s, String encoding ) {
+ try {
+ return s.getBytes( encoding );
+ }
+ catch ( UnsupportedEncodingException e ) {
+ // logger.log(Level.SEVERE, "UnsupportedEncodingException ", e);
+ throw new RuntimeException( e );
+ }
+ }
+
+
+ public static byte[] bytes( ByteBuffer bb ) {
+ byte[] b = new byte[bb.remaining()];
+ bb.duplicate().get( b );
+ return b;
+ }
+
+
+ public static ByteBuffer bytebuffer( String s, String encoding ) {
+ return ByteBuffer.wrap( bytes( s, encoding ) );
+ }
+
+
+ /**
+ * @param b
+ * @return
+ */
+ public static byte[] bytes( Boolean b ) {
+ byte[] bytes = new byte[1];
+ bytes[0] = b ? ( byte ) 1 : 0;
+ return bytes;
+ }
+
+
+ public static ByteBuffer bytebuffer( Boolean b ) {
+ return ByteBuffer.wrap( bytes( b ) );
+ }
+
+
+ /**
+ * @param val
+ * @return
+ */
+ public static byte[] bytes( Long val ) {
+ ByteBuffer buf = ByteBuffer.allocate( 8 );
+ buf.order( ByteOrder.BIG_ENDIAN );
+ buf.putLong( val );
+ return buf.array();
+ }
+
+
+ public static ByteBuffer bytebuffer( Long val ) {
+ ByteBuffer buf = ByteBuffer.allocate( 8 );
+ buf.order( ByteOrder.BIG_ENDIAN );
+ buf.putLong( val );
+ return ( ByteBuffer ) buf.rewind();
+ }
+
+
+ /**
+ * @param obj
+ * @return
+ */
+ public static byte[] bytes( Object obj ) {
+ if ( obj == null ) {
+ return new byte[0];
+ }
+ else if ( obj instanceof byte[] ) {
+ return ( byte[] ) obj;
+ }
+ else if ( obj instanceof Long ) {
+ return bytes( ( Long ) obj );
+ }
+ else if ( obj instanceof String ) {
+ return bytes( ( String ) obj );
+ }
+ else if ( obj instanceof UUID ) {
+ return bytes( ( UUID ) obj );
+ }
+ else if ( obj instanceof Boolean ) {
+ return bytes( ( Boolean ) obj );
+ }
+ else if ( obj instanceof Date ) {
+ return bytes( ( ( Date ) obj ).getTime() );
+ }
+ else {
+ return bytes( obj.toString() );
+ }
+ }
+
+
+ public static ByteBuffer bytebuffer( byte[] bytes ) {
+ return ByteBuffer.wrap( bytes );
+ }
+
+
+ public static ByteBuffer bytebuffer( ByteBuffer bytes ) {
+ return bytes.duplicate();
+ }
+
+
+ public static ByteBuffer bytebuffer( Object obj ) {
+ if ( obj instanceof ByteBuffer ) {
+ return ( ( ByteBuffer ) obj ).duplicate();
+ }
+ return ByteBuffer.wrap( bytes( obj ) );
+ }
+
+
+ public static List<ByteBuffer> bytebuffers( List<?> l ) {
+ List<ByteBuffer> results = new ArrayList<ByteBuffer>( l.size() );
+ for ( Object o : l ) {
+ results.add( bytebuffer( o ) );
+ }
+ return results;
+ }
+
+
+ /**
+ * @param bytes
+ * @return
+ */
+ public static boolean getBoolean( byte[] bytes ) {
+ return bytes[0] != 0;
+ }
+
+
+ public static boolean getBoolean( ByteBuffer bytes ) {
+ return bytes.slice().get() != 0;
+ }
+
+
+ /**
+ * @param bytes
+ * @param offset
+ * @return
+ */
+ public static boolean getBoolean( byte[] bytes, int offset ) {
+ return bytes[offset] != 0;
+ }
+
+
+ public static boolean getBoolean( Object obj ) {
+ if ( obj instanceof Boolean ) {
+ return ( Boolean ) obj;
+ }
+ else if ( obj instanceof String ) {
+ return Boolean.parseBoolean( ( String ) obj );
+ }
+ else if ( obj instanceof Number ) {
+ return ( ( Number ) obj ).longValue() > 0;
+ }
+
+ return false;
+ }
+
+
+ /**
+ * @param obj
+ * @return
+ */
+ public static String string( Object obj ) {
+ if ( obj instanceof String ) {
+ return ( String ) obj;
+ }
+ else if ( obj instanceof byte[] ) {
+ return string( ( byte[] ) obj );
+ }
+ else if ( obj instanceof ByteBuffer ) {
+ return string( ( ByteBuffer ) obj );
+ }
+ else if ( obj != null ) {
+ return obj.toString();
+ }
+ return null;
+ }
+
+
+ /**
+ * @param bytes
+ * @return
+ */
+ public static String string( byte[] bytes ) {
+ if ( bytes == null ) {
+ return null;
+ }
+ return string( bytes, 0, bytes.length, UTF8_ENCODING );
+ }
+
+
+ public static String string( ByteBuffer bytes ) {
+ if ( bytes == null ) {
+ return null;
+ }
+ return string( bytes.array(), bytes.arrayOffset() + bytes.position(), bytes.remaining(), UTF8_ENCODING );
+ }
+
+
+ /**
+ * @param bytes
+ * @param offset
+ * @param length
+ * @return
+ */
+ public static String string( byte[] bytes, int offset, int length ) {
+ return string( bytes, offset, length, UTF8_ENCODING );
+ }
+
+
+ /**
+ * @param bytes
+ * @param offset
+ * @param length
+ * @param encoding
+ * @return
+ */
+ public static String string( byte[] bytes, int offset, int length, String encoding ) {
+
+ if ( length <= 0 ) {
+ return "";
+ }
+
+ if ( bytes == null ) {
+ return "";
+ }
+
+ try {
+ return new String( bytes, offset, length, encoding );
+ }
+ catch ( UnsupportedEncodingException e ) {
+ // logger.log(Level.SEVERE, "UnsupportedEncodingException ", e);
+ throw new RuntimeException( e );
+ }
+ }
+
+
+ public static <T> List<String> strings( Collection<T> items ) {
+ List<String> strings = new ArrayList<String>();
+ for ( T item : items ) {
+ strings.add( string( item ) );
+ }
+ return strings;
+ }
+
+
+ /**
+ * @param bytes
+ * @param offset
+ * @return
+ */
+ public static String stringFromLong( byte[] bytes, int offset ) {
+ if ( bytes.length == 0 ) {
+ return "";
+ }
+ if ( ( bytes.length - offset ) < 8 ) {
+ throw new IllegalArgumentException( "A long is at least 8 bytes" );
+ }
+ return String.valueOf( ByteBuffer.wrap( bytes, offset, 8 ).getLong() );
+ }
+
+
+ /**
+ * @param bytes
+ * @return
+ */
+ public static long getLong( byte[] bytes ) {
+ return ByteBuffer.wrap( bytes, 0, 8 ).getLong();
+ }
+
+
+ public static long getLong( ByteBuffer bytes ) {
+ return bytes.slice().getLong();
+ }
+
+
+ public static long getLong( Object obj ) {
+ if ( obj instanceof Long ) {
+ return ( Long ) obj;
+ }
+ if ( obj instanceof Number ) {
+ return ( ( Number ) obj ).longValue();
+ }
+ if ( obj instanceof String ) {
+ return NumberUtils.toLong( ( String ) obj );
+ }
+ if ( obj instanceof Date ) {
+ return ( ( Date ) obj ).getTime();
+ }
+ if ( obj instanceof byte[] ) {
+ return getLong( ( byte[] ) obj );
+ }
+ if ( obj instanceof ByteBuffer ) {
+ return getLong( ( ByteBuffer ) obj );
+ }
+ return 0;
+ }
+
+
+ /**
+ * @param bytes
+ * @return
+ */
+ public static int getInt( byte[] bytes ) {
+ return ByteBuffer.wrap( bytes, 0, 4 ).getInt();
+ }
+
+
+ public static int getInt( ByteBuffer bytes ) {
+ return bytes.slice().getInt();
+ }
+
+
+ public static int getInt( Object obj ) {
+ if ( obj instanceof Integer ) {
+ return ( Integer ) obj;
+ }
+ if ( obj instanceof Number ) {
+ return ( ( Number ) obj ).intValue();
+ }
+ if ( obj instanceof String ) {
+ return NumberUtils.toInt( ( String ) obj );
+ }
+ if ( obj instanceof Date ) {
+ return ( int ) ( ( Date ) obj ).getTime();
+ }
+ if ( obj instanceof byte[] ) {
+ return getInt( ( byte[] ) obj );
+ }
+ if ( obj instanceof ByteBuffer ) {
+ return getInt( ( ByteBuffer ) obj );
+ }
+ return 0;
+ }
+
+
+ /**
+ * @param bytes
+ * @return
+ */
+ public static float getFloat( byte[] bytes ) {
+ return ByteBuffer.wrap( bytes, 0, 4 ).getFloat();
+ }
+
+
+ public static float getFloat( ByteBuffer bytes ) {
+ return bytes.slice().getFloat();
+ }
+
+
+ public static float getFloat( Object obj ) {
+ if ( obj instanceof Float ) {
+ return ( Float ) obj;
+ }
+ if ( obj instanceof Number ) {
+ return ( ( Number ) obj ).floatValue();
+ }
+ if ( obj instanceof String ) {
+ return NumberUtils.toFloat( ( String ) obj );
+ }
+ if ( obj instanceof Date ) {
+ return ( ( Date ) obj ).getTime();
+ }
+ if ( obj instanceof byte[] ) {
+ return getFloat( ( byte[] ) obj );
+ }
+ if ( obj instanceof ByteBuffer ) {
+ return getFloat( ( ByteBuffer ) obj );
+ }
+ return 0;
+ }
+
+
+ public static double getDouble( byte[] bytes ) {
+ return ByteBuffer.wrap( bytes, 0, 8 ).getDouble();
+ }
+
+
+ public static double getDouble( ByteBuffer bytes ) {
+ return bytes.slice().getDouble();
+ }
+
+
+ public static double getDouble( Object obj ) {
+ if ( obj instanceof Double ) {
+ return ( Double ) obj;
+ }
+ if ( obj instanceof Number ) {
+ return ( ( Number ) obj ).doubleValue();
+ }
+ if ( obj instanceof String ) {
+ return NumberUtils.toDouble( ( String ) obj );
+ }
+ if ( obj instanceof Date ) {
+ return ( ( Date ) obj ).getTime();
+ }
+ if ( obj instanceof byte[] ) {
+ return getDouble( ( byte[] ) obj );
+ }
+ if ( obj instanceof ByteBuffer ) {
+ return getDouble( ( ByteBuffer ) obj );
+ }
+ return 0;
+ }
+
+
+ /**
+ * @param type
+ * @param bytes
+ * @return
+ */
+ public static Object object( Class<?> type, byte[] bytes ) {
+
+ try {
+ if ( Long.class.isAssignableFrom( type ) ) {
+ return getLong( bytes );
+ }
+ else if ( UUID.class.isAssignableFrom( type ) ) {
+ return uuid( bytes );
+ }
+ else if ( String.class.isAssignableFrom( type ) ) {
+ return string( bytes );
+ }
+ else if ( Boolean.class.isAssignableFrom( type ) ) {
+ return getBoolean( bytes );
+ }
+ else if ( Integer.class.isAssignableFrom( type ) ) {
+ return getInt( bytes );
+ }
+ else if ( Double.class.isAssignableFrom( type ) ) {
+ return getDouble( bytes );
+ }
+ else if ( Float.class.isAssignableFrom( type ) ) {
+ return getFloat( bytes );
+ }
+ else if ( byte[].class.isAssignableFrom( type ) ) {
+ return bytes;
+ }
+ }
+ catch ( Exception e ) {
+ logger.error( "Unable to get object from bytes for type " + type.getName(), e );
+ }
+ return null;
+ }
+
+
+ public static Object object( Class<?> type, ByteBuffer bytes ) {
+
+ try {
+ if ( Long.class.isAssignableFrom( type ) ) {
+ return bytes.slice().getLong();
+ }
+ else if ( UUID.class.isAssignableFrom( type ) ) {
+ return uuid( bytes );
+ }
+ else if ( String.class.isAssignableFrom( type ) ) {
+ return string( bytes );
+ }
+ else if ( Boolean.class.isAssignableFrom( type ) ) {
+ return bytes.slice().get() != 0;
+ }
+ else if ( Integer.class.isAssignableFrom( type ) ) {
+ return bytes.slice().getInt();
+ }
+ else if ( Double.class.isAssignableFrom( type ) ) {
+ return bytes.slice().getDouble();
+ }
+ else if ( Float.class.isAssignableFrom( type ) ) {
+ return bytes.slice().getFloat();
+ }
+ else if ( ByteBuffer.class.isAssignableFrom( type ) ) {
+ return bytes.duplicate();
+ }
+ else if ( byte[].class.isAssignableFrom( type ) ) {
+ byte[] b = new byte[bytes.remaining()];
+ bytes.slice().get( b );
+ return b;
+ }
+ }
+ catch ( Exception e ) {
+ logger.error( "Unable to get object from bytes for type " + type.getName(), e );
+ }
+ return null;
+ }
+
+
+ /**
+ * @param bb
+ * @param bytes
+ * @param len
+ * @return
+ */
+ public static ByteBuffer appendToByteBuffer( ByteBuffer bb, byte[] bytes, int len ) {
+ if ( len > bytes.length ) {
+ int pos = bb.position();
+ bb.put( bytes );
+ bb.position( pos + len );
+ }
+ else {
+ bb.put( bytes, 0, len );
+ }
+ return bb;
+ }
+
+
+ public static Object coerce( Class<?> type, Object obj ) {
+
+ if ( obj == null ) {
+ return null;
+ }
+
+ if ( type == null ) {
+ return obj;
+ }
+
+ try {
+ if ( Long.class.isAssignableFrom( type ) ) {
+ return getLong( obj );
+ }
+ else if ( UUID.class.isAssignableFrom( type ) ) {
+ return uuid( obj );
+ }
+ else if ( String.class.isAssignableFrom( type ) ) {
+ return string( obj );
+ }
+ else if ( Boolean.class.isAssignableFrom( type ) ) {
+ return getBoolean( obj );
+ }
+ else if ( Integer.class.isAssignableFrom( type ) ) {
+ return getInt( obj );
+ }
+ else if ( Double.class.isAssignableFrom( type ) ) {
+ return getDouble( obj );
+ }
+ else if ( Float.class.isAssignableFrom( type ) ) {
+ return getFloat( obj );
+ }
+ else if ( byte[].class.isAssignableFrom( type ) ) {
+ return bytes( obj );
+ }
+ else if ( ByteBuffer.class.isAssignableFrom( type ) ) {
+ return bytebuffer( obj );
+ }
+ }
+ catch ( Exception e ) {
+ logger.error( "Unable to get object from bytes for type " + type.getName(), e );
+ }
+ return null;
+ }
+
+
+ public static Map<String, Object> coerceMap( Map<String, Class<?>> types, Map<String, Object> values ) {
+ for ( Map.Entry<String, Object> entry : values.entrySet() ) {
+ if ( types.containsKey( entry.getKey() ) ) {
+ values.put( entry.getKey(), coerce( types.get( entry.getKey() ), entry.getValue() ) );
+ }
+ }
+ return values;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/EntityBuilder.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/EntityBuilder.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/EntityBuilder.java
new file mode 100644
index 0000000..6de9d39
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/EntityBuilder.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+
+package org.apache.usergrid.persistence.index.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.field.BooleanField;
+import org.apache.usergrid.persistence.model.field.DoubleField;
+import org.apache.usergrid.persistence.model.field.EntityObjectField;
+import org.apache.usergrid.persistence.model.field.Field;
+import org.apache.usergrid.persistence.model.field.FloatField;
+import org.apache.usergrid.persistence.model.field.IntegerField;
+import org.apache.usergrid.persistence.model.field.ListField;
+import org.apache.usergrid.persistence.model.field.LocationField;
+import org.apache.usergrid.persistence.model.field.LongField;
+import org.apache.usergrid.persistence.model.field.StringField;
+import org.apache.usergrid.persistence.model.field.value.Location;
+
+
+public class EntityBuilder {
+
+ public static Entity fromMap( String scope, Map<String, Object> item ) {
+ return fromMap( scope, null, item );
+ }
+
+ public static Entity fromMap( String scope, Entity entity, Map<String, Object> map ) {
+
+ if ( entity == null ) {
+ entity = new Entity();
+ }
+
+ for ( String fieldName : map.keySet() ) {
+
+ Object value = map.get( fieldName );
+
+ if ( value instanceof String ) {
+ entity.setField( new StringField( fieldName, (String)value ));
+
+ } else if ( value instanceof Boolean ) {
+ entity.setField( new BooleanField( fieldName, (Boolean)value ));
+
+ } else if ( value instanceof Integer ) {
+ entity.setField( new IntegerField( fieldName, (Integer)value ));
+
+ } else if ( value instanceof Double ) {
+ entity.setField( new DoubleField( fieldName, (Double)value ));
+
+ } else if ( value instanceof Float ) {
+ entity.setField( new FloatField( fieldName, (Float)value ));
+
+ } else if ( value instanceof Long ) {
+ entity.setField( new LongField( fieldName, (Long)value ));
+
+ } else if ( value instanceof List) {
+ entity.setField( listToListField( scope, fieldName, (List)value ));
+
+ } else if ( value instanceof Map ) {
+
+ Field field = null;
+
+ // is the map really a location element?
+ Map<String, Object> m = (Map<String, Object>)value;
+ if ( m.size() == 2) {
+ Double lat = null;
+ Double lon = null;
+ try {
+ if ( m.get("latitude") != null && m.get("longitude") != null ) {
+ lat = Double.parseDouble( m.get("latitude").toString() );
+ lon = Double.parseDouble( m.get("longitude").toString() );
+
+ } else if ( m.get("lat") != null && m.get("lon") != null ) {
+ lat = Double.parseDouble( m.get("lat").toString() );
+ lon = Double.parseDouble( m.get("lon").toString() );
+ }
+ } catch ( NumberFormatException ignored ) {}
+
+ if ( lat != null && lon != null ) {
+ field = new LocationField( fieldName, new Location( lat, lon ));
+ }
+ }
+
+ if ( field == null ) {
+
+ // not a location element, process it as map
+ entity.setField( new EntityObjectField( fieldName,
+ fromMap( scope, (Map<String, Object>)value ))); // recursion
+
+ } else {
+ entity.setField( field );
+ }
+
+ } else {
+ throw new RuntimeException("Unknown type " + value.getClass().getName());
+ }
+ }
+
+ return entity;
+ }
+
+
+ private static ListField listToListField( String scope, String fieldName, List list ) {
+
+ if (list.isEmpty()) {
+ return new ListField( fieldName );
+ }
+
+ Object sample = list.get(0);
+
+ if ( sample instanceof Map ) {
+ return new ListField<Entity>( fieldName, processListForField( scope, list ));
+
+ } else if ( sample instanceof List ) {
+ return new ListField<List>( fieldName, processListForField( scope, list ));
+
+ } else if ( sample instanceof String ) {
+ return new ListField<String>( fieldName, (List<String>)list );
+
+ } else if ( sample instanceof Boolean ) {
+ return new ListField<Boolean>( fieldName, (List<Boolean>)list );
+
+ } else if ( sample instanceof Integer ) {
+ return new ListField<Integer>( fieldName, (List<Integer>)list );
+
+ } else if ( sample instanceof Double ) {
+ return new ListField<Double>( fieldName, (List<Double>)list );
+
+ } else if ( sample instanceof Long ) {
+ return new ListField<Long>( fieldName, (List<Long>)list );
+
+ } else {
+ throw new RuntimeException("Unknown type " + sample.getClass().getName());
+ }
+ }
+
+
+ private static List processListForField( String scope, List list ) {
+ if ( list.isEmpty() ) {
+ return list;
+ }
+ Object sample = list.get(0);
+
+ if ( sample instanceof Map ) {
+ List<Entity> newList = new ArrayList<Entity>();
+ for ( Map<String, Object> map : (List<Map<String, Object>>)list ) {
+ newList.add( fromMap( scope, map ) );
+ }
+ return newList;
+
+ } else if ( sample instanceof List ) {
+ return processListForField( scope, list ); // recursion
+
+ } else {
+ return list;
+ }
+ }
+
+
+}
[42/50] [abbrv] Put queryindex classes all under one top-level
"index" package to eliminate conflict with old persistence classes.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/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
new file mode 100644
index 0000000..18c50ec
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/JsonUtils.java
@@ -0,0 +1,329 @@
+/*
+ * 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.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.usergrid.persistence.index.exceptions.JsonReadException;
+import org.apache.usergrid.persistence.index.exceptions.JsonWriteException;
+//import org.apache.usergrid.persistence.Entity;
+
+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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.commons.lang.StringUtils.substringAfter;
+
+import static org.apache.usergrid.persistence.index.utils.StringUtils.stringOrSubstringBeforeFirst;
+
+
+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().set( Feature.INDENT_OUTPUT, true );
+ }
+
+
+ /** 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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/ListUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/ListUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/ListUtils.java
new file mode 100644
index 0000000..6c7b480
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/ListUtils.java
@@ -0,0 +1,232 @@
+/*
+ * 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.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.usergrid.persistence.collection.util.EntityUtils;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class ListUtils extends org.apache.commons.collections.ListUtils {
+ private static final Logger LOG = LoggerFactory.getLogger( ListUtils.class );
+
+
+ public static <A> A first( List<A> list ) {
+ if ( list == null ) {
+ return null;
+ }
+ if ( list.size() == 0 ) {
+ return null;
+ }
+ return list.get( 0 );
+ }
+
+
+ public static <A> A last( List<A> list ) {
+ if ( list == null ) {
+ return null;
+ }
+ if ( list.size() == 0 ) {
+ return null;
+ }
+ return list.get( list.size() - 1 );
+ }
+
+
+ public static <A> Integer firstInteger( List<A> list ) {
+ A a = first( list );
+ if ( a == null ) {
+ return null;
+ }
+
+ if ( a instanceof Integer ) {
+ return ( Integer ) a;
+ }
+
+ try {
+ return NumberUtils.toInt( ( String ) a );
+ }
+ catch ( Exception e ) {
+ LOG.warn( "Could not convert list item {} to int", a, e );
+ }
+ return null;
+ }
+
+
+ public static <A> Long firstLong( List<A> list ) {
+ A a = first( list );
+ if ( a == null ) {
+ return null;
+ }
+
+ if ( a instanceof Long ) {
+ return ( Long ) a;
+ }
+
+ try {
+ return NumberUtils.toLong( ( String ) a );
+ }
+ catch ( Exception e ) {
+ LOG.warn( "Could not convert list item {} to long", a, e );
+ }
+ return null;
+ }
+
+
+ public static <A> Boolean firstBoolean( List<A> list ) {
+ A a = first( list );
+ if ( a == null ) {
+ return null;
+ }
+
+ if ( a instanceof Boolean ) {
+ return ( Boolean ) a;
+ }
+
+ try {
+ return Boolean.parseBoolean( ( String ) a );
+ }
+ catch ( Exception e ) {
+ LOG.warn( "Could not convert list item {} to boolean", a, e );
+ }
+ return null;
+ }
+
+
+ public static <A> UUID firstUuid( List<A> list ) {
+ A i = first( list );
+ if ( i == null ) {
+ return null;
+ }
+
+ if ( i instanceof UUID ) {
+ return ( UUID ) i;
+ }
+
+ try {
+ return UUIDUtils.tryGetUUID( ( String ) i );
+ }
+ catch ( Exception e ) {
+ LOG.warn( "Could not convert list item {} to UUID", i, e );
+ }
+ return null;
+ }
+
+
+ public static boolean isEmpty( List<?> list ) {
+ return ( list == null ) || ( list.size() == 0 );
+ }
+
+
+ public static <T> List<T> dequeueCopy( List<T> list ) {
+ if ( !isEmpty( list ) ) {
+ list = list.subList( 1, list.size() );
+ }
+ return list;
+ }
+
+
+ public static <T> List<T> initCopy( List<T> list ) {
+ if ( !isEmpty( list ) ) {
+ list = new ArrayList<T>( list );
+ }
+ else {
+ list = new ArrayList<T>();
+ }
+ return list;
+ }
+
+
+ public static <T> T dequeue( List<T> list ) {
+ if ( !isEmpty( list ) ) {
+ return list.remove( 0 );
+ }
+ return null;
+ }
+
+
+ public static <T> List<T> queue( List<T> list, T item ) {
+ if ( list == null ) {
+ list = new ArrayList<T>();
+ }
+ list.add( item );
+ return list;
+ }
+
+
+ public static <T> List<T> requeue( List<T> list, T item ) {
+ if ( list == null ) {
+ list = new ArrayList<T>();
+ }
+ list.add( 0, item );
+ return list;
+ }
+
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public static List<?> flatten( Collection<?> l ) {
+ boolean hasCollection = false;
+ for ( Object o : l ) {
+ if ( o instanceof Collection ) {
+ hasCollection = true;
+ break;
+ }
+ }
+ if ( !hasCollection && ( l instanceof List ) ) {
+ return ( List<?> ) l;
+ }
+ List newList = new ArrayList();
+ for ( Object o : l ) {
+ if ( o instanceof List ) {
+ newList.addAll( flatten( ( List ) o ) );
+ }
+ else {
+ newList.add( o );
+ }
+ }
+ return newList;
+ }
+
+
+ public static boolean anyNull( List<?> l ) {
+ for ( Object o : l ) {
+ if ( o == null ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public static boolean anyNull( Object... objects ) {
+ for ( Object o : objects ) {
+ if ( o == null ) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/MapUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/MapUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/MapUtils.java
new file mode 100644
index 0000000..a7c0b06
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/MapUtils.java
@@ -0,0 +1,377 @@
+/*
+ * 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.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import static org.apache.commons.lang.StringUtils.isNotBlank;
+
+import static org.apache.usergrid.persistence.index.utils.ClassUtils.cast;
+
+
+public class MapUtils extends org.apache.commons.collections.MapUtils {
+
+ public static <A, B> void addMapSet( Map<A, Set<B>> map, A a, B b ) {
+ addMapSet( map, false, a, b );
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static <A, B> void addMapSet( Map<A, Set<B>> map, boolean ignoreCase, A a, B b ) {
+
+ Set<B> setB = map.get( a );
+ if ( setB == null ) {
+ if ( ignoreCase && ( b instanceof String ) ) {
+ setB = ( Set<B> ) new TreeSet<String>( String.CASE_INSENSITIVE_ORDER );
+ }
+ else {
+ setB = new LinkedHashSet<B>();
+ }
+ map.put( a, setB );
+ }
+ setB.add( b );
+ }
+
+
+ public static <A, B, C> void addMapMapSet( Map<A, Map<B, Set<C>>> map, A a, B b, C c ) {
+ addMapMapSet( map, false, a, b, c );
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static <A, B, C> void addMapMapSet( Map<A, Map<B, Set<C>>> map, boolean ignoreCase, A a, B b, C c ) {
+
+ Map<B, Set<C>> mapB = map.get( a );
+ if ( mapB == null ) {
+ if ( ignoreCase && ( b instanceof String ) ) {
+ mapB = ( Map<B, Set<C>> ) new TreeMap<String, Set<C>>( String.CASE_INSENSITIVE_ORDER );
+ }
+ else {
+ mapB = new LinkedHashMap<B, Set<C>>();
+ }
+ map.put( a, mapB );
+ }
+ addMapSet( mapB, ignoreCase, b, c );
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static <A, B, C, D> void addMapMapMapSet( Map<A, Map<B, Map<C, Set<D>>>> map, boolean ignoreCase, A a, B b,
+ C c, D d ) {
+ Map<B, Map<C, Set<D>>> mapB = map.get( a );
+ if ( mapB == null ) {
+ if ( ignoreCase && ( b instanceof String ) ) {
+ mapB = ( Map<B, Map<C, Set<D>>> ) new TreeMap<String, Map<C, Set<D>>>( String.CASE_INSENSITIVE_ORDER );
+ }
+ else {
+ mapB = new LinkedHashMap<B, Map<C, Set<D>>>();
+ }
+ map.put( a, mapB );
+ }
+ addMapMapSet( mapB, ignoreCase, b, c, d );
+ }
+
+
+ public static <A, B, C> C getMapMap( Map<A, Map<B, C>> map, A a, B b ) {
+
+ Map<B, C> mapB = map.get( a );
+ if ( mapB == null ) {
+ return null;
+ }
+ return mapB.get( b );
+ }
+
+
+ public static <A, B> void addMapList( Map<A, List<B>> map, A a, B b ) {
+
+ List<B> listB = map.get( a );
+ if ( listB == null ) {
+ listB = new ArrayList<B>();
+ map.put( a, listB );
+ }
+ listB.add( b );
+ }
+
+
+ public static <A, B> void addListToMapList( Map<A, List<B>> map, A a, List<B> b ) {
+
+ List<B> listB = map.get( a );
+ if ( listB == null ) {
+ listB = new ArrayList<B>();
+ map.put( a, listB );
+ }
+ listB.addAll( b );
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static <K, V> V getValue( Map<K, ?> map, K k ) {
+ V v = null;
+ try {
+ v = ( V ) map.get( k );
+ }
+ catch ( ClassCastException e ) {
+ //LOG.war( "Map value {} was not the expected class", map.get( k ), e );
+ }
+
+ return v;
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static <K, V> Map<?, ?> map( Object... objects ) {
+ Map<K, V> map = new LinkedHashMap<K, V>();
+ int i = 0;
+ while ( i < objects.length ) {
+ if ( objects[i] instanceof Map.Entry ) {
+ Map.Entry<K, V> entry = ( Entry<K, V> ) objects[i];
+ map.put( entry.getKey(), entry.getValue() );
+ i++;
+ }
+ else if ( objects[i] instanceof Map ) {
+ map.putAll( ( Map<? extends K, ? extends V> ) objects[i] );
+ i++;
+ }
+ else if ( i < ( objects.length - 1 ) ) {
+ K k = ( K ) objects[i];
+ V v = ( V ) objects[i + 1];
+ map.put( k, v );
+ i += 2;
+ }
+ else {
+ break;
+ }
+ }
+ return map;
+ }
+
+
+ private static class SimpleMapEntry<K, V> implements Map.Entry<K, V> {
+
+ private final K k;
+ private V v;
+
+
+ public SimpleMapEntry( K k, V v ) {
+ this.k = k;
+ this.v = v;
+ }
+
+
+ @Override
+ public K getKey() {
+ return k;
+ }
+
+
+ @Override
+ public V getValue() {
+ return v;
+ }
+
+
+ @Override
+ public V setValue( V v ) {
+ V oldV = this.v;
+ this.v = v;
+ return oldV;
+ }
+ }
+
+
+ public static <K, V> Map.Entry<K, V> entry( K k, V v ) {
+ return new SimpleMapEntry<K, V>( k, v );
+ }
+
+
+ public static <K, V> K getFirstKey( Map<K, V> map ) {
+ if ( map == null ) {
+ return null;
+ }
+ Entry<K, V> e = map.entrySet().iterator().next();
+ if ( e != null ) {
+ return e.getKey();
+ }
+ return null;
+ }
+
+
+ public static <V> Map<String, V> filter( Map<String, V> map, String prefix, boolean removePrefix ) {
+ Map<String, V> filteredMap = new LinkedHashMap<String, V>();
+ for ( Entry<String, V> entry : map.entrySet() ) {
+ if ( entry.getKey().startsWith( prefix ) ) {
+ if ( removePrefix ) {
+ filteredMap.put( entry.getKey().substring( prefix.length() ), entry.getValue() );
+ }
+ else {
+ filteredMap.put( entry.getKey(), entry.getValue() );
+ }
+ }
+ }
+ return filteredMap;
+ }
+
+
+ public static <V> Map<String, V> filter( Map<String, V> map, String prefix ) {
+ return filter( map, prefix, false );
+ }
+
+
+ public static Properties filter( Properties properties, String prefix, boolean removePrefix ) {
+ Properties filteredProperties = new Properties();
+ for ( Entry<String, String> entry : asMap( properties ).entrySet() ) {
+ if ( entry.getKey().startsWith( prefix ) ) {
+ if ( removePrefix ) {
+ filteredProperties.put( entry.getKey().substring( prefix.length() ), entry.getValue() );
+ }
+ else {
+ filteredProperties.put( entry.getKey(), entry.getValue() );
+ }
+ }
+ }
+ return filteredProperties;
+ }
+
+
+ public static Properties filter( Properties properties, String prefix ) {
+ return filter( properties, prefix, false );
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static Map<String, String> asMap( Properties properties ) {
+ return cast( properties );
+ }
+
+
+ public static <S, T> HashMapBuilder<S, T> hashMap( S key, T value ) {
+ return new HashMapBuilder<S, T>().map( key, value );
+ }
+
+
+ public static class HashMapBuilder<S, T> extends HashMap<S, T> {
+ private static final long serialVersionUID = 1L;
+
+
+ public HashMapBuilder() {
+ }
+
+
+ public HashMapBuilder<S, T> map( S key, T value ) {
+ put( key, value );
+ return this;
+ }
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static Map<String, List<?>> toMapList( Map<String, ?> m ) {
+ Map<String, List<Object>> mapList = new LinkedHashMap<String, List<Object>>();
+
+ for ( Entry<String, ?> e : m.entrySet() ) {
+ if ( e.getValue() instanceof List ) {
+ addListToMapList( mapList, e.getKey(), ( List<Object> ) e.getValue() );
+ }
+ else {
+ addMapList( mapList, e.getKey(), e.getValue() );
+ }
+ }
+
+ return cast( mapList );
+ }
+
+
+ public static Map<String, ?> putPath( String path, Object value ) {
+ return putPath( null, path, value );
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public static Map<String, ?> putPath( Map<String, ?> map, String path, Object value ) {
+
+ if ( map == null ) {
+ map = new HashMap<String, Object>();
+ }
+
+ int i = path.indexOf( '.' );
+ if ( i < 0 ) {
+ ( ( Map<String, Object> ) map ).put( path, value );
+ return map;
+ }
+ String segment = path.substring( 0, i ).trim();
+ if ( isNotBlank( segment ) ) {
+ Object o = map.get( segment );
+ if ( ( o != null ) && ( !( o instanceof Map ) ) ) {
+ return map;
+ }
+ Map<String, Object> subMap = ( Map<String, Object> ) o;
+ if ( subMap == null ) {
+ subMap = new HashMap<String, Object>();
+ ( ( Map<String, Object> ) map ).put( segment, subMap );
+ }
+ String subPath = path.substring( i + 1 );
+ if ( isNotBlank( subPath ) ) {
+ putPath( subMap, subPath, value );
+ }
+ }
+
+ return map;
+ }
+
+
+ public static <K, V> Map<K, V> emptyMapWithKeys( Map<K, V> map ) {
+ Map<K, V> newMap = new HashMap<K, V>();
+
+ for ( K k : map.keySet() ) {
+ newMap.put( k, null );
+ }
+
+ return newMap;
+ }
+
+
+ public static boolean hasKeys( Map<?, ?> map, String... keys ) {
+ if ( map == null ) {
+ return false;
+ }
+ for ( String key : keys ) {
+ if ( !map.containsKey( key ) ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+
+ public static boolean hasKeys( Map<?, ?> map, Set<String> keys ) {
+ if ( map == null ) {
+ return false;
+ }
+ return map.keySet().containsAll( keys );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/StringUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/StringUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/StringUtils.java
new file mode 100644
index 0000000..8aabbbf
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/StringUtils.java
@@ -0,0 +1,172 @@
+/*
+ * 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.util.Arrays;
+
+import org.apache.commons.io.IOUtils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.usergrid.persistence.index.utils.ConversionUtils.string;
+
+
+public class StringUtils extends org.apache.commons.lang.StringUtils {
+
+ private static final Logger LOG = LoggerFactory.getLogger( StringUtils.class );
+
+
+ public static Object lower( Object obj ) {
+ if ( !( obj instanceof String ) ) {
+ return obj;
+ }
+ return ( ( String ) obj ).toLowerCase();
+ }
+
+
+ public static String stringOrSubstringAfterLast( String str, char c ) {
+ if ( str == null ) {
+ return null;
+ }
+ int i = str.lastIndexOf( c );
+ if ( i != -1 ) {
+ return str.substring( i + 1 );
+ }
+ return str;
+ }
+
+
+ public static String stringOrSubstringBeforeLast( String str, char c ) {
+ if ( str == null ) {
+ return null;
+ }
+ int i = str.lastIndexOf( c );
+ if ( i != -1 ) {
+ return str.substring( 0, i );
+ }
+ return str;
+ }
+
+
+ public static String stringOrSubstringBeforeFirst( String str, char c ) {
+ if ( str == null ) {
+ return null;
+ }
+ int i = str.indexOf( c );
+ if ( i != -1 ) {
+ return str.substring( 0, i );
+ }
+ return str;
+ }
+
+
+ public static String stringOrSubstringAfterFirst( String str, char c ) {
+ if ( str == null ) {
+ return null;
+ }
+ int i = str.indexOf( c );
+ if ( i != -1 ) {
+ return str.substring( i + 1 );
+ }
+ return str;
+ }
+
+
+ public static String compactWhitespace( String str ) {
+ if ( str == null ) {
+ return null;
+ }
+ boolean prevWS = false;
+ StringBuilder builder = new StringBuilder();
+ for ( int i = 0; i < str.length(); i++ ) {
+ char c = str.charAt( i );
+ if ( Character.isWhitespace( c ) ) {
+ if ( !prevWS ) {
+ builder.append( ' ' );
+ }
+ prevWS = true;
+ }
+ else {
+ prevWS = false;
+ builder.append( c );
+ }
+ }
+ return builder.toString().trim();
+ }
+
+
+ /** @return new string with replace applied */
+ public static String replaceAll( String source, String find, String replace ) {
+ if ( source == null ) {
+ return null;
+ }
+ while ( true ) {
+ String old = source;
+ source = source.replaceAll( find, replace );
+ if ( source.equals( old ) ) {
+ return source;
+ }
+ }
+ }
+
+
+ public static String toString( Object obj ) {
+ return string( obj );
+ }
+
+
+ public static String toStringFormat( Object obj, String format ) {
+ if ( obj != null ) {
+ if ( format != null ) {
+ if ( obj.getClass().isArray() ) {
+ return String.format( format, Arrays.toString( ( Object[] ) obj ) );
+ }
+ return String.format( format, string( obj ) );
+ }
+ else {
+ return string( obj );
+ }
+ }
+ return "";
+ }
+
+
+ public static boolean isString( Object obj ) {
+ return obj instanceof String;
+ }
+
+
+ public static boolean isStringOrNull( Object obj ) {
+ if ( obj == null ) {
+ return true;
+ }
+ return obj instanceof String;
+ }
+
+
+ public static String readClasspathFileAsString( String filePath ) {
+ try {
+ return IOUtils.toString( StringUtils.class.getResourceAsStream( filePath ) );
+ }
+ catch ( Exception e ) {
+ LOG.error( "Error getting file from classpath: " + filePath, e );
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/UUIDUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/UUIDUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/UUIDUtils.java
new file mode 100644
index 0000000..fdffaef
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/utils/UUIDUtils.java
@@ -0,0 +1,412 @@
+/*
+ * 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.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.ReentrantLock;
+
+import com.fasterxml.uuid.EthernetAddress;
+import com.fasterxml.uuid.UUIDComparator;
+
+import static com.fasterxml.uuid.impl.UUIDUtil.BYTE_OFFSET_CLOCK_HI;
+import static com.fasterxml.uuid.impl.UUIDUtil.BYTE_OFFSET_CLOCK_LO;
+import static com.fasterxml.uuid.impl.UUIDUtil.BYTE_OFFSET_CLOCK_MID;
+import static com.fasterxml.uuid.impl.UUIDUtil.BYTE_OFFSET_CLOCK_SEQUENCE;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.commons.codec.binary.Base64.decodeBase64;
+import static org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString;
+
+import static org.apache.usergrid.persistence.index.utils.ConversionUtils.bytes;
+import static org.apache.usergrid.persistence.index.utils.ConversionUtils.uuid;
+
+
+public class UUIDUtils {
+ private static final Logger LOG = LoggerFactory.getLogger( UUIDUtils.class );
+ private static final int[] MICROS = new int[1000];
+
+
+ static {
+ for ( int x = 0; x < 1000; x++ ) {
+ MICROS[x] = x * 10;
+ }
+ }
+
+
+ private static ReentrantLock tsLock = new ReentrantLock( true );
+
+ public static final UUID MIN_TIME_UUID = UUID.fromString( "00000000-0000-1000-8000-000000000000" );
+
+ public static final UUID MAX_TIME_UUID = UUID.fromString( "ffffffff-ffff-1fff-bfff-ffffffffffff" );
+
+ public static final UUID ZERO_UUID = new UUID( 0, 0 );
+
+ private static long timestampMillisNow = System.currentTimeMillis();
+
+ private static AtomicInteger currentMicrosPoint = new AtomicInteger( 0 );
+ private static AtomicInteger customMicrosPointer = new AtomicInteger( 0 );
+
+
+ /**
+ * Return the "next" UUID in micro second resolution. <b>WARNING</b>: this is designed to return the next unique
+ * timestamped UUID for this JVM. Depending on velocity of the call, this method may block internally to insure that
+ * "now" is kept in sync with the UUIDs being generated by this call.
+ * <p/>
+ * In other words, we will intentionally burn CPU insuring that this method is not executed more than 10k -1 times
+ * per millisecond and guarantee that those microseconds held within are sequential.
+ * <p/>
+ * If we did not do this, you would get <b>timestamp collision</b> even though the UUIDs will technically be
+ * 'unique.'
+ */
+ public static java.util.UUID newTimeUUID() {
+ // get & inc counter, but roll on 1k (because we divide by 10 on retrieval)
+ // if count + currentMicro > 1k, block and roll
+ tsLock.lock();
+ long ts = System.currentTimeMillis();
+ if ( ts > timestampMillisNow ) {
+ timestampMillisNow = ts;
+ currentMicrosPoint.set( 0 );
+ }
+ int pointer = currentMicrosPoint.getAndIncrement();
+ try {
+ if ( pointer > 990 ) {
+ TimeUnit.MILLISECONDS.sleep( 1L );
+ }
+ }
+ catch ( Exception ex ) {
+ ex.printStackTrace();
+ }
+ finally {
+ tsLock.unlock();
+ }
+ return newTimeUUID( ts, MICROS[pointer] );
+ }
+
+
+ private static final long KCLOCK_OFFSET = 0x01b21dd213814000L;
+ private static final long KCLOCK_MULTIPLIER_L = 10000L;
+
+ private static final Random CLOCK_SEQ_RANDOM = new Random();
+
+
+ // 14 bits of randomness
+ private static int getRandomClockSequence() {
+ return CLOCK_SEQ_RANDOM.nextInt() & 0x3FFF;
+ }
+
+
+ private static void setTimestamp( long timestamp, byte[] uuidBytes, int clockSeq, int timeOffset ) {
+
+ timestamp *= KCLOCK_MULTIPLIER_L;
+ timestamp += KCLOCK_OFFSET;
+ timestamp += timeOffset;
+
+ // Set random clock sequence
+ uuidBytes[BYTE_OFFSET_CLOCK_SEQUENCE] = ( byte ) ( clockSeq >> 8 );
+ uuidBytes[BYTE_OFFSET_CLOCK_SEQUENCE + 1] = ( byte ) clockSeq;
+
+ // Set variant
+ uuidBytes[BYTE_OFFSET_CLOCK_SEQUENCE] &= 0x3F;
+ uuidBytes[BYTE_OFFSET_CLOCK_SEQUENCE] |= 0x80;
+ setTime( uuidBytes, timestamp );
+ }
+
+
+ @SuppressWarnings("all")
+ private static void setTime( byte[] uuidBytes, long timestamp ) {
+
+ // Time fields aren't nicely split across the UUID, so can't just
+ // linearly dump the stamp:
+ int clockHi = ( int ) ( timestamp >>> 32 );
+ int clockLo = ( int ) timestamp;
+
+ uuidBytes[BYTE_OFFSET_CLOCK_HI] = ( byte ) ( clockHi >>> 24 );
+ uuidBytes[BYTE_OFFSET_CLOCK_HI + 1] = ( byte ) ( clockHi >>> 16 );
+ uuidBytes[BYTE_OFFSET_CLOCK_MID] = ( byte ) ( clockHi >>> 8 );
+ uuidBytes[BYTE_OFFSET_CLOCK_MID + 1] = ( byte ) clockHi;
+
+ uuidBytes[BYTE_OFFSET_CLOCK_LO] = ( byte ) ( clockLo >>> 24 );
+ uuidBytes[BYTE_OFFSET_CLOCK_LO + 1] = ( byte ) ( clockLo >>> 16 );
+ uuidBytes[BYTE_OFFSET_CLOCK_LO + 2] = ( byte ) ( clockLo >>> 8 );
+ uuidBytes[BYTE_OFFSET_CLOCK_LO + 3] = ( byte ) clockLo;
+
+ // Set version
+ uuidBytes[BYTE_OFFSET_CLOCK_HI] &= 0x0F;
+ uuidBytes[BYTE_OFFSET_CLOCK_HI] |= 0x10;
+ }
+
+
+ /**
+ * Generate a timeuuid with the given timestamp in milliseconds and the time offset. Useful when you need to
+ * generate sequential UUIDs for the same period in time. I.E
+ * <p/>
+ * newTimeUUID(1000, 0) <br/> newTimeUUID(1000, 1) <br /> newTimeUUID(1000, 2) <br />
+ * <p/>
+ * etc.
+ * <p/>
+ * Only use this method if you are absolutely sure you need it. When it doubt use the method without the timestamp
+ * offset
+ *
+ * @param ts The timestamp in milliseconds
+ * @param timeoffset The offset, which should always be <= 10000. If you go beyond this range, the millisecond will
+ * be incremented since this is beyond the possible values when coverrting from millis to 1/10 microseconds stored
+ * in the time uuid.
+ */
+ public static UUID newTimeUUID( long ts, int timeoffset ) {
+ if ( ts == 0 ) {
+ return newTimeUUID();
+ }
+
+ byte[] uuidBytes = new byte[16];
+ // 47 bits of randomness
+ EthernetAddress eth = EthernetAddress.constructMulticastAddress();
+ eth.toByteArray( uuidBytes, 10 );
+ setTimestamp( ts, uuidBytes, getRandomClockSequence(), timeoffset );
+
+ return uuid( uuidBytes );
+ }
+
+
+ /**
+ * Generate a new UUID with the given time stamp in milliseconds. This method guarantees that subsequent calls will
+ * be of increasing value chronologically. If a large number of subsequent calls are made to this method (>1000)
+ * with the same timestamp, you will have non-unique temporal values stored in your UUID.
+ */
+ public static UUID newTimeUUID( long ts ) {
+ tsLock.lock();
+ int pointer = customMicrosPointer.getAndIncrement();
+ try {
+ if ( pointer > 990 ) {
+ customMicrosPointer.set( 0 );
+ }
+ }
+ finally {
+ tsLock.unlock();
+ }
+ return newTimeUUID( ts, MICROS[pointer] );
+ }
+
+
+ public static UUID minTimeUUID( long ts ) {
+ byte[] uuidBytes = new byte[16];
+ setTimestamp( ts, uuidBytes, 0, 0 );
+
+ return uuid( uuidBytes );
+ }
+
+
+ public static UUID maxTimeUUID( long ts ) {
+ byte[] uuidBytes = new byte[16];
+ uuidBytes[10] = ( byte ) 0xFF;
+ uuidBytes[11] = ( byte ) 0xFF;
+ uuidBytes[12] = ( byte ) 0xFF;
+ uuidBytes[13] = ( byte ) 0xFF;
+ uuidBytes[14] = ( byte ) 0xFF;
+ uuidBytes[15] = ( byte ) 0xFF;
+ setTimestamp( ts, uuidBytes, 0x3FFF, 0x1FFF );
+
+ return uuid( uuidBytes );
+ }
+
+
+ /** Returns the minimum UUID */
+ public static UUID min( UUID first, UUID second ) {
+ if ( first == null ) {
+ if ( second == null ) {
+ return null;
+ }
+ return second;
+ }
+
+ if ( second == null ) {
+ return first;
+ }
+
+ if ( compare( first, second ) < 0 ) {
+ return first;
+ }
+ return second;
+ }
+
+
+ /** Returns the minimum UUID */
+ public static UUID max( UUID first, UUID second ) {
+ if ( first == null ) {
+ if ( second == null ) {
+ return null;
+ }
+ return second;
+ }
+
+ if ( second == null ) {
+ return first;
+ }
+
+ if ( compare( first, second ) < 0 ) {
+ return second;
+ }
+ return first;
+ }
+
+
+ /** Returns a UUID that is -1 of the passed uuid, sorted by time uuid only */
+ public static UUID decrement( UUID uuid ) {
+ if ( !isTimeBased( uuid ) ) {
+ throw new IllegalArgumentException( "The uuid must be a time type" );
+ }
+
+
+ //timestamp is in the 60 bit timestamp
+ long timestamp = uuid.timestamp();
+ timestamp--;
+
+ if ( timestamp < 0 ) {
+ throw new IllegalArgumentException( "You must specify a time uuid with a timestamp > 0" );
+ }
+
+ //get our bytes, then set the smaller timestamp into it
+ byte[] uuidBytes = bytes( uuid );
+
+ setTime( uuidBytes, timestamp );
+
+ return uuid( uuidBytes );
+ }
+
+
+ public static boolean isTimeBased( UUID uuid ) {
+ if ( uuid == null ) {
+ return false;
+ }
+ return uuid.version() == 1;
+ }
+
+
+ public static long getTimestampInMillis( UUID uuid ) {
+ if ( uuid == null ) {
+ return 0;
+ }
+ long t = uuid.timestamp();
+ return ( t - KCLOCK_OFFSET ) / KCLOCK_MULTIPLIER_L;
+ }
+
+
+ public static long getTimestampInMicros( UUID uuid ) {
+ if ( uuid == null ) {
+ return 0;
+ }
+ long t = uuid.timestamp();
+ return ( t - KCLOCK_OFFSET ) / 10;
+ }
+
+
+ public static UUID tryGetUUID( String s ) {
+ if ( s == null ) {
+ return null;
+ }
+ if ( s.length() != 36 ) {
+ return null;
+ }
+ // 8-4-4-4-12
+ // 0-7,8,9-12,13,14-17,18,19-22,23,24-35
+ if ( s.charAt( 8 ) != '-' ) {
+ return null;
+ }
+ if ( s.charAt( 13 ) != '-' ) {
+ return null;
+ }
+ if ( s.charAt( 18 ) != '-' ) {
+ return null;
+ }
+ if ( s.charAt( 23 ) != '-' ) {
+ return null;
+ }
+ UUID uuid = null;
+ try {
+ uuid = UUID.fromString( s );
+ }
+ catch ( Exception e ) {
+ LOG.info( "Could not convert String {} into a UUID", s, e );
+ }
+ return uuid;
+ }
+
+
+ public static boolean isUUID( String s ) {
+ return tryGetUUID( s ) != null;
+ }
+
+
+ public static UUID tryExtractUUID( String s ) {
+ if ( s == null ) {
+ return null;
+ }
+ if ( s.length() < 36 ) {
+ return null;
+ }
+ return tryGetUUID( s.substring( 0, 36 ) );
+ }
+
+
+ public static UUID tryExtractUUID( String s, int offset ) {
+ if ( s == null ) {
+ return null;
+ }
+ if ( ( s.length() - offset ) < 36 ) {
+ return null;
+ }
+ return tryGetUUID( s.substring( offset, offset + 36 ) );
+ }
+
+
+ public static String toBase64( UUID id ) {
+ if ( id == null ) {
+ return null;
+ }
+ return encodeBase64URLSafeString( bytes( id ) );
+ }
+
+
+ public static UUID fromBase64( String str ) {
+ if ( str == null ) {
+ return null;
+ }
+ byte[] bytes = decodeBase64( str );
+ if ( bytes.length != 16 ) {
+ return null;
+ }
+ return uuid( bytes );
+ }
+
+
+ public static int compare( UUID u1, UUID u2 ) {
+ return UUIDComparator.staticCompare( u1, u2 );
+ }
+
+
+ public static List<UUID> sort( List<UUID> uuids ) {
+ Collections.sort( uuids, new UUIDComparator() );
+ return uuids;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CollectionIT.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CollectionIT.java
index 9feeaf6..187259d 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CollectionIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CollectionIT.java
@@ -41,11 +41,11 @@ import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
import org.apache.usergrid.persistence.model.entity.SimpleId;
import org.apache.usergrid.persistence.model.field.StringField;
-import org.apache.usergrid.persistence.query.Query;
-import org.apache.usergrid.persistence.query.Results;
-import org.apache.usergrid.utils.JsonUtils;
-import static org.apache.usergrid.utils.MapUtils.hashMap;
-import org.apache.usergrid.utils.UUIDUtils;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.query.Results;
+import org.apache.usergrid.persistence.index.utils.JsonUtils;
+import static org.apache.usergrid.persistence.index.utils.MapUtils.hashMap;
+import org.apache.usergrid.persistence.index.utils.UUIDUtils;
import org.jukito.JukitoRunner;
import org.jukito.UseModules;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CorePerformanceIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CorePerformanceIT.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CorePerformanceIT.java
index 827e917..2627298 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CorePerformanceIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CorePerformanceIT.java
@@ -42,8 +42,8 @@ import org.apache.usergrid.persistence.model.field.DoubleField;
import org.apache.usergrid.persistence.model.field.LongField;
import org.apache.usergrid.persistence.model.field.StringField;
import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.apache.usergrid.persistence.query.Query;
-import org.apache.usergrid.persistence.query.Results;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.query.Results;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexStressTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexStressTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexStressTest.java
index 605c44c..a3e38fc 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexStressTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexStressTest.java
@@ -34,8 +34,8 @@ import org.apache.usergrid.persistence.index.legacy.EntityManagerFacade;
import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.apache.usergrid.persistence.query.Query;
-import org.apache.usergrid.persistence.query.Results;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.query.Results;
import org.jukito.JukitoRunner;
import org.jukito.UseModules;
import static org.junit.Assert.assertNotNull;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexTest.java
index 423780c..f0c42f2 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityCollectionIndexTest.java
@@ -41,9 +41,9 @@ import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
import org.apache.usergrid.persistence.model.entity.SimpleId;
import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.apache.usergrid.persistence.query.Query;
-import org.apache.usergrid.persistence.query.Results;
-import org.apache.usergrid.utils.EntityBuilder;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.query.Results;
+import org.apache.usergrid.persistence.index.utils.EntityBuilder;
import org.jukito.JukitoRunner;
import org.jukito.UseModules;
import static org.junit.Assert.assertEquals;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoIT.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoIT.java
index 054dadd..4795783 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/GeoIT.java
@@ -37,11 +37,11 @@ import org.apache.usergrid.persistence.index.legacy.Point;
import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.apache.usergrid.persistence.query.EntityRef;
-import org.apache.usergrid.persistence.query.Query;
-import org.apache.usergrid.persistence.query.Results;
-import org.apache.usergrid.persistence.query.SimpleEntityRef;
-import org.apache.usergrid.utils.MapUtils;
+import org.apache.usergrid.persistence.index.query.EntityRef;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.query.Results;
+import org.apache.usergrid.persistence.index.query.SimpleEntityRef;
+import org.apache.usergrid.persistence.index.utils.MapUtils;
import org.jukito.JukitoRunner;
import org.jukito.UseModules;
import static org.junit.Assert.assertEquals;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexIT.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexIT.java
index 9bfae05..cd05605 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexIT.java
@@ -33,9 +33,9 @@ import org.apache.usergrid.persistence.index.legacy.EntityManagerFacade;
import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.apache.usergrid.persistence.query.Query;
-import org.apache.usergrid.persistence.query.Results;
-import org.apache.usergrid.utils.JsonUtils;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.query.Results;
+import org.apache.usergrid.persistence.index.utils.JsonUtils;
import org.jukito.JukitoRunner;
import org.jukito.UseModules;
import static org.junit.Assert.assertEquals;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/Application.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/Application.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/Application.java
index a7d461f..ba19b86 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/Application.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/Application.java
@@ -22,8 +22,8 @@ import java.util.Map;
import java.util.UUID;
import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.query.Query;
-import org.apache.usergrid.persistence.query.Results;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.query.Results;
import org.junit.rules.TestRule;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/CoreApplication.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/CoreApplication.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/CoreApplication.java
index fdb23c7..2160527 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/CoreApplication.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/CoreApplication.java
@@ -31,8 +31,8 @@ import org.slf4j.LoggerFactory;
import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.query.Query;
-import org.apache.usergrid.persistence.query.Results;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.query.Results;
public class CoreApplication implements Application, TestRule {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/CoreITSetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/CoreITSetupImpl.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/CoreITSetupImpl.java
index 56ba256..4c49627 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/CoreITSetupImpl.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/legacy/CoreITSetupImpl.java
@@ -19,7 +19,7 @@ package org.apache.usergrid.persistence.index.legacy;
import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
-import org.apache.usergrid.utils.JsonUtils;
+import org.apache.usergrid.persistence.index.utils.JsonUtils;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/AbstractIteratingQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/AbstractIteratingQueryIT.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/AbstractIteratingQueryIT.java
index 4113394..02bad1a 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/AbstractIteratingQueryIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/AbstractIteratingQueryIT.java
@@ -16,6 +16,8 @@
package org.apache.usergrid.persistence.query;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.query.Results;
import com.google.inject.Inject;
import java.util.ArrayList;
import java.util.Comparator;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/AllInConnectionNoTypeIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/AllInConnectionNoTypeIT.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/AllInConnectionNoTypeIT.java
index 8f0286f..4761448 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/AllInConnectionNoTypeIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/AllInConnectionNoTypeIT.java
@@ -16,6 +16,8 @@
package org.apache.usergrid.persistence.query;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.query.Results;
import org.apache.usergrid.persistence.index.legacy.CoreApplication;
import org.junit.Ignore;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java
index 8199c79..46ba6c3 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java
@@ -16,6 +16,8 @@
package org.apache.usergrid.persistence.query;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.index.query.Results;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/QueryTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/QueryTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/QueryTest.java
index 3b09c86..35e50de 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/QueryTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/QueryTest.java
@@ -19,28 +19,29 @@
package org.apache.usergrid.persistence.query;
+import org.apache.usergrid.persistence.index.query.Query;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
-import org.apache.usergrid.persistence.exceptions.QueryParseException;
+import org.apache.usergrid.persistence.index.exceptions.QueryParseException;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.usergrid.persistence.query.Query.SortDirection;
-import org.apache.usergrid.persistence.query.Query.SortPredicate;
-import org.apache.usergrid.persistence.query.tree.AndOperand;
-import org.apache.usergrid.persistence.query.tree.ContainsOperand;
-import org.apache.usergrid.persistence.query.tree.Equal;
-import org.apache.usergrid.persistence.query.tree.FloatLiteral;
-import org.apache.usergrid.persistence.query.tree.GreaterThan;
-import org.apache.usergrid.persistence.query.tree.GreaterThanEqual;
-import org.apache.usergrid.persistence.query.tree.LessThan;
-import org.apache.usergrid.persistence.query.tree.LessThanEqual;
-import org.apache.usergrid.persistence.query.tree.LongLiteral;
-import org.apache.usergrid.persistence.query.tree.NotOperand;
-import org.apache.usergrid.persistence.query.tree.StringLiteral;
-import org.apache.usergrid.persistence.query.tree.WithinOperand;
+import org.apache.usergrid.persistence.index.query.Query.SortDirection;
+import org.apache.usergrid.persistence.index.query.Query.SortPredicate;
+import org.apache.usergrid.persistence.index.query.tree.AndOperand;
+import org.apache.usergrid.persistence.index.query.tree.ContainsOperand;
+import org.apache.usergrid.persistence.index.query.tree.Equal;
+import org.apache.usergrid.persistence.index.query.tree.FloatLiteral;
+import org.apache.usergrid.persistence.index.query.tree.GreaterThan;
+import org.apache.usergrid.persistence.index.query.tree.GreaterThanEqual;
+import org.apache.usergrid.persistence.index.query.tree.LessThan;
+import org.apache.usergrid.persistence.index.query.tree.LessThanEqual;
+import org.apache.usergrid.persistence.index.query.tree.LongLiteral;
+import org.apache.usergrid.persistence.index.query.tree.NotOperand;
+import org.apache.usergrid.persistence.index.query.tree.StringLiteral;
+import org.apache.usergrid.persistence.index.query.tree.WithinOperand;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java
index 345bfea..e032855 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/GrammarTreeTest.java
@@ -19,6 +19,22 @@
package org.apache.usergrid.persistence.query.tree;
+import org.apache.usergrid.persistence.index.query.tree.LongLiteral;
+import org.apache.usergrid.persistence.index.query.tree.QueryFilterLexer;
+import org.apache.usergrid.persistence.index.query.tree.QueryFilterParser;
+import org.apache.usergrid.persistence.index.query.tree.ContainsOperand;
+import org.apache.usergrid.persistence.index.query.tree.NotOperand;
+import org.apache.usergrid.persistence.index.query.tree.LessThan;
+import org.apache.usergrid.persistence.index.query.tree.AndOperand;
+import org.apache.usergrid.persistence.index.query.tree.GreaterThan;
+import org.apache.usergrid.persistence.index.query.tree.LessThanEqual;
+import org.apache.usergrid.persistence.index.query.tree.UUIDLiteral;
+import org.apache.usergrid.persistence.index.query.tree.Operand;
+import org.apache.usergrid.persistence.index.query.tree.WithinOperand;
+import org.apache.usergrid.persistence.index.query.tree.OrOperand;
+import org.apache.usergrid.persistence.index.query.tree.StringLiteral;
+import org.apache.usergrid.persistence.index.query.tree.GreaterThanEqual;
+import org.apache.usergrid.persistence.index.query.tree.Equal;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@@ -26,9 +42,9 @@ import java.util.UUID;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.TokenRewriteStream;
-import org.apache.usergrid.persistence.exceptions.QueryParseException;
+import org.apache.usergrid.persistence.index.exceptions.QueryParseException;
import org.junit.Test;
-import org.apache.usergrid.persistence.query.Query;
+import org.apache.usergrid.persistence.index.query.Query;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/LongLiteralTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/LongLiteralTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/LongLiteralTest.java
index 67039e7..3813268 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/LongLiteralTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/LongLiteralTest.java
@@ -19,6 +19,7 @@
package org.apache.usergrid.persistence.query.tree;
+import org.apache.usergrid.persistence.index.query.tree.LongLiteral;
import org.antlr.runtime.CommonToken;
import org.junit.Test;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8f969d8d/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/StringLiteralTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/StringLiteralTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/StringLiteralTest.java
index 56ef54d..480b6c0 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/StringLiteralTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/query/tree/StringLiteralTest.java
@@ -17,7 +17,7 @@ package org.apache.usergrid.persistence.query.tree;
import org.antlr.runtime.CommonToken;
-import org.apache.usergrid.persistence.query.tree.StringLiteral;
+import org.apache.usergrid.persistence.index.query.tree.StringLiteral;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
[40/50] [abbrv] git commit: Add license headers to awscluster files.
Posted by sn...@apache.org.
Add license headers to awscluster files.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e7d8ece0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e7d8ece0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e7d8ece0
Branch: refs/heads/asyncqueue
Commit: e7d8ece0f8b88bd1a1a2b050531a88444ef0240c
Parents: f9d44a9
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Mar 25 12:39:35 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Mar 25 12:39:35 2014 -0400
----------------------------------------------------------------------
stack/awscluster/assembly.xml | 70 ++++++++++++--------
stack/awscluster/pom.xml | 16 +++++
.../src/main/dist/init_instance/create_raid0.sh | 18 +++++
.../main/dist/init_instance/init_db_server.sh | 19 ++++++
.../main/dist/init_instance/init_rest_server.sh | 19 ++++++
.../dist/init_instance/install_cassandra.sh | 19 ++++++
.../dist/init_instance/install_elasticsearch.sh | 19 ++++++
.../dist/init_instance/install_oraclejdk.sh | 19 ++++++
stack/awscluster/src/main/dist/update.sh | 18 +++++
.../src/main/groovy/configure_cassandra.groovy | 20 +++++-
.../main/groovy/configure_elasticsearch.groovy | 19 ++++++
.../src/main/groovy/configure_portal_new.groovy | 19 ++++++
.../src/main/groovy/configure_priam.groovy | 19 ++++++
.../src/main/groovy/configure_usergrid.groovy | 19 ++++++
.../src/main/groovy/registry_clear.groovy | 19 ++++++
.../src/main/groovy/registry_list.groovy | 19 ++++++
.../src/main/groovy/registry_register.groovy | 19 ++++++
.../src/main/groovy/tag_instance.groovy | 19 ++++++
.../src/main/groovy/wait_for_instances.groovy | 19 ++++++
19 files changed, 381 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/assembly.xml
----------------------------------------------------------------------
diff --git a/stack/awscluster/assembly.xml b/stack/awscluster/assembly.xml
index b5406dd..5be9ef3 100644
--- a/stack/awscluster/assembly.xml
+++ b/stack/awscluster/assembly.xml
@@ -1,29 +1,47 @@
<assembly>
- <id>any</id>
- <formats>
- <format>tar.gz</format>
- </formats>
-
- <includeBaseDirectory>false</includeBaseDirectory>
-
- <fileSets>
-
- <fileSet>
- <outputDirectory>.</outputDirectory>
- <directory>${project.basedir}/src/main/dist</directory>
- <includes>
- <include>**</include>
- </includes>
- </fileSet>
-
- <fileSet>
- <outputDirectory>./scripts</outputDirectory>
- <directory>./src/main/groovy</directory>
- <includes>
- <include>**</include>
- </includes>
- </fileSet>
-
- </fileSets>
+
+<!--
+ 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.
+ -->
+
+ <id>any</id>
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+
+ <fileSet>
+ <outputDirectory>.</outputDirectory>
+ <directory>${project.basedir}/src/main/dist</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ </fileSet>
+
+ <fileSet>
+ <outputDirectory>./scripts</outputDirectory>
+ <directory>./src/main/groovy</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ </fileSet>
+
+ </fileSets>
</assembly>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/pom.xml
----------------------------------------------------------------------
diff --git a/stack/awscluster/pom.xml b/stack/awscluster/pom.xml
index 9362f9f..2783c8c 100644
--- a/stack/awscluster/pom.xml
+++ b/stack/awscluster/pom.xml
@@ -1,5 +1,21 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<!--
+ 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.
+-->
<modelVersion>4.0.0</modelVersion>
<artifactId>awscluster</artifactId>
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/dist/init_instance/create_raid0.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/create_raid0.sh b/stack/awscluster/src/main/dist/init_instance/create_raid0.sh
index 401fcf4..80f75d8 100644
--- a/stack/awscluster/src/main/dist/init_instance/create_raid0.sh
+++ b/stack/awscluster/src/main/dist/init_instance/create_raid0.sh
@@ -1,5 +1,23 @@
#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. 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 additional information regarding
+# copyright in this work, please see the NOTICE file in the top level
+# directory of this distribution.
+#
+
# install postfix first and prevent it from prompting the user
debconf-set-selections <<< "postfix postfix/mailname string your.hostname.com"
debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/init_db_server.sh b/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
index 4c2e8c6..87db30c 100644
--- a/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
+++ b/stack/awscluster/src/main/dist/init_instance/init_db_server.sh
@@ -1,4 +1,23 @@
#!/bin/bash
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. 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 additional information regarding
+# copyright in this work, please see the NOTICE file in the top level
+# directory of this distribution.
+#
+
echo "${HOSTNAME}" > /etc/hostname
echo "127.0.0.1 ${HOSTNAME}" >> /etc/hosts
hostname `cat /etc/hostname`
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh b/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
index 3eaf58c..6b2c217 100644
--- a/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
+++ b/stack/awscluster/src/main/dist/init_instance/init_rest_server.sh
@@ -1,4 +1,23 @@
#!/bin/bash
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. 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 additional information regarding
+# copyright in this work, please see the NOTICE file in the top level
+# directory of this distribution.
+#
+
echo "${HOSTNAME}" > /etc/hostname
echo "127.0.0.1 ${HOSTNAME}" >> /etc/hosts
hostname `cat /etc/hostname`
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh b/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh
index 0467753..8e29161 100644
--- a/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh
+++ b/stack/awscluster/src/main/dist/init_instance/install_cassandra.sh
@@ -1,5 +1,24 @@
#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. 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 additional information regarding
+# copyright in this work, please see the NOTICE file in the top level
+# directory of this distribution.
+#
+
+
# Install and stop Cassandra
pushd /etc/apt/sources.list.d
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/dist/init_instance/install_elasticsearch.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/install_elasticsearch.sh b/stack/awscluster/src/main/dist/init_instance/install_elasticsearch.sh
index 080fa9a..432189a 100644
--- a/stack/awscluster/src/main/dist/init_instance/install_elasticsearch.sh
+++ b/stack/awscluster/src/main/dist/init_instance/install_elasticsearch.sh
@@ -1,5 +1,24 @@
#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. 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 additional information regarding
+# copyright in this work, please see the NOTICE file in the top level
+# directory of this distribution.
+#
+
+
# Install and stop ElasticSearch
pushd /etc/apt/sources.list.d
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/dist/init_instance/install_oraclejdk.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/init_instance/install_oraclejdk.sh b/stack/awscluster/src/main/dist/init_instance/install_oraclejdk.sh
index f81c5fa..20a2311 100644
--- a/stack/awscluster/src/main/dist/init_instance/install_oraclejdk.sh
+++ b/stack/awscluster/src/main/dist/init_instance/install_oraclejdk.sh
@@ -1,6 +1,25 @@
#!/bin/bash
pushd /tmp
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. 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 additional information regarding
+# copyright in this work, please see the NOTICE file in the top level
+# directory of this distribution.
+#
+
+
# Build environment for scripts
. /etc/profile.d/aws-credentials.sh
. /etc/profile.d/usergrid-env.sh
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/dist/update.sh
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/dist/update.sh b/stack/awscluster/src/main/dist/update.sh
index a908d55..a39197d 100644
--- a/stack/awscluster/src/main/dist/update.sh
+++ b/stack/awscluster/src/main/dist/update.sh
@@ -1,3 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. 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 additional information regarding
+# copyright in this work, please see the NOTICE file in the top level
+# directory of this distribution.
+#
+
sudo mkdir __tmpupdate__
pushd __tmpupdate__
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/groovy/configure_cassandra.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/configure_cassandra.groovy b/stack/awscluster/src/main/groovy/configure_cassandra.groovy
index f4b8e6e..eb45054 100644
--- a/stack/awscluster/src/main/groovy/configure_cassandra.groovy
+++ b/stack/awscluster/src/main/groovy/configure_cassandra.groovy
@@ -1,4 +1,22 @@
-//
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+
// configure_cassandra.groovy
//
// Emits Cassandra config file based on environment and Cassandra node
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy b/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy
index 6b90e17..aa03d8d 100644
--- a/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy
+++ b/stack/awscluster/src/main/groovy/configure_elasticsearch.groovy
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+
//
// configure_cassandra.groovy
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/groovy/configure_portal_new.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/configure_portal_new.groovy b/stack/awscluster/src/main/groovy/configure_portal_new.groovy
index 2f15223..af906e3 100644
--- a/stack/awscluster/src/main/groovy/configure_portal_new.groovy
+++ b/stack/awscluster/src/main/groovy/configure_portal_new.groovy
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+
//
// Emits dash/app/config.js file
//
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/groovy/configure_priam.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/configure_priam.groovy b/stack/awscluster/src/main/groovy/configure_priam.groovy
index 22f4661..dc7bb86 100644
--- a/stack/awscluster/src/main/groovy/configure_priam.groovy
+++ b/stack/awscluster/src/main/groovy/configure_priam.groovy
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+
//
// configure_priam.groovy
//
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/groovy/configure_usergrid.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/configure_usergrid.groovy b/stack/awscluster/src/main/groovy/configure_usergrid.groovy
index a3e710b..518d4df 100644
--- a/stack/awscluster/src/main/groovy/configure_usergrid.groovy
+++ b/stack/awscluster/src/main/groovy/configure_usergrid.groovy
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+
//
// configure_usergrid.groovy
//
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/groovy/registry_clear.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/registry_clear.groovy b/stack/awscluster/src/main/groovy/registry_clear.groovy
index 5baa537..b95c88f 100644
--- a/stack/awscluster/src/main/groovy/registry_clear.groovy
+++ b/stack/awscluster/src/main/groovy/registry_clear.groovy
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+
//
// registry_clear.groovy
//
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/groovy/registry_list.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/registry_list.groovy b/stack/awscluster/src/main/groovy/registry_list.groovy
index 9871a21..e54193b 100644
--- a/stack/awscluster/src/main/groovy/registry_list.groovy
+++ b/stack/awscluster/src/main/groovy/registry_list.groovy
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+
//
// registry_list.groovy
//
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/groovy/registry_register.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/registry_register.groovy b/stack/awscluster/src/main/groovy/registry_register.groovy
index 739c04e..04bc6a7 100644
--- a/stack/awscluster/src/main/groovy/registry_register.groovy
+++ b/stack/awscluster/src/main/groovy/registry_register.groovy
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+
//
// configure_usergrid.groovy
//
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/groovy/tag_instance.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/tag_instance.groovy b/stack/awscluster/src/main/groovy/tag_instance.groovy
index 76c5e86..7e5ed84 100644
--- a/stack/awscluster/src/main/groovy/tag_instance.groovy
+++ b/stack/awscluster/src/main/groovy/tag_instance.groovy
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+
//
// tag_instance.groovy
//
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7d8ece0/stack/awscluster/src/main/groovy/wait_for_instances.groovy
----------------------------------------------------------------------
diff --git a/stack/awscluster/src/main/groovy/wait_for_instances.groovy b/stack/awscluster/src/main/groovy/wait_for_instances.groovy
index 75b73b7..2e22a64 100644
--- a/stack/awscluster/src/main/groovy/wait_for_instances.groovy
+++ b/stack/awscluster/src/main/groovy/wait_for_instances.groovy
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. 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 additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+
//
// wait_for_cassandra.groovy
//
[29/50] [abbrv] git commit: Merge pull request #72 from
lgov/USERGRID-100
Posted by sn...@apache.org.
Merge pull request #72 from lgov/USERGRID-100
USERGRID-100 - Add license headers to the iOS sdk files, add NOTICE + update LICENSE.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/0ed192fe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/0ed192fe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/0ed192fe
Branch: refs/heads/asyncqueue
Commit: 0ed192fe2fb2091b0ff1687c94b9b898353b8209
Parents: 24425d5 e02f3cf
Author: Sungju Jin <su...@softwaregeeks.org>
Authored: Fri Mar 21 21:22:23 2014 +0900
Committer: Sungju Jin <su...@softwaregeeks.org>
Committed: Fri Mar 21 21:22:23 2014 +0900
----------------------------------------------------------------------
LICENSE | 65 +++++++++++++++++++++++++++-
NOTICE | 11 +++++
sdks/ios/UGAPI/UGActivity.h | 17 ++++++++
sdks/ios/UGAPI/UGActivity.m | 17 ++++++++
sdks/ios/UGAPI/UGClient.h | 17 ++++++++
sdks/ios/UGAPI/UGClient.m | 17 ++++++++
sdks/ios/UGAPI/UGClientDelegate.h | 17 ++++++++
sdks/ios/UGAPI/UGClientResponse.h | 17 ++++++++
sdks/ios/UGAPI/UGClientResponse.m | 17 ++++++++
sdks/ios/UGAPI/UGHTTPManager.h | 17 ++++++++
sdks/ios/UGAPI/UGHTTPManager.m | 17 ++++++++
sdks/ios/UGAPI/UGMultiStepAction.h | 17 ++++++++
sdks/ios/UGAPI/UGMultiStepAction.m | 17 ++++++++
sdks/ios/UGAPI/UGQuery.h | 17 ++++++++
sdks/ios/UGAPI/UGQuery.m | 17 ++++++++
sdks/ios/UGAPI/UGUser.h | 17 ++++++++
sdks/ios/UGAPI/UGUser.m | 23 +++++++---
sdks/ios/UGAPIApp/UGAPIApp-Prefix.pch | 17 ++++++++
sdks/ios/UGAPIApp/UGAppAppDelegate.h | 23 +++++++---
sdks/ios/UGAPIApp/UGAppAppDelegate.m | 23 +++++++---
sdks/ios/UGAPIApp/UGAppViewController.h | 23 +++++++---
sdks/ios/UGAPIApp/UGAppViewController.m | 23 +++++++---
sdks/ios/UGAPIApp/main.m | 23 +++++++---
sdks/ios/UGAPIAppTests/UGAPIAppTests.h | 23 +++++++---
sdks/ios/UGAPIAppTests/UGAPIAppTests.m | 23 +++++++---
25 files changed, 458 insertions(+), 57 deletions(-)
----------------------------------------------------------------------
[03/50] [abbrv] git commit: Test case for default query string options
Posted by sn...@apache.org.
Test case for default query string options
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/55462ea0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/55462ea0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/55462ea0
Branch: refs/heads/asyncqueue
Commit: 55462ea09173292a8418020bf6514accb3404998
Parents: 00afe2c
Author: ryan bridges <rb...@apigee.com>
Authored: Thu Mar 13 10:24:32 2014 -0400
Committer: ryan bridges <rb...@apigee.com>
Committed: Thu Mar 13 10:28:48 2014 -0400
----------------------------------------------------------------------
sdks/html5-javascript/lib/modules/Client.js | 2 +-
sdks/html5-javascript/tests/mocha/test.js | 25 ++++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/55462ea0/sdks/html5-javascript/lib/modules/Client.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/lib/modules/Client.js b/sdks/html5-javascript/lib/modules/Client.js
index 242b08b..63e5a13 100644
--- a/sdks/html5-javascript/lib/modules/Client.js
+++ b/sdks/html5-javascript/lib/modules/Client.js
@@ -50,7 +50,7 @@
var mQuery = options.mQuery || false; //is this a query to the management endpoint?
var orgName = this.get('orgName');
var appName = this.get('appName');
- var default_qs=this.get('default_qs');
+ var default_qs=this.getObject('default_qs');
var uri;
var logoutCallback=function(){
if (typeof(this.logoutCallback) === 'function') {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/55462ea0/sdks/html5-javascript/tests/mocha/test.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/tests/mocha/test.js b/sdks/html5-javascript/tests/mocha/test.js
index 7b78e04..a60a61c 100644
--- a/sdks/html5-javascript/tests/mocha/test.js
+++ b/sdks/html5-javascript/tests/mocha/test.js
@@ -186,6 +186,31 @@ describe('Usergrid', function(){
method: 'GET',
endpoint: 'users'
};
+ it('should persist default query parameters', function(done) {
+ //create new client with default params
+ var client=new Usergrid.Client({
+ orgName: 'yourorgname',
+ appName: 'sandbox',
+ logging: false, //optional - turn on logging, off by default
+ buildCurl: true, //optional - turn on curl commands, off by default
+ qs:{
+ test1:'test1',
+ test2:'test2'
+ }
+ });
+ var default_qs=client.getObject('default_qs');
+ assert(default_qs.test1==='test1', "the default query parameters were not persisted");
+ assert(default_qs.test2==='test2', "the default query parameters were not persisted");
+ client.request({
+ method: 'GET',
+ endpoint: 'users'
+ }, function(err, data) {
+ //console.log(err, data);
+ assert(data.params.test2[0]==='test2', "the default query parameters were not sent to the backend");
+ assert(data.params.test1[0]==='test1', "the default query parameters were not sent to the backend");
+ done();
+ });
+ });
it('should CREATE a new user', function(done) {
client.request({
method: 'POST',
[32/50] [abbrv] git commit: Merge branch 'master' of
https://github.com/usergrid/usergrid into Export_Persistance_Integration
Posted by sn...@apache.org.
Merge branch 'master' of https://github.com/usergrid/usergrid into Export_Persistance_Integration
# By ryan bridges (6) and Lieven Govaerts (2)
# Via ryan bridges (2) and others
* 'master' of https://github.com/usergrid/usergrid:
Added Counters section to readme
tweaking formatting in readme
Changing script reference to local path
Adding basic asset documentation to README
Update changelog for 0.10.8
Updating version to 0.10.8. Updating references to point to apache documentation
For USERGRID-100, add a NOTICE file and update LICENSE for the SBJson and SSKeychain components in the iOS SDK..
Partial fix for USERGRID-100: Add the correct A.L. headers to the ios sdk files.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/153cf717
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/153cf717
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/153cf717
Branch: refs/heads/asyncqueue
Commit: 153cf71762fe0baada6300d0d9259816278858b0
Parents: 1f71604 3f93ca7
Author: grey <gr...@apigee.com>
Authored: Fri Mar 21 11:48:18 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Fri Mar 21 11:48:18 2014 -0700
----------------------------------------------------------------------
LICENSE | 65 ++++++++-
NOTICE | 11 ++
sdks/html5-javascript/README.md | 206 ++++++++++++++++++++++-----
sdks/html5-javascript/changelog.md | 10 +-
sdks/ios/UGAPI/UGActivity.h | 17 +++
sdks/ios/UGAPI/UGActivity.m | 17 +++
sdks/ios/UGAPI/UGClient.h | 17 +++
sdks/ios/UGAPI/UGClient.m | 17 +++
sdks/ios/UGAPI/UGClientDelegate.h | 17 +++
sdks/ios/UGAPI/UGClientResponse.h | 17 +++
sdks/ios/UGAPI/UGClientResponse.m | 17 +++
sdks/ios/UGAPI/UGHTTPManager.h | 17 +++
sdks/ios/UGAPI/UGHTTPManager.m | 17 +++
sdks/ios/UGAPI/UGMultiStepAction.h | 17 +++
sdks/ios/UGAPI/UGMultiStepAction.m | 17 +++
sdks/ios/UGAPI/UGQuery.h | 17 +++
sdks/ios/UGAPI/UGQuery.m | 17 +++
sdks/ios/UGAPI/UGUser.h | 17 +++
sdks/ios/UGAPI/UGUser.m | 23 ++-
sdks/ios/UGAPIApp/UGAPIApp-Prefix.pch | 17 +++
sdks/ios/UGAPIApp/UGAppAppDelegate.h | 23 ++-
sdks/ios/UGAPIApp/UGAppAppDelegate.m | 23 ++-
sdks/ios/UGAPIApp/UGAppViewController.h | 23 ++-
sdks/ios/UGAPIApp/UGAppViewController.m | 23 ++-
sdks/ios/UGAPIApp/main.m | 23 ++-
sdks/ios/UGAPIAppTests/UGAPIAppTests.h | 23 ++-
sdks/ios/UGAPIAppTests/UGAPIAppTests.m | 23 ++-
27 files changed, 639 insertions(+), 92 deletions(-)
----------------------------------------------------------------------
[45/50] [abbrv] Put queryindex classes all under one top-level
"index" package to eliminate conflict with old persistence classes.
Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/ListUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/ListUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/ListUtils.java
deleted file mode 100644
index db56cdd..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/ListUtils.java
+++ /dev/null
@@ -1,232 +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.utils;
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.UUID;
-
-import org.apache.commons.lang.math.NumberUtils;
-import org.apache.usergrid.persistence.collection.util.EntityUtils;
-import org.apache.usergrid.persistence.model.entity.Id;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class ListUtils extends org.apache.commons.collections.ListUtils {
- private static final Logger LOG = LoggerFactory.getLogger( ListUtils.class );
-
-
- public static <A> A first( List<A> list ) {
- if ( list == null ) {
- return null;
- }
- if ( list.size() == 0 ) {
- return null;
- }
- return list.get( 0 );
- }
-
-
- public static <A> A last( List<A> list ) {
- if ( list == null ) {
- return null;
- }
- if ( list.size() == 0 ) {
- return null;
- }
- return list.get( list.size() - 1 );
- }
-
-
- public static <A> Integer firstInteger( List<A> list ) {
- A a = first( list );
- if ( a == null ) {
- return null;
- }
-
- if ( a instanceof Integer ) {
- return ( Integer ) a;
- }
-
- try {
- return NumberUtils.toInt( ( String ) a );
- }
- catch ( Exception e ) {
- LOG.warn( "Could not convert list item {} to int", a, e );
- }
- return null;
- }
-
-
- public static <A> Long firstLong( List<A> list ) {
- A a = first( list );
- if ( a == null ) {
- return null;
- }
-
- if ( a instanceof Long ) {
- return ( Long ) a;
- }
-
- try {
- return NumberUtils.toLong( ( String ) a );
- }
- catch ( Exception e ) {
- LOG.warn( "Could not convert list item {} to long", a, e );
- }
- return null;
- }
-
-
- public static <A> Boolean firstBoolean( List<A> list ) {
- A a = first( list );
- if ( a == null ) {
- return null;
- }
-
- if ( a instanceof Boolean ) {
- return ( Boolean ) a;
- }
-
- try {
- return Boolean.parseBoolean( ( String ) a );
- }
- catch ( Exception e ) {
- LOG.warn( "Could not convert list item {} to boolean", a, e );
- }
- return null;
- }
-
-
- public static <A> UUID firstUuid( List<A> list ) {
- A i = first( list );
- if ( i == null ) {
- return null;
- }
-
- if ( i instanceof UUID ) {
- return ( UUID ) i;
- }
-
- try {
- return UUIDUtils.tryGetUUID( ( String ) i );
- }
- catch ( Exception e ) {
- LOG.warn( "Could not convert list item {} to UUID", i, e );
- }
- return null;
- }
-
-
- public static boolean isEmpty( List<?> list ) {
- return ( list == null ) || ( list.size() == 0 );
- }
-
-
- public static <T> List<T> dequeueCopy( List<T> list ) {
- if ( !isEmpty( list ) ) {
- list = list.subList( 1, list.size() );
- }
- return list;
- }
-
-
- public static <T> List<T> initCopy( List<T> list ) {
- if ( !isEmpty( list ) ) {
- list = new ArrayList<T>( list );
- }
- else {
- list = new ArrayList<T>();
- }
- return list;
- }
-
-
- public static <T> T dequeue( List<T> list ) {
- if ( !isEmpty( list ) ) {
- return list.remove( 0 );
- }
- return null;
- }
-
-
- public static <T> List<T> queue( List<T> list, T item ) {
- if ( list == null ) {
- list = new ArrayList<T>();
- }
- list.add( item );
- return list;
- }
-
-
- public static <T> List<T> requeue( List<T> list, T item ) {
- if ( list == null ) {
- list = new ArrayList<T>();
- }
- list.add( 0, item );
- return list;
- }
-
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public static List<?> flatten( Collection<?> l ) {
- boolean hasCollection = false;
- for ( Object o : l ) {
- if ( o instanceof Collection ) {
- hasCollection = true;
- break;
- }
- }
- if ( !hasCollection && ( l instanceof List ) ) {
- return ( List<?> ) l;
- }
- List newList = new ArrayList();
- for ( Object o : l ) {
- if ( o instanceof List ) {
- newList.addAll( flatten( ( List ) o ) );
- }
- else {
- newList.add( o );
- }
- }
- return newList;
- }
-
-
- public static boolean anyNull( List<?> l ) {
- for ( Object o : l ) {
- if ( o == null ) {
- return true;
- }
- }
- return false;
- }
-
-
- public static boolean anyNull( Object... objects ) {
- for ( Object o : objects ) {
- if ( o == null ) {
- return true;
- }
- }
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/MapUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/MapUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/MapUtils.java
deleted file mode 100644
index 12da2e0..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/MapUtils.java
+++ /dev/null
@@ -1,377 +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.utils;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import static org.apache.commons.lang.StringUtils.isNotBlank;
-
-import static org.apache.usergrid.utils.ClassUtils.cast;
-
-
-public class MapUtils extends org.apache.commons.collections.MapUtils {
-
- public static <A, B> void addMapSet( Map<A, Set<B>> map, A a, B b ) {
- addMapSet( map, false, a, b );
- }
-
-
- @SuppressWarnings("unchecked")
- public static <A, B> void addMapSet( Map<A, Set<B>> map, boolean ignoreCase, A a, B b ) {
-
- Set<B> setB = map.get( a );
- if ( setB == null ) {
- if ( ignoreCase && ( b instanceof String ) ) {
- setB = ( Set<B> ) new TreeSet<String>( String.CASE_INSENSITIVE_ORDER );
- }
- else {
- setB = new LinkedHashSet<B>();
- }
- map.put( a, setB );
- }
- setB.add( b );
- }
-
-
- public static <A, B, C> void addMapMapSet( Map<A, Map<B, Set<C>>> map, A a, B b, C c ) {
- addMapMapSet( map, false, a, b, c );
- }
-
-
- @SuppressWarnings("unchecked")
- public static <A, B, C> void addMapMapSet( Map<A, Map<B, Set<C>>> map, boolean ignoreCase, A a, B b, C c ) {
-
- Map<B, Set<C>> mapB = map.get( a );
- if ( mapB == null ) {
- if ( ignoreCase && ( b instanceof String ) ) {
- mapB = ( Map<B, Set<C>> ) new TreeMap<String, Set<C>>( String.CASE_INSENSITIVE_ORDER );
- }
- else {
- mapB = new LinkedHashMap<B, Set<C>>();
- }
- map.put( a, mapB );
- }
- addMapSet( mapB, ignoreCase, b, c );
- }
-
-
- @SuppressWarnings("unchecked")
- public static <A, B, C, D> void addMapMapMapSet( Map<A, Map<B, Map<C, Set<D>>>> map, boolean ignoreCase, A a, B b,
- C c, D d ) {
- Map<B, Map<C, Set<D>>> mapB = map.get( a );
- if ( mapB == null ) {
- if ( ignoreCase && ( b instanceof String ) ) {
- mapB = ( Map<B, Map<C, Set<D>>> ) new TreeMap<String, Map<C, Set<D>>>( String.CASE_INSENSITIVE_ORDER );
- }
- else {
- mapB = new LinkedHashMap<B, Map<C, Set<D>>>();
- }
- map.put( a, mapB );
- }
- addMapMapSet( mapB, ignoreCase, b, c, d );
- }
-
-
- public static <A, B, C> C getMapMap( Map<A, Map<B, C>> map, A a, B b ) {
-
- Map<B, C> mapB = map.get( a );
- if ( mapB == null ) {
- return null;
- }
- return mapB.get( b );
- }
-
-
- public static <A, B> void addMapList( Map<A, List<B>> map, A a, B b ) {
-
- List<B> listB = map.get( a );
- if ( listB == null ) {
- listB = new ArrayList<B>();
- map.put( a, listB );
- }
- listB.add( b );
- }
-
-
- public static <A, B> void addListToMapList( Map<A, List<B>> map, A a, List<B> b ) {
-
- List<B> listB = map.get( a );
- if ( listB == null ) {
- listB = new ArrayList<B>();
- map.put( a, listB );
- }
- listB.addAll( b );
- }
-
-
- @SuppressWarnings("unchecked")
- public static <K, V> V getValue( Map<K, ?> map, K k ) {
- V v = null;
- try {
- v = ( V ) map.get( k );
- }
- catch ( ClassCastException e ) {
- //LOG.war( "Map value {} was not the expected class", map.get( k ), e );
- }
-
- return v;
- }
-
-
- @SuppressWarnings("unchecked")
- public static <K, V> Map<?, ?> map( Object... objects ) {
- Map<K, V> map = new LinkedHashMap<K, V>();
- int i = 0;
- while ( i < objects.length ) {
- if ( objects[i] instanceof Map.Entry ) {
- Map.Entry<K, V> entry = ( Entry<K, V> ) objects[i];
- map.put( entry.getKey(), entry.getValue() );
- i++;
- }
- else if ( objects[i] instanceof Map ) {
- map.putAll( ( Map<? extends K, ? extends V> ) objects[i] );
- i++;
- }
- else if ( i < ( objects.length - 1 ) ) {
- K k = ( K ) objects[i];
- V v = ( V ) objects[i + 1];
- map.put( k, v );
- i += 2;
- }
- else {
- break;
- }
- }
- return map;
- }
-
-
- private static class SimpleMapEntry<K, V> implements Map.Entry<K, V> {
-
- private final K k;
- private V v;
-
-
- public SimpleMapEntry( K k, V v ) {
- this.k = k;
- this.v = v;
- }
-
-
- @Override
- public K getKey() {
- return k;
- }
-
-
- @Override
- public V getValue() {
- return v;
- }
-
-
- @Override
- public V setValue( V v ) {
- V oldV = this.v;
- this.v = v;
- return oldV;
- }
- }
-
-
- public static <K, V> Map.Entry<K, V> entry( K k, V v ) {
- return new SimpleMapEntry<K, V>( k, v );
- }
-
-
- public static <K, V> K getFirstKey( Map<K, V> map ) {
- if ( map == null ) {
- return null;
- }
- Entry<K, V> e = map.entrySet().iterator().next();
- if ( e != null ) {
- return e.getKey();
- }
- return null;
- }
-
-
- public static <V> Map<String, V> filter( Map<String, V> map, String prefix, boolean removePrefix ) {
- Map<String, V> filteredMap = new LinkedHashMap<String, V>();
- for ( Entry<String, V> entry : map.entrySet() ) {
- if ( entry.getKey().startsWith( prefix ) ) {
- if ( removePrefix ) {
- filteredMap.put( entry.getKey().substring( prefix.length() ), entry.getValue() );
- }
- else {
- filteredMap.put( entry.getKey(), entry.getValue() );
- }
- }
- }
- return filteredMap;
- }
-
-
- public static <V> Map<String, V> filter( Map<String, V> map, String prefix ) {
- return filter( map, prefix, false );
- }
-
-
- public static Properties filter( Properties properties, String prefix, boolean removePrefix ) {
- Properties filteredProperties = new Properties();
- for ( Entry<String, String> entry : asMap( properties ).entrySet() ) {
- if ( entry.getKey().startsWith( prefix ) ) {
- if ( removePrefix ) {
- filteredProperties.put( entry.getKey().substring( prefix.length() ), entry.getValue() );
- }
- else {
- filteredProperties.put( entry.getKey(), entry.getValue() );
- }
- }
- }
- return filteredProperties;
- }
-
-
- public static Properties filter( Properties properties, String prefix ) {
- return filter( properties, prefix, false );
- }
-
-
- @SuppressWarnings("unchecked")
- public static Map<String, String> asMap( Properties properties ) {
- return cast( properties );
- }
-
-
- public static <S, T> HashMapBuilder<S, T> hashMap( S key, T value ) {
- return new HashMapBuilder<S, T>().map( key, value );
- }
-
-
- public static class HashMapBuilder<S, T> extends HashMap<S, T> {
- private static final long serialVersionUID = 1L;
-
-
- public HashMapBuilder() {
- }
-
-
- public HashMapBuilder<S, T> map( S key, T value ) {
- put( key, value );
- return this;
- }
- }
-
-
- @SuppressWarnings("unchecked")
- public static Map<String, List<?>> toMapList( Map<String, ?> m ) {
- Map<String, List<Object>> mapList = new LinkedHashMap<String, List<Object>>();
-
- for ( Entry<String, ?> e : m.entrySet() ) {
- if ( e.getValue() instanceof List ) {
- addListToMapList( mapList, e.getKey(), ( List<Object> ) e.getValue() );
- }
- else {
- addMapList( mapList, e.getKey(), e.getValue() );
- }
- }
-
- return cast( mapList );
- }
-
-
- public static Map<String, ?> putPath( String path, Object value ) {
- return putPath( null, path, value );
- }
-
-
- @SuppressWarnings("unchecked")
- public static Map<String, ?> putPath( Map<String, ?> map, String path, Object value ) {
-
- if ( map == null ) {
- map = new HashMap<String, Object>();
- }
-
- int i = path.indexOf( '.' );
- if ( i < 0 ) {
- ( ( Map<String, Object> ) map ).put( path, value );
- return map;
- }
- String segment = path.substring( 0, i ).trim();
- if ( isNotBlank( segment ) ) {
- Object o = map.get( segment );
- if ( ( o != null ) && ( !( o instanceof Map ) ) ) {
- return map;
- }
- Map<String, Object> subMap = ( Map<String, Object> ) o;
- if ( subMap == null ) {
- subMap = new HashMap<String, Object>();
- ( ( Map<String, Object> ) map ).put( segment, subMap );
- }
- String subPath = path.substring( i + 1 );
- if ( isNotBlank( subPath ) ) {
- putPath( subMap, subPath, value );
- }
- }
-
- return map;
- }
-
-
- public static <K, V> Map<K, V> emptyMapWithKeys( Map<K, V> map ) {
- Map<K, V> newMap = new HashMap<K, V>();
-
- for ( K k : map.keySet() ) {
- newMap.put( k, null );
- }
-
- return newMap;
- }
-
-
- public static boolean hasKeys( Map<?, ?> map, String... keys ) {
- if ( map == null ) {
- return false;
- }
- for ( String key : keys ) {
- if ( !map.containsKey( key ) ) {
- return false;
- }
- }
- return true;
- }
-
-
- public static boolean hasKeys( Map<?, ?> map, Set<String> keys ) {
- if ( map == null ) {
- return false;
- }
- return map.keySet().containsAll( keys );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/StringUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/StringUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/StringUtils.java
deleted file mode 100644
index 5f64ef3..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/StringUtils.java
+++ /dev/null
@@ -1,172 +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.utils;
-
-
-import java.util.Arrays;
-
-import org.apache.commons.io.IOUtils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.usergrid.utils.ConversionUtils.string;
-
-
-public class StringUtils extends org.apache.commons.lang.StringUtils {
-
- private static final Logger LOG = LoggerFactory.getLogger( StringUtils.class );
-
-
- public static Object lower( Object obj ) {
- if ( !( obj instanceof String ) ) {
- return obj;
- }
- return ( ( String ) obj ).toLowerCase();
- }
-
-
- public static String stringOrSubstringAfterLast( String str, char c ) {
- if ( str == null ) {
- return null;
- }
- int i = str.lastIndexOf( c );
- if ( i != -1 ) {
- return str.substring( i + 1 );
- }
- return str;
- }
-
-
- public static String stringOrSubstringBeforeLast( String str, char c ) {
- if ( str == null ) {
- return null;
- }
- int i = str.lastIndexOf( c );
- if ( i != -1 ) {
- return str.substring( 0, i );
- }
- return str;
- }
-
-
- public static String stringOrSubstringBeforeFirst( String str, char c ) {
- if ( str == null ) {
- return null;
- }
- int i = str.indexOf( c );
- if ( i != -1 ) {
- return str.substring( 0, i );
- }
- return str;
- }
-
-
- public static String stringOrSubstringAfterFirst( String str, char c ) {
- if ( str == null ) {
- return null;
- }
- int i = str.indexOf( c );
- if ( i != -1 ) {
- return str.substring( i + 1 );
- }
- return str;
- }
-
-
- public static String compactWhitespace( String str ) {
- if ( str == null ) {
- return null;
- }
- boolean prevWS = false;
- StringBuilder builder = new StringBuilder();
- for ( int i = 0; i < str.length(); i++ ) {
- char c = str.charAt( i );
- if ( Character.isWhitespace( c ) ) {
- if ( !prevWS ) {
- builder.append( ' ' );
- }
- prevWS = true;
- }
- else {
- prevWS = false;
- builder.append( c );
- }
- }
- return builder.toString().trim();
- }
-
-
- /** @return new string with replace applied */
- public static String replaceAll( String source, String find, String replace ) {
- if ( source == null ) {
- return null;
- }
- while ( true ) {
- String old = source;
- source = source.replaceAll( find, replace );
- if ( source.equals( old ) ) {
- return source;
- }
- }
- }
-
-
- public static String toString( Object obj ) {
- return string( obj );
- }
-
-
- public static String toStringFormat( Object obj, String format ) {
- if ( obj != null ) {
- if ( format != null ) {
- if ( obj.getClass().isArray() ) {
- return String.format( format, Arrays.toString( ( Object[] ) obj ) );
- }
- return String.format( format, string( obj ) );
- }
- else {
- return string( obj );
- }
- }
- return "";
- }
-
-
- public static boolean isString( Object obj ) {
- return obj instanceof String;
- }
-
-
- public static boolean isStringOrNull( Object obj ) {
- if ( obj == null ) {
- return true;
- }
- return obj instanceof String;
- }
-
-
- public static String readClasspathFileAsString( String filePath ) {
- try {
- return IOUtils.toString( StringUtils.class.getResourceAsStream( filePath ) );
- }
- catch ( Exception e ) {
- LOG.error( "Error getting file from classpath: " + filePath, e );
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b516f578/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/UUIDUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/UUIDUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/UUIDUtils.java
deleted file mode 100644
index 6d8175c..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/UUIDUtils.java
+++ /dev/null
@@ -1,412 +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.utils;
-
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.locks.ReentrantLock;
-
-import com.fasterxml.uuid.EthernetAddress;
-import com.fasterxml.uuid.UUIDComparator;
-
-import static com.fasterxml.uuid.impl.UUIDUtil.BYTE_OFFSET_CLOCK_HI;
-import static com.fasterxml.uuid.impl.UUIDUtil.BYTE_OFFSET_CLOCK_LO;
-import static com.fasterxml.uuid.impl.UUIDUtil.BYTE_OFFSET_CLOCK_MID;
-import static com.fasterxml.uuid.impl.UUIDUtil.BYTE_OFFSET_CLOCK_SEQUENCE;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.commons.codec.binary.Base64.decodeBase64;
-import static org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString;
-
-import static org.apache.usergrid.utils.ConversionUtils.bytes;
-import static org.apache.usergrid.utils.ConversionUtils.uuid;
-
-
-public class UUIDUtils {
- private static final Logger LOG = LoggerFactory.getLogger( UUIDUtils.class );
- private static final int[] MICROS = new int[1000];
-
-
- static {
- for ( int x = 0; x < 1000; x++ ) {
- MICROS[x] = x * 10;
- }
- }
-
-
- private static ReentrantLock tsLock = new ReentrantLock( true );
-
- public static final UUID MIN_TIME_UUID = UUID.fromString( "00000000-0000-1000-8000-000000000000" );
-
- public static final UUID MAX_TIME_UUID = UUID.fromString( "ffffffff-ffff-1fff-bfff-ffffffffffff" );
-
- public static final UUID ZERO_UUID = new UUID( 0, 0 );
-
- private static long timestampMillisNow = System.currentTimeMillis();
-
- private static AtomicInteger currentMicrosPoint = new AtomicInteger( 0 );
- private static AtomicInteger customMicrosPointer = new AtomicInteger( 0 );
-
-
- /**
- * Return the "next" UUID in micro second resolution. <b>WARNING</b>: this is designed to return the next unique
- * timestamped UUID for this JVM. Depending on velocity of the call, this method may block internally to insure that
- * "now" is kept in sync with the UUIDs being generated by this call.
- * <p/>
- * In other words, we will intentionally burn CPU insuring that this method is not executed more than 10k -1 times
- * per millisecond and guarantee that those microseconds held within are sequential.
- * <p/>
- * If we did not do this, you would get <b>timestamp collision</b> even though the UUIDs will technically be
- * 'unique.'
- */
- public static java.util.UUID newTimeUUID() {
- // get & inc counter, but roll on 1k (because we divide by 10 on retrieval)
- // if count + currentMicro > 1k, block and roll
- tsLock.lock();
- long ts = System.currentTimeMillis();
- if ( ts > timestampMillisNow ) {
- timestampMillisNow = ts;
- currentMicrosPoint.set( 0 );
- }
- int pointer = currentMicrosPoint.getAndIncrement();
- try {
- if ( pointer > 990 ) {
- TimeUnit.MILLISECONDS.sleep( 1L );
- }
- }
- catch ( Exception ex ) {
- ex.printStackTrace();
- }
- finally {
- tsLock.unlock();
- }
- return newTimeUUID( ts, MICROS[pointer] );
- }
-
-
- private static final long KCLOCK_OFFSET = 0x01b21dd213814000L;
- private static final long KCLOCK_MULTIPLIER_L = 10000L;
-
- private static final Random CLOCK_SEQ_RANDOM = new Random();
-
-
- // 14 bits of randomness
- private static int getRandomClockSequence() {
- return CLOCK_SEQ_RANDOM.nextInt() & 0x3FFF;
- }
-
-
- private static void setTimestamp( long timestamp, byte[] uuidBytes, int clockSeq, int timeOffset ) {
-
- timestamp *= KCLOCK_MULTIPLIER_L;
- timestamp += KCLOCK_OFFSET;
- timestamp += timeOffset;
-
- // Set random clock sequence
- uuidBytes[BYTE_OFFSET_CLOCK_SEQUENCE] = ( byte ) ( clockSeq >> 8 );
- uuidBytes[BYTE_OFFSET_CLOCK_SEQUENCE + 1] = ( byte ) clockSeq;
-
- // Set variant
- uuidBytes[BYTE_OFFSET_CLOCK_SEQUENCE] &= 0x3F;
- uuidBytes[BYTE_OFFSET_CLOCK_SEQUENCE] |= 0x80;
- setTime( uuidBytes, timestamp );
- }
-
-
- @SuppressWarnings("all")
- private static void setTime( byte[] uuidBytes, long timestamp ) {
-
- // Time fields aren't nicely split across the UUID, so can't just
- // linearly dump the stamp:
- int clockHi = ( int ) ( timestamp >>> 32 );
- int clockLo = ( int ) timestamp;
-
- uuidBytes[BYTE_OFFSET_CLOCK_HI] = ( byte ) ( clockHi >>> 24 );
- uuidBytes[BYTE_OFFSET_CLOCK_HI + 1] = ( byte ) ( clockHi >>> 16 );
- uuidBytes[BYTE_OFFSET_CLOCK_MID] = ( byte ) ( clockHi >>> 8 );
- uuidBytes[BYTE_OFFSET_CLOCK_MID + 1] = ( byte ) clockHi;
-
- uuidBytes[BYTE_OFFSET_CLOCK_LO] = ( byte ) ( clockLo >>> 24 );
- uuidBytes[BYTE_OFFSET_CLOCK_LO + 1] = ( byte ) ( clockLo >>> 16 );
- uuidBytes[BYTE_OFFSET_CLOCK_LO + 2] = ( byte ) ( clockLo >>> 8 );
- uuidBytes[BYTE_OFFSET_CLOCK_LO + 3] = ( byte ) clockLo;
-
- // Set version
- uuidBytes[BYTE_OFFSET_CLOCK_HI] &= 0x0F;
- uuidBytes[BYTE_OFFSET_CLOCK_HI] |= 0x10;
- }
-
-
- /**
- * Generate a timeuuid with the given timestamp in milliseconds and the time offset. Useful when you need to
- * generate sequential UUIDs for the same period in time. I.E
- * <p/>
- * newTimeUUID(1000, 0) <br/> newTimeUUID(1000, 1) <br /> newTimeUUID(1000, 2) <br />
- * <p/>
- * etc.
- * <p/>
- * Only use this method if you are absolutely sure you need it. When it doubt use the method without the timestamp
- * offset
- *
- * @param ts The timestamp in milliseconds
- * @param timeoffset The offset, which should always be <= 10000. If you go beyond this range, the millisecond will
- * be incremented since this is beyond the possible values when coverrting from millis to 1/10 microseconds stored
- * in the time uuid.
- */
- public static UUID newTimeUUID( long ts, int timeoffset ) {
- if ( ts == 0 ) {
- return newTimeUUID();
- }
-
- byte[] uuidBytes = new byte[16];
- // 47 bits of randomness
- EthernetAddress eth = EthernetAddress.constructMulticastAddress();
- eth.toByteArray( uuidBytes, 10 );
- setTimestamp( ts, uuidBytes, getRandomClockSequence(), timeoffset );
-
- return uuid( uuidBytes );
- }
-
-
- /**
- * Generate a new UUID with the given time stamp in milliseconds. This method guarantees that subsequent calls will
- * be of increasing value chronologically. If a large number of subsequent calls are made to this method (>1000)
- * with the same timestamp, you will have non-unique temporal values stored in your UUID.
- */
- public static UUID newTimeUUID( long ts ) {
- tsLock.lock();
- int pointer = customMicrosPointer.getAndIncrement();
- try {
- if ( pointer > 990 ) {
- customMicrosPointer.set( 0 );
- }
- }
- finally {
- tsLock.unlock();
- }
- return newTimeUUID( ts, MICROS[pointer] );
- }
-
-
- public static UUID minTimeUUID( long ts ) {
- byte[] uuidBytes = new byte[16];
- setTimestamp( ts, uuidBytes, 0, 0 );
-
- return uuid( uuidBytes );
- }
-
-
- public static UUID maxTimeUUID( long ts ) {
- byte[] uuidBytes = new byte[16];
- uuidBytes[10] = ( byte ) 0xFF;
- uuidBytes[11] = ( byte ) 0xFF;
- uuidBytes[12] = ( byte ) 0xFF;
- uuidBytes[13] = ( byte ) 0xFF;
- uuidBytes[14] = ( byte ) 0xFF;
- uuidBytes[15] = ( byte ) 0xFF;
- setTimestamp( ts, uuidBytes, 0x3FFF, 0x1FFF );
-
- return uuid( uuidBytes );
- }
-
-
- /** Returns the minimum UUID */
- public static UUID min( UUID first, UUID second ) {
- if ( first == null ) {
- if ( second == null ) {
- return null;
- }
- return second;
- }
-
- if ( second == null ) {
- return first;
- }
-
- if ( compare( first, second ) < 0 ) {
- return first;
- }
- return second;
- }
-
-
- /** Returns the minimum UUID */
- public static UUID max( UUID first, UUID second ) {
- if ( first == null ) {
- if ( second == null ) {
- return null;
- }
- return second;
- }
-
- if ( second == null ) {
- return first;
- }
-
- if ( compare( first, second ) < 0 ) {
- return second;
- }
- return first;
- }
-
-
- /** Returns a UUID that is -1 of the passed uuid, sorted by time uuid only */
- public static UUID decrement( UUID uuid ) {
- if ( !isTimeBased( uuid ) ) {
- throw new IllegalArgumentException( "The uuid must be a time type" );
- }
-
-
- //timestamp is in the 60 bit timestamp
- long timestamp = uuid.timestamp();
- timestamp--;
-
- if ( timestamp < 0 ) {
- throw new IllegalArgumentException( "You must specify a time uuid with a timestamp > 0" );
- }
-
- //get our bytes, then set the smaller timestamp into it
- byte[] uuidBytes = bytes( uuid );
-
- setTime( uuidBytes, timestamp );
-
- return uuid( uuidBytes );
- }
-
-
- public static boolean isTimeBased( UUID uuid ) {
- if ( uuid == null ) {
- return false;
- }
- return uuid.version() == 1;
- }
-
-
- public static long getTimestampInMillis( UUID uuid ) {
- if ( uuid == null ) {
- return 0;
- }
- long t = uuid.timestamp();
- return ( t - KCLOCK_OFFSET ) / KCLOCK_MULTIPLIER_L;
- }
-
-
- public static long getTimestampInMicros( UUID uuid ) {
- if ( uuid == null ) {
- return 0;
- }
- long t = uuid.timestamp();
- return ( t - KCLOCK_OFFSET ) / 10;
- }
-
-
- public static UUID tryGetUUID( String s ) {
- if ( s == null ) {
- return null;
- }
- if ( s.length() != 36 ) {
- return null;
- }
- // 8-4-4-4-12
- // 0-7,8,9-12,13,14-17,18,19-22,23,24-35
- if ( s.charAt( 8 ) != '-' ) {
- return null;
- }
- if ( s.charAt( 13 ) != '-' ) {
- return null;
- }
- if ( s.charAt( 18 ) != '-' ) {
- return null;
- }
- if ( s.charAt( 23 ) != '-' ) {
- return null;
- }
- UUID uuid = null;
- try {
- uuid = UUID.fromString( s );
- }
- catch ( Exception e ) {
- LOG.info( "Could not convert String {} into a UUID", s, e );
- }
- return uuid;
- }
-
-
- public static boolean isUUID( String s ) {
- return tryGetUUID( s ) != null;
- }
-
-
- public static UUID tryExtractUUID( String s ) {
- if ( s == null ) {
- return null;
- }
- if ( s.length() < 36 ) {
- return null;
- }
- return tryGetUUID( s.substring( 0, 36 ) );
- }
-
-
- public static UUID tryExtractUUID( String s, int offset ) {
- if ( s == null ) {
- return null;
- }
- if ( ( s.length() - offset ) < 36 ) {
- return null;
- }
- return tryGetUUID( s.substring( offset, offset + 36 ) );
- }
-
-
- public static String toBase64( UUID id ) {
- if ( id == null ) {
- return null;
- }
- return encodeBase64URLSafeString( bytes( id ) );
- }
-
-
- public static UUID fromBase64( String str ) {
- if ( str == null ) {
- return null;
- }
- byte[] bytes = decodeBase64( str );
- if ( bytes.length != 16 ) {
- return null;
- }
- return uuid( bytes );
- }
-
-
- public static int compare( UUID u1, UUID u2 ) {
- return UUIDComparator.staticCompare( u1, u2 );
- }
-
-
- public static List<UUID> sort( List<UUID> uuids ) {
- Collections.sort( uuids, new UUIDComparator() );
- return uuids;
- }
-}
[36/50] [abbrv] git commit: Merge branch 'master' of
https://github.com/usergrid/usergrid into Export_Persistance_Integration
Posted by sn...@apache.org.
Merge branch 'master' of https://github.com/usergrid/usergrid into Export_Persistance_Integration
# By Dave Johnson
# Via Dave Johnson
* 'master' of https://github.com/usergrid/usergrid:
Update README.md
Update README.md
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/5475be27
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/5475be27
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/5475be27
Branch: refs/heads/asyncqueue
Commit: 5475be27e2a3da200440675a481e5a39f6fa8158
Parents: 86da615 268250e
Author: grey <gr...@apigee.com>
Authored: Mon Mar 24 09:58:14 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Mon Mar 24 09:58:14 2014 -0700
----------------------------------------------------------------------
README.md | 64 +++-------------------------------------------------------
1 file changed, 3 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
[02/50] [abbrv] git commit: Merging from usergrid/usergrid
Posted by sn...@apache.org.
Merging from usergrid/usergrid
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/dee2ca98
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/dee2ca98
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/dee2ca98
Branch: refs/heads/asyncqueue
Commit: dee2ca98330294101c4a5258910cb75fbac7205b
Parents: c0ba7b0 7ea7503
Author: ryan bridges <rb...@apigee.com>
Authored: Thu Mar 13 10:28:40 2014 -0400
Committer: ryan bridges <rb...@apigee.com>
Committed: Thu Mar 13 10:28:40 2014 -0400
----------------------------------------------------------------------
.gitignore | 9 +-
portal/config.js | 11 +-
portal/index-debug.html | 18 +-
portal/index-template.html | 2 +-
portal/index.html | 18 +-
portal/js/app.js | 7 +-
portal/js/global/page-controller.js | 58 +-
portal/js/global/page-title.html | 2 +-
portal/js/global/ug-service.js | 74 +-
portal/js/libs/usergrid-libs.min.js | 22 +-
portal/js/libs/usergrid.sdk.js | 5 +
portal/js/login/forgot-password-controller.js | 1 -
portal/js/login/login-controller.js | 8 +-
portal/js/login/login.html | 6 +
portal/js/menus/appMenu.html | 7 +-
portal/js/menus/menu-directives.js | 1 -
portal/js/org-overview/org-overview.html | 4 +-
portal/js/templates.js | 57 +-
portal/js/usergrid-dev.min.js | 171 +-
portal/js/usergrid.min.js | 12 +-
portal/js/users/users-feed-controller.js | 29 +
portal/js/users/users-feed.html | 27 +
portal/js/users/users.html | 1 +
portal/package.json | 5 +-
portal/phantomjsdriver.log | 3869 ------------------
portal/seleniumLog.txt | 0
portal/tests/unit/sample.spec.js | 3 +-
sdks/html5-javascript/lib/modules/Folder.js | 4 +-
sdks/html5-javascript/usergrid.js | 4 +-
sdks/html5-javascript/usergrid.min.js | 2 +-
.../org/apache/usergrid/persistence/Query.java | 5 +-
.../usergrid/persistence/entities/Export.java | 158 +
.../1.5.4/AppleJavaExtensions-1.5.4.jar | Bin 0 -> 23531 bytes
.../1.5.4/AppleJavaExtensions-1.5.4.pom | 9 +
.../maven-metadata-local.xml | 12 +
stack/pom.xml | 7 +-
.../rest/management/ManagementResource.java | 15 +-
.../applications/ApplicationResource.java | 181 +-
.../rest/management/ManagementResourceIT.java | 497 ++-
.../usergrid/management/export/ExportJob.java | 81 +
.../management/export/ExportService.java | 48 +
.../management/export/ExportServiceImpl.java | 608 +++
.../usergrid/management/export/S3Export.java | 35 +
.../management/export/S3ExportImpl.java | 109 +
.../services/AbstractCollectionService.java | 3 +
.../resources/usergrid-services-context.xml | 10 +
.../org/apache/usergrid/ServiceITSetup.java | 3 +
.../org/apache/usergrid/ServiceITSetupImpl.java | 6 +
.../cassandra/ManagementServiceIT.java | 707 +++-
.../management/cassandra/MockS3ExportImpl.java | 72 +
.../RepairingMismatchedApplicationMetadata.java | 73 +
51 files changed, 3001 insertions(+), 4075 deletions(-)
----------------------------------------------------------------------