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

Examples of org.pentaho.platform.api.repository2.unified.RepositoryFileAcl$Builder


    final boolean sampleBoolean = true;
    final int sampleInteger = 99;
    final String parentFolderPath = ClientRepositoryPaths.getUserHomeFolderPath( USERNAME_SUZY );
    RepositoryFile newFile =
        createSampleFile( parentFolderPath, expectedName, sampleString, sampleBoolean, sampleInteger );
    RepositoryFileAcl acls = repo.getAcl( newFile.getId() );

    RepositoryFileAcl.Builder newAclBuilder = new RepositoryFileAcl.Builder( acls );
    newAclBuilder.entriesInheriting( false ).ace( userNameUtils.getPrincipleId( tenantAcme, USERNAME_SUZY ),
        RepositoryFileSid.Type.USER, RepositoryFilePermission.ALL );
    repo.updateAcl( newAclBuilder.build() );
View Full Code Here


    {
      RepositoryFile newFolder =
          repo.createFolder( parentFolder.getId(), new RepositoryFile.Builder( "testFolder" ).folder( true ).build(),
              null, null );

      RepositoryFileAcl acl = repo.getAcl( newFolder.getId() );

      RepositoryFileAcl newAcl =
          new RepositoryFileAcl.Builder( acl ).ace( userNameUtils.getPrincipleId( tenantAcme, USERNAME_ADMIN ),
              RepositoryFileSid.Type.USER, RepositoryFilePermission.ALL ).entriesInheriting( true ).build();
      repo.updateAcl( newAcl );

      login( USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName } );
      try {
        repo.deleteFile( newFolder.getId(), null );
      } catch ( Exception e ) {
        e.printStackTrace();
        fail();
      }
    }

    // Now try one not inheriting
    //CHECKSTYLE IGNORE AvoidNestedBlocks FOR NEXT 3 LINES
    {
      RepositoryFile newFolder =
          repo.createFolder( parentFolder.getId(), new RepositoryFile.Builder( "testFolder2" ).folder( true ).build(),
              null, null );

      RepositoryFileAcl acl = repo.getAcl( newFolder.getId() );

      RepositoryFileAcl newAcl =
          new RepositoryFileAcl.Builder( acl ).clearAces().ace(
              userNameUtils.getPrincipleId( tenantAcme, USERNAME_ADMIN ), RepositoryFileSid.Type.USER,
              RepositoryFilePermission.ALL ).entriesInheriting( false ).build();
      repo.updateAcl( newAcl );
View Full Code Here

      RepositoryFile newFile =
          repo.createFile( newFolder.getId(), new RepositoryFile.Builder( "testFile" ).folder( false ).build(),
              content, null );

      RepositoryFileAcl acl = repo.getAcl( newFile.getId() );

      RepositoryFileAcl newAcl =
          new RepositoryFileAcl.Builder( acl ).ace( userNameUtils.getPrincipleId( tenantAcme, USERNAME_ADMIN ),
              RepositoryFileSid.Type.USER, RepositoryFilePermission.ALL ).entriesInheriting( true ).build();
      repo.updateAcl( newAcl );

      login( USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName } );
      try {
        repo.deleteFile( newFile.getId(), null );
      } catch ( Exception e ) {
        e.printStackTrace();
        fail();
      }
    }

    // Now try one not inheriting
    //CHECKSTYLE IGNORE AvoidNestedBlocks FOR NEXT 3 LINES
    {

      RepositoryFile newFile =
          repo.createFile( newFolder.getId(), new RepositoryFile.Builder( "testFile" ).folder( false ).build(),
              content, null );

      RepositoryFileAcl acl = repo.getAcl( newFile.getId() );

      RepositoryFileAcl newAcl =
          new RepositoryFileAcl.Builder( acl ).ace( userNameUtils.getPrincipleId( tenantAcme, USERNAME_ADMIN ),
              RepositoryFileSid.Type.USER, RepositoryFilePermission.ALL ).entriesInheriting( false ).build();
      repo.updateAcl( newAcl );

      login( USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName } );
View Full Code Here

    DataNode newChild1 = node.addNode( "herfkmdx" );

    NodeRepositoryFileData data = new NodeRepositoryFileData( node );
    RepositoryFile repoFile =
        repo.createFile( parentFolder.getId(), new RepositoryFile.Builder( "test" ).build(), data, null );
    RepositoryFileAcl acl = repo.getAcl( repoFile.getId() );

    RepositoryFileSid suzySid = new RepositoryFileSid( userNameUtils.getPrincipleId( tenantAcme, USERNAME_SUZY ) );
    RepositoryFileAcl.Builder newAclBuilder =
        new RepositoryFileAcl.Builder( acl ).ace( suzySid, EnumSet.of( RepositoryFilePermission.READ,
            RepositoryFilePermission.WRITE ) );
