planetj.dataengine
Class NavigationManager

java.lang.Object
  extended byplanetj.dataengine.NavigationManager
All Implemented Interfaces:
INavigation

public final class NavigationManager
extends java.lang.Object
implements INavigation


Field Summary
static java.lang.String className
          Class name.
 
Fields inherited from interface planetj.dataengine.INavigation
CHILD_PREFIX, GROUP_ATTRIBUTES, GROUP_ID, INITIAL_GROUP_ID, INITIAL_PAGE_ID, INITIAL_REQUEST_ID, NAVIGATION_CHECKED, NAVIGATION_OBJECT_LIST_PREFIX, NEW_GROUP_ID, NEW_REQUEST_ID, NEW_SESSION_ID, PAGE_ATTRIBUTES, PAGE_ID, PARENT_PREFIX, PERSISTENT_ATTRIBUTES, PREVIOUS_ATTRIBUTES, PREVIOUS_GROUP_ID, PREVIOUS_PAGE_ID, PREVIOUS_REQUEST_ID, REQUEST_ID, RESET_GROUP_ID, RESET_NAVIGATION_IDS, RESET_NAVIGATION_IDS_COMPLETED, RESET_PAGE_ID, RESET_REQUEST_ID, RESET_SESSION_ID, SESSION_ID
 
Constructor Summary
NavigationManager()
           
 
Method Summary
static void expireOldPages(HttpServletRequest request)
          Expire any old pages.
static NavigationGroup getGroup(java.lang.String sessionId, java.lang.String requestId, java.lang.String groupId, HttpServletRequest request)
          Gets this navigation group for the specified ids.
static java.lang.String getGroupId(boolean create, HttpServletRequest request)
          Get the current group id from the request.
static int getGroupIdAsInt(boolean create, HttpServletRequest request)
          Get the current group id from the request.
static java.util.List getNavigationKeys(java.lang.String listKey, HttpServletRequest request)
          Gets a list of keys for navigation objects stored in navigation that have the same navigation list key as the given key.
static int getNextGroupIdAsInt(HttpServletRequest request)
          Gets the next group id.
static int getNextPageIdAsInt(HttpServletRequest request)
          Gets the next page id.
static int getNextRequestIdAsInt(HttpServletRequest request)
          Gets the next group id.
static java.lang.String getNextSessionId(HttpServletRequest request)
          Gets the next group id.
static NavigationPage getPage(java.lang.String sessionId, java.lang.String requestId, java.lang.String groupId, java.lang.String pageId, HttpServletRequest request)
          Gets this navigation group for the specified ids.
static java.lang.String getPageId(boolean create, HttpServletRequest request)
          Get the current page id from the request.
static int getPageIdAsInt(boolean create, HttpServletRequest request)
          Get the current page id from the request.
static int getPreviousGroupId(HttpServletRequest request)
          Get the group id from the previous request.
static int getPreviousPageId(HttpServletRequest request)
          Get the page id from the previous request.
static int getPreviousRequestId(HttpServletRequest request)
          Get the request id from the previous request.
static NavigationRequest getRequest(java.lang.String sessionId, java.lang.String requestId, HttpServletRequest request)
          Gets this navigation request for the specified ids.
static java.lang.String getRequestId(boolean create, HttpServletRequest request)
          Get the current request id from the request.
static int getRequestIdAsInt(boolean create, HttpServletRequest request)
          Get the current request id from the request.
static NavigationSession getSession(java.lang.String sessionId, HttpServletRequest request)
          Gets this navigation session for the specified id.
static java.lang.String getSessionId(boolean create, HttpServletRequest request)
          Gets the session id for the given request to use for getting and setting session attributes.
static void initializeNavigationIds(HttpServletRequest request, HttpServletResponse response)
          Initializes the navigation state to the proper session, request, group, and page ids.
static boolean isNewGroupId(HttpServletRequest request)
          Test if a new group is desired.
static boolean isNewRequestId(HttpServletRequest request)
          Test if a new request is desired.
static boolean isNewSessionId(HttpServletRequest request)
          Test if a new session is desired.
static boolean isPageExpired(HttpServletRequest request)
          Check if a page is expired.
