Class RemoteTemplateStorage
- java.lang.Object
-
- de.dytanic.cloudnet.driver.template.defaults.DefaultAsyncTemplateStorage
-
- de.dytanic.cloudnet.driver.template.RemoteTemplateStorage
-
- All Implemented Interfaces:
de.dytanic.cloudnet.common.INameable,DriverAPIUser,TemplateStorage,java.lang.AutoCloseable
public class RemoteTemplateStorage extends DefaultAsyncTemplateStorage implements DriverAPIUser
-
-
Constructor Summary
Constructors Constructor Description RemoteTemplateStorage(java.lang.String name, java.util.function.Supplier<INetworkChannel> channelSupplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.io.OutputStream>appendOutputStreamAsync(@NotNull ServiceTemplate template, @NotNull java.lang.String path)Creates a newOutputStreamthat will append its content to the file at the given path.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void>closeAsync()Closes this storage, after it has been closed, no more interaction to this storage should be done and might lead to errors.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean>copyAsync(@NotNull ServiceTemplate template, @NotNull java.nio.file.Path directory)Copies the given template into the given directory@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean>createAsync(@NotNull ServiceTemplate template)Creates the given template if it doesn't exists.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean>createDirectoryAsync(@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.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean>createFileAsync(@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.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean>deleteAsync(@NotNull ServiceTemplate template)Deletes the given template if it exists.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean>deleteFileAsync(@NotNull ServiceTemplate template, @NotNull java.lang.String path)Deletes a file in the given template at the given path if it doesn't exist.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean>deployAsync(@NotNull java.io.InputStream inputStream, @NotNull ServiceTemplate target)Copies the given directory into the given template.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean>deployAsync(@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.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<FileInfo>getFileInfoAsync(@NotNull ServiceTemplate template, @NotNull java.lang.String path)Retrieves information about a specified file/directory.java.lang.StringgetName()INetworkChannelgetNetworkChannel()@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.util.Collection<ServiceTemplate>>getTemplatesAsync()Gets a list of all templates that exist in this storage.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean>hasAsync(@NotNull ServiceTemplate template)Checks whether the given template exists.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean>hasFileAsync(@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.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<FileInfo[]>listFilesAsync(@NotNull ServiceTemplate template, @NotNull java.lang.String dir, boolean deep)Lists all files in the given directory.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.io.InputStream>newInputStreamAsync(@NotNull ServiceTemplate template, @NotNull java.lang.String path)Creates a newInputStreamwith the data of the file at the given path in the given template.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.io.OutputStream>newOutputStreamAsync(@NotNull ServiceTemplate template, @NotNull java.lang.String path)Creates a newOutputStreamthat will override its content to the file at the given path.@NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.io.InputStream>zipTemplateAsync(@NotNull ServiceTemplate template)Zips a template into anInputStream.-
Methods inherited from class de.dytanic.cloudnet.driver.template.defaults.DefaultAsyncTemplateStorage
appendOutputStream, asZipInputStream, close, copy, create, createDirectory, createFile, delete, deleteFile, deploy, deploy, deploy, getFileInfo, getTemplates, has, hasFile, listFiles, listFiles, newInputStream, newOutputStream, zipTemplate
-
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.api.DriverAPIUser
executeChunkedDriverAPIMethod, executeDriverAPIMethod, executeDriverAPIMethod, executeVoidDriverAPIMethod, executeVoidDriverAPIMethod
-
Methods inherited from interface de.dytanic.cloudnet.driver.template.TemplateStorage
asZipInputStreamAsync, deployAsync, listFiles, listFiles, listFilesAsync, listFilesAsync, listFilesAsync
-
-
-
-
Constructor Detail
-
RemoteTemplateStorage
public RemoteTemplateStorage(java.lang.String name, java.util.function.Supplier<INetworkChannel> channelSupplier)
-
-
Method Detail
-
getNetworkChannel
public INetworkChannel getNetworkChannel()
- Specified by:
getNetworkChannelin interfaceDriverAPIUser
-
deployAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean> deployAsync(@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:
deployAsyncin 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
-
deployAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean> deployAsync(@NotNull @NotNull java.io.InputStream inputStream, @NotNull @NotNull ServiceTemplate target)Description copied from interface:TemplateStorageCopies the given directory into the given template.- Specified by:
deployAsyncin interfaceTemplateStorage- Parameters:
inputStream- the zipped data to be deployedtarget- the template to be deployed to- Returns:
- whether it was copied successfully
-
copyAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean> copyAsync(@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:
copyAsyncin interfaceTemplateStorage- Parameters:
template- the template to copy the files fromdirectory- the target directory to copy the files to- Returns:
- whether it was copied successfully
-
zipTemplateAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.io.InputStream> zipTemplateAsync(@NotNull @NotNull ServiceTemplate template)Description copied from interface:TemplateStorageZips a template into anInputStream.- Specified by:
zipTemplateAsyncin interfaceTemplateStorage- Parameters:
template- the template to be zipped- Returns:
- a new
InputStreamor null if it the template doesn't exist
-
deleteAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean> deleteAsync(@NotNull @NotNull ServiceTemplate template)Description copied from interface:TemplateStorageDeletes the given template if it exists.- Specified by:
deleteAsyncin interfaceTemplateStorage- Parameters:
template- the template to be deleted- Returns:
- whether the template was successfully deleted,
falseif it doesn't exists
-
createAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean> createAsync(@NotNull @NotNull ServiceTemplate template)Description copied from interface:TemplateStorageCreates the given template if it doesn't exists.- Specified by:
createAsyncin interfaceTemplateStorage- Parameters:
template- the template to be deleted- Returns:
- whether the template was successfully created,
falseif it already exists
-
hasAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean> hasAsync(@NotNull @NotNull ServiceTemplate template)Description copied from interface:TemplateStorageChecks whether the given template exists.- Specified by:
hasAsyncin interfaceTemplateStorage- Parameters:
template- the template to be checked- Returns:
- whether the template exists or not
-
appendOutputStreamAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.io.OutputStream> appendOutputStreamAsync(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String path)Description 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:
appendOutputStreamAsyncin 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
-
newOutputStreamAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.io.OutputStream> newOutputStreamAsync(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String path)Description 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:
newOutputStreamAsyncin 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
-
createFileAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean> createFileAsync(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String path)Description copied from interface:TemplateStorageCreates a new file in the given template at the given path if it doesn't exist.- Specified by:
createFileAsyncin 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
-
createDirectoryAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean> createDirectoryAsync(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String path)Description copied from interface:TemplateStorageCreates a new directory in the given template at the given path if it doesn't exist.- Specified by:
createDirectoryAsyncin 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
-
hasFileAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean> hasFileAsync(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String path)Description 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:
hasFileAsyncin 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
-
deleteFileAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Boolean> deleteFileAsync(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String path)Description copied from interface:TemplateStorageDeletes a file in the given template at the given path if it doesn't exist.- Specified by:
deleteFileAsyncin 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
-
newInputStreamAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.io.InputStream> newInputStreamAsync(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String path)Description copied from interface:TemplateStorageCreates a newInputStreamwith the data of the file at the given path in the given template.- Specified by:
newInputStreamAsyncin 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
-
getFileInfoAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<FileInfo> getFileInfoAsync(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String path)
Description copied from interface:TemplateStorageRetrieves information about a specified file/directory.- Specified by:
getFileInfoAsyncin 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
-
listFilesAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<FileInfo[]> listFilesAsync(@NotNull @NotNull ServiceTemplate template, @NotNull @NotNull java.lang.String dir, boolean deep)
Description copied from interface:TemplateStorageLists all files in the given directory.- Specified by:
listFilesAsyncin 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
-
getTemplatesAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.util.Collection<ServiceTemplate>> getTemplatesAsync()
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:
getTemplatesAsyncin interfaceTemplateStorage- Returns:
- a list of all templates
-
closeAsync
@NotNull public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void> closeAsync()
Description 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:
closeAsyncin interfaceTemplateStorage
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfacede.dytanic.cloudnet.common.INameable
-
-