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

Examples of org.pentaho.platform.api.repository2.unified.data.sample.SampleRepositoryFileData


    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() );
    logger.info( "getChildren" );
    List<RepositoryFile> folder1ChildrenFiltered = repo.getChildren( new RepositoryRequest( String.valueOf( folder1.getId() ), true, -1, "*.sample" ) );
    assertNotNull( folder1ChildrenFiltered );
    assertEquals( 0, folder1ChildrenFiltered.size() );
    logger.info( "getDeletedFiles" );
    assertEquals( 0, repo.getDeletedFiles().size() );
    logger.info( "deleteFile" );
    repo.deleteFile( file1.getId(), null );
    logger.info( "getDeletedFiles" );
    assertEquals( 0, repo.getDeletedFiles( folder1.getPath(), "*.sample" ).size() );

    logger.info( "hasAccess" );
    assertFalse( repo.hasAccess( "/pentaho", EnumSet.of( RepositoryFilePermission.WRITE ) ) );

    logger.info( "getEffectiveAces" );
    List<RepositoryFileAce> folder1EffectiveAces = repo.getEffectiveAces( folder1.getId() );
    assertEquals( 1, folder1EffectiveAces.size() );

    logger.info( "getAcl" );
    RepositoryFileAcl folder1Acl = repo.getAcl( folder1.getId() );
    assertEquals( USERNAME_SUZY, folder1Acl.getOwner().getName() );

    logger.info( "updateAcl" );
    userRoleDao.createUser( tenantAcme, USERNAME_TIFFANY, PASSWORD, "", null );
    RepositoryFileAcl updatedFolder1Acl =
        repo.updateAcl( new RepositoryFileAcl.Builder( folder1Acl ).entriesInheriting( false ).ace(
            userNameUtils.getPrincipleId( tenantAcme, USERNAME_TIFFANY ), RepositoryFileSid.Type.USER,
            RepositoryFilePermission.ALL ).build() );
    assertNotNull( updatedFolder1Acl );
    assertEquals( 1, updatedFolder1Acl.getAces().size() );

    logger.info( "lockFile" );
    assertFalse( file1.isLocked() );
    repo.lockFile( file1.getId(), "I locked this file" );
    logger.info( "canUnlockFile" );
    assertTrue( repo.canUnlockFile( file1.getId() ) );
    logger.info( "unlockFile" );
    repo.unlockFile( file1.getId() );

    logger.info( "moveFile" );
    repo.moveFile( file1.getId(), ClientRepositoryPaths.getUserHomeFolderPath( USERNAME_SUZY ) + "/folder1", null );
    logger.info( "copyFile" );
    repo.copyFile( file1.getId(), ClientRepositoryPaths.getUserHomeFolderPath( USERNAME_SUZY )
        + "/folder1/fileB.whatever", null );
    RepositoryFile copiedFile = repo.getFile( ClientRepositoryPaths.getUserHomeFolderPath( USERNAME_SUZY )
        + "/folder1/fileB.whatever" );
    copiedFile = repo.updateFile( copiedFile, data, null );

    logger.info( "getVersionSummaries" );
    List<VersionSummary> versionSummaries = repo.getVersionSummaries( file1.getId() );
    assertNotNull( versionSummaries );
    // copy doesn't increase version number
    assertTrue( versionSummaries.size() >= 1 );
    assertEquals( USERNAME_SUZY, versionSummaries.get( 0 ).getAuthor() );

    logger.info( "getVersionSummary" );
    VersionSummary versionSummary = repo.getVersionSummary( file1.getId(), null );
    assertNotNull( versionSummary );
    assertNotNull( versionSummary.getId() );

    logger.info( "getFileAtVersion" );
    RepositoryFile file1AtVersion = repo.getFileAtVersion( file1.getId(), versionSummary.getId() );
    assertNotNull( file1AtVersion );
    assertEquals( versionSummary.getId(), file1AtVersion.getVersionId() );

    logger.info( "getTree" );
    RepositoryFileTree tree = repo.getTree( new RepositoryRequest( ClientRepositoryPaths.getRootFolderPath(), true, -1, null ) );
    assertNotNull( tree.getFile().getId() );

    logger.info( "getDataForReadInBatch" );
    List<NodeRepositoryFileData> result =
        repo.getDataForReadInBatch( Arrays.asList( file1, copiedFile ), NodeRepositoryFileData.class );
View Full Code Here


  @Test
  public void testBlockoutWillFireError() throws Exception {
    JobScheduleRequest mockJobScheduleRequest = mock( JobScheduleRequest.class );

    UnifiedRepositoryException mockUnifiedRepositoryException = mock( UnifiedRepositoryException.class );

    SchedulerException mockSchedulerException = mock( SchedulerException.class );

    Response mockUnifiedRepositoryExceptionResponse = mock( Response.class );
    doReturn( mockUnifiedRepositoryExceptionResponse ).when( schedulerResource )
View Full Code Here

    // copy doesn't increase version number
    assertTrue( versionSummaries.size() >= 1 );
    assertEquals( USERNAME_SUZY, versionSummaries.get( 0 ).getAuthor() );

    logger.info( "getVersionSummary" );
    VersionSummary versionSummary = repo.getVersionSummary( file1.getId(), null );
    assertNotNull( versionSummary );
    assertNotNull( versionSummary.getId() );

    logger.info( "getFileAtVersion" );
    RepositoryFile file1AtVersion = repo.getFileAtVersion( file1.getId(), versionSummary.getId() );
    assertNotNull( file1AtVersion );
    assertEquals( versionSummary.getId(), file1AtVersion.getVersionId() );

    logger.info( "getTree" );
    RepositoryFileTree tree = repo.getTree( new RepositoryRequest( ClientRepositoryPaths.getRootFolderPath(), true, -1, null ) );
    assertNotNull( tree.getFile().getId() );
View Full Code Here

        RepositoryFile metadata =
          unifiedRepository.getFile( etcMondrian + RepositoryFile.SEPARATOR + catalogName + RepositoryFile.SEPARATOR
            + "metadata" ); //$NON-NLS-1$

        if ( metadata != null ) {
          DataNode metadataNode =
            unifiedRepository.getDataForRead( metadata.getId(), NodeRepositoryFileData.class ).getNode();
          String datasourceInfo = metadataNode.getProperty( "datasourceInfo" ).getString(); //$NON-NLS-1$
          String definition = metadataNode.getProperty( "definition" ).getString(); //$NON-NLS-1$

          datasourcesXML.append( "<Catalog name=\"" + encoder.encodeForXML( catalogName ) + "\">\n" ); //$NON-NLS-1$ //$NON-NLS-2$
          datasourcesXML
            .append( "<DataSourceInfo>" + encoder.encodeForXML( datasourceInfo ) + "</DataSourceInfo>\n" ); //$NON-NLS-1$ //$NON-NLS-2$
          datasourcesXML.append( "<Definition>" + encoder.encodeForXML( definition ) + "</Definition>\n" ); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

    final TimeZone defaultTimeZone = TimeZone.getDefault();
    final String DATE_PROPERTY = "date"; //$NON-NLS-1$

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

    logger.info( "getReservedChars" );
    assertFalse( repo.getReservedChars().isEmpty() );
  }

  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

    } finally {
      Locale.setDefault( defaultLocale );
      TimeZone.setDefault( defaultTimeZone );
    }

    DataProperty property = result.getNode().getProperty( DATE_PROPERTY );
    assertNotNull( property );
    assertEquals( date, property.getDate() );
  }
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

TOP

Related Classes of org.pentaho.platform.api.repository2.unified.data.sample.SampleRepositoryFileData

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.