Search in sources :

Example 1 with RepositoryFileTreeDto

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

the class FileResourceTest method testDoGetTree.

@Test
public void testDoGetTree() {
    Integer depth = 0;
    String filter = "filter";
    Boolean showHidden = Boolean.TRUE;
    Boolean includeAcls = Boolean.TRUE;
    Boolean includeSysDirs = Boolean.FALSE;
    RepositoryFileTreeDto mockRepositoryFileTreeDto = mock(RepositoryFileTreeDto.class);
    doReturn(mockRepositoryFileTreeDto).when(fileResource.fileService).doGetTree(PATH_ID, depth, filter, showHidden, includeAcls, includeSysDirs);
    RepositoryFileTreeDto testDto = fileResource.doGetTree(PATH_ID, depth, filter, showHidden, includeAcls, includeSysDirs);
    assertEquals(mockRepositoryFileTreeDto, testDto);
    verify(fileResource.fileService).doGetTree(PATH_ID, depth, filter, showHidden, includeAcls, includeSysDirs);
}
Also used : RepositoryFileTreeDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileTreeDto) Test(org.junit.Test)

Example 2 with RepositoryFileTreeDto

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

the class FileResourceTest method testDoGetRootTree.

@Test
public void testDoGetRootTree() {
    Integer depth = 0;
    String filter = "filter";
    Boolean showHidden = Boolean.TRUE;
    Boolean includeAcls = Boolean.TRUE;
    RepositoryFileTreeDto mockRepositoryFileTreeDto = mock(RepositoryFileTreeDto.class);
    doReturn(mockRepositoryFileTreeDto).when(fileResource.fileService).doGetTree(FileUtils.PATH_SEPARATOR, depth, filter, showHidden, includeAcls);
    RepositoryFileTreeDto testDto = fileResource.doGetRootTree(depth, filter, showHidden, includeAcls);
    assertEquals(mockRepositoryFileTreeDto, testDto);
    verify(fileResource.fileService, times(1)).doGetTree(FileUtils.PATH_SEPARATOR, depth, filter, showHidden, includeAcls);
}
Also used : RepositoryFileTreeDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileTreeDto) Test(org.junit.Test)

Example 3 with RepositoryFileTreeDto

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

the class RepositoryFileTreeAdapter method unmarshal.

@Override
public RepositoryFileTree unmarshal(final RepositoryFileTreeDto v) {
    List<RepositoryFileTree> children = null;
    if (v.children != null) {
        children = new ArrayList<RepositoryFileTree>();
        for (RepositoryFileTreeDto child : v.children) {
            children.add(unmarshal(child));
        }
    }
    RepositoryFileTree repositoryFileTree = new RepositoryFileTree(RepositoryFileAdapter.toFile(v.file), children);
    if (v.file.getVersioningEnabled() != null) {
        repositoryFileTree.setVersioningEnabled(v.file.getVersioningEnabled());
    }
    if (v.file.getVersionCommentEnabled() != null) {
        repositoryFileTree.setVersionCommentEnabled(v.file.getVersionCommentEnabled());
    }
    return repositoryFileTree;
}
Also used : RepositoryFileTree(org.pentaho.platform.api.repository2.unified.RepositoryFileTree)

Example 4 with RepositoryFileTreeDto

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

the class DefaultUnifiedRepositoryWebService method getTreeFromRequest.

public RepositoryFileTreeDto getTreeFromRequest(final RepositoryRequest repositoryRequest) {
    // RepositoryFileTree tree = repo.getTree( path, depth, filter, showHidden );
    IAuthorizationPolicy policy = PentahoSystem.get(IAuthorizationPolicy.class);
    boolean isAdmin = policy.isAllowed(AdministerSecurityAction.NAME);
    // PDI uses this web-service and system folders must be returned to admin repository database connections.
    if (!isAdmin) {
        // Non Admin users can never get system folders
        repositoryRequest.setIncludeSystemFolders(false);
        getLogger().warn("User does not have administrator privileges; setting includeSystemFolders to false.");
    }
    RepositoryFileTree tree = repo.getTree(repositoryRequest);
    return new RepositoryFileTreeAdapter(repositoryRequest).marshal(tree);
}
Also used : IAuthorizationPolicy(org.pentaho.platform.api.engine.IAuthorizationPolicy) RepositoryFileTree(org.pentaho.platform.api.repository2.unified.RepositoryFileTree)

Example 5 with RepositoryFileTreeDto

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

the class UnifiedRepositoryPurgeService method processRevisionDeletion.

private void processRevisionDeletion(PurgeUtilitySpecification purgeSpecification) throws PurgeDeletionException {
    RepositoryRequest repositoryRequest = new RepositoryRequest(purgeSpecification.getPath(), true, -1, purgeSpecification.getFileFilter());
    repositoryRequest.setTypes(FILES_TYPE_FILTER.FILES_FOLDERS);
    repositoryRequest.setIncludeMemberSet(new HashSet<String>(Arrays.asList(new String[] { "name", "id", "folder", "path", "versioned", "versionId", "locked" })));
    getLogger().debug("Creating file list");
    RepositoryFileTreeDto tree = getRepoWs().getTreeFromRequest(repositoryRequest);
    processPurgeForTree(tree, purgeSpecification);
}
Also used : RepositoryFileTreeDto(org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileTreeDto) RepositoryRequest(org.pentaho.platform.api.repository2.unified.RepositoryRequest)

Aggregations

RepositoryFileTreeDto (org.pentaho.platform.repository2.unified.webservices.RepositoryFileTreeDto)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 RepositoryFileTree (org.pentaho.platform.api.repository2.unified.RepositoryFileTree)5 RepositoryRequest (org.pentaho.platform.api.repository2.unified.RepositoryRequest)4 RepositoryFileTreeDto (org.pentaho.platform.api.repository2.unified.webservices.RepositoryFileTreeDto)3 Collator (java.text.Collator)2 JAXBContext (javax.xml.bind.JAXBContext)2 Unmarshaller (javax.xml.bind.Unmarshaller)2 RepositoryFileTree (org.pentaho.gwt.widgets.client.filechooser.RepositoryFileTree)2 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)2 RepositoryFileDto (org.pentaho.platform.repository2.unified.webservices.RepositoryFileDto)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Serializable (java.io.Serializable)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 HashMap (java.util.HashMap)1 JAXBException (javax.xml.bind.JAXBException)1 Marshaller (javax.xml.bind.Marshaller)1 Matchers.anyBoolean (org.mockito.Matchers.anyBoolean)1