use of com.epam.pipeline.manager.metadata.parser.MetadataHeader in project cloud-pipeline by epam.
the class MetadataUploadManager method readFile.
private MetadataParsingResult readFile(Long parentId, MultipartFile file) {
try {
final Folder parent = folderManager.load(parentId);
String delimiter = MetadataParsingUtils.getDelimiterFromFileExtension(file.getOriginalFilename());
byte[] inputData = file.getBytes();
MetadataHeader header = new MetadataEntityHeaderParser(delimiter).readHeader(ByteSource.wrap(inputData).openStream());
validateTypes(header, parentId);
MetadataClass metadataClass = getOrCreateClass(header.getClassName());
return new MetadataEntityReader(delimiter, parent, metadataClass).readData(ByteSource.wrap(inputData).openStream(), header.getFields());
} catch (IOException e) {
throw new MetadataReadingException(e.getMessage(), e);
}
}
Aggregations