Class ServerDirectoryHelper
- java.lang.Object
-
- org.ametys.plugins.serverdirectory.ServerDirectoryHelper
-
public final class ServerDirectoryHelper extends Object
Helper gathering utility methods for server directories
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
evaluateDynamicPath(String path, String siteName, String language, UserIdentity currentUser)
Evaluate a dynamic path with contextual variablesstatic Set<String>
getRootServerDirectoryPaths()
Get the paths of the server directories' rootsstatic Set<Source>
getRootServerSources(SourceResolver sourceResolver)
Get the sources corresponding to the roots of the defined server directoriesstatic boolean
isValidPath(String path, Set<Source> rootSources)
Check if the given path is a valid path for a root of a server directorystatic String
normalize(String path)
Normalizes a path, removing double and single dot path steps and replace '\' by '/'
-
-
-
Method Detail
-
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
public static Set<String> getRootServerDirectoryPaths()
Get the paths of the server directories' roots- Returns:
- the paths of the server directories' roots
-
normalize
public static String normalize(String path)
Normalizes a path, removing double and single dot path steps and replace '\' by '/'- Parameters:
path
- The path- Returns:
- The normalized path
-
isValidPath
public static boolean isValidPath(String path, Set<Source> rootSources)
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
-
-