Class GenericFileHelper

java.lang.Object
org.apache.camel.component.file.GenericFileHelper

public final class GenericFileHelper extends Object
  • Method Details

    • jailToLocalWorkDirectory

      public static void jailToLocalWorkDirectory(File target, File localWorkDirectory)
      Ensures the resolved local work file stays within the configured local work directory. The remote file name used to build the local work file path may contain ../ sequences that would otherwise resolve to a path outside the work directory.
      Parameters:
      target - the resolved local work file (or its in-progress temp file)
      localWorkDirectory - the local work directory the file must stay within
      Throws:
      GenericFileOperationFailedException - if the target resolves outside the local work directory
    • isWithinDirectory

      public static boolean isWithinDirectory(String compactTarget, String compactDir)
      Determines whether a compacted target path is contained within a compacted directory path, using a path-segment boundary comparison. Unlike a bare string prefix test, a sibling directory whose name merely extends the directory name (for example /work versus /workspace) is not considered contained. A trailing separator on the directory is tolerated, and an empty directory imposes no boundary.
      Parameters:
      compactTarget - the compacted target path (see FileUtil.compactPath(String))
      compactDir - the compacted directory the target must stay within
      Returns:
      true if the target is the directory itself or a path inside it
    • asExclusiveReadLockKey

      public static String asExclusiveReadLockKey(GenericFile file, String key)
    • asExclusiveReadLockKey

      public static String asExclusiveReadLockKey(String path, String key)
    • createDummy

      public static <T> org.apache.camel.Exchange createDummy(GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange dynamic, Supplier<GenericFile<T>> file)
    • createDummy

      public static <T> org.apache.camel.Exchange createDummy(GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange dynamic)