Class PathNormalizer

java.lang.Object
ch.tocco.nice2.dms.api.tree.PathNormalizer

public final class PathNormalizer extends Object
Util to normalize and validate paths and file names.
  • Field Details

  • Method Details

    • normalizeName

      public static String normalizeName(String name)
      Removes illegal characters from a string to be used as name for a ContentTreeNode and therefore also as part of an URI. Please note: The name of a ContentTreeNode will be used as its Path in an URI, pointing to a file or folder for example. Therefore, that name has to be a valid filename as well, calling normalizeFilename(String).
      Parameters:
      name - the string to be normalized
      Returns:
      normalized
    • normalizeFilename

      public static String normalizeFilename(String filename)
      Removes illegal characters from a string to be used as name for a file or folder. See applied conventions at https://msdn.microsoft.com/en-us/library/aa365247
      Parameters:
      filename - the string to be normalized
      Returns:
      normalized
    • normalizeAliases

      public static String normalizeAliases(String aliases)
    • normalizePath

      @Nullable public static @Nullable String normalizePath(String path)
    • normalizePathParts

      public static String normalizePathParts(String path)
    • makeFilenameUnique

      public static String makeFilenameUnique(FolderNode folder, ResourceNode resource)
      Checks if a file with the given name already exists and adds a corresponding counter suffix to it's name if so. Example: If there is one document with the same name, it will lead to a document with suffix "-1", counting up for each other document having the same name.
      Parameters:
      folder - the FolderNode where the document shall be saved
      resource - the ResourceNode of which the name has to be checked for already existing resources with the same name
      Returns:
      a unique filename to use