use of org.springframework.extensions.jcr.SessionFactory in project pentaho-kettle by pentaho.
the class UIEERepositoryDirectoryIT method setApplicationContext.
@Override
public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
SessionFactory jcrSessionFactory = (SessionFactory) applicationContext.getBean("jcrSessionFactory");
testJcrTemplate = new JcrTemplate(jcrSessionFactory);
testJcrTemplate.setAllowCreate(true);
testJcrTemplate.setExposeNativeSession(true);
repositoryAdminUsername = (String) applicationContext.getBean("repositoryAdminUsername");
superAdminRoleName = (String) applicationContext.getBean("superAdminAuthorityName");
sysAdminUserName = (String) applicationContext.getBean("superAdminUserName");
tenantAuthenticatedRoleName = (String) applicationContext.getBean("singleTenantAuthenticatedAuthorityName");
singleTenantAdminRoleName = (String) applicationContext.getBean("singleTenantAdminAuthorityName");
tenantManager = (ITenantManager) applicationContext.getBean("tenantMgrProxy");
roleBindingDaoTarget = (IRoleAuthorizationPolicyRoleBindingDao) applicationContext.getBean("roleAuthorizationPolicyRoleBindingDaoTarget");
authorizationPolicy = (IAuthorizationPolicy) applicationContext.getBean("authorizationPolicy");
repo = (IUnifiedRepository) applicationContext.getBean("unifiedRepository");
userRoleDao = (IUserRoleDao) applicationContext.getBean("userRoleDao");
repositoryFileDao = (IRepositoryFileDao) applicationContext.getBean("repositoryFileDao");
testUserRoleDao = userRoleDao;
repositoryLifecyleManager = (IBackingRepositoryLifecycleManager) applicationContext.getBean("defaultBackingRepositoryLifecycleManager");
txnTemplate = (TransactionTemplate) applicationContext.getBean("jcrTransactionTemplate");
TestPrincipalProvider.userRoleDao = testUserRoleDao;
TestPrincipalProvider.adminCredentialsStrategy = (CredentialsStrategy) applicationContext.getBean("jcrAdminCredentialsStrategy");
TestPrincipalProvider.repository = (Repository) applicationContext.getBean("jcrRepository");
}
use of org.springframework.extensions.jcr.SessionFactory in project pentaho-platform by pentaho.
the class DefaultUnifiedRepositoryBase method setApplicationContext.
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
SessionFactory jcrSessionFactory = (SessionFactory) applicationContext.getBean("jcrSessionFactory");
testJcrTemplate = new JcrTemplate(jcrSessionFactory);
testJcrTemplate.setAllowCreate(true);
testJcrTemplate.setExposeNativeSession(true);
jcrTemplate = (JcrTemplate) applicationContext.getBean("jcrTemplate");
repositoryAdminUsername = (String) applicationContext.getBean("repositoryAdminUsername");
singleTenantAdminUserName = (String) applicationContext.getBean("singleTenantAdminUserName");
superAdminRoleName = (String) applicationContext.getBean("superAdminAuthorityName");
sysAdminUserName = (String) applicationContext.getBean("superAdminUserName");
tenantAuthenticatedRoleName = (String) applicationContext.getBean("singleTenantAuthenticatedAuthorityName");
tenantAdminRoleName = (String) applicationContext.getBean("singleTenantAdminAuthorityName");
tenantManager = (ITenantManager) applicationContext.getBean("tenantMgrProxy");
pathConversionHelper = (IPathConversionHelper) applicationContext.getBean("pathConversionHelper");
roleBindingDao = (IRoleAuthorizationPolicyRoleBindingDao) applicationContext.getBean("roleAuthorizationPolicyRoleBindingDaoTxn");
roleBindingDaoTarget = (IRoleAuthorizationPolicyRoleBindingDao) applicationContext.getBean("roleAuthorizationPolicyRoleBindingDaoTarget");
authorizationPolicy = (IAuthorizationPolicy) applicationContext.getBean("authorizationPolicy");
repo = (IUnifiedRepository) applicationContext.getBean("unifiedRepository");
userRoleDao = (IUserRoleDao) applicationContext.getBean("userRoleDao");
jcrTransactionTemplate = (TransactionTemplate) applicationContext.getBean("jcrTransactionTemplate");
defaultBackingRepositoryLifecycleManager = (IBackingRepositoryLifecycleManager) applicationContext.getBean("defaultBackingRepositoryLifecycleManager");
repositoryFileDao = (IRepositoryFileDao) applicationContext.getBean("repositoryFileDao");
repositoryFileAclDao = (IRepositoryFileAclDao) applicationContext.getBean("repositoryFileAclDao");
testUserRoleDao = userRoleDao;
txnTemplate = (TransactionTemplate) applicationContext.getBean("jcrTransactionTemplate");
TestPrincipalProvider.userRoleDao = testUserRoleDao;
TestPrincipalProvider.adminCredentialsStrategy = (CredentialsStrategy) applicationContext.getBean("jcrAdminCredentialsStrategy");
TestPrincipalProvider.repository = (Repository) applicationContext.getBean("jcrRepository");
}
use of org.springframework.extensions.jcr.SessionFactory in project pentaho-platform by pentaho.
the class PentahoTransactionManagerTest method isCreatingTransaction.
@Test
public void isCreatingTransaction() throws Exception {
PentahoTransactionManager transactionManager = new PentahoTransactionManager();
SessionFactory sessionFactory = mock(SessionFactory.class);
XASession xaSession = mock(XASession.class);
when(xaSession.getXAResource()).thenReturn(mock(XAResource.class));
transactionManager.setSessionFactory(sessionFactory);
TransactionDefinition transactionDefinition = mock(TransactionDefinition.class);
when(transactionDefinition.getIsolationLevel()).thenReturn(-1);
// All of our assertions must be done while doBegin is being called
when(sessionFactory.getSession()).then(invocation -> {
List<Integer> transDefs = Arrays.asList(TransactionDefinition.PROPAGATION_NESTED, TransactionDefinition.PROPAGATION_REQUIRED, TransactionDefinition.PROPAGATION_REQUIRES_NEW);
for (Integer transDef : transDefs) {
when(transactionDefinition.getPropagationBehavior()).thenReturn(transDef);
assertTrue(transactionManager.isCreatingTransaction());
}
return xaSession;
});
// Calls doBegin
transactionManager.getTransaction(transactionDefinition);
}
use of org.springframework.extensions.jcr.SessionFactory in project pentaho-platform by pentaho.
the class PentahoTransactionManagerTest method getTransactionDefinition.
@Test
public void getTransactionDefinition() throws Exception {
PentahoTransactionManager transactionManager = new PentahoTransactionManager();
SessionFactory sessionFactory = mock(SessionFactory.class);
XASession xaSession = mock(XASession.class);
when(xaSession.getXAResource()).thenReturn(mock(XAResource.class));
transactionManager.setSessionFactory(sessionFactory);
TransactionDefinition transactionDefinition = mock(TransactionDefinition.class);
when(transactionDefinition.getIsolationLevel()).thenReturn(-1);
// Main assertion. While doBegin is being called, the transactionDefinition can be reached.
AtomicBoolean wasAvailable = new AtomicBoolean(false);
when(sessionFactory.getSession()).then(invocation -> {
assertEquals(transactionDefinition, transactionManager.getTransactionDefinition());
wasAvailable.set(true);
return xaSession;
});
transactionManager.getTransaction(transactionDefinition);
assertTrue(wasAvailable.get());
// after life of doBegin call the definition is not available
assertNull(transactionManager.getTransactionDefinition());
}
use of org.springframework.extensions.jcr.SessionFactory in project pentaho-platform by pentaho.
the class UserRoleDaoEncodeIT method setApplicationContext.
public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
manager = (IBackingRepositoryLifecycleManager) applicationContext.getBean("backingRepositoryLifecycleManager");
SessionFactory jcrSessionFactory = (SessionFactory) applicationContext.getBean("jcrSessionFactory");
testJcrTemplate = new JcrTemplate(jcrSessionFactory);
testJcrTemplate.setAllowCreate(true);
testJcrTemplate.setExposeNativeSession(true);
repositoryAdminUsername = (String) applicationContext.getBean("repositoryAdminUsername");
authenticatedRoleName = (String) applicationContext.getBean("singleTenantAuthenticatedAuthorityName");
adminRoleName = (String) applicationContext.getBean("singleTenantAdminAuthorityName");
roleBindingDaoTarget = (IRoleAuthorizationPolicyRoleBindingDao) applicationContext.getBean("roleAuthorizationPolicyRoleBindingDaoTarget");
sysAdminRoleName = (String) applicationContext.getBean("superAdminAuthorityName");
sysAdminUserName = (String) applicationContext.getBean("superAdminUserName");
authorizationPolicy = (IAuthorizationPolicy) applicationContext.getBean("authorizationPolicy");
tenantManager = (ITenantManager) applicationContext.getBean("tenantMgrProxy");
repositoryFileDao = (IRepositoryFileDao) applicationContext.getBean("repositoryFileDao");
userRoleDaoProxy = (IUserRoleDao) applicationContext.getBean("userRoleDaoTxn");
userRoleDaoTestProxy = (IUserRoleDao) applicationContext.getBean("userRoleDaoTxn");
tenantedUserNameUtils = (ITenantedPrincipleNameResolver) applicationContext.getBean("tenantedUserNameUtils");
tenantedRoleNameUtils = (ITenantedPrincipleNameResolver) applicationContext.getBean("tenantedRoleNameUtils");
TestPrincipalProvider.userRoleDao = (IUserRoleDao) applicationContext.getBean("userRoleDaoTxn");
TestPrincipalProvider.adminCredentialsStrategy = (CredentialsStrategy) applicationContext.getBean("jcrAdminCredentialsStrategy");
TestPrincipalProvider.repository = (Repository) applicationContext.getBean("jcrRepository");
jcrTemplate = (JcrTemplate) applicationContext.getBean("jcrTemplate");
}
Aggregations