Search in sources :

Example 1 with PurRepository

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);
}
Also used : PurRepository(org.pentaho.di.repository.pur.PurRepository) PurRepositoryMeta(org.pentaho.di.repository.pur.PurRepositoryMeta) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Before(org.junit.Before)

Example 2 with 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());
}
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 3 with PurRepository

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");
}
Also used : PurRepository(org.pentaho.di.repository.pur.PurRepository) PurRepositoryMeta(org.pentaho.di.repository.pur.PurRepositoryMeta) PurRepositoryLocation(org.pentaho.di.repository.pur.PurRepositoryLocation)

Example 4 with PurRepository

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();
        }
    }
}
Also used : IAbsSecurityProvider(org.pentaho.di.ui.repository.pur.services.IAbsSecurityProvider) SpoonMenuLockController(org.pentaho.di.ui.repository.pur.controller.SpoonMenuLockController) KettleException(org.pentaho.di.core.exception.KettleException) PurRepository(org.pentaho.di.repository.pur.PurRepository) Repository(org.pentaho.di.repository.Repository) PurRepository(org.pentaho.di.repository.pur.PurRepository) SpoonLockController(org.pentaho.di.ui.repository.pur.controller.SpoonLockController) SpoonMenuABSController(org.pentaho.di.ui.repository.pur.repositoryexplorer.abs.controller.SpoonMenuABSController)

Example 5 with PurRepository

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);
    }
}
Also used : IAbsSecurityProvider(org.pentaho.di.ui.repository.pur.services.IAbsSecurityProvider) DefaultBindingFactory(org.pentaho.ui.xul.binding.DefaultBindingFactory) JobGraph(org.pentaho.di.ui.spoon.job.JobGraph) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) PurRepository(org.pentaho.di.repository.pur.PurRepository) UnifiedRepositoryLockService(org.pentaho.di.repository.pur.UnifiedRepositoryLockService) Spoon(org.pentaho.di.ui.spoon.Spoon) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RepositoryLock(org.pentaho.di.repository.pur.model.RepositoryLock) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException)

Aggregations

PurRepository (org.pentaho.di.repository.pur.PurRepository)7 KettleException (org.pentaho.di.core.exception.KettleException)3 PurRepositoryMeta (org.pentaho.di.repository.pur.PurRepositoryMeta)3 IAbsSecurityProvider (org.pentaho.di.ui.repository.pur.services.IAbsSecurityProvider)3 Spoon (org.pentaho.di.ui.spoon.Spoon)3 XulMenuitem (org.pentaho.ui.xul.components.XulMenuitem)3 Before (org.junit.Before)2 EngineMetaInterface (org.pentaho.di.core.EngineMetaInterface)2 Repository (org.pentaho.di.repository.Repository)2 RepositoryLock (org.pentaho.di.repository.pur.model.RepositoryLock)2 JobGraph (org.pentaho.di.ui.spoon.job.JobGraph)2 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)2 XulToolbarbutton (org.pentaho.ui.xul.components.XulToolbarbutton)2 Serializable (java.io.Serializable)1 JobMeta (org.pentaho.di.job.JobMeta)1 UserInfo (org.pentaho.di.repository.UserInfo)1 PurRepositoryConnector (org.pentaho.di.repository.pur.PurRepositoryConnector)1 PurRepositoryLocation (org.pentaho.di.repository.pur.PurRepositoryLocation)1 UnifiedRepositoryLockService (org.pentaho.di.repository.pur.UnifiedRepositoryLockService)1 EEJobMeta (org.pentaho.di.repository.pur.model.EEJobMeta)1