Ejemplo n.º 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);
  }
Ejemplo n.º 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();
  }
Ejemplo n.º 3
0
 @Get("/projects/{project.id}")
 public Project view(Project project) {
   List<OperatingSystem> oss = osDao.listAll();
   result.include("oss", oss);
   return projectDao.find(project.getId());
 }
Ejemplo n.º 4
0
 @Get("/projects/{project.id}/servers")
 public void viewServers(Project project) {
   Project projectDB = projectDao.find(project.getId());
   result.include("servers", projectDB.getServers());
 }