Package ch.tocco.nice2.dms.api.tree
Class PathNormalizer
java.lang.Object
ch.tocco.nice2.dms.api.tree.PathNormalizer
Util to normalize and validate paths and file names.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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.static String
normalizeAliases
(String aliases) static String
normalizeFilename
(String filename) Removes illegal characters from a string to be used as name for a file or folder.static String
normalizeName
(String name) Removes illegal characters from a string to be used as name for aContentTreeNode
and therefore also as part of an URI.static @Nullable String
normalizePath
(String path) static String
normalizePathParts
(String path)
-
Field Details
-
PATH_PART_PATTERN
- See Also:
-
-
Method Details
-
normalizeName
Removes illegal characters from a string to be used as name for aContentTreeNode
and therefore also as part of an URI. Please note: The name of aContentTreeNode
will be used as itsPath
in anURI
, pointing to a file or folder for example. Therefore, that name has to be a valid filename as well, callingnormalizeFilename(String)
.- Parameters:
name
- the string to be normalized- Returns:
- normalized
-
normalizeFilename
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
-
normalizePath
-
normalizePathParts
-
makeFilenameUnique
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
- theFolderNode
where the document shall be savedresource
- theResourceNode
of which the name has to be checked for already existing resources with the same name- Returns:
- a unique filename to use
-