Java Code Examples for org.apache.olingo.odata2.api.ep.EntityProvider#writeServiceDocument()

The following examples show how to use org.apache.olingo.odata2.api.ep.EntityProvider#writeServiceDocument() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ODataSingleProcessor.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
/**
 * @see ServiceDocumentProcessor
 */
@Override
public ODataResponse readServiceDocument(final GetServiceDocumentUriInfo uriInfo, final String contentType)
    throws ODataException {
  final Edm edm = getContext().getService().getEntityDataModel();

  //Service Document has version 1.0 specifically
  if ("HEAD".equals(getContext().getHttpMethod())) {
    return ODataResponse.header(ODataHttpHeaders.DATASERVICEVERSION, ODataServiceVersion.V10).build();
  } else {
    final String serviceRoot = getContext().getPathInfo().getServiceRoot().toASCIIString();
    final ODataResponse response = EntityProvider.writeServiceDocument(contentType, edm, serviceRoot);
    return ODataResponse.fromResponse(response)
        .header(ODataHttpHeaders.DATASERVICEVERSION, ODataServiceVersion.V10).build();
  }
}
 
Example 2
Source File: Processor.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public ODataResponse readServiceDocument(GetServiceDocumentUriInfo uri_info, String content_type)
      throws ODataException
{
   Edm edm = new EdmWrapper(getContext().getService().getEntityDataModel());
   return EntityProvider.writeServiceDocument(content_type, edm, ServiceFactory.ROOT_URL);
}
 
Example 3
Source File: ServiceDocumentProducerTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testServiceDocumentXml() throws EntityProviderException, ODataException {
  ODataResponse response =
      EntityProvider.writeServiceDocument(HttpContentType.APPLICATION_ATOM_XML, edm, "http://localhost/");

  assertNull("EntityProvider should not set content header", response.getContentHeader());
}
 
Example 4
Source File: AtomServiceDocumentProducerTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void writeEmptyServiceDocumentOverRuntimeDelegate() throws Exception {
  ODataResponse response =
      EntityProvider.writeServiceDocument(HttpContentType.APPLICATION_ATOM_XML, edm, "http://localhost");
  String xmlString = verifyResponse(response);

  assertXpathExists("/a:service", xmlString);
  assertXpathExists("/a:service/a:workspace", xmlString);
  assertXpathExists("/a:service/a:workspace/atom:title", xmlString);
  assertXpathEvaluatesTo("Default", "/a:service/a:workspace/atom:title", xmlString);
}