Class DefaultSyncTemplateStorage

  • All Implemented Interfaces:
    de.dytanic.cloudnet.common.INameable, TemplateStorage, java.lang.AutoCloseable

    public abstract class DefaultSyncTemplateStorage
    extends java.lang.Object
    implements TemplateStorage
    • 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 new OutputStream that will append its content to the file at the given path.
      @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.util.zip.ZipInputStream> asZipInputStreamAsync​(@NotNull ServiceTemplate template)
      Gets a template into a ZipInputStream.
      @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)
      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.
      @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, boolean deep)
      Lists all files in the root directory of the template.
      @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 new InputStream with 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 new OutputStream that 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 an InputStream.
      • 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.common.INameable

        getName
    • Constructor Detail

      • DefaultSyncTemplateStorage

        public DefaultSyncTemplateStorage()
    • Method Detail

      • 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: TemplateStorage
        Deploys 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:
        deployAsync in interface TemplateStorage
        Parameters:
        directory - the directory to be deployed
        target - the template to be deployed to
        fileFilter - 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.nio.file.Path directory,
                                                                                                   @NotNull
                                                                                                   @NotNull ServiceTemplate target)
        Description copied from interface: TemplateStorage
        Copies the given directory into the given template.
        Specified by:
        deployAsync in interface TemplateStorage
        Parameters:
        directory - the directory to be deployed
        target - the template to be deployed to
        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: TemplateStorage
        Copies the given directory into the given template.
        Specified by:
        deployAsync in interface TemplateStorage
        Parameters:
        inputStream - the zipped data to be deployed
        target - 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: TemplateStorage
        Copies the given template into the given directory
        Specified by:
        copyAsync in interface TemplateStorage
        Parameters:
        template - the template to copy the files from
        directory - the target directory to copy the files to
        Returns:
        whether it was copied successfully
      • asZipInputStreamAsync

        @NotNull
        public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.util.zip.ZipInputStream> asZipInputStreamAsync​(@NotNull
                                                                                                                        @NotNull ServiceTemplate template)
        Description copied from interface: TemplateStorage
        Gets a template into a ZipInputStream.
        Specified by:
        asZipInputStreamAsync in interface TemplateStorage
        Parameters:
        template - the template to be zipped
        Returns:
        a new ZipInputStream or null if it the template doesn't exist
      • zipTemplateAsync

        @NotNull
        public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.io.InputStream> zipTemplateAsync​(@NotNull
                                                                                                          @NotNull ServiceTemplate template)
        Description copied from interface: TemplateStorage
        Zips a template into an InputStream.
        Specified by:
        zipTemplateAsync in interface TemplateStorage
        Parameters:
        template - the template to be zipped
        Returns:
        a new InputStream or 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: TemplateStorage
        Deletes the given template if it exists.
        Specified by:
        deleteAsync in interface TemplateStorage
        Parameters:
        template - the template to be deleted
        Returns:
        whether the template was successfully deleted, false if 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: TemplateStorage
        Creates the given template if it doesn't exists.
        Specified by:
        createAsync in interface TemplateStorage
        Parameters:
        template - the template to be deleted
        Returns:
        whether the template was successfully created, false if 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: TemplateStorage
        Checks whether the given template exists.
        Specified by:
        hasAsync in interface TemplateStorage
        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: TemplateStorage
        Creates a new OutputStream that 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 the OutputStream.
        Specified by:
        appendOutputStreamAsync in interface TemplateStorage
        Parameters:
        template - the template where the target file is located at
        path - the path to the file relative to the template
        Returns:
        a new OutputStream or null if 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: TemplateStorage
        Creates a new OutputStream that 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 the OutputStream.
        Specified by:
        newOutputStreamAsync in interface TemplateStorage
        Parameters:
        template - the template where the target file is located at
        path - the path to the file relative to the template
        Returns:
        a new OutputStream or null if 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: TemplateStorage
        Creates a new file in the given template at the given path if it doesn't exist.
        Specified by:
        createFileAsync in interface TemplateStorage
        Parameters:
        template - the template where the target file is located at
        path - the path to the file relative to the template
        Returns:
        whether the file was created successfully, false if 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: TemplateStorage
        Creates a new directory in the given template at the given path if it doesn't exist.
        Specified by:
        createDirectoryAsync in interface TemplateStorage
        Parameters:
        template - the template where the target file is located at
        path - the path to the directory relative to the template
        Returns:
        whether the directory was created successfully, false if 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: TemplateStorage
        Checks whether the given path/directory exists in the given template, it doesn't matter if it is a directory or a file.
        Specified by:
        hasFileAsync in interface TemplateStorage
        Parameters:
        template - the template where the target file is located at
        path - 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: TemplateStorage
        Deletes a file in the given template at the given path if it doesn't exist.
        Specified by:
        deleteFileAsync in interface TemplateStorage
        Parameters:
        template - the template where the target file is located at
        path - the path to the file relative to the template
        Returns:
        whether the file was deleted successfully, false if 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: TemplateStorage
        Creates a new InputStream with the data of the file at the given path in the given template.
        Specified by:
        newInputStreamAsync in interface TemplateStorage
        Parameters:
        template - the template where the target file is located at
        path - the path to the file relative to the template
        Returns:
        the new InputStream or null if 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: TemplateStorage
        Retrieves information about a specified file/directory.
        Specified by:
        getFileInfoAsync in interface TemplateStorage
        Parameters:
        template - the template where the target file is located at
        path - the path to the file relative to the template
        Returns:
        the FileInfo or null if 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: TemplateStorage
        Lists all files in the given directory.
        Specified by:
        listFilesAsync in interface TemplateStorage
        Parameters:
        template - the template where the target file is located at
        dir - the directory
        deep - whether the contents of sub directories should also be discovered
        Returns:
        a list of all files in the given directory or null if the given directory doesn't exist/is not a directory
      • listFilesAsync

        @NotNull
        public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<FileInfo[]> listFilesAsync​(@NotNull
                                                                                               @NotNull ServiceTemplate template,
                                                                                               boolean deep)
        Description copied from interface: TemplateStorage
        Lists all files in the root directory of the template.
        Specified by:
        listFilesAsync in interface TemplateStorage
        Parameters:
        template - the template where the target file is located at
        deep - whether the contents of sub directories should also be discovered
        Returns:
        a list of all files in the given directory or null if 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: TemplateStorage
        Gets a list of all templates that exist in this storage. Modifications to the collection won't have any effect.
        Specified by:
        getTemplatesAsync in interface TemplateStorage
        Returns:
        a list of all templates
      • closeAsync

        @NotNull
        public @NotNull de.dytanic.cloudnet.common.concurrent.ITask<java.lang.Void> closeAsync()
        Description copied from interface: TemplateStorage
        Closes this storage, after it has been closed, no more interaction to this storage should be done and might lead to errors.
        Specified by:
        closeAsync in interface TemplateStorage