Browse Source

Adding leaf method

pull/60/head
Martin Stockhammer 4 years ago
parent
commit
a34a59f9c3

+ 10
- 3
archiva-modules/archiva-base/archiva-storage-api/src/main/java/org/apache/archiva/repository/storage/StorageAsset.java View File

@@ -36,6 +36,7 @@ import java.util.List;
*
* The implementation may read the data directly from the filesystem or underlying storage implementation.
*
* @since 3.0
* @author Martin Stockhammer <martin_s@apache.org>
*/
public interface StorageAsset
@@ -56,23 +57,29 @@ public interface StorageAsset

/**
* Returns the name of the asset. It may be just the filename.
* @return
* @return the asset name
*/
String getName();

/**
* Returns the time of the last modification.
*
* @return
* @return the time instant of the last modification
*/
Instant getModificationTime();

/**
* Returns true, if this asset is a container type and contains further child assets.
* @return
* @return <code>true</code>, if this is a container type, otherwise <code>false</code>
*/
boolean isContainer();

/**
* Returns true, if this asset is a leaf node and cannot contain further childs
* @return <code>true</code>, if this is a leaf type, otherwise <code>false</code>
*/
boolean isLeaf();

/**
* List the child assets.
*

+ 10
- 0
archiva-modules/archiva-base/archiva-storage-fs/src/main/java/org/apache/archiva/repository/storage/FilesystemAsset.java View File

@@ -257,6 +257,16 @@ public class FilesystemAsset implements StorageAsset, Comparable {
}
}

@Override
public boolean isLeaf( )
{
if (Files.exists( assetPath )) {
return Files.isRegularFile( assetPath );
} else {
return !directoryHint;
}
}

/**
* Returns the list of directory entries, if this asset represents a directory.
* Otherwise a empty list will be returned.

Loading…
Cancel
Save