@POST @Path("downloads") @ApiOperation(value = "Starts downloading artifacts", response = DownloadToken::class) @ApiResponses( value = [ApiResponse(code = 202, message = "OK"), ApiResponse( code = 400, message = "Illegal version format or artifact name" ), ApiResponse(code = 409, message = "Downloading already in progress"), ApiResponse( code = 500, message = "Server error" )] ) fun startDownload( @QueryParam(value = "artifact") @ApiParam( value = "Artifact name", allowableValues = CDECArtifact.NAME ) artifactName: String?, @QueryParam(value = "version") @ApiParam(value = "Version number") versionNumber: String? ): Response? { return try { val downloadToken = DownloadToken() downloadToken.setId(DOWNLOAD_TOKEN) val artifact: Artifact = createArtifactOrNull(artifactName) val version: Version = createVersionOrNull(versionNumber) facade.startDownload(artifact, version) Response.status(Response.Status.ACCEPTED).entity(downloadToken).build() } catch (e: ArtifactNotFoundException) { handleException(e, Response.Status.BAD_REQUEST) } catch (e: IllegalVersionException) { handleException(e, Response.Status.BAD_REQUEST) } catch (e: DownloadAlreadyStartedException) { handleException(e, Response.Status.CONFLICT) } catch (e: Exception) { handleException(e) } }
Starts downloading artifacts .