Class ServerDirectoryHelper
java.lang.Object
org.ametys.plugins.serverdirectory.ServerDirectoryHelper
Helper gathering utility methods for server directories
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringevaluateDynamicPath(String path, String siteName, String language, UserIdentity currentUser) Evaluate a dynamic path with contextual variablesGet the paths of the server directories' rootsgetRootServerSources(SourceResolver sourceResolver) Get the sources corresponding to the roots of the defined server directoriesstatic booleanisValidPath(String path, Set<Source> rootSources) Check if the given path is a valid path for a root of a server directorystatic StringNormalizes a path, removing double and single dot path steps and replace '\' by '/'
-
Method Details
-
getRootServerSources
public static Set<Source> getRootServerSources(SourceResolver sourceResolver) throws ProcessingException Get the sources corresponding to the roots of the defined server directories- Parameters:
sourceResolver- the source resolver- Returns:
- the sources of the server directories' roots
- Throws:
ProcessingException- if the sever directory's location wasn't found
-
getRootServerDirectoryPaths
Get the paths of the server directories' roots- Returns:
- the paths of the server directories' roots
-
normalize
Normalizes a path, removing double and single dot path steps and replace '\' by '/'- Parameters:
path- The path- Returns:
- The normalized path
-
isValidPath
Check if the given path is a valid path for a root of a server directory- Parameters:
path- the path to checkrootSources- the sources corresponding to the server directories' roots- Returns:
- true if the path is valid, false otherwise
-
evaluateDynamicPath
public static String evaluateDynamicPath(String path, String siteName, String language, UserIdentity currentUser) throws AuthorizationRequiredException, AccessDeniedException, IllegalArgumentException Evaluate a dynamic path with contextual variables- Parameters:
path- The dynamic pathsiteName- The current site namelanguage- The current site languagecurrentUser- The current user- Returns:
- The path resolved
- Throws:
AuthorizationRequiredException- If the current user is null and the path required the loginAccessDeniedException- If the connected user does not belong to required populationIllegalArgumentException- If a dynamic variable can not be evaluated
-