コード例 #1
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();
 }
コード例 #2
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());
 }
コード例 #3
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);
 }
コード例 #4
0
ファイル: RunResource.java プロジェクト: albertchau/DVT
 @GET
 @Path("{id}")
 @UnitOfWork
 @Produces({MediaType.APPLICATION_JSON})
 public Response getDatasource(@PathParam("id") LongParam id) {
   return Response.ok(runDAO.findById(id.get())).build();
 }
コード例 #5
0
 @GET
 @Path("/view_mustache")
 @UnitOfWork
 @Produces(MediaType.TEXT_HTML)
 public PersonView getPersonViewMustache(@PathParam("personId") LongParam personId) {
   return new PersonView(PersonView.Template.MUSTACHE, findSafely(personId.get()));
 }
コード例 #6
0
 @GET
 @Path("/view_freemaker")
 @UnitOfWork
 @Produces(MediaType.TEXT_HTML)
 public PersonView getPersonViewFreemaker(@PathParam("personId") LongParam personId) {
   return new PersonView(PersonView.Template.FREEMAKER, findSafely(personId.get()));
 }
コード例 #7
0
  @GET
  @UnitOfWork
  @Path("viewers/{personId}")
  @Produces(MediaType.APPLICATION_JSON)
  public LinkedList<Viewer> profileViews(@PathParam("personId") LongParam personId)
      throws JsonParseException, JsonMappingException, IOException {

    Person person = findSafely(personId.get());

    LinkedList<Viewer> viewers;

    if (person.getViewers() != null) {
      viewers = mapper.readValue(person.getViewers(), new TypeReference<LinkedList<Viewer>>() {});

      // send only valid views; which happened in last ten days
      // do not update person object for invalid views : update only in addProfile function
      LinkedList<Viewer> tmp = new LinkedList<Viewer>();
      for (Viewer viewer : viewers) {
        if (isValid(viewer)) tmp.add(viewer);
      }

      viewers = tmp;
    } else viewers = new LinkedList<Viewer>();

    return viewers;
  }
コード例 #8
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);
 }
コード例 #9
0
 @GET
 @Path("{id}/revisionIds")
 @Produces(MediaType.APPLICATION_JSON)
 @Timed
 @UnitOfWork
 public List<Number> getRevisionNumbers(@PathParam("id") LongParam id) {
   return dao.getRevisionNumbers(id.get());
 }
コード例 #10
0
  @POST
  @UnitOfWork
  @Path("add_view/{personId}")
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  public synchronized Person addProfileView(
      @PathParam("personId") LongParam personId, Viewer viewer)
      throws JsonParseException, JsonMappingException, IOException {
    // load person object
    Person person = findSafely(personId.get());
    LinkedList<Viewer> viewers;

    // Pending: make sure the viewer Id exists in db

    if (viewer.getId() == personId.get())
      throw new BadRequestException("Viewer & viewee id's are same");

    if (person.getViewers() != null) {
      // de-serialise viewers object to list from json
      viewers = mapper.readValue(person.getViewers(), new TypeReference<LinkedList<Viewer>>() {});

      // filter invalid/obsolete views
      LinkedList<Viewer> tmp = new LinkedList<Viewer>();
      for (Viewer vr : viewers) {
        // if viewer is valid and not same as current one
        if (vr.getId() != viewer.getId() && isValid(vr)) tmp.add(vr);
      }

      // if max viewers are present; remove last one
      if (tmp.size() == maxViewers) tmp.removeLast();

      viewers = tmp;
    } else {
      viewers = new LinkedList<Viewer>();
    }

    // add new viewer
    viewers.addFirst(viewer);

    person.setViewers(mapper.writeValueAsString(viewers));

    personDAO.update(person);

    return person;
  }
コード例 #11
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;
 }
コード例 #12
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;
 }
コード例 #13
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;
 }
コード例 #14
0
 @GET
 @UnitOfWork
 @Timed
 public Person getPerson(@PathParam("personId") LongParam personId) {
   return findSafely(personId.get());
 }