Search in sources :

Example 1 with RepositoryFileProxyFactory

use of org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory in project pentaho-kettle by pentaho.

the class UIEERepositoryDirectoryIT method setUp.

@Before
public void setUp() throws Exception {
    this.testContextManager = new TestContextManager(getClass());
    this.testContextManager.prepareTestInstance(this);
    loginAsRepositoryAdmin();
    SimpleJcrTestUtils.deleteItem(testJcrTemplate, ServerRepositoryPaths.getPentahoRootFolderPath());
    mp = new MicroPlatform();
    // used by DefaultPentahoJackrabbitAccessControlHelper
    mp.defineInstance("tenantedUserNameUtils", userNameUtils);
    mp.defineInstance("tenantedRoleNameUtils", roleNameUtils);
    mp.defineInstance(IAuthorizationPolicy.class, authorizationPolicy);
    mp.defineInstance(ITenantManager.class, tenantManager);
    mp.defineInstance("roleAuthorizationPolicyRoleBindingDaoTarget", roleBindingDaoTarget);
    mp.defineInstance("repositoryAdminUsername", repositoryAdminUsername);
    mp.defineInstance("RepositoryFileProxyFactory", new RepositoryFileProxyFactory(testJcrTemplate, repositoryFileDao));
    mp.defineInstance("useMultiByteEncoding", new Boolean(false));
    mp.defineInstance(IAclService.class, new Boolean(false));
    // Start the micro-platform
    mp.start();
    loginAsRepositoryAdmin();
    setAclManagement();
    systemTenant = tenantManager.createTenant(null, ServerRepositoryPaths.getPentahoRootFolderName(), singleTenantAdminRoleName, tenantAuthenticatedRoleName, "Anonymous");
    userRoleDao.createUser(systemTenant, sysAdminUserName, "password", "", new String[] { singleTenantAdminRoleName });
    logout();
    super.setUp();
    KettleEnvironment.init();
    // programmatically register plugins, annotation based plugins do not get loaded unless
    // they are in kettle's plugins folder.
    JobEntryPluginType.getInstance().registerCustom(JobEntryAttributeTesterJobEntry.class, "test", "JobEntryAttributeTester", "JobEntryAttributeTester", "JobEntryAttributeTester", "");
    StepPluginType.getInstance().registerCustom(TransStepAttributeTesterTransStep.class, "test", "StepAttributeTester", "StepAttributeTester", "StepAttributeTester", "");
    repositoryMeta = new PurRepositoryMeta();
    repositoryMeta.setName("JackRabbit");
    repositoryMeta.setDescription("JackRabbit test repository");
    userInfo = new UserInfo(EXP_LOGIN, "password", EXP_USERNAME, "Apache Tomcat user", true);
    repository = new PurRepository();
    repository.init(repositoryMeta);
    login(sysAdminUserName, systemTenant, new String[] { singleTenantAdminRoleName, tenantAuthenticatedRoleName });
    ITenant tenantAcme = tenantManager.createTenant(systemTenant, EXP_TENANT, singleTenantAdminRoleName, tenantAuthenticatedRoleName, "Anonymous");
    userRoleDao.createUser(tenantAcme, EXP_LOGIN, "password", "", new String[] { singleTenantAdminRoleName });
    logout();
    setUpUser();
    PurRepository purRep = (PurRepository) repository;
    final PurRepositoryConnector purRepositoryConnector = new PurRepositoryConnector(purRep, (PurRepositoryMeta) repositoryMeta, purRep.getRootRef());
    purRep.setPurRepositoryConnector(purRepositoryConnector);
    purRep.setTest(repo);
    repository.connect(EXP_LOGIN, "password");
    login(EXP_LOGIN, tenantAcme, new String[] { singleTenantAdminRoleName, tenantAuthenticatedRoleName });
    System.out.println("PUR NAME!!!: " + repo.getClass().getCanonicalName());
    RepositoryFile repositoryFile = repo.getFile(ClientRepositoryPaths.getPublicFolderPath());
    Serializable repositoryFileId = repositoryFile.getId();
    List<RepositoryFile> files = repo.getChildren(repositoryFileId);
    StringBuilder buf = new StringBuilder();
    for (RepositoryFile file : files) {
        buf.append("\n").append(file);
    }
    assertTrue("files not deleted: " + buf, files.isEmpty());
}
Also used : Serializable(java.io.Serializable) PurRepository(org.pentaho.di.repository.pur.PurRepository) PurRepositoryMeta(org.pentaho.di.repository.pur.PurRepositoryMeta) PurRepositoryConnector(org.pentaho.di.repository.pur.PurRepositoryConnector) UserInfo(org.pentaho.di.repository.UserInfo) TestContextManager(org.springframework.test.context.TestContextManager) ITenant(org.pentaho.platform.api.mt.ITenant) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryFileProxyFactory(org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory) Before(org.junit.Before)

