Examples of SimpleRepositoryFileData


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

    doReturn( true ).when( mockWhiteList ).accept( anyString() );

    RepositoryFile mockRepoFile = mock( RepositoryFile.class );
    doReturn( mockRepoFile ).when( fileService.repository ).getFile( anyString() );

    SimpleRepositoryFileData mockData = mock( SimpleRepositoryFileData.class );
    doReturn( mockData ).when( fileService.repository ).getDataForRead( any( Serializable.class ), any( Class.class ) );

    InputStream mockInputStream = mock( InputStream.class );
    doReturn( mockInputStream ).when( mockData ).getInputStream();
View Full Code Here

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

  }

  public InputStream convert( final Serializable fileId ) {
    InputStream stream = null;
    if ( repository != null ) {
      SimpleRepositoryFileData fileData = repository.getDataForRead( fileId, SimpleRepositoryFileData.class );
      stream = fileData.getStream();
    }
    return stream;
  }
View Full Code Here

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

    }
    return stream;
  }

  public IRepositoryFileData convert( final InputStream inputStream, final String charset, final String mimeType ) {
    return new SimpleRepositoryFileData( inputStream, charset, mimeType );
  }
View Full Code Here

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

      java.io.ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
      ex.printStackTrace( new java.io.PrintStream( byteArrayOutputStream ) );
      throw new DomainStorageException( byteArrayOutputStream.toString(), ex );
    }

    final SimpleRepositoryFileData data =
        new SimpleRepositoryFileData( inputStream2, DEFAULT_ENCODING, DOMAIN_MIME_TYPE );
    if ( domainFile == null ) {
      final RepositoryFile newDomainFile = createUniqueFile( domainId, null, data );
    } else {
      repository.updateFile( domainFile, data, null );
    }
