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 boolean
executeLongRunningOperation(String name, Runnable runnable, Session session)
Executes a given operation and waits a given amount of time for it's completion, if it does not complete in time the thread is left running in background.static User
getSessionUser(String sid)
static User
getSessionUser(javax.servlet.http.HttpServletRequest request)
static GUIAttribute[]
prepareGUIAttributes(Template template, ExtensibleObject extensibleObject)
Prepares the extended attributes of an extensible objectstatic 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
-
convertToDate
public static Date convertToDate(Date src)
To always deal with dates and not Timestamps
-
executeLongRunningOperation
public static boolean executeLongRunningOperation(String name, Runnable runnable, Session session) throws Throwable
Executes a given operation and waits a given amount of time for it's completion, if it does not complete in time the thread is left running in background. Useful for releasing the User Interface and avoiding browser's timeout when you fear that the execution may take too much time.- Parameters:
name
- Name of the operationrunnable
- The operation to executesession
- The current session- Returns:
- true if the runnable already completed successfully
- Throws:
Throwable
- Whatever error that may occur
-
prepareGUIAttributes
public static GUIAttribute[] prepareGUIAttributes(Template template, ExtensibleObject extensibleObject)
Prepares the extended attributes of an extensible object- Parameters:
template
- The template to considerextensibleObject
- The GUI object to consider- Returns:
- The array of attributes
-
-