com.jalios.jcms.context
Class JcmsContext

java.lang.Object
  extended by com.jalios.jcms.context.JcmsContext
All Implemented Interfaces:
JcmsConstants, JaliosConstants
Direct Known Subclasses:
JcmsJspContext, PagerHandler

public class JcmsContext
extends Object
implements JcmsConstants

This class keep track of all variables declared in doInitPage and give access to convenient methods when you are not in a jsp (servlet, tag, custom class etc) To use methods of this class, You MUST set a valid request and response (either with the contructor or with the setters). The current JcmsContext can be retreived either through the variable jcmsContext in a JSP or through the method Channel.getCurrentJcmsContext().

Since:
jcms-5.0.0
Version:
$Revision: 42480 $
Author:
Olivier Jaquemet

Field Summary
protected  Browser browser
           
protected  Caddy caddy
           
protected static Channel channel
           
protected  boolean inFO
           
protected  boolean initDone
           
protected  boolean initWorkspace
           
protected  boolean isAdmin
           
protected  boolean isAjaxRequest
           
protected  boolean isDBMember
           
protected  boolean isDebug
           
protected  boolean isLogged
           
protected  Member loggedMember
           
protected  javax.servlet.http.HttpServletRequest request
           
protected  javax.servlet.http.HttpServletResponse response
           
static String REVISION
           
protected  String userCountry
           
protected  String userLang
           
protected  Locale userLocale
           
protected  Workspace workspace
           
 
Fields inherited from interface com.jalios.jcms.JcmsConstants
ADATE_SEARCH, ADMIN_NOTES_PROP, ADVANCED_TAB, ARCHIVES_DIR, ASCII_WIDTH, CATEGORY_TAB, CDATE_SEARCH, COMMON_ALARM, CONTENT_TAB, COOKIE_MAX_AGE, CTRL_TOPIC_INTERNAL, CTRL_TOPIC_REF, CTRL_TOPIC_VALUE, CTRL_TOPIC_WRITE, CUSTOM_PROP, DOCCHOOSER_HEIGHT, DOCCHOOSER_WIDTH, DOCS_DIR, EDATE_SEARCH, EMAIL_REGEXP, ERROR_MSG, FORBIDDEN_FILE_ACCESS, FORBIDDEN_REDIRECT, FORCE_REDIRECT, ICON_ARCHIVE, ICON_LOCK, ICON_LOCK_STRONG, ICON_WARN, ICON_WH_BOOK_CLOSED, ICON_WH_BOOK_OPEN, INFORMATION_MSG, JALIOS_JUNIT_PROP, JCMS_CADDY, JCMS_MSG_LIST, JSYNC_DOWNLOAD_DIR, JSYNC_SYNC_ALARM, LOG_FILE, LOG_TOPIC_SECURITY, LOGGER_PROP, LOGGER_XMLPROP, MBR_PHOTO_DIR, MDATE_SEARCH, MONITOR_XML, OP_CREATE, OP_DEEP_COPY, OP_DEEP_DELETE, OP_DELETE, OP_MERGE, OP_UPDATE, PDATE_SEARCH, PHOTO_DIR, PHOTO_ICON, PHOTO_ICON_HEIGHT, PHOTO_ICON_WIDTH, PHOTO_LARGE, PHOTO_LARGE_HEIGHT, PHOTO_LARGE_WIDTH, PHOTO_NORMAL, PHOTO_NORMAL_HEIGHT, PHOTO_NORMAL_WIDTH, PHOTO_SMALL, PHOTO_SMALL_HEIGHT, PHOTO_SMALL_WIDTH, PHOTO_TINY, PHOTO_TINY_HEIGHT, PHOTO_TINY_WIDTH, PREVIOUS_TAB, PRINT_VIEW, PRIVATE_FILE_ACCESS, PUBLIC_FILE_ACCESS, READ_RIGHT_TAB, SDATE_SEARCH, SEARCHENGINE_ALARM, SESSION_AUTHORIZED_FILENAMES_SET, STATS_REPORT_DIR, STATUS_PROP, STORE_XML, TEMPLATE_TAB, THUMBNAIL_LARGE_HEIGHT, THUMBNAIL_LARGE_WIDTH, THUMBNAIL_SMALL_HEIGHT, THUMBNAIL_SMALL_WIDTH, UDATE_SEARCH, UPDATE_RIGHT_TAB, UPLOAD_DIR, URL_REGEXP, WARNING_MSG, WEBAPP_PROP, WFEXPRESS_ALARM, WFREMINDER_ALARM, WORKFLOW_TAB, WORKFLOW_XML
 
