Class CacheProcess

java.lang.Object
org.savantbuild.dep.workflow.process.CacheProcess
All Implemented Interfaces:
Process

public class CacheProcess extends Object implements Process
This is an implementation of the Process that uses local caches to fetch and publish artifacts. It manages up to three cache directories: one for Savant-sourced artifacts, one for integration-version artifacts, and one for Maven-sourced artifacts. Any directory can be null to disable that cache.
  • Field Details

    • integrationDir

      public final String integrationDir
    • mavenDir

      public final String mavenDir
    • output

      public final org.savantbuild.output.Output output
    • savantDir

      public final String savantDir
  • Constructor Details

    • CacheProcess

      public CacheProcess(org.savantbuild.output.Output output, String savantDir, String integrationDir, String mavenDir)
  • Method Details

    • fetch

      public FetchResult fetch(ResolvableItem item, PublishWorkflow publishWorkflow) throws NegativeCacheException
      Checks the cache directories for the item. Tries the Savant cache first (tagging hits as SAVANT), then the Maven cache (tagging hits as MAVEN). If found in either, the result is returned. If not found in either, null is returned.
      Specified by:
      fetch in interface Process
      Parameters:
      item - The item being fetched.
      publishWorkflow - The PublishWorkflow that is used to store the item if it can be found.
      Returns:
      The FetchResult from the cache or null if it doesn't exist.
      Throws:
      NegativeCacheException - If there is a negative cache record of the file, meaning it doesn't exist anywhere in the world.
    • publish

      public Path publish(FetchResult fetchResult) throws ProcessFailureException
      Publishes the given artifact item into the appropriate cache. Items are routed based on the FetchResult's source: SAVANT items go to savantDir, MAVEN items go to mavenDir. Returns null if the relevant directory is null or the source doesn't match either cache.
      Specified by:
      publish in interface Process
      Parameters:
      fetchResult - The fetch result containing the item, file, and source.
      Returns:
      The path to the published file, or null if the source doesn't match.
      Throws:
      ProcessFailureException - If the publish fails.
    • toString

      public String toString()
      Overrides:
      toString in class Object