Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
import org.commonjava.maven.galley.model.ConcreteResource;
import org.commonjava.maven.galley.spi.cache.CacheProvider;
import org.commonjava.storage.pathmapped.core.PathMappedFileManager;
import org.commonjava.storage.pathmapped.spi.PathDB;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import java.io.InputStream;

import static org.apache.commons.lang3.StringUtils.isNotBlank;

@ApplicationScoped
public class PathMappedController
{
Expand Down Expand Up @@ -53,8 +56,14 @@ public PathMappedDeleteResult delete( String packageType, String type, String na
return new PathMappedDeleteResult( packageType, type, name, path, result );
}

public PathMappedListResult list( String packageType, String type, String name, String path, boolean recursive, int limit )
public PathMappedListResult list( String packageType, String type, String name, String path, boolean recursive,
String fileType, int limit )
{
PathDB.FileType fType = PathDB.FileType.all;
if ( isNotBlank( fileType ) )
{
fType = PathDB.FileType.valueOf( fileType );
}
String[] list;
StoreKey storeKey = new StoreKey( packageType, StoreType.get( type ), name );
if ( recursive )
Expand All @@ -64,11 +73,11 @@ public PathMappedListResult list( String packageType, String type, String name,
{
lmt = limit;
}
list = fileManager.list( storeKey.toString(), path, true, lmt );
list = fileManager.list( storeKey.toString(), path, true, lmt, fType );
}
else
{
list = fileManager.list( storeKey.toString(), path );
list = fileManager.list( storeKey.toString(), path, fType );
}
return new PathMappedListResult( packageType, type, name, path, list );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ public PathMappedListResult listRoot( final @ApiParam( required = true ) @PathPa
final @ApiParam( allowableValues = "hosted,group,remote", required = true ) @PathParam( "type" ) String type,
final @ApiParam( required = true ) @PathParam( "name" ) String name,
final @QueryParam( "recursive" ) boolean recursive,
final @QueryParam( "type" ) String fileType,
final @QueryParam( "limit" ) int limit,
final @Context HttpServletRequest request,
final @Context SecurityContext securityContext )
{
logger.debug( "List, packageType:{}, type:{}, name:{}, recursive:{}", packageType, type, name, recursive );
return controller.list( packageType, type, name, ROOT_DIR, recursive, limit );
return controller.list( packageType, type, name, ROOT_DIR, recursive, fileType, limit );
}

@ApiOperation( "List specified path." )
Expand All @@ -99,13 +100,14 @@ public PathMappedListResult list( final @ApiParam( required = true ) @PathParam(
final @ApiParam( required = true ) @PathParam( "name" ) String name,
final @PathParam( "path" ) String path,
final @QueryParam( "recursive" ) boolean recursive,
final @QueryParam( "type" ) String fileType,
final @QueryParam( "limit" ) int limit,
final @Context HttpServletRequest request,
final @Context SecurityContext securityContext )
{
logger.debug( "List, packageType:{}, type:{}, name:{}, path:{}, recursive:{}", packageType, type, name, path,
recursive );
return controller.list( packageType, type, name, path, recursive, limit );
return controller.list( packageType, type, name, path, recursive, fileType, limit );
}

@ApiOperation( "Get specified path." )
Expand Down