protected static boolean isValidState(HttpServletRequest request)
          Checks to see if the current navigation state is correct.
protected static boolean persistAttributes(java.lang.String sessionId, java.lang.String requestId, java.lang.String groupId, java.lang.String pageId, HttpServletRequest request)
          Restore the navigation state for the specified navigation ids.
protected static boolean persistPreviousAttributes(HttpServletRequest request)
          Restores the previous navigation state.
static void removeNavigationKey(INavigationObject object, HttpServletRequest request)
          Removes the navigation key from the given navigation object.
static void resetGroupId(HttpServletRequest request)
          Resets the group id for the given request used to get and set attributes in the request's session and maintain naviation state.
static void resetPageId(HttpServletRequest request)
          Resets the page id for the given request used to get and set attributes in the request's session and maintain naviation state.
static void resetRequestId(HttpServletRequest request)
          Resets the request id for the given request used to get and set attributes in the request and maintain state navigation.
static void resetSessionId(HttpServletRequest request)
          Reset the session id for the given request used to get and set attributes in the request's session and maintain naviation state.
protected static boolean restorePreviousGroupState(HttpServletRequest request)
          Restores the previous groups navigation state.
protected static boolean restorePreviousState(HttpServletRequest request)
          Restores the previous navigation state.
protected static boolean restoreState(java.lang.String sessionId, int requestId, int groupId, int pageId, HttpServletRequest request)
          Restore the navigation state for the specified navigation ids.
protected static boolean restoreState(java.lang.String sessionId, java.lang.String requestId, java.lang.String groupId, java.lang.String pageId, HttpServletRequest request)
          Restore the navigation state for the specified navigation ids.
static boolean saveState(HttpServletRequest request)
          Saves the current state of navigation.
static void setGroupId(int id, HttpServletRequest request)
          Sets the group id.
static void setGroupId(java.lang.String id, HttpServletRequest request)
          Sets the group id.
static void setNavigationKey(java.lang.String key, INavigationObject object, HttpServletRequest request)
          Sets the navigation key on the given navigation object.
static void setNewGroup(HttpServletRequest request)
          Sets a flag in the request that a new group is starting.
static void setNewRequest(HttpServletRequest request)
          Sets a flag in the request that a new request is starting.
static void setNewSession(HttpServletRequest request)
          Sets a flag in the request that a new session is starting.
static void setPageId(int id, HttpServletRequest request)
          Sets the page id.
static void setPageId(java.lang.String id, HttpServletRequest request)
          Sets the request id.
static void setRequestId(int id, HttpServletRequest request)
          Sets the request id.
static void setRequestId(java.lang.String id, HttpServletRequest request)
          Sets the request id.
static void setSessionId(java.lang.String id, HttpServletRequest request)
          Sets the session id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

className

public static final java.lang.String className
Class name.

Constructor Detail

NavigationManager

public NavigationManager()
Method Detail

expireOldPages

public static void expireOldPages(HttpServletRequest request)
Expire any old pages.


getGroup

public static NavigationGroup getGroup(java.lang.String sessionId,
                                       java.lang.String requestId,
                                       java.lang.String groupId,
                                       HttpServletRequest request)
Gets this navigation group for the specified ids.


getGroupId

public static java.lang.String getGroupId(boolean create,
                                          HttpServletRequest request)
Get the current group id from the request.


getGroupIdAsInt

public static int getGroupIdAsInt(boolean create,
                                  HttpServletRequest request)
Get the current group id from the request.


getNavigationKeys

public static java.util.List getNavigationKeys(java.lang.String listKey,
                                               HttpServletRequest request)
Gets a list of keys for navigation objects stored in navigation that have the same navigation list key as the given key.


getNextGroupIdAsInt

public static int getNextGroupIdAsInt(HttpServletRequest request)
Gets the next group id.

Parameters:
request - the HttpServletRequest object that containing the client's request

getNextPageIdAsInt

public static int getNextPageIdAsInt(HttpServletRequest request)
Gets the next page id. If its a new session, request, or group the page id will be 0.

Parameters:
request - the HttpServletRequest object that containing the client's request

getNextRequestIdAsInt

