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

Examples of org.pentaho.platform.api.repository2.unified.data.node.DataNode


        repo.createFolder( f.getId(), new RepositoryFile.Builder( "folder1" ).folder( true ).build(), null );
    assertNotNull( folder1 );
    assertEquals( "folder1", folder1.getName() );
    assertNotNull( folder1.getId() );

    NodeRepositoryFileData data = makeNodeRepositoryFileData1();
    logger.info( "createFile" );
    RepositoryFile file1 =
        repo.createFile( folder1.getId(), new RepositoryFile.Builder( "file1.whatever" ).versioned( true ).build(),
            data, null );
    assertNotNull( file1 );
    assertNotNull( file1.getId() );

    logger.info( "getDataForRead" );
    NodeRepositoryFileData file1Data = repo.getDataForRead( file1.getId(), NodeRepositoryFileData.class );
    assertNotNull( file1Data );
    assertEquals( "testNode", file1Data.getNode().getName() );
    assertEquals( "hello world", file1Data.getNode().getProperty( "prop1" ).getString() );
    assertEquals( false, file1Data.getNode().getProperty( "prop2" ).getBoolean() );
    assertEquals( DataPropertyType.BOOLEAN, file1Data.getNode().getProperty( "prop2" ).getType() );
    assertEquals( 12L, file1Data.getNode().getProperty( "prop3" ).getLong() );

    logger.info( "createFile (binary)" );
    SimpleRepositoryFileData simpleData =
        new SimpleRepositoryFileData( new ByteArrayInputStream( "Hello World!".getBytes( "UTF-8" ) ), "UTF-8",
            "text/plain" );
View Full Code Here


  private NodeRepositoryFileData makeNodeRepositoryFileData1() {
    DataNode node = new DataNode( "testNode" );
    node.setProperty( "prop1", "hello world" );
    node.setProperty( "prop2", false );
    node.setProperty( "prop3", 12L );
    return new NodeRepositoryFileData( node );
  }
