Examples of RepositoryFileAcl


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

  protected void init() {
    RepositoryFile rootFolder =
        new RepositoryFile.Builder( "" ).path( RepositoryFile.SEPARATOR ).folder( true ).build();

    RepositoryFileAcl rootFolderAcl =
        new RepositoryFileAcl.Builder( root() ).entriesInheriting( false ).ace( everyone(), READ ).build();

    root = new FileRecord( rootFolder, rootFolderAcl );
    idManager.register( root );

    RepositoryFile publicFolder =
        new RepositoryFile.Builder( "public" ).path( RepositoryFile.SEPARATOR + "public" ).folder( true ).build();

    RepositoryFileAcl publicFolderAcl =
        new RepositoryFileAcl.Builder( root() ).entriesInheriting( false ).ace( everyone(), READ, WRITE ).build();

    FileRecord pub = new FileRecord( publicFolder, publicFolderAcl );
    root.addChild( pub );
    idManager.register( pub );

    RepositoryFile etcFolder =
        new RepositoryFile.Builder( "etc" ).path( RepositoryFile.SEPARATOR + "etc" ).folder( true ).build();

    RepositoryFileAcl etcFolderAcl = new RepositoryFileAcl.Builder( root() ).entriesInheriting( true ).build();

    FileRecord etc = new FileRecord( etcFolder, etcFolderAcl );
    root.addChild( etc );
    idManager.register( etc );
View Full Code Here

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

    }
    FileRecord parentFolder = idManager.getFileById( parentFolderId );
    RepositoryFile fileFromRepo =
        new RepositoryFile.Builder( file ).path( parentFolder.getPath() + RepositoryFile.SEPARATOR + file.getName() )
            .title( findTitle( file ) ).description( findDesc( file ) ).build();
    RepositoryFileAcl aclFromRepo = new RepositoryFileAcl.Builder( acl ).build();
    FileRecord fileRecord = new FileRecord( fileFromRepo, data, aclFromRepo, new HashMap<String, Serializable>() );
    idManager.register( fileRecord );

    process( fileRecord, null );
View Full Code Here

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

    RepositoryFile fileFromRepo =
        new RepositoryFile.Builder( file ).path(
            parentFolder.getPath()
                + ( parentFolder.getPath().endsWith( RepositoryFile.SEPARATOR ) ? "" : RepositoryFile.SEPARATOR )
                + file.getName() ).title( findTitle( file ) ).description( findDesc( file ) ).build();
    RepositoryFileAcl aclFromRepo = new RepositoryFileAcl.Builder( acl ).build();
    FileRecord fileRecord = new FileRecord( fileFromRepo, null, aclFromRepo, new HashMap<String, Serializable>() );
    idManager.register( fileRecord );
    parentFolder.addChild( fileRecord );
    return fileRecord.getFile();
  }
