Class RepositorySessionManager
java.lang.Object
com.webmethods.caf.faces.bean.BaseFacesBean
com.webmethods.caf.faces.bean.BaseFacesSessionBean
com.webmethods.caf.jcr.faces.bean.RepositorySessionManager
- All Implemented Interfaces:
IPageFlowScopeAdapter
,EventListener
,HttpSessionBindingListener
Wrapper around a JCR session that takes care of cleaning up when
the http session is invalidated. Also exposes a few JCR session
methods in a JSF friendly way.
- Since:
- 8.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected javax.jcr.Credentials
Holds reference to the user credentials.protected javax.jcr.Session
Holds the current JCR sessionprotected String
Holds the id of the impersonated userprotected javax.jcr.Repository
Holds reference to the JCR Repositoryprotected String
Holds the JNDI name to get a reference to the Repositoryprotected String
Holds the current workspace nameprotected String
Holds the JNDI name of the workspace nameFields inherited from class com.webmethods.caf.faces.bean.BaseFacesSessionBean
fExpireWithPageFlow
Fields inherited from class com.webmethods.caf.faces.bean.BaseFacesBean
DATA_BINDING_CLIENTS, EMPTY_RESOURCES, OUTCOME_ERROR, OUTCOME_OK, resourcesProviders
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
finalize()
Overrides the default to logout the current JCR sessionjavax.jcr.Credentials
Return the credentials used to create a JCR sessionjavax.jcr.Session
Return the currently active session is it exists and is still live, otherwise a new JCR session is created and returned.Returns the user that the current session will impersonatejavax.jcr.Repository
Get the handle to the repository by using a JNDI lookupThis is a convenience method to expose theSession.refresh(boolean)
API for use in a MethodBinding expression.This is a convenience method to expose theSession.refresh(boolean)
API for use in a MethodBinding expression.protected void
release()
Overrides the default to logout the current JCR sessionsave()
This is a convenience method to expose theSession.save()
API for use in a MethodBinding expression.void
setCredentials
(javax.jcr.Credentials credentials) Sets the credentials to usevoid
setImpersonatedUser
(String impersonatedUser) Sets the user that the session will attempt to impersonateThis is a convenience method to throw away the current JCR session.Methods inherited from class com.webmethods.caf.faces.bean.BaseFacesSessionBean
getExpireWithPageFlow, setExpireWithPageFlow, valueBound, valueUnbound
Methods inherited from class com.webmethods.caf.faces.bean.BaseFacesBean
createMethodBinding, createMethodExpression, createValueBinding, createValueExpression, createValueExpression, error, error, error, error, error, getBean, getFacesContext, getLocale, getResourceInputStream, getResources, getResourcesProvider, getRootCause, getStackTrace, getTreeAttribute, isUserInRole, log, log, log, putTreeAttribute, resetDataBindingClients, resolveDataBinding, resolveDataBinding, resolveExpression, setValue
-
Field Details
-
fRepositoryJNDIName
Holds the JNDI name to get a reference to the Repository -
fWorkspaceNameJNDIName
Holds the JNDI name of the workspace name -
fWorkspaceName
Holds the current workspace name -
fCurrentSession
protected javax.jcr.Session fCurrentSessionHolds the current JCR session -
fImpersonatedUser
Holds the id of the impersonated user -
fRepository
protected javax.jcr.Repository fRepositoryHolds reference to the JCR Repository -
fCredentials
protected javax.jcr.Credentials fCredentialsHolds reference to the user credentials. If this is null, and we are a MwS inproc app, then the current MwS user will be used.
-
-
Constructor Details
-
RepositorySessionManager
public RepositorySessionManager()
-
-
Method Details
-
getRepository
public javax.jcr.Repository getRepository()Get the handle to the repository by using a JNDI lookup- Returns:
- the repository
-
getCredentials
public javax.jcr.Credentials getCredentials()Return the credentials used to create a JCR session -
setCredentials
public void setCredentials(javax.jcr.Credentials credentials) Sets the credentials to use- Parameters:
credentials
- the credentials to set
-
getCurrentSession
public javax.jcr.Session getCurrentSession()Return the currently active session is it exists and is still live, otherwise a new JCR session is created and returned. This API will also attempt user impersonation if an impersonatedUser has been supplied. NOTE: the real user must be a member of the admin role to impersonate other users.- Returns:
- the currentSession
-
release
protected void release()Overrides the default to logout the current JCR session- Specified by:
release
in classBaseFacesSessionBean
- See Also:
-
finalize
Overrides the default to logout the current JCR session -
startNewSession
This is a convenience method to throw away the current JCR session.- Returns:
- action status: "ok" or "error"
-
save
This is a convenience method to expose theSession.save()
API for use in a MethodBinding expression. Any RepositoryException is caught and exposed as a FacesMessage.- Returns:
- action status: "ok" or "error"
-
refreshDiscardUnsaved
This is a convenience method to expose theSession.refresh(boolean)
API for use in a MethodBinding expression. Any RepositoryException is caught and exposed as a FacesMessage. Refreshes the state in the current session. All unsaved transient nodes/properties will be discarded.- Returns:
- action status: "ok" or "error"
-
refreshKeepUnsaved
This is a convenience method to expose theSession.refresh(boolean)
API for use in a MethodBinding expression. Any RepositoryException is caught and exposed as a FacesMessage. Refresh the state in the current session. All unsaved transient nodes/properties will be preserved.- Returns:
- action status: "ok" or "error"
-
getImpersonatedUser
Returns the user that the current session will impersonate -
setImpersonatedUser
Sets the user that the session will attempt to impersonate- Parameters:
impersonatedUser
- the userid to impersonate
-