当前位置: 首页>>代码示例>>Java>>正文


Java HttpMethod类代码示例

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


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

示例1: updateEntity

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
public static void updateEntity(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo, Entity requestEntity,
		HttpMethod httpMethod) throws OData2SparqlException {
	SparqlStatement sparqlStatement = null;
	// 1. Retrieve the entity set which belongs to the requested entity
	List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
	// Note: only in our example we can assume that the first segment is the EntitySet
	UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
	EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
	//EdmEntityType edmEntityType = edmEntitySet.getEntityType();

	RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);

	List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
	// Note that this updateEntity()-method is invoked for both PUT or PATCH operations  
	SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
			rdfEdmProvider);
	try {
		sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateUpdateEntity(entityType, keyPredicates,
				requestEntity);
	} catch (Exception e) {
		log.error(e.getMessage());
		throw new OData2SparqlException(e.getMessage());
	}
	sparqlStatement.executeDelete(rdfEdmProvider);
}
 
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:26,代码来源:SparqlBaseCommand.java

示例2: queryESCompCollDerivedJson

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的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

示例3: queryESAllPrimDerivedXml

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void queryESAllPrimDerivedXml() throws Exception {
  URL url = new URL(SERVICE_URI + "ESAllPrimDerived(0)?$expand=NavPropertyETTwoPrimMany&$format=xml");

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

  assertEquals(HttpStatusCode.OK.getStatusCode(), connection.getResponseCode());

  final String content = IOUtils.toString(connection.getInputStream());
  assertTrue(content.contains("term=\"#olingo.odata.test1.ETBase\"/>"));
  assertTrue(content.contains(
      "<d:PropertyInt16 m:type=\"Int16\">32766</d:PropertyInt16>" +
      "<d:PropertyString>Test String1</d:PropertyString>" +
      "<d:AdditionalPropertyString_5>Additional String1</d:AdditionalPropertyString_5>"));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:DerivedAndMixedTypeTestITCase.java

示例4: queryESCompCollDerivedJsonNone

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的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

示例5: queryESTwoPrimWithEntityTypeCast

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

  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());
  assertEquals(ContentType.JSON_FULL_METADATA, 
      ContentType.create(connection.getHeaderField(HttpHeader.CONTENT_TYPE)));

  final String content = IOUtils.toString(connection.getInputStream());
  assertTrue(content.contains("\"@odata.type\":\"#olingo.odata.test1.ETBase\","
      + "\"@odata.id\":\"ESBase(111)\","
      + "\"[email protected]\":\"#Int16\","
      + "\"PropertyInt16\":111,"
      + "\"PropertyString\":\"TEST A\","
      + "\"AdditionalPropertyString_5\":\"TEST A 0815\""));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:DerivedAndMixedTypeTestITCase.java

示例6: streamESStreamJson

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void streamESStreamJson() throws Exception {
  URL url = new URL(SERVICE_URI + "ESStream?$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("[email protected]\"," +
          "\"[email protected]\"," +
          "\"[email protected]\""));
  assertTrue(content.contains("\"PropertyString\":\"TEST 1->streamed\""));
  assertTrue(content.contains("\"PropertyString\":\"TEST 2->streamed\""));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:BasicStreamITCase.java

示例7: validatePropertyOperations

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
private void validatePropertyOperations(final UriInfo uriInfo, final HttpMethod method)
    throws UriValidationException {
  final List<UriResource> parts = uriInfo.getUriResourceParts();
  final UriResource last = !parts.isEmpty() ? parts.get(parts.size() - 1) : null;
  final UriResource previous = parts.size() > 1 ? parts.get(parts.size() - 2) : null;
  if (last != null
      && (last.getKind() == UriResourceKind.primitiveProperty
      || last.getKind() == UriResourceKind.complexProperty
      || (last.getKind() == UriResourceKind.value
          && previous != null && previous.getKind() == UriResourceKind.primitiveProperty))) {
    final EdmProperty property = ((UriResourceProperty)
        (last.getKind() == UriResourceKind.value ? previous : last)).getProperty();
    if (method == HttpMethod.PATCH && property.isCollection()) {
      throw new UriValidationException("Attempt to patch collection property.",
          UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD, method.toString());
    }
    if (method == HttpMethod.DELETE && !property.isNullable()) {
      throw new UriValidationException("Attempt to delete non-nullable property.",
          UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD, method.toString());
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:UriValidator.java

示例8: streamESStreamServerSidePagingNextXml

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void streamESStreamServerSidePagingNextXml() throws Exception {
  URL url = new URL(SERVICE_URI + "ESStreamServerSidePaging?$format=xml&$skiptoken=1%2A10");

  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("<a:link rel=\"next\" href="));
  assertTrue(content.contains("ESStreamServerSidePaging?$format=xml&amp;%24skiptoken=2%2A10\"/>"));
  assertTrue(content.contains("<a:id>ESStreamServerSidePaging(11)</a:id>"));
  assertTrue(content.contains("<d:PropertyInt16 m:type=\"Int16\">11</d:PropertyInt16>"));
  assertTrue(content.contains("<d:PropertyStream m:type=\"Stream\">readLink</d:PropertyStream>"));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:BasicStreamITCase.java

示例9: streamESStreamServerSidePagingJsonNext

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void streamESStreamServerSidePagingJsonNext() throws Exception {
  URL url = new URL(SERVICE_URI + "ESStreamServerSidePaging?$format=json&$skiptoken=1%2A10");

  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\":12,"+
  "\"[email protected]\":\"eTag\",\"[email protected]\":\"image/jpeg\"}"));
  assertTrue(content.contains("\"@odata.nextLink\""));
  assertTrue(content.contains("ESStreamServerSidePaging?$format=json&%24skiptoken=2%2A10"));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:BasicStreamITCase.java

示例10: streamCountFalsetXml

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void streamCountFalsetXml() throws Exception {
  URL url = new URL(SERVICE_URI + "ESStreamServerSidePaging?$count=false&$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("<a:link rel=\"next\" href="));
  assertTrue(content.contains("ESStreamServerSidePaging?$count=false&amp;$format=xml&amp;%24skiptoken=1%2A10\"/>"));
  assertTrue(content.contains("<a:id>ESStreamServerSidePaging(1)</a:id>"));
  assertTrue(content.contains("<d:PropertyInt16 m:type=\"Int16\">1</d:PropertyInt16>"));
  assertTrue(content.contains("<d:PropertyStream m:type=\"Stream\">readLink</d:PropertyStream>"));
  assertFalse(content.contains("<m:count>504</m:count>"));
  }
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:BasicStreamITCase.java

示例11: streamCountFalseJson

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void streamCountFalseJson() throws Exception {
  URL url = new URL(SERVICE_URI + "ESStreamServerSidePaging?$count=false&$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\":2,"+
  "\"Pr[email protected]\":\"eTag\",\"[email protected]\":\"image/jpeg\"}"));
  assertTrue(content.contains("\"@odata.nextLink\""));
  assertTrue(content.contains("ESStreamServerSidePaging?$count=false&$format=json&%24skiptoken=1%2A10"));
  assertFalse(content.contains("\"@odata.count\":504"));
  }
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:BasicStreamITCase.java

