public IHttpActionResult GetImportInformation([FromUri]string fileUrl) { var retVal = new webModel.ImportInfo(); using (var stream = _blobStorageProvider.OpenReadOnly(fileUrl)) { retVal.ExportManifest = _platformExportManager.ReadPlatformExportManifest(stream); //First check platform compatibility if (!SemanticVersion.Parse(retVal.ExportManifest.PlatformVersion).IsCompatibleWith(PlatformVersion.CurrentVersion)) { throw new InvalidDataException("Imported platform version " + retVal.ExportManifest.PlatformVersion + " not compatible with current " + PlatformVersion.CurrentVersion.ToString()); } foreach (var exportModuleInfo in retVal.ExportManifest.Modules) { var installedModule = _packageService.GetModules().FirstOrDefault(x => exportModuleInfo.ModuleId == x.Id); if (installedModule != null) { var moduleDescriptor = installedModule.ToWebModel(); retVal.Modules.Add(moduleDescriptor); //Check compatibility if (!SemanticVersion.Parse(moduleDescriptor.Version).IsCompatibleWith(SemanticVersion.Parse(installedModule.Version))) { moduleDescriptor.ValidationErrors.Add("Imported module version " + moduleDescriptor.Version + " not compatible with installed " + installedModule.Version); } } } } return Ok(retVal); }
public IHttpActionResult GetImportInformation([FromUri] string fileUrl) { var retVal = new webModel.ImportInfo(); using (var stream = _blobStorageProvider.OpenReadOnly(fileUrl)) { retVal.ExportManifest = _platformExportManager.ReadPlatformExportManifest(stream); //First check platform compatibility if (!SemanticVersion.Parse(retVal.ExportManifest.PlatformVersion).IsCompatibleWith(PlatformVersion.CurrentVersion)) { throw new InvalidDataException("Imported platform version " + retVal.ExportManifest.PlatformVersion + " not compatible with current " + PlatformVersion.CurrentVersion.ToString()); } foreach (var exportModuleInfo in retVal.ExportManifest.Modules) { var installedModule = _packageService.GetModules().FirstOrDefault(x => exportModuleInfo.ModuleId == x.Id); if (installedModule != null) { var moduleDescriptor = installedModule.ToWebModel(); retVal.Modules.Add(moduleDescriptor); //Check compatibility if (!SemanticVersion.Parse(moduleDescriptor.Version).IsCompatibleWith(SemanticVersion.Parse(installedModule.Version))) { moduleDescriptor.ValidationErrors.Add("Imported module version " + moduleDescriptor.Version + " not compatible with installed " + installedModule.Version); } } } } return(Ok(retVal)); }