Class JcmsContext
- java.lang.Object
-
- com.jalios.jcms.context.JcmsContext
-
- All Implemented Interfaces:
JcmsConstants,JaliosConstants
- Direct Known Subclasses:
JcmsJspContext,PagerHandler
public class JcmsContext extends java.lang.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 retrieved either through the variable jcmsContext in a JSP or through the methodChannel.getCurrentJcmsContext().- Since:
- jcms-5.0.0
- Version:
- $Revision: 135354 $
- Author:
- Olivier Jaquemet
-
-
Field Summary
Fields Modifier and Type Field Description protected Browserbrowserprotected Caddycaddyprotected static Channelchannelprotected booleaninFOprotected booleaninitDoneprotected booleaninitWorkspaceprotected booleanisAdminprotected booleanisAjaxRequestprotected booleanisDBMemberprotected booleanisDebugprotected booleanisDebugTemplatePathprotected booleanisLoggedprotected MemberloggedMemberprotected javax.servlet.http.HttpServletRequestrequestprotected javax.servlet.http.HttpServletResponseresponsestatic java.lang.StringREVISIONprotected java.lang.StringuserCountryprotected java.lang.StringuserLangprotected java.util.LocaleuserLocaleprotected java.time.ZoneIduserZoneIdprotected Workspaceworkspace-
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
-
Fields inherited from interface com.jalios.jcms.JcmsConstants
ADATE_SEARCH, ADMIN_NOTES_PROP, ADVANCED_TAB, AJAX_MODE_ATTR, ARCHIVES_DIR, ASCII_WIDTH, CATEGORY_TAB, CDATE_SEARCH, CLASS_PROPERTY, COMMON_ALARM, CONTENT_TAB, COOKIE_MAX_AGE, COUNTRY_SPRITE, CS_TYPOLOGY_ROOT_CAT_VID, CTRL_TOPIC_INTERNAL, CTRL_TOPIC_REF, CTRL_TOPIC_VALUE, CTRL_TOPIC_WRITE, CUSTOM_PROP, DEFAULT_PHOTO_PROP, DOCCHOOSER_HEIGHT, DOCCHOOSER_WIDTH, DOCS_DIR, EDATE_SEARCH, EMAIL_REGEXP, ERROR_MSG, FORBIDDEN_FILE_ACCESS, FORBIDDEN_REDIRECT, FORCE_REDIRECT, GLYPH_ICON_PREFIX, ICON_ARCHIVE, ICON_ICON_PREFIX, ICON_LOCK, ICON_LOCK_STRONG, ICON_PREFIX_PROP, ICON_WARN, ICON_WH_BOOK_CLOSED, ICON_WH_BOOK_OPEN, INFORMATION_MSG, IS_IN_FRONT_OFFICE, JALIOS_JUNIT_PROP, JCMS_CADDY, JCMS_MSG_LIST, JCMS_TOASTR_COLLECTION, JSYNC_DOWNLOAD_DIR, JSYNC_SYNC_ALARM, LANG_SPRITE, LOG_FILE, LOG_TOPIC_SECURITY, LOGGER_PROP, LOGGER_XMLPROP, MBR_PHOTO_DIR, MDATE_SEARCH, MONITOR_XML, OP_CREATE, OP_CREATE_STR, OP_DEEP_COPY, OP_DEEP_COPY_STR, OP_DEEP_DELETE, OP_DEEP_DELETE_STR, OP_DELETE, OP_DELETE_STR, OP_MERGE, OP_MERGE_STR, OP_UPDATE, OP_UPDATE_STR, ORGANIZATION_ROOT_GROUP_PROP, PDATE_SEARCH, PHOTO_DIR, PHOTO_ICON, PHOTO_ICON_HEIGHT, PHOTO_ICON_PROP_PREFIX, PHOTO_ICON_WIDTH, PHOTO_LARGE, PHOTO_LARGE_HEIGHT, PHOTO_LARGE_PROP_PREFIX, PHOTO_LARGE_WIDTH, PHOTO_NORMAL, PHOTO_NORMAL_HEIGHT, PHOTO_NORMAL_PROP_PREFIX, PHOTO_NORMAL_WIDTH, PHOTO_SMALL, PHOTO_SMALL_HEIGHT, PHOTO_SMALL_PROP_PREFIX, PHOTO_SMALL_WIDTH, PHOTO_TINY, PHOTO_TINY_HEIGHT, PHOTO_TINY_PROP_PREFIX, PHOTO_TINY_WIDTH, PREVIOUS_TAB, PRINT_VIEW, PRIVATE_FILE_ACCESS, PUBLIC_FILE_ACCESS, RAW_CONTENT_ICON_PREFIX, READ_RIGHT_TAB, SDATE_SEARCH, SEARCHENGINE_ALARM, SECURITY_LOG_FILE, SESSION_AUTHORIZED_FILENAMES_SET, SPRITE_ICON_PREFIX, STATS_REPORT_DIR, STATUS_PROP, STORE_XML, SUCCESS_MSG, SVG_ICON_PREFIX, SVGINLINE_ICON_PREFIX, TEMPLATE_TAB, THUMBNAIL_LARGE_HEIGHT, THUMBNAIL_LARGE_WIDTH, THUMBNAIL_SMALL_HEIGHT, THUMBNAIL_SMALL_WIDTH, TTCARD_MEDIA_HEIGHT, TTCARD_MEDIA_WIDTH, TYPES_ICON_ALT_PROP, TYPES_ICON_SUFFIX_PROP, TYPES_ICON_TITLE_PROP, TYPES_PREFIX_PROP, TYPES_THUMB_SUFFIX_PROP, UDATE_SEARCH, UPDATE_RIGHT_TAB, UPLOAD_DIR, UPLOAD_PERMISSION_COUNT_PROP_PREFIX, UPLOAD_PERMISSION_SIZE_PROP_PREFIX, URL_REGEXP, VID_LOGGED_MEMBER, WARNING_MSG, WEBAPP_PROP, WFEXPRESS_ALARM, WFREMINDER_ALARM, WORKFLOW_TAB, WORKFLOW_XML
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddCookie(javax.servlet.http.Cookie cookie)Deprecated.since JCMS-7729, useHttpUtil.addCookie(HttpServletResponse, Cookie)voidaddMsg(JcmsMessage msg)Add JCMS info message for specified request (displayed through doMessageBox.jsp)static voidaddMsg(javax.servlet.http.HttpServletRequest request, JcmsMessage msg)Add JCMS info message for specified request (displayed through doMessageBox.jsp)voidaddMsgSession(JcmsMessage msg)Add JCMS info message for current session (displayed through doMessageBox.jsp)static voidaddMsgSession(javax.servlet.http.HttpServletRequest request, JcmsMessage msg)Add JCMS info message for specified session (displayed through doMessageBox.jsp)voidaddToastr(JcmsToastr toastr)Add JCMS toastr for specified request (displayed through doToastr.jspf)static voidaddToastr(javax.servlet.http.HttpServletRequest request, JcmsToastr toastr)Add JCMS toastr for specified request (displayed through doToastr.jspf)voidaddToastrSession(JcmsToastr toastr)Add JCMS toastr for current session (displayed through doToastr.jspf)static voidaddToastrSession(javax.servlet.http.HttpServletRequest request, JcmsToastr toastr)Add JCMS toastr for specified session (displayed through doToastr.jspf)static java.util.List<JcmsMessage>applySelector(java.util.List<JcmsMessage> msgList, JcmsMessageSelector selector)Apply givenJcmsMessageSelectorby removing non selectedJcmsMessagefrom the givenList.voidforceUpdate()Will force an update of all JcmsContext variables (retrieve it from the request).voidforceWorkspaceUpdate()Force Workspace update on next getWorkspace()java.lang.StringgetBaseUrl()Convenient method which returns ServletUtil.getBaseUrl(request);BrowsergetBrowser()Returns the Client Browser computed for this session identified from userAgent.CaddygetCaddy()Returns the caddy stored in current session.java.lang.StringgetContextPath()Convenient method which returns ServletUtil.getContextPath(request)static java.lang.StringgetErrorMsg(javax.servlet.http.HttpServletRequest request)Returns the error message in the J2EE request.static java.util.List<JcmsMessage>getErrorMsgList(javax.servlet.http.HttpServletRequest request)Returns the error message in the J2EE request.static java.lang.StringgetErrorMsgSession(javax.servlet.http.HttpServletRequest request)Returns the error message in the J2EE session.static java.util.List<JcmsMessage>getErrorMsgSessionList(javax.servlet.http.HttpServletRequest request)Returns the error message in the J2EE session.static java.lang.StringgetInfoMsg(javax.servlet.http.HttpServletRequest request)Returns the information message in the J2EE request.static java.util.List<JcmsMessage>getInfoMsgList(javax.servlet.http.HttpServletRequest request)Returns the success message in the J2EE request.static java.lang.StringgetInfoMsgSession(javax.servlet.http.HttpServletRequest request)Returns the information message in the J2EE session.static java.util.List<JcmsMessage>getInfoMsgSessionList(javax.servlet.http.HttpServletRequest request)Returns the information message in the J2EE session.MembergetLoggedMember()Retrieve the loggedMember variable for this context.static java.util.List<JcmsMessage>getMsgList(javax.servlet.http.HttpServletRequest request)Returns the information message in the J2EE request.static java.util.List<JcmsMessage>getMsgSessionList(javax.servlet.http.HttpServletRequest request)Returns the message list in the J2EE session.javax.servlet.http.HttpServletRequestgetRequest()javax.servlet.http.HttpServletResponsegetResponse()javax.servlet.http.HttpSessiongetSession()Shorter Method to get Session from requeststatic java.lang.StringgetSuccessMsg(javax.servlet.http.HttpServletRequest request)Returns the success message in the J2EE request.static java.util.List<JcmsMessage>getSuccessMsgList(javax.servlet.http.HttpServletRequest request)Returns the information message in the J2EE request.static java.lang.StringgetSuccessMsgSession(javax.servlet.http.HttpServletRequest request)Returns the success message in the J2EE session.static java.util.List<JcmsMessage>getSuccessMsgSessionList(javax.servlet.http.HttpServletRequest request)Returns the success message in the J2EE session.static java.util.Set<JcmsToastr>getToastrCollection(javax.servlet.http.HttpServletRequest request)Returns the toastr collection in the J2EE request.static java.util.Set<JcmsToastr>getToastrSessionCollection(javax.servlet.http.HttpServletRequest request)Returns the toastr collection in the J2EE session.java.lang.ObjectgetUploadedFile(java.lang.String field, boolean isFileDocument, boolean override)Deprecated.java.util.List<DocUploadInfo>getUploadedFileList(java.lang.String field, boolean isFileDocument, boolean override)Deprecated.java.util.List<DocUploadInfo>getUploadedFiles(java.lang.String field)Performs upload for the given field.java.util.List<DocUploadInfo>getUploadedFiles(java.lang.String field, FileUploadOptions options)Performs upload for the given field.java.lang.StringgetUrlWithCommonUpdatedParams(java.lang.String[] names, java.lang.String[] values, boolean encodeParams)java.lang.StringgetUserCountry()Retrieves the user country variable for this context.
Fast: this method is cached using initDone (it is recomputed only on forceUpdate() or setRequest()).java.lang.StringgetUserLang()Retrieves the user lang variable for this context.
Fast: this method is cached using initDone (it is recomputed only on forceUpdate() or setRequest()).java.util.LocalegetUserLocale()Retrieve the userLocale variable for this context.
Fast: this method is cached using initDone (it is retrieved again only on forceUpdate() or setRequest()).java.time.ZoneIdgetUserZoneId()Retrieve the userZoneId variable for this context.
Fast: this method is cached using initDone (it is retrieved again only on forceUpdate() or setRequest()).static java.lang.StringgetWarningMsg(javax.servlet.http.HttpServletRequest request)Returns the warning message in the J2EE request.static java.util.List<JcmsMessage>getWarningMsgList(javax.servlet.http.HttpServletRequest request)Returns the warning message in the J2EE request.static java.lang.StringgetWarningMsgSession(javax.servlet.http.HttpServletRequest request)Returns the warning message in the J2EE session.static java.util.List<JcmsMessage>getWarningMsgSessionList(javax.servlet.http.HttpServletRequest request)Returns the warning message in the J2EE session.WorkspacegetWorkspace()Retrieve the current Workspace variable for this context either from request if inFO or from session if in back office.java.lang.Stringglp(java.lang.String key, java.lang.Object... params)Resolve a language property in the user language of the current request.booleanisAdmin()Return the admin status of the current logged user.booleanisAdminZone()booleanisAjaxRequest()Check if the current request is an Ajax Request (performed through by prototypejs API).booleanisDBMember()Return the DB status of the current logged user.booleanisDebug()Return the debug state of the request depending on request parameter "debug"booleanisDebugTemplate()Return the debug template state of the request depending on request parameter "_debugTemplate"booleanisInFrontOffice()retrieve the inFO variable for this context.booleanisLogged()Return the user logging status for current request.booleanisWebdavAccess()Check if the current request is a Webdav AccessbooleanisWorkZone()static voidremoveMessage(javax.servlet.http.HttpServletRequest request, JcmsMessage jcmsMessage)Remove specified messages from the session and request message list.static voidremoveMessage(javax.servlet.http.HttpServletRequest request, java.util.List<JcmsMessage> messages)Remove specified messages from the session and request message list.protected DocUploadInforetrieveUploadedFile(org.apache.commons.fileupload.FileItem item, boolean isFileDocument, boolean override)Deprecated.static java.util.List<JcmsMessage>select(java.util.Collection<? extends JcmsMessage> dataColl, JcmsMessageSelector selector)Perform a selection on aCollectionofJcmsMessageusing the givenJcmsMessageSelectorvoidsendError(int statusCode)Sends an error response to the client using the specified status code and clears the buffer.
This is equivalent to callingsendError(int, String)with the same status code andnullfor the message.voidsendError(int statusCode, java.lang.String message)Sends an error response to the client using the specified status code and clears the output buffer.
The server defaults to creating the response to look like an HTML-formatted server error page containing the specified message, setting the content type to "text/html", leaving cookies and other headers unmodified.voidsendForbidden()Send a redirect to the forbidden pagestatic voidsendForbidden(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.voidsendRedirect(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.voidsendRedirect(java.lang.String url)Redirect current request to given URL.static voidsendRedirect(java.lang.String url, boolean checkUrlSecurity, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Redirect current request to given URL.static voidsendRedirect(java.lang.String url, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Redirect current request to given URL.voidsetErrorMsg(java.lang.String msg)Set JCMS warning message for current request (displayed through doMessageBox.jsp)static voidsetErrorMsg(java.lang.String msg, javax.servlet.http.HttpServletRequest request)Set JCMS warning message for specified request (displayed through doMessageBox.jsp)voidsetErrorMsgSession(java.lang.String msg)Set JCMS warning message for current session (displayed through doMessageBox.jsp)static voidsetErrorMsgSession(java.lang.String msg, javax.servlet.http.HttpServletRequest request)Set JCMS warning message for specified session (displayed through doMessageBox.jsp)voidsetInfoMsg(java.lang.String msg)Set JCMS info message for current request (displayed through doMessageBox.jsp)static voidsetInfoMsg(java.lang.String msg, javax.servlet.http.HttpServletRequest request)Set JCMS info message for specified request (displayed through doMessageBox.jsp)voidsetInfoMsgSession(java.lang.String msg)Set JCMS info message for current session (displayed through doMessageBox.jsp)static voidsetInfoMsgSession(java.lang.String msg, javax.servlet.http.HttpServletRequest request)Set JCMS info message for specified session (displayed through doMessageBox.jsp)voidsetLoggedMember(Member mbr)Set the logged member for this context.voidsetRequest(javax.servlet.http.HttpServletRequest request)Setter for the request.voidsetResponse(javax.servlet.http.HttpServletResponse response)Setter for the response.voidsetSuccessMsg(java.lang.String msg)Set JCMS success message for current request (displayed through doMessageBox.jsp)static voidsetSuccessMsg(java.lang.String msg, javax.servlet.http.HttpServletRequest request)Set JCMS success message for specified request (displayed through doMessageBox.jsp)voidsetSuccessMsgSession(java.lang.String msg)Set JCMS success message for current session (displayed through doMessageBox.jsp)static voidsetSuccessMsgSession(java.lang.String msg, javax.servlet.http.HttpServletRequest request)Set JCMS success message for specified session (displayed through doMessageBox.jsp)voidsetWarningMsg(java.lang.String msg)Set JCMS warning message for current request (displayed through doMessageBox.jsp)static voidsetWarningMsg(java.lang.String msg, javax.servlet.http.HttpServletRequest request)Set JCMS warning message for specified request (displayed through doMessageBox.jsp)voidsetWarningMsgSession(java.lang.String msg)Set JCMS warning message for current session (displayed through doMessageBox.jsp)static voidsetWarningMsgSession(java.lang.String msg, javax.servlet.http.HttpServletRequest request)Set JCMS warning message for specified session (displayed through doMessageBox.jsp)voidupdateWorkspace(Workspace workspace)Set the given workspace to the request and refreshes the context by forcing an update.booleanvalidateRegexp(java.lang.String regexp)Validate a pattern as a Perl regexp and set a convienient warning message in the request if not valid.booleanvalidateSchedule(java.lang.String param)Validate a string as validScheduleand set a convienient warning message in the request if not valid.
-
-
-
Field Detail
-
REVISION
public static final java.lang.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
-
isDebugTemplatePath
protected boolean isDebugTemplatePath
-
loggedMember
protected Member loggedMember
-
userLocale
protected java.util.Locale userLocale
-
userZoneId
protected java.time.ZoneId userZoneId
-
userLang
protected java.lang.String userLang
-
userCountry
protected java.lang.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 assendRedirect(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
-
getUploadedFiles
public java.util.List<DocUploadInfo> getUploadedFiles(java.lang.String field)
Performs upload for the given field.- Parameters:
field- the submited field- Returns:
- a List of uploaded files DocUploadInfo, never return null
- Since:
- jcms-10.0.6 / JCMS-8317
- See Also:
getUploadedFiles(String, FileUploadOptions)
-
getUploadedFiles
public java.util.List<DocUploadInfo> getUploadedFiles(java.lang.String field, FileUploadOptions options)
Performs upload for the given field.- Parameters:
field- the submited fieldoptions- upload options- Returns:
- a List of uploaded files DocUploadInfo, never return null
- Since:
- jcms-10.0.6 / JCMS-8317
- See Also:
UploadManager.getUploadedFiles(JcmsContext, String, FileUploadOptions)
-
getUploadedFile
@Deprecated public java.lang.Object getUploadedFile(java.lang.String field, boolean isFileDocument, boolean override)Deprecated.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 fieldisFileDocument- upload to a FileDocument path upload/docs/...override- IGNORED- 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
@Deprecated public java.util.List<DocUploadInfo> getUploadedFileList(java.lang.String field, boolean isFileDocument, boolean override)
Deprecated.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 fieldisFileDocument- upload to a FileDocument upload/docs/...override- IGNORED- Returns:
- List a List of uploaded files
- Since:
- jcms-5.7.0
- See Also:
UploadManager.getUploadedFileList(JcmsContext, String, boolean, boolean)
-
retrieveUploadedFile
@Deprecated protected DocUploadInfo retrieveUploadedFile(org.apache.commons.fileupload.FileItem item, boolean isFileDocument, boolean override)
Deprecated.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 informationisFileDocument- upload to a FileDocument path upload/docs/...override- IGNORED- 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
-
isDebugTemplate
public boolean isDebugTemplate()
Return the debug template state of the request depending on request parameter "_debugTemplate"- Returns:
- true if request is in debug template mode
- Since:
- jcms-10.0.5
-
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, seeAuthenticationHandler.- Parameters:
mbr- the Member to set as the currently logged Member.- Since:
- jcms-5.7.1
-
getUserLang
public java.lang.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 java.lang.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 java.util.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
-
getUserZoneId
public java.time.ZoneId getUserZoneId()
Retrieve the userZoneId variable for this context.
Fast: this method is cached using initDone (it is retrieved again only on forceUpdate() or setRequest()).- Returns:
- the ZoneId associated with the current user timezone
-
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
-
isAdminZone
public boolean isAdminZone()
- Returns:
- true if "zone" request attribute is equal to "AdminArea".
- Since:
- jcms-10.0.5
-
isWorkZone
public boolean isWorkZone()
- Returns:
- true if "zone" request attribute is equal to "WorkArea".
- Since:
- jcms-10.0.5
-
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 java.io.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:
java.io.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(java.lang.String url) throws java.io.IOExceptionRedirect 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:
java.io.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 java.io.IOExceptionSend a redirect to the forbidden page- Throws:
java.io.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(java.lang.String url, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOExceptionRedirect 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 performedresponse- the response in which to write redirect headers- Throws:
java.io.IOException- if an error occured while writing in response headers- Since:
- jcms-5.5.0
-
sendRedirect
public static void sendRedirect(java.lang.String url, boolean checkUrlSecurity, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOExceptionRedirect current request to given URL.If
checkUrlSecurityparam is set to true, the specified URL must match security configuration ofHttpUtil.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 andcheckUrlSecurity=falseonly 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 performedresponse- the response in which to write redirect headers- Throws:
java.io.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 java.io.IOExceptionSend 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 performedresponse- the response in which to write forbidden redirect headers- Throws:
java.io.IOException- if an error occured while writing in response headers- Since:
- jcms-5.5.0
-
sendError
public void sendError(int statusCode, java.lang.String message)Sends an error response to the client using the specified status code and clears the output buffer.
The server defaults to creating the response to look like an HTML-formatted server error page containing the specified message, setting the content type to "text/html", leaving cookies and other headers unmodified. If an error-page declaration has been made for the web application corresponding to the status code passed in, it will be served back in preference to the suggested msg parameter.
If the response has already been committed, this method won't send the error message. After using this method, the response should be considered to be committed and should not be written to.- Parameters:
statusCode- the error status codemessage- the descriptive message
-
sendError
public void sendError(int statusCode)
Sends an error response to the client using the specified status code and clears the buffer.
This is equivalent to callingsendError(int, String)with the same status code andnullfor the message.- Parameters:
statusCode- the error status code
-
addCookie
public void addCookie(javax.servlet.http.Cookie cookie)
Deprecated.since JCMS-7729, useHttpUtil.addCookie(HttpServletResponse, 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 java.lang.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 java.lang.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 java.lang.String getUrlWithCommonUpdatedParams(java.lang.String[] names, java.lang.String[] values, boolean encodeParams)- Parameters:
names- an array of parameter names added or updated the urlvalues- an array of values added or updated the url corresponding to namesencodeParams- 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)
-
setSuccessMsg
public void setSuccessMsg(java.lang.String msg)
Set JCMS success message for current request (displayed through doMessageBox.jsp)- Parameters:
msg- the message to display
-
setSuccessMsgSession
public void setSuccessMsgSession(java.lang.String msg)
Set JCMS success message for current session (displayed through doMessageBox.jsp)- Parameters:
msg- the message to display
-
setInfoMsg
public void setInfoMsg(java.lang.String msg)
Set JCMS info message for current request (displayed through doMessageBox.jsp)- Parameters:
msg- the message to display
-
setInfoMsgSession
public void setInfoMsgSession(java.lang.String msg)
Set JCMS info message for current session (displayed through doMessageBox.jsp)- Parameters:
msg- the message to display
-
setWarningMsg
public void setWarningMsg(java.lang.String msg)
Set JCMS warning message for current request (displayed through doMessageBox.jsp)- Parameters:
msg- the message to display
-
setWarningMsgSession
public void setWarningMsgSession(java.lang.String msg)
Set JCMS warning message for current session (displayed through doMessageBox.jsp)- Parameters:
msg- the message to display
-
setErrorMsg
public void setErrorMsg(java.lang.String msg)
Set JCMS warning message for current request (displayed through doMessageBox.jsp)- Parameters:
msg- the message to display
-
setErrorMsgSession
public void setErrorMsgSession(java.lang.String msg)
Set JCMS warning message for current session (displayed through doMessageBox.jsp)- Parameters:
msg- the message to display
-
setSuccessMsg
public static void setSuccessMsg(java.lang.String msg, javax.servlet.http.HttpServletRequest request)Set JCMS success message for specified request (displayed through doMessageBox.jsp)- Parameters:
msg- the message to displayrequest- the current request from which the message is being set
-
setSuccessMsgSession
public static void setSuccessMsgSession(java.lang.String msg, javax.servlet.http.HttpServletRequest request)Set JCMS success message for specified session (displayed through doMessageBox.jsp)- Parameters:
msg- the message to displayrequest- the current request from which the message is being set
-
setInfoMsg
public static void setInfoMsg(java.lang.String msg, javax.servlet.http.HttpServletRequest request)Set JCMS info message for specified request (displayed through doMessageBox.jsp)- Parameters:
msg- the message to displayrequest- the current request from which the message is being set
-
setInfoMsgSession
public static void setInfoMsgSession(java.lang.String msg, javax.servlet.http.HttpServletRequest request)Set JCMS info message for specified session (displayed through doMessageBox.jsp)- Parameters:
msg- the message to displayrequest- the current request from which the message is being set
-
setWarningMsg
public static void setWarningMsg(java.lang.String msg, javax.servlet.http.HttpServletRequest request)Set JCMS warning message for specified request (displayed through doMessageBox.jsp)- Parameters:
msg- the message to displayrequest- the current request from which the message is being set
-
setWarningMsgSession
public static void setWarningMsgSession(java.lang.String msg, javax.servlet.http.HttpServletRequest request)Set JCMS warning message for specified session (displayed through doMessageBox.jsp)- Parameters:
msg- the message to displayrequest- the current request from which the message is being set
-
setErrorMsg
public static void setErrorMsg(java.lang.String msg, javax.servlet.http.HttpServletRequest request)Set JCMS warning message for specified request (displayed through doMessageBox.jsp)- Parameters:
msg- the message to displayrequest- the current request from which the message is being set
-
setErrorMsgSession
public static void setErrorMsgSession(java.lang.String msg, javax.servlet.http.HttpServletRequest request)Set JCMS warning message for specified session (displayed through doMessageBox.jsp)- Parameters:
msg- the message to displayrequest- the current request from which the message is being set
-
getSuccessMsg
public static java.lang.String getSuccessMsg(javax.servlet.http.HttpServletRequest request)
Returns the success message in the J2EE request.- Parameters:
request- the request to check for- Returns:
- the information message if any or null if none was set.
-
getSuccessMsgSession
public static java.lang.String getSuccessMsgSession(javax.servlet.http.HttpServletRequest request)
Returns the success message in the J2EE session.- Parameters:
request- the request to check for- Returns:
- the information message if any or null if none was set.
-
getInfoMsg
public static java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.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, java.util.List<JcmsMessage> messages)Remove specified messages from the session and request message list.- Parameters:
request- the current request must not be nullmessages- 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 nulljcmsMessage- the message to remove
-
addToastr
public void addToastr(JcmsToastr toastr)
Add JCMS toastr for specified request (displayed through doToastr.jspf)- Parameters:
toastr-JcmsToastr- Since:
- jcms-10.0.0
-
addToastrSession
public void addToastrSession(JcmsToastr toastr)
Add JCMS toastr for current session (displayed through doToastr.jspf)- Parameters:
toastr-JcmsToastr- Since:
- jcms-10.0.0
-
addToastr
public static void addToastr(javax.servlet.http.HttpServletRequest request, JcmsToastr toastr)Add JCMS toastr for specified request (displayed through doToastr.jspf)- Parameters:
request- the current request from which the message is being addedtoastr-JcmsToastrto be displayed- Since:
- jcms-10.0.0
-
addToastrSession
public static void addToastrSession(javax.servlet.http.HttpServletRequest request, JcmsToastr toastr)Add JCMS toastr for specified session (displayed through doToastr.jspf)- Parameters:
request- the current request from which the message is being addedtoastr-JcmsToastrto be displayed- Since:
- jcms-10.0.0
-
getToastrSessionCollection
public static java.util.Set<JcmsToastr> getToastrSessionCollection(javax.servlet.http.HttpServletRequest request)
Returns the toastr collection in the J2EE session.- Parameters:
request- the request to check for- Returns:
- the toastr collection if any or null if none was added.
- Since:
- jcms-10.0.0
-
getToastrCollection
public static java.util.Set<JcmsToastr> getToastrCollection(javax.servlet.http.HttpServletRequest request)
Returns the toastr collection in the J2EE request.- Parameters:
request- the request to check for- Returns:
- the toastr collection if any or null if none was added.
- Since:
- jcms-10.0.0
-
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 displayrequest- 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 displayrequest- the current request from which the message is being added- Since:
- jcms-7.0.0
-
getMsgList
public static java.util.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 java.util.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
-
getSuccessMsgList
public static java.util.List<JcmsMessage> getSuccessMsgList(javax.servlet.http.HttpServletRequest request)
Returns the information message in the J2EE request.- Parameters:
request- the request to check for- Returns:
- the success message set if any or null if none was added.
- Since:
- jcms-9.0.0
-
getSuccessMsgSessionList
public static java.util.List<JcmsMessage> getSuccessMsgSessionList(javax.servlet.http.HttpServletRequest request)
Returns the success message in the J2EE session.- Parameters:
request- the request to check for- Returns:
- the success message set if any or null if none was added.
- Since:
- jcms-9.0.0
-
getInfoMsgList
public static java.util.List<JcmsMessage> getInfoMsgList(javax.servlet.http.HttpServletRequest request)
Returns the success 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 java.util.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 java.util.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 java.util.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 java.util.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 java.util.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 java.lang.String glp(java.lang.String key, java.lang.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(java.lang.String param)
Validate a string as validScheduleand 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
Schedulestring - Since:
- jcms-6.0
-
validateRegexp
public boolean validateRegexp(java.lang.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 java.util.List<JcmsMessage> select(java.util.Collection<? extends JcmsMessage> dataColl, JcmsMessageSelector selector)
Perform a selection on aCollectionofJcmsMessageusing the givenJcmsMessageSelector- Parameters:
dataColl- theCollectionofDatato select.selector- theDataSelectorto use.- Returns:
- a NEW or CLONED
ListofJcmsMessage. - Since:
- jcms-7.0.0
-
applySelector
public static java.util.List<JcmsMessage> applySelector(java.util.List<JcmsMessage> msgList, JcmsMessageSelector selector)
Apply givenJcmsMessageSelectorby removing non selectedJcmsMessagefrom the givenList.
This method DOES NOT create any new List, modify the existing one.- Parameters:
msgList- aListofJcmsMessagefrom which to remove non selected data.selector- theJcmsMessageSelectorto apply- Returns:
- the SAME
Listthat was given but modified. - Since:
- jcms-7.0.0
-
updateWorkspace
public void updateWorkspace(Workspace workspace)
Set the given workspace to the request and refreshes the context by forcing an update.- Parameters:
workspace- the workspace- Since:
- jcms-10.0.7
-
-