示例12: updateEntity

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
                          ContentType requestFormat, ContentType responseFormat)
						throws ODataApplicationException, DeserializerException, SerializerException {
	
	// 1. Retrieve the entity set which belongs to the requested entity 
	List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
	// Note: only in our example we can assume that the first segment is the EntitySet
	UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0); 
	EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
	EdmEntityType edmEntityType = edmEntitySet.getEntityType();

	// 2. update the data in backend
	// 2.1. retrieve the payload from the PUT request for the entity to be updated 
	InputStream requestInputStream = request.getBody();
	ODataDeserializer deserializer = odata.createDeserializer(requestFormat);
	DeserializerResult result = deserializer.entity(requestInputStream, edmEntityType);
	Entity requestEntity = result.getEntity();
	// 2.2 do the modification in backend
	List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
	// Note that this updateEntity()-method is invoked for both PUT or PATCH operations
	HttpMethod httpMethod = request.getMethod();
	storage.updateEntityData(edmEntitySet, keyPredicates, requestEntity, httpMethod);
	
	//3. configure the response object
	response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:DemoEntityProcessor.java

示例13: dispatchComplexProperty

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Test
public void dispatchComplexProperty() throws Exception {
  final String uri = "ESMixPrimCollComp(7)/PropertyComp";
  final ComplexProcessor processor = mock(ComplexProcessor.class);

  dispatch(HttpMethod.GET, uri, processor);
  verify(processor).readComplex(
      any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class));

  dispatch(HttpMethod.PATCH, uri, processor);
  verify(processor).updateComplex(
      any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class),
      any(ContentType.class));

  dispatch(HttpMethod.PUT, uri, processor);
  verify(processor, times(2)).updateComplex(
      any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class),
      any(ContentType.class));

  dispatch(HttpMethod.DELETE, uri, processor);
  verify(processor).deleteComplex(any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class));

  dispatchMethodNotAllowed(HttpMethod.POST, uri, processor);
  dispatchMethodNotAllowed(HttpMethod.HEAD, uri, processor);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:ODataHandlerImplTest.java

示例14: getEntityUpdateRequest

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Override
public <E extends ClientEntity> ODataEntityUpdateRequest<E> getEntityUpdateRequest(
    final UpdateType type, final E entity) {

  if (entity.getEditLink() == null) {
    throw new IllegalArgumentException("No edit link found");
  }

  final ODataEntityUpdateRequest<E> req;

  if (client.getConfiguration().isUseXHTTPMethod()) {
    req = new ODataEntityUpdateRequestImpl<E>(client, HttpMethod.POST, entity.getEditLink(), entity);
    req.setXHTTPMethod(type.getMethod().name());
  } else {
    req = new ODataEntityUpdateRequestImpl<E>(client, type.getMethod(), entity.getEditLink(), entity);
  }

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

示例15: getPropertyComplexValueUpdateRequest

import org.apache.olingo.commons.api.http.HttpMethod; //导入依赖的package包/类
@Override
public ODataPropertyUpdateRequest getPropertyComplexValueUpdateRequest(
    final URI targetURI, final UpdateType type, final ClientProperty property) {

  if (!property.hasComplexValue()) {
    throw new IllegalArgumentException("A complex value is required");
  }

  final ODataPropertyUpdateRequest req;

  if (client.getConfiguration().isUseXHTTPMethod()) {
    req = new ODataPropertyUpdateRequestImpl(client, HttpMethod.POST, targetURI, property);
    req.setXHTTPMethod(type.getMethod().name());
  } else {
    req = new ODataPropertyUpdateRequestImpl(client, type.getMethod(), targetURI, property);
  }

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


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