Fields inherited from interface com.jalios.util.JaliosConstants
CRLF, MILLIS_IN_ONE_DAY, MILLIS_IN_ONE_HOUR, MILLIS_IN_ONE_MINUTE, MILLIS_IN_ONE_MONTH, MILLIS_IN_ONE_SECOND, MILLIS_IN_ONE_WEEK, MILLIS_IN_ONE_YEAR
 
Constructor Summary
JcmsContext()
          If you use this constructor, request must be initialized at a later time (This constructor is kept to allow JcmsJspContext to be initialized as a bean, with pageContext parameter)
JcmsContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 
Method Summary
 void addCookie(javax.servlet.http.Cookie cookie)
          Adds the specified cookie to the response (or in a http-equiv is the response has already been commited, in this case, only for front office use).
static void addMsg(javax.servlet.http.HttpServletRequest request, JcmsMessage msg)
          Add JCMS info message for specified request (displayed through doMessageBox.jsp)
 void addMsg(JcmsMessage msg)
          Add JCMS info message for specified request (displayed through doMessageBox.jsp)
static void addMsgSession(javax.servlet.http.HttpServletRequest request, JcmsMessage msg)
          Add JCMS info message for specified session (displayed through doMessageBox.jsp)
 void addMsgSession(JcmsMessage msg)
          Add JCMS info message for current session (displayed through doMessageBox.jsp)
static List<JcmsMessage> applySelector(List<JcmsMessage> msgList, JcmsMessageSelector selector)
          Apply given JcmsMessageSelector by removing non selected JcmsMessage from the given List.
 void forceUpdate()
          Will force an update of all JcmsContext variables (retrieve it from the request).
 void forceWorkspaceUpdate()
          Force Workspace update on next getWorkspace()
 String getBaseUrl()
          Convenient method which returns ServletUtil.getBaseUrl(request);
 Browser getBrowser()
          Returns the Client Browser computed for this session identified from userAgent.
 Caddy getCaddy()
          Returns the caddy stored in current session.
 String getContextPath()
          Convenient method which returns ServletUtil.getContextPath(request)
static String getErrorMsg(javax.servlet.http.HttpServletRequest request)
          Returns the error message in the J2EE request.
static List<JcmsMessage> getErrorMsgList(javax.servlet.http.HttpServletRequest request)
          Returns the error message in the J2EE request.
static String getErrorMsgSession(javax.servlet.http.HttpServletRequest request)
          Returns the error message in the J2EE session.
static List<JcmsMessage> getErrorMsgSessionList(javax.servlet.http.HttpServletRequest request)
          Returns the error message in the J2EE session.
static String getInfoMsg(javax.servlet.http.HttpServletRequest request)
          Returns the information message in the J2EE request.
static List<JcmsMessage> getInfoMsgList(javax.servlet.http.HttpServletRequest request)
          Returns the information message in the J2EE request.
static String getInfoMsgSession(javax.servlet.http.HttpServletRequest request)
          Returns the information message in the J2EE session.
static List<JcmsMessage> getInfoMsgSessionList(javax.servlet.http.HttpServletRequest request)
          Returns the information message in the J2EE session.
 Member getLoggedMember()
          Retrieve the loggedMember variable for this context.
static List<JcmsMessage> getMsgList(javax.servlet.http.HttpServletRequest request)
          Returns the information message in the J2EE request.
static List<JcmsMessage> getMsgSessionList(javax.servlet.http.HttpServletRequest request)
          Returns the message list in the J2EE session.
 javax.servlet.http.HttpServletRequest getRequest()
           
 javax.servlet.http.HttpServletResponse getResponse()
           
 javax.servlet.http.HttpSession getSession()
          Shorter Method to get Session from request
 Object getUploadedFile(String field, boolean isFileDocument, boolean override)
          Performs upload for the given field to JCMS upload directory.
 List<DocUploadInfo> getUploadedFileList(String field, boolean isFileDocument, boolean override)
          Performs upload for the given field to JCMS upload directory.
 String getUrlWithCommonUpdatedParams(String[] names, String[] values, boolean encodeParams)
           
 String getUserCountry()
          Retrieves the user country variable for this context.
Fast: this method is cached using initDone (it is recomputed only on forceUpdate() or setRequest()).
 String getUserLang()
          Retrieves the user lang variable for this context.
Fast: this method is cached using initDone (it is recomputed only on forceUpdate() or setRequest()).
 Locale getUserLocale()
          Retrieve the userLocale variable for this context.
