Exemple #1
0
  /**
   * 创建项目
   *
   * @return
   * @throws IOException
   */
  @RequestMapping(value = "/projects/add", method = RequestMethod.POST)
  public @ResponseBody WebResult add(HttpEntity<Project> entity) throws IOException {
    Project project = entity.getBody();
    String userName = simpleAuthz.getPrincipal();
    project.setAdmins(Lists.newArrayList(userName));
    WebResult result = new WebResult();
    project.setMetricCollection(project.getMetricCollection());
    try {
      projectService.create(project);

    } catch (IllegalArgumentException e) {
      result.setSuccess(false);
      result.setMessage(e.getMessage());
    }
    return result;
  }
Exemple #2
0
  /**
   * 创建项目
   *
   * @param map
   * @param response
   * @return
   * @throws IOException
   */
  @RequestMapping(value = "/projects", method = RequestMethod.POST)
  public String save(
      ModelMap map, HttpServletResponse response, Project project, BindingResult bindingResult)
      throws IOException {

    String userName = simpleAuthz.getPrincipal();
    project.setAdmins(Lists.newArrayList(userName));

    project.setMetricCollection(project.getMetricCollection());
    try {
      projectService.create(project);
      return "redirect:/projects/" + project.getName();
    } catch (IllegalArgumentException e) {
      map.put("project", project);
      map.put("flashMsg", e.getMessage());
      return "project/new";
    }
  }