@Deprecated
    public String renderListing( final String acceptHeader, final StoreKey key, final String requestPath,
                                 final String serviceUrl, final UriFormatter uriFormatter, final EventMetadata eventMetadata )
        throws IndyWorkflowException
    {
        String path = requestPath;
        if ( path.endsWith( LISTING_HTML_FILE ) )
        {
            path = normalize( parentPath( path ) );
        }

        final List<StoreResource> listed = getListing( key, path, eventMetadata );
        if ( ApplicationContent.application_json.equals( acceptHeader ) )
        {
            final DirectoryListingDTO dto = new DirectoryListingDTO( StoreResource.convertToEntries( listed ) );
            try
            {
                return mapper.writeValueAsString( dto );
            }
            catch ( final JsonProcessingException e )
            {
                throw new IndyWorkflowException( "Failed to render listing to JSON: %s. Reason: %s", e, dto,
                                                  e.getMessage() );
            }
        }

        final Map<String, Set<String>> listingUrls = new TreeMap<>();

        final String storeUrl =
            uriFormatter.formatAbsolutePathTo( serviceUrl, key.getType()
                                                              .singularEndpointName(), key.getName() );

        if ( listed != null )
        {
            // first pass, process only obvious directory entries (ending in '/')
            // second pass, process the remainder.
            for ( int pass = 0; pass < 2; pass++ )
            {
                for ( final ConcreteResource res : listed )
                {
                    String p = res.getPath();
                    if ( pass == 0 && !p.endsWith( "/" ) )
                    {
                        continue;
                    }
                    if ( p.endsWith( "-" ) || p.endsWith( "-/" ) )
                    {
                        //skip npm adduser path to avoid the sensitive info showing.
                        continue;
                    }
                    else if ( pass == 1 )
                    {
                        if ( !p.endsWith( "/" ) )
                        {
                            final String dirpath = p + "/";
                            if ( listingUrls.containsKey( normalize( storeUrl, dirpath ) ) )
                            {
                                p = dirpath;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }

                    final String localUrl = normalize( storeUrl, p );
                    Set<String> sources = listingUrls.get( localUrl );
                    if ( sources == null )
                    {
                        sources = new HashSet<>();
                        listingUrls.put( localUrl, sources );
                    }

                    sources.add( normalize( res.getLocationUri(), res.getPath() ) );
                }
            }
        }

        final List<String> sources = new ArrayList<>();
        if ( listed != null )
        {
            for ( final ConcreteResource res : listed )
            {
                // KeyedLocation is all we use in Indy.
                logger.debug( "Formatting sources URL for: {}", res );
                final KeyedLocation kl = (KeyedLocation) res.getLocation();

                final String uri = uriFormatter.formatAbsolutePathTo( serviceUrl, kl.getKey()
                                                                                    .getType()
                                                                                    .singularEndpointName(), kl.getKey()
                                                                                                               .getName() );
                if ( !sources.contains( uri ) )
                {
                    logger.debug( "adding source URI: '{}'", uri );
                    sources.add( uri );
                }
            }
        }

        Collections.sort( sources );

        String parentPath = normalize( parentPath( path ) );
        if ( !parentPath.endsWith( "/" ) )
        {
            parentPath += "/";
        }

        final String parentUrl;
        if ( parentPath.equals( path ) )
        {
            parentPath = null;
            parentUrl = null;
        }
        else
        {
            parentUrl =
                uriFormatter.formatAbsolutePathTo( serviceUrl, key.getType()
                                                                  .singularEndpointName(), key.getName(), parentPath );
        }

        final Map<String, Object> params = new HashMap<>();
        params.put( "items", listingUrls );
        params.put( "parentUrl", parentUrl );
        params.put( "parentPath", parentPath );
        params.put( "path", path );
        params.put( "storeKey", key );
        params.put( "storeUrl", storeUrl );
        params.put( "baseUrl", serviceUrl );
        params.put( "sources", sources );

        // render...
        try
        {
            return templates.render( acceptHeader, "directory-listing", params );
        }
        catch ( final IndyGroovyException e )
        {
            throw new IndyWorkflowException( e.getMessage(), e );
        }
    }
@ Deprecated public String renderListing ( final String acceptHeader , final StoreKey key , final String requestPath , final String serviceUrl , final UriFormatter uriFormatter , final EventMetadata eventMetadata ) throws IndyWorkflowException { String path = requestPath ; if ( path . endsWith ( LISTING_HTML_FILE ) ) { path = normalize ( parentPath ( path ) ) ; } final List < StoreResource > listed = getListing ( key , path , eventMetadata ) ; if ( ApplicationContent . application_json . equals ( acceptHeader ) ) { final DirectoryListingDTO dto = new DirectoryListingDTO ( StoreResource . convertToEntries ( listed ) ) ; try { return mapper . writeValueAsString ( dto ) ; } catch ( final JsonProcessingException e ) { throw new IndyWorkflowException ( "Failed to render listing to JSON: %s. Reason: %s" , e , dto , e . getMessage ( ) ) ; } } final Map < String , Set < String > > listingUrls = new TreeMap < > ( ) ; final String storeUrl = uriFormatter . formatAbsolutePathTo ( serviceUrl , key . getType ( ) . singularEndpointName ( ) , key . getName ( ) ) ; if ( listed != null ) { for ( int pass = 0 ; pass < 2 ; pass ++ ) { for ( final ConcreteResource res : listed ) { String p = res . getPath ( ) ; if ( pass == 0 && ! p . endsWith ( "/" ) ) { continue ; } if ( p . endsWith ( "-" ) || p . endsWith ( "-/" ) ) { continue ; } else if ( pass == 1 ) { if ( ! p . endsWith ( "/" ) ) { final String dirpath = p + "/" ; if ( listingUrls . containsKey ( normalize ( storeUrl , dirpath ) ) ) { p = dirpath ; } } else { continue ; } } final String localUrl = normalize ( storeUrl , p ) ; Set < String > sources = listingUrls . get ( localUrl ) ; if ( sources == null ) { sources = new HashSet < > ( ) ; listingUrls . put ( localUrl , sources ) ; } sources . add ( normalize ( res . getLocationUri ( ) , res . getPath ( ) ) ) ; } } } final List < String > sources = new ArrayList < > ( ) ; if ( listed != null ) { for ( final ConcreteResource res : listed ) { logger . debug ( "Formatting sources URL for: {}" , res ) ; final KeyedLocation kl = ( KeyedLocation ) res . getLocation ( ) ; final String uri = uriFormatter . formatAbsolutePathTo ( serviceUrl , kl . getKey ( ) . getType ( ) . singularEndpointName ( ) , kl . getKey ( ) . getName ( ) ) ; if ( ! sources . contains ( uri ) ) { logger . debug ( "adding source URI: '{}'" , uri ) ; sources . add ( uri ) ; } } } Collections . sort ( sources ) ; String parentPath = normalize ( parentPath ( path ) ) ; if ( ! parentPath . endsWith ( "/" ) ) { parentPath += "/" ; } final String parentUrl ; if ( parentPath . equals ( path ) ) { parentPath = null ; parentUrl = null ; } else { parentUrl = uriFormatter . formatAbsolutePathTo ( serviceUrl , key . getType ( ) . singularEndpointName ( ) , key . getName ( ) , parentPath ) ; } final Map < String , Object > params = new HashMap < > ( ) ; params . put ( "items" , listingUrls ) ; params . put ( "parentUrl" , parentUrl ) ; params . put ( "parentPath" , parentPath ) ; params . put ( "path" , path ) ; params . put ( "storeKey" , key ) ; params . put ( "storeUrl" , storeUrl ) ; params . put ( "baseUrl" , serviceUrl ) ; params . put ( "sources" , sources ) ; try { return templates . render ( acceptHeader , "directory-listing" , params ) ; } catch ( final IndyGroovyException e ) { throw new IndyWorkflowException ( e . getMessage ( ) , e ) ; } }
@deprecated directory listing has been moved to addons/content-browse