Examples of SimpleRepositoryFileData


Examples of org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData

  public void testExportFile() throws Exception {
    Serializable mockSerializable = mock( Serializable.class );
    when( repositoryFile.getId() ).thenReturn( mockSerializable );

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

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

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

    File mockFile = mock( File.class );
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData

   * @param zos
   */
  private void exportFileAsZip( RepositoryFile exportRepositoryFile, ZipOutputStream zos ) throws IOException {
    ZipEntry entry = new ZipEntry( exportRepositoryFile.getPath().substring( filePath.length() + 1 ) );
    zos.putNextEntry( entry );
    SimpleRepositoryFileData repoFileData =
        unifiedRepository.getDataForRead( exportRepositoryFile.getId(), SimpleRepositoryFileData.class );
    InputStream is = repoFileData.getStream();
    IOUtils.copy( is, zos );
    zos.closeEntry();
    is.close();
  }
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData

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

    SimpleRepositoryFileData repoFileData =
        unifiedRepository.getDataForRead( exportRepositoryFile.getId(), SimpleRepositoryFileData.class );
    InputStream is = repoFileData.getStream();
    File exportFile = new File( exportDirectory.getAbsolutePath() + File.separator + exportRepositoryFile.getName() );
    OutputStream os = new FileOutputStream( exportFile );
    IOUtils.copy( is, os );
    os.close();
    is.close();
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData

    if ( resourceNode.hasProperty( pentahoJcrConstants.getJCR_ENCODING() ) ) {
      encoding = resourceNode.getProperty( pentahoJcrConstants.getJCR_ENCODING() ).getString();
    }
    InputStream data = resourceNode.getProperty( pentahoJcrConstants.getJCR_DATA() ).getBinary().getStream();
    String mimeType = resourceNode.getProperty( pentahoJcrConstants.getJCR_MIMETYPE() ).getString();
    return new SimpleRepositoryFileData( data, encoding, mimeType );
  }
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData

  public <T extends IRepositoryFileData> T getData( Serializable fileId, Serializable versionId, Class<T> dataClass ) {
    File f = new File( fileId.toString() );
    T data = null;
    try {
      if( SimpleRepositoryFileData.class.getName().equals( dataClass.getName() ) ){
        data = (T) new SimpleRepositoryFileData ( new FileInputStream( f ), "UTF-8", "text/plain" );
     
      } else if( NodeRepositoryFileData.class.getName().equals( dataClass.getName() ) ) {
        throw new UnsupportedOperationException( "This operation is not support by this repository" );
      }
     
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData

    throw new UnsupportedOperationException( "This operation is not support by this repository" );
  }

  public void moveFile( Serializable fileId, String destRelPath, String versionMessage ) {
    RepositoryFile file = getFileById( fileId );
    SimpleRepositoryFileData data = getData( fileId, null, SimpleRepositoryFileData.class );
    deleteFile( fileId, versionMessage );
    createFile( null, file, data, null, versionMessage );
  }
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData

      in = dh.getInputStream();
      IOUtils.copy( in, fout );
      fout.close();
      foutClosed = true;
      InputStream fin = new BufferedInputStream( FileUtils.openInputStream( tmpFile ) );
      return new SimpleRepositoryFileData( fin, simpleJaxWsData.encoding, simpleJaxWsData.mimeType );
    } catch ( Exception e ) {
      throw new RuntimeException( e );
    } finally {
      try {
        // close the streams
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData

    byte[] data = dataString.getBytes( encoding );
    ByteArrayInputStream dataStream = new ByteArrayInputStream( data );
    final String mimeType = "text/plain";
    final String fileName = "helloworld.xaction";

    final SimpleRepositoryFileData content = new SimpleRepositoryFileData( dataStream, encoding, mimeType );

    // Try an inheriting folder delete
    //CHECKSTYLE IGNORE AvoidNestedBlocks FOR NEXT 3 LINES
    {
      RepositoryFile newFolder =
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData

    byte[] data = dataString.getBytes( encoding );
    ByteArrayInputStream dataStream = new ByteArrayInputStream( data );
    final String mimeType = "text/plain";
    final String fileName = "helloworld.xaction";

    final SimpleRepositoryFileData content = new SimpleRepositoryFileData( dataStream, encoding, mimeType );

    RepositoryFile newFolder = null;
    // Try an inheriting file delete
    //CHECKSTYLE IGNORE AvoidNestedBlocks FOR NEXT 3 LINES
    {
View Full Code Here

Examples of org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData

    byte[] data = dataString.getBytes( encoding );
    ByteArrayInputStream dataStream = new ByteArrayInputStream( data );
    final String mimeType = "text/plain";
    final String fileName = "helloworld.xaction";

    final SimpleRepositoryFileData content = new SimpleRepositoryFileData( dataStream, encoding, mimeType );
    RepositoryFile newFile =
        repo.createFile( parentFolder.getId(), new RepositoryFile.Builder( fileName ).build(), content, null );
    final String filePath = parentFolderPath + RepositoryFile.SEPARATOR + fileName;

    login( USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName } );
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.