You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2015/02/16 20:05:59 UTC

[08/50] incubator-usergrid git commit: Updated resource framework.

Updated resource framework.


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

Branch: refs/heads/USERGRID-273
Commit: bb6ac19dca76aeec34a155817c8a2a29d45a9e52
Parents: 151d8cc
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Feb 11 09:52:15 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Feb 11 09:52:15 2015 -0700

----------------------------------------------------------------------
 .../org/apache/usergrid/rest/ApiResponse.java   |  16 ++
 .../imports/FileErrorsResource.java             | 143 +++++++++++++++
 .../imports/FileIncludesResource.java           | 175 +++++++++++++++++++
 .../applications/imports/ImportResource.java    |  98 -----------
 .../applications/imports/ImportsResource.java   |  82 +++++----
 .../management/importer/ImportService.java      |  45 +++++
 .../management/importer/ImportServiceImpl.java  |  61 +++++--
 7 files changed, 474 insertions(+), 146 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bb6ac19d/stack/rest/src/main/java/org/apache/usergrid/rest/ApiResponse.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/ApiResponse.java b/stack/rest/src/main/java/org/apache/usergrid/rest/ApiResponse.java
index 3df3df4..d7dd5f8 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/ApiResponse.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/ApiResponse.java
@@ -35,6 +35,7 @@ import javax.xml.bind.annotation.XmlRootElement;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.apache.usergrid.persistence.AggregateCounterSet;
 import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.Results;
 import org.apache.usergrid.persistence.entities.Application;
 import org.apache.usergrid.security.oauth.ClientCredentialsInfo;
 import org.apache.usergrid.services.ServiceRequest;
@@ -378,6 +379,21 @@ public class ApiResponse {
     }
 
 