Example 2 with RepositoryFileProxyFactory

use of org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory in project pentaho-platform by pentaho.

the class DirectoryResourceIT method beforeTest.

@Before
public void beforeTest() throws PlatformInitializationException {
    mp = new MicroPlatform();
    // used by DefaultPentahoJackrabbitAccessControlHelper
    mp.defineInstance(IAuthorizationPolicy.class, authorizationPolicy);
    mp.defineInstance(ITenantManager.class, tenantManager);
    mp.define(ITenant.class, Tenant.class);
    mp.defineInstance("roleAuthorizationPolicyRoleBindingDaoTarget", roleBindingDaoTarget);
    mp.defineInstance(IRoleAuthorizationPolicyRoleBindingDao.class, roleBindingDaoTarget);
    mp.defineInstance("tenantedUserNameUtils", tenantedUserNameUtils);
    mp.defineInstance("tenantedRoleNameUtils", tenantedRoleNameUtils);
    mp.defineInstance("repositoryAdminUsername", repositoryAdminUsername);
    mp.define(IRoleAuthorizationPolicyRoleBindingDao.class, RoleAuthorizationPolicy.class, Scope.GLOBAL);
    mp.define(ITenantManager.class, RepositoryTenantManager.class, Scope.GLOBAL);
    mp.defineInstance("singleTenantAdminAuthorityName", new String("Administrator"));
    mp.defineInstance("RepositoryFileProxyFactory", new RepositoryFileProxyFactory(this.testJcrTemplate, this.repositoryFileDao));
    DefaultRepositoryVersionManager defaultRepositoryVersionManager = new DefaultRepositoryVersionManager();
    defaultRepositoryVersionManager.setPlatformMimeResolver(new NameBaseMimeResolver());
    mp.defineInstance(IRepositoryVersionManager.class, defaultRepositoryVersionManager);
    UserRoleDaoUserDetailsService userDetailsService = new UserRoleDaoUserDetailsService();
    userDetailsService.setUserRoleDao(userRoleDao);
    List<String> systemRoles = new ArrayList<String>();
    systemRoles.add("Admin");
    List<String> extraRoles = Arrays.asList(new String[] { "Authenticated", "Anonymous" });
    String adminRole = "Admin";
    userRoleListService = new UserRoleDaoUserRoleListService(userRoleDao, userDetailsService, tenantedUserNameUtils, systemRoles, extraRoles, adminRole);
    ((UserRoleDaoUserRoleListService) userRoleListService).setUserRoleDao(userRoleDao);
    ((UserRoleDaoUserRoleListService) userRoleListService).setUserDetailsService(userDetailsService);
    mp.defineInstance(IUserRoleListService.class, userRoleListService);
    mp.start();
    logout();
    startupCalled = true;
    SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
}
Also used : NameBaseMimeResolver(org.pentaho.platform.plugin.services.importer.NameBaseMimeResolver) UserRoleDaoUserDetailsService(org.pentaho.platform.security.userroledao.service.UserRoleDaoUserDetailsService) UserRoleDaoUserRoleListService(org.pentaho.platform.security.userroledao.service.UserRoleDaoUserRoleListService) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) ArrayList(java.util.ArrayList) DefaultRepositoryVersionManager(org.pentaho.platform.repository2.unified.DefaultRepositoryVersionManager) RepositoryFileProxyFactory(org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory) Before(org.junit.Before)

Example 3 with RepositoryFileProxyFactory

use of org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory in project pentaho-kettle by pentaho.

the class PurRepositoryIT method setUp.

