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

Java HttpHeader类代码示例

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

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



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

示例1: readServiceDocument

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
@Override
public void readServiceDocument(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
		final ContentType requestedContentType) throws ODataApplicationException, ODataLibraryException {
	boolean isNotModified = false;
	ServiceMetadataETagSupport eTagSupport = serviceMetadata.getServiceMetadataETagSupport();
	if (eTagSupport != null && eTagSupport.getServiceDocumentETag() != null) {
		// Set application etag at response
		response.setHeader(HttpHeader.ETAG, eTagSupport.getServiceDocumentETag());
		// Check if service document has been modified
		ETagHelper eTagHelper = odata.createETagHelper();
		isNotModified = eTagHelper.checkReadPreconditions(eTagSupport.getServiceDocumentETag(),
				request.getHeaders(HttpHeader.IF_MATCH), request.getHeaders(HttpHeader.IF_NONE_MATCH));
	}

	// Send the correct response req.getRequestURL().toString().replace(req.getServletPath(), "")
	if (isNotModified) {
		response.setStatusCode(HttpStatusCode.NOT_MODIFIED.getStatusCode());
	} else {
		ODataSerializer serializer = odata.createSerializer(requestedContentType);
		//Provide serviceRoot with rawBaseUri as Excel PowerQuery does not like relative URIs
		response.setContent(serializer.serviceDocument(serviceMetadata, request.getRawBaseUri()).getContent());
		response.setStatusCode(HttpStatusCode.OK.getStatusCode());
		response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
	}
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:26,代码来源:SparqlDefaultProcessor.java


示例2: readMetadata

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
@Override
public void readMetadata(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
		final ContentType requestedContentType) throws ODataApplicationException, ODataLibraryException {
	boolean isNotModified = false;
	ServiceMetadataETagSupport eTagSupport = serviceMetadata.getServiceMetadataETagSupport();
	if (eTagSupport != null && eTagSupport.getMetadataETag() != null) {
		// Set application etag at response
		response.setHeader(HttpHeader.ETAG, eTagSupport.getMetadataETag());
		// Check if metadata document has been modified
		ETagHelper eTagHelper = odata.createETagHelper();
		isNotModified = eTagHelper.checkReadPreconditions(eTagSupport.getMetadataETag(),
				request.getHeaders(HttpHeader.IF_MATCH), request.getHeaders(HttpHeader.IF_NONE_MATCH));
	}

	// Send the correct response
	if (isNotModified) {
		response.setStatusCode(HttpStatusCode.NOT_MODIFIED.getStatusCode());
	} else {
		ODataSerializer serializer = odata.createSerializer(requestedContentType);
		response.setContent(serializer.metadataDocument(serviceMetadata).getContent());
		response.setStatusCode(HttpStatusCode.OK.getStatusCode());
		response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
	}
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:25,代码来源:SparqlDefaultProcessor.java


示例3: writePropertyValue

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
private void writePropertyValue(ODataResponse response, Property property) throws ODataApplicationException {
	if (property == null) {
		throw new ODataApplicationException("No property found", HttpStatusCode.NOT_FOUND.getStatusCode(),
				Locale.ENGLISH);
	} else {
		if (property.getValue() == null) {
			response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
		} else {
			String value = String.valueOf(property.getValue());
			ByteArrayInputStream serializerContent = new ByteArrayInputStream(value.getBytes());//Charset.forName("UTF-8")));
			response.setContent(serializerContent);
			response.setStatusCode(HttpStatusCode.OK.getStatusCode());
			response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.TEXT_PLAIN.toContentTypeString());
		}
	}
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:17,代码来源:SparqlPrimitiveValueProcessor.java


示例4: read

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
/**
 * Method is a template to provide behavior for all read processors.
 */
@Override
public void read(ODataRequest request, ODataResponse response, UriInfo uriInfo,
        ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
    this.request = request;
    ESRequest searchRequest = createRequest(uriInfo);
    ElasticEdmEntitySet entitySet = searchRequest.getEntitySet();
    SearchResponse searchResponse = searchRequest.execute();
    InstanceData<T, V> data = parseResponse(searchResponse, entitySet);

    ODataSerializer serializer = odata.createSerializer(responseFormat);
    SerializerResult serializerResult = serialize(serializer, data, entitySet, uriInfo);
    response.setContent(serializerResult.getContent());
    response.setStatusCode(HttpStatusCode.OK.getStatusCode());
    response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:19,代码来源:AbstractESReadProcessor.java


示例5: countEntitySet

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
@Override
public void countEntitySet(ODataRequest request, ODataResponse response,UriInfo uriInfo) {
    try {
        checkExpand(uriInfo.asUriInfoResource());
        ODataSQLBuilder visitor = new ODataSQLBuilder(this.client.getMetadataStore(), this.prepared);
        visitor.visit(uriInfo);
        Query query = visitor.selectQuery(true);
        List<SQLParam> parameters = visitor.getParameters();

        CountResponse countResponse = this.client.executeCount(query,parameters);
        ByteArrayInputStream bis = new ByteArrayInputStream(String.valueOf(countResponse.getCount()).getBytes());
        response.setContent(bis);
        response.setStatusCode(HttpStatusCode.OK.getStatusCode());
        response.setHeader(HttpHeader.CONTENT_TYPE,ContentType.TEXT_PLAIN.toContentTypeString());
    } catch (Exception e) {
        handleException(response, ContentType.APPLICATION_JSON, e);
    }
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:19,代码来源:TeiidProcessor.java


示例6: queryESCompCollDerivedJson

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
@Test
public void queryESCompCollDerivedJson() throws Exception {
  URL url = new URL(SERVICE_URI + "ESCompCollDerived?$format=json");

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
  assertEquals(ContentType.JSON, ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));

  final String content = IOUtils.toString(connection.getInputStream());

  assertTrue(content.contains(
      "[{\"PropertyInt16\":32767,\"PropertyCompAno\":null,\"CollPropertyCompAno\":[{\"PropertyString\":" +
      "\"TEST9876\"}]},{\"PropertyInt16\":12345,\"PropertyCompAno\":{\"@odata.type\":" +
      "\"#olingo.odata.test1.CTBaseAno\",\"PropertyString\":\"Num111\",\"AdditionalPropString\":" +
      "\"Test123\"},\"CollPropertyCompAno\":[{\"@odata.type\":\"#olingo.odata.test1.CTBaseAno\"," +
      "\"PropertyString\":\"TEST12345\",\"AdditionalPropString\":\"Additional12345\"}," +
      "{\"PropertyString\":\"TESTabcd\"}]}]}" ));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:DerivedAndMixedTypeTestITCase.java


示例7: queryESCompCollDerivedXml

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
@Test
public void queryESCompCollDerivedXml() throws Exception {
  URL url = new URL(SERVICE_URI + "ESCompCollDerived?$format=xml");

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
  assertEquals(ContentType.APPLICATION_XML, ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));

  final String content = IOUtils.toString(connection.getInputStream());
  assertTrue(content.contains("<d:PropertyCompAno m:type=\"#olingo.odata.test1.CTBaseAno\">" +
      "<d:PropertyString>Num111</d:PropertyString>" +
      "<d:AdditionalPropString>Test123</d:AdditionalPropString>" +
      "</d:PropertyCompAno>" +
      "<d:CollPropertyCompAno m:type=\"#Collection(olingo.odata.test1.CTTwoPrimAno)\">" +
      "<m:element m:type=\"olingo.odata.test1.CTBaseAno\">" +
      "<d:PropertyString>TEST12345</d:PropertyString>" +
      "<d:AdditionalPropString>Additional12345</d:AdditionalPropString>" ));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:DerivedAndMixedTypeTestITCase.java


示例8: queryESCompCollDerivedJsonNone

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
@Test
public void queryESCompCollDerivedJsonNone() throws Exception {
  URL url = new URL(SERVICE_URI + "ESCompCollDerived");

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.setRequestProperty(HttpHeader.ACCEPT, "application/json;odata.metadata=none");
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
  assertEquals(ContentType.JSON_NO_METADATA, ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));

  final String content = IOUtils.toString(connection.getInputStream());

  assertTrue(content.contains(
      "[{\"PropertyInt16\":32767,\"PropertyCompAno\":null,\"CollPropertyCompAno\":[{\"PropertyString\":" +
      "\"TEST9876\"}]},{\"PropertyInt16\":12345,\"PropertyCompAno\":{"+
      "\"PropertyString\":\"Num111\",\"AdditionalPropString\":" +
      "\"Test123\"},\"CollPropertyCompAno\":[{" +
      "\"PropertyString\":\"TEST12345\",\"AdditionalPropString\":\"Additional12345\"}," +
      "{\"PropertyString\":\"TESTabcd\"}]}]}" ));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:DerivedAndMixedTypeTestITCase.java


示例9: isChangeSet

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
private boolean isChangeSet(final Header headers) throws BatchDeserializerException {
  final List<String> contentTypes = headers.getHeaders(HttpHeader.CONTENT_TYPE);

  if (contentTypes.isEmpty()) {
    throw new BatchDeserializerException("Missing content type",
        BatchDeserializerException.MessageKeys.MISSING_CONTENT_TYPE,
        Integer.toString(headers.getLineNumber()));
  }

  boolean changeSet = false;
  for (String contentType : contentTypes) {
    if (isContentTypeMultiPartMixed(contentType)) {
      changeSet = true;
    }
  }
  return changeSet;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:BatchBodyPart.java


示例10: getODataPath

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
private String getODataPath(final ODataRequest request, final ODataResponse response)
    throws BatchDeserializerException {
  String resourceUri = null;

  if (request.getMethod() == HttpMethod.POST) {
    // Create entity
    // The URI of the new resource will be generated by the server and published in the location header
    final String locationHeader = response.getHeader(HttpHeader.LOCATION);
    resourceUri = locationHeader == null ? null : parseODataPath(locationHeader, request.getRawBaseUri());
  } else {
    // Update, Upsert (PUT, PATCH, Delete)
    // These methods still addresses a given resource, so we use the URI given by the request
    resourceUri = request.getRawODataPath();
  }

  return resourceUri;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:BatchReferenceRewriter.java


示例11: boundFunctionReturningDerievedType

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
@Test
public void boundFunctionReturningDerievedType() throws Exception {
  URL url = new URL(SERVICE_URI + "ESBase(111)/olingo.odata.test1.ETTwoBase/"
      + "olingo.odata.test1.BFESBaseRTESTwoBase()");

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.setRequestProperty(HttpHeader.ACCEPT, "application/json");
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
  final String expected =  "\"PropertyInt16\":111,"
      +  "\"PropertyString\":\"TEST A\","
      +  "\"AdditionalPropertyString_5\":\"TEST A 0815\","
      +  "\"AdditionalPropertyString_6\":\"TEST B 0815\"";
  String content = IOUtils.toString(connection.getInputStream());
  assertTrue(content.contains(expected));
  connection.disconnect();
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:BasicBoundFunctionITCase.java


示例12: biggerResponse

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
@Test
public void biggerResponse() throws Exception {
  ODataResponse response = new ODataResponse();
  response.setStatusCode(HttpStatusCode.ACCEPTED.getStatusCode());
  response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.APPLICATION_JSON.toContentTypeString());
  response.setHeader(HttpHeader.CONTENT_LENGTH, String.valueOf(0));

  String testData = testData(20000);
  response.setContent(IOUtils.toInputStream(testData));

  AsyncResponseSerializer serializer = new AsyncResponseSerializer();
  InputStream in = serializer.serialize(response);
  String result = IOUtils.toString(in);
  assertEquals("HTTP/1.1 202 Accepted" + CRLF
      + "Content-Type: application/json" + CRLF
      + "Content-Length: 0" + CRLF + CRLF
      + testData, result);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:AsyncResponseSerializerTest.java


示例13: createMediaEntity

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
@Override
public void createMediaEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
    ContentType requestFormat, ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
  
  final EdmEntitySet edmEntitySet = Util.getEdmEntitySet(uriInfo);
  final byte[] mediaContent = odata.createFixedFormatDeserializer().binary(request.getBody());
  
  final Entity entity = storage.createMediaEntity(edmEntitySet.getEntityType(), 
                                                  requestFormat.toContentTypeString(), 
                                                  mediaContent);
  
  final ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build();
  final EntitySerializerOptions opts = EntitySerializerOptions.with().contextURL(contextUrl).build();
  final SerializerResult serializerResult = odata.createSerializer(responseFormat).entity(serviceMetadata,
      edmEntitySet.getEntityType(), entity, opts);
  
  final String location = request.getRawBaseUri() + '/'
      + odata.createUriHelper().buildCanonicalURL(edmEntitySet, entity);
  response.setContent(serializerResult.getContent());
  response.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
  response.setHeader(HttpHeader.LOCATION, location);
  response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:24,代码来源:DemoEntityProcessor.java


示例14: buildResponse

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
private ODataResponse buildResponse(final ODataRequest request) {
  final ODataResponse oDataResponse = new ODataResponse();

  if (request.getMethod() == HttpMethod.POST) {
    oDataResponse.setStatusCode(HttpStatusCode.CREATED.getStatusCode());
    oDataResponse.setHeader(HttpHeader.LOCATION, createResourceUri(request));
  } else {
    oDataResponse.setStatusCode(HttpStatusCode.OK.getStatusCode());
  }

  final String contentId = request.getHeader(HttpHeader.CONTENT_ID);
  if (contentId != null) {
    oDataResponse.setHeader(HttpHeader.CONTENT_ID, contentId);
  }

  return oDataResponse;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:MockedBatchHandlerTest.java


示例15: duplicatedAddList

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
@Test
public void duplicatedAddList() {
  Header header = new Header(1);
  header.addHeader(HttpHeader.CONTENT_TYPE, ContentType.MULTIPART_MIXED.toContentTypeString(), 1);
  header.addHeader(HttpHeader.CONTENT_TYPE, Arrays.asList(new String[] {
      ContentType.MULTIPART_MIXED.toContentTypeString(),
      ContentType.APPLICATION_ATOM_SVC.toContentTypeString() }), 2);

  assertEquals(ContentType.MULTIPART_MIXED + ", " + ContentType.APPLICATION_ATOM_SVC, header
      .getHeader(HttpHeader.CONTENT_TYPE));
  assertEquals(2, header.getHeaders(HttpHeader.CONTENT_TYPE).size());
  assertEquals(ContentType.MULTIPART_MIXED.toContentTypeString(),
      header.getHeaders(HttpHeader.CONTENT_TYPE).get(0));
  assertEquals(ContentType.APPLICATION_ATOM_SVC.toContentTypeString(),
      header.getHeaders(HttpHeader.CONTENT_TYPE).get(1));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:HeaderTest.java


示例16: testBaseTypeDerivedTypeCasting3

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
@Test
public void testBaseTypeDerivedTypeCasting3() throws Exception {
  URL url = new URL(SERVICE_URI + "ESTwoPrim(32766)/olingo.odata.test1.ETTwoPrim");

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.setRequestProperty(HttpHeader.ACCEPT, "application/json;odata.metadata=full");
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
  final String content = IOUtils.toString(connection.getInputStream());

  assertTrue(content.contains("\"PropertyInt16\":32766"));
  assertTrue(content.contains("\"PropertyString\":\"Test String1\""));
  assertTrue(content.contains("\"@odata.type\":\"#olingo.odata.test1.ETTwoPrim\""));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:BasicHttpITCase.java


示例17: testBaseTypeDerivedComplexTypeCasting1

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
@Test
public void testBaseTypeDerivedComplexTypeCasting1() throws Exception {
  URL url = new URL(SERVICE_URI + "ESMixPrimCollComp(32767)/PropertyComp/olingo.odata.test1.CTBase");

  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setRequestMethod(HttpMethod.GET.name());
  connection.setRequestProperty(HttpHeader.ACCEPT, "application/json;odata.metadata=full");
  connection.connect();

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());
  final String content = IOUtils.toString(connection.getInputStream());

  assertTrue(content.contains("\"PropertyInt16\":111"));
  assertTrue(content.contains("\"PropertyString\":\"TEST A\""));
  assertTrue(content.contains("\"AdditionalPropString\":null"));
  assertTrue(content.contains("\"@odata.type\":\"#olingo.odata.test1.CTBase\""));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:BasicHttpITCase.java


示例18: handleServerError

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
void handleServerError(final ODataRequest request, final ODataResponse response,
    final ODataServerError serverError) {
  try {
    ODataSerializer serializer = this.odata.createSerializer(this.contentType);
    ErrorResponse errorResponse = new ErrorResponse(this.metadata, serializer, this.contentType, response);
    handler.processError(serverError, errorResponse);
  } catch (Exception e) {
    // This should never happen but to be sure we have this catch here
    // to prevent sending a stacktrace to a client.
    String responseContent = "{\"error\":{\"code\":null,\"message\":\"An unexpected exception occurred during "
        + "error processing with message: " + e.getMessage() + "\"}}"; //$NON-NLS-1$ //$NON-NLS-2$
    response.setContent(new ByteArrayInputStream(responseContent.getBytes()));
    response.setStatusCode(HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode());
    response.setHeader(HttpHeader.CONTENT_TYPE,
        ContentType.APPLICATION_JSON.toContentTypeString());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:ErrorHandler.java


示例19: serializeEntityCollection

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
private SerializerResult serializeEntityCollection(final ODataRequest request, final EntityCollection
    entityCollection, final EdmEntitySet edmEntitySet, final EdmEntityType edmEntityType,
    final ContentType requestedFormat, final ExpandOption expand, final SelectOption select,
    final CountOption countOption, String id, final boolean isContNav) throws ODataLibraryException {

  return odata.createSerializer(requestedFormat, request.getHeaders(HttpHeader.ODATA_VERSION))
      .entityCollection(
      serviceMetadata,
      edmEntityType,
      entityCollection,
      EntityCollectionSerializerOptions.with()
          .contextURL(isODataMetadataNone(requestedFormat) ? null :
              getContextUrl(request.getRawODataPath(), edmEntitySet, edmEntityType, false, expand, select, isContNav))
          .count(countOption)
          .expand(expand).select(select)
          .id(id)
          .build());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:TechnicalEntityProcessor.java


示例20: deletePrimitive

import org.apache.olingo.commons.api.http.HttpHeader; //导入依赖的package包/类
@Test
public void deletePrimitive() throws Exception {
  final URI uri = getClient().newURIBuilder(SERVICE_URI)
      .appendEntitySetSegment("ESTwoPrim").appendKeySegment(32766).appendPropertySegment("PropertyString")
      .build();
  final ODataDeleteRequest request = getClient().getCUDRequestFactory().getDeleteRequest(uri);
  final ODataDeleteResponse response = request.execute();
  assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());

  // Check that the property is really gone.
  // This check has to be in the same session in order to access the same data provider.
  ODataPropertyRequest<ClientProperty> propertyRequest = getClient().getRetrieveRequestFactory()
      .getPropertyRequest(uri);
  propertyRequest.addCustomHeader(HttpHeader.COOKIE, response.getHeader(HttpHeader.SET_COOKIE).iterator().next());
  assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), propertyRequest.execute().getStatusCode());

  try {
    getClient().getCUDRequestFactory().getDeleteRequest(getClient().newURIBuilder(SERVICE_URI)
        .appendEntitySetSegment("ESTwoPrim").appendKeySegment(32766).appendPropertySegment("PropertyInt16")
        .build()).execute();
    fail("Expected exception not thrown!");
  } catch (final ODataClientErrorException e) {
    assertEquals(HttpStatusCode.BAD_REQUEST.getStatusCode(), e.getStatusLine().getStatusCode());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:PrimitiveComplexITCase.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java IndexRoutingTable类代码示例发布时间:2022-05-22
下一篇:
Java Vpc类代码示例发布时间: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