You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2015/06/01 23:38:05 UTC
[01/10] incubator-usergrid git commit: Changes parsing to use regex
Repository: incubator-usergrid
Updated Branches:
refs/heads/two-dot-o-dev b06852534 -> 45ce5d288
Changes parsing to use regex
Changes fields to be more descriptive
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/c3c24804
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/c3c24804
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/c3c24804
Branch: refs/heads/two-dot-o-dev
Commit: c3c248049d3d3b3699703bf053402115761cd57b
Parents: 53563e8
Author: Todd Nine <tn...@apigee.com>
Authored: Wed May 27 10:25:47 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu May 28 06:30:46 2015 -0600
----------------------------------------------------------------------
.../index/impl/EntityToMapConverter.java | 11 +-
.../impl/EsApplicationEntityIndexImpl.java | 3 +-
.../persistence/index/impl/IndexOperation.java | 1 -
.../persistence/index/impl/IndexingUtils.java | 153 ++++++++++++++-----
.../index/migration/LegacyIndexIdentifier.java | 78 ----------
.../index/impl/EntityToMapConverterTest.java | 6 +-
.../index/impl/IndexingUtilsTest.java | 109 +++++++++++++
7 files changed, 233 insertions(+), 128 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3c24804/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverter.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverter.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverter.java
index ff81672..cced80f 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverter.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverter.java
@@ -37,8 +37,11 @@ import static org.apache.usergrid.persistence.index.impl.IndexingUtils.ENTITY_FI
import static org.apache.usergrid.persistence.index.impl.IndexingUtils.ENTITY_ID_FIELDNAME;
import static org.apache.usergrid.persistence.index.impl.IndexingUtils.ENTITY_TYPE_FIELDNAME;
import static org.apache.usergrid.persistence.index.impl.IndexingUtils.ENTITY_VERSION_FIELDNAME;
+import static org.apache.usergrid.persistence.index.impl.IndexingUtils.applicationId;
+import static org.apache.usergrid.persistence.index.impl.IndexingUtils.entityId;
import static org.apache.usergrid.persistence.index.impl.IndexingUtils.getType;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.idString;
+import static org.apache.usergrid.persistence.index.impl.IndexingUtils.nodeId;
+
/**
* Convert a CP entity to an elasticsearch document
@@ -64,16 +67,16 @@ public class EntityToMapConverter {
* Add our static fields for easier admin/debugging/reporting
****/
- outputEntity.put( ENTITY_ID_FIELDNAME, idString(entityId) );
+ outputEntity.put( ENTITY_ID_FIELDNAME, entityId( entityId ) );
outputEntity.put( ENTITY_VERSION_FIELDNAME, entity.getVersion() );
outputEntity.put( ENTITY_TYPE_FIELDNAME, getType( applicationScope, entityId ) );
- outputEntity.put( APPLICATION_ID_FIELDNAME, idString( applicationScope.getApplication() ) );
+ outputEntity.put( APPLICATION_ID_FIELDNAME, applicationId( applicationScope.getApplication() ) );
- outputEntity.put( EDGE_NODE_ID_FIELDNAME, idString( indexEdge.getNodeId() ) );
+ outputEntity.put( EDGE_NODE_ID_FIELDNAME, nodeId( indexEdge.getNodeId() ) );
outputEntity.put( EDGE_NODE_TYPE_FIELDNAME, indexEdge.getNodeType() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3c24804/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
index 5b67060..34b4e9a 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
@@ -65,6 +65,7 @@ import com.google.inject.Inject;
import rx.Observable;
import static org.apache.usergrid.persistence.index.impl.IndexingUtils.APPLICATION_ID_FIELDNAME;
+import static org.apache.usergrid.persistence.index.impl.IndexingUtils.applicationId;
import static org.apache.usergrid.persistence.index.impl.IndexingUtils.parseIndexDocId;
@@ -178,7 +179,7 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex {
*/
public Observable deleteApplication() {
deleteApplicationMeter.mark();
- String idString = IndexingUtils.idString( applicationScope.getApplication() );
+ String idString = applicationId( applicationScope.getApplication() );
final TermQueryBuilder tqb = QueryBuilders.termQuery( APPLICATION_ID_FIELDNAME, idString );
final String[] indexes = entityIndex.getUniqueIndexes();
Timer.Context timer = deleteApplicationTimer.time();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3c24804/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexOperation.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexOperation.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexOperation.java
index 2e2f188..fae809f 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexOperation.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexOperation.java
@@ -30,7 +30,6 @@ import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.client.Client;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.idString;
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3c24804/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
index bc15149..94038b1 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
@@ -19,6 +19,8 @@ package org.apache.usergrid.persistence.index.impl;/*
import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.index.CandidateResult;
@@ -28,14 +30,46 @@ 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 com.google.common.base.Preconditions;
+
public class IndexingUtils {
+ /**
+ * Regular expression for uuids
+ */
+ public static final String UUID_REX =
+ "([A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12})";
+
+ public static final String TYPE_REX = "(\\w+)";
+
+
+ private static final String APPID_NAME = "appId";
+
+ private static final String ENTITY_NAME = "entityId";
+
+ private static final String NODEID_NAME = "nodeId";
+
+ private static final String VERSION_NAME = "version";
+ private static final String EDGE_NAME = "edgeName";
+
+ private static final String NODE_TYPE_NAME = "nodeType";
+ private static final String ENTITY_TYPE_NAME = "entityType";
+
+
+ //the document Id will have 9 groups
+ private static final String DOCUMENT_ID_REGEX =
+ "appId\\(" + UUID_REX + "," + TYPE_REX + "\\)\\.entityId\\(" + UUID_REX + "," + TYPE_REX + "\\)\\.version\\(" + UUID_REX
+ + "\\)\\.nodeId\\(" + UUID_REX + "," + TYPE_REX + "\\)\\.edgeName\\(" + TYPE_REX + "\\)\\.nodeType\\(" + TYPE_REX + "\\)";
+
+
+ private static final Pattern DOCUMENT_PATTERN = Pattern.compile( DOCUMENT_ID_REGEX );
+
// These are not allowed in document type names: _ . , | #
- public static final String FIELD_SEPERATOR = "__";
+ public static final String FIELD_SEPERATOR = ".";
- public static final String ID_SEPERATOR = "::";
+ public static final String ID_SEPERATOR = ",";
/**
@@ -93,10 +127,6 @@ public class IndexingUtils {
public static final String FIELD_STRING_NESTED_UNANALYZED = FIELD_STRING_NESTED + ".exact";
-
-
-
-
/**
* Create our sub scope. This is the ownerUUID + type
*
@@ -104,29 +134,11 @@ public class IndexingUtils {
*/
public static String createContextName( final ApplicationScope applicationScope, final SearchEdge scope ) {
StringBuilder sb = new StringBuilder();
- idString( sb, applicationScope.getApplication() );
+ idString( sb, APPID_NAME, applicationScope.getApplication() );
sb.append( FIELD_SEPERATOR );
- idString( sb, scope.getNodeId() );
+ idString( sb, NODEID_NAME, scope.getNodeId() );
sb.append( FIELD_SEPERATOR );
- sb.append( scope.getEdgeName() );
- return sb.toString();
- }
-
-
- /**
- * Append the id to the string
- */
- public static final void idString( final StringBuilder builder, final Id id ) {
- builder.append( id.getUuid() ).append( ID_SEPERATOR ).append( id.getType().toLowerCase() );
- }
-
-
- /**
- * Turn the id into a string
- */
- public static final String idString( final Id id ) {
- final StringBuilder sb = new StringBuilder();
- idString( sb, id );
+ appendField( sb, EDGE_NAME, scope.getEdgeName() );
return sb.toString();
}
@@ -147,46 +159,105 @@ public class IndexingUtils {
final UUID version, final SearchEdge searchEdge ) {
StringBuilder sb = new StringBuilder();
- idString( sb, applicationScope.getApplication() );
+ idString( sb, APPID_NAME, applicationScope.getApplication() );
sb.append( FIELD_SEPERATOR );
- idString( sb, entityId );
+ idString( sb, ENTITY_ID_FIELDNAME, entityId );
sb.append( FIELD_SEPERATOR );
- sb.append( version.toString() );
-
+ appendField( sb, VERSION_NAME, version.toString() );
sb.append( FIELD_SEPERATOR );
- idString( sb, searchEdge.getNodeId() );
+ idString( sb, NODEID_NAME, searchEdge.getNodeId() );
sb.append( FIELD_SEPERATOR );
- sb.append( searchEdge.getEdgeName() );
+ appendField( sb, EDGE_NAME, searchEdge.getEdgeName() );
sb.append( FIELD_SEPERATOR );
- sb.append( searchEdge.getNodeType() );
+ appendField( sb, NODE_TYPE_NAME, searchEdge.getNodeType().name() );
return sb.toString();
}
+ public static final String entityId( final Id id ) {
+ return idString( ENTITY_NAME, id );
+ }
+
+
+ public static final String applicationId( final Id id ) {
+ return idString( APPID_NAME, id );
+ }
+
+
+ public static final String nodeId( final Id id ) {
+ return idString( NODEID_NAME, id );
+ }
+
+
+ /**
+ * Construct and Id string with the specified type for the id provided.
+ */
+ private static final String idString( final String type, final Id id ) {
+ final StringBuilder stringBuilder = new StringBuilder();
+
+ idString( stringBuilder, type, id );
+
+ return stringBuilder.toString();
+ }
+
+
+ /**
+ * Append the id to the string
+ */
+ private static final void idString( final StringBuilder builder, final String type, final Id id ) {
+ builder.append( type ).append( "(" ).append( id.getUuid() ).append( ID_SEPERATOR )
+ .append( id.getType().toLowerCase() ).append( ")" );
+ }
+
+
+ /**
+ * Append a field
+ */
+ private static void appendField( final StringBuilder builder, final String type, final String value ) {
+ builder.append( type ).append( "(" ).append( value ).append( ")" );
+ }
+
+
/**
* Parse the document id into a candidate result
*/
public static CandidateResult parseIndexDocId( final String documentId ) {
- String[] idparts = documentId.split( FIELD_SEPERATOR );
- String entityIdString = idparts[1];
- String version = idparts[2];
- final String[] entityIdParts = entityIdString.split( ID_SEPERATOR );
+ final Matcher matcher = DOCUMENT_PATTERN.matcher( documentId );
+
+ Preconditions.checkArgument( matcher.matches(), "Pattern for document id did not match expected format" );
+ Preconditions.checkArgument( matcher.groupCount() == 9, "9 groups expected in the pattern" );
+
+ //Other fields can be parsed using groups. The groups start at value 1, group 0 is the entire match
+ final String entityUUID = matcher.group( 3 );
+ final String entityType = matcher.group( 4 );
+
+ final String versionUUID = matcher.group( 5 );
- Id entityId = new SimpleId( UUID.fromString( entityIdParts[0] ), entityIdParts[1] );
- return new CandidateResult( entityId, UUID.fromString( version ) );
+ Id entityId = new SimpleId( UUID.fromString( entityUUID ), entityType );
+
+ return new CandidateResult( entityId, UUID.fromString( versionUUID ) );
}
+ /**
+ * Get the entity type
+ */
public static String getType( ApplicationScope applicationScope, Id entityId ) {
return getType( applicationScope, entityId.getType() );
}
public static String getType( ApplicationScope applicationScope, String type ) {
- return idString( applicationScope.getApplication() ) + FIELD_SEPERATOR + type;
+
+ StringBuilder sb = new StringBuilder();
+
+ idString( sb, APPID_NAME, applicationScope.getApplication() );
+ sb.append( FIELD_SEPERATOR );
+ sb.append( ENTITY_TYPE_NAME).append("(" ).append( type ).append( ")" );
+ return sb.toString();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3c24804/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/LegacyIndexIdentifier.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/LegacyIndexIdentifier.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/LegacyIndexIdentifier.java
deleted file mode 100644
index c93fd86..0000000
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/LegacyIndexIdentifier.java
+++ /dev/null
@@ -1,78 +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.index.migration;
-
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-import org.apache.usergrid.persistence.index.impl.IndexAlias;
-import org.apache.usergrid.persistence.index.IndexFig;
-import org.apache.usergrid.persistence.index.impl.IndexIdentifier;
-import org.apache.usergrid.persistence.index.impl.IndexingUtils;
-
-/**
- * Class is used to generate an index name and alias name the old way via app name
- */
-public class LegacyIndexIdentifier implements IndexIdentifier {
- private final IndexFig config;
- private final ApplicationScope applicationScope;
-
- public LegacyIndexIdentifier(IndexFig config, ApplicationScope applicationScope) {
- this.config = config;
- this.applicationScope = applicationScope;
- }
-
- /**
- * Get the alias name
- * @return
- */
- public IndexAlias getAlias() {
- return new IndexAlias(config,getIndexBase());
- }
-
- /**
- * Get index name, send in additional parameter to add incremental indexes
- * @param suffix
- * @return
- */
- public String getIndex(String suffix) {
- if (suffix != null) {
- return getIndexBase() + "_" + suffix;
- } else {
- return getIndexBase();
- }
- }
-
- /**
- * returns the base name for index which will be used to add an alias and index
- * @return
- */
- private String getIndexBase() {
- StringBuilder sb = new StringBuilder();
- sb.append(config.getIndexPrefix()).append(IndexingUtils.FIELD_SEPERATOR );
- IndexingUtils.idString(sb, applicationScope.getApplication());
- return sb.toString();
- }
-
-
-
- public String toString() {
- return "application: " + applicationScope.getApplication().getUuid();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3c24804/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
index 7fed42c..96f9169 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityToMapConverterTest.java
@@ -86,11 +86,11 @@ public class EntityToMapConverterTest {
final String applicationId = entityMap.get( IndexingUtils.APPLICATION_ID_FIELDNAME ).toString();
- assertEquals( IndexingUtils.idString( scope.getApplication() ), applicationId );
+ assertEquals( IndexingUtils.applicationId( scope.getApplication() ), applicationId );
final String entityIdString = entityMap.get( IndexingUtils.ENTITY_ID_FIELDNAME ).toString();
- assertEquals( IndexingUtils.idString( entity.getId() ), entityIdString );
+ assertEquals( IndexingUtils.entityId( entity.getId() ), entityIdString );
final String versionString = entityMap.get( IndexingUtils.ENTITY_VERSION_FIELDNAME ).toString();
@@ -103,7 +103,7 @@ public class EntityToMapConverterTest {
final String nodeIdString = entityMap.get( IndexingUtils.EDGE_NODE_ID_FIELDNAME ).toString();
- assertEquals( IndexingUtils.idString( indexEdge.getNodeId() ), nodeIdString );
+ assertEquals( IndexingUtils.nodeId( indexEdge.getNodeId() ), nodeIdString );
final String edgeName = entityMap.get( IndexingUtils.EDGE_NAME_FIELDNAME ).toString();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c3c24804/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexingUtilsTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexingUtilsTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexingUtilsTest.java
new file mode 100644
index 0000000..cc66854
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexingUtilsTest.java
@@ -0,0 +1,109 @@
+/*
+ * 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.impl;
+
+
+import java.util.UUID;
+
+import org.junit.Test;
+
+import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
+import org.apache.usergrid.persistence.index.CandidateResult;
+import org.apache.usergrid.persistence.index.SearchEdge;
+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 static org.apache.usergrid.persistence.index.impl.IndexingUtils.parseIndexDocId;
+import static org.junit.Assert.assertEquals;
+
+
+public class IndexingUtilsTest {
+
+ @Test
+ public void testCreateContextName() throws Exception {
+
+ final ApplicationScopeImpl applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) );
+
+ final SearchEdgeImpl searchEdge =
+ new SearchEdgeImpl( new SimpleId( "source" ), "users", SearchEdge.NodeType.TARGET );
+
+ final String output = IndexingUtils.createContextName( applicationScope, searchEdge );
+
+
+ final String expected =
+ "appId(" + applicationScope.getApplication().getUuid() + ",application).nodeId(" + searchEdge.getNodeId()
+ .getUuid()
+ + "," + searchEdge.getNodeId().getType() + ").edgeName(users)";
+
+
+ assertEquals( output, expected );
+ }
+
+
+ @Test
+ public void testDocumentId() {
+
+ final ApplicationScopeImpl applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) );
+
+ final Id id = new SimpleId( "id" );
+ final UUID version = UUIDGenerator.newTimeUUID();
+
+ final SearchEdgeImpl searchEdge =
+ new SearchEdgeImpl( new SimpleId( "source" ), "users", SearchEdge.NodeType.TARGET );
+
+ final String output = IndexingUtils.createIndexDocId( applicationScope, id, version, searchEdge );
+
+
+ final String expected =
+ "appId(" + applicationScope.getApplication().getUuid() + ",application).entityId(" + id.getUuid() + "," + id
+ .getType() + ").version(" + version + ").nodeId(" + searchEdge.getNodeId().getUuid() + "," + searchEdge
+ .getNodeId().getType() + ").edgeName(users).nodeType(TARGET)";
+
+
+ assertEquals( output, expected );
+
+
+ //now parse it
+
+ final CandidateResult parsedId = parseIndexDocId( output );
+
+ assertEquals(version, parsedId.getVersion());
+ assertEquals(id, parsedId.getId());
+ }
+
+
+ @Test
+ public void testEntityType() {
+
+ final ApplicationScopeImpl applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) );
+
+ final Id id = new SimpleId( "id" );
+
+ final String output = IndexingUtils.getType( applicationScope, id );
+
+
+ final String expected =
+ "appId(" + applicationScope.getApplication().getUuid() + ",application).entityType(" + id.getType() + ")";
+
+
+ assertEquals( output, expected );
+ }
+}
[10/10] incubator-usergrid git commit: merge
Posted by sf...@apache.org.
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/45ce5d28
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/45ce5d28
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/45ce5d28
Branch: refs/heads/two-dot-o-dev
Commit: 45ce5d288a1efbce52a3b5338e1b62acb7335c94
Parents: 1d2356b b068525
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Jun 1 15:37:56 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Jun 1 15:37:56 2015 -0600
----------------------------------------------------------------------
.../rest/management/RegistrationIT.java | 37 ++++++++++++--------
1 file changed, 23 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
[08/10] incubator-usergrid git commit: Merge branch 'USERGRID-669' of
https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-669
Posted by sf...@apache.org.
Merge branch 'USERGRID-669' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-669
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/210273bb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/210273bb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/210273bb
Branch: refs/heads/two-dot-o-dev
Commit: 210273bb787ea499672b2b688269ff30b19e06ee
Parents: 8aa793b bfe1337
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Jun 1 15:36:57 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Jun 1 15:36:57 2015 -0600
----------------------------------------------------------------------
.../index/impl/EntityToMapConverter.java | 11 +-
.../impl/EsApplicationEntityIndexImpl.java | 7 +-
.../persistence/index/impl/IndexOperation.java | 1 -
.../persistence/index/impl/IndexingUtils.java | 153 ++++++++++++++-----
.../index/migration/LegacyIndexIdentifier.java | 78 ----------
.../index/impl/EntityToMapConverterTest.java | 6 +-
.../index/impl/IndexingUtilsTest.java | 141 +++++++++++++++++
7 files changed, 267 insertions(+), 130 deletions(-)
----------------------------------------------------------------------
[03/10] incubator-usergrid git commit: Fixes method removal on merge
Posted by sf...@apache.org.
Fixes method removal on 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/490e2cb2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/490e2cb2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/490e2cb2
Branch: refs/heads/two-dot-o-dev
Commit: 490e2cb2ec58f8acd0411e5154e70ca8b801aaec
Parents: 9c9fb27
Author: Todd Nine <tn...@apigee.com>
Authored: Thu May 28 06:37:41 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu May 28 06:37:41 2015 -0600
----------------------------------------------------------------------
.../persistence/index/impl/EsApplicationEntityIndexImpl.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/490e2cb2/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
index 0f0e6a5..fb2dc86 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
@@ -206,7 +206,7 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex {
//I can't just search on the entity Id.
FilterBuilder entityEdgeFilter = FilterBuilders.termFilter( IndexingUtils.EDGE_NODE_ID_FIELDNAME,
- IndexingUtils.idString( edge.getNodeId() ));
+ IndexingUtils.nodeId( edge.getNodeId() ));
srb.setPostFilter(entityEdgeFilter);
@@ -276,7 +276,7 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex {
final SearchRequestBuilder srb = searchRequestBuilderStrategyV2.getBuilder();
FilterBuilder entityIdFilter = FilterBuilders.termFilter( IndexingUtils.ENTITY_ID_FIELDNAME,
- IndexingUtils.idString( entityId ) );
+ IndexingUtils.entityId( entityId ) );
FilterBuilder entityVersionFilter = FilterBuilders.rangeFilter( IndexingUtils.ENTITY_VERSION_FIELDNAME ).lte( markedVersion );
[06/10] incubator-usergrid git commit: Merge branch 'two-dot-o-dev'
of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into
two-dot-o-dev
Posted by sf...@apache.org.
Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o-dev
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/00ba90fd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/00ba90fd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/00ba90fd
Branch: refs/heads/two-dot-o-dev
Commit: 00ba90fdc3290d0cbd073108f3980707e590a08d
Parents: 4fc85a6 ac2cba2
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Jun 1 14:39:11 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Jun 1 14:39:11 2015 -0600
----------------------------------------------------------------------
.../corepersistence/StaleIndexCleanupTest.java | 2 +-
.../collection/users/PermissionsResourceIT.java | 20 +--
.../rest/management/RegistrationIT.java | 122 ++++---------------
3 files changed, 39 insertions(+), 105 deletions(-)
----------------------------------------------------------------------
[02/10] incubator-usergrid git commit: Merge branch 'two-dot-o-dev'
of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into
USERGRID-669
Posted by sf...@apache.org.
Merge branch 'two-dot-o-dev' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-669
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/9c9fb27c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/9c9fb27c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/9c9fb27c
Branch: refs/heads/two-dot-o-dev
Commit: 9c9fb27ce02e12f7ee8753bcbff076c2443f689f
Parents: c3c2480 758c0e5
Author: Todd Nine <tn...@apigee.com>
Authored: Thu May 28 06:31:12 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu May 28 06:31:12 2015 -0600
----------------------------------------------------------------------
.../corepersistence/CpEntityManager.java | 108 +++--
.../corepersistence/CpEntityManagerFactory.java | 47 +-
.../corepersistence/CpRelationManager.java | 219 ++++++----
.../asyncevents/AmazonAsyncEventService.java | 426 +++++++++++++++++++
.../asyncevents/AsyncIndexProvider.java | 38 +-
.../asyncevents/EventBuilderImpl.java | 23 +-
.../asyncevents/InMemoryAsyncEventService.java | 1 -
.../asyncevents/SQSAsyncEventService.java | 356 ----------------
.../asyncevents/model/AsyncEvent.java | 117 +++++
.../asyncevents/model/EdgeDeleteEvent.java | 45 ++
.../asyncevents/model/EdgeIndexEvent.java | 46 ++
.../asyncevents/model/EntityDeleteEvent.java | 36 ++
.../asyncevents/model/EntityIndexEvent.java | 39 ++
.../index/IndexProcessorFig.java | 13 +-
.../corepersistence/index/IndexService.java | 5 +-
.../corepersistence/index/IndexServiceImpl.java | 118 ++---
.../corepersistence/index/ReIndexService.java | 4 +-
.../index/ReIndexServiceImpl.java | 2 +-
.../corepersistence/pipeline/Pipeline.java | 93 ++--
.../pipeline/PipelineBuilderFactory.java | 39 --
.../pipeline/PipelineModule.java | 20 +-
.../pipeline/PipelineOperation.java | 2 +-
.../pipeline/PipelineOperations.java | 30 ++
.../pipeline/builder/CandidateBuilder.java | 67 +++
.../pipeline/builder/ConnectionRefBuilder.java | 53 +++
.../pipeline/builder/EntityBuilder.java | 54 +++
.../pipeline/builder/IdBuilder.java | 151 +++++++
.../pipeline/builder/PipelineBuilder.java | 100 +++++
.../builder/PipelineBuilderFactory.java | 35 ++
.../pipeline/read/AbstractFilter.java | 2 +-
.../pipeline/read/AbstractPathFilter.java | 2 +-
.../pipeline/read/Collector.java | 38 --
.../pipeline/read/CollectorFactory.java | 38 --
.../corepersistence/pipeline/read/Filter.java | 31 --
.../pipeline/read/FilterFactory.java | 74 ++--
.../pipeline/read/ReadFilterFactoryImpl.java | 136 ------
.../pipeline/read/ReadPipelineBuilder.java | 104 -----
.../pipeline/read/ReadPipelineBuilderImpl.java | 296 -------------
.../pipeline/read/ResultsPage.java | 10 +-
.../read/collect/AbstractCollector.java | 46 --
.../read/collect/ConnectionRefFilter.java | 68 +++
.../read/collect/ConnectionRefResumeFilter.java | 86 ++++
.../pipeline/read/collect/EntityFilter.java | 68 ---
.../read/collect/EntityResumeFilter.java | 67 +++
.../pipeline/read/collect/IdResumeFilter.java | 61 +++
.../read/collect/ResultsPageCollector.java | 35 +-
.../AbstractElasticSearchFilter.java | 171 --------
.../pipeline/read/elasticsearch/Candidate.java | 55 ---
.../elasticsearch/CandidateEntityFilter.java | 234 ----------
.../read/elasticsearch/CandidateIdFilter.java | 201 ---------
.../ElasticSearchCollectionFilter.java | 77 ----
.../ElasticSearchConnectionFilter.java | 73 ----
.../ElasticsearchCursorSerializer.java | 42 --
.../read/elasticsearch/Elasticsearchdiagram.jpg | Bin 316655 -> 0 bytes
.../graph/AbstractReadGraphEdgeByIdFilter.java | 82 ----
.../read/graph/AbstractReadGraphFilter.java | 147 -------
.../read/graph/EdgeCursorSerializer.java | 42 --
.../pipeline/read/graph/EntityIdFilter.java | 54 ---
.../pipeline/read/graph/EntityLoadFilter.java | 155 -------
.../pipeline/read/graph/GraphDiagram.jpg | Bin 347711 -> 0 bytes
.../graph/ReadGraphCollectionByIdFilter.java | 49 ---
.../read/graph/ReadGraphCollectionFilter.java | 53 ---
.../graph/ReadGraphConnectionByIdFilter.java | 50 ---
.../graph/ReadGraphConnectionByTypeFilter.java | 100 -----
.../read/graph/ReadGraphConnectionFilter.java | 53 ---
.../search/AbstractElasticSearchFilter.java | 169 ++++++++
.../pipeline/read/search/Candidate.java | 55 +++
.../read/search/CandidateEntityFilter.java | 232 ++++++++++
.../pipeline/read/search/CandidateIdFilter.java | 190 +++++++++
.../search/ElasticsearchCursorSerializer.java | 40 ++
.../read/search/Elasticsearchdiagram.jpg | Bin 0 -> 316655 bytes
.../read/search/SearchCollectionFilter.java | 77 ++++
.../read/search/SearchConnectionFilter.java | 72 ++++
.../AbstractReadGraphEdgeByIdFilter.java | 82 ++++
.../read/traverse/AbstractReadGraphFilter.java | 146 +++++++
.../read/traverse/EdgeCursorSerializer.java | 42 ++
.../pipeline/read/traverse/EntityIdFilter.java | 53 +++
.../read/traverse/EntityLoadVerifyFilter.java | 154 +++++++
.../pipeline/read/traverse/GraphDiagram.jpg | Bin 0 -> 347711 bytes
.../traverse/ReadGraphCollectionByIdFilter.java | 49 +++
.../traverse/ReadGraphCollectionFilter.java | 53 +++
.../traverse/ReadGraphConnectionByIdFilter.java | 50 +++
.../ReadGraphConnectionByTypeFilter.java | 99 +++++
.../traverse/ReadGraphConnectionFilter.java | 53 +++
.../results/ConnectionRefQueryExecutor.java | 60 +++
.../results/EntityQueryExecutor.java | 84 ++++
.../results/ObservableQueryExecutor.java | 52 +--
.../corepersistence/results/QueryExecutor.java | 1 +
.../corepersistence/util/CpNamingUtils.java | 5 +
.../corepersistence/StaleIndexCleanupTest.java | 8 +-
.../index/AmazonAsyncEventServiceTest.java | 84 ++++
.../corepersistence/index/IndexServiceTest.java | 202 ++++++++-
.../index/SQSAsyncEventServiceTest.java | 84 ----
.../pipeline/cursor/CursorTest.java | 4 +-
.../apache/usergrid/persistence/CounterIT.java | 6 +
.../usergrid/persistence/EntityManagerIT.java | 67 ++-
.../cassandra/EntityManagerFactoryImplIT.java | 66 +--
.../mvcc/stage/delete/UniqueCleanup.java | 18 +-
stack/corepersistence/pom.xml | 2 +-
.../index/ApplicationEntityIndex.java | 23 +
.../persistence/index/CandidateResults.java | 4 +-
.../SearchRequestBuilderStrategyV2.java | 69 +++
.../usergrid/persistence/index/IndexEdge.java | 6 +
.../impl/EsApplicationEntityIndexImpl.java | 191 ++++++++-
.../index/impl/EsIndexBufferConsumerImpl.java | 5 +-
.../persistence/index/impl/EntityIndexTest.java | 55 ++-
.../usergrid/persistence/queue/QueueFig.java | 19 +
.../persistence/queue/guice/QueueModule.java | 12 +-
.../queue/impl/SNSQueueManagerImpl.java | 370 ++++++++++++++++
.../queue/impl/SQSQueueManagerImpl.java | 239 +++++++----
.../queue/util/AmazonNotificationUtils.java | 177 ++++++++
stack/pom.xml | 9 +-
.../exceptions/AbstractExceptionMapper.java | 9 +
.../services/notifications/QueueListener.java | 2 +-
.../usergrid/services/ConnectionsServiceIT.java | 1 +
115 files changed, 5216 insertions(+), 3421 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9c9fb27c/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
----------------------------------------------------------------------
[07/10] incubator-usergrid git commit: ManagermentResource
Posted by sf...@apache.org.
ManagermentResource
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/deee37ee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/deee37ee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/deee37ee
Branch: refs/heads/two-dot-o-dev
Commit: deee37ee1d664c98d867f865944717a0568aabfa
Parents: 00ba90f
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Jun 1 15:36:16 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Jun 1 15:36:16 2015 -0600
----------------------------------------------------------------------
.../rest/management/ManagementResourceIT.java | 74 ++++++++------------
.../endpoints/mgmt/ManagementResource.java | 4 ++
2 files changed, 32 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/deee37ee/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
index d5b04be..006b99c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
@@ -316,48 +316,41 @@ public class ManagementResourceIT extends AbstractRestIT {
@Test
public void token() throws Exception {
- JsonNode node = resource().path( "/management/token" ).queryParam( "grant_type", "password" )
- .queryParam( "username", "test@usergrid.com" ).queryParam( "password", "test" )
- .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
+ Token myToken = management.token().get(new QueryParameters().addParam("grant_type", "password").addParam("username", clientSetup.getEmail()).addParam("password", clientSetup.getPassword()));
- logNode( node );
- String token = node.get( "access_token" ).textValue();
+ String token = myToken.getAccessToken();
assertNotNull( token );
// set an organization property
- HashMap<String, Object> payload = new HashMap<String, Object>();
+ Organization payload = new Organization();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put( "securityLevel", 5 );
payload.put( OrganizationsResource.ORGANIZATION_PROPERTIES, properties );
- node = resource().path( "/management/organizations/test-organization" )
- .queryParam( "access_token", clientSetup.getSuperuserToken().getAccessToken() )
- .accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE )
- .put( JsonNode.class, payload );
+ management.orgs().organization(clientSetup.getOrganizationName())
+ .put(payload);
// ensure the organization property is included
- node = resource().path( "/management/token" ).queryParam( "access_token", token )
- .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
- logNode( node );
+ myToken = myToken = management.token().get(new QueryParameters().addParam("access_token", token));
+
- JsonNode securityLevel = node.findValue( "securityLevel" );
+ Object securityLevel = myToken.get("securityLevel");
assertNotNull( securityLevel );
- assertEquals( 5L, securityLevel.asLong() );
+ assertEquals( 5L, (long)securityLevel );
}
@Test
public void meToken() throws Exception {
- JsonNode node = resource().path( "/management/me" ).queryParam( "grant_type", "password" )
- .queryParam( "username", "test@usergrid.com" ).queryParam( "password", "test" )
- .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
+ QueryParameters queryParameters = new QueryParameters().addParam("grant_type", "password")
+ .addParam("username", "test@usergrid.com").addParam("password", "test");
+ JsonNode node = management.me().post(JsonNode.class,queryParameters);
+
logNode( node );
String token = node.get( "access_token" ).textValue();
assertNotNull( token );
- node = resource().path( "/management/me" ).queryParam( "access_token", token )
- .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
+ node = management.me().get( JsonNode.class );
logNode( node );
assertNotNull( node.get( "passwordChanged" ) );
@@ -427,8 +420,7 @@ public class ManagementResourceIT extends AbstractRestIT {
Status responseStatus = null;
try {
- resource().path( "/management/token" ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
+ management.token().post(JsonNode.class, payload);
}
catch ( UniformInterfaceException uie ) {
responseStatus = uie.getResponse().getClientResponseStatus();
@@ -448,8 +440,7 @@ public class ManagementResourceIT extends AbstractRestIT {
Status responseStatus = null;
try {
- resource().path( "/management/token" ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
+ management.token().post(JsonNode.class, payload);
}
catch ( UniformInterfaceException uie ) {
responseStatus = uie.getResponse().getClientResponseStatus();
@@ -522,15 +513,10 @@ public class ManagementResourceIT extends AbstractRestIT {
management().orgs().post(
new Organization( username, username, username+"@example.com", username, "password", null ) );
- Map<String, Object> loginInfo = new HashMap<String, Object>() {{
- put("username", username );
- put("password", "password");
- put("grant_type", "password");
- }};
- JsonNode accessInfoNode = resource().path("/management/token")
- .type( MediaType.APPLICATION_JSON_TYPE )
- .post( JsonNode.class, loginInfo );
- String accessToken = accessInfoNode.get( "access_token" ).textValue();
+ refreshIndex();
+ QueryParameters queryParams = new QueryParameters().addParam("username", username ).addParam("password", "password").addParam("grant_type", "password");
+ Token accessInfoNode = management.token().get(queryParams);
+ String accessToken = accessInfoNode.getAccessToken();
// set the Usergrid Central SSO URL because Tomcat port is dynamically assigned
@@ -538,29 +524,25 @@ public class ManagementResourceIT extends AbstractRestIT {
Map<String, String> props = new HashMap<String, String>();
props.put( USERGRID_CENTRAL_URL, getBaseURI().toURL().toExternalForm() );
resource().path( "/testproperties" )
- .queryParam( "access_token", suToken)
+ .queryParam("access_token", suToken)
.accept( MediaType.APPLICATION_JSON )
.type( MediaType.APPLICATION_JSON_TYPE )
.post( props );
// attempt to validate the token, must be valid
+ queryParams = new QueryParameters().addParam("access_token", suToken ).addParam("ext_access_token", accessToken).addParam("ttl", "1000");
- JsonNode validatedNode = resource().path( "/management/externaltoken" )
- .queryParam( "access_token", suToken ) // as superuser
- .queryParam( "ext_access_token", accessToken )
- .queryParam( "ttl", "1000" )
- .get( JsonNode.class );
- String validatedAccessToken = validatedNode.get( "access_token" ).textValue();
+ Entity validatedNode = management.externaltoken().get(Entity.class,queryParams);
+ String validatedAccessToken = validatedNode.get( "access_token" ).toString();
assertEquals( accessToken, validatedAccessToken );
// attempt to validate an invalid token, must fail
try {
- resource().path( "/management/externaltoken" )
- .queryParam( "access_token", suToken ) // as superuser
- .queryParam( "ext_access_token", "rubbish_token")
- .queryParam( "ttl", "1000" )
- .get( JsonNode.class );
+ queryParams = new QueryParameters().addParam("access_token", suToken ).addParam("ext_access_token", "rubbish_token").addParam("ttl", "1000");
+
+ validatedNode = management.externaltoken().get(Entity.class,queryParams);
+
fail("Validation should have failed");
} catch ( UniformInterfaceException actual ) {
assertEquals( 404, actual.getResponse().getStatus() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/deee37ee/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
index 45d9b7f..6b27473 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
@@ -49,6 +49,10 @@ public class ManagementResource extends NamedResource {
return new UsersResource( context, this );
}
+ public EntityEndpoint externaltoken(){
+ return new EntityEndpoint("externaltoken",context,this);
+ }
+
public EntityEndpoint get(final String identifier){
return new EntityEndpoint(identifier, context, this);
}
[04/10] incubator-usergrid git commit: Fixes bugs with naming regex
Posted by sf...@apache.org.
Fixes bugs with naming regex
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/bfe13376
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/bfe13376
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/bfe13376
Branch: refs/heads/two-dot-o-dev
Commit: bfe133765184d523f8cbde2a82f5572757074fd7
Parents: 490e2cb
Author: Todd Nine <tn...@apigee.com>
Authored: Thu May 28 06:52:54 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu May 28 06:52:54 2015 -0600
----------------------------------------------------------------------
.../persistence/index/impl/IndexingUtils.java | 2 +-
.../index/impl/IndexingUtilsTest.java | 32 ++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bfe13376/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
index 94038b1..e82a082 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
@@ -42,7 +42,7 @@ public class IndexingUtils {
public static final String UUID_REX =
"([A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12})";
- public static final String TYPE_REX = "(\\w+)";
+ public static final String TYPE_REX = "(.+)";
private static final String APPID_NAME = "appId";
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bfe13376/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexingUtilsTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexingUtilsTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexingUtilsTest.java
index cc66854..97389b2 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexingUtilsTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexingUtilsTest.java
@@ -91,6 +91,38 @@ public class IndexingUtilsTest {
@Test
+ public void testDocumentIdPipes() {
+
+ final ApplicationScopeImpl applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) );
+
+ final Id id = new SimpleId( "id" );
+ final UUID version = UUIDGenerator.newTimeUUID();
+
+ final SearchEdgeImpl searchEdge =
+ new SearchEdgeImpl( new SimpleId( "source" ), "zzzcollzzz|users", SearchEdge.NodeType.TARGET );
+
+ final String output = IndexingUtils.createIndexDocId( applicationScope, id, version, searchEdge );
+
+
+ final String expected =
+ "appId(" + applicationScope.getApplication().getUuid() + ",application).entityId(" + id.getUuid() + "," + id
+ .getType() + ").version(" + version + ").nodeId(" + searchEdge.getNodeId().getUuid() + "," + searchEdge
+ .getNodeId().getType() + ").edgeName(zzzcollzzz|users).nodeType(TARGET)";
+
+
+ assertEquals( output, expected );
+
+
+ //now parse it
+
+ final CandidateResult parsedId = parseIndexDocId( output );
+
+ assertEquals(version, parsedId.getVersion());
+ assertEquals(id, parsedId.getId());
+ }
+
+
+ @Test
public void testEntityType() {
final ApplicationScopeImpl applicationScope = new ApplicationScopeImpl( new SimpleId( "application" ) );
[09/10] incubator-usergrid git commit: Merge branch 'two-dot-o-dev'
into USERGRID-669
Posted by sf...@apache.org.
Merge branch 'two-dot-o-dev' into USERGRID-669
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/1d2356b4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/1d2356b4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/1d2356b4
Branch: refs/heads/two-dot-o-dev
Commit: 1d2356b46d4e8174a8b810457d3d45b384c0acfb
Parents: 210273b deee37e
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Jun 1 15:37:10 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Jun 1 15:37:10 2015 -0600
----------------------------------------------------------------------
README.md | 2 +-
docs/file-storage-configuration.md | 39 ++
docs/get_2.0_running_locally.md | 165 +++++++
docs/index.md | 3 +-
.../main/resources/usergrid-default.properties | 24 +-
.../corepersistence/CpEntityManagerFactory.java | 32 +-
.../pipeline/builder/EntityBuilder.java | 2 +-
.../search/AbstractElasticSearchFilter.java | 13 +-
.../pipeline/read/search/Candidate.java | 11 +-
.../read/search/CandidateEntityFilter.java | 66 ++-
.../corepersistence/util/CpNamingUtils.java | 10 +-
.../org/apache/usergrid/persistence/Query.java | 8 +-
.../persistence/cassandra/CassandraService.java | 54 +--
.../org/apache/usergrid/utils/JsonUtils.java | 2 +-
.../corepersistence/StaleIndexCleanupTest.java | 2 +-
.../org/apache/usergrid/persistence/GeoIT.java | 2 +-
.../apache/usergrid/persistence/IndexIT.java | 44 +-
.../persistence/model/field/AbstractField.java | 1 +
.../usergrid/persistence/model/field/Field.java | 13 +-
stack/pom.xml | 28 +-
.../rest/applications/ServiceResource.java | 2 +-
.../rest/management/ManagementResource.java | 403 ++++++++++++++++-
.../organizations/OrganizationsResource.java | 20 +-
.../rest/management/users/UserResource.java | 42 ++
.../rest/management/users/UsersResource.java | 45 +-
.../OAuth2AccessTokenSecurityFilter.java | 4 +
.../applications/assets/AssetResourceIT.java | 302 +++++++++----
.../collection/paging/PagingResourceIT.java | 14 +-
.../collection/users/PermissionsResourceIT.java | 20 +-
.../collection/users/RetrieveUsersTest.java | 5 +-
.../collection/users/UserResourceIT.java | 17 +-
.../applications/queries/AndOrQueryTest.java | 4 +-
.../applications/queries/GeoPagingTest.java | 3 +-
.../rest/applications/queries/OrderByTest.java | 8 +-
.../rest/applications/utils/UserRepo.java | 36 +-
.../rest/filters/ContentTypeResourceIT.java | 177 ++++----
.../usergrid/rest/management/AdminUsersIT.java | 14 +-
.../rest/management/ManagementResourceIT.java | 440 +++++++++++++++++--
.../rest/management/OrganizationsIT.java | 5 +
.../rest/management/RegistrationIT.java | 397 +++++++----------
.../rest/test/PropertiesResourceIT.java | 23 +-
.../test/resource2point0/AbstractRestIT.java | 2 -
.../rest/test/resource2point0/ClientSetup.java | 25 +-
.../endpoints/NamedResource.java | 9 +
.../endpoints/mgmt/FeedResource.java | 5 +-
.../endpoints/mgmt/ManagementResource.java | 4 +
.../endpoints/mgmt/TokenResource.java | 8 +
.../resource2point0/model/Organization.java | 4 +-
.../src/test/resources/cat-larger-than-6mb.jpg | Bin 0 -> 9799257 bytes
stack/rest/src/test/resources/log4j.properties | 3 +-
stack/services/pom.xml | 21 +
.../usergrid/management/ManagementService.java | 5 +-
.../cassandra/ManagementServiceImpl.java | 7 +
.../management/export/S3ExportImpl.java | 7 +
.../apache/usergrid/security/shiro/Realm.java | 10 +-
.../usergrid/security/tokens/TokenService.java | 3 +
.../tokens/cassandra/TokenServiceImpl.java | 44 +-
.../assets/data/AwsSdkS3BinaryStore.java | 230 ++++++++++
.../services/assets/data/S3BinaryStore.java | 268 +++++++----
.../services/notifications/QueueListener.java | 159 +++----
.../usergrid/management/importer/S3Upload.java | 9 +-
.../security/tokens/TokenServiceIT.java | 42 ++
.../usergrid/services/ConnectionsServiceIT.java | 2 +-
.../setup/ConcurrentProcessSingleton.java | 8 +-
ugc/README.md | 2 +-
65 files changed, 2491 insertions(+), 888 deletions(-)
----------------------------------------------------------------------
[05/10] incubator-usergrid git commit: managementresource 2 tests
fixed
Posted by sf...@apache.org.
managementresource 2 tests fixed
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/4fc85a6c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/4fc85a6c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/4fc85a6c
Branch: refs/heads/two-dot-o-dev
Commit: 4fc85a6c3813f79cf22c7d981fbdab5ea83d88bf
Parents: 0d4fa2b
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Jun 1 11:28:57 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Jun 1 11:28:57 2015 -0600
----------------------------------------------------------------------
.../rest/management/ManagementResourceIT.java | 155 ++++++-------------
.../endpoints/NamedResource.java | 9 ++
.../endpoints/mgmt/TokenResource.java | 8 +
3 files changed, 62 insertions(+), 110 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4fc85a6c/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
index e35d339..d5b04be 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
@@ -25,8 +25,10 @@ import org.apache.commons.lang.RandomStringUtils;
import org.apache.usergrid.management.OrganizationOwnerInfo;
import org.apache.usergrid.persistence.index.utils.UUIDUtils;
import org.apache.usergrid.rest.management.organizations.OrganizationsResource;
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
import org.apache.usergrid.rest.test.resource2point0.model.*;
import org.apache.usergrid.rest.test.resource2point0.model.Collection;
+import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,45 +45,43 @@ import static org.junit.Assert.*;
/**
* @author tnine
*/
-public class ManagementResourceIT extends org.apache.usergrid.rest.test.resource2point0.AbstractRestIT {
+public class ManagementResourceIT extends AbstractRestIT {
private static final Logger logger = LoggerFactory.getLogger(ManagementResourceIT.class);
+ private org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.ManagementResource management;
public ManagementResourceIT() throws Exception {
}
+ @Before
+ public void setup() {
+ management= clientSetup.getRestClient().management();
+ }
+
/**
* Test if we can reset our password as an admin
*/
@Test
public void setSelfAdminPasswordAsAdmin() {
- String newPassword = "foo";
+ management.token().setToken(this.getAdminToken());
- Map<String, Object> data = new HashMap<>();
- data.put( "newpassword", newPassword );
- data.put( "oldpassword", "test" );
- JsonNode responseNode = resource().path( "/management/users/test/password" )
- .accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE )
- .post( JsonNode.class, data );
- logNode( responseNode );
+ management.users().post(User.class,new User("test","test","test@email.com","test"));
- String adminAccessToken = context().getToken().getAccessToken();
+ Map<String, Object> data = new HashMap<>();
+ data.put( "newpassword", "foo" );
+ data.put( "oldpassword", "test" );
- data.put( "oldpassword", newPassword );
+ management.users().user("test").password().post(Entity.class, data);
+ data.clear();
+ data.put( "oldpassword", "foo" );
data.put( "newpassword", "test" );
-
- responseNode = resource().path( "/management/users/test/password" )
- .queryParam( "access_token", adminAccessToken )
- .accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE )
- .post( JsonNode.class, data );
-
- logNode( responseNode );
+ Token token = management.token().post(Token.class, new Token( "test", "foo" ) );
+ management.token().setToken( token );
+ management.users().user("test").password().post(Entity.class,data);
}
@@ -260,7 +260,7 @@ public class ManagementResourceIT extends org.apache.usergrid.rest.test.resource
Map roles =(Map) collections.get("roles");
assertNotNull(roles.get("title"));
assertEquals("Roles", roles.get("title").toString());
- assertEquals(3, roles.size());
+ assertEquals(4, roles.size());
refreshIndex( );
@@ -270,10 +270,8 @@ public class ManagementResourceIT extends org.apache.usergrid.rest.test.resource
Entity app = management().orgs().organization(clientSetup.getOrganizationName()).app().addToPath("mgmt-org-app").get();
- assertEquals(this.clientSetup.getOrganizationName().toLowerCase(), app.get("organization").toString());
+ assertEquals(this.clientSetup.getOrganizationName().toLowerCase(), app.get("organizationName").toString());
assertEquals( "mgmt-org-app", app.get( "applicationName" ).toString() );
- assertEquals( "http://sometestvalue/" + this.clientSetup.getOrganizationName().toLowerCase() + "/mgmt-org-app",
- app.get( "uri" ).toString() );
assertEquals( clientSetup.getOrganizationName().toLowerCase() + "/mgmt-org-app", app.get( "name" ).toString() );
metadata =(Map) appdata.get( "metadata" );
@@ -281,7 +279,7 @@ public class ManagementResourceIT extends org.apache.usergrid.rest.test.resource
roles =(Map) collections.get("roles");
assertEquals( "Roles", roles.get("title").toString() );
- assertEquals(3, roles.size());
+ assertEquals(4, roles.size());
}
@Test
@@ -289,29 +287,24 @@ public class ManagementResourceIT extends org.apache.usergrid.rest.test.resource
long ttl = 2000;
- JsonNode node = resource().path( "/management/token" ).queryParam( "grant_type", "password" )
- .queryParam( "username", "test@usergrid.com" ).queryParam( "password", "test" )
- .queryParam( "ttl", String.valueOf( ttl ) ).accept( MediaType.APPLICATION_JSON )
- .get( JsonNode.class );
+ Token token = management.token().get(new QueryParameters().addParam("grant_type", "password").addParam("username", clientSetup.getEmail()).addParam("password", clientSetup.getPassword()).addParam("ttl", String.valueOf(ttl)));
+
long startTime = System.currentTimeMillis();
- String token = node.get( "access_token" ).textValue();
assertNotNull( token );
- JsonNode userdata = resource().path( "/management/users/test@usergrid.com" ).queryParam( "access_token", token )
- .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
+ Entity userdata = management.users().entity(clientSetup.getEmail()).get(token);
- assertEquals( "test@usergrid.com", userdata.get( "data" ).get( "email" ).asText() );
+ assertNotNull(userdata.get("email").toString());
// wait for the token to expire
- Thread.sleep( ttl - (System.currentTimeMillis() - startTime) + 1000 );
+ Thread.sleep( (System.currentTimeMillis() - startTime) + ttl );
Status responseStatus = null;
try {
- userdata = resource().path( "/management/users/test@usergrid.com" ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+ userdata = management.users().user(clientSetup.getEmail()).get();
}
catch ( UniformInterfaceException uie ) {
responseStatus = uie.getResponse().getClientResponseStatus();
@@ -391,17 +384,14 @@ public class ManagementResourceIT extends org.apache.usergrid.rest.test.resource
Map<String, String> payload =
hashMap( "grant_type", "password" ).map( "username", "test@usergrid.com" ).map( "password", "test" );
- JsonNode node = resource().path( "/management/me" ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class, payload );
+ JsonNode node = management.me().post(JsonNode.class, payload);
logNode( node );
String token = node.get( "access_token" ).textValue();
assertNotNull( token );
- node = resource().path( "/management/me" ).queryParam( "access_token", token )
- .accept( MediaType.APPLICATION_JSON ).get( JsonNode.class );
- logNode( node );
+ node = management.me().get( JsonNode.class );
}
@@ -471,40 +461,25 @@ public class ManagementResourceIT extends org.apache.usergrid.rest.test.resource
@Test
public void revokeToken() throws Exception {
- String token1 = context().getToken().getAccessToken();
- String token2 = context().getToken().getAccessToken();
+ Token token1 = management.token().get(clientSetup.getUsername(),clientSetup.getPassword());
- JsonNode response = resource().path( "/management/users/test" )
- .queryParam( "access_token", token1 )
- .accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE )
- .get( JsonNode.class );
+ Entity response = management.users().user(clientSetup.getUsername()).get();
- assertEquals( "test@usergrid.com", response.get( "data" ).get( "email" ).asText() );
+ assertNotNull(response.get("email").toString());
- response = resource().path( "/management/users/test" )
- .queryParam( "access_token", token2 )
- .accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE )
- .get( JsonNode.class );
+ response = management.users().user(clientSetup.getUsername()).get();
- assertEquals( "test@usergrid.com", response.get( "data" ).get( "email" ).asText() );
+ assertNotNull(response.get("email").toString());
// now revoke the tokens
- response = resource().path( "/management/users/test/revoketokens" )
- .queryParam( "access_token", this.clientSetup.getSuperuserToken().getAccessToken() )
- .accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE )
- .post( JsonNode.class );
+ response = management.users().user(clientSetup.getUsername()).revokeTokens().post(true,Entity.class);
// the tokens shouldn't work
Status status = null;
try {
- response = resource().path( "/management/users/test" ).queryParam( "access_token", token1 )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
- .get( JsonNode.class );
+ response = management.users().user(clientSetup.getUsername()).get();
}
catch ( UniformInterfaceException uie ) {
status = uie.getResponse().getClientResponseStatus();
@@ -512,47 +487,21 @@ public class ManagementResourceIT extends org.apache.usergrid.rest.test.resource
assertEquals( Status.UNAUTHORIZED, status );
- status = null;
-
- try {
- response = resource().path( "/management/users/test" ).queryParam( "access_token", token2 )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
- .get( JsonNode.class );
- }
- catch ( UniformInterfaceException uie ) {
- status = uie.getResponse().getClientResponseStatus();
- }
-
- assertEquals( Status.UNAUTHORIZED, status );
-
- String token3 = context().getToken().getAccessToken();
- String token4 = context().getToken().getAccessToken();
-
- response = resource().path( "/management/users/test" ).queryParam( "access_token", token3 )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
- .get( JsonNode.class );
+ Token token3 = management.token().get(clientSetup.getUsername(), clientSetup.getPassword());
- assertEquals( "test@usergrid.com", response.get( "data" ).get( "email" ).asText() );
-
- response = resource().path( "/management/users/test" ).queryParam( "access_token", token4 )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
- .get( JsonNode.class );
-
- assertEquals( "test@usergrid.com", response.get( "data" ).get( "email" ).asText() );
+ response = management.users().user(clientSetup.getUsername()).get();
+ assertNotNull(response.get("email").toString());
// now revoke the token3
- response = resource().path( "/management/users/test/revoketoken" ).queryParam( "access_token", token3 )
- .queryParam( "token", token3 ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).post( JsonNode.class );
+ QueryParameters queryParameters = new QueryParameters();
+ queryParameters.addParam( "token", token3.getAccessToken() );
+ response = management.users().user(clientSetup.getUsername()).revokeToken().post( Entity.class,queryParameters );;
// the token3 shouldn't work
-
status = null;
try {
- response = resource().path( "/management/users/test" ).queryParam( "access_token", token3 )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
- .get( JsonNode.class );
+ response = management.users().user(clientSetup.getUsername()).get();
}
catch ( UniformInterfaceException uie ) {
status = uie.getResponse().getClientResponseStatus();
@@ -560,20 +509,6 @@ public class ManagementResourceIT extends org.apache.usergrid.rest.test.resource
assertEquals( Status.UNAUTHORIZED, status );
- status = null;
-
- try {
- response = resource().path( "/management/users/test" ).queryParam( "access_token", token4 )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
- .get( JsonNode.class );
-
- status = Status.OK;
- }
- catch ( UniformInterfaceException uie ) {
- status = uie.getResponse().getClientResponseStatus();
- }
-
- assertEquals( Status.OK, status );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4fc85a6c/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
index 2a7f29f..b048cee 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/NamedResource.java
@@ -220,6 +220,15 @@ public abstract class NamedResource implements UrlResource {
}
+ //For edge cases like Organizations and Tokens without any payload
+ public <T> T post(boolean useToken , Class<T> type) {
+ GenericType<T> gt = new GenericType<>((Class) type);
+ return getResource(useToken).type(MediaType.APPLICATION_JSON_TYPE)
+ .accept( MediaType.APPLICATION_JSON )
+ .post(gt.getRawClass());
+
+ }
+
public <T> T post(Class<T> type, Form requestEntity) {
GenericType<T> gt = new GenericType<>((Class) type);
return getResource()
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4fc85a6c/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/TokenResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/TokenResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/TokenResource.java
index 6a0c5d6..ff342f7 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/TokenResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/TokenResource.java
@@ -35,6 +35,14 @@ public class TokenResource extends NamedResource {
super("token", context, parent);
}
+ public Token get(String username, String password){
+ QueryParameters queryParameters = new QueryParameters();
+ queryParameters.addParam( "grant_type", "password" );
+ queryParameters.addParam( "username", username );
+ queryParameters.addParam( "password", password );
+ return get(queryParameters);
+
+ }
/**
* Obtains an access token and sets the token for the context to use in later calls
*