Package org.pentaho.platform.api.repository2.unified

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


        versionManager.restoreVersion( fileId, versionId, currentUserProvider.getUser(), versionMessage, new Date() );
    FileRecord fileRecord = idManager.getFileById( fileId );
    fileRecord.setData( restored.getData() );
    fileRecord.setMetadata( restored.getMetadata() );
    // reset properties that aren't versioned
    RepositoryFile orig = fileRecord.getFile();
    fileRecord.setFile( new RepositoryFile.Builder( restored.getFile() ).locked( orig.isLocked() ).lockDate(
        orig.getLockDate() ).lockMessage( orig.getLockMessage() ).lockOwner( orig.getLockOwner() ).build() );
  }
View Full Code Here


    login( USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName } );
    userRoleDao.createUser( tenantAcme, USERNAME_TIFFANY, PASSWORD, "", null );

    login( USERNAME_TIFFANY, tenantAcme, new String[] { tenantAuthenticatedRoleName } );

    RepositoryFile tiffanyHomeFolder = repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( USERNAME_TIFFANY ) );
    RepositoryFile testFolder =
        repo.createFolder( tiffanyHomeFolder.getId(), new RepositoryFile.Builder( "test" )
            .folder( true ).build(), null );
    RepositoryFileAcl acl = repo.getAcl( testFolder.getId() );
    RepositoryFileAcl updatedAcl = new RepositoryFileAcl.Builder( acl ).entriesInheriting( false ).build();
    updatedAcl = repo.updateAcl( updatedAcl );
    assertFalse( updatedAcl.isEntriesInheriting() );
    updatedAcl = new RepositoryFileAcl.Builder( updatedAcl ).entriesInheriting( true ).build();
    updatedAcl = repo.updateAcl( updatedAcl );
View Full Code Here

    login( USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName } );
    login( USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName } );
    defaultBackingRepositoryLifecycleManager.newTenant();

    final String fileName = "helloworld.sample";
    RepositoryFile newFile =
        createSampleFile( ClientRepositoryPaths.getUserHomeFolderPath( USERNAME_SUZY ), fileName, "blah", false, 123,
            true );
    assertEquals( 1, repo.getVersionSummaries( newFile.getId() ).size() );
    RepositoryFileAcl acl = repo.getAcl( newFile.getId() );
    // no change; just want to create a new version
    RepositoryFileAcl updatedAcl = new RepositoryFileAcl.Builder( acl ).build();
    repo.updateAcl( updatedAcl );
    assertEquals( 2, repo.getVersionSummaries( newFile.getId() ).size() );
    assertNotNull( repo.getVersionSummary( newFile.getId(), "1.1" ) );
  }
View Full Code Here

    login( USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName } );
    userRoleDao.createUser( tenantAcme, USERNAME_SUZY, PASSWORD, "", null );

    login( USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName } );

    RepositoryFile parentFolder = repo.getFile( ClientRepositoryPaths.getRootFolderPath() );
    RepositoryFile newFolder = new RepositoryFile.Builder( "test" ).folder( true ).build();
    repo.createFolder( parentFolder.getId(), newFolder, null );
  }
View Full Code Here

    userRoleDao.createUser( tenantAcme, USERNAME_SUZY, PASSWORD, "", null );
    userRoleDao.createUser( tenantAcme, USERNAME_TIFFANY, PASSWORD, "", null );

    login( USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName } );

    RepositoryFile parentFolder =
        repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() ) );
    RepositoryFile newFolder = new RepositoryFile.Builder( "test" ).folder( true ).versioned( true ).build();
    final String testFolderPath =
        ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() )
            + RepositoryFile.SEPARATOR + "test";
    newFolder = repo.createFolder( parentFolder.getId(), newFolder, null );
    assertEquals( new RepositoryFileSid( USERNAME_SUZY ), repo.getAcl( newFolder.getId() ).getOwner() );

    // set acl removing suzy's rights to this folder
    login( USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName } );
    RepositoryFileAcl testFolderAcl = repo.getAcl( newFolder.getId() );
    RepositoryFileAcl newAcl =
        new RepositoryFileAcl.Builder( testFolderAcl ).entriesInheriting( false ).clearAces().build();
    repo.updateAcl( newAcl );
    // but suzy is still the owner--she should be able to "acl" herself back into the folder
    login( USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName } );
View Full Code Here

    userRoleDao.createUser( tenantAcme, USERNAME_TIFFANY, PASSWORD, "", null );

    defaultBackingRepositoryLifecycleManager.newTenant();
    login( USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName } );

    RepositoryFile parentFolder =
        repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() ) );
    RepositoryFile newFolder = new RepositoryFile.Builder( "test" ).folder( true ).versioned( true ).build();
    newFolder = repo.createFolder( parentFolder.getId(), newFolder, null );

    RepositoryFileAcl acl = repo.getAcl( newFolder.getId() );
    assertEquals( true, acl.isEntriesInheriting() );
    assertEquals( new RepositoryFileSid( USERNAME_SUZY ), acl.getOwner() );
    assertEquals( newFolder.getId(), acl.getId() );
    assertTrue( acl.getAces().isEmpty() );
    RepositoryFileAcl newAcl =
        new RepositoryFileAcl.Builder( acl ).ace( userNameUtils.getPrincipleId( tenantAcme, USERNAME_TIFFANY ),
            RepositoryFileSid.Type.USER, RepositoryFilePermission.READ ).entriesInheriting( true ).build();
    RepositoryFileAcl fetchedAcl = repo.updateAcl( newAcl );
View Full Code Here

    login( USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName } );
    userRoleDao.createUser( tenantAcme, USERNAME_SUZY, PASSWORD, "", null );
    defaultBackingRepositoryLifecycleManager.newTenant();
    login( USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName } );

    RepositoryFile parentFolder =
        repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() ) );
    RepositoryFile newFolder = new RepositoryFile.Builder( "test" ).folder( true ).versioned( true ).build();
    newFolder = repo.createFolder( parentFolder.getId(), newFolder, null );
    RepositoryFileAcl acl = repo.getAcl( newFolder.getId() );
    RepositoryFileAcl newAcl =
        new RepositoryFileAcl.Builder( acl ).entriesInheriting( false ).ace(
            new RepositoryFileSid( userNameUtils.getPrincipleId( tenantAcme, USERNAME_SUZY ) ),
            RepositoryFilePermission.ALL ).build();
    repo.updateAcl( newAcl );
    RepositoryFileAcl fetchedAcl = repo.getAcl( newFolder.getId() );
    assertEquals( 1, fetchedAcl.getAces().size() );
  }