public static int getNextRequestIdAsInt(HttpServletRequest request)
Gets the next group id.

Parameters:
request - the HttpServletRequest object that containing the client's request

getNextSessionId

public static java.lang.String getNextSessionId(HttpServletRequest request)
Gets the next group id.

Parameters:
request - the HttpServletRequest object that containing the client's request

getPage

public static NavigationPage getPage(java.lang.String sessionId,
                                     java.lang.String requestId,
                                     java.lang.String groupId,
                                     java.lang.String pageId,
                                     HttpServletRequest request)
Gets this navigation group for the specified ids.


getPageId

public static java.lang.String getPageId(boolean create,
                                         HttpServletRequest request)
Get the current page id from the request.


getPageIdAsInt

public static int getPageIdAsInt(boolean create,
                                 HttpServletRequest request)
Get the current page id from the request.


getPreviousGroupId

public static int getPreviousGroupId(HttpServletRequest request)
Get the group id from the previous request.


getPreviousPageId

public static int getPreviousPageId(HttpServletRequest request)
Get the page id from the previous request.


getPreviousRequestId

public static int getPreviousRequestId(HttpServletRequest request)
Get the request id from the previous request.


getRequest

public static NavigationRequest getRequest(java.lang.String sessionId,
                                           java.lang.String requestId,
                                           HttpServletRequest request)
Gets this navigation request for the specified ids.


getRequestId

public static java.lang.String getRequestId(boolean create,
                                            HttpServletRequest request)
Get the current request id from the request.


getRequestIdAsInt

public static int getRequestIdAsInt(boolean create,
                                    HttpServletRequest request)
Get the current request id from the request.


getSession

public static NavigationSession getSession(java.lang.String sessionId,
                                           HttpServletRequest request)
Gets this navigation session for the specified id.

Parameters:
request - the HttpServletRequest object that contains the request the client made of the servlet

getSessionId

public static java.lang.String getSessionId(boolean create,
                                            HttpServletRequest request)
Gets the session id for the given request to use for getting and setting session attributes.

Parameters:
create - whether or not the session id should be created if it doesn't exist
request - HttpServletRequest
Returns:
session id

initializeNavigationIds

public static void initializeNavigationIds(HttpServletRequest request,
                                           HttpServletResponse response)
Initializes the navigation state to the proper session, request, group, and page ids.


isNewGroupId

public static boolean isNewGroupId(HttpServletRequest request)
Test if a new group is desired.

Parameters:
request - the HttpServletRequest object that containing the client's request

isNewRequestId

public static boolean isNewRequestId(HttpServletRequest request)
Test if a new request is desired.

Parameters:
request - the HttpServletRequest object that containing the client's request

isNewSessionId

public static boolean isNewSessionId(HttpServletRequest request)
Test if a new session is desired.

Parameters:
request - the HttpServletRequest object that containing the client's request

isPageExpired

public static boolean isPageExpired(HttpServletRequest request)
Check if a page is expired. A page gets expired once it no longer falls into the last x navigation groups.


isValidState

protected static boolean isValidState(HttpServletRequest request)
Checks to see if the current navigation state is correct.


persistAttributes

protected static boolean persistAttributes(java.lang.String sessionId,
                                           java.lang.String requestId,
                                           java.lang.String groupId,
                                           java.lang.String pageId,
                                           HttpServletRequest request)
Restore the navigation state for the specified navigation ids.

Parameters:
sessionId - the id of the navigation session
requestId - the id of the navigation request
groupId - the id of the navigation group
pageId - the id of the navigation page
request - the HttpServletRequest object that contains the request the client made of the servlet
Returns:
true if the navigation state was restored successfully

persistPreviousAttributes

protected static boolean persistPreviousAttributes(HttpServletRequest request)
Restores the previous navigation state. This method should only be called if navigation state is valid.

Parameters:
request - the HttpServletRequest object that contains the request the client made of the servlet
Returns:
true if the navigation state was restored successfully

removeNavigationKey

public static void removeNavigationKey(INavigationObject object,
                                       HttpServletRequest request)
Removes the navigation key from the given navigation object.


resetGroupId

