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

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


    ITenant mainTenant_1 =
        tenantManager.createTenant( systemTenant, MAIN_TENANT_1, tenantAdminRoleName,
            tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME );
    userRoleDao.createUser( mainTenant_1, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName } );
    login( USERNAME_ADMIN, mainTenant_1, new String[] { tenantAuthenticatedRoleName } );
    RepositoryFile file = repo.getFile( ClientRepositoryPaths.getPublicFolderPath() );
    final RepositoryFile testfile =
        repo.createFile( file.getId(), new RepositoryFile.Builder( "testfile" ).build(),
            new SimpleRepositoryFileData( new ByteArrayInputStream( "test".getBytes() ), "UTF-8",
              "text/plain" ), null );
    //CHECKSTYLE IGNORE AvoidNestedBlocks FOR NEXT 3 LINES
    {
      // Make sure the repository is setup correctly
      assertNotNull( testfile );
      assertNotNull( testfile.getId() );
      final Map<String, Serializable> fileMetadata = repo.getFileMetadata( testfile.getId() );
      assertNotNull( fileMetadata );
      assertEquals( 0, fileMetadata.size() );
    }

    final Map<String, Serializable> metadata = new HashMap<String, Serializable>();
    metadata.put( "sample key", "sample value" );
    metadata.put( "complex key?", "\"an even more 'complex' value\"! {and them some}" );

    adapter.setFileMetadata( testfile.getId(), metadata );
    //CHECKSTYLE IGNORE AvoidNestedBlocks FOR NEXT 3 LINES
    {
      // Make sure the repository sees the metadata
      assertNotNull( testfile );
      assertNotNull( testfile.getId() );
      final Map<String, Serializable> fileMetadata = repo.getFileMetadata( testfile.getId() );
      assertNotNull( fileMetadata );
      assertEquals( 2, fileMetadata.size() );
    }
    //CHECKSTYLE IGNORE AvoidNestedBlocks FOR NEXT 3 LINES
    {
      // Make sure we can get the same metadata back via the web service
      final Map<String, Serializable> fileMetadata = adapter.getFileMetadata( testfile.getId() );
      assertNotNull( fileMetadata );
      assertEquals( 2, fileMetadata.size() );
      assertTrue( StringUtils.equals( "sample value", (String) fileMetadata.get( "sample key" ) ) );
      assertTrue( StringUtils.equals( "\"an even more 'complex' value\"! {and them some}", (String) fileMetadata
          .get( "complex key?" ) ) );
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 );

    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

      final PentahoJcrConstants pentahoJcrConstants, final IPathConversionHelper pathConversionHelper,
      final ILockHelper lockHelper, final Node fileNode, final int depth, final String childNodeFilter,
      final boolean showHidden, IRepositoryAccessVoterManager accessVoterManager,
      RepositoryRequest.FILES_TYPE_FILTER types, MutableBoolean foundFiltered ) throws RepositoryException {

    RepositoryFile rootFile =
        nodeToFile( session, pentahoJcrConstants, pathConversionHelper, lockHelper, fileNode, false, null );
    if ( ( !showHidden && rootFile.isHidden() )
        || ( !accessVoterManager.hasAccess( rootFile, RepositoryFilePermission.READ, JcrRepositoryFileAclUtils.getAcl(
            session, pentahoJcrConstants, rootFile.getId() ), PentahoSessionHolder.getSession() ) ) ) {
      return null;
    }
    List<RepositoryFileTree> children;
    HashSet<Node> childrenFolderSet;
    // if depth is neither negative (indicating unlimited depth) nor positive (indicating at least one more level
View Full Code Here

TOP

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

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.