|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jalios.jcms.context.JcmsContext
public class JcmsContext
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()
.
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 |
isDebug
|
protected boolean |
isLogged
|
protected Member |
loggedMember
|
protected javax.servlet.http.HttpServletRequest |
request
|
protected javax.servlet.http.HttpServletResponse |
response
|
static String |
REVISION
|
protected String |
userLang
|
protected Locale |
userLocale
|
protected Workspace |
workspace
|
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). |
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 messages in the J2EE session and in the J2EE request of ERROR level. |
static String[] |
getInfoMsg(javax.servlet.http.HttpServletRequest request)
Returns messages in the J2EE session and in the J2EE request of INFO level. |
Member |
getLoggedMember()
Retrieve the loggedMember variable for this context. |
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 |
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 |
getUserLang()
Retrieves the user lang variable for this context. |
Locale |
getUserLocale()
Retrieve the userLocale variable for this context. |
static String[] |
getWarningMsg(javax.servlet.http.HttpServletRequest request)
Returns messages in the J2EE session and in the J2EE request of WARNING level. |
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 |
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 |
protected DocUploadInfo |
retrieveUploadedFile(org.apache.commons.fileupload.FileItem item,
boolean isFileDocument,
boolean override)
Performs upload of a given FileItem to JCMS upload directory. |
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, ...) |
void |
sendRedirect(String url)
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String REVISION
protected static final Channel channel
protected boolean initDone
protected boolean initWorkspace
protected javax.servlet.http.HttpServletRequest request
protected javax.servlet.http.HttpServletResponse response
protected boolean isLogged
protected boolean isAdmin
protected boolean isDebug
protected Member loggedMember
protected Locale userLocale
protected String userLang
protected Workspace workspace
protected Browser browser
protected Caddy caddy
protected boolean inFO
protected boolean isAjaxRequest
Constructor Detail |
---|
public JcmsContext()
public JcmsContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Method Detail |
---|
public void forceUpdate()
public void setRequest(javax.servlet.http.HttpServletRequest request)
request
- the HttpServletRequest from twhich to retrieve all jcms context information.public javax.servlet.http.HttpServletRequest getRequest()
public void setResponse(javax.servlet.http.HttpServletResponse response)
sendRedirect(String)
response
- the HttpServletResponse to use when needed.public javax.servlet.http.HttpServletResponse getResponse()
public javax.servlet.http.HttpSession getSession()
public Object getUploadedFile(String field, boolean isFileDocument, boolean override)
field
- the submited fieldisFileDocument
- upload to a FileDocument path upload/docs/...override
- If file already exists, override or rename with current timemillis
public List getUploadedFileList(String field, boolean isFileDocument, boolean override)
field
- the submited fieldisFileDocument
- upload to a FileDocument upload/docs/...override
- If file already exists, override or rename with current timemillis
protected DocUploadInfo retrieveUploadedFile(org.apache.commons.fileupload.FileItem item, boolean isFileDocument, boolean override)
item
- the FileItem handling uploaded file informationisFileDocument
- upload to a FileDocument path upload/docs/...override
- If file already exists, override or rename with current timemillis
public boolean isLogged()
public boolean isWebdavAccess()
public boolean isDebug()
public boolean isAdmin()
public Member getLoggedMember()
public void setLoggedMember(Member mbr)
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
.
mbr
- the Member to set as the currently logged Member.public String getUserLang()
public Locale getUserLocale()
public boolean isInFrontOffice()
public void forceWorkspaceUpdate()
public Workspace getWorkspace()
public Browser getBrowser()
public Caddy getCaddy()
public boolean isAjaxRequest()
public void sendRedirect(Data data) throws IOException
data
- the data to redirect to.
IOException
- if an error occured while writing in response headerssendRedirect(String, HttpServletRequest, HttpServletResponse)
public void sendRedirect(String url) throws IOException
url
- the url to redirect to.
IOException
- if an error occured while writing in response headerssendRedirect(String, HttpServletRequest, HttpServletResponse)
public void sendForbidden() throws IOException
IOException
- if an error occured while writing in response headerssendForbidden(HttpServletRequest, HttpServletResponse)
public static void sendRedirect(String url, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
url
- the url to redirect to.request
- the current request from which the redirect is performedresponse
- the response in which to write redirect headers
IOException
- if an error occured while writing in response headerspublic static void sendForbidden(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
request
- the current request from which the forbidden redirect is performedresponse
- the response in which to write forbidden redirect headers
IOException
- if an error occured while writing in response headerspublic void addCookie(javax.servlet.http.Cookie cookie)
cookie
- the cookie to be addedpublic String getContextPath()
ServletUtil.getContextPath(HttpServletRequest)
public String getBaseUrl()
ServletUtil.getBaseUrl(HttpServletRequest)
public String getUrlWithCommonUpdatedParams(String[] names, String[] values, boolean encodeParams)
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)
PortalManager.getUrlWithCommonUpdatedParams(HttpServletRequest, String[], String[], boolean)
public void setInfoMsg(String msg)
msg
- the message to displaypublic void setInfoMsgSession(String msg)
msg
- the message to displaypublic void setWarningMsg(String msg)
msg
- the message to displaypublic void setWarningMsgSession(String msg)
msg
- the message to displaypublic void setErrorMsg(String msg)
msg
- the message to displaypublic void setErrorMsgSession(String msg)
msg
- the message to displaypublic static void setInfoMsg(String msg, javax.servlet.http.HttpServletRequest request)
msg
- the message to displayrequest
- the current request from which the message is being setpublic static void setInfoMsgSession(String msg, javax.servlet.http.HttpServletRequest request)
msg
- the message to displayrequest
- the current request from which the message is being setpublic static void setWarningMsg(String msg, javax.servlet.http.HttpServletRequest request)
msg
- the message to displayrequest
- the current request from which the message is being setpublic static void setWarningMsgSession(String msg, javax.servlet.http.HttpServletRequest request)
msg
- the message to displayrequest
- the current request from which the message is being setpublic static void setErrorMsg(String msg, javax.servlet.http.HttpServletRequest request)
msg
- the message to displayrequest
- the current request from which the message is being setpublic static void setErrorMsgSession(String msg, javax.servlet.http.HttpServletRequest request)
msg
- the message to displayrequest
- the current request from which the message is being setpublic static String[] getInfoMsg(javax.servlet.http.HttpServletRequest request)
request
-
public static String[] getWarningMsg(javax.servlet.http.HttpServletRequest request)
request
-
public static String[] getErrorMsg(javax.servlet.http.HttpServletRequest request)
request
-
public String glp(String key, Object... params)
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
public boolean validateRegexp(String regexp)
regexp
- The pattern to validate
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |