archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java
/**
     * Returns the artifacts. The number of artifacts returned depend on the selector.
     * If the selector sets the flag {@link ItemSelector#includeRelatedArtifacts()} to <code>true</code>,
     * additional to the matching artifacts, related artifacts like hash values or signatures are included in the artifact
     * stream.
     * If the selector sets the flag {@link ItemSelector#recurse()} to <code>true</code>, artifacts of the given
     * namespace and from all sub namespaces that start with the given namespace are returned.
     * <ul>
     *     <li>If only a namespace is given, all artifacts with the given namespace or starting with the given
     *     namespace (see {@link ItemSelector#recurse()} are returned.</li>
     *     <li>If a namespace and a project id, or artifact id is given, the artifacts of all versions of the given
     *     namespace and project are returned.</li>
     *     <li>If a namespace and a project id or artifact id and a version is given, the artifacts of the given
     *     version are returned</li>
     *     <li>If no artifact version or artifact id is given, it will return all "artifacts" found in the directory.
     *     To select only artifacts that match the layout you should add the artifact id and artifact version
     *     (can contain a '*' pattern).</li>
     * </ul>
     *
     * The '*' pattern can be used in classifiers and artifact versions and match zero or more characters.
     *
     * There is no determinate order of the elements in the stream.
     *
     * Returned streams are auto closable and should be used in a try-with-resources statement.
     *
     * @param selector the item selector
     * @throws ContentAccessException if the access to the underlying filesystem failed
     */
Returns the artifacts. The number of artifacts returned depend on the selector.
If the selector sets the flag  ItemSelector#includeRelatedArtifacts() to true,
additional to the matching artifacts, related artifacts like hash values or signatures are included in the artifact
stream.
If the selector sets the flag  ItemSelector#recurse() to true, artifacts of the given
namespace and from all sub namespaces that start with the given namespace are returned.

If only a namespace is given, all artifacts with the given namespace or starting with the given
namespace  are returned.
If a namespace and a project id, or artifact id is given, the artifacts of all versions of the given
namespace and project are returned.
If a namespace and a project id or artifact id and a version is given, the artifacts of the given
version are returned
If no artifact version or artifact id is given, it will return all "artifacts" found in the directory.
To select only artifacts that match the layout you should add the artifact id and artifact version
(can contain a '*' pattern).


The '*' pattern can be used in classifiers and artifact versions and match zero or more characters.

There is no determinate order of the elements in the stream.

Returned streams are auto closable and should be used in a try-with-resources statement.

@param selector the item selector
@throws ContentAccessException if the access to the underlying filesystem failed
Returns the artifacts . The number of artifacts returned depend on the selector . If the selector sets the flag ItemSelector#includeRelatedArtifacts () to true additional to the matching artifacts related artifacts like hash values or signatures are included in the artifact stream . If the selector sets the flag ItemSelector#recurse () to true artifacts of the given namespace and from all sub namespaces that start with the given namespace are returned . If only a namespace is given all artifacts with the given namespace or starting with the given namespace are returned . If a namespace and a project id or artifact id is given the artifacts of all versions of the given namespace and project are returned . If a namespace and a project id or artifact id and a version is given the artifacts of the given version are returned If no artifact version or artifact id is given it will return all " artifacts " found in the directory . To select only artifacts that match the layout you should add the artifact id and artifact version ( can contain a ' * ' pattern ) . The ' * ' pattern can be used in classifiers and artifact versions and match zero or more characters . There is no determinate order of the elements in the stream . Returned streams are auto closable and should be used in a try - with - resources statement . @param selector the item selector @throws ContentAccessException if the access to the underlying filesystem failed
@Override
    public Stream<? extends Artifact> newArtifactStream( ItemSelector selector ) throws ContentAccessException
    {
        String projectId = selector.hasProjectId( ) ? selector.getProjectId( ) : ( selector.hasArtifactId( ) ? selector.getArtifactId( )
            : null );
        final Predicate<StorageAsset> filter = getFileFilterFromSelector( selector );
        if (projectId!=null && selector.hasVersion()) {
            return getAsset( selector.getNamespace( ), projectId, selector.getVersion( ) )
                .list( ).stream( ).filter( filter )
                .map( this::getArtifactFromPath );
        } else if (projectId!=null) {
            final StorageAsset projDir = getAsset( selector.getNamespace( ), projectId );
            return projDir.list( ).stream( )
                .map(a -> a.isContainer( ) ? a.list( ) : Arrays.asList( a ) )
                .flatMap( List::stream )
                .filter( filter )
                .map( this::getArtifactFromPath );
        } else
        {
            StorageAsset namespaceDir = getAsset( selector.getNamespace( ) );
            if (selector.recurse())
            {
                return StorageUtil.newAssetStream( namespaceDir, true )
                    .filter( filter )
                        .map( this::getArtifactFromPath );
            } else {
                return namespaceDir.list( ).stream( )
                    .map( a -> a.isContainer( ) ? a.list( ) : Arrays.asList( a ) )
                    .flatMap( List::stream )
                    .map( a -> a.isContainer( ) ? a.list( ) : Arrays.asList( a ) )
                    .flatMap( List::stream )
                    .filter( filter )
                    .map( this::getArtifactFromPath );
            }
        }
    }
@ Override public Stream < ? extends Artifact > newArtifactStream ( ItemSelector selector ) throws ContentAccessException { String projectId = selector . hasProjectId ( ) ? selector . getProjectId ( ) : ( selector . hasArtifactId ( ) ? selector . getArtifactId ( ) : null ) ; final Predicate < StorageAsset > filter = getFileFilterFromSelector ( selector ) ; if ( projectId != null && selector . hasVersion ( ) ) { return getAsset ( selector . getNamespace ( ) , projectId , selector . getVersion ( ) ) . list ( ) . stream ( ) . filter ( filter ) . map ( this :: getArtifactFromPath ) ; } else if ( projectId != null ) { final StorageAsset projDir = getAsset ( selector . getNamespace ( ) , projectId ) ; return projDir . list ( ) . stream ( ) . map ( a -> a . isContainer ( ) ? a . list ( ) : Arrays . asList ( a ) ) . flatMap ( List :: stream ) . filter ( filter ) . map ( this :: getArtifactFromPath ) ; } else { StorageAsset namespaceDir = getAsset ( selector . getNamespace ( ) ) ; if ( selector . recurse ( ) ) { return StorageUtil . newAssetStream ( namespaceDir , true ) . filter ( filter ) . map ( this :: getArtifactFromPath ) ; } else { return namespaceDir . list ( ) . stream ( ) . map ( a -> a . isContainer ( ) ? a . list ( ) : Arrays . asList ( a ) ) . flatMap ( List :: stream ) . map ( a -> a . isContainer ( ) ? a . list ( ) : Arrays . asList ( a ) ) . flatMap ( List :: stream ) . filter ( filter ) . map ( this :: getArtifactFromPath ) ; } } }
Returns the artifacts.
Returns the artifacts .
// We descend into 2 subdirectories (project and version)