use of org.pentaho.di.repository.pur.PurRepository in project pentaho-kettle by pentaho.
the class PurRepositoryMetaStoreTest method setUp.
@Before
public void setUp() throws Exception {
purRepository = mock(PurRepository.class);
pur = mock(IUnifiedRepository.class);
namespacesFolder = mock(RepositoryFile.class);
when(purRepository.getUnderlyingRepository()).thenReturn(pur);
when(pur.getFile(PurRepositoryMetaStore.METASTORE_FOLDER_PATH)).thenReturn(namespacesFolder);
PurRepositoryMeta mockPurRepositoryMeta = mock(PurRepositoryMeta.class);
when(purRepository.getRepositoryMeta()).thenReturn(mockPurRepositoryMeta);
when(purRepository.getRepositoryMeta().getName()).thenReturn("MockPurRepository");
metaStore = new PurRepositoryMetaStore(purRepository);
}
use of org.pentaho.di.repository.pur.PurRepository 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.di.repository.pur.PurRepository in project pentaho-kettle by pentaho.
the class RepositoryPerformanceApp method startupRepository.
protected void startupRepository() throws Exception {
// PentahoLicenseVerifier.setStreamOpener(new TestLicenseStream("pdi-ee=true")); //$NON-NLS-1$
KettleEnvironment.init();
repositoryMeta = new PurRepositoryMeta();
repositoryMeta.setName("JackRabbit");
repositoryMeta.setDescription("JackRabbit test repository");
((PurRepositoryMeta) repositoryMeta).setRepositoryLocation(new PurRepositoryLocation(repositoryLocation));
userInfo = new UserInfo(EXP_LOGIN, "password", EXP_USERNAME, "Apache Tomcat user", true);
repository = new PurRepository();
repository.init(repositoryMeta);
repository.connect(EXP_LOGIN, "password");
}
use of org.pentaho.di.repository.pur.PurRepository in project pentaho-kettle by pentaho.
the class EESpoonPlugin method applyToContainer.
public void applyToContainer(String category, XulDomContainer container) throws XulException {
container.registerClassLoader(getClass().getClassLoader());
if (category.equals("spoon")) {
// $NON-NLS-1$
// register the two controllers, note that the lock controller must come
// after the abs controller so the biz logic between the two hold.
// Register the ABS Menu controller
getSpoonInstance().addSpoonMenuController(new SpoonMenuABSController());
// Register the SpoonMenuLockController to modify the main Spoon Menu structure
getSpoonInstance().addSpoonMenuController(new SpoonMenuLockController());
} else if (category.equals("trans-graph") || category.equals("job-graph")) {
// $NON-NLS-1$ //$NON-NLS-2$
if ((getSpoonInstance() != null) && (getSpoonInstance().getRepository() != null) && (getSpoonInstance().getRepository() instanceof PurRepository)) {
// $NON-NLS-1$
container.getDocumentRoot().addOverlay("org/pentaho/di/ui/repository/pur/xul/spoon-lock-overlay.xul");
container.addEventHandler(new SpoonLockController());
}
try {
Repository repository = getSpoonInstance().getRepository();
if (repository != null) {
IAbsSecurityProvider securityProvider = (IAbsSecurityProvider) repository.getService(IAbsSecurityProvider.class);
if (securityProvider != null) {
enablePermission(securityProvider);
}
}
} catch (KettleException e) {
e.printStackTrace();
}
} else if (category.equals("repository-explorer")) {
// $NON-NLS-1$
try {
Repository repository = getSpoonInstance().getRepository();
IAbsSecurityProvider securityProvider = null;
if (repository != null) {
securityProvider = (IAbsSecurityProvider) repository.getService(IAbsSecurityProvider.class);
}
if (securityProvider != null) {
boolean createPermitted = securityProvider.isAllowed(IAbsSecurityProvider.CREATE_CONTENT_ACTION);
boolean executePermitted = securityProvider.isAllowed(IAbsSecurityProvider.EXECUTE_CONTENT_ACTION);
// Disable export if user can not create or execute content (prevents execution outside of this repo)
container.getDocumentRoot().getElementById("folder-context-export").setDisabled(!createPermitted || !executePermitted);
}
} catch (KettleException e) {
e.printStackTrace();
}
}
}
use of org.pentaho.di.repository.pur.PurRepository in project pentaho-kettle by pentaho.
the class SpoonLockController method init.
protected void init() {
try {
if ((Spoon.getInstance().getRepository() != null) && (Spoon.getInstance().getRepository().hasService(IAbsSecurityProvider.class))) {
IAbsSecurityProvider securityService = (IAbsSecurityProvider) Spoon.getInstance().getRepository().getService(IAbsSecurityProvider.class);
setCreateAllowed(allowedActionsContains(securityService, IAbsSecurityProvider.CREATE_CONTENT_ACTION));
}
shell = (((Spoon) SpoonFactory.getInstance()).getShell());
XulDomContainer container = getXulDomContainer();
bindingFactory = new DefaultBindingFactory();
bindingFactory.setDocument(container.getDocumentRoot());
bindingFactory.setBindingType(Type.ONE_WAY);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
bindingFactory.createBinding(this, "activeMetaUnlocked", "lock-context-locknotes", "disabled");
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
bindingFactory.createBinding(this, "lockingNotAllowed", "lock-context-lock", "disabled");
// Try transformation
if (container.getEventHandlers().containsKey("transgraph")) {
// $NON-NLS-1$
// $NON-NLS-1$
workingMeta = ((TransGraph) container.getEventHandler("transgraph")).getMeta();
} else if (container.getEventHandlers().containsKey("jobgraph")) {
// $NON-NLS-1$
// $NON-NLS-1$
workingMeta = ((JobGraph) container.getEventHandler("jobgraph")).getMeta();
}
RepositoryLock repoLock = fetchRepositoryLock(workingMeta);
if (repoLock != null) {
// $NON-NLS-1$
XulMenuitem lockMenuItem = (XulMenuitem) container.getDocumentRoot().getElementById("lock-context-lock");
lockMenuItem.setSelected(true);
// Permit locking/unlocking if the user owns the lock
if (Spoon.getInstance().getRepository() instanceof PurRepository) {
setLockingAllowed(new UnifiedRepositoryLockService(((PurRepository) Spoon.getInstance().getRepository()).getUnderlyingRepository()).canUnlockFileById(workingMeta.getObjectId()));
} else {
setLockingAllowed(repoLock.getLogin().equalsIgnoreCase(Spoon.getInstance().getRepository().getUserInfo().getLogin()));
}
} else {
setLockingAllowed(true);
}
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
firePropertyChange("activeMetaUnlocked", null, repoLock == null);
} catch (Exception e) {
// $NON-NLS-1$
log.error(BaseMessages.getString(PKG, "LockController.NoLockingSupport"), e);
new ErrorDialog(((Spoon) SpoonFactory.getInstance()).getShell(), BaseMessages.getString(PKG, "Dialog.Error"), e.getMessage(), // $NON-NLS-1$
e);
}
}
Aggregations