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

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


    return actionSequence;
  }

  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;
        }
      } else {
        logger.error( Messages.getInstance().getErrorString(
            "ActionSequenceJCRHelper.ERROR_0019_NO_DATA_IN_FILE", file.getName() ) ); //$NON-NLS-1$
        return null;
      }
      if ( ( document == null ) && ( file != null ) && ( data != null ) ) {
        // the document exists but cannot be parsed
        logger.error( Messages.getInstance().getErrorString(
View Full Code Here


    return document;
  }

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

  protected String getLocaleString( final String key, String baseName, final RepositoryFile baseFile,
      boolean marchUpParents ) {

    String parentPath = FilenameUtils.getFullPathNoEndSeparator( baseFile.getPath() );

    RepositoryFile searchDir = repository.getFile( parentPath );
    if ( baseFile.isFolder() ) {
      searchDir = baseFile;
    }
    try {
      boolean searching = true;
      while ( searching ) {

        RepositoryFile[] propertyFiles = listFiles( searchDir, new IFileFilter() {
          public boolean accept( RepositoryFile file ) {
            return file.getName().toLowerCase().endsWith( PROPERTIES_SUFFIX );
          }
        } );
        RepositoryFile blcv = null;
        RepositoryFile blc = null;
        RepositoryFile bl = null;
        RepositoryFile b = null;
        for ( RepositoryFile element : propertyFiles ) {
          if ( element.getName().equalsIgnoreCase(
              baseName + '_' + getLocale().getLanguage() + '_' + getLocale().getCountry() + '_'
                  + getLocale().getVariant() + PROPERTIES_SUFFIX ) ) {
            blcv = element;
View Full Code Here

    // you have to have PublishAction in order to get dir as zip
    if ( !getPolicy().isAllowed( PublishAction.NAME ) ) {
      return buildStatusResponse( FORBIDDEN );
    }

    RepositoryFile repoFile = getRepository().getFile( path );

    if ( repoFile == null ) {
      // file does not exist or is not readable but we can't tell at this point
      return buildStatusResponse( NOT_FOUND );
    }
View Full Code Here

  } )

  // have to accept anything for browsers to work
  public String doIsParameterizable( @PathParam ( "pathId" ) String pathId ) throws FileNotFoundException {
    boolean hasParameterUi = false;
    RepositoryFile repositoryFile = getRepository().getFile( fileService.idToPath( pathId ) );
    if ( repositoryFile != null ) {
      try {
        hasParameterUi = hasParameterUi( repositoryFile );
      } catch ( NoSuchBeanDefinitionException e ) {
        // Do nothing.
      }
    }
    boolean hasParameters = false;
    if ( hasParameterUi ) {
      try {
        IContentGenerator parameterContentGenerator = getContentGenerator( repositoryFile );
        if ( parameterContentGenerator != null ) {
          ByteArrayOutputStream outputStream = getByteArrayOutputStream();
          parameterContentGenerator.setOutputHandler( new SimpleOutputHandler( outputStream, false ) );
          parameterContentGenerator.setMessagesList( new ArrayList<String>() );

          Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();

          SimpleParameterProvider parameterProvider = getSimpleParameterProvider();
          parameterProvider.setParameter( "path", encode( repositoryFile.getPath() ) );
          parameterProvider.setParameter( "renderMode", "PARAMETER" );
          parameterProviders.put( IParameterProvider.SCOPE_REQUEST, parameterProvider );

          parameterContentGenerator.setParameterProviders( parameterProviders );
          parameterContentGenerator.setSession( getSession() );
View Full Code Here

    doReturn( true ).when( fileResource ).isPathValid( path );

    doReturn( true ).when( fileResource.policy ).isAllowed( PublishAction.NAME );

    RepositoryFile mockFile = mock( RepositoryFile.class );
    doReturn( mockFile ).when( fileResource.repository ).getFile( path );

    Response mockResponse = mock( Response.class );
    doReturn( mockResponse ).when( fileResource ).doGetDirAsZip( mockFile );
View Full Code Here

    verify( fileResource.policy, times( 2 ) ).isAllowed( PublishAction.NAME );
  }

  @Test
  public void testDoGetDirAsZipWithFile() throws Exception {
    RepositoryFile mockRepositoryFile = mock( RepositoryFile.class );

    String path = "path";
    doReturn( path ).when( mockRepositoryFile ).getPath();

    Exporter mockExporter = mock( Exporter.class );
View Full Code Here

    verify( fileResource, times( 1 ) ).buildOkResponse( mockOutput, FileResource.APPLICATION_ZIP );
  }

  @Test
  public void testDoGetDirAsZipWithFileError() {
    RepositoryFile mockRepositoryFile = mock( RepositoryFile.class );

    String path = "path";
    doReturn( path ).when( mockRepositoryFile ).getPath();

    Exception mockException = mock( RuntimeException.class );
View Full Code Here

    String pathId = "pathId";

    String path = "path";
    doReturn( path ).when( fileResource.fileService ).idToPath( pathId );

    RepositoryFile mockRepositoryFile = mock( RepositoryFile.class );
    doReturn( mockRepositoryFile ).when( fileResource.repository ).getFile( path );

    doReturn( true ).when( fileResource ).hasParameterUi( mockRepositoryFile );

    IContentGenerator mockContentGenerator = mock( IContentGenerator.class );
View Full Code Here

    String pathId = "pathId";

    String path = "path";
    doReturn( path ).when( fileResource.fileService ).idToPath( pathId );

    RepositoryFile mockRepositoryFile = mock( RepositoryFile.class );
    doReturn( mockRepositoryFile ).when( fileResource.repository ).getFile( path );

    Exception mockNoSuchBeanDefinitionException = mock( NoSuchBeanDefinitionException.class );
    doThrow( mockNoSuchBeanDefinitionException ).when( fileResource ).hasParameterUi( mockRepositoryFile );
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.