Package com.logicaldoc.web.util
Class ServiceUtil
- java.lang.Object
-
- com.logicaldoc.web.util.ServiceUtil
-
public class ServiceUtil extends Object
Various methods related to the user session- Since:
- 6.0
- Author:
- Marco Meschieri - LogicalDOC
-
-
Constructor Summary
Constructors Constructor Description ServiceUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Session
checkEvenOneMenu(javax.servlet.http.HttpServletRequest request, long... menuIds)
Checks if a specific menu is accessible by the user in the current sessionstatic Session
checkMenu(javax.servlet.http.HttpServletRequest request, long menuId)
Check if a specific menu is accessible by the user in the current sessionstatic void
checkPermission(Permission permission, User user, long folderId)
static Date
convertToDate(Date src)
To always deal with dates and not Timestampsstatic Locale
currentLocale(Session session)
static Locale
currentLocale(String sid)
static User
getSessionUser(String sid)
static User
getSessionUser(javax.servlet.http.HttpServletRequest request)
static Object
throwServerException(Session session, org.slf4j.Logger logger, Throwable t)
static Session
validateSession(String sid)
Throws a runtime exception id the given session is invalidstatic Session
validateSession(javax.servlet.http.HttpServletRequest request)
-
-
-
Field Detail
-
LOCALE
public static final String LOCALE
- See Also:
- Constant Field Values
-
USER
public static final String USER
- See Also:
- Constant Field Values
-
-
Method Detail
-
validateSession
public static Session validateSession(javax.servlet.http.HttpServletRequest request) throws InvalidSessionException
- Throws:
InvalidSessionException
-
validateSession
public static Session validateSession(String sid) throws InvalidSessionException
Throws a runtime exception id the given session is invalid- Parameters:
sid
- identifier of the session- Returns:
- the session
- Throws:
InvalidSessionException
- the session does not exist or is expired
-
checkEvenOneMenu
public static Session checkEvenOneMenu(javax.servlet.http.HttpServletRequest request, long... menuIds) throws InvalidSessionException, AccessDeniedException
Checks if a specific menu is accessible by the user in the current session- Parameters:
request
- the HTTP requestmenuIds
- identifiers of the menus- Returns:
- the current session
- Throws:
InvalidSessionException
- the session does not exist or is expiredAccessDeniedException
- the user cannot access any menu
-
checkMenu
public static Session checkMenu(javax.servlet.http.HttpServletRequest request, long menuId) throws InvalidSessionException, AccessDeniedException
Check if a specific menu is accessible by the user in the current session- Parameters:
request
- the HTTP requestmenuId
- identifier of the menus- Returns:
- the curent session
- Throws:
InvalidSessionException
- the session does not exist or is expiredAccessDeniedException
- the user cannot access any menu
-
checkPermission
public static void checkPermission(Permission permission, User user, long folderId) throws AccessDeniedException
- Throws:
AccessDeniedException
-
currentLocale
public static Locale currentLocale(Session session) throws InvalidSessionException
- Throws:
InvalidSessionException
-
currentLocale
public static Locale currentLocale(String sid) throws InvalidSessionException
- Throws:
InvalidSessionException
-
getSessionUser
public static User getSessionUser(String sid) throws InvalidSessionException
- Throws:
InvalidSessionException
-
getSessionUser
public static User getSessionUser(javax.servlet.http.HttpServletRequest request) throws InvalidSessionException
- Throws:
InvalidSessionException
-
throwServerException
public static Object throwServerException(Session session, org.slf4j.Logger logger, Throwable t) throws ServerException
- Throws:
ServerException
-
-