private dynamic InstallPackage(dynamic o) { try { var package = this.Bind <InstallPackage>(); var manifest = _repository.AddPackage(package); _installationRecorder.RecordInstall(package.Path, DateTime.Now); if (package.DisableManifest) { // Skip manifest reporting. Nancy will return an empty message body. manifest = null; } return(Response .AsJson(manifest, HttpStatusCode.Created) .WithHeader("Location", ShipServiceUrl.PackageLatestVersion)); } catch (NotFoundException) { return(new Response { StatusCode = HttpStatusCode.NotFound }); } }
public override void HandleRequest(HttpContextBase context) { if (CanHandle(context)) { try { var package = GetRequest(context.Request); var manifest = _repository.AddPackage(package); _installationRecorder.RecordInstall(package.Path, DateTime.Now); var json = new JavaScriptSerializer().Serialize(new { manifest.Entries }); JsonResponse(json, HttpStatusCode.Created, context); context.Response.AddHeader("Location", ShipServiceUrl.PackageLatestVersion); } catch (NotFoundException) { context.Response.StatusCode = (int)HttpStatusCode.NotFound; } } else if (Successor != null) { Successor.HandleRequest(context); } }
public override void HandleRequest(HttpContextBase context) { if (CanHandle(context)) { try { var package = GetRequest(context.Request); var manifest = _repository.AddPackage(package); if (!package.AnalyzeOnly) { _installationRecorder.RecordInstall(package.Path, DateTime.Now); foreach (var entry in manifest.Entries) { if (entry.ID.HasValue) { _publishService.AddToPublishQueue(entry.ID.Value); } } } var json = Json.Encode(new { manifest.ManifestReport }); JsonResponse(json, manifest.ManifestReport.ErrorOccured, manifest.ManifestReport.WarningOccured, context); context.Response.AddHeader("Location", ShipServiceUrl.PackageLatestVersion); } catch (NotFoundException) { context.Response.StatusCode = (int)HttpStatusCode.NotFound; } } else if (Successor != null) { Successor.HandleRequest(context); } }
private dynamic InstallPackage(dynamic o) { try { var package = this.Bind <InstallPackage>(); var manifest = _repository.AddPackage(package); _installationRecorder.RecordInstall(package.Path, DateTime.Now); return(Response .AsJson(manifest, HttpStatusCode.Created) .WithHeader("Location", ShipServiceUrl.PackageLatestVersion)); } catch (NotFoundException) { return(new Response { StatusCode = HttpStatusCode.NotFound }); } }
public override void HandleRequest(HttpContextBase context) { if (CanHandle(context)) { try { if (context.Request.Files.Count == 0) { context.Response.StatusCode = (int)HttpStatusCode.BadRequest; } var file = context.Request.Files[0]; var uploadPackage = GetRequest(context.Request); PackageManifest manifest; try { var package = new InstallPackage { Path = _tempPackager.GetPackageToInstall(file.InputStream) }; manifest = _repository.AddPackage(package); _installationRecorder.RecordInstall(uploadPackage.PackageId, uploadPackage.Description, DateTime.Now); } finally { _tempPackager.Dispose(); } var json = new JavaScriptSerializer().Serialize(new { manifest.Entries }); JsonResponse(json, HttpStatusCode.Created, context); context.Response.AddHeader("Location", ShipServiceUrl.PackageLatestVersion); } catch (NotFoundException) { context.Response.StatusCode = (int)HttpStatusCode.NotFound; } } else if (Successor != null) { Successor.HandleRequest(context); } }
public override void HandleRequest(HttpContextBase context) { if (CanHandle(context)) { try { if (context.Request.Files.Count == 0) { context.Response.StatusCode = (int)HttpStatusCode.BadRequest; } var file = context.Request.Files[0]; var uploadPackage = GetRequest(context.Request); PackageManifest manifest; try { var package = new InstallPackage { Path = _tempPackager.GetPackageToInstall(file.InputStream), DisableIndexing = uploadPackage.DisableIndexing, EnableSecurityInstall = uploadPackage.EnableSecurityInstall, AnalyzeOnly = uploadPackage.AnalyzeOnly, SummeryOnly = uploadPackage.SummeryOnly, Version = uploadPackage.Version }; manifest = _repository.AddPackage(package); if (!uploadPackage.AnalyzeOnly) { _installationRecorder.RecordInstall(uploadPackage.PackageId, uploadPackage.Description, DateTime.Now); } } finally { _tempPackager.Dispose(); } if (!uploadPackage.AnalyzeOnly) { foreach (var entry in manifest.Entries) { if (entry.ID.HasValue) { _publishService.AddToPublishQueue(entry.ID.Value); } } } var json = Json.Encode(new { manifest.ManifestReport }); JsonResponse(json, manifest.ManifestReport.ErrorOccured, manifest.ManifestReport.WarningOccured, context); context.Response.AddHeader("Location", ShipServiceUrl.PackageLatestVersion); } catch (NotFoundException) { context.Response.StatusCode = (int)HttpStatusCode.NotFound; } } else if (Successor != null) { Successor.HandleRequest(context); } }