View Full Code Here

    }

  }

  private void assertLocalAclEmpty( final RepositoryFile file ) {
    RepositoryFileAcl acl = repo.getAcl( file.getId() );
    assertTrue( acl.getAces().size() == 0 );
  }
View Full Code Here

    assertTrue( acl.getAces().size() == 0 );
  }

  private void assertLocalAceExists( final RepositoryFile file, final RepositoryFileSid sid,
                                     final EnumSet<RepositoryFilePermission> permissions ) {
    RepositoryFileAcl acl = repo.getAcl( file.getId() );

    List<RepositoryFileAce> aces = acl.getAces();
    for ( RepositoryFileAce ace : aces ) {
      if ( sid.equals( ace.getSid() ) && permissions.equals( ace.getPermissions() ) ) {
        return;
      }
    }
View Full Code Here

      final RepositoryFile file, final RepositoryFileSid owner ) throws RepositoryException {
    RepositoryFileSid newOwnerSid = owner;
    if ( JcrTenantUtils.getUserNameUtils().getTenant( owner.getName() ) == null ) {
      newOwnerSid = new RepositoryFileSid( JcrTenantUtils.getTenantedUser( owner.getName() ), owner.getType() );
    }
    RepositoryFileAcl acl = getAcl( session, pentahoJcrConstants, file.getId() );
    RepositoryFileAcl newAcl = new RepositoryFileAcl.Builder( acl ).owner( newOwnerSid ).build();
    updateAcl( session, newAcl );
  }
View Full Code Here

    RepositoryFileSid newRecipient = recipient;
    if ( JcrTenantUtils.getUserNameUtils().getTenant( recipient.getName() ) == null ) {
      newRecipient = new RepositoryFileSid( JcrTenantUtils.getTenantedUser( recipient.getName() ),
        recipient.getType() );
    }
    RepositoryFileAcl acl = getAcl( session, pentahoJcrConstants, id );
    RepositoryFileAcl updatedAcl = new RepositoryFileAcl.Builder( acl ).ace( newRecipient, permission ).build();
    updateAcl( session, updatedAcl );
  }
View Full Code Here

    }

    Assert.notNull( id );
    Assert.notNull( recipient );
    Assert.notNull( permission );
    RepositoryFileAcl acl = getAcl( id );
    Assert.notNull( acl );
    // TODO mlowery find an ACE with the recipient and update that rather than adding a new ACE
    RepositoryFileSid newRecipient = recipient;
    if ( recipient.getType().equals( Type.USER ) ) {
      if ( JcrTenantUtils.getUserNameUtils().getTenant( recipient.getName() ) == null ) {
        newRecipient =
            new RepositoryFileSid( JcrTenantUtils.getTenantedUser( recipient.getName() ), recipient.getType() );
      }
    } else {
      if ( JcrTenantUtils.getRoleNameUtils().getTenant( recipient.getName() ) == null ) {
        newRecipient =
            new RepositoryFileSid( JcrTenantUtils.getTenantedRole( recipient.getName() ), recipient.getType() );
      }
    }
    RepositoryFileAcl updatedAcl = new RepositoryFileAcl.Builder( acl ).ace( newRecipient, permission ).build();
    updateAcl( updatedAcl );
    logger.debug( "added ace: id=" + id + ", sid=" + recipient + ", permission=" + permission ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
  }
View Full Code Here

  public RepositoryFileAcl updateAcl( final RepositoryFileAcl acl ) {
    return (RepositoryFileAcl) jcrTemplate.execute( new JcrCallback() {
      public Object doInJcr( final Session session ) throws RepositoryException, IOException {
        PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants( session );
        JcrRepositoryFileUtils.checkoutNearestVersionableFileIfNecessary( session, pentahoJcrConstants, acl.getId() );
        RepositoryFileAcl updatedAcl = internalUpdateAcl( session, pentahoJcrConstants, acl.getId(), acl );
        JcrRepositoryFileUtils.checkinNearestVersionableFileIfNecessary( session, pentahoJcrConstants, acl.getId(),
            null, null, true );
        return updatedAcl;
      }
    } );
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.repository2.unified.RepositoryFileAcl$Builder

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.