Example #1
0
  @Produces({"application/xml"})
  @GET
  @Path("{path}")
  public synchronized Response geExternalGrammar(
      @Context UriInfo uriInfo, @PathParam("path") String path) {
    try {
      // Fail if wadl generation is disabled
      if (!wadlContext.isWadlGenerationEnabled()) {
        return Response.status(Response.Status.NOT_FOUND).build();
      }

      ApplicationDescription applicationDescription =
          wadlContext.getApplication(uriInfo, WadlUtils.isDetailedWadlRequested(uriInfo));

      // Fail is we don't have any metadata for this path
      ApplicationDescription.ExternalGrammar externalMetadata =
          applicationDescription.getExternalGrammar(path);

      if (externalMetadata == null) {
        return Response.status(Response.Status.NOT_FOUND).build();
      }

      // Return the data
      return Response.ok()
          .type(externalMetadata.getType())
          .entity(externalMetadata.getContent())
          .build();
    } catch (Exception e) {
      throw new ProcessingException(LocalizationMessages.ERROR_WADL_RESOURCE_EXTERNAL_GRAMMAR(), e);
    }
  }