/**
   * Create Push Application
   *
   * @param pushApp new {@link PushApplication}
   * @return created {@link PushApplication}
   * @statuscode 201 The PushApplication Variant created successfully
   * @statuscode 400 The format of the client request was incorrect
   */
  @POST
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  @ReturnType("org.jboss.aerogear.unifiedpush.api.PushApplication")
  public Response registerPushApplication(PushApplication pushApp) {

    // some validation
    try {
      validateModelClass(pushApp);
    } catch (ConstraintViolationException cve) {

      // Build and return the 400 (Bad Request) response
      ResponseBuilder builder = createBadRequestResponse(cve.getConstraintViolations());

      return builder.build();
    }

    pushAppService.addPushApplication(pushApp);

    return Response.created(
            UriBuilder.fromResource(PushApplicationEndpoint.class)
                .path(String.valueOf(pushApp.getPushApplicationID()))
                .build())
        .entity(pushApp)
        .build();
  }
Esempio n. 2
0
 @POST
 @Produces(value = {"application/json;charset=utf-8"})
 @Consumes(value = {"application/json"})
 public Response postarPessoa(Pessoa pessoa) {
   return Response.created(
           UriBuilder.fromResource(PessoaRest.class).path(String.valueOf(pessoa.getId())).build())
       .build();
 }
 @POST
 @Consumes("application/json")
 public Response create(Reporter entity) {
   em.persist(entity);
   return Response.created(
           UriBuilder.fromResource(ReporterEndpoint.class)
               .path(String.valueOf(entity.getId()))
               .build())
       .build();
 }
Esempio n. 4
0
 @POST
 @Consumes(MediaType.APPLICATION_JSON)
 public Response create(Vendor entity) {
   em.persist(entity);
   return Response.created(
           UriBuilder.fromResource(VendorEndpoint.class)
               .path(String.valueOf(entity.getId()))
               .build())
       .build();
 }
 @POST
 @Consumes("application/json")
 public Response create(Proposicao entity) {
   service.save(entity);
   return Response.created(
           UriBuilder.fromResource(ProposicaoEndpoint.class)
               .path(String.valueOf(entity.getId()))
               .build())
       .build();
 }
Esempio n. 6
0
  @Path("start")
  @POST
  public Response post(@DefaultValue("0") @QueryParam("testSources") int testSources) {
    final Process process = new Process(testSources);
    processes.put(process.getId(), process);

    Executors.newSingleThreadExecutor().execute(process);

    final URI processIdUri =
        UriBuilder.fromResource(DomainResource.class).path("process/{id}").build(process.getId());
    return Response.created(processIdUri).build();
  }
Esempio n. 7
0
  /**
   * ジャンルが見つからない画面にリダイレクトする.
   *
   * @param reviewId レビューID
   * @return リダイレクトレスポンス
   */
  private Response redirectNotFound(final long reviewId) {

    final String base = UriBuilder.fromResource(ReviewDetail.class).toTemplate();
    final String append = UriBuilder.fromMethod(ReviewDetail.class, "notFound").toTemplate();

    final UriBuilder builder = UriBuilder.fromUri(base + append);
    builder.resolveTemplate("reviewId", reviewId);

    final URI uri = builder.build();

    return Response.seeOther(uri).build();
  }
Esempio n. 8
0
  @Override
  public void configure(ResourceInfo resourceInfo, FeatureContext context) {

    Method resourceMethod = resourceInfo.getResourceMethod();
    Class<?> resourceClass = resourceInfo.getResourceClass();
    if (metricsDisabled(resourceClass)) {
      return;
    }
    Path methodPath = resourceMethod.getAnnotation(Path.class);
    Path classPath = resourceClass.getAnnotation(Path.class);

    Path path = methodPath != null ? methodPath : classPath;
    if (path != null) {
      UriBuilder builder =
          methodPath != null
              ? UriBuilder.fromResource(resourceClass).path(resourceClass, resourceMethod.getName())
              : UriBuilder.fromResource(resourceClass);

      String template = builder.toTemplate();
      context.register(new TimerBeforeFilter(template));
      context.register(TimerAfterFilter.class);
    }
  }
Esempio n. 9
0
  public Response buildResponse(
      final Class<? extends JaxrsResource> theClass,
      final String getMethodName,
      final Object objectId,
      final String baseUri) {

    // Let's build a n absolute location for cross resources
    // See Jersey ContainerResponse.setHeaders
    final StringBuilder tmp = new StringBuilder(baseUri.substring(0, baseUri.length() - 1));
    tmp.append(
        UriBuilder.fromResource(theClass).path(theClass, getMethodName).build(objectId).toString());
    final URI newUriFromResource = UriBuilder.fromUri(tmp.toString()).build();
    final Response.ResponseBuilder ri = Response.created(newUriFromResource);
    return ri.entity(
            new Object() {
              @SuppressWarnings(value = "all")
              public URI getUri() {

                return newUriFromResource;
              }
            })
        .build();
  }
 @Override
 protected URI getRelativeEngineUri(String engineName) {
   return UriBuilder.fromResource(NamedProcessEngineRestServiceImpl.class)
       .path("{name}")
       .build(engineName);
 }