Examples of RepositoryFileTree


Examples of org.pentaho.platform.api.repository2.unified.RepositoryFileTree

  }

  public RepositoryFileTreeDto getTreeFromRequest( final RepositoryRequest repositoryRequest ) {
    // RepositoryFileTree tree = repo.getTree( path, depth, filter, showHidden );

    RepositoryFileTree tree = repo.getTree( repositoryRequest );

    // Filter system folders from non-admin users.
    // PDI uses this web-service and system folders must be returned to admin repository database connections.
    List<RepositoryFileTree> files = new ArrayList<RepositoryFileTree>();
    IAuthorizationPolicy policy = PentahoSystem.get( IAuthorizationPolicy.class );
    boolean isAdmin = policy.isAllowed( AdministerSecurityAction.NAME );
    for ( RepositoryFileTree file : tree.getChildren() ) {
      Map<String, Serializable> fileMeta = repo.getFileMetadata( file.getFile().getId() );
      boolean isSystemFolder =
          fileMeta.containsKey( IUnifiedRepository.SYSTEM_FOLDER ) ? (Boolean) fileMeta
              .get( IUnifiedRepository.SYSTEM_FOLDER ) : false;
      if ( !isAdmin && isSystemFolder ) {
        continue;
      }
      files.add( file );
    }
    tree = new RepositoryFileTree( tree.getFile(), files );
    if ( tree == null ) {
      return null;
    }

    return new RepositoryFileTreeAdapter( repositoryRequest ).marshal( tree );
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.RepositoryFileTree

        for( File child : childrenArray ){
         
          if( child.isFile() ){
           
            if( types == RepositoryRequest.FILES_TYPE_FILTER.FILES_FOLDERS || types == RepositoryRequest.FILES_TYPE_FILTER.FILES ){
              children.add( new RepositoryFileTree( internalGetFile( child ), new ArrayList<RepositoryFileTree>() ) );
            }
           
            continue;
          }
         
          RepositoryFileTree repositoryChildFileTree = getTree( child, depth - 1, childNodeFilter, types );
          if ( repositoryChildFileTree != null ) {
            children.add( repositoryChildFileTree );
          }
        }
      }
      Collections.sort( children );
    } else {
      children = null;
    }
    return new RepositoryFileTree( rootFile, children );
 
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.RepositoryFileTree

      for ( RepositoryFileTreeDto child : v.children ) {
        children.add( unmarshal( child ) );
      }
    }

    return new RepositoryFileTree( RepositoryFileAdapter.toFile( v.file ), children );
  }
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.RepositoryFileTree

    if ( depth != 0 ) {
      children = new ArrayList<RepositoryFileTree>();
      if ( rootFile.isFolder() ) {
        List<RepositoryFile> childrenTmp = getChildren( rootFile.getId(), filter );
        for ( RepositoryFile child : childrenTmp ) {
          RepositoryFileTree repositoryFileTree = getTree( child.getPath(), depth - 1, filter, showHidden );
          if ( repositoryFileTree != null ) {
            children.add( repositoryFileTree );
          }
        }
      }
      Collections.sort( children );
    } else {
      children = null;
    }
    return new RepositoryFileTree( rootFile, children );
  }
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.RepositoryFileTree

    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() );
  }
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.RepositoryFileTree

    assertEquals( 1, root.getChildren().size() );
  }

  @Test
  public void testGetTreeWithFileTypeFilter() throws Exception {
    RepositoryFileTree root = null;
    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 } );

    RepositoryFile publicFolder =
        repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() ) );
    final String dataString = "Hello World!";
    final String encoding = "UTF-8";
    byte[] data = dataString.getBytes( encoding );
    ByteArrayInputStream dataStream = new ByteArrayInputStream( data );
    final String mimeType = "text/plain";
    final SimpleRepositoryFileData content = new SimpleRepositoryFileData( dataStream, encoding, mimeType );
    RepositoryFile newFile1 =
        repo.createFile( publicFolder.getId(), new RepositoryFile.Builder( "helloworld.xaction" ).versioned( true )
            .hidden( false ).build(), content, null );

    RepositoryFile newFile2 =
        repo.createFolder( publicFolder.getId(), new RepositoryFile.Builder( "testFolder" ).versioned( false ).hidden(
            false ).folder( true ).build(), null, null );

    root = repo.getTree( new RepositoryRequest( publicFolder.getPath(), true, 1, "*|FILES" ) );
    assertFalse( root.getChildren().isEmpty() );
    assertEquals( 1, root.getChildren().size() );
    assertEquals( "helloworld.xaction", root.getChildren().get( 0 ).getFile().getName() );

    root = repo.getTree( new RepositoryRequest( publicFolder.getPath(), true, 1, "*" ) );
    assertFalse( root.getChildren().isEmpty() );
    assertEquals( 2, root.getChildren().size() );

    root = repo.getTree( new RepositoryRequest( publicFolder.getPath(), true, 1, "*|FILES_FOLDERS" ) );
    assertFalse( root.getChildren().isEmpty() );
    assertEquals( 2, root.getChildren().size() );

    root = repo.getTree( new RepositoryRequest( publicFolder.getPath(), true, 1, "*|FOLDERS" ) );
    assertFalse( root.getChildren().isEmpty() );
    assertEquals( 1, root.getChildren().size() );
    assertEquals( "testFolder", root.getChildren().get( 0 ).getFile().getName() );

  }
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.RepositoryFileTree

  }

  @Test
  public void testGetTreeWithShowHidden() throws Exception {
    RepositoryFileTree root = null;
    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 } );

    RepositoryFile publicFolder =
        repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() ) );
    final String dataString = "Hello World!";
    final String encoding = "UTF-8";
    byte[] data = dataString.getBytes( encoding );
    ByteArrayInputStream dataStream = new ByteArrayInputStream( data );
    final String mimeType = "text/plain";
    final SimpleRepositoryFileData content = new SimpleRepositoryFileData( dataStream, encoding, mimeType );
    RepositoryFile newFile1 =
        repo.createFile( publicFolder.getId(), new RepositoryFile.Builder( "helloworld.xaction" ).versioned( true )
            .hidden( true ).build(), content, null );
    root = repo.getTree( new RepositoryRequest( publicFolder.getPath(), true, -1, null ) );
    assertFalse( root.getChildren().isEmpty() );
    root = repo.getTree( new RepositoryRequest( publicFolder.getPath(), false, -1, null ) );
    assertTrue( root.getChildren().isEmpty() );
  }
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.RepositoryFileTree

  public static JSONObject getJSONSolution( String path, int depth, boolean showHiddenFiles, String mode ) {
    JSONObject jsonRoot = new JSONObject();

    try {
      path = StringUtils.defaultIfEmpty( path, SEPARATOR );
      RepositoryFileTree tree = PentahoSystem.get( IUnifiedRepository.class ).getTree( path, depth, "*", false );

      if ( tree != null ) {

        if ( mode.equalsIgnoreCase( Parameter.NAVIGATOR ) ) {

          JSONObject json = new JSONObject();
          processTree( tree, json, false, showHiddenFiles, path );
          jsonRoot.put( "solution", json );

        } else if ( mode.equalsIgnoreCase( Parameter.CONTENT_LIST ) ) {

          jsonRoot = repositoryFileToJSONObject( tree.getFile() );
          jsonRoot.put( "content", new JSONArray() );
          jsonRoot.remove( "files" );
          jsonRoot.remove( "folders" );
          processContentListTree( tree, jsonRoot, showHiddenFiles, path );

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.