View Full Code Here

    userRoleDao.createUser( tenantAcme, USERNAME_SUZY, PASSWORD, "", null );
    userRoleDao.createUser( tenantAcme, USERNAME_TIFFANY, PASSWORD, "", null );
    defaultBackingRepositoryLifecycleManager.newTenant();
    login( USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName } );

    RepositoryFile acmePublicFolder =
        repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() ) );
    List<RepositoryFileAce> expectedEffectiveAces1 = repo.getEffectiveAces( acmePublicFolder.getId() );
    RepositoryFile newFolder = new RepositoryFile.Builder( "test" ).folder( true ).versioned( true ).build();
    newFolder = repo.createFolder( acmePublicFolder.getId(), newFolder, null );
    assertEquals( expectedEffectiveAces1, repo.getEffectiveAces( newFolder.getId() ) );

    RepositoryFileAcl acl = repo.getAcl( newFolder.getId() );
    RepositoryFileAcl newAcl =
        new RepositoryFileAcl.Builder( acl ).entriesInheriting( false ).ace(
            new RepositoryFileSid( userNameUtils.getPrincipleId( tenantAcme, USERNAME_SUZY ) ),
            RepositoryFilePermission.ALL ).ace(
            new RepositoryFileSid( userNameUtils.getPrincipleId( tenantAcme, USERNAME_TIFFANY ) ),
            RepositoryFilePermission.READ ).build();
    repo.updateAcl( newAcl );

    List<RepositoryFileAce> expectedEffectiveAces2 = new ArrayList<RepositoryFileAce>();
    expectedEffectiveAces2.add( new RepositoryFileAce( new RepositoryFileSid( USERNAME_SUZY ), EnumSet
        .of( RepositoryFilePermission.ALL ) ) );
    expectedEffectiveAces2.add( new RepositoryFileAce( new RepositoryFileSid( USERNAME_TIFFANY ), EnumSet
        .of( RepositoryFilePermission.READ ) ) );
    assertEquals( expectedEffectiveAces2, repo.getEffectiveAces( newFolder.getId() ) );

    assertEquals( expectedEffectiveAces2, repo.getEffectiveAces( newFolder.getId(), false ) );

    assertEquals( expectedEffectiveAces1, repo.getEffectiveAces( newFolder.getId(), true ) );
  }
View Full Code Here

    login( USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName } );
    userRoleDao.createUser( tenantAcme, USERNAME_SUZY, PASSWORD, "", null );
    defaultBackingRepositoryLifecycleManager.newTenant();
    login( USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName } );

    RepositoryFile parentFolder =
        repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() ) );
    RepositoryFile newFolder = new RepositoryFile.Builder( "test" ).folder( true ).versioned( true ).build();
    newFolder = repo.createFolder( parentFolder.getId(), newFolder, null );
    RepositoryFileAcl acl = repo.getAcl( newFolder.getId() );

    RepositoryFileAcl.Builder newAclBuilder = new RepositoryFileAcl.Builder( acl );
    RepositoryFileSid tiffanySid = new RepositoryFileSid(
        userNameUtils.getPrincipleId( tenantAcme, USERNAME_TIFFANY ) );
    newAclBuilder.owner( tiffanySid );
    repo.updateAcl( newAclBuilder.build() );
    RepositoryFileAcl fetchedAcl = repo.getAcl( newFolder.getId() );
    assertEquals( new RepositoryFileSid( USERNAME_TIFFANY ), fetchedAcl.getOwner() );
  }
View Full Code Here

    login( USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName } );
    userRoleDao.createUser( tenantAcme, USERNAME_SUZY, PASSWORD, "", null );

    login( USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName } );

    RepositoryFile parentFolder =
        repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() ) );
    RepositoryFile newFolder = new RepositoryFile.Builder( "test" ).folder( true ).versioned( true ).build();
    RepositoryFileSid tiffanySid = new RepositoryFileSid(
        userNameUtils.getPrincipleId( tenantAcme, USERNAME_TIFFANY ) );
    RepositoryFileSid suzySid = new RepositoryFileSid( userNameUtils.getPrincipleId( tenantAcme, USERNAME_SUZY ) );
    // tiffany owns it but suzy is creating it
    RepositoryFileAcl.Builder aclBuilder = new RepositoryFileAcl.Builder( tiffanySid );
    // need this to be able to fetch acl as suzy
    aclBuilder.ace( suzySid, RepositoryFilePermission.READ );
    newFolder = repo.createFolder( parentFolder.getId(), newFolder, aclBuilder.build(), null );
    RepositoryFileAcl fetchedAcl = repo.getAcl( newFolder.getId() );
    assertEquals( new RepositoryFileSid( USERNAME_TIFFANY ), fetchedAcl.getOwner() );
    assertLocalAceExists( newFolder, new RepositoryFileSid( USERNAME_SUZY ),
        EnumSet.of( RepositoryFilePermission.READ ) );
  }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.repository2.unified.RepositoryFile

Copyright © 2018 www.massapicom. 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.