private void handleCollectionResource(final String targetUri,final HttpServerRequest req,final int recursionLevel,final AtomicInteger subRequestCounter,final RecursiveHandlerFactory.RecursiveHandlerTypes recursionHandlerType,final DeltaHandler<ResourceNode> handler,final Buffer data,final String eTag) throws ResourceCollectionException {
  CollectionResourceContainer collectionResourceContainer=ExpansionDeltaUtil.verifyCollectionResponse(targetUri,data,null);
  Logger log=RequestLoggerFactory.getLogger(ExpansionHandler.class,req);
  if (log.isTraceEnabled()) {
    log.trace("Collection resource: " + collectionResourceContainer.getCollectionName());
    log.trace("actual recursion level: " + recursionLevel);
  }
  List<String> subResourceNames=collectionResourceContainer.getResourceNames();
  if (subResourceNames.size() == 0) {
    if (log.isTraceEnabled()) {
      log.trace("No sub resource available for: " + collectionResourceContainer.getCollectionName());
    }
    ResourceNode node=new ResourceNode(collectionResourceContainer.getCollectionName(),new JsonArray(),eTag);
    handler.handle(node);
  }
 else {
    boolean maxRecursionLevelReached=recursionLevel == MAX_RECURSION_LEVEL;
    if (!maxRecursionLevelReached) {
      if (log.isTraceEnabled()) {
        log.trace("max. recursion reached for " + collectionResourceContainer.getCollectionName());
      }
      final DeltaHandler<ResourceNode> parentHandler=RecursiveHandlerFactory.createHandler(recursionHandlerType,subResourceNames,collectionResourceContainer.getCollectionName(),eTag,handler);
      if (isStorageExpand(targetUri)) {
        makeStorageExpandRequest(targetUri,subResourceNames,req,handler);
      }
 else {
        for (        String childResourceName : subResourceNames) {
          if (log.isTraceEnabled()) {
            log.trace("processing child resource: " + childResourceName);
          }
          boolean collection=isCollection(childResourceName);
          final String collectionURI=ExpansionDeltaUtil.constructRequestUri(targetUri,req.params(),parameter_to_remove_after_initial_request,childResourceName,SlashHandling.END_WITHOUT_SLASH);
          makeResourceSubRequest((collection ? collectionURI : removeParameters(collectionURI)),req,recursionLevel - DECREMENT_BY_ONE,subRequestCounter,recursionHandlerType,parentHandler,collection);
        }
      }
    }
 else {
      JsonArray jsonArray=new JsonArray();
      for (      String childResourceName : subResourceNames) {
        if (log.isTraceEnabled()) {
          log.trace("(max level reached) processing child resource: " + childResourceName);
        }
        jsonArray.add(childResourceName);
      }
      handler.handle(new ResourceNode(collectionResourceContainer.getCollectionName(),jsonArray,eTag));
    }
  }
}

private void handleCollectionResource ( final String targetUri , final HttpServerRequest req , final int recursionLevel , final AtomicInteger subRequestCounter , final RecursiveHandlerFactory . RecursiveHandlerTypes recursionHandlerType , final DeltaHandler < ResourceNode > handler , final Buffer data , final String eTag ) throws ResourceCollectionException { CollectionResourceContainer collectionResourceContainer = ExpansionDeltaUtil . verifyCollectionResponse ( targetUri , data , null ) ; Logger log = RequestLoggerFactory . getLogger ( ExpansionHandler . class , req ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "Collection resource: " + collectionResourceContainer . getCollectionName ( ) ) ; log . trace ( "actual recursion level: " + recursionLevel ) ; } List < String > subResourceNames = collectionResourceContainer . getResourceNames ( ) ; if ( subResourceNames . size ( ) == 0 ) { if ( log . isTraceEnabled ( ) ) { log . trace ( "No sub resource available for: " + collectionResourceContainer . getCollectionName ( ) ) ; } ResourceNode node = new ResourceNode ( collectionResourceContainer . getCollectionName ( ) , new JsonArray ( ) , eTag ) ; handler . handle ( node ) ; } else { boolean maxRecursionLevelReached = recursionLevel == MAX_RECURSION_LEVEL ; if ( ! maxRecursionLevelReached ) { if ( log . isTraceEnabled ( ) ) { log . trace ( "max. recursion reached for " + collectionResourceContainer . getCollectionName ( ) ) ; } final DeltaHandler < ResourceNode > parentHandler = RecursiveHandlerFactory . createHandler ( recursionHandlerType , subResourceNames , collectionResourceContainer . getCollectionName ( ) , eTag , handler ) ; if ( isStorageExpand ( targetUri ) ) { makeStorageExpandRequest ( targetUri , subResourceNames , req , handler ) ; } else { for ( String childResourceName : subResourceNames ) { if ( log . isTraceEnabled ( ) ) { log . trace ( "processing child resource: " + childResourceName ) ; } boolean collection = isCollection ( childResourceName ) ; final String collectionURI = ExpansionDeltaUtil . constructRequestUri ( targetUri , req . params ( ) , parameter_to_remove_after_initial_request , childResourceName , SlashHandling . END_WITHOUT_SLASH ) ; makeResourceSubRequest ( ( collection ? collectionURI : removeParameters ( collectionURI ) ) , req , recursionLevel - DECREMENT_BY_ONE , subRequestCounter , recursionHandlerType , parentHandler , collection ) ; } } } else { JsonArray jsonArray = new JsonArray ( ) ; for ( String childResourceName : subResourceNames ) { if ( log . isTraceEnabled ( ) ) { log . trace ( "(max level reached) processing child resource: " + childResourceName ) ; } jsonArray . add ( childResourceName ) ; } handler . handle ( new ResourceNode ( collectionResourceContainer . getCollectionName ( ) , jsonArray , eTag ) ) ; } } }
handles the response data for creating a collection resource .
