Class AstoRepository

java.lang.Object
com.artipie.composer.AstoRepository
All Implemented Interfaces:
Repository

public final class AstoRepository extends Object implements Repository
PHP Composer repository that stores packages in a Storage.
Since:
0.3
  • Field Details

    • ALL_PACKAGES

      public static final Key ALL_PACKAGES
      Key to all packages.
  • Constructor Details

    • AstoRepository

      public AstoRepository(Storage storage)
      Ctor.
      Parameters:
      storage - Storage to store all repository data.
    • AstoRepository

      public AstoRepository(Storage storage, Optional<String> prefix)
      Ctor.
      Parameters:
      storage - Storage to store all repository data.
      prefix - Prefix with url for uploaded archive.
  • Method Details

    • packages

      public CompletionStage<Optional<Packages>> packages()
      Description copied from interface: Repository
      Reads packages description from storage.
      Specified by:
      packages in interface Repository
      Returns:
      Packages found by name, might be empty.
    • packages

      public CompletionStage<Optional<Packages>> packages(Name name)
      Description copied from interface: Repository
      Reads packages description from storage.
      Specified by:
      packages in interface Repository
      Parameters:
      name - Package name.
      Returns:
      Packages found by name, might be empty.
    • addJson

      public CompletableFuture<Void> addJson(Content content, Optional<String> vers)
      Description copied from interface: Repository
      Adds package described in JSON format from storage.
      Specified by:
      addJson in interface Repository
      Parameters:
      content - Package content.
      vers - Version in case of absence version in content with package. If package does not contain version, this value should be passed as a parameter.
      Returns:
      Completion of adding package to repository.
    • addArchive

      public CompletableFuture<Void> addArchive(Archive archive, Content content)
      Description copied from interface: Repository
      Adds package described in archive with ZIP or TAR.GZ format from storage.
      Specified by:
      addArchive in interface Repository
      Parameters:
      archive - Archive with package content.
      content - Package content.
      Returns:
      Completion of adding package to repository.
    • value

      public CompletableFuture<Content> value(Key key)
      Description copied from interface: Repository
      Obtain bytes by key.
      Specified by:
      value in interface Repository
      Parameters:
      key - The key
      Returns:
      Bytes.
    • storage

      public Storage storage()
      Description copied from interface: Repository
      Obtains storage for repository. It can be useful for implementation cache or in other places where Storage instance is required for using classes which are created in asto module.
      Specified by:
      storage in interface Repository
      Returns:
      Storage instance
    • exists

      public CompletableFuture<Boolean> exists(Key key)
      Description copied from interface: Repository
      This file exists?
      Specified by:
      exists in interface Repository
      Parameters:
      key - The key (file name)
      Returns:
      TRUE if exists, FALSE otherwise
    • save

      public CompletableFuture<Void> save(Key key, Content content)
      Description copied from interface: Repository
      Saves the bytes to the specified key.
      Specified by:
      save in interface Repository
      Parameters:
      key - The key
      content - Bytes to save
      Returns:
      Completion or error signal.
    • exclusively

      public <T> CompletionStage<T> exclusively(Key key, Function<Storage,CompletionStage<T>> operation)
      Description copied from interface: Repository
      Runs operation exclusively for specified key.
      Specified by:
      exclusively in interface Repository
      Type Parameters:
      T - Operation result type.
      Parameters:
      key - Key which is scope of operation.
      operation - Operation to be performed exclusively.
      Returns:
      Result of operation.
    • move

      public CompletableFuture<Void> move(Key source, Key destination)
      Description copied from interface: Repository
      Moves value from one location to another.
      Specified by:
      move in interface Repository
      Parameters:
      source - Source key.
      destination - Destination key.
      Returns:
      Completion or error signal.
    • delete

      public CompletableFuture<Void> delete(Key key)
      Description copied from interface: Repository
      Removes value from storage. Fails if value does not exist.
      Specified by:
      delete in interface Repository
      Parameters:
      key - Key for value to be deleted.
      Returns:
      Completion or error signal.