View Full Code Here

    logger.debug( MessageFormat.format( msg, args ) );
  }

  protected String extractUrl( RepositoryFile file ) {

    SimpleRepositoryFileData data = null;

    data = repository.getDataForRead( file.getId(), SimpleRepositoryFileData.class );
    StringWriter writer = new StringWriter();
    try {
      IOUtils.copy( data.getInputStream(), writer );
    } catch ( IOException e ) {
      return ""; //$NON-NLS-1$
    }

    String props = writer.toString();
View Full Code Here

        throw new IllegalArgumentException();
      }
    }

    try {
      SimpleRepositoryFileData fileData =
          getRepository().getDataForRead( repositoryFile.getId(), SimpleRepositoryFileData.class );
      final InputStream is = fileData.getInputStream();

      // copy streaming output
      StreamingOutput streamingOutput = getStreamingOutput( is );

      RepositoryFileToStreamWrapper wrapper = new RepositoryFileToStreamWrapper();
View Full Code Here

  public Document getSolutionDocument( final String documentPath, final RepositoryFilePermission actionOperation ) {

    RepositoryFile file = repository.getFile( documentPath );

    Document document = null;
    SimpleRepositoryFileData data = null;
    if ( file != null ) {
      data = repository.getDataForRead( file.getId(), SimpleRepositoryFileData.class );
      if ( data != null ) {
        try {
          document = XmlDom4JHelper.getDocFromStream( data.getStream() );
        } catch ( Throwable t ) {
          logger.error( Messages.getInstance().getErrorString(
              "ActionSequenceJCRHelper.ERROR_0017_INVALID_XML_DOCUMENT", documentPath ), t ); //$NON-NLS-1$
          return null;
        }
View Full Code Here

  public String getURL( String filePath ) {
    RepositoryFile file = repository.getFile( filePath );
    if ( file == null || !file.getName().endsWith( ".url" ) ) { //$NON-NLS-1$
      return ""; //$NON-NLS-1$
    }
    SimpleRepositoryFileData data = null;

    data = repository.getDataForRead( file.getId(), SimpleRepositoryFileData.class );
    StringWriter writer = new StringWriter();
    try {
      IOUtils.copy( data.getStream(), writer );
    } catch ( IOException e ) {
      return ""; //$NON-NLS-1$
    }

    String props = writer.toString();
View Full Code Here

  }

  protected String getLocaleText( final String key, final RepositoryFile file ) throws IOException {
    if ( file != null ) {

      SimpleRepositoryFileData data = null;
      data = repository.getDataForRead( file.getId(), SimpleRepositoryFileData.class );

      Properties p = new Properties();
      p.load( data.getStream() );

      String localeText = p.getProperty( key.substring( 1 ) );
      if ( localeText == null ) {
        localeText = p.getProperty( key );
      }
View Full Code Here

  }

  public void testFileMetadata() throws Exception {
    final RepositoryFile testfile =
        repository.createFile( repository.getFile( "/etc" ).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 );
View Full Code Here

    assertEquals( false, file1Data.getNode().getProperty( "prop2" ).getBoolean() );
    assertEquals( DataPropertyType.BOOLEAN, file1Data.getNode().getProperty( "prop2" ).getType() );
    assertEquals( 12L, file1Data.getNode().getProperty( "prop3" ).getLong() );

    logger.info( "createFile (binary)" );
    SimpleRepositoryFileData simpleData =
        new SimpleRepositoryFileData( new ByteArrayInputStream( "Hello World!".getBytes( "UTF-8" ) ), "UTF-8",
            "text/plain" );
    RepositoryFile simpleFile =
        repo.createFile( folder1.getId(), new RepositoryFile.Builder( "file2.whatever" ).versioned( true ).build(),
            simpleData, null );

    Serializable simpleVersion = simpleFile.getVersionId();

    logger.info( "getDataForRead (binary)" );
    SimpleRepositoryFileData simpleFileData = repo.getDataForRead( simpleFile.getId(), SimpleRepositoryFileData.class );
    assertNotNull( simpleFileData );
    assertEquals( "Hello World!", IOUtils.toString( simpleFileData.getInputStream(), simpleFileData.getEncoding() ) );
    assertEquals( "text/plain", simpleFileData.getMimeType() );
    assertEquals( "UTF-8", simpleFileData.getEncoding() );

    logger.info( "updateFile (binary)" );
    simpleData =
        new SimpleRepositoryFileData( new ByteArrayInputStream( "Ciao World!".getBytes( "UTF-8" ) ), "UTF-8",
            "text/plain" );
    simpleFile = repo.updateFile( simpleFile, simpleData, null );
    assertNotNull( simpleFile.getLastModifiedDate() );

    logger.info( "getDataForRead (binary)" );
    simpleFileData = repo.getDataForRead( simpleFile.getId(), SimpleRepositoryFileData.class );
    assertNotNull( simpleFileData );
    assertEquals( "Ciao World!", IOUtils.toString( simpleFileData.getInputStream(), simpleFileData.getEncoding() ) );

    logger.info( "getDataForReadAtVersion (binary)" );
    simpleFileData = repo.getDataAtVersionForRead( simpleFile.getId(), simpleVersion, SimpleRepositoryFileData.class );
    assertNotNull( simpleFileData );
    assertEquals( "Hello World!", IOUtils.toString( simpleFileData.getInputStream(), simpleFileData.getEncoding() ) );

    logger.info( "getChildren" );
    List<RepositoryFile> folder1Children = repo.getChildren( new RepositoryRequest( String.valueOf( folder1.getId() ), true, -1, null ) );
    assertNotNull( folder1Children );
    assertEquals( 2, folder1Children.size() );
View Full Code Here

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

TOP

Related Classes of org.pentaho.platform.api.repository2.unified.data.node.DataNode

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.