@Before
public void setUp() throws Exception {
    this.testContextManager = new TestContextManager(getClass());
    this.testContextManager.prepareTestInstance(this);
    IRepositoryVersionManager mockRepositoryVersionManager = mock(IRepositoryVersionManager.class);
    when(mockRepositoryVersionManager.isVersioningEnabled(anyString())).thenReturn(true);
    when(mockRepositoryVersionManager.isVersionCommentEnabled(anyString())).thenReturn(false);
    JcrRepositoryFileUtils.setRepositoryVersionManager(mockRepositoryVersionManager);
    loginAsRepositoryAdmin();
    SimpleJcrTestUtils.deleteItem(testJcrTemplate, ServerRepositoryPaths.getPentahoRootFolderPath());
    mp = new MicroPlatform();
    // used by DefaultPentahoJackrabbitAccessControlHelper
    mp.defineInstance("tenantedUserNameUtils", userNameUtils);
    mp.defineInstance("tenantedRoleNameUtils", roleNameUtils);
    mp.defineInstance(IAuthorizationPolicy.class, authorizationPolicy);
    mp.defineInstance(ITenantManager.class, tenantManager);
    mp.defineInstance("roleAuthorizationPolicyRoleBindingDaoTarget", roleBindingDaoTarget);
    mp.defineInstance("repositoryAdminUsername", repositoryAdminUsername);
    mp.defineInstance("RepositoryFileProxyFactory", new RepositoryFileProxyFactory(testJcrTemplate, repositoryFileDao));
    mp.defineInstance("useMultiByteEncoding", new Boolean(false));
    // Start the micro-platform
    mp.start();
    loginAsRepositoryAdmin();
    setAclManagement();
    systemTenant = tenantManager.createTenant(null, ServerRepositoryPaths.getPentahoRootFolderName(), singleTenantAdminRoleName, tenantAuthenticatedRoleName, "Anonymous");
    userRoleDao.createUser(systemTenant, sysAdminUserName, "password", "", new String[] { singleTenantAdminRoleName });
    logout();
    super.setUp();
    KettleEnvironment.init();
    // programmatically register plugins, annotation based plugins do not get loaded unless
    // they are in kettle's plugins folder.
    JobEntryPluginType.getInstance().registerCustom(JobEntryAttributeTesterJobEntry.class, "test", "JobEntryAttributeTester", "JobEntryAttributeTester", "JobEntryAttributeTester", "");
    StepPluginType.getInstance().registerCustom(TransStepAttributeTesterTransStep.class, "test", "StepAttributeTester", "StepAttributeTester", "StepAttributeTester", "");
    repositoryMeta = new PurRepositoryMeta();
    repositoryMeta.setName("JackRabbit");
    repositoryMeta.setDescription("JackRabbit test repository");
    userInfo = new UserInfo(EXP_LOGIN, "password", EXP_USERNAME, "Apache Tomcat user", true);
    repository = new PurRepository();
    repository.init(repositoryMeta);
    login(sysAdminUserName, systemTenant, new String[] { singleTenantAdminRoleName, tenantAuthenticatedRoleName });
    ITenant tenantAcme = tenantManager.createTenant(systemTenant, EXP_TENANT, singleTenantAdminRoleName, tenantAuthenticatedRoleName, "Anonymous");
    userRoleDao.createUser(tenantAcme, EXP_LOGIN, "password", "", new String[] { singleTenantAdminRoleName });
    logout();
    setUpUser();
    PurRepository purRep = (PurRepository) repository;
    purRep.setPurRepositoryConnector(new PurRepositoryConnector(purRep, (PurRepositoryMeta) repositoryMeta, purRep.getRootRef()));
    ((PurRepository) repository).setTest(repo);
    repository.connect(EXP_LOGIN, "password");
    login(EXP_LOGIN, tenantAcme, new String[] { singleTenantAdminRoleName, tenantAuthenticatedRoleName });
    System.out.println("PUR NAME!!!: " + repo.getClass().getCanonicalName());
    RepositoryFile repositoryFile = repo.getFile(ClientRepositoryPaths.getPublicFolderPath());
    Serializable repositoryFileId = repositoryFile.getId();
    List<RepositoryFile> files = repo.getChildren(repositoryFileId);
    StringBuilder buf = new StringBuilder();
    for (RepositoryFile file : files) {
        buf.append("\n").append(file);
    }
    assertTrue("files not deleted: " + buf, files.isEmpty());
}
Also used : Serializable(java.io.Serializable) UserInfo(org.pentaho.di.repository.UserInfo) TestContextManager(org.springframework.test.context.TestContextManager) IRepositoryVersionManager(org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager) ITenant(org.pentaho.platform.api.mt.ITenant) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryFileProxyFactory(org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory) Before(org.junit.Before)

Example 4 with RepositoryFileProxyFactory

use of org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory in project pentaho-kettle by pentaho.

the class PurRepositoryTestBase method startMicroPlatform.

private void startMicroPlatform() throws Exception {
    mp = new MicroPlatform();
    mp.defineInstance("tenantedUserNameUtils", userNameUtils);
    mp.defineInstance("tenantedRoleNameUtils", roleNameUtils);
    mp.defineInstance(IAuthorizationPolicy.class, authorizationPolicy);
    mp.defineInstance(ITenantManager.class, tenantManager);
    mp.defineInstance("roleAuthorizationPolicyRoleBindingDaoTarget", roleBindingDaoTarget);
    mp.defineInstance("repositoryAdminUsername", repositoryAdmin);
    mp.defineInstance("RepositoryFileProxyFactory", new RepositoryFileProxyFactory(testJcrTemplate, repositoryFileDao));
    mp.defineInstance("useMultiByteEncoding", Boolean.FALSE);
    initMicroPlatform(mp);
    mp.start();
}
Also used : MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) RepositoryFileProxyFactory(org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory)