Fast: this method is cached using initDone (it is retrieved again only on forceUpdate() or setRequest()).
static String getWarningMsg(javax.servlet.http.HttpServletRequest request)
          Returns the warning message in the J2EE request.
static List<JcmsMessage> getWarningMsgList(javax.servlet.http.HttpServletRequest request)
          Returns the warning message in the J2EE request.
static String getWarningMsgSession(javax.servlet.http.HttpServletRequest request)
          Returns the warning message in the J2EE session.
static List<JcmsMessage> getWarningMsgSessionList(javax.servlet.http.HttpServletRequest request)
          Returns the warning message in the J2EE session.
 Workspace getWorkspace()
          Retrieve the current Workspace variable for this context either from request if inFO or from session if in back office.
 String glp(String key, Object... params)
          Resolve a language property in the user language of the current request.
 boolean isAdmin()
          Return the admin status of the current logged user.
 boolean isAjaxRequest()
          Check if the current request is an Ajax Request (performed through by prototypejs API).
 boolean isDBMember()
          Return the DB status of the current logged user.
 boolean isDebug()
          Return the debug state of the request depending on request parameter "debug"
 boolean isInFrontOffice()
          retrieve the inFO variable for this context.
 boolean isLogged()
          Return the user logging status for current request.
 boolean isWebdavAccess()
          Check if the current request is a Webdav Access
static void removeMessage(javax.servlet.http.HttpServletRequest request, JcmsMessage jcmsMessage)
          Remove specified messages from the session and request message list.
static void removeMessage(javax.servlet.http.HttpServletRequest request, List<JcmsMessage> messages)
          Remove specified messages from the session and request message list.
protected  DocUploadInfo retrieveUploadedFile(org.apache.commons.fileupload.FileItem item, boolean isFileDocument, boolean override)
          Performs upload of a given FileItem to JCMS upload directory.
static List<JcmsMessage> select(Collection<? extends JcmsMessage> dataColl, JcmsMessageSelector selector)
          Perform a selection on a Collection of JcmsMessage using the given JcmsMessageSelector
 void sendForbidden()
          Send a redirect to the forbidden page
