/// <summary> /// create bundle, process the file /// </summary> /// <param name="filename"></param> /// <param name="input"></param> /// <returns>bundleId</returns> public string ProcessInputfile(string filename, DumpAnalysisInput input) { var bundleInfo = bundleRepo.Create(filename, input); ScheduleDownload(bundleInfo.BundleId, input.Url, filename); // indirectly calls ProcessFile() return(bundleInfo.BundleId); }
public IActionResult Post([FromBody] DumpAnalysisInput input) { if (ModelState.IsValid) { string filename = input.UrlFilename; //validate URL if (Utility.ValidateUrl(input.Url, ref filename)) { if (filename == null && Utility.IsLocalFile(input.Url)) { filename = Path.GetFileName(input.Url); } string bundleId = superDumpRepo.ProcessInputfile(filename, input); if (bundleId != null) { return(CreatedAtAction(nameof(HomeController.BundleCreated), "Home", new { bundleId = bundleId }, null)); } else { // in case the input was just symbol files, we don't get a bundleid. // TODO throw new NotImplementedException(); } } else { return(BadRequest("Invalid request, resource identifier is not valid or cannot be reached.")); } } else { return(BadRequest("Invalid request, check if value was set.")); } }
public BundleMetainfo Create(string filename, DumpAnalysisInput input) { lock (sync) { string bundleId = CreateUniqueBundleId(); var bundleInfo = new BundleMetainfo() { BundleId = bundleId, BundleFileName = filename, Created = DateTime.Now, Status = BundleStatus.Created }; bundleInfo.CustomProperties = input.CustomProperties; if (!string.IsNullOrEmpty(input.JiraIssue)) { bundleInfo.CustomProperties["ref"] = input.JiraIssue; } if (!string.IsNullOrEmpty(input.FriendlyName)) { bundleInfo.CustomProperties["note"] = input.FriendlyName; } bundles[bundleId] = bundleInfo; storage.Store(bundleInfo); return(bundleInfo); } }
public string ProcessWebInputfile(DumpAnalysisInput input) { string filename = input.UrlFilename; //validate URL if (Utility.ValidateUrl(input.Url, ref filename)) { if (filename == null && Utility.IsLocalFile(input.Url)) { filename = Path.GetFileName(input.Url); } return(ProcessWebInputfile(filename, input)); } return(string.Empty); }
public IActionResult Post([FromBody] DumpAnalysisInput input) { if (ModelState.IsValid) { string bundleId = superDumpRepo.ProcessWebInputfile(input); //validate URL if (!string.IsNullOrEmpty(bundleId)) { logger.LogFileUpload("Api Upload", HttpContext, bundleId, input.CustomProperties, input.Url); return(CreatedAtAction(nameof(HomeController.BundleCreated), "Home", new { bundleId = bundleId }, null)); } else { logger.LogNotFound("Api Upload: File not found", HttpContext, "Url", input.Url); return(BadRequest("Invalid request, resource identifier is not valid or cannot be reached.")); } } else { var errors = string.Join("; ", ModelState.Values.SelectMany(v => v.Errors).Select(x => "'" + x.Exception.Message + "'")); return(BadRequest($"Invalid request, check if value was set: {errors}")); } }
public IActionResult Post([FromBody] DumpAnalysisInput input) { if (ModelState.IsValid) { string filename = input.UrlFilename; //validate URL if (Utility.ValidateUrl(input.Url, ref filename)) { if (filename == null && Utility.IsLocalFile(input.Url)) { filename = Path.GetFileName(input.Url); } string bundleId = superDumpRepo.ProcessInputfile(filename, input); if (bundleId != null) { logger.LogFileUpload("Api Upload", HttpContext, bundleId, input.CustomProperties, input.Url); return(CreatedAtAction(nameof(HomeController.BundleCreated), "Home", new { bundleId = bundleId }, null)); } else { // in case the input was just symbol files, we don't get a bundleid. // TODO throw new NotImplementedException(); } } else { logger.LogNotFound("Api Upload: File not found", HttpContext, "Url", input.Url); return(BadRequest("Invalid request, resource identifier is not valid or cannot be reached.")); } } else { var errors = string.Join("; ", ModelState.Values.SelectMany(v => v.Errors).Select(x => "'" + x.Exception.Message + "'")); return(BadRequest($"Invalid request, check if value was set: {errors}")); } }