View Full Code Here

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

  private boolean hasAccess( final Serializable fileId, final EnumSet<RepositoryFilePermission> permissions ) {
    String username = currentUserProvider.getUser();
    List<String> roles = currentUserProvider.getRoles();

    RepositoryFileAcl acl = idManager.getFileById( fileId ).getAcl();
    if ( acl.getOwner().getType() == USER && acl.getOwner().getName().equals( username ) ) {
      return true; // owner can do anything
    }

    List<RepositoryFileAce> aces = internalGetEffectiveAces( fileId );
    for ( RepositoryFileAce ace : aces ) {
View Full Code Here

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

   * if there is no EntityAcl present.
   *
   * @return RepositoryFile
   */
  public RepositoryFileAcl getRepositoryFileAcl() throws ExportManifestFormatException {
    RepositoryFileAcl repositoryFileAcl;
    EntityAcl entityAcl = getEntityAcl();
    if ( entityAcl == null ) {
      return null;
    }

    ArrayList<RepositoryFileAce> repositoryFileAces = new ArrayList<RepositoryFileAce>();
    RepositoryFileSid rfs;
    for ( EntityAcl.Aces ace : entityAcl.getAces() ) {
      rfs = getSid( ace.getRecipient(), ace.getRecipientType() );
      HashSet<RepositoryFilePermission> permissionSet = new HashSet<RepositoryFilePermission>();
      for ( String permission : ace.getPermissions() ) {
        permissionSet.add( getPermission( permission ) );
      }
      RepositoryFileAce repositoryFileAce = new RepositoryFileAce( rfs, EnumSet.copyOf( permissionSet ) );
      repositoryFileAces.add( repositoryFileAce );
    }

    repositoryFileAcl =
        new RepositoryFileAcl( "", getSid( entityAcl.getOwner(), entityAcl.getOwnerType() ), entityAcl
            .isEntriesInheriting(), repositoryFileAces );

    return repositoryFileAcl;
  }
View Full Code Here

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

    doReturn( destFileDto ).when( fileService ).toFileDto( sourceFile, null, false );

    RepositoryFile destFile = mock( RepositoryFile.class );
    doReturn( destFile ).when( fileService ).toFile( destFileDto );

    RepositoryFileAcl acl = mock( RepositoryFileAcl.class );
    doReturn( acl ).when( fileService.repository ).getAcl( acl );

    IRepositoryFileData data = mock( IRepositoryFileData.class );
    doReturn( data ).when( fileService ).getData( sourceFile );
View Full Code Here

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

   */
  private void updateAcl( boolean newFile, RepositoryFile repositoryFile, RepositoryFileAcl repositoryFileAcl ) {
    getLogger().debug( "File " + ( newFile ? "is new" : "already exists" ) );
    if ( repositoryFileAcl != null
        && ( getImportSession().isApplyAclSettings() || getImportSession().isRetainOwnership() ) ) {
      RepositoryFileAcl manifestAcl = repositoryFileAcl;
      RepositoryFileAcl originalAcl = repository.getAcl( repositoryFile.getId() );

      // Determine who will own this file
      RepositoryFileSid newOwner;
      if ( getImportSession().isRetainOwnership() ) {
        if ( newFile ) {
          getLogger().debug( "Getting Owner from Session" );
          newOwner = new RepositoryFileSid( PentahoSessionHolder.getSession().getName(), RepositoryFileSid.Type.USER );
        } else {
          getLogger().debug( "Getting Owner from existing file" );
          newOwner = originalAcl.getOwner();
        }
      } else {
        getLogger().debug( "Getting Owner from Manifest" );
        newOwner = manifestAcl.getOwner();
      }

      // Determine the Aces we will use for this file
      RepositoryFileAcl useAclForPermissions; // The ACL we will use the permissions from
      if ( getImportSession().isApplyAclSettings() && ( getImportSession().isOverwriteAclSettings() || newFile ) ) {
        getLogger().debug( "Getting permissions from Manifest" );
        useAclForPermissions = manifestAcl;
      } else {
        if ( newFile ) {
          getLogger().debug( "Getting permissions from Default settings" );
          useAclForPermissions = getDefaultAcl( repositoryFile );
        } else {
          getLogger().debug( "Getting permissions from existing file" );
          useAclForPermissions = originalAcl;
        }
      }

      // Make the new Acl if it has changed from the orignal
      if ( !newOwner.equals( originalAcl.getOwner() ) || !useAclForPermissions.equals( originalAcl ) ) {
        RepositoryFileAcl updatedAcl =
            new RepositoryFileAcl( repositoryFile.getId(), newOwner, useAclForPermissions.isEntriesInheriting(),
                useAclForPermissions.getAces() );
        repository.updateAcl( updatedAcl );
      }
    }
  }
View Full Code Here

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

    assertNotNull( fileEntity.getEntityMetaData() );
    assertTrue( fileEntity.getEntityMetaData().isIsFolder() );

    RepositoryFile r = fileEntity.getRepositoryFile();
    try {
      RepositoryFileAcl rfa = fileEntity.getRepositoryFileAcl();
      assertNotNull( rfa.getAces() );
    } catch ( ExportManifestFormatException e ) {
      e.printStackTrace();
      fail( "Could not un-marshal to RepositoryFileAcl" );
    }
View Full Code Here

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

  }

  private RepositoryFileAcl createMockRepositoryAcl( Serializable id, String owner, boolean entriesInheriting,
      List<RepositoryFileAce> aces ) {
    RepositoryFileSid ownerSid = new RepositoryFileSid( owner );
    return new RepositoryFileAcl( id, ownerSid, entriesInheriting, aces );
  }
View Full Code Here

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

          new RepositoryFile.Builder( bundle.getName() ).hidden( isHiddenBundle( bundle ) ).title(
              RepositoryFile.DEFAULT_LOCALE,
              getTitle( bundle.getTitle() != null ? bundle.getTitle() : bundle.getName() ) ).versioned( true ).build();
      final Serializable parentId = checkAndCreatePath( repositoryPath, getImportSession().getCurrentManifestKey() );

      final RepositoryFileAcl acl = bundle.getAcl();
      if ( null == acl ) {
        return repository.createFile( parentId, file, data, bundle.getComment() );
      } else {
        return repository.createFile( parentId, file, data, acl, bundle.getComment() );
      }
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.