public class FilesystemAsset extends Object implements StorageAsset, Comparable
The implementation does not check the given paths. Caller should normalize the asset path and check, if the base path is a parent of the resulting path.
The file must not exist for all operations.
| Modifier and Type | Field and Description | 
|---|---|
| static AclEntryPermission[] | DEFAULT_ACL_DIR_PERMISSIONS | 
| static AclEntryPermission[] | DEFAULT_ACL_FILE_PERMISSIONS | 
| static Set<PosixFilePermission> | DEFAULT_POSIX_DIR_PERMISSIONS | 
| static String | DEFAULT_POSIX_DIR_PERMS | 
| static Set<PosixFilePermission> | DEFAULT_POSIX_FILE_PERMISSIONS | 
| static String | DEFAULT_POSIX_FILE_PERMS | 
| Constructor and Description | 
|---|
| FilesystemAsset(RepositoryStorage storage,
               String path,
               Path assetPath)Creates an asset for the given path. | 
| FilesystemAsset(RepositoryStorage storage,
               String path,
               Path assetPath,
               Path basePath,
               boolean directory)Creates an asset for the given path. | 
| FilesystemAsset(RepositoryStorage storage,
               String path,
               Path assetPath,
               Path basePath,
               boolean directory,
               boolean setPermissionsForNew)Creates an asset for the given path. | 
| Modifier and Type | Method and Description | 
|---|---|
| int | compareTo(Object o) | 
| void | create()Creates the asset in the underlying storage, if it does not exist. | 
| boolean | exists()Returns true, if the asset exists. | 
| List<AclEntry> | getDefaultDirectoryAcls() | 
| List<AclEntry> | getDefaultFileAcls() | 
| Set<PosixFilePermission> | getDefaultPosixDirectoryPermissions() | 
| Set<PosixFilePermission> | getDefaultPosixFilePermissions() | 
| Path | getFilePath()Returns the real path to the asset, if it exist. | 
| Instant | getModificationTime()Returns the time of the last modification. | 
| String | getName()Returns the name of the asset. | 
| StorageAsset | getParent()Returns the parent of this asset. | 
| String | getPath()Returns the complete path relative to the repository to the given asset. | 
| ReadableByteChannel | getReadChannel()Returns a NIO representation of the data. | 
| InputStream | getReadStream()Returns a input stream to the underlying file, if it exists. | 
| long | getSize()Returns the size of the represented file. | 
| RepositoryStorage | getStorage()Returns the storage this asset belongs to. | 
| WritableByteChannel | getWriteChannel(boolean replace)Returns a NIO representation of the asset where you can write the data. | 
| OutputStream | getWriteStream(boolean replace)Returns an output stream where you can write data to the asset. | 
| boolean | hasParent()Returns true, if there is a parent to this asset. | 
| boolean | isContainer()Returns true, if the path of this asset points to a directory | 
| boolean | isFileBased()Returns true, if the asset can return a file path for the given asset. | 
| List<StorageAsset> | list()Returns the list of directory entries, if this asset represents a directory. | 
| boolean | replaceDataFromFile(Path newData)Replaces the content. | 
| StorageAsset | resolve(String toPath)Returns the asset relative to the given path | 
| void | setDefaultDirectoryAcls(List<AclEntry> acl) | 
| void | setDefaultFileAcls(List<AclEntry> acl) | 
| void | setDefaultPosixDirectoryPermissions(Set<PosixFilePermission> perms) | 
| void | setDefaultPosixFilePermissions(Set<PosixFilePermission> perms) | 
| String | toString() | 
public static final String DEFAULT_POSIX_FILE_PERMS
public static final String DEFAULT_POSIX_DIR_PERMS
public static final Set<PosixFilePermission> DEFAULT_POSIX_FILE_PERMISSIONS
public static final Set<PosixFilePermission> DEFAULT_POSIX_DIR_PERMISSIONS
public static final AclEntryPermission[] DEFAULT_ACL_FILE_PERMISSIONS
public static final AclEntryPermission[] DEFAULT_ACL_DIR_PERMISSIONS
public FilesystemAsset(RepositoryStorage storage, String path, Path assetPath)
path - The logical path for the asset relative to the repository.assetPath - The asset path.public FilesystemAsset(RepositoryStorage storage, String path, Path assetPath, Path basePath, boolean directory)
path - The logical path for the asset relative to the repositoryassetPath - The asset path.directory - This is only relevant, if the represented file or directory does not exist yet and
                  is a hint.public FilesystemAsset(RepositoryStorage storage, String path, Path assetPath, Path basePath, boolean directory, boolean setPermissionsForNew)
path - The logical path for the asset relative to the repositoryassetPath - The asset path.directory - This is only relevant, if the represented file or directory does not exist yet and
                  is a hint.public RepositoryStorage getStorage()
StorageAssetgetStorage in interface StorageAssetpublic String getPath()
StorageAssetgetPath in interface StorageAssetpublic String getName()
StorageAssetgetName in interface StorageAssetpublic Instant getModificationTime()
StorageAssetgetModificationTime in interface StorageAssetpublic boolean isContainer()
isContainer in interface StorageAssetpublic List<StorageAsset> list()
list in interface StorageAssetpublic long getSize()
getSize in interface StorageAssetpublic InputStream getReadStream() throws IOException
getReadStream in interface StorageAssetIOExceptionpublic ReadableByteChannel getReadChannel() throws IOException
StorageAssetgetReadChannel in interface StorageAssetIOExceptionpublic OutputStream getWriteStream(boolean replace) throws IOException
StorageAssetgetWriteStream in interface StorageAssetreplace - If true, the original data will be replaced, otherwise the data will be appended.IOExceptionpublic WritableByteChannel getWriteChannel(boolean replace) throws IOException
StorageAssetgetWriteChannel in interface StorageAssetreplace - True, if the content should be replaced by the data written to the stream.IOExceptionpublic boolean replaceDataFromFile(Path newData) throws IOException
StorageAssetreplaceDataFromFile in interface StorageAssetnewData - Replaces the data by the content of the given file.IOExceptionpublic boolean exists()
StorageAssetexists in interface StorageAssetpublic Path getFilePath() throws UnsupportedOperationException
StorageAssetUnsupportedOperationException, if and only if StorageAsset.isFileBased() returns false.getFilePath in interface StorageAssetUnsupportedOperationException - If the underlying storage is not file based.public boolean isFileBased()
StorageAssetStorageAsset.getFilePath()
 will not throw a UnsupportedOperationExceptionisFileBased in interface StorageAssetpublic boolean hasParent()
StorageAssethasParent in interface StorageAssetpublic StorageAsset getParent()
StorageAssetgetParent in interface StorageAssetnull, if it does not exist.public StorageAsset resolve(String toPath)
StorageAssetresolve in interface StorageAssetpublic void setDefaultFileAcls(List<AclEntry> acl)
public List<AclEntry> getDefaultFileAcls()
public void setDefaultPosixFilePermissions(Set<PosixFilePermission> perms)
public Set<PosixFilePermission> getDefaultPosixFilePermissions()
public void setDefaultDirectoryAcls(List<AclEntry> acl)
public List<AclEntry> getDefaultDirectoryAcls()
public void setDefaultPosixDirectoryPermissions(Set<PosixFilePermission> perms)
public Set<PosixFilePermission> getDefaultPosixDirectoryPermissions()
public void create() throws IOException
StorageAssetcreate in interface StorageAssetIOExceptionpublic int compareTo(Object o)
compareTo in interface ComparableCopyright © 2006–2019 The Apache Software Foundation. All rights reserved.