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

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


   * Factory for {@link PathPropertyPair} instances.
   */
  public static PathPropertyPair pathPropertyPair( final String path, final Date value ) {
    checkPath( path );
    String[] pathSegments = path.split( "/" );
    return new PathPropertyPair( path, new DataProperty( pathSegments[pathSegments.length - 1], value,
        DataPropertyType.DATE ) );
  }
View Full Code Here


   * Factory for {@link PathPropertyPair} instances.
   */
  public static PathPropertyPair pathPropertyPair( final String path, final Serializable value ) {
    checkPath( path );
    String[] pathSegments = path.split( "/" );
    return new PathPropertyPair( path, new DataProperty( pathSegments[pathSegments.length - 1], value,
        DataPropertyType.REF ) );
  }
View Full Code Here

    }

    @Override
    public boolean matchesSafely( final NodeRepositoryFileData data ) {
      for ( PathPropertyPair pair : pairs ) {
        DataProperty expectedProperty = pair.getProperty();
        String[] pathSegments = pair.getPath().substring( 1 ).split( "/" );
        DataNode currentNode = data.getNode();
        if ( !currentNode.getName().equals( pathSegments[0] ) ) {
          return false;
        }
        for ( int i = 1; i < pathSegments.length - 1; i++ ) {
          currentNode = currentNode.getNode( pathSegments[i] );
          if ( currentNode == null ) {
            return false;
          }
        }
        DataProperty actualProperty = currentNode.getProperty( pathSegments[pathSegments.length - 1] );
        if ( !expectedProperty.equals( actualProperty ) ) {
          return false;
        }
      }
      return true;
View Full Code Here

    RepositoryFile foundFile = repo.getFile( expectedPath );
    assertNotNull( foundFile );

    DataNode foundNode = repo.getDataForRead( newFile.getId(), NodeRepositoryFileData.class ).getNode();
    DataProperty d = foundNode.getProperty( "urei2" );
    assertNotNull( d );
    assertTrue( d.getType() == DataPropertyType.REF );
    assertTrue( d.getRef().getId() == DataNodeRef.REF_MISSING );

    // now change permissions back so she can get access to the node, confirm things are back to normal

    login( USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName } );
    newAcl = new RepositoryFileAcl.Builder( acl ).entriesInheriting( true ).clearAces().build();
    repo.updateAcl( newAcl );
    login( USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName } );
    foundFile = repo.getFile( expectedPath );
    assertNotNull( foundFile );

    foundNode = repo.getDataForRead( newFile.getId(), NodeRepositoryFileData.class ).getNode();
    d = foundNode.getProperty( "urei2" );
    assertNotNull( d );
    assertTrue( d.getType() == DataPropertyType.REF );
    assertTrue( d.getRef().getId().equals( sampleFile.getId() ) );
  }
View Full Code Here

    NodeRepositoryFileDataAdapter adapter = new NodeRepositoryFileDataAdapter();
    Date date = new Date();
    DataNode node = new DataNode( "" ); //$NON-NLS-1$
    node.setProperty( DATE_PROPERTY, date );
    NodeRepositoryFileData data = new NodeRepositoryFileData( node );
    NodeRepositoryFileData result;

    // Convert using the provided locale
    try {
      Locale.setDefault( locale );
      TimeZone.setDefault( timeZone );
      NodeRepositoryFileDataDto dto = adapter.marshal( data );
      result = adapter.unmarshal( dto );
    } finally {
      Locale.setDefault( defaultLocale );
      TimeZone.setDefault( defaultTimeZone );
    }

    DataProperty property = result.getNode().getProperty( DATE_PROPERTY );
    assertNotNull( property );
    assertEquals( date, property.getDate() );
  }
View Full Code Here

        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

TOP

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

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.