Class DefaultAsyncTemplateStorage
- java.lang.Object
-
- de.dytanic.cloudnet.driver.template.defaults.DefaultAsyncTemplateStorage
-
- All Implemented Interfaces:
de.dytanic.cloudnet.common.INameable,TemplateStorage,java.lang.AutoCloseable
- Direct Known Subclasses:
RemoteTemplateStorage
public abstract class DefaultAsyncTemplateStorage extends java.lang.Object implements TemplateStorage
-
-
Constructor Summary
Constructors Constructor Description DefaultAsyncTemplateStorage()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable java.io.OutputStreamappendOutputStream(@NotNull ServiceTemplate template, @NotNull java.lang.String path)Creates a newOutputStreamthat will append its content to the file at the given path.@Nullable java.util.zip.ZipInputStreamasZipInputStream(@NotNull ServiceTemplate template)Gets a template into aZipInputStream.voidclose()Closes this storage, after it has been closed, no more interaction to this storage should be done and might lead to errors.booleancopy(@NotNull ServiceTemplate template, @NotNull java.nio.file.Path directory)Copies the given template into the given directorybooleancreate(@NotNull ServiceTemplate template)Creates the given template if it doesn't exists.booleancreateDirectory(@NotNull ServiceTemplate template, @NotNull java.lang.String path)Creates a new directory in the given template at the given path if it doesn't exist.booleancreateFile(@NotNull ServiceTemplate template, @NotNull java.lang.String path)Creates a new file in the given template at the given path if it doesn't exist.booleandelete(@NotNull ServiceTemplate template)Deletes the given template if it exists.booleandeleteFile(@NotNull ServiceTemplate template, @NotNull java.lang.String path)Deletes a file in the given template at the given path if it doesn't exist.booleandeploy(@NotNull java.io.InputStream inputStream, @NotNull ServiceTemplate target)Copies the given stream into the given template.booleandeploy(@NotNull java.nio.file.Path directory, @NotNull ServiceTemplate target)Copies the given directory into the given template.booleandeploy(@NotNull java.nio.file.Path directory, @NotNull ServiceTemplate target, @Nullable java.util.function.Predicate<java.nio.file.Path> fileFilter)Deploys the following directory files to the target template storage.@Nullable FileInfogetFileInfo(@NotNull ServiceTemplate template, @NotNull java.lang.String path)Retrieves information about a specified file/directory.@NotNull java.util.Collection<ServiceTemplate>getTemplates()Gets a list of all templates that exist in this storage.booleanhas(@NotNull ServiceTemplate template)Checks whether the given template exists.booleanhasFile(@NotNull ServiceTemplate template, @NotNull java.lang.String path)Checks whether the given path/directory exists in the given template, it doesn't matter if it is a directory or a file.FileInfo[]listFiles(@NotNull ServiceTemplate template, boolean deep)Lists all files in the root directory of the template.FileInfo[]listFiles(@NotNull ServiceTemplate template, @NotNull java.lang.String dir, boolean deep)Lists all files in the given directory.@Nullable java.io.InputStreamnewInputStream(@NotNull ServiceTemplate template, @NotNull java.lang.String path)Creates a newInputStreamwith the data of the file at the given path in the given template.@Nullable java.io.OutputStreamnewOutputStream(@NotNull ServiceTemplate template, @NotNull java.lang.String path)Creates a newOutputStreamthat will override its content to the file at the given path.@Nullable java.io.InputStreamzipTemplate(@NotNull ServiceTemplate template)Zips a template into anInputStream.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.dytanic.cloudnet.driver.template.TemplateStorage
appendOutputStreamAsync, asZipInputStreamAsync, closeAsync, copyAsync, createAsync, createDirectoryAsync, createFileAsync, deleteAsync, deleteFileAsync, deployAsync, deployAsync, deployAsync, getFileInfoAsync, getTemplatesAsync, hasAsync, hasFileAsync, listFiles, listFiles, listFilesAsync, listFilesAsync, listFilesAsync, listFilesAsync, newInputStreamAsync, newOutputStreamAsync, zipTemplateAsync
-
-
-
-
Method Detail
-
deploy
public boolean deploy(@NotNull @NotNull java.nio.file.Path directory, @NotNull @NotNull ServiceTemplate target, @Nullable @Nullable java.util.function.Predicate<java.nio.file.Path> fileFilter)Description copied from interface:TemplateStorageDeploys the following directory files to the target template storage. If the given file filter is not null, method will apply every single file to the given file filter and only deploy files that were allowed by the filter.- Specified by:
deployin interfaceTemplateStorage- Parameters:
directory- the directory to be deployedtarget- the template to be deployed tofileFilter- the filter for files that should be deployed- Returns:
- whether it was copied successfully
-
deploy
public boolean deploy(@NotNull @NotNull java.nio.file.Path directory, @NotNull @NotNull ServiceTemplate target)Description copied from interface:TemplateStorageCopies the given directory into the given template.- Specified by:
deployin interfaceTemplateStorage- Parameters:
directory- the directory to be deployedtarget- the template to be deployed to- Returns:
- whether it was copied successfully
-
deploy
public boolean deploy(@NotNull @NotNull java.io.InputStream inputStream, @NotNull @NotNull ServiceTemplate target)Description copied from interface:TemplateStorageCopies the given stream into the given template.- Specified by:
deployin interfaceTemplateStorage- Parameters:
inputStream- the zipped data to be deployedtarget- the template to be deployed to- Returns:
- whether it was copied successfully
-
copy
public boolean copy(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.nio.file.Path directory)Description copied from interface:TemplateStorageCopies the given template into the given directory- Specified by:
copyin interfaceTemplateStorage- Parameters:
template- the template to copy the files fromdirectory- the target directory to copy the files to- Returns:
- whether it was copied successfully
-
asZipInputStream
@Nullable public @Nullable java.util.zip.ZipInputStream asZipInputStream(@NotNull @NotNull ServiceTemplate template) throws java.io.IOExceptionDescription copied from interface:TemplateStorageGets a template into aZipInputStream.- Specified by:
asZipInputStreamin interfaceTemplateStorage- Parameters:
template- the template to be zipped- Returns:
- a new
ZipInputStreamor null if it the template doesn't exist - Throws:
java.io.IOException- if an I/O error occurred
-
zipTemplate
@Nullable public @Nullable java.io.InputStream zipTemplate(@NotNull @NotNull ServiceTemplate template) throws java.io.IOExceptionDescription copied from interface:TemplateStorageZips a template into anInputStream.- Specified by:
zipTemplatein interfaceTemplateStorage- Parameters:
template- the template to be zipped- Returns:
- a new
InputStreamor null if it the template doesn't exist - Throws:
java.io.IOException- if an I/O error occurred
-
delete
public boolean delete(@NotNull @NotNull ServiceTemplate template)Description copied from interface:TemplateStorageDeletes the given template if it exists.- Specified by:
deletein interfaceTemplateStorage- Parameters:
template- the template to be deleted- Returns:
- whether the template was successfully deleted,
falseif it doesn't exists
-
create
public boolean create(@NotNull @NotNull ServiceTemplate template)Description copied from interface:TemplateStorageCreates the given template if it doesn't exists.- Specified by:
createin interfaceTemplateStorage- Parameters:
template- the template to be deleted- Returns:
- whether the template was successfully created,
falseif it already exists
-
has
public boolean has(@NotNull @NotNull ServiceTemplate template)Description copied from interface:TemplateStorageChecks whether the given template exists.- Specified by:
hasin interfaceTemplateStorage- Parameters:
template- the template to be checked- Returns:
- whether the template exists or not
-
appendOutputStream
@Nullable public @Nullable java.io.OutputStream appendOutputStream(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String path) throws java.io.IOExceptionDescription copied from interface:TemplateStorageCreates a newOutputStreamthat will append its content to the file at the given path. If the file at the given path doesn't exist, it will be created. To finish your modifications, you'll need to close theOutputStream.- Specified by:
appendOutputStreamin interfaceTemplateStorage- Parameters:
template- the template where the target file is located atpath- the path to the file relative to the template- Returns:
- a new
OutputStreamornullif it couldn't be opened - Throws:
java.io.IOException- if an I/O error occurred
-
newOutputStream
@Nullable public @Nullable java.io.OutputStream newOutputStream(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String path) throws java.io.IOExceptionDescription copied from interface:TemplateStorageCreates a newOutputStreamthat will override its content to the file at the given path. If the file at the given path doesn't exist, it will be created. To finish your modifications, you'll need to close theOutputStream.- Specified by:
newOutputStreamin interfaceTemplateStorage- Parameters:
template- the template where the target file is located atpath- the path to the file relative to the template- Returns:
- a new
OutputStreamornullif it couldn't be opened - Throws:
java.io.IOException- if an I/O error occurred
-
createFile
public boolean createFile(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String path) throws java.io.IOExceptionDescription copied from interface:TemplateStorageCreates a new file in the given template at the given path if it doesn't exist.- Specified by:
createFilein interfaceTemplateStorage- Parameters:
template- the template where the target file is located atpath- the path to the file relative to the template- Returns:
- whether the file was created successfully,
falseif it already exists - Throws:
java.io.IOException- if an I/O error occurred
-
createDirectory
public boolean createDirectory(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String path) throws java.io.IOExceptionDescription copied from interface:TemplateStorageCreates a new directory in the given template at the given path if it doesn't exist.- Specified by:
createDirectoryin interfaceTemplateStorage- Parameters:
template- the template where the target file is located atpath- the path to the directory relative to the template- Returns:
- whether the directory was created successfully,
falseif it already exists - Throws:
java.io.IOException- if an I/O error occurred
-
hasFile
public boolean hasFile(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String path) throws java.io.IOExceptionDescription copied from interface:TemplateStorageChecks whether the given path/directory exists in the given template, it doesn't matter if it is a directory or a file.- Specified by:
hasFilein interfaceTemplateStorage- Parameters:
template- the template where the target file is located atpath- the path to the file relative to the template- Returns:
- whether the file exists
- Throws:
java.io.IOException- if an I/O error occurred
-
deleteFile
public boolean deleteFile(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String path) throws java.io.IOExceptionDescription copied from interface:TemplateStorageDeletes a file in the given template at the given path if it doesn't exist.- Specified by:
deleteFilein interfaceTemplateStorage- Parameters:
template- the template where the target file is located atpath- the path to the file relative to the template- Returns:
- whether the file was deleted successfully,
falseif it already exists - Throws:
java.io.IOException- if an I/O error occurred
-
newInputStream
@Nullable public @Nullable java.io.InputStream newInputStream(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String path) throws java.io.IOExceptionDescription copied from interface:TemplateStorageCreates a newInputStreamwith the data of the file at the given path in the given template.- Specified by:
newInputStreamin interfaceTemplateStorage- Parameters:
template- the template where the target file is located atpath- the path to the file relative to the template- Returns:
- the new
InputStreamornullif the file doesn't exist/is a directory - Throws:
java.io.IOException- if an I/O error occurred
-
getFileInfo
@Nullable public @Nullable FileInfo getFileInfo(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String path) throws java.io.IOException
Description copied from interface:TemplateStorageRetrieves information about a specified file/directory.- Specified by:
getFileInfoin interfaceTemplateStorage- Parameters:
template- the template where the target file is located atpath- the path to the file relative to the template- Returns:
- the
FileInfoornullif the file/directory doesn't exist - Throws:
java.io.IOException- if an I/O error occurred
-
listFiles
public FileInfo[] listFiles(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String dir, boolean deep) throws java.io.IOException
Description copied from interface:TemplateStorageLists all files in the given directory.- Specified by:
listFilesin interfaceTemplateStorage- Parameters:
template- the template where the target file is located atdir- the directorydeep- whether the contents of sub directories should also be discovered- Returns:
- a list of all files in the given directory or
nullif the given directory doesn't exist/is not a directory - Throws:
java.io.IOException- if an I/O error occurred
-
listFiles
public FileInfo[] listFiles(@NotNull @NotNull ServiceTemplate template, boolean deep) throws java.io.IOException
Description copied from interface:TemplateStorageLists all files in the root directory of the template.- Specified by:
listFilesin interfaceTemplateStorage- Parameters:
template- the template where the target file is located atdeep- whether the contents of sub directories should also be discovered- Returns:
- a list of all files in the given directory or
nullif the given directory doesn't exist/is not a directory - Throws:
java.io.IOException- if an I/O error occurred
-
getTemplates
@NotNull public @NotNull java.util.Collection<ServiceTemplate> getTemplates()
Description copied from interface:TemplateStorageGets a list of all templates that exist in this storage. Modifications to the collection won't have any effect.- Specified by:
getTemplatesin interfaceTemplateStorage- Returns:
- a list of all templates
-
close
public void close() throws java.io.IOExceptionDescription copied from interface:TemplateStorageCloses this storage, after it has been closed, no more interaction to this storage should be done and might lead to errors.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceTemplateStorage- Throws:
java.io.IOException- if an I/O error occurred
-
-