MetadataResource.java 文件源码

java
阅读 23 收藏 0 点赞 0 评论 0

项目:oreva 作者:
@GET
@Produces({ ODataConstants.APPLICATION_XML_CHARSET_UTF8, ODataConstants.APPLICATION_ATOMSVC_XML_CHARSET_UTF8 })
public Response getMetadata(
    @Context HttpHeaders httpHeaders,
    @Context UriInfo uriInfo,
    @Context ContextResolver<ODataProducer> producerResolver,
    @QueryParam("$format") String format) {

  ODataProducer producer = producerResolver.getContext(ODataProducer.class);

  // a request for media type atomsvc+xml means give me the service document of the metadata producer
  if ("atomsvc".equals(format) || isAtomSvcRequest(httpHeaders)) {
    MetadataProducer metadataProducer = producer.getMetadataProducer();
    if (metadataProducer == null) {
      throw newMetadataNotImplementedException();
    }
    ServiceDocumentResource r = new ServiceDocumentResource();
    return r.getServiceDocument(httpHeaders, uriInfo, producerResolver, FormatType.ATOM.name(), null);
  } else {
    StringWriter w = new StringWriter();
    ODataProducer source = "metamodel".equals(format) ? producer.getMetadataProducer() : producer;
    if (source == null) {
      throw newMetadataNotImplementedException();
    }
    EdmDataServices s = source.getMetadata();
    EdmxFormatWriter.write(s, w);

    return Response.ok(w.toString(), ODataConstants.APPLICATION_XML_CHARSET_UTF8)
        .header(ODataConstants.Headers.DATA_SERVICE_VERSION, ODataConstants.DATA_SERVICE_VERSION_HEADER)
        .build();
  }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号