Search in sources :

Example 1 with MetadataFileFormat

use of com.epam.pipeline.manager.metadata.writer.MetadataFileFormat in project cloud-pipeline by epam.

the class MetadataDownloadManager method getInputStream.

public InputStream getInputStream(final Long folderId, final String entityClass, final String fileExtension) {
    final MetadataFileFormat fileFormat = retrieveMetadataFileFormat(fileExtension);
    final List<MetadataEntity> entities = retrieveMetadataEntities(folderId, entityClass);
    final StringWriter stringWriter = new StringWriter();
    final MetadataWriter metadataWriter = metadataWriterProvider.getMetadataWriter(stringWriter, fileFormat);
    metadataWriter.writeEntities(entityClass, entities);
    try {
        return new StringInputStream(stringWriter.toString());
    } catch (IOException e) {
        throw new MetadataWriterException(messageHelper.getMessage(MessageConstants.ERROR_METADATA_ENTITY_WRITING_BAD_ENCODING), e);
    }
}
Also used : MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) StringInputStream(com.amazonaws.util.StringInputStream) StringWriter(java.io.StringWriter) MetadataWriterException(com.epam.pipeline.manager.metadata.writer.MetadataWriterException) IOException(java.io.IOException) MetadataWriter(com.epam.pipeline.manager.metadata.writer.MetadataWriter) MetadataFileFormat(com.epam.pipeline.manager.metadata.writer.MetadataFileFormat)

Aggregations

StringInputStream (com.amazonaws.util.StringInputStream)1 MetadataEntity (com.epam.pipeline.entity.metadata.MetadataEntity)1 MetadataFileFormat (com.epam.pipeline.manager.metadata.writer.MetadataFileFormat)1 MetadataWriter (com.epam.pipeline.manager.metadata.writer.MetadataWriter)1 MetadataWriterException (com.epam.pipeline.manager.metadata.writer.MetadataWriterException)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1