public static void resetGroupId(HttpServletRequest request)
Resets the group id for the given request used to get and set attributes in the request's session and maintain naviation state. Reseting the group id also resets the page id.

Parameters:
request - HttpServletRequest

resetPageId

public static void resetPageId(HttpServletRequest request)
Resets the page id for the given request used to get and set attributes in the request's session and maintain naviation state.

Parameters:
request - HttpServletRequest

resetRequestId

public static void resetRequestId(HttpServletRequest request)
Resets the request id for the given request used to get and set attributes in the request and maintain state navigation. Reseting the request id also resets the group and page ids.

Parameters:
request - HttpServletRequest

resetSessionId

public static void resetSessionId(HttpServletRequest request)
Reset the session id for the given request used to get and set attributes in the request's session and maintain naviation state. Reseting the session id also resets the request, group, and page ids.

Parameters:
request - HttpServletRequest

restorePreviousGroupState

protected static boolean restorePreviousGroupState(HttpServletRequest request)
Restores the previous groups navigation state. This restores the navigation state of the last navigation page in the previous group.

Parameters:
request - the HttpServletRequest object that contains the request the client made of the servlet
Returns:
true if the navigation state was restored successfully

restorePreviousState

protected static boolean restorePreviousState(HttpServletRequest request)
Restores the previous navigation state. This method should only be called if navigation state is valid.

Parameters:
request - the HttpServletRequest object that contains the request the client made of the servlet
Returns:
true if the navigation state was restored successfully

restoreState

protected static boolean restoreState(java.lang.String sessionId,
                                      int requestId,
                                      int groupId,
                                      int pageId,
                                      HttpServletRequest request)
Restore the navigation state for the specified navigation ids.

Parameters:
sessionId - the id of the navigation session
requestId - the id of the navigation request
groupId - the id of the navigation group
pageId - the id of the navigation page
request - the HttpServletRequest object that contains the request the client made of the servlet
Returns:
true if the navigation state was restored successfully

restoreState

protected static boolean restoreState(java.lang.String sessionId,
                                      java.lang.String requestId,
                                      java.lang.String groupId,
                                      java.lang.String pageId,
                                      HttpServletRequest request)
Restore the navigation state for the specified navigation ids.

Parameters:
sessionId - the id of the navigation session
requestId - the id of the navigation request
groupId - the id of the navigation group
pageId - the id of the navigation page
request - the HttpServletRequest object that contains the request the client made of the servlet
Returns:
true if the navigation state was restored successfully

saveState

public static boolean saveState(HttpServletRequest request)
Saves the current state of navigation.

Parameters:
request - the HttpServletRequest object that contains the request the client made of the servlet
Returns:
true if the navigation state was successfully saved

setGroupId

public static void setGroupId(int id,
                              HttpServletRequest request)
Sets the group id.


setGroupId

public static void setGroupId(java.lang.String id,
                              HttpServletRequest request)
Sets the group id.


setNavigationKey

public static void setNavigationKey(java.lang.String key,
                                    INavigationObject object,
                                    HttpServletRequest request)
Sets the navigation key on the given navigation object.


setNewGroup

public static void setNewGroup(HttpServletRequest request)
Sets a flag in the request that a new group is starting.

Parameters:
request - the HttpServletRequest object that containing the client's request

setNewRequest

public static void setNewRequest(HttpServletRequest request)
Sets a flag in the request that a new request is starting.

Parameters:
request - the HttpServletRequest object that containing the client's request

setNewSession

public static void setNewSession(HttpServletRequest request)
Sets a flag in the request that a new session is starting.

Parameters:
request - the HttpServletRequest object that containing the client's request

setPageId

public static void setPageId(int id,
                             HttpServletRequest request)
Sets the page id.


setPageId

public static void setPageId(java.lang.String id,
                             HttpServletRequest request)
Sets the request id.


setRequestId

public static void setRequestId(int id,
                                HttpServletRequest request)
Sets the request id.


setRequestId

public static void setRequestId(java.lang.String id,
                                HttpServletRequest request)
Sets the request id.


setSessionId

public static void setSessionId(java.lang.String id,
                                HttpServletRequest request)
Sets the session id.