Class CredentialsStrategySessionFactory
- java.lang.Object
-
- org.pentaho.platform.repository2.unified.jcr.sejcr.CredentialsStrategySessionFactory
-
- All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean
,org.springframework.beans.factory.InitializingBean
,org.springframework.extensions.jcr.SessionFactory
public class CredentialsStrategySessionFactory extends Object implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, org.springframework.extensions.jcr.SessionFactory
Copy-and-paste ofJcrSessionFactory
except that this implementation delegates to aCredentialsStrategy
implementation for getting aCredentials
instance. Also has fixes from SEJCR-18. Also getBareSession changed to getAdminSession and runs as Jackrabbit admin.- Author:
- mlowery
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CredentialsStrategySessionFactory.LogoutSuppressingInvocationHandler
-
Field Summary
Fields Modifier and Type Field Description protected PentahoJcrSessionFactory
sessionFactory
-
Constructor Summary
Constructors Constructor Description CredentialsStrategySessionFactory(javax.jcr.Repository repository, String workspaceName, CredentialsStrategy credentialsStrategy, CredentialsStrategy adminCredentialsStrategy)
Constructor with all the required fields.CredentialsStrategySessionFactory(javax.jcr.Repository repository, String workspaceName, CredentialsStrategy credentialsStrategy, CredentialsStrategy adminCredentialsStrategy, org.springframework.extensions.jcr.SessionHolderProviderManager sessionHolderProviderManager)
Constructor containing all the fields available.CredentialsStrategySessionFactory(javax.jcr.Repository repository, CredentialsStrategy credentialsStrategy)
Constructor with all the required fields.CredentialsStrategySessionFactory(javax.jcr.Repository repository, CredentialsStrategy credentialsStrategy, CredentialsStrategy adminCredentialsStrategy)
Constructor with all the required fields.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.jcr.Session
addListeners(javax.jcr.Session session)
Hook for adding listeners to the newly returned session.void
afterPropertiesSet()
javax.jcr.Session
createSessionProxy(javax.jcr.Session session)
We create a proxy wraper around the actualy session to prevent it from being closed.void
destroy()
boolean
equals(Object obj)
javax.jcr.Session
getAdminSession()
org.springframework.extensions.jcr.EventListenerDefinition[]
getEventListeners()
Properties
getNamespaces()
javax.jcr.Repository
getRepository()
javax.jcr.Session
getSession()
PentahoJcrSessionFactory
getSessionFactory()
org.springframework.extensions.jcr.SessionHolder
getSessionHolder(javax.jcr.Session session)
protected org.springframework.extensions.jcr.SessionHolderProvider
getSessionHolderProvider()
Used internally.org.springframework.extensions.jcr.SessionHolderProviderManager
getSessionHolderProviderManager()
String
getWorkspaceName()
int
hashCode()
boolean
isForceNamespacesRegistration()
boolean
isKeepNewNamespaces()
boolean
isSkipExistingNamespaces()
protected void
registerNamespaces()
Register the namespaces.protected void
registerNodeTypes()
void
setEventListeners(org.springframework.extensions.jcr.EventListenerDefinition[] eventListenerDefinitions)
void
setForceNamespacesRegistration(boolean forceNamespacesRegistration)
Indicate if the given namespace registrations will override the namespace already registered in the repository under the same prefix.void
setKeepNewNamespaces(boolean keepNamespaces)
Indicate if the given namespace registrations will be kept (the default) when the application context closes down or if they will be unregistered.void
setNamespaces(Properties namespaces)
void
setNodeTypeDefinitionProviders(List<NodeTypeDefinitionProvider> nodeTypeDefinitionProviders)
void
setRepository(javax.jcr.Repository repository)
void
setSessionFactory(PentahoJcrSessionFactory sessionFactory)
protected void
setSessionHolderProvider(org.springframework.extensions.jcr.SessionHolderProvider sessionHolderProvider)
Used internally.void
setSessionHolderProviderManager(org.springframework.extensions.jcr.SessionHolderProviderManager sessionHolderProviderManager)
void
setSkipExistingNamespaces(boolean skipRegisteredNamespace)
Indicate if the given namespace registrations will skip already registered namespaces or not.void
setWorkspaceName(String workspaceName)
String
toString()
protected void
unregisterNamespaces()
Removes the namespaces.protected void
unregisterNodeTypes()
Hook for un-registering node types on the underlying repository.
-
-
-
Field Detail
-
sessionFactory
protected PentahoJcrSessionFactory sessionFactory
-
-
Constructor Detail
-
CredentialsStrategySessionFactory
public CredentialsStrategySessionFactory(javax.jcr.Repository repository, CredentialsStrategy credentialsStrategy)
Constructor with all the required fields.- Parameters:
repository
-workspaceName
-credentials
-
-
CredentialsStrategySessionFactory
public CredentialsStrategySessionFactory(javax.jcr.Repository repository, CredentialsStrategy credentialsStrategy, CredentialsStrategy adminCredentialsStrategy)
Constructor with all the required fields.- Parameters:
repository
-workspaceName
-credentials
-
-
CredentialsStrategySessionFactory
public CredentialsStrategySessionFactory(javax.jcr.Repository repository, String workspaceName, CredentialsStrategy credentialsStrategy, CredentialsStrategy adminCredentialsStrategy)
Constructor with all the required fields.- Parameters:
repository
-workspaceName
-credentials
-
-
CredentialsStrategySessionFactory
public CredentialsStrategySessionFactory(javax.jcr.Repository repository, String workspaceName, CredentialsStrategy credentialsStrategy, CredentialsStrategy adminCredentialsStrategy, org.springframework.extensions.jcr.SessionHolderProviderManager sessionHolderProviderManager)
Constructor containing all the fields available.- Parameters:
repository
-workspaceName
-credentials
-sessionHolderProviderManager
-
-
-
Method Detail
-
getSessionFactory
public PentahoJcrSessionFactory getSessionFactory()
-
setSessionFactory
public void setSessionFactory(PentahoJcrSessionFactory sessionFactory)
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
setNodeTypeDefinitionProviders
public void setNodeTypeDefinitionProviders(List<NodeTypeDefinitionProvider> nodeTypeDefinitionProviders)
-
unregisterNodeTypes
protected void unregisterNodeTypes() throws Exception
Hook for un-registering node types on the underlying repository. Since this process is not covered by the spec, each implementation requires its own subclass. By default, this method doesn't do anything.- Throws:
Exception
-
registerNamespaces
protected void registerNamespaces() throws Exception
Register the namespaces.- Throws:
javax.jcr.RepositoryException
Exception
-
destroy
public void destroy() throws Exception
- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
- Throws:
Exception
- See Also:
DisposableBean.destroy()
-
unregisterNamespaces
protected void unregisterNamespaces() throws Exception
Removes the namespaces.- Throws:
Exception
-
getAdminSession
public javax.jcr.Session getAdminSession() throws javax.jcr.RepositoryException
- Throws:
javax.jcr.RepositoryException
-
getSession
public javax.jcr.Session getSession() throws javax.jcr.RepositoryException
- Specified by:
getSession
in interfaceorg.springframework.extensions.jcr.SessionFactory
- Throws:
javax.jcr.RepositoryException
- See Also:
SessionFactory.getSession()
-
createSessionProxy
public javax.jcr.Session createSessionProxy(javax.jcr.Session session)
We create a proxy wraper around the actualy session to prevent it from being closed. This allows it to be re-used for subsequent requests.- Parameters:
session
-- Returns:
-
getSessionHolder
public org.springframework.extensions.jcr.SessionHolder getSessionHolder(javax.jcr.Session session)
- Specified by:
getSessionHolder
in interfaceorg.springframework.extensions.jcr.SessionFactory
- See Also:
SessionFactory.getSessionHolder(javax.jcr.Session)
-
addListeners
protected javax.jcr.Session addListeners(javax.jcr.Session session) throws javax.jcr.RepositoryException
Hook for adding listeners to the newly returned session. We have to treat exceptions manually and can't rely on the template.- Parameters:
session
- JCR session- Returns:
- the listened session
- Throws:
javax.jcr.RepositoryException
-
getRepository
public javax.jcr.Repository getRepository()
- Returns:
- Returns the repository.
-
setRepository
public void setRepository(javax.jcr.Repository repository)
- Parameters:
repository
- The repository to set.
-
setWorkspaceName
public void setWorkspaceName(String workspaceName)
- Parameters:
workspaceName
- The workspaceName to set.
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classObject
- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classObject
- See Also:
Object.hashCode()
-
toString
public String toString()
- Overrides:
toString
in classObject
- See Also:
Object.toString()
-
getEventListeners
public org.springframework.extensions.jcr.EventListenerDefinition[] getEventListeners()
- Returns:
- Returns the eventListenerDefinitions.
-
setEventListeners
public void setEventListeners(org.springframework.extensions.jcr.EventListenerDefinition[] eventListenerDefinitions)
- Parameters:
eventListenerDefinitions
- The eventListenerDefinitions to set.
-
getNamespaces
public Properties getNamespaces()
- Returns:
- Returns the namespaces.
-
setNamespaces
public void setNamespaces(Properties namespaces)
- Parameters:
namespaces
- The namespaces to set.
-
getSessionHolderProvider
protected org.springframework.extensions.jcr.SessionHolderProvider getSessionHolderProvider()
Used internally.- Returns:
- Returns the sessionHolderProvider.
-
setSessionHolderProvider
protected void setSessionHolderProvider(org.springframework.extensions.jcr.SessionHolderProvider sessionHolderProvider)
Used internally.- Parameters:
sessionHolderProvider
- The sessionHolderProvider to set.
-
getSessionHolderProviderManager
public org.springframework.extensions.jcr.SessionHolderProviderManager getSessionHolderProviderManager()
- Returns:
- Returns the sessionHolderProviderManager.
-
setSessionHolderProviderManager
public void setSessionHolderProviderManager(org.springframework.extensions.jcr.SessionHolderProviderManager sessionHolderProviderManager)
- Parameters:
sessionHolderProviderManager
- The sessionHolderProviderManager to set.
-
setKeepNewNamespaces
public void setKeepNewNamespaces(boolean keepNamespaces)
Indicate if the given namespace registrations will be kept (the default) when the application context closes down or if they will be unregistered. If unregistered, the namespace mappings that were overriden are registered back to the repository.- Parameters:
keepNamespaces
- The keepNamespaces to set.- See Also:
forceNamespacesRegistration
-
setForceNamespacesRegistration
public void setForceNamespacesRegistration(boolean forceNamespacesRegistration)
Indicate if the given namespace registrations will override the namespace already registered in the repository under the same prefix. This will cause unregistration for the namespaces that will be modified. However, depending on thesetKeepNewNamespaces(boolean)
setting, the old namespaces can be registered back once the application context is destroyed. False by default.- Parameters:
forceNamespacesRegistration
- The forceNamespacesRegistration to set.
-
setSkipExistingNamespaces
public void setSkipExistingNamespaces(boolean skipRegisteredNamespace)
Indicate if the given namespace registrations will skip already registered namespaces or not. If true (default), the new namespace will not be registered and the old namespace kept in place. If not skipped, registration of new namespaces will fail if there are already namespace registered under the same prefix. This flag is required for JCR implementations which do not support namespace unregistration which render thesetForceNamespacesRegistration(boolean)
method useless (as namespace registration cannot be forced).- Parameters:
skipRegisteredNamespace
- The skipRegisteredNamespace to set.
-
isForceNamespacesRegistration
public boolean isForceNamespacesRegistration()
- Returns:
- Returns the forceNamespacesRegistration.
-
isKeepNewNamespaces
public boolean isKeepNewNamespaces()
- Returns:
- Returns the keepNewNamespaces.
-
isSkipExistingNamespaces
public boolean isSkipExistingNamespaces()
- Returns:
- Returns the skipExistingNamespaces.
-
getWorkspaceName
public String getWorkspaceName()
- Returns:
- Returns the workspaceName.
-
-