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

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


    List<RepositoryFile> mockList = mock( List.class );
    when( unifiedRepository.getChildren( mockSerializable ) ).thenReturn( mockList );

    Iterator<RepositoryFile> mockIterator = mock( Iterator.class );
    RepositoryFile repositoryFile2 = mock( RepositoryFile.class );
    when( mockIterator.hasNext() ).thenReturn( true, false );
    when( mockIterator.next() ).thenReturn( repositoryFile2 );
    when( mockList.iterator() ).thenReturn( mockIterator );

    when( repositoryFile2.isFolder() ).thenReturn( false );

    when( repositoryFile2.getPath() ).thenReturn( REPO_PATH );

    Serializable mockSerializable2 = mock( Serializable.class );
    when( repositoryFile2.getId() ).thenReturn( mockSerializable2 );

    SimpleRepositoryFileData mockRepoFileData = mock( SimpleRepositoryFileData.class );
    when( unifiedRepository.getDataForRead( mockSerializable2, SimpleRepositoryFileData.class ) ).thenReturn(
        mockRepoFileData );
View Full Code Here


    List<RepositoryFile> mockList = mock( List.class );
    when( unifiedRepository.getChildren( mockSerializable ) ).thenReturn( mockList );

    Iterator<RepositoryFile> mockIterator = mock( Iterator.class );
    RepositoryFile repositoryFile2 = mock( RepositoryFile.class );
    when( mockIterator.hasNext() ).thenReturn( true, false );
    when( mockIterator.next() ).thenReturn( repositoryFile2 );
    when( mockList.iterator() ).thenReturn( mockIterator );

    when( repositoryFile2.isFolder() ).thenReturn( false );

    Serializable mockSerializable2 = mock( Serializable.class );
    when( repositoryFile2.getId() ).thenReturn( mockSerializable2 );

    SimpleRepositoryFileData mockRepoFileData = mock( SimpleRepositoryFileData.class );
    when( unifiedRepository.getDataForRead( mockSerializable2, SimpleRepositoryFileData.class ) ).thenReturn(
        mockRepoFileData );

    InputStream mockInputStream = new InputStream() {
      @Override
      public int read() throws IOException {
        return -1; // EOF
      }
    };
    when( mockRepoFileData.getStream() ).thenReturn( mockInputStream );

    String name2 = "name.txt";
    when( repositoryFile2.getName() ).thenReturn( name2 );

    File parentDir = new File( System.getProperty( "java.io.tmpdir" ) );
    File file = new File( parentDir, name );
    // already exists
    if ( file.isDirectory() ) {
View Full Code Here

   *
   * @throws java.io.IOException
   */
  public void doExport() throws IOException {
    exportDir = new File( filePath );
    RepositoryFile exportRepositoryFile = unifiedRepository.getFile( repoPath );

    if ( exportRepositoryFile == null ) {
      throw new FileNotFoundException( Messages.getInstance().getErrorString(
          "Exporter.ERROR_0001_INVALID_SOURCE_DIRECTORY", repoPath ) );
    }

    if ( exportRepositoryFile.isFolder() ) { // Handle recursive export
      exportDirectory( exportRepositoryFile, exportDir );
    } else { // Handle a single file export
      exportFile( exportRepositoryFile, exportDir );
    }
  }
View Full Code Here

   *
   * @return
   * @throws java.io.IOException
   */
  public File doExportAsZip() throws IOException {
    RepositoryFile exportRepositoryFile = unifiedRepository.getFile( repoPath );
    return doExportAsZip( exportRepositoryFile );
  }
View Full Code Here

  public boolean isLocaleFile( IRepositoryFileBundle file, String parentPath, byte[] bytes ) throws IOException {

    boolean isLocale = false;
    String fileName = file.getFile().getName();
    String actualFilePath = file.getPath();
    RepositoryFile localeRepositoryFile = file.getFile();
    if ( ImportSession.getSession().getManifest() != null && ImportSession.getSession().getManifest().getManifestInformation().getManifestVersion() != null ) {
      fileName = ExportFileNameEncoder.decodeZipFileName( fileName );
      actualFilePath = ExportFileNameEncoder.decodeZipFileName( actualFilePath );
      localeRepositoryFile = new RepositoryFile.Builder( localeRepositoryFile ).name(
          ExportFileNameEncoder.decodeZipFileName( localeRepositoryFile.getName() ) ).build();
    }
    int sourceVersion = 0; // 0 = Not a local file, 1 = 4.8 .properties file, 2= Sugar 5.0 .local file
    if ( fileName.endsWith( PROPERTIES_EXT ) ) {
      sourceVersion = 1;
    } else if ( fileName.endsWith( LOCALE_EXT ) ) {
View Full Code Here

    return nodeToFile( session, pentahoJcrConstants, pathConversionHelper, lockHelper, node, false, null );
  }

  private static RepositoryFile getRootFolder( final Session session ) throws RepositoryException {
    Node node = session.getRootNode();
    RepositoryFile file =
        new RepositoryFile.Builder( node.getIdentifier(), "" ).folder( true ).versioned( false ).path( //$NON-NLS-1$
            JcrStringHelper.pathDecode( node.getPath() ) ).build();
    return file;
  }
View Full Code Here

      lockOwner = lockHelper.getLockOwner( session, pentahoJcrConstants, lock );
      lockDate = lockHelper.getLockDate( session, pentahoJcrConstants, lock );
      lockMessage = lockHelper.getLockMessage( session, pentahoJcrConstants, lock );
    }

    RepositoryFile file =
        new RepositoryFile.Builder( id, name ).createdDate( created ).creatorId( creatorId ).lastModificationDate(
            lastModified ).folder( folder ).versioned( versioned ).path( path ).versionId( versionId ).fileSize(
            fileSize ).locked( locked ).lockDate( lockDate ).hidden( hidden ).lockMessage( lockMessage ).lockOwner(
            lockOwner ).title( title ).description( description ).locale( pentahoLocale.toString() )
            .localePropertiesMap( localePropertiesMap ).build();
View Full Code Here

    }

    while ( nodeIterator.hasNext() ) {
      Node node = nodeIterator.nextNode();
      if ( isSupportedNodeType( pentahoJcrConstants, node ) ) {
        RepositoryFile file = nodeToFile( session, pentahoJcrConstants, pathConversionHelper, lockHelper, node );
        if ( !repositoryRequest.isShowHidden() ) {
          if ( !file.isHidden() ) {
            children.add( file );
          }
        } else {
          children.add( file );
        }
View Full Code Here

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

    } else {
      sid = new RepositoryFileSid( principal.getName(), RepositoryFileSid.Type.USER );
    }
    Privilege[] privileges = acEntry.getPrivileges();
    IPermissionConversionHelper permissionConversionHelper = new DefaultPermissionConversionHelper( session );
    return new RepositoryFileAce( sid, permissionConversionHelper.privilegesToPentahoPermissions( session,
      privileges ) );
  }
View Full Code Here

TOP

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

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.