Search in sources :

Example 11 with RepositoryRequest

use of org.pentaho.platform.api.repository2.unified.RepositoryRequest in project pentaho-platform by pentaho.

the class DefaultUnifiedRepositoryContentIT method testGetTree.

@Test
public void testGetTree() throws Exception {
    loginAsSysTenantAdmin();
    ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
    userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
    login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
    userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
    login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
    RepositoryFileTree root = repo.getTree(new RepositoryRequest(ClientRepositoryPaths.getRootFolderPath(), true, 0, null));
    assertNotNull(root.getFile());
    assertNull(root.getChildren());
    root = repo.getTree(new RepositoryRequest(ClientRepositoryPaths.getRootFolderPath(), true, 1, null));
    assertNotNull(root.getFile());
    assertNotNull(root.getChildren());
    assertFalse(root.getChildren().isEmpty());
    assertNull(root.getChildren().get(0).getChildren());
    root = repo.getTree(new RepositoryRequest(ClientRepositoryPaths.getHomeFolderPath(), true, -1, null));
    assertNotNull(root.getFile());
    assertNotNull(root.getChildren());
    assertFalse(root.getChildren().isEmpty());
    assertTrue(root.getChildren().get(0).getChildren().isEmpty());
    root = repo.getTree(new RepositoryRequest(ClientRepositoryPaths.getHomeFolderPath(), true, -1, "*uz*"));
    assertEquals(1, root.getChildren().size());
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) RepositoryRequest(org.pentaho.platform.api.repository2.unified.RepositoryRequest) RepositoryFileTree(org.pentaho.platform.api.repository2.unified.RepositoryFileTree) Test(org.junit.Test)

Example 12 with RepositoryRequest

use of org.pentaho.platform.api.repository2.unified.RepositoryRequest in project pentaho-platform by pentaho.

the class DefaultUnifiedRepositoryContentIT method testListHomeFolders.

/**
 * A user should only be able to see his home folder (unless your the admin).
 */
// @Test
public void testListHomeFolders() throws Exception {
    loginAsSysTenantAdmin();
    ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
    userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
    login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
    userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
    userRoleDao.createUser(tenantAcme, USERNAME_TIFFANY, PASSWORD, "", null);
    login(USERNAME_TIFFANY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
    List<RepositoryFile> children = repo.getChildren(new RepositoryRequest(String.valueOf(repo.getFile(ClientRepositoryPaths.getHomeFolderPath()).getId()), true, -1, null));
    assertEquals(1, children.size());
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryRequest(org.pentaho.platform.api.repository2.unified.RepositoryRequest)

Example 13 with RepositoryRequest

use of org.pentaho.platform.api.repository2.unified.RepositoryRequest in project pentaho-metaverse by pentaho.

the class LocatorTestUtils method getTree.

/**
 * ************ end -- load job and trans methods for the mock diRepo ****************
 */
public static RepositoryFileTree getTree(RepositoryRequest req) {
    File root = new File(SOLUTION_PATH);
    RepositoryFileTree rft = createFileTree(root);
    return rft;
}
Also used : File(java.io.File) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryFileTree(org.pentaho.platform.api.repository2.unified.RepositoryFileTree)

Example 14 with RepositoryRequest

use of org.pentaho.platform.api.repository2.unified.RepositoryRequest in project pentaho-kettle by pentaho.

the class RepositoryFileProvider method populateFilesLazy.

public void populateFilesLazy(RepositoryDirectory repositoryDirectory, String filter) {
    RepositoryRequest repositoryRequest = new RepositoryRequest();
    repositoryRequest.setPath(repositoryDirectory.getPath());
    repositoryRequest.setDepth(1);
    repositoryRequest.setShowHidden(true);
    repositoryRequest.setTypes(RepositoryRequest.FILES_TYPE_FILTER.FILES);
    repositoryRequest.setChildNodeFilter(filter);
    RepositoryFileTree tree = getRepository().getUnderlyingRepository().getTree(repositoryRequest);
    for (RepositoryFileTree repositoryFileTree : tree.getChildren()) {
        org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile = repositoryFileTree.getFile();
        RepositoryFile repositoryFile1 = RepositoryFile.build(repositoryDirectory.getPath(), repositoryFile, isAdmin());
        repositoryDirectory.addChild(repositoryFile1);
    }
}
Also used : RepositoryRequest(org.pentaho.platform.api.repository2.unified.RepositoryRequest) RepositoryFile(org.pentaho.di.plugins.fileopensave.providers.repository.model.RepositoryFile) RepositoryFileTree(org.pentaho.platform.api.repository2.unified.RepositoryFileTree)

Example 15 with RepositoryRequest

use of org.pentaho.platform.api.repository2.unified.RepositoryRequest in project pentaho-kettle by pentaho.

the class RepositoryBrowserController method populateFilesLazy.

public void populateFilesLazy(RepositoryDirectory repositoryDirectory, String filter) {
    RepositoryRequest repositoryRequest = new RepositoryRequest();
    repositoryRequest.setPath(repositoryDirectory.getPath());
    repositoryRequest.setDepth(1);
    repositoryRequest.setShowHidden(true);
    repositoryRequest.setTypes(RepositoryRequest.FILES_TYPE_FILTER.FILES);
    repositoryRequest.setChildNodeFilter(filter);
    RepositoryFileTree tree = getRepository().getUnderlyingRepository().getTree(repositoryRequest);
    for (RepositoryFileTree repositoryFileTree : tree.getChildren()) {
        org.pentaho.platform.api.repository2.unified.RepositoryFile repositoryFile = repositoryFileTree.getFile();
        RepositoryFile repositoryFile1 = RepositoryFile.build(repositoryDirectory.getPath(), repositoryFile, isAdmin());
        repositoryDirectory.addChild(repositoryFile1);
    }
}
Also used : RepositoryRequest(org.pentaho.platform.api.repository2.unified.RepositoryRequest) RepositoryFile(org.pentaho.repo.model.RepositoryFile) RepositoryFileTree(org.pentaho.platform.api.repository2.unified.RepositoryFileTree)

Aggregations

RepositoryRequest (org.pentaho.platform.api.repository2.unified.RepositoryRequest)31 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)19 RepositoryFileTree (org.pentaho.platform.api.repository2.unified.RepositoryFileTree)19 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)11 Matchers.anyString (org.mockito.Matchers.anyString)8 ITenant (org.pentaho.platform.api.mt.ITenant)7 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Collator (java.text.Collator)4 SimpleRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData)4 File (java.io.File)3 Serializable (java.io.Serializable)3 ObjectId (org.pentaho.di.repository.ObjectId)3 EERepositoryObject (org.pentaho.di.repository.pur.model.EERepositoryObject)3 RepositoryFileAcl (org.pentaho.platform.api.repository2.unified.RepositoryFileAcl)3 RepositoryFileDto (org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto)3 HashMap (java.util.HashMap)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)2