@RvdAuth @PUT @Path("{name}/upgrade") public Response upgradeProject(@PathParam("name") String projectName) { // TODO IMPORTANT!!! sanitize the project name!! if (!RvdUtils.isEmpty(projectName)) { try { UpgradeService upgradeService = new UpgradeService(workspaceStorage); upgradeService.upgradeProject(projectName); logger.info( "project '" + projectName + "' upgraded to version " + RvdConfiguration.getRvdProjectVersion()); // re-build project BuildService buildService = new BuildService(workspaceStorage); buildService.buildProject(projectName, activeProject); logger.info("project '" + projectName + "' built"); return Response.ok().build(); } catch (StorageException e) { return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } catch (UpgradeException e) { logger.error(e.getMessage(), e); return Response.status(Status.INTERNAL_SERVER_ERROR) .entity(e.asJson()) .type(MediaType.APPLICATION_JSON) .build(); } } else return Response.status(Status.BAD_REQUEST).build(); }
@RvdAuth @POST @Path("{name}/build") public Response buildProject(@PathParam("name") String name) throws StorageException, ProjectDoesNotExist { assertProjectAvailable(name); BuildService buildService = new BuildService(workspaceStorage); try { buildService.buildProject(name, activeProject); return Response.ok().build(); } catch (StorageException e) { logger.error(e.getMessage(), e); return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } }
@RvdAuth @PUT @Path("{name}") public Response createProject( @PathParam("name") String name, @QueryParam("kind") String kind, @QueryParam("ticket") String ticket) { Principal loggedUser = securityContext.getUserPrincipal(); ProjectApplicationsApi applicationsApi = null; logger.info("Creating project " + name); try { applicationsApi = new ProjectApplicationsApi(servletContext, workspaceStorage, marshaler); applicationsApi.createApplication(ticket, name, kind); ProjectState projectState = projectService.createProject(name, kind, loggedUser.getName()); BuildService buildService = new BuildService(workspaceStorage); buildService.buildProject(name, projectState); } catch (ProjectAlreadyExists e) { logger.error(e.getMessage(), e); try { applicationsApi.rollbackCreateApplication(ticket, name); } catch (ApplicationsApiSyncException e1) { logger.error(e1.getMessage(), e1); return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } return Response.status(Status.CONFLICT).build(); } catch (StorageException e) { logger.error(e.getMessage(), e); return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } catch (InvalidServiceParameters e) { logger.error(e); return Response.status(Status.BAD_REQUEST).build(); } catch (ApplicationAlreadyExists e) { logger.error(e.getMessage(), e); return Response.status(Status.CONFLICT).build(); } catch (ApplicationsApiSyncException e) { logger.error(e.getMessage(), e); return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } catch (UnsupportedEncodingException e) { logger.error(e.getMessage(), e); return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } return Response.ok().build(); }