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