+    /**
+     * Set the response from the EM results
+     * @param results
+     * @return
+     */
+    public ApiResponse withResults(Results results){
+        entities = results.getEntities();
+        next = results.getNextResult();
+        cursor = results.getCursor();
+        counters = results.getCounters();
+
+        return this;
+    }
+
+
     public ApiResponse withResults( ServiceResults results ) {
         setResults( results );
         return this;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bb6ac19d/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileErrorsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileErrorsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileErrorsResource.java
new file mode 100644
index 0000000..552b3b5
--- /dev/null
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileErrorsResource.java
@@ -0,0 +1,143 @@
+/*
+ * 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.rest.management.organizations.applications.imports;
+
+
+import java.util.Collections;
+import java.util.UUID;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.UriInfo;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import org.apache.usergrid.management.ApplicationInfo;
+import org.apache.usergrid.management.importer.ImportService;
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.Results;
+import org.apache.usergrid.persistence.entities.FailedImportEntity;
+import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
+import org.apache.usergrid.rest.AbstractContextResource;
+import org.apache.usergrid.rest.ApiResponse;
+import org.apache.usergrid.rest.RootResource;
+
+import com.sun.jersey.api.json.JSONWithPadding;
+
+
+@Component("org.apache.usergrid.rest.management.organizations.applications.imports.FileErrorsResource")
+@Scope("prototype")
+@Produces(MediaType.APPLICATION_JSON)
+public class FileErrorsResource extends AbstractContextResource {
+
+
+    @Autowired
+    protected ImportService importService;
+
+    private ApplicationInfo application;
+    private UUID importId;
+    private UUID importFileId;
+
+    /**
+     * Override our service manager factory so that we get entities from the root management app
+     */
+    public FileErrorsResource() {
+        //override the services management app
+
+    }
+
+
+    public FileErrorsResource init( final ApplicationInfo application, final UUID importId, final UUID importFileId){
+        this.application = application;
+        this.importId = importId;
+        this.importFileId = importFileId;
+        return this;
+    }
+
+
+
+    @GET
+    public JSONWithPadding getFileIncludes( @Context UriInfo ui, @QueryParam( "cursor" ) String cursor )
+          throws Exception {
+
+
+          final Results importResults = importService.getFailedImportEntities( application.getId(), importId,
+              importFileId, cursor );
+
+          if(importResults == null){
+              throw new EntityNotFoundException( "could not load import results" );
+          }
+
+          ApiResponse response = createApiResponse();
+
+
+          response.setAction( "get" );
+          response.setApplication( emf.getEntityManager( application.getId() ).getApplication()  );
+          response.setParams( ui.getQueryParameters() );
+
+
+          response.withResults( importResults );
+
+          return new JSONWithPadding( response );
+
+      }
+
+    @GET
+    @Path( RootResource.ENTITY_ID_PATH )
+    public JSONWithPadding getFileIncludeById( @Context UriInfo ui, @PathParam( "entityId" ) PathSegment entityId )
+        throws Exception {
+
+        final UUID failedEntity = UUID.fromString( entityId.getPath() );
+        final FailedImportEntity
+            importEntity = importService.getFailedImportEntity( application.getId(), importId, importFileId,
+            failedEntity );
+
+        if(importEntity == null){
+            throw new EntityNotFoundException( "could not find import with uuid " + importId );
+        }
+
+        ApiResponse response = createApiResponse();
+
+
+        response.setAction( "get" );
+        response.setApplication( emf.getEntityManager( application.getId() ).getApplication()  );
+        response.setParams( ui.getQueryParameters() );
+
+
+        response.setEntities( Collections.<Entity>singletonList( importEntity ) );
+
+        return new JSONWithPadding( response );
+
+    }
+
+
+
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bb6ac19d/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileIncludesResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileIncludesResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileIncludesResource.java
new file mode 100644
index 0000000..2d14e93
--- /dev/null
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/FileIncludesResource.java
@@ -0,0 +1,175 @@
+/*
+ * 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.rest.management.organizations.applications.imports;
+
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.UriInfo;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+
+import org.apache.usergrid.management.ApplicationInfo;
+import org.apache.usergrid.management.OrganizationInfo;
+import org.apache.usergrid.management.importer.ImportService;
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.Results;
+import org.apache.usergrid.persistence.entities.FileImport;
+import org.apache.usergrid.persistence.entities.Import;
+import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
+import org.apache.usergrid.persistence.queue.impl.UsergridAwsCredentials;
+import org.apache.usergrid.rest.AbstractContextResource;
+import org.apache.usergrid.rest.ApiResponse;
+import org.apache.usergrid.rest.RootResource;
+import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess;
+
+import com.sun.jersey.api.json.JSONWithPadding;
+
+
+@Component("org.apache.usergrid.rest.management.organizations.applications.imports.FileIncludesResource")
+@Scope("prototype")
+@Produces(MediaType.APPLICATION_JSON)
+public class FileIncludesResource extends AbstractContextResource {
+
+
+    @Autowired
+    protected ImportService importService;
+
+    private ApplicationInfo application;
+    private UUID importId;
+
+    /**
+     * Override our service manager factory so that we get entities from the root management app
+     */
+    public FileIncludesResource() {
+        //override the services management app
+
+    }
+
+
+    public FileIncludesResource init(  final ApplicationInfo application, final UUID importId){
+        this.application = application;
+        this.importId = importId;
+        return this;
+    }
+
+
+
+    @GET
+    public JSONWithPadding getFileIncludes( @Context UriInfo ui, @QueryParam( "cursor" ) String cursor )
+          throws Exception {
+
+
+          final Results importResults = importService.getFileImports( application.getId(), importId, cursor );
+
+          if(importResults == null){
+              throw new EntityNotFoundException( "could not load import results" );
+          }
+
+          ApiResponse response = createApiResponse();
+
+
+          response.setAction( "get" );
+          response.setApplication( emf.getEntityManager( application.getId() ).getApplication()  );
+          response.setParams( ui.getQueryParameters() );
+
+
+          response.withResults( importResults );
+
+          return new JSONWithPadding( response );
+
+      }
+
+    @GET
+    @Path( RootResource.ENTITY_ID_PATH )
+    public JSONWithPadding getFileIncludeById( @Context UriInfo ui, @PathParam( "entityId" ) PathSegment entityId )
+        throws Exception {
+
+        final UUID fileIncludeId = UUID.fromString( entityId.getPath() );
+        final FileImport importEntity = importService.getFileImport( application.getId(), importId, fileIncludeId );
+
+        if(importEntity == null){
+            throw new EntityNotFoundException( "could not find import with uuid " + importId );
+        }
+
+        ApiResponse response = createApiResponse();
+
+
+        response.setAction( "get" );
+        response.setApplication( emf.getEntityManager( application.getId() ).getApplication()  );
+        response.setParams( ui.getQueryParameters() );
+
+
+        response.setEntities( Collections.<Entity>singletonList( importEntity ) );
+
+        return new JSONWithPadding( response );
+
+    }
+
+
+
+
+
+    @GET
+    @Path( RootResource.ENTITY_ID_PATH + "/errors" )
+    public JSONWithPadding getIncludes( @Context UriInfo ui, @PathParam( "entityId" ) PathSegment entityId )
+        throws Exception {
+
+        final UUID importId = UUID.fromString( entityId.getPath() );
+        final Import importEntity = importService.getImport( application.getId(), importId);
+
+        if(importEntity == null){
+            throw new EntityNotFoundException( "could not find import with uuid " + importId );
+        }
+
+        ApiResponse response = createApiResponse();
+
+
+        response.setAction( "get" );
+        response.setApplication( emf.getEntityManager( application.getId() ).getApplication()  );
+        response.setParams( ui.getQueryParameters() );
+
+
+        response.setEntities( Collections.<Entity>singletonList( importEntity ) );
+
+        return new JSONWithPadding( response );
+
+    }
+
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bb6ac19d/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportResource.java
deleted file mode 100644
index ac1c6f5..0000000
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportResource.java
+++ /dev/null
@@ -1,98 +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.rest.management.organizations.applications.imports;
-
-
-import com.sun.jersey.api.json.JSONWithPadding;
-import org.apache.usergrid.exception.NotImplementedException;
-import org.apache.usergrid.management.importer.ImportService;
-import org.apache.usergrid.persistence.Entity;
-import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.rest.AbstractContextResource;
-import org.apache.usergrid.rest.ApiResponse;
-import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
-
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-import java.util.Collections;
-import java.util.UUID;
-
-
-@Component("org.apache.usergrid.rest.management.organizations.applications.imports.ImportResource")
-@Scope("prototype")
-@Produces({
-    MediaType.APPLICATION_JSON,
-    "application/javascript",
-    "application/x-javascript",
-    "text/ecmascript",
-    "application/ecmascript",
-    "text/jscript"
-})
-public class ImportResource extends AbstractContextResource {
-
-    private static final Logger logger = LoggerFactory.getLogger( ImportResource.class );
-
-    private UUID importId;
-
-    @Autowired
-    ImportService importService;
-
-
-    public ImportResource() {
-    }
-
-
-    public ImportResource init( final UUID importId ) {
-        this.importId = importId;
-        return this;
-    }
-
-
-    @GET
-    public JSONWithPadding get() throws Exception {
-
-        logger.info( "ImportResource.get" );
-
-        ApiResponse response = createApiResponse();
-        response.setAction( "Get Import" );
-
-        EntityManager emMgmtApp = emf.getEntityManager( emf.getManagementAppId() );
-        Entity importEntity = emMgmtApp.get(importId);
-
-        response.setEntities( Collections.singletonList( importEntity ));
-
-        return new JSONWithPadding( response );
-    }
-
-
-    @DELETE
-    @RequireOrganizationAccess
-    public JSONWithPadding executeDelete( @Context UriInfo ui,
-        @QueryParam("callback") @DefaultValue("callback") String callback ) throws Exception {
-
-        throw new NotImplementedException( "Organization delete is not allowed yet" );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bb6ac19d/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportsResource.java
index d74b94f..8d23bcd 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/imports/ImportsResource.java
@@ -36,50 +36,31 @@ import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.PathSegment;
-import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 
-import org.apache.amber.oauth2.common.exception.OAuthSystemException;
-import org.apache.amber.oauth2.common.message.OAuthResponse;
-import org.apache.commons.lang.StringUtils;
-
 import org.apache.usergrid.management.ApplicationInfo;
 import org.apache.usergrid.management.OrganizationInfo;
 import org.apache.usergrid.management.importer.ImportService;
 import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.Results;
 import org.apache.usergrid.persistence.entities.Import;
 import org.apache.usergrid.persistence.exceptions.EntityNotFoundException;
-import org.apache.usergrid.persistence.index.query.Identifier;
 import org.apache.usergrid.persistence.queue.impl.UsergridAwsCredentials;
 import org.apache.usergrid.rest.AbstractContextResource;
 import org.apache.usergrid.rest.ApiResponse;
 import org.apache.usergrid.rest.RootResource;
-import org.apache.usergrid.rest.applications.ServiceResource;
-import org.apache.usergrid.rest.applications.users.UserResource;
-import org.apache.usergrid.rest.security.annotations.RequireApplicationAccess;
 import org.apache.usergrid.rest.security.annotations.RequireOrganizationAccess;
-import org.apache.usergrid.rest.utils.JSONPUtils;
-import org.apache.usergrid.services.ServiceAction;
-import org.apache.usergrid.services.ServicePayload;
 
-import com.amazonaws.AmazonClientException;
 import com.sun.jersey.api.json.JSONWithPadding;
 
-import static javax.servlet.http.HttpServletResponse.SC_ACCEPTED;
-import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
-import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
-import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
-
-import static org.apache.usergrid.services.ServiceParameter.addParameter;
 
-
-@Component("org.apache.usergrid.rest.management.organizations.applications.ImportsResource")
-@Scope("prototype")
-@Produces(MediaType.APPLICATION_JSON)
+@Component( "org.apache.usergrid.rest.management.organizations.applications.imports.ImportsResource" )
+@Scope( "prototype" )
+@Produces( MediaType.APPLICATION_JSON )
 public class ImportsResource extends AbstractContextResource {
 
 
@@ -89,6 +70,7 @@ public class ImportsResource extends AbstractContextResource {
     private OrganizationInfo organization;
     private ApplicationInfo application;
 
+
     /**
      * Override our service manager factory so that we get entities from the root management app
      */
@@ -98,7 +80,7 @@ public class ImportsResource extends AbstractContextResource {
     }
 
 
-    public ImportsResource init( final OrganizationInfo organization, final ApplicationInfo application ){
+    public ImportsResource init( final OrganizationInfo organization, final ApplicationInfo application ) {
         this.organization = organization;
         this.application = application;
         return this;
@@ -117,15 +99,11 @@ public class ImportsResource extends AbstractContextResource {
 
 
         response.setAction( "post" );
-        response.setApplication( emf.getEntityManager( application.getId() ).getApplication()  );
+        response.setApplication( emf.getEntityManager( application.getId() ).getApplication() );
         response.setParams( ui.getQueryParameters() );
 
         final Map<String, Object> json = ( Map<String, Object> ) readJsonToObject( body );
 
-        UsergridAwsCredentials uac = new UsergridAwsCredentials();
-
-        Map<String, String> uuidRet = new HashMap<String, String>();
-
         Map<String, Object> properties;
         Map<String, Object> storage_info;
         // UsergridAwsCredentialsProvider uacp = new UsergridAwsCredentialsProvider();
@@ -147,8 +125,8 @@ public class ImportsResource extends AbstractContextResource {
         String bucketName = ( String ) storage_info.get( "bucket_location" );
 
         //check to make sure that access key and secret key are there.
-//        uac.getAWSAccessKeyIdJson( storage_info );
-//        uac.getAWSSecretKeyJson( storage_info );
+        //        uac.getAWSAccessKeyIdJson( storage_info );
+        //        uac.getAWSSecretKeyJson( storage_info );
 
         if ( bucketName == null ) {
             throw new NullPointerException( "Could not find field 'bucketName'" );
@@ -166,14 +144,38 @@ public class ImportsResource extends AbstractContextResource {
 
 
     @GET
+    public JSONWithPadding getImports( @Context UriInfo ui, @QueryParam( "cursor" ) String cursor ) throws Exception {
+
+
+        final Results importResults = importService.getImports( application.getId(), cursor );
+
+        if ( importResults == null ) {
+            throw new EntityNotFoundException( "could not load import results" );
+        }
+
+        ApiResponse response = createApiResponse();
+
+
+        response.setAction( "get" );
+        response.setApplication( emf.getEntityManager( application.getId() ).getApplication() );
+        response.setParams( ui.getQueryParameters() );
+
+
+        response.withResults( importResults );
+
+        return new JSONWithPadding( response );
+    }
+
+
+    @GET
     @Path( RootResource.ENTITY_ID_PATH )
-    public JSONWithPadding addIdParameter( @Context UriInfo ui, @PathParam( "entityId" ) PathSegment entityId )
+    public JSONWithPadding getImportById( @Context UriInfo ui, @PathParam( "entityId" ) PathSegment entityId )
         throws Exception {
 
         final UUID importId = UUID.fromString( entityId.getPath() );
-        final Import importEntity = importService.getImport( application.getId(), importId);
+        final Import importEntity = importService.getImport( application.getId(), importId );
 
-        if(importEntity == null){
+        if ( importEntity == null ) {
             throw new EntityNotFoundException( "could not find import with uuid " + importId );
         }
 
@@ -181,17 +183,21 @@ public class ImportsResource extends AbstractContextResource {
 
 
         response.setAction( "get" );
-        response.setApplication( emf.getEntityManager( application.getId() ).getApplication()  );
+        response.setApplication( emf.getEntityManager( application.getId() ).getApplication() );
         response.setParams( ui.getQueryParameters() );
 
 
         response.setEntities( Collections.<Entity>singletonList( importEntity ) );
 
         return new JSONWithPadding( response );
-
     }
 
 
-
-
+    @GET
+    @Path( RootResource.ENTITY_ID_PATH + "/includes" )
+    public FileIncludesResource getIncludes( @Context UriInfo ui, @PathParam( "entityId" ) PathSegment entityId )
+        throws Exception {
+        final UUID importId = UUID.fromString( entityId.getPath() );
+        return getSubResource( FileIncludesResource.class ).init( application, importId );
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bb6ac19d/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportService.java b/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportService.java
index 1933482..d899dc9 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportService.java
@@ -20,6 +20,7 @@ package org.apache.usergrid.management.importer;
 
 import org.apache.usergrid.batch.JobExecution;
 import org.apache.usergrid.persistence.Results;
+import org.apache.usergrid.persistence.entities.FailedImportEntity;
 import org.apache.usergrid.persistence.entities.FileImport;
 import org.apache.usergrid.persistence.entities.Import;
 
@@ -37,6 +38,12 @@ public interface ImportService {
      */
     Import schedule( final UUID applicationId, Map<String, Object> json ) throws Exception;
 
+    /**
+     * Get the imports results for the application
+     * @param applicationId
+     * @param cursor
+     * @return
+     */
     Results getImports(final UUID applicationId, final String cursor);
 
     /**
@@ -48,6 +55,44 @@ public interface ImportService {
     Import getImport(final UUID applicationId, final UUID importId);
 
     /**
+     * Get the results
+     *
+     * @param importId The import id to get files from
+     * @param cursor The cursor used in parsing
+     * @return
+     */
+    Results getFileImports(final UUID applicationId, final UUID importId, final String cursor);
+
+    /**
+     * Get the file import
+     * @param importId
+     * @param fileImportId
+     * @return
+     */
+    FileImport getFileImport(final UUID applicationId, final UUID importId, final UUID fileImportId);
+
+
+
+    /**
+     * Get the results of failed imports
+     *
+     * @param importId The import id to get files from
+     * @param fileImportId the fileImportId
+     * @param cursor The cursor used in parsing
+     * @return
+     */
+    Results getFailedImportEntities(final UUID applicationId,  final UUID importId, final UUID fileImportId, final String cursor);
+
+    /**
+     * Get the failedimport entity from it's parentId
+     * @param importId
+     * @param fileImportId
+     * @param failedImportId
+     * @return
+     */
+    FailedImportEntity getFailedImportEntity(final UUID applicationId, final UUID importId, final UUID fileImportId, final UUID failedImportId);
+
+    /**
      * Perform the import from the external resource
      */
     void doImport(JobExecution jobExecution) throws Exception;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/bb6ac19d/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
index 6e24264..ba72857 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
@@ -24,6 +24,7 @@ import org.apache.usergrid.batch.service.SchedulerService;
 import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 import org.apache.usergrid.management.ManagementService;
 import org.apache.usergrid.persistence.*;
+import org.apache.usergrid.persistence.entities.FailedImportEntity;
 import org.apache.usergrid.persistence.entities.FileImport;
 import org.apache.usergrid.persistence.entities.Import;
 import org.apache.usergrid.persistence.entities.JobData;
@@ -78,16 +79,7 @@ public class ImportServiceImpl implements ImportService {
     }
 
 
-    public SchedulerService getSch() {
-        return sch;
-    }
-
-
-    public void setSch(final SchedulerService sch) {
-        this.sch = sch;
-    }
 
-    
     /**
      * This schedules the main import Job.
      *
@@ -146,7 +138,25 @@ public class ImportServiceImpl implements ImportService {
 
     @Override
     public Results getImports( final UUID applicationId, final String cursor ) {
-        return null;
+        try {
+            final EntityManager rootEm = emf.getEntityManager( emf.getManagementAppId() );
+
+
+            final Entity applicationEntity = getApplicationEntity( rootEm, applicationId );
+
+            Query query = new Query();
+            if ( cursor != null ) {
+                query.setCursor( cursor );
+            }
+
+            //set our entity type
+            query.setEntityType( Schema.getDefaultSchema().getEntityType( Import.class ) );
+
+            return rootEm.searchCollection( applicationEntity, APP_IMPORT_CONNECTION, query );
+        }
+        catch ( Exception e ) {
+            throw new RuntimeException( "Unable to get import entity", e );
+        }
     }
 
 
@@ -171,6 +181,8 @@ public class ImportServiceImpl implements ImportService {
     }
 
 
+
+
     private Entity getApplicationEntity(final EntityManager rootEm, final UUID applicationId) throws Exception {
         final Entity entity = rootEm.get( new SimpleEntityRef( "application_info", applicationId ) );
 
@@ -181,6 +193,30 @@ public class ImportServiceImpl implements ImportService {
         return entity;
     }
 
+    @Override
+    public Results getFileImports(final UUID applicationId,  final UUID importId, final String cursor ) {
+        return null;
+    }
+
+
+    @Override
+    public FileImport getFileImport(final UUID applicationId,  final UUID importId, final UUID fileImportId ) {
+        return null;
+    }
+
+
+    @Override
+    public Results getFailedImportEntities(final UUID applicationId,  final UUID importId, final UUID fileImportId, final String cursor ) {
+        return null;
+    }
+
+
+    @Override
+    public FailedImportEntity getFailedImportEntity(final UUID applicationId, final UUID importId, final UUID fileImportId,
+                                                     final UUID failedImportId ) {
+        return null;
+    }
+
 
     /**
      * This schedules the sub  FileImport Job
@@ -383,6 +419,11 @@ public class ImportServiceImpl implements ImportService {
     }
 
 
+    public void setSch(final SchedulerService sch) {
+        this.sch = sch;
+    }
+
+
     /**
      * This method creates sub-jobs for each file i.e. File Import Jobs.
      *