• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EntityProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.olingo.odata2.api.ep.EntityProvider的典型用法代码示例。如果您正苦于以下问题:Java EntityProvider类的具体用法?Java EntityProvider怎么用?Java EntityProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EntityProvider类属于org.apache.olingo.odata2.api.ep包,在下文中一共展示了EntityProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: executeFunctionImport

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
@Override
public ODataResponse executeFunctionImport(GetFunctionImportUriInfo uri_info, String content_type)
      throws ODataException
{
   EdmFunctionImport function_import = uri_info.getFunctionImport();
   Map<String, EdmLiteral> params = uri_info.getFunctionImportParameters();
   EntityProviderWriteProperties entry_props =
         EntityProviderWriteProperties.serviceRoot(makeLink()).build();

   AbstractOperation op = Model.getServiceOperation(function_import.getName());

   fr.gael.dhus.database.object.User current_user =
         ApplicationContextProvider.getBean(SecurityService.class).getCurrentUser();
   if (!op.canExecute(current_user))
   {
      throw new NotAllowedException();
   }

   Object res = op.execute(params);

   return EntityProvider.writeFunctionImport(content_type, function_import, res, entry_props);
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:23,代码来源:Processor.java


示例2: readFeed

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
/**
 * Reads a feed (the content of an EntitySet).
 * 
 * @param resource_path the resource path to the parent of the requested
 *    EntitySet, as defined in {@link #getResourcePath(URI)}.
 * @param query_parameters Query parameters, as defined in {@link URI}.
 * 
 * @return an ODataFeed containing the ODataEntries for the given 
 *    {@code resource_path}.
 * 
 * @throws HttpException if the server emits an HTTP error code.
 * @throws IOException if the connection with the remote service fails.
 * @throws EdmException if the EDM does not contain the given entitySetName.
 * @throws EntityProviderException if reading of data (de-serialization)
 *    fails.
 * @throws UriSyntaxException violation of the OData URI construction rules.
 * @throws UriNotMatchingException URI parsing exception.
 * @throws ODataException encapsulate the OData exceptions described above.
 * @throws InterruptedException if running thread has been interrupted.
 */
public ODataFeed readFeed(String resource_path,
   Map<String, String> query_parameters) throws IOException, ODataException, InterruptedException
{
   if (resource_path == null || resource_path.isEmpty ())
      throw new IllegalArgumentException (
         "resource_path must not be null or empty.");
   
   ContentType contentType = ContentType.APPLICATION_ATOM_XML;
   
   String absolutUri = serviceRoot.toString () + '/' + resource_path;
   
   // Builds the query parameters string part of the URL.
   absolutUri = appendQueryParam (absolutUri, query_parameters);
   
   InputStream content = execute (absolutUri, contentType, "GET");
   
   return EntityProvider.readFeed (contentType.type (),
      getEntitySet (resource_path), content,
      EntityProviderReadProperties.init ().build ());
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:41,代码来源:ODataClient.java


示例3: readEntry

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
/**
 * Reads an entry (an Entity, a property, a complexType, ...).
 * 
 * @param resource_path the resource path to the parent of the requested
 *    EntitySet, as defined in {@link #getResourcePath(URI)}.
 * @param query_parameters Query parameters, as defined in {@link URI}.
 * 
 * @return an ODataEntry for the given {@code resource_path}.
 * 
 * @throws HttpException if the server emits an HTTP error code.
 * @throws IOException if the connection with the remote service fails.
 * @throws EdmException if the EDM does not contain the given entitySetName.
 * @throws EntityProviderException if reading of data (de-serialization)
 *    fails.
 * @throws UriSyntaxException violation of the OData URI construction rules.
 * @throws UriNotMatchingException URI parsing exception.
 * @throws ODataException encapsulate the OData exceptions described above.
 * @throws InterruptedException if running thread has been interrupted.
 */
public ODataEntry readEntry(String resource_path,
   Map<String, String> query_parameters) throws IOException, ODataException, InterruptedException
{
   if (resource_path == null || resource_path.isEmpty ())
      throw new IllegalArgumentException (
         "resource_path must not be null or empty.");
   
   ContentType contentType = ContentType.APPLICATION_ATOM_XML;
   
   String absolutUri = serviceRoot.toString () + '/' + resource_path;
   
   // Builds the query parameters string part of the URL.
   absolutUri = appendQueryParam (absolutUri, query_parameters);
   
   InputStream content = execute (absolutUri, contentType, "GET");
   
   return EntityProvider.readEntry(contentType.type (),
      getEntitySet (resource_path), content,
      EntityProviderReadProperties.init ().build ());
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:40,代码来源:ODataClient.java


示例4: readEdm

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
private Edm readEdm() throws EntityProviderException,
		IllegalStateException, IOException {

	// This is used for both setting the Edm and CSRF Token :)
	if (m_edm != null) {
		return m_edm;
	}

	String serviceUrl = new StringBuilder(getODataServiceUrl())
			.append(SEPARATOR).append(METADATA).toString();

	logger.info("Metadata url => " + serviceUrl);

	final HttpGet get = new HttpGet(serviceUrl);
	get.setHeader(AUTHORIZATION_HEADER, getAuthorizationHeader());
	get.setHeader(CSRF_TOKEN_HEADER, CSRF_TOKEN_FETCH);

	HttpResponse response = getHttpClient().execute(get);

	m_csrfToken = response.getFirstHeader(CSRF_TOKEN_HEADER).getValue();
	logger.info("CSRF token => " + m_csrfToken);

	m_edm = EntityProvider.readMetadata(response.getEntity().getContent(),
			false);
	return m_edm;
}
 
开发者ID:SAP,项目名称:C4CODATAAPIDEVGUIDE,代码行数:27,代码来源:ServiceTicketODataConsumer.java


示例5: readEntry

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
public ODataEntry readEntry(String serviceUri, String contentType,
		String entitySetName, String keyValue, SystemQueryOptions options)
		throws IllegalStateException, IOException, EdmException,
		EntityProviderException {
	EdmEntityContainer entityContainer = readEdm()
			.getDefaultEntityContainer();
	logger.info("Entity container is => " + entityContainer.getName());
	String absolutUri = createUri(serviceUri, entitySetName, keyValue,
			options);

	InputStream content = executeGet(absolutUri, contentType);

	return EntityProvider.readEntry(contentType,
			entityContainer.getEntitySet(entitySetName), content,
			EntityProviderReadProperties.init().build());
}
 
开发者ID:SAP,项目名称:C4CODATAAPIDEVGUIDE,代码行数:17,代码来源:ServiceTicketODataConsumer.java


示例6: readEntityMedia

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
@Override
public ODataResponse readEntityMedia(final GetMediaResourceUriInfo uriInfo, final String contentType)
    throws ODataException {
  final Object data = retrieveData(
      uriInfo.getStartEntitySet(),
      uriInfo.getKeyPredicates(),
      uriInfo.getFunctionImport(),
      mapFunctionParameters(uriInfo.getFunctionImportParameters()),
      uriInfo.getNavigationSegments());

  if (!appliesFilter(data, uriInfo.getFilter())) {
    throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
  }

  final EdmEntitySet entitySet = uriInfo.getTargetEntitySet();
  final BinaryData binaryData = dataSource.readBinaryData(entitySet, data);
  if (binaryData == null) {
    throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
  }

  final String mimeType = binaryData.getMimeType() == null ?
      HttpContentType.APPLICATION_OCTET_STREAM : binaryData.getMimeType();

  return ODataResponse.fromResponse(EntityProvider.writeBinary(mimeType, binaryData.getData())).eTag(
      constructETag(entitySet, data)).build();
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:27,代码来源:ListsProcessor.java


示例7: updateEntityMedia

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
@Override
public ODataResponse updateEntityMedia(final PutMergePatchUriInfo uriInfo, final InputStream content,
    final String requestContentType, final String contentType) throws ODataException {
  final Object data = retrieveData(
      uriInfo.getStartEntitySet(),
      uriInfo.getKeyPredicates(),
      uriInfo.getFunctionImport(),
      mapFunctionParameters(uriInfo.getFunctionImportParameters()),
      uriInfo.getNavigationSegments());

  if (!appliesFilter(data, uriInfo.getFilter())) {
    throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
  }

  ODataContext context = getContext();
  final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "readBinary");

  final byte[] value = EntityProvider.readBinary(content);

  context.stopRuntimeMeasurement(timingHandle);

  final EdmEntitySet entitySet = uriInfo.getTargetEntitySet();
  dataSource.writeBinaryData(entitySet, data, new BinaryData(value, requestContentType));

  return ODataResponse.newBuilder().eTag(constructETag(entitySet, data)).build();
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:27,代码来源:ListsProcessor.java


示例8: simpleBatchWithAbsoluteUri

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
@Test
public void simpleBatchWithAbsoluteUri() throws Exception {
  final String batchRequestBody = StringHelper.inputStreamToStringCRLFLineBreaks(
      EntityProvider.writeBatchRequest(
          Collections.<BatchPart> singletonList(
              BatchQueryPart
                  .method(ODataHttpMethod.GET.name())
                  .uri(getEndpoint().getPath() + "Employees('2')/EmployeeName/$value")
                  .build()),
          BOUNDARY));
  final HttpResponse batchResponse = execute(batchRequestBody);
  final List<BatchSingleResponse> responses = EntityProvider.parseBatchResponse(
      batchResponse.getEntity().getContent(),
      batchResponse.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue());
  assertEquals(1, responses.size());
  final BatchSingleResponse response = responses.get(0);
  assertEquals(Integer.toString(HttpStatusCodes.OK.getStatusCode()), response.getStatusCode());
  assertEquals(HttpStatusCodes.OK.getInfo(), response.getStatusInfo());
  assertEquals(EMPLOYEE_2_NAME, response.getBody());
  assertEquals(HttpContentType.TEXT_PLAIN_UTF8, response.getHeader(HttpHeaders.CONTENT_TYPE));
  assertNotNull(response.getHeader(HttpHeaders.CONTENT_LENGTH));
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:23,代码来源:ClientBatchTest.java


示例9: parseEntry

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
private ODataEntry parseEntry(final EdmEntitySet entitySet, final InputStream content,
    final String requestContentType, final EntityProviderReadProperties properties) throws ODataBadRequestException {
  ODataContext context = getContext();
  final int timingHandle = context.startRuntimeMeasurement("EntityConsumer", "readEntry");

  ODataEntry entryValues;
  try {
    entryValues = EntityProvider.readEntry(requestContentType, entitySet, content, properties);
  } catch (final EntityProviderException e) {
    throw new ODataBadRequestException(ODataBadRequestException.BODY, e);
  }

  context.stopRuntimeMeasurement(timingHandle);

  return entryValues;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:17,代码来源:ListsProcessor.java


示例10: parseLink

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
public final UriInfo parseLink(final EdmEntitySet entitySet, final InputStream content, final String contentType)
    throws ODataJPARuntimeException {

  String uriString = null;
  UriInfo uri = null;
  try {
    uriString = EntityProvider.readLink(contentType, entitySet, content);
    ODataContext odataContext = context.getODataContext();
    final String svcRoot = odataContext.getPathInfo().getServiceRoot().toString();
    final String path =
        uriString.startsWith(svcRoot.toString()) ? uriString.substring(svcRoot.length()) : uriString;
    final List<PathSegment> pathSegment = getPathSegment(path);
    edm = getEdm();
    uri = UriParser.parse(edm, pathSegment, Collections.<String, String> emptyMap());
  } catch (ODataException e) {
    throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
  }
  return uri;
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:20,代码来源:ODataEntityParser.java


示例11: executeBatch

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
@Override
public ODataResponse executeBatch(final BatchHandler handler, final String contentType, final InputStream content)
    throws ODataException {
  try {
    oDataJPAContext.setODataContext(getContext());

    ODataResponse batchResponse;
    List<BatchResponsePart> batchResponseParts = new ArrayList<BatchResponsePart>();
    PathInfo pathInfo = getContext().getPathInfo();
    EntityProviderBatchProperties batchProperties = EntityProviderBatchProperties.init().pathInfo(pathInfo).build();
    List<BatchRequestPart> batchParts = EntityProvider.parseBatchRequest(contentType, content, batchProperties);

    for (BatchRequestPart batchPart : batchParts) {
      batchResponseParts.add(handler.handleBatchPart(batchPart));
    }
    batchResponse = EntityProvider.writeBatchResponse(batchResponseParts);
    return batchResponse;
  } finally {
    close(true);
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:22,代码来源:ODataJPADefaultProcessor.java


示例12: readEntity

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
@Override
public ODataResponse readEntity(GetEntityUriInfo uriInfo, String contentType) throws ODataException {
  HashMap<String, Object> data = new HashMap<String, Object>();

  if ("Employees".equals(uriInfo.getTargetEntitySet().getName())) {
    if ("2".equals(uriInfo.getKeyPredicates().get(0).getLiteral())) {
      data.put("EmployeeId", "1");
      data.put("TeamId", "420");
    }

    ODataContext context = getContext();
    EntityProviderWriteProperties writeProperties =
        EntityProviderWriteProperties.serviceRoot(context.getPathInfo().getServiceRoot()).build();

    return EntityProvider.writeEntry(contentType, uriInfo.getTargetEntitySet(), data, writeProperties);
  } else {
    throw new ODataApplicationException("Wrong testcall", Locale.getDefault(), HttpStatusCodes.NOT_IMPLEMENTED);
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:20,代码来源:InvalidDataInScenarioTest.java


示例13: selectIdAndBuildingLink

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
@Test
public void selectIdAndBuildingLink() throws Exception {
  EdmEntitySet roomsSet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
  List<String> selectedNavigationProperties = new ArrayList<String>();
  selectedNavigationProperties.add("nr_Building");

  List<String> selectedProperties = new ArrayList<String>();
  selectedProperties.add("Id");

  ExpandSelectTreeNode expandSelectTree =
      ExpandSelectTreeNode.entitySet(roomsSet).selectedProperties(selectedProperties).selectedLinks(
          selectedNavigationProperties).build();

  EntityProviderWriteProperties properties =
      EntityProviderWriteProperties.fromProperties(DEFAULT_PROPERTIES).expandSelectTree(expandSelectTree).build();
  ODataResponse entry = EntityProvider.writeEntry("application/xml", roomsSet, roomData, properties);

  String xml = StringHelper.inputStreamToString((InputStream) entry.getEntity());
  assertXpathExists("/a:entry/a:content/m:properties", xml);
  assertXpathExists("/a:entry/a:link[@type]", xml);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:22,代码来源:ExpandSelectProducerWithBuilderTest.java


示例14: expandBuilding

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
@Test
public void expandBuilding() throws Exception {
  EdmEntitySet roomsSet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
  List<String> expandedNavigationProperties = new ArrayList<String>();
  expandedNavigationProperties.add("nr_Building");

  ExpandSelectTreeNode expandSelectTree =
      ExpandSelectTreeNode.entitySet(roomsSet).expandedLinks(expandedNavigationProperties).build();

  Map<String, ODataCallback> callbacks = new HashMap<String, ODataCallback>();
  callbacks.put("nr_Building", new LocalCallback());
  EntityProviderWriteProperties properties =
      EntityProviderWriteProperties.fromProperties(DEFAULT_PROPERTIES).callbacks(callbacks).expandSelectTree(
          expandSelectTree).build();
  ODataResponse entry = EntityProvider.writeEntry("application/xml", roomsSet, roomData, properties);

  String xml = StringHelper.inputStreamToString((InputStream) entry.getEntity());
  assertXpathExists("/a:entry/a:content/m:properties", xml);
  assertXpathExists("/a:entry/a:link[@type]/m:inline", xml);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:21,代码来源:ExpandSelectProducerWithBuilderTest.java


示例15: expandBuildingAndSelectIdFromRoom

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
@Test
public void expandBuildingAndSelectIdFromRoom() throws Exception {
  EdmEntitySet roomsSet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
  List<String> expandedNavigationProperties = new ArrayList<String>();
  expandedNavigationProperties.add("nr_Building");

  List<String> selectedProperties = new ArrayList<String>();
  selectedProperties.add("Id");

  ExpandSelectTreeNode expandSelectTree =
      ExpandSelectTreeNode.entitySet(roomsSet).selectedProperties(selectedProperties).expandedLinks(
          expandedNavigationProperties).build();

  Map<String, ODataCallback> callbacks = new HashMap<String, ODataCallback>();
  callbacks.put("nr_Building", new LocalCallback());
  EntityProviderWriteProperties properties =
      EntityProviderWriteProperties.fromProperties(DEFAULT_PROPERTIES).callbacks(callbacks).expandSelectTree(
          expandSelectTree).build();
  ODataResponse entry = EntityProvider.writeEntry("application/xml", roomsSet, roomData, properties);

  String xml = StringHelper.inputStreamToString((InputStream) entry.getEntity());
  assertXpathExists("/a:entry/a:content/m:properties/d:Id", xml);
  assertXpathNotExists("/a:entry/a:content/m:properties/d:Name", xml);
  assertXpathExists("/a:entry/a:link[@type]/m:inline", xml);
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:26,代码来源:ExpandSelectProducerWithBuilderTest.java


示例16: roomsFeedWithRoomsToEmployeesInlineTeams

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
/**
 * Rooms navigate to Employees and has inline entry Teams
 * E.g: Rooms('1')/nr_Employees?$expand=ne_Team
 * @throws Exception
 */
@Test
public void roomsFeedWithRoomsToEmployeesInlineTeams() throws Exception {
  InputStream stream = getFileAsStream("RoomsToEmployeesWithInlineTeams.xml");
  assertNotNull(stream);
  FeedCallback callback = new FeedCallback();

  EntityProviderReadProperties readProperties = EntityProviderReadProperties.init()
      .mergeSemantic(false).callback(callback).build();

  ODataFeed feed =
      EntityProvider.readFeed("application/atom+xml", MockFacade.getMockEdm().getDefaultEntityContainer()
          .getEntitySet(
              "Employees"), stream, readProperties);
  assertNotNull(feed);
  assertEquals(2, feed.getEntries().size());

  Map<String, Object> inlineEntries = callback.getNavigationProperties();
  getExpandedData(inlineEntries, feed);
  for (ODataEntry entry : feed.getEntries()) {
    assertEquals(10, entry.getProperties().size());
    assertEquals(3, ((ODataEntry)entry.getProperties().get("ne_Team")).getProperties().size());
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:29,代码来源:XmlFeedConsumerTest.java


示例17: testAtomServiceDocument

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
@Test
public void testAtomServiceDocument() throws EntityProviderException {
  InputStream in = ClassLoader.class.getResourceAsStream("/svcExample.xml");
  ServiceDocument serviceDocument = EntityProvider.readServiceDocument(in, "application/atom+xml");
  assertNotNull(serviceDocument);
  AtomInfo atomInfo = serviceDocument.getAtomInfo();
  assertNotNull(atomInfo);
  for (Workspace workspace : atomInfo.getWorkspaces()) {
    assertEquals(10, workspace.getCollections().size());
    for (Collection collection : workspace.getCollections()) {
      assertNotNull(collection.getExtesionElements().get(0));
      assertEquals("member-title", collection.getExtesionElements().get(0).getName());
      assertEquals("foo", collection.getExtesionElements().get(0).getPrefix());
    }
  }
  for (ExtensionElement extElement : atomInfo.getExtesionElements()) {
    assertEquals(2, extElement.getAttributes().size());
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:20,代码来源:ServiceDocumentConsumerTest.java


示例18: testJsonServiceDocument

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
@Test
public void testJsonServiceDocument() throws EntityProviderException {
  InputStream in = ClassLoader.class.getResourceAsStream("/svcDocJson.json");
  ServiceDocument serviceDoc = EntityProvider.readServiceDocument(in, "application/json");
  assertNotNull(serviceDoc);
  assertNull(serviceDoc.getAtomInfo());
  List<EdmEntitySetInfo> entitySetsInfo = serviceDoc.getEntitySetsInfo();
  assertEquals(7, entitySetsInfo.size());
  for (EdmEntitySetInfo entitySetInfo : entitySetsInfo) {
    if (!entitySetInfo.isDefaultEntityContainer()) {
      if ("Container2".equals(entitySetInfo.getEntityContainerName())) {
        assertEquals("Photos", entitySetInfo.getEntitySetName());
      } else if ("Container.Nr1".equals(entitySetInfo.getEntityContainerName())) {
        assertEquals("Employees", entitySetInfo.getEntitySetName());
      }
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:19,代码来源:ServiceDocumentConsumerTest.java


示例19: testCompareJsonWithAtom

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
@Test
public void testCompareJsonWithAtom() throws EntityProviderException {
  InputStream inputJson = ClassLoader.class.getResourceAsStream("/svcDocJson.json");
  ServiceDocument serviceDocJson = EntityProvider.readServiceDocument(inputJson, "application/json");
  assertNotNull(serviceDocJson);
  List<EdmEntitySetInfo> entitySetsInfoJson = serviceDocJson.getEntitySetsInfo();

  InputStream inputAtom = ClassLoader.class.getResourceAsStream("/serviceDocument.xml");
  ServiceDocument serviceDocAtom = EntityProvider.readServiceDocument(inputAtom, "application/atom+xml");
  assertNotNull(serviceDocAtom);
  List<EdmEntitySetInfo> entitySetsInfoAtom = serviceDocAtom.getEntitySetsInfo();

  assertEquals(entitySetsInfoJson.size(), entitySetsInfoAtom.size());
  for (int i = 0; i < entitySetsInfoJson.size(); i++) {
    assertEquals(entitySetsInfoJson.get(i).getEntitySetName(), entitySetsInfoAtom.get(i).getEntitySetName());
    assertEquals(entitySetsInfoJson.get(i).getEntitySetUri(), entitySetsInfoAtom.get(i).getEntitySetUri());
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:19,代码来源:ServiceDocumentConsumerTest.java


示例20: simpleBatch

import org.apache.olingo.odata2.api.ep.EntityProvider; //导入依赖的package包/类
@Test
public void simpleBatch() throws Exception {
  List<BatchPart> batch = new ArrayList<BatchPart>();
  BatchPart request = BatchQueryPart.method(ODataHttpMethod.GET.name()).uri("$metadata").build();
  batch.add(request);

  InputStream body = EntityProvider.writeBatchRequest(batch, BOUNDARY);
  String batchRequestBody = StringHelper.inputStreamToStringCRLFLineBreaks(body);
  checkMimeHeaders(batchRequestBody);
  checkBoundaryDelimiters(batchRequestBody);
  assertTrue(batchRequestBody.contains("GET $metadata HTTP/1.1"));

  HttpResponse batchResponse = execute(batchRequestBody);
  InputStream responseBody = batchResponse.getEntity().getContent();
  String contentType = batchResponse.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue();
  List<BatchSingleResponse> responses = EntityProvider.parseBatchResponse(responseBody, contentType);
  for (BatchSingleResponse response : responses) {
    assertEquals("200", response.getStatusCode());
    assertEquals("OK", response.getStatusInfo());
    assertTrue(response.getBody().contains("<edmx:Edmx"));
    assertEquals("application/xml;charset=utf-8", response.getHeader(HttpHeaders.CONTENT_TYPE));
    assertNotNull(response.getHeader(HttpHeaders.CONTENT_LENGTH));
  }
}
 
开发者ID:apache,项目名称:olingo-odata2,代码行数:25,代码来源:ClientBatchTest.java



注:本文中的org.apache.olingo.odata2.api.ep.EntityProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AbstractFeature类代码示例发布时间:2022-05-22
下一篇:
Java MessageFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap