Uploaded image for project: 'Usergrid (Retired)'
  1. Usergrid (Retired)
  2. USERGRID-1293

Asset files do not appear to be deleted

    XMLWordPrintableJSON

Details

    • Story
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.2.0, 2.1.0
    • 2.2.0
    • None
    • None
    • Usergrid 36

    Description

      Need to add a test case to services layer to prove that the asset binary files get deleted when an entity is deleted and fix if proven. Per request from mailing list, appears there is a bug around this as ServiceResults.Type.COLLECTION is almost always used. There does not appear to be a services layer test cases for assets, only REST layer tests which test creation. Any deletion test in REST would only verify that an entity got deleted, but could not check specifically if the asset binary file is gone, hence the need for services layer test.

      I think Usergrid is an amazing project, and I use it as my application's backbone. But I always cannot delete binary files, and here is my question about deleting asset binary files through rest API.
      `stack/rest/src/main/java/org/apache/usergrid/rest/applications/ServiceResource.java` has this code snippet:

          ServiceResults sr = executeServiceRequest( ui, response, ServiceAction.DELETE, null );
      
          // if we deleted an entity (and not a connection or collection) then
          // we may need to clean up binary asset data associated with that entity
      
          if (    !sr.getResultsType().equals( ServiceResults.Type.CONNECTION )
              && !sr.getResultsType().equals( ServiceResults.Type.COLLECTION )) {
      
              // Execute binaryStore.delete()
      

      So I learn Usergrid has a way to delete binary files. Here comes my question. The if-else statement does not allow a ServiceResult whose ResultType equals COLLECTION. But take a look `stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java` (I remember almost services extend this class):

          @Override
          public ServiceResults deleteItemById( ServiceContext context, UUID id ) throws Exception {
      
              checkPermissionsForEntity( context, id );
           
              // skip some contents ...
      
              return new ServiceResults( this, context, Type.COLLECTION, Results.fromEntity( item ), null, null );
          }
      

      Above method always returns a ServiceResults whose ResultType equals Type.COLLECTION. So it always cannot access the code snippet inside of the if-else statement. Is that a bug? Or it's my misunderstanding ? I look forward your help and hope you can explain a little bit more if I'm understanding. Thank you so much.

      Attachments

        Activity

          People

            Unassigned Unassigned
            mrusso Michael Russo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: