@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Timed @UnitOfWork public Orchestration create(Orchestration entity) { entity.setState(OrchestrationState.Initialized); LocalDateTime now = LocalDateTime.now(); entity.setCreated(now); entity.setLastModified(now); return dao.save(entity); }
@POST @Path("{id}/stop") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Timed @UnitOfWork public Orchestration stop(@PathParam("id") LongParam id) { Optional<Orchestration> ent = dao.find(id.get()); if (!ent.isPresent()) { throw new NotFoundException("Orchestration " + id.get() + " not found"); } Orchestration entity = ent.get(); boolean result = engine.stop(entity); if (result) { entity.setState(OrchestrationState.Stopped); entity.setLastModified(LocalDateTime.now()); dao.save(entity); } return entity; }