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());
}
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);
}
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());
}
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();
}
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();
}
Aggregations