Example 5 with RepositoryFileProxyFactory

use of org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory in project pentaho-platform by pentaho.

the class DefaultUnifiedRepositoryBase method initialize.

public void initialize(boolean multiByteEncoding) throws Exception {
    loginAsRepositoryAdmin();
    SimpleJcrTestUtils.deleteItem(testJcrTemplate, ServerRepositoryPaths.getPentahoRootFolderPath());
    mp = new MicroPlatform(getSolutionPath());
    // used by DefaultPentahoJackrabbitAccessControlHelper
    mp.defineInstance("tenantedUserNameUtils", userNameUtils);
    mp.defineInstance("tenantedRoleNameUtils", roleNameUtils);
    mp.defineInstance("ILockHelper", new DefaultLockHelper(userNameUtils));
    mp.defineInstance(IAuthorizationPolicy.class, authorizationPolicy);
    mp.defineInstance(ITenantManager.class, tenantManager);
    mp.defineInstance("roleAuthorizationPolicyRoleBindingDaoTarget", roleBindingDaoTarget);
    mp.defineInstance("repositoryAdminUsername", repositoryAdminUsername);
    mp.defineInstance("RepositoryFileProxyFactory", new RepositoryFileProxyFactory(this.jcrTemplate, this.repositoryFileDao));
    mp.defineInstance("ITenantedPrincipleNameResolver", new DefaultTenantedPrincipleNameResolver());
    mp.defineInstance("useMultiByteEncoding", multiByteEncoding);
    mp.defineInstance(IUnifiedRepository.class, repo);
    mp.defineInstance(IRepositoryFileAclDao.class, repositoryFileAclDao);
    IUserRoleListService userRoleListService = mock(IUserRoleListService.class);
    when(userRoleListService.getRolesForUser(any(ITenant.class), anyString())).thenReturn(Arrays.asList(tenantAdminRoleName, AUTHENTICATED_ROLE_NAME));
    mp.defineInstance(IUserRoleListService.class, userRoleListService);
    mp.defineInstance("singleTenantAdminUserName", singleTenantAdminUserName);
    mp.defineInstance("singleTenantAdminAuthorityName", tenantAdminRoleName);
    // Start the micro-platform
    mp.start();
    loginAsRepositoryAdmin();
    setAclManagement();
    systemTenant = tenantManager.createTenant(null, ServerRepositoryPaths.getPentahoRootFolderName(), tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
    userRoleDao.createUser(systemTenant, sysAdminUserName, PASSWORD, "", new String[] { tenantAdminRoleName });
    logout();
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) DefaultLockHelper(org.pentaho.platform.repository2.unified.jcr.DefaultLockHelper) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) DefaultTenantedPrincipleNameResolver(org.pentaho.platform.security.userroledao.DefaultTenantedPrincipleNameResolver) IUserRoleListService(org.pentaho.platform.api.engine.IUserRoleListService) RepositoryFileProxyFactory(org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory)

Aggregations

RepositoryFileProxyFactory (org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory)9 MicroPlatform (org.pentaho.test.platform.engine.core.MicroPlatform)9 Before (org.junit.Before)7 ArrayList (java.util.ArrayList)3 ITenant (org.pentaho.platform.api.mt.ITenant)3 UserRoleDaoUserDetailsService (org.pentaho.platform.security.userroledao.service.UserRoleDaoUserDetailsService)3 UserRoleDaoUserRoleListService (org.pentaho.platform.security.userroledao.service.UserRoleDaoUserRoleListService)3 Serializable (java.io.Serializable)2 UserInfo (org.pentaho.di.repository.UserInfo)2 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)2 NameBaseMimeResolver (org.pentaho.platform.plugin.services.importer.NameBaseMimeResolver)2 DefaultRepositoryVersionManager (org.pentaho.platform.repository2.unified.DefaultRepositoryVersionManager)2 TestContextManager (org.springframework.test.context.TestContextManager)2 PurRepository (org.pentaho.di.repository.pur.PurRepository)1 PurRepositoryConnector (org.pentaho.di.repository.pur.PurRepositoryConnector)1 PurRepositoryMeta (org.pentaho.di.repository.pur.PurRepositoryMeta)1 IUserRoleListService (org.pentaho.platform.api.engine.IUserRoleListService)1 IRepositoryVersionManager (org.pentaho.platform.api.repository2.unified.IRepositoryVersionManager)1 DefaultLockHelper (org.pentaho.platform.repository2.unified.jcr.DefaultLockHelper)1 DefaultTenantedPrincipleNameResolver (org.pentaho.platform.security.userroledao.DefaultTenantedPrincipleNameResolver)1