Search in sources :

Example 1 with StorageItem

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;
}
Also used : ModelInfo(org.eclipse.vorto.repository.core.ModelInfo) ModelResource(org.eclipse.vorto.repository.core.ModelResource) ArrayList(java.util.ArrayList) StorageItem(org.eclipse.vorto.repository.core.impl.StorageItem)

Aggregations

ArrayList (java.util.ArrayList)1 ModelInfo (org.eclipse.vorto.repository.core.ModelInfo)1 ModelResource (org.eclipse.vorto.repository.core.ModelResource)1 StorageItem (org.eclipse.vorto.repository.core.impl.StorageItem)1