use of org.eclipse.vorto.repository.core.impl.StorageItem in project vorto by eclipse.
the class AbstractModelImporter method doImport.
@Override
public List<ModelInfo> doImport(String uploadHandleId, Context context) {
StorageItem uploadedItem = this.uploadStorage.get(uploadHandleId);
if (uploadedItem == null) {
throw new ModelImporterException(String.format("No uploaded file found for handleId '%s'", uploadHandleId));
}
List<ModelInfo> importedModels = new ArrayList<>();
try {
if (handleZipUploads() && isZipFile(uploadedItem.getValue())) {
getUploadedFilesFromZip(uploadedItem.getValue().getContent()).stream().forEach(extractedFile -> {
List<ModelResource> resources = this.convert(extractedFile, context);
importedModels.addAll(sortAndSaveToRepository(resources, extractedFile, context));
});
} else {
List<ModelResource> resources = this.convert(uploadedItem.getValue(), context);
importedModels.addAll(sortAndSaveToRepository(resources, uploadedItem.getValue(), context));
}
} finally {
this.uploadStorage.remove(uploadHandleId);
}
return importedModels;
}
Aggregations