예제 #1
0
 @DELETE
 @Path("{id}")
 @Timed
 @UnitOfWork
 public void delete(@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();
   if (entity.getState() == OrchestrationState.Started) {
     throw new WebApplicationException(Response.Status.CONFLICT);
   }
   dao.delete(entity);
 }
예제 #2
0
 @GET
 @Produces(MediaType.APPLICATION_JSON)
 @Timed
 @UnitOfWork
 public Set<Orchestration> getAll() {
   return Sets.newLinkedHashSet(dao.findAll());
 }
예제 #3
0
 @PUT
 @Path("{id}")
 @Consumes(MediaType.APPLICATION_JSON)
 @Produces(MediaType.APPLICATION_JSON)
 @Timed
 @UnitOfWork
 public Orchestration update(@PathParam("id") LongParam id, Orchestration entity) {
   Optional<Orchestration> ent = dao.find(id.get());
   if (!ent.isPresent()) {
     throw new NotFoundException("Orchestration " + id.get() + " not found");
   }
   if (ent.get().getState() == OrchestrationState.Started) {
     throw new WebApplicationException(Response.Status.CONFLICT);
   }
   entity.setLastModified(LocalDateTime.now());
   return dao.merge(entity);
 }
예제 #4
0
 @GET
 @Path("{id}/revisionIds")
 @Produces(MediaType.APPLICATION_JSON)
 @Timed
 @UnitOfWork
 public List<Number> getRevisionNumbers(@PathParam("id") LongParam id) {
   return dao.getRevisionNumbers(id.get());
 }
예제 #5
0
 @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;
 }
예제 #6
0
 @GET
 @Path("{id}")
 @Produces(MediaType.APPLICATION_JSON)
 @Timed
 @UnitOfWork
 public Orchestration get(@PathParam("id") LongParam id) {
   Optional<Orchestration> entity = dao.find(id.get());
   if (!entity.isPresent()) {
     throw new NotFoundException("Orchestration " + id.get() + " not found");
   }
   return entity.get();
 }
예제 #7
0
 @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);
 }
예제 #8
0
 @GET
 @Path("{id}/specification")
 @Produces(MediaType.APPLICATION_JSON)
 @Timed
 @UnitOfWork
 public String getSpecification(@PathParam("id") LongParam id) throws IOException {
   Optional<Orchestration> ent = dao.find(id.get());
   if (!ent.isPresent()) {
     throw new NotFoundException("Orchestration " + id.get() + " not found");
   }
   return engine.getGeneratedSpecification(ent.get());
 }
예제 #9
0
 @GET
 @Path("{id}/revisions/{revisionId}")
 @Produces(MediaType.APPLICATION_JSON)
 @Timed
 @UnitOfWork
 public Orchestration getRevision(
     @PathParam("id") LongParam id, @PathParam("revisionId") IntParam revisionId) {
   Orchestration orchestration = dao.getRevision(id.get(), revisionId.get());
   // eagerly load the related objects
   for (OutboundEndpoint outboundEndpoint : orchestration.getOutboundEndpoints()) {
     Map<String, String> properties = outboundEndpoint.getProperties();
     for (Map.Entry<String, String> property : properties.entrySet()) {
       property.getValue();
     }
   }
   return orchestration;
 }
예제 #10
0
 @GET
 @Path("{id}/revisions")
 @Produces(MediaType.APPLICATION_JSON)
 @Timed
 @UnitOfWork
 public List<Orchestration> getRevisions(@PathParam("id") LongParam id) {
   List<Orchestration> orchestrations = dao.getRevisions(id.get());
   // eagerly load the related objects
   for (Orchestration orchestration : orchestrations) {
     for (OutboundEndpoint outboundEndpoint : orchestration.getOutboundEndpoints()) {
       Map<String, String> properties = outboundEndpoint.getProperties();
       for (Map.Entry<String, String> property : properties.entrySet()) {
         property.getValue();
       }
     }
   }
   return orchestrations;
 }