@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);
  }
Esempio n. 2
0
 @Path("/projeto/altera")
 public void altera(final Projeto projeto) {
   validator.validate(projeto);
   validator.onErrorForwardTo(this).altera_form(projeto.getIdProjeto());
   dao.update(projeto);
   result.redirectTo(ProjetoController.class).index();
 }
Esempio n. 3
0
 @Path("/projeto/cria")
 public void cria(final Projeto projeto) {
   validator.validate(projeto);
   validator.onErrorForwardTo(this).novo_form();
   dao.save(projeto);
   result.redirectTo(ProjetoController.class).index();
 }
Esempio n. 4
0
 @Put
 @Path("/codes")
 public void update(Code code) {
   CodeValidation(code, false);
   validator.onErrorForwardTo(CodeController.class).index(code, false);
   repository.update(code);
   result.forwardTo(this).index(code, true);
 }
  @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();
  }