예제 #1
0
  @Post("/projects/{project.id}/servers")
  public void addServer(final Server server, final Project project) {

    validator.checking(
        new Validations() {
          {
            if (server != null) {
              that(server.getDescription(), is(notEmpty()), "description", "invalid_description");
              that(server.getIp(), is(notEmpty()), "ip", "invalid_ip");
            }
          }
        });

    validator.onErrorForwardTo(ProjectsController.class).addServer(server, project);

    Project p = projectDao.find(project.getId());

    server.setCreation(Calendar.getInstance());
    server.setOwner(userInfo.getUser());

    p.addServer(server);

    projectDao.add(p);

    result.include("notice", server.getDescription() + " server added");
    result.redirectTo(ProjectsController.class).view(project);
  }
예제 #2
0
  @Post("/projects")
  public void add(final Project project) {

    validator.checking(
        new Validations() {
          {
            if (project != null) {
              that(project.getDescription(), is(notEmpty()), "description", "invalid_description");
            }
          }
        });

    validator.onErrorForwardTo(ProjectsController.class).list();

    project.setCreation(Calendar.getInstance());
    project.setOwner(userInfo.getUser());

    projectDao.add(project);

    result.include("notice", project.getDescription() + " project added");
    result.redirectTo(ProjectsController.class).list();
  }