public async Task <ActionResult <PublishResponse> > PublishRepository([FromBody] PublishInfo publishInfo) { IVcsService vcsService; switch (publishInfo.versionControl) { case "git": vcsService = gitHubService; break; case "svn": vcsService = subversionService; break; default: vcsService = gitHubService; break; } Snapshot snapshot; try { snapshot = vcsService.GetRepositorySnapshot(publishInfo.repoURL, publishInfo.repoName, publishInfo.snapshotId, HttpContext.TraceIdentifier.Replace(':', '.')); } catch (Exception e) { return(BadRequest(new ErrorResponse() { message = $"An error occurred while accessing the repository at {publishInfo.repoURL}. Please make sure the repository is publicly accessible." })); } Publication duplicate = publicationService.FindDuplicatePublication(snapshot.checksum); if (duplicate != null) { return(BadRequest(new DuplicatePublicationResponse() { message = $"This repository has already been published.", duplicatePublicationUrl = duplicate.PublicationUrl })); } IPublishingService publishingService; switch (publishInfo.publishingSystem) { case "b2share": publishingService = b2ShareService; break; case "figshare": publishingService = figshareService; break; case "dataverse": publishingService = dataverseService; break; default: publishingService = b2ShareService; break; } Response response = await publishingService.PublishRepository(snapshot.zippedBytes, publishInfo); if (response is PublishResponse) { publicationService.CreatePublication(publishInfo.repoURL, ((PublishResponse)response).publishUrl, publishInfo.metaData.open_access, snapshot.checksum); return(Ok(response)); } else if (response is PublishErrorResponse) { return(BadRequest(response)); } return(BadRequest(new ErrorResponse() { message = "Unknown error occurred." })); }