static void sendForbidden(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Send a redirect to the forbidden page if parameter forbidden is set, then redirect to the given url without logging anything.
 void sendRedirect(Data data)
          Redirect to the given data (eg a publication, a category, ...) Will not redirect if data is null or if response has already been commited, but we put the request attribute "redirect" with the value of the url so that doDisplayBuffer can be able to redirect with the javascript hack.
 void sendRedirect(String url)
          Redirect current request to given URL.
static void sendRedirect(String url, boolean checkUrlSecurity, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Redirect current request to given URL.
static void sendRedirect(String url, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Redirect current request to given URL.
 void setErrorMsg(String msg)
          Set JCMS warning message for current request (displayed through doMessageBox.jsp)
static void setErrorMsg(String msg, javax.servlet.http.HttpServletRequest request)
          Set JCMS warning message for specified request (displayed through doMessageBox.jsp)
 void setErrorMsgSession(String msg)
          Set JCMS warning message for current session (displayed through doMessageBox.jsp)
static void setErrorMsgSession(String msg, javax.servlet.http.HttpServletRequest request)
          Set JCMS warning message for specified session (displayed through doMessageBox.jsp)
 void setInfoMsg(String msg)
          Set JCMS info message for current request (displayed through doMessageBox.jsp)
static void setInfoMsg(String msg, javax.servlet.http.HttpServletRequest request)
          Set JCMS info message for specified request (displayed through doMessageBox.jsp)
 void setInfoMsgSession(String msg)
          Set JCMS info message for current session (displayed through doMessageBox.jsp)
static void setInfoMsgSession(String msg, javax.servlet.http.HttpServletRequest request)
          Set JCMS info message for specified session (displayed through doMessageBox.jsp)
 void setLoggedMember(Member mbr)
          Set the logged member for this context.
 void setRequest(javax.servlet.http.HttpServletRequest request)
          Setter for the request.
 void setResponse(javax.servlet.http.HttpServletResponse response)
          Setter for the response.
 void setWarningMsg(String msg)
          Set JCMS warning message for current request (displayed through doMessageBox.jsp)
static void setWarningMsg(String msg, javax.servlet.http.HttpServletRequest request)
          Set JCMS warning message for specified request (displayed through doMessageBox.jsp)
 void setWarningMsgSession(String msg)
          Set JCMS warning message for current session (displayed through doMessageBox.jsp)
static void setWarningMsgSession(String msg, javax.servlet.http.HttpServletRequest request)
          Set JCMS warning message for specified session (displayed through doMessageBox.jsp)
 boolean validateRegexp(String regexp)
          Validate a pattern as a Perl regexp and set a convienient warning message in the request if not valid.
 boolean validateSchedule(String param)
          Validate a string as valid Schedule and set a convienient warning message in the request if not valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

channel

protected static final Channel channel

initDone

protected boolean initDone

initWorkspace

protected boolean initWorkspace

request

protected javax.servlet.http.HttpServletRequest request

response

protected javax.servlet.http.HttpServletResponse response

isLogged

protected boolean isLogged

isAdmin

protected boolean isAdmin

isDBMember

protected boolean isDBMember

isDebug

protected boolean isDebug

loggedMember

protected Member loggedMember

userLocale

protected Locale userLocale

userLang

protected String userLang

userCountry

protected String userCountry

workspace

protected Workspace workspace

browser

protected Browser browser

caddy

protected Caddy caddy

inFO

protected boolean inFO

isAjaxRequest

protected boolean isAjaxRequest
Constructor Detail

JcmsContext

public JcmsContext()
If you use this constructor, request must be initialized at a later time (This constructor is kept to allow JcmsJspContext to be initialized as a bean, with pageContext parameter)


JcmsContext

public JcmsContext(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
Method Detail

forceUpdate

public void forceUpdate()
Will force an update of all JcmsContext variables (retrieve it from the request). Update the protected variable initDone (to false at begining of method, and true on end).


setRequest

public void setRequest(javax.servlet.http.HttpServletRequest request)
Setter for the request. Will initialize all the variable of the JcmsContext if available in the request. (Therefore, it must be called after all the treatements done in doInitPage)

Parameters:
request - the HttpServletRequest from twhich to retrieve all jcms context information.

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Returns:
the request of this JcmsContext

setResponse

public void setResponse(javax.servlet.http.HttpServletResponse response)
Setter for the response.
Response is only needed for some methods of the context such as sendRedirect(String)

Parameters:
response - the HttpServletResponse to use when needed.

getResponse

public javax.servlet.http.HttpServletResponse getResponse()
Returns:
the response of this JcmsContext

getSession

public javax.servlet.http.HttpSession getSession()
Shorter Method to get Session from request

Returns:
HttpSession the Session

getUploadedFile

public Object getUploadedFile(String field,
                              boolean isFileDocument,
                              boolean override)
Performs upload for the given field to JCMS upload directory. Calling method must handle job around file like creating or updating associated FileDocument.

Parameters:
field - the submited field
isFileDocument - upload to a FileDocument path upload/docs/...
override - If file already exists, override or rename with current timemillis
Returns:
Object a List of uploaded files (DocUploadInfo) or a DocUploadInfo
Since:
jcms-5.7.0
See Also:
UploadManager.getUploadedFile(JcmsContext, String, boolean, boolean)

getUploadedFileList

public List<DocUploadInfo> getUploadedFileList(String field,
                                               boolean isFileDocument,
                                               boolean override)
Performs upload for the given field to JCMS upload directory. Calling method must handle job around file like creating or updating associated FileDocument.

Parameters:
field - the submited field
isFileDocument - upload to a FileDocument upload/docs/...
override - If file already exists, override or rename with current timemillis
Returns:
List a List of uploaded files
Since:
jcms-5.7.0
See Also:
UploadManager.getUploadedFileList(JcmsContext, String, boolean, boolean)

retrieveUploadedFile

protected DocUploadInfo retrieveUploadedFile(org.apache.commons.fileupload.FileItem item,
                                             boolean isFileDocument,
                                             boolean override)
Performs upload of a given FileItem to JCMS upload directory. Calling method must handle job around file like creating or updating associated FileDocument.

Parameters:
item - the FileItem handling uploaded file information
isFileDocument - upload to a FileDocument path upload/docs/...
override - If file already exists, override or rename with current timemillis
Returns:
DocUploadInfo the uploaded DocUploadInfo
Since:
jcms-5.7.0
See Also:
UploadManager.retrieveUploadedFile(FileItem, boolean, boolean)

isLogged

public boolean isLogged()
Return the user logging status for current request. Fast: this method is cached using initDone (it is recomputed only on forceUpdate() or setRequest()).

Returns:
true if a member is logged, false otherwise.

isWebdavAccess

public boolean isWebdavAccess()
Check if the current request is a Webdav Access

Returns:
boolean true if it is a Webdav Access
Since:
jcms-5.5.0

isDebug

public boolean isDebug()
Return the debug state of the request depending on request parameter "debug"

Returns:
true if request is in debug mode

isAdmin

public boolean isAdmin()
Return the admin status of the current logged user. Fast: this method is cached using initDone (it is recomputed only on forceUpdate() or setRequest()).

Returns:
true if the logged member is admin, false otherwise.

isDBMember

public boolean isDBMember()
Return the DB status of the current logged user. Fast: this method is cached using initDone (it is recomputed only on forceUpdate() or setRequest()).

Returns:
true if the logged member is an DBMember, false otherwise.

getLoggedMember

public Member getLoggedMember()
Retrieve the loggedMember variable for this context. Fast: this method is cached using initDone (it is recomputed only on forceUpdate() or setRequest()).

Returns:
the logged member (or null if nobody is logged)

setLoggedMember

public void setLoggedMember(Member mbr)
Set the logged member for this context.

This methods only changed the logged member for this context instance, this method is provided in case you want to force the logged member in bean/handlers.
It will NOT change the logged member of the current request, if you want to do that, see AuthenticationHandler.

Parameters:
mbr - the Member to set as the currently logged Member.
Since:
jcms-5.7.1

getUserLang

public String getUserLang()
Retrieves the user lang variable for this context.
Fast: this method is cached using initDone (it is recomputed only on forceUpdate() or setRequest()).

Returns:
the user lang (define in InitFilter, guessed either from logged member lang, userLang portlet action, http request Accept-Language header, or defaut channel language

getUserCountry

public String getUserCountry()
Retrieves the user country variable for this context.
Fast: this method is cached using initDone (it is recomputed only on forceUpdate() or setRequest()).

Returns:
the user country (define in InitFilter, guessed either from logged member country, http request Accept-Language header, or defaut channel language

getUserLocale

public Locale getUserLocale()
Retrieve the userLocale variable for this context.
Fast: this method is cached using initDone (it is retrieved again only on forceUpdate() or setRequest()).

Returns:
the Locale associated with the user language

isInFrontOffice

public boolean isInFrontOffice()
retrieve the inFO variable for this context. This parameter indicate if the jsp/servlet is in the FrontOffice or Not. Fast: this method is cached using initDone (it is retrieve again only on forceUpdate() or setRequest()).

Returns:
true if in FrontOffice otherwise false

forceWorkspaceUpdate

public void forceWorkspaceUpdate()
Force Workspace update on next getWorkspace()


getWorkspace

public Workspace getWorkspace()
Retrieve the current Workspace variable for this context either from request if inFO or from session if in back office. Fast: this method is cached using initDone (it is recomputed only on forceUpdate() or setRequest()).

Returns:
the Workspace associated with the current session or the default workspace in none was found in session

getBrowser

public Browser getBrowser()
Returns the Client Browser computed for this session identified from userAgent. Fast: this method is cached using initDone (it is retrieve again only on forceUpdate() or setRequest()).

Returns:
the Client Browser

getCaddy

public Caddy getCaddy()
Returns the caddy stored in current session. Fast: this method is cached using initDone (it is retrieve again only on forceUpdate() or setRequest()).

Returns:
the session caddy

isAjaxRequest

public boolean isAjaxRequest()
Check if the current request is an Ajax Request (performed through by prototypejs API). Fast: this method is cached using initDone (it is retrieve again only on forceUpdate() or setRequest()).

Returns:
true if request is an ajax request, false otherwise

sendRedirect

public void sendRedirect(Data data)
                  throws IOException
Redirect to the given data (eg a publication, a category, ...) Will not redirect if data is null or if response has already been commited, but we put the request attribute "redirect" with the value of the url so that doDisplayBuffer can be able to redirect with the javascript hack.

Parameters:
data - the data to redirect to.
Throws:
IOException - if an error occured while writing in response headers
Since:
jcms-5.7.1
See Also:
sendRedirect(String, HttpServletRequest, HttpServletResponse)

sendRedirect

public void sendRedirect(String url)
                  throws IOException
Redirect current request to given URL. Will not redirect if response has already been commited, but we put the request attribute "redirect" with the value of the url so that doDisplayBuffer can be able to redirect with the javascript hack.

Parameters:
url - the url to redirect to.
Throws:
IOException - if an error occured while writing in response headers
Since:
jcms-5.0.0
See Also:
sendRedirect(String, HttpServletRequest, HttpServletResponse)

sendForbidden

public void sendForbidden()
                   throws IOException
Send a redirect to the forbidden page

Throws:
IOException - if an error occured while writing in response headers
Since:
jcms-5.0.0
See Also:
sendForbidden(HttpServletRequest, HttpServletResponse)

sendRedirect

public static void sendRedirect(String url,
                                javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response)
                         throws IOException
Redirect current request to given URL.

The specified URL must match security configuration of HttpUtil.isValidHttpUrl(String) in order for the redirect to be performed. If the URL does not validate those requirement, the request is redirected to the webapp root.

As of current implementation,, the redirect will not happen using HTTP if the response has already been commited. Instead a request attribute "redirect" is set with the value of the url, it is later used by doDisplayBuffer to redirect the user with a javascript hack (applies only to front office).

Parameters:
url - the url to redirect to.
request - the current request from which the redirect is performed
response - the response in which to write redirect headers
Throws:
IOException - if an error occured while writing in response headers
Since:
jcms-5.5.0

sendRedirect

public static void sendRedirect(String url,
                                boolean checkUrlSecurity,
                                javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response)
                         throws IOException
Redirect current request to given URL.

If checkUrlSecurity param is set to true, the specified URL must match security configuration of HttpUtil.isValidHttpUrl(String) in order for the redirect to be performed. If the URL does not validate those requirement, the request is redirected to the webapp root.
It is highly recommended to always use method sendRedirect(String, HttpServletRequest, HttpServletResponse) which always enable this verification. Use this method and checkUrlSecurity=false only if you are absolutely sure of the specified URL security and can trust its value.

As of current implementation,, the redirect will not happen using HTTP if the response has already been commited. Instead a request attribute "redirect" is set with the value of the url, it is later used by doDisplayBuffer to redirect the user with a javascript hack (applies only to front office).

Parameters:
url - the url to redirect to.
checkUrlSecurity - if true, check the URL for validity to prevent phishing, unwanted external redirect and other forward attack. set to false to disable those verification (which is not recommended)
request - the current request from which the redirect is performed
response - the response in which to write redirect headers
Throws:
IOException - if an error occured while writing in response headers
Since:
jcms-7.1.0
See Also:
sendRedirect(String, HttpServletRequest, HttpServletResponse)

sendForbidden

public static void sendForbidden(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response)
                          throws IOException
Send a redirect to the forbidden page if parameter forbidden is set, then redirect to the given url without logging anything.

Parameters:
request - the current request from which the forbidden redirect is performed
response - the response in which to write forbidden redirect headers
Throws:
IOException - if an error occured while writing in response headers
Since:
jcms-5.5.0

addCookie

public void addCookie(javax.servlet.http.Cookie cookie)
Adds the specified cookie to the response (or in a http-equiv is the response has already been commited, in this case, only for front office use). This method can be called multiple times to set more than one cookie.

The cookie is not added to the response if it has already been commited, instead, we put the request attribute "cookieList" with a ArrayList containing all cookies to add so that doDisplayBuffer.jsp can use "http-equiv" able to add those cookies. doDisplayBuffer.jsp is automatically called by display.jsp.

Parameters:
cookie - the cookie to be added
Since:
jcms-5.0.0

getContextPath

public String getContextPath()
Convenient method which returns ServletUtil.getContextPath(request)

Returns:
the context path of the request (without trailing '/')
Since:
jcms-5.0.0
See Also:
ServletUtil.getContextPath(HttpServletRequest)

getBaseUrl

public String getBaseUrl()
Convenient method which returns ServletUtil.getBaseUrl(request);

Returns:
the base url of the request
Since:
jcms-5.0.0
See Also:
ServletUtil.getBaseUrl(HttpServletRequest)

getUrlWithCommonUpdatedParams

public String getUrlWithCommonUpdatedParams(String[] names,
                                            String[] values,
                                            boolean encodeParams)
Parameters:
names - an array of parameter names added or updated the url
values - an array of values added or updated the url corresponding to names
encodeParams - whether to do a encodeURL on given param (if false, don't forget to do the encodeURL yourself on the parameters which need it! it is provided as a performance boost because encodeURL can be slow)
Returns:
Returns a relative URL with the given parameters added or updated plus common parameters: portal, id, portlet, jsp, cid if they are in the current request parameters
See Also:
PortalManager.getUrlWithCommonUpdatedParams(HttpServletRequest, String[], String[], boolean)

setInfoMsg

public void setInfoMsg(String msg)
Set JCMS info message for current request (displayed through doMessageBox.jsp)

Parameters:
msg - the message to display

setInfoMsgSession

public void setInfoMsgSession(String msg)
Set JCMS info message for current session (displayed through doMessageBox.jsp)

Parameters:
msg - the message to display

setWarningMsg

public void setWarningMsg(String msg)
Set JCMS warning message for current request (displayed through doMessageBox.jsp)

Parameters:
msg - the message to display

setWarningMsgSession

public void setWarningMsgSession(String msg)
Set JCMS warning message for current session (displayed through doMessageBox.jsp)

Parameters:
msg - the message to display

setErrorMsg

public void setErrorMsg(String msg)
Set JCMS warning message for current request (displayed through doMessageBox.jsp)

Parameters:
msg - the message to display

setErrorMsgSession

public void setErrorMsgSession(String msg)
Set JCMS warning message for current session (displayed through doMessageBox.jsp)

Parameters:
msg - the message to display

setInfoMsg

public static void setInfoMsg(String msg,
                              javax.servlet.http.HttpServletRequest request)
Set JCMS info message for specified request (displayed through doMessageBox.jsp)

Parameters:
msg - the message to display
request - the current request from which the message is being set

setInfoMsgSession

public static void setInfoMsgSession(String msg,
                                     javax.servlet.http.HttpServletRequest request)
Set JCMS info message for specified session (displayed through doMessageBox.jsp)

Parameters:
msg - the message to display
request - the current request from which the message is being set

setWarningMsg

public static void setWarningMsg(String msg,
                                 javax.servlet.http.HttpServletRequest request)
Set JCMS warning message for specified request (displayed through doMessageBox.jsp)

Parameters:
msg - the message to display
request - the current request from which the message is being set

setWarningMsgSession

public static void setWarningMsgSession(String msg,
                                        javax.servlet.http.HttpServletRequest request)
Set JCMS warning message for specified session (displayed through doMessageBox.jsp)

Parameters:
msg - the message to display
request - the current request from which the message is being set

setErrorMsg

public static void setErrorMsg(String msg,
                               javax.servlet.http.HttpServletRequest request)
Set JCMS warning message for specified request (displayed through doMessageBox.jsp)

Parameters:
msg - the message to display
request - the current request from which the message is being set

setErrorMsgSession

public static void setErrorMsgSession(String msg,
                                      javax.servlet.http.HttpServletRequest request)
Set JCMS warning message for specified session (displayed through doMessageBox.jsp)

Parameters:
msg - the message to display
request - the current request from which the message is being set

getInfoMsg

public static String getInfoMsg(javax.servlet.http.HttpServletRequest request)
Returns the information message in the J2EE request.

Parameters:
request - the request to check for
Returns:
the information message if any or null if none was set.
Since:
jcms-6.1.1

getInfoMsgSession

public static String getInfoMsgSession(javax.servlet.http.HttpServletRequest request)
Returns the information message in the J2EE session.

Parameters:
request - the request to check for
Returns:
the information message if any or null if none was set.
Since:
jcms-6.1.1

getWarningMsg

public static String getWarningMsg(javax.servlet.http.HttpServletRequest request)
Returns the warning message in the J2EE request.

Parameters:
request - the request to check for
Returns:
the warning message if any or null if none was set.
Since:
jcms-6.1.1

getWarningMsgSession

public static String getWarningMsgSession(javax.servlet.http.HttpServletRequest request)
Returns the warning message in the J2EE session.

Parameters:
request - the request to check for
Returns:
the warning message if any or null if none was set.
Since:
jcms-6.1.1

getErrorMsg

public static String getErrorMsg(javax.servlet.http.HttpServletRequest request)
Returns the error message in the J2EE request.

Parameters:
request - the request to check for
Returns:
the error message if any or null if none was set.
Since:
jcms-6.1.1

getErrorMsgSession

public static String getErrorMsgSession(javax.servlet.http.HttpServletRequest request)
Returns the error message in the J2EE session.

Parameters:
request - the request to check for
Returns:
the error message if any or null if none was set.
Since:
jcms-6.1.1

removeMessage

public static void removeMessage(javax.servlet.http.HttpServletRequest request,
                                 List<JcmsMessage> messages)
Remove specified messages from the session and request message list.

Parameters:
request - the current request must not be null
messages - a list of JcmsMessage to remove

removeMessage

public static void removeMessage(javax.servlet.http.HttpServletRequest request,
                                 JcmsMessage jcmsMessage)
Remove specified messages from the session and request message list.

Parameters:
request - the current request must not be null
jcmsMessage - the message to remove

addMsg

public void addMsg(JcmsMessage msg)
Add JCMS info message for specified request (displayed through doMessageBox.jsp)

Parameters:
msg - the message to display
Since:
jcms-7.0.0

addMsgSession

public void addMsgSession(JcmsMessage msg)
Add JCMS info message for current session (displayed through doMessageBox.jsp)

Parameters:
msg - the message to display
Since:
jcms-7.1.0

addMsg

public static void addMsg(javax.servlet.http.HttpServletRequest request,
                          JcmsMessage msg)
Add JCMS info message for specified request (displayed through doMessageBox.jsp)

Parameters:
msg - the message to display
request - the current request from which the message is being added
Since:
jcms-7.0.0

addMsgSession

public static void addMsgSession(javax.servlet.http.HttpServletRequest request,
                                 JcmsMessage msg)
Add JCMS info message for specified session (displayed through doMessageBox.jsp)

Parameters:
msg - the message to display
request - the current request from which the message is being added
Since:
jcms-7.0.0

getMsgList

public static List<JcmsMessage> getMsgList(javax.servlet.http.HttpServletRequest request)
Returns the information message in the J2EE request.

Parameters:
request - the request to check for
Returns:
the information message set if any or null if none was added.
Since:
jcms-7.0.0

getMsgSessionList

public static List<JcmsMessage> getMsgSessionList(javax.servlet.http.HttpServletRequest request)
Returns the message list in the J2EE session.

Parameters:
request - the request to check for
Returns:
the information message set if any or null if none was added.
Since:
jcms-7.0.0

getInfoMsgList

public static List<JcmsMessage> getInfoMsgList(javax.servlet.http.HttpServletRequest request)
Returns the information message in the J2EE request.

Parameters:
request - the request to check for
Returns:
the information message set if any or null if none was added.
Since:
jcms-7.0.0

getInfoMsgSessionList

public static List<JcmsMessage> getInfoMsgSessionList(javax.servlet.http.HttpServletRequest request)
Returns the information message in the J2EE session.

Parameters:
request - the request to check for
Returns:
the information message set if any or null if none was added.
Since:
jcms-7.0.0

getWarningMsgList

public static List<JcmsMessage> getWarningMsgList(javax.servlet.http.HttpServletRequest request)
Returns the warning message in the J2EE request.

Parameters:
request - the request to check for
Returns:
the warning message List if any or null if none was added.
Since:
jcms-7.0.0

getWarningMsgSessionList

public static List<JcmsMessage> getWarningMsgSessionList(javax.servlet.http.HttpServletRequest request)
Returns the warning message in the J2EE session.

Parameters:
request - the request to check for
Returns:
the warning message List if any or null if none was added.
Since:
jcms-7.0.0

getErrorMsgList

public static List<JcmsMessage> getErrorMsgList(javax.servlet.http.HttpServletRequest request)
Returns the error message in the J2EE request.

Parameters:
request - the request to check for
Returns:
the error message List if any or null if none was added.
Since:
jcms-7.0.0

getErrorMsgSessionList

public static List<JcmsMessage> getErrorMsgSessionList(javax.servlet.http.HttpServletRequest request)
Returns the error message in the J2EE session.

Parameters:
request - the request to check for
Returns:
the error message List if any or null if none was added.
Since:
jcms-7.0.0

glp

public String glp(String key,
                  Object... params)
Resolve a language property in the user language of the current request.

Parameters:
key - the language property to resolve, for example "ui.com.lbl.contents"
params - an array of parameters to use when resolving the format of the given property
Returns:
the resolved property
Since:
jcms-5.0.0

validateSchedule

public boolean validateSchedule(String param)
Validate a string as valid Schedule and set a convienient warning message in the request if not valid.

Parameters:
param - The parameter to validate
Returns:
true if the parameter is a valid Schedule string
Since:
jcms-6.0

validateRegexp

public boolean validateRegexp(String regexp)
Validate a pattern as a Perl regexp and set a convienient warning message in the request if not valid.

Parameters:
regexp - The pattern to validate
Returns:
true if the pattern is a valid Perl 5 regexp.
Since:
jcms-6.0

select

public static List<JcmsMessage> select(Collection<? extends JcmsMessage> dataColl,
                                       JcmsMessageSelector selector)
Perform a selection on a Collection of JcmsMessage using the given JcmsMessageSelector

Parameters:
dataColl - the Collection of Data to select.
selector - the DataSelector to use.
Returns:
a NEW or CLONED List of JcmsMessage.
Since:
jcms-7.0.0

applySelector

public static List<JcmsMessage> applySelector(List<JcmsMessage> msgList,
                                              JcmsMessageSelector selector)
Apply given JcmsMessageSelector by removing non selected JcmsMessage from the given List.
This method DOES NOT create any new List, modify the existing one.

Parameters:
msgList - a List of JcmsMessage from which to remove non selected data.
selector - the JcmsMessageSelector to apply
Returns:
the SAME List that was given but modified.
Since:
jcms-7.0.0


Copyright © 2001-2010 Jalios SA. All Rights Reserved.