Ejemplo n.º 1
0
  @RequestMapping(value = "/key/{keyId}/edit")
  public ModelAndView editKey(@PathVariable("keyId") final String keyId) {
    final DeployKey key = this.service.getDeployKey(keyId);

    if (key == null) {
      return CommonController.createNotFound("Deploy Key", keyId);
    }

    final Map<String, Object> model = new HashMap<>();

    model.put("command", DeployKeyBean.fromKey(key));

    return new ModelAndView("editKey", model);
  }
Ejemplo n.º 2
0
  @RequestMapping(value = "/key/{keyId}/edit", method = RequestMethod.POST)
  public ModelAndView editKeyPost(
      @PathVariable("keyId") final String keyId,
      @Valid @FormData("command") final DeployKeyBean key,
      final BindingResult result) {
    if (!result.hasErrors()) {
      final DeployKey dk = this.service.updateDeployKey(keyId, key.getName());
      if (dk != null && dk.getGroup().getId() != null) {
        return new ModelAndView(
            "redirect:/deploy/auth/group/"
                + urlPathSegmentEscaper().escape(dk.getGroup().getId())
                + "/view");
      }
    }

    return new ModelAndView("editKey", Collections.singletonMap("command", key));
  }