View Full Code Here

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

    Domain domain = null;
    try {
      // Load the domain file
      final RepositoryFile file = getMetadataRepositoryFile( domainId );
      if ( file != null ) {
        SimpleRepositoryFileData data = repository.getDataForRead( file.getId(), SimpleRepositoryFileData.class );
        if ( data != null ) {
          domain = xmiParser.parseXmi( data.getStream() );
          domain.setId( domainId );
          logger.debug( "loaded domain" );

          // Load any I18N bundles
          loadLocaleStrings( domainId, domain );
View Full Code Here

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

        if ( !overwrite && localeFile != null ) {
          throw new DomainStorageException( messages.getErrorString(
              "PentahoMetadataDomainRepository.ERROR_0009_LOCALE_ALREADY_EXISTS", domainId, locale ), null );
        }

        final SimpleRepositoryFileData data =
            new SimpleRepositoryFileData( inputStream, DEFAULT_ENCODING, LOCALE_MIME_TYPE );
        if ( localeFile == null ) {
          final RepositoryFile newLocaleFile = createUniqueFile( domainId, locale, data );
          metadataMapping.addLocale( domainId, locale, newLocaleFile );
        } else {
          repository.updateFile( localeFile, data, null );
View Full Code Here

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

  }

  protected Properties loadProperties( final RepositoryFile bundle ) {
    try {
      Properties properties = null;
      final SimpleRepositoryFileData bundleData =
          repository.getDataForRead( bundle.getId(), SimpleRepositoryFileData.class );
      if ( bundleData != null ) {
        properties = new Properties();
        properties.load( bundleData.getStream() );
      } else {
        logger.warn( "Could not load properties from repository file: " + bundle.getName() );
      }
      return properties;
    } catch ( IOException e ) {
View Full Code Here

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

      Map<String, Serializable> metadata = repo.getFileMetadata( sourceFile.getId() );
      String lineageId = (String) params.get( QuartzScheduler.RESERVEDMAPKEY_LINEAGE_ID );
      metadata.put( QuartzScheduler.RESERVEDMAPKEY_LINEAGE_ID, lineageId );
      repo.setFileMetadata( sourceFile.getId(), metadata );
      // send email
      SimpleRepositoryFileData data =
          repo.getDataForRead( sourceFile.getId(), SimpleRepositoryFileData.class );     
     
      // if email is setup and we have tos, then do it
      Emailer emailer = new Emailer();
      if ( !emailer.setup() ) {
        // email not configured
        return;
      }
      String to = (String) actionParams.get( "_SCH_EMAIL_TO" );
      String cc = (String) actionParams.get( "_SCH_EMAIL_CC" );
      String bcc = (String) actionParams.get( "_SCH_EMAIL_BCC" );
      if ( ( to == null || "".equals( to ) ) && ( cc == null || "".equals( cc ) )
          && ( bcc == null || "".equals( bcc ) ) ) {
        // no destination
        return;
      }
      emailer.setTo( to );
      emailer.setCc( cc );
      emailer.setBcc( bcc );
      emailer.setAttachment( data.getInputStream() );
      emailer.setAttachmentName( "attachment" );
      String attachmentName = (String) actionParams.get( "_SCH_EMAIL_ATTACHMENT_NAME" );
      if ( attachmentName != null && !"".equals( attachmentName ) ) {
        String path = filePath;
        if ( path.endsWith( ".*" ) ) {
          path = path.replace( ".*", "" );
        }
        String extension = MimeHelper.getExtension( data.getMimeType() );
        if ( extension == null ) {
          extension = ".bin";
        }
        if ( !attachmentName.endsWith( extension ) ) {
          emailer.setAttachmentName( attachmentName + extension );
        } else {
          emailer.setAttachmentName( attachmentName );
        }
      } else if ( data != null ) {
        String path = filePath;
        if ( path.endsWith( ".*" ) ) {
          path = path.replace( ".*", "" );
        }
        String extension = MimeHelper.getExtension( data.getMimeType() );
        if ( extension == null ) {
          extension = ".bin";
        }
        path = path.substring( path.lastIndexOf( "/" ) + 1, path.length() );
        if ( !path.endsWith( extension ) ) {
          emailer.setAttachmentName( path + extension );
        } else {
          emailer.setAttachmentName( path );
        }
      }
      if ( data == null || data.getMimeType() == null || "".equals( data.getMimeType() ) ) {
        emailer.setAttachmentMimeType( "binary/octet-stream" );
      } else {
        emailer.setAttachmentMimeType( data.getMimeType() );
      }
      String subject = (String) actionParams.get( "_SCH_EMAIL_SUBJECT" );
      if ( subject != null && !"".equals( subject ) ) {
        emailer.setSubject( subject );
      } else {
View Full Code Here

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

  @Test
  public void testGetFile() throws Exception {
    final MockUnifiedRepository repository = new MockUnifiedRepository( new SpringSecurityCurrentUserProvider() );
    final RepositoryUtils repositoryUtils = new RepositoryUtils( repository );

    final SimpleRepositoryFileData data =
        new SimpleRepositoryFileData( new ByteArrayInputStream( "Test".getBytes() ), "UTF-8", "text/plain" );
    RepositoryFile test = repositoryUtils.getFile( "/public/one/two/three.prpt", data, true, true, null );
    assertNotNull( test );
    assertEquals( "The filename is invalid", "three.prpt", test.getName() );
    assertEquals( "The path is invalid", "/public/one/two/three.prpt", test.getPath() );
    assertFalse( "The file should not be defined as a folder", test.isFolder() );
View Full Code Here

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

    // FIXME: not a good idea that we assume we are dealing with text. Best if this is somehow moved to the
    // RepositoryFileWriter
    // but I couldn't figure out a clean way to do that. For now, charsetName is passed in here and we use it if
    // available.
    final SimpleRepositoryFileData payload = new SimpleRepositoryFileData( bis, charsetName, mimeType );
    if ( !flushed ) {
      RepositoryFile file = repository.getFile( path );
      RepositoryFile parentFolder = getParent( path );
      String baseFileName = RepositoryFilenameUtils.getBaseName( path );
      String extension = RepositoryFilenameUtils.getExtension( path );
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.