You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by gr...@apache.org on 2015/01/27 23:08:16 UTC
incubator-usergrid git commit: Critical fix to organization imports.
Fixes to import rest tests. Fix to REST test framework where management
application gets were doing a post. Added a work around for import where the
entity was returned as a property an
Repository: incubator-usergrid
Updated Branches:
refs/heads/two-dot-o-import 6e301f07c -> 311d2a9d0
Critical fix to organization imports.
Fixes to import rest tests.
Fix to REST test framework where management application gets were doing a post.
Added a work around for import where the entity was returned as a property and not being picked up by the REST test framework.
Added a model for the ImportQueueMessage to distinguish itself.
Left commented in the queue listener for future work.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/311d2a9d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/311d2a9d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/311d2a9d
Branch: refs/heads/two-dot-o-import
Commit: 311d2a9d029f1a798007a8b3a3f57b608a2a2abe
Parents: 6e301f0
Author: grey <gr...@apigee.com>
Authored: Tue Jan 27 14:08:15 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Tue Jan 27 14:08:15 2015 -0800
----------------------------------------------------------------------
.../organizations/OrganizationResource.java | 6 ++--
.../rest/management/ImportResourceIT.java | 32 ++++++++++++--------
.../endpoints/mgmt/ApplicationResource.java | 2 +-
.../rest/test/resource2point0/model/Entity.java | 4 +++
.../services/queues/ImportQueueListener.java | 5 +--
.../services/queues/ImportQueueMessage.java | 15 +++++++++
6 files changed, 47 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/311d2a9d/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
index 7e6032d..da8f475 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/OrganizationResource.java
@@ -25,6 +25,7 @@ import org.apache.usergrid.corepersistence.util.CpNamingUtils;
import org.apache.usergrid.management.ActivationState;
import org.apache.usergrid.management.OrganizationInfo;
import org.apache.usergrid.management.export.ExportService;
+import org.apache.usergrid.management.importer.ImportService;
import org.apache.usergrid.persistence.EntityRef;
import org.apache.usergrid.persistence.SimpleEntityRef;
import org.apache.usergrid.persistence.entities.Export;
@@ -77,7 +78,7 @@ public class OrganizationResource extends AbstractContextResource {
protected ExportService exportService;
@Autowired
- protected ExportService importService;
+ protected ImportService importService; //ExportService importService;
OrganizationInfo organization;
@@ -435,7 +436,8 @@ public class OrganizationResource extends AbstractContextResource {
}
if ( entity == null ) {
- return Response.status( SC_BAD_REQUEST ).build();
+ return Response.status( SC_NOT_FOUND ).type( JSONPUtils.jsonMediaType( callback ) )
+ .entity( ServiceResource.wrapWithCallback( "Import Job not found", callback ) ).build();
}
return Response.status( SC_OK ).entity( entity).build();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/311d2a9d/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
index 882156a..800b131 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
@@ -36,6 +36,7 @@ import java.util.UUID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -52,9 +53,12 @@ public class ImportResourceIT extends AbstractRestIT {
String app = clientSetup.getAppName();
Entity payload = payloadBuilder();
///management/orgs/orgname/apps/appname/collection/users/import
- Entity entity = this.management().orgs().organization(org).apps(app).addToPath("collection").addToPath("users").addToPath("import").post(payload);
+ //Entity entity = this.management().orgs().organization(org).apps(app).addToPath("collection").addToPath("users").addToPath("import").post(payload);
+ Entity entity = this.management().orgs().organization( org ).app().addToPath( app ).addToPath( "collection" ).addToPath( "users" ).addToPath( "import" ).post( payload );
+
+ assertNotNull( entity );
+ assertNotNull( entity.getString( "Import Entity" ));
- assertEquals("", entity.getString("Import Entity"));
}
@@ -66,9 +70,10 @@ public class ImportResourceIT extends AbstractRestIT {
String app = clientSetup.getAppName();
Entity payload = payloadBuilder();
///management/orgs/orgname/apps/appname/import
- Entity entity = this.management().orgs().organization(org).apps(app).addToPath("import").post(payload);
+ Entity entity = this.management().orgs().organization(org).app().addToPath( app ).addToPath("import").post(payload);
- assertEquals("", entity.getString("Import Entity"));
+ assertNotNull( entity );
+ assertNotNull( entity.getString( "Import Entity" ) );
}
@@ -83,7 +88,8 @@ public class ImportResourceIT extends AbstractRestIT {
///management/orgs/orgname/import
Entity entity = this.management().orgs().organization(org).addToPath("import").post(payload);
- assertEquals("", entity.getString("Import Entity"));
+ assertNotNull( entity );
+ assertNotNull( entity.getString( "Import Entity" ) );
}
@@ -96,9 +102,10 @@ public class ImportResourceIT extends AbstractRestIT {
///management/orgs/orgname/import
Entity entity = this.management().orgs().organization(org).addToPath("import").post(payload);
- assertEquals("", entity.getString("Import Entity"));
+ assertNotNull( entity );
+ assertNotNull( entity.getString( "Import Entity" ) );
- String uuid = entity.getString("uuid");
+ String uuid = entity.getString("Import Entity");
uuid = uuid.replaceAll( "\"", "" );
entity = this.management().orgs().organization(org).addToPath("import").addToPath(uuid).get();
@@ -115,13 +122,14 @@ public class ImportResourceIT extends AbstractRestIT {
String app = clientSetup.getAppName();
Entity payload = payloadBuilder();
///management/orgs/orgname/apps/appname/import
- Entity entity = this.management().orgs().organization(org).apps(app).addToPath("import").post(payload);
+ Entity entity = this.management().orgs().organization( org ).app().addToPath( app ).addToPath("import").post(payload);
- assertEquals("", entity.getString("Import Entity"));
+ assertNotNull( entity );
+ assertNotNull( entity.getString( "Import Entity" ) );
String uuid = entity.getString("uuid");
uuid = uuid.replaceAll( "\"", "" );
- entity = this.management().orgs().organization(org).apps(app).addToPath("import").addToPath(uuid).get();
+ entity = this.management().orgs().organization( org ).app().addToPath( app ).addToPath("import").addToPath(uuid).get();
assertEquals( "SCHEDULED", entity.getString( "state" ) );//TODO: do tests for other states in service tier
@@ -135,14 +143,14 @@ public class ImportResourceIT extends AbstractRestIT {
String app = clientSetup.getAppName();
Entity payload = payloadBuilder();
///management/orgs/orgname/apps/appname/import
- Entity entity = this.management().orgs().organization(org).apps(app).addToPath("collection")
+ Entity entity = this.management().orgs().organization( org ).app().addToPath( app ).addToPath("collection")
.addToPath("users").addToPath("import").post(payload);
assertEquals("", entity.getString("Import Entity"));
String uuid = entity.getString("uuid");
uuid = uuid.replaceAll( "\"", "" );
- entity = this.management().orgs().organization(org).apps(app).addToPath("collection")
+ entity = this.management().orgs().organization(org).app().addToPath( app ).addToPath("collection")
.addToPath("users").addToPath("import").addToPath(uuid).get();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/311d2a9d/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
index 0ffbe35..79982c0 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
@@ -61,7 +61,7 @@ public class ApplicationResource extends NamedResource {
public Entity get() {
ApiResponse response = getResource(true).type(MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
- .post(ApiResponse.class);
+ .get(ApiResponse.class);
return new Entity(response);
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/311d2a9d/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
index 635c7b4..efcec2f 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
@@ -79,6 +79,10 @@ public class Entity implements Serializable, Map<String,Object> {
this.putAll( entity );
}
}
+ //TODO: added bit for import tests and other tests that only put a single thing into properties
+ else if (response.getProperties() != null){
+ this.putAll( response.getProperties() );
+ }
}
//For the owner , should have different cases that looks at the different types it could be
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/311d2a9d/stack/services/src/main/java/org/apache/usergrid/services/queues/ImportQueueListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/queues/ImportQueueListener.java b/stack/services/src/main/java/org/apache/usergrid/services/queues/ImportQueueListener.java
index a3d2190..53bf144 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/queues/ImportQueueListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/queues/ImportQueueListener.java
@@ -62,9 +62,10 @@ public class ImportQueueListener extends QueueListener {
*/
for (QueueMessage message : messages) {
ImportQueueMessage queueMessage = ( ImportQueueMessage ) message.getBody();
+
+
/**
- * Do work here that will help determine what import messages are being passed through
- * to s3.
+ * Do work here that will help determine what import messages are being passed from s3
*/
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/311d2a9d/stack/services/src/main/java/org/apache/usergrid/services/queues/ImportQueueMessage.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/queues/ImportQueueMessage.java b/stack/services/src/main/java/org/apache/usergrid/services/queues/ImportQueueMessage.java
index 3d72626..73c34e6 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/queues/ImportQueueMessage.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/queues/ImportQueueMessage.java
@@ -18,6 +18,7 @@ package org.apache.usergrid.services.queues;
import java.io.Serializable;
+import java.util.UUID;
/**
@@ -29,8 +30,22 @@ public class ImportQueueMessage implements Serializable {
* Import specific identifiers here
*/
+ private UUID importId;
+
public ImportQueueMessage(){
}
+ public ImportQueueMessage(UUID importId){
+ this.importId = importId;
+ }
+
+ public UUID getImportId() {
+ return importId;
+ }
+
+
+ public void setImportId( final UUID importId ) {
+ this.importId = importId;
+ }
}