コード例 #1
0
  @POST
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  public Response action(
      @Context HttpServletRequest httpRequest,
      @FormParam("csrfToken") String csrfToken,
      @FormParam("key") @DefaultValue("") String key,
      @FormParam("name") @DefaultValue("") String name,
      @FormParam("description") @DefaultValue("") String description,
      @FormParam("rollback") @DefaultValue("") String rollback,
      @FormParam("version") @DefaultValue("") String version,
      @FormParam("upgrade") @DefaultValue("") String upgrade,
      @FormParam("repository") @DefaultValue("") String repository,
      @FormParam("email") @DefaultValue("") String email,
      @FormParam("autoRelease") @DefaultValue("false") boolean autoRelease,
      @FormParam("action") @DefaultValue("") String action) {

    return shiroRequestHelper.csrfCall(
        csrfToken,
        "releases/action",
        (csrfToken1) -> {
          if (action.startsWith("export")) {
            String export =
                pluginRegion.doExport(
                    new ReleasesPluginRegionInput(
                        key,
                        name,
                        description,
                        rollback,
                        version,
                        upgrade,
                        repository,
                        email,
                        autoRelease,
                        "export"),
                    httpRequest.getRemoteUser());
            return Response.ok(export, MediaType.APPLICATION_OCTET_STREAM_TYPE);
          } else {
            String rendered =
                soyService.renderPlugin(
                    httpRequest.getRemoteUser(),
                    csrfToken1,
                    pluginRegion,
                    new ReleasesPluginRegionInput(
                        key,
                        name,
                        description,
                        rollback,
                        version,
                        upgrade,
                        repository,
                        email,
                        autoRelease,
                        action));
            return Response.ok(rendered, MediaType.TEXT_HTML);
          }
        });
  }
コード例 #2
0
 @GET
 @Produces(MediaType.TEXT_HTML)
 @Path("/scm")
 public Response scm(@QueryParam("releaseKey") @DefaultValue("") String releaseKey)
     throws Exception {
   return shiroRequestHelper.call(
       "releases/scm",
       (csrfToken1) -> {
         return Response.ok(pluginRegion.renderScm(releaseKey));
       });
 }
コード例 #3
0
 @POST
 @Path("/property/remove")
 @Produces(MediaType.APPLICATION_JSON)
 @Consumes(MediaType.APPLICATION_JSON)
 public Response remove(@Context HttpServletRequest httpRequest, PropertyUpdate update) {
   return shiroRequestHelper.call(
       "releases/property/remove",
       (csrfToken1) -> {
         pluginRegion.remove(httpRequest.getRemoteUser(), update);
         return Response.ok();
       });
 }
コード例 #4
0
 @POST
 @Path("/import")
 @Consumes(MediaType.MULTIPART_FORM_DATA)
 public Response importTopology(
     @Context HttpServletRequest httpRequest,
     @FormDataParam("csrfToken") String csrfToken,
     @FormDataParam("file") InputStream fileInputStream,
     @FormDataParam("file") FormDataContentDisposition contentDispositionHeader) {
   return shiroRequestHelper.csrfCall(
       csrfToken,
       "releases/import",
       (csrfToken1) -> {
         String json = IOUtils.toString(fileInputStream, StandardCharsets.UTF_8);
         pluginRegion.doImport(json, httpRequest.getRemoteUser());
         URI location = new URI("/ui/releases");
         return Response.seeOther(location);
       });
 }