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


Java HttpMethod.POST属性代码示例

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


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

示例1: getODataPath

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,代码行数:17,代码来源:BatchReferenceRewriter.java

示例2: execute

/**
 * {@inheritDoc }
 */
@Override
public ODataInvokeResponse<T> execute() {
  final InputStream input = getPayload();

  if (!this.parameters.isEmpty()) {
    if (this.method == HttpMethod.GET) {
      ((HttpRequestBase) this.request).setURI(
          URIUtils.buildFunctionInvokeURI(this.uri, parameters));
    } else if (this.method == HttpMethod.POST) {
      ((HttpPost) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));

      setContentType(getActualFormat(getPOSTParameterFormat()));
    }
  }

  try {
    return new ODataInvokeResponseImpl(odataClient, httpClient, doExecute());
  } finally {
    IOUtils.closeQuietly(input);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:24,代码来源:AbstractODataInvokeRequest.java

示例3: invalidChangeSetBoundary

@Test
public void invalidChangeSetBoundary() throws Exception {
  final String batch = "--" + BOUNDARY + CRLF
      + HttpHeader.CONTENT_TYPE + ": " + MULTIPART_MIXED + ";boundary=" + CHANGESET_BOUNDARY + CRLF
      + CRLF
      + "--" + CHANGESET_BOUNDARY.substring(0, CHANGESET_BOUNDARY.length() - 1) + CRLF
      + MIME_HEADERS
      + HttpHeader.CONTENT_ID + ": 1" + CRLF
      + CRLF
      + HttpMethod.POST + " ESAllPrim" + HTTP_VERSION + CRLF
      + HttpHeader.CONTENT_TYPE + ": " + APPLICATION_JSON + CRLF
      + CRLF
      + "--" + CHANGESET_BOUNDARY + "--" + CRLF
      + CRLF
      + "--" + BOUNDARY + "--";

  final List<BatchRequestPart> parts = parse(batch);
  Assert.assertEquals(1, parts.size());

  final BatchRequestPart part = parts.get(0);
  Assert.assertTrue(part.isChangeSet());
  Assert.assertEquals(0, part.getRequests().size());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:BatchRequestParserTest.java

示例4: getPropertyComplexValueUpdateRequest

@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,代码行数:19,代码来源:CUDRequestFactoryImpl.java

示例5: getPropertyCollectionValueUpdateRequest

@Override
public ODataPropertyUpdateRequest getPropertyCollectionValueUpdateRequest(
    final URI targetURI, final ClientProperty property) {

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

  final ODataPropertyUpdateRequest req;

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

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

示例6: extractMethod

/**
 * Extract method.
 *
 * @param odRequest
 *            the od request
 * @param httpRequest
 *            the http request
 * @throws ODataTranslatedException
 *             the o data translated exception
 */
private void extractMethod(final ODataRequest odRequest,
		final HttpServletRequest httpRequest)
		throws ODataTranslatedException {
	try {
		HttpMethod httpRequestMethod = HttpMethod.valueOf(httpRequest
				.getMethod());

		if (httpRequestMethod == HttpMethod.POST) {
			String xHttpMethod = httpRequest
					.getHeader(HttpHeader.X_HTTP_METHOD);
			String xHttpMethodOverride = httpRequest
					.getHeader(HttpHeader.X_HTTP_METHOD_OVERRIDE);

			if (xHttpMethod == null && xHttpMethodOverride == null) {
				odRequest.setMethod(httpRequestMethod);
			} else if (xHttpMethod == null) {
				odRequest
						.setMethod(HttpMethod.valueOf(xHttpMethodOverride));
			} else if (xHttpMethodOverride == null) {
				odRequest.setMethod(HttpMethod.valueOf(xHttpMethod));
			} else {
				if (!xHttpMethod.equalsIgnoreCase(xHttpMethodOverride)) {
					throw new ODataHandlerException(
							"Ambiguous X-HTTP-Methods",
							ODataHandlerException.MessageKeys.AMBIGUOUS_XHTTP_METHOD,
							xHttpMethod, xHttpMethodOverride);
				}
				odRequest.setMethod(HttpMethod.valueOf(xHttpMethod));
			}
		} else {
			odRequest.setMethod(httpRequestMethod);
		}
	} catch (IllegalArgumentException e) {
		throw new ODataHandlerException("Invalid HTTP method"
				+ httpRequest.getMethod(),
				ODataHandlerException.MessageKeys.INVALID_HTTP_METHOD,
				httpRequest.getMethod());
	}
}
 
开发者ID:rohitghatol,项目名称:spring-boot-Olingo-oData,代码行数:49,代码来源:EDMController.java

示例7: postWithoutBody

@Test
public void postWithoutBody() throws Exception {
  final String batch = "--" + BOUNDARY + CRLF
      + HttpHeader.CONTENT_TYPE + ": " + MULTIPART_MIXED + "; boundary=" + CHANGESET_BOUNDARY + CRLF
      + CRLF
      + "--" + CHANGESET_BOUNDARY + CRLF
      + MIME_HEADERS
      + HttpHeader.CONTENT_ID + ": changeRequest1" + CRLF
      + CRLF
      + HttpMethod.POST + " ESAllPrim" + HTTP_VERSION + CRLF
      + HttpHeader.CONTENT_LENGTH + ": 100" + CRLF
      + HttpHeader.CONTENT_TYPE + ": " + APPLICATION_OCTET_STREAM + CRLF
      + CRLF
      + CRLF
      + "--" + CHANGESET_BOUNDARY + "--" + CRLF
      + CRLF
      + "--" + BOUNDARY + "--";
  final List<BatchRequestPart> batchRequestParts = parse(batch);

  Assert.assertEquals(1, batchRequestParts.size());
  Assert.assertTrue(batchRequestParts.get(0).isChangeSet());
  Assert.assertEquals(1, batchRequestParts.get(0).getRequests().size());
  final ODataRequest request = batchRequestParts.get(0).getRequests().get(0);
  Assert.assertEquals(HttpMethod.POST, request.getMethod());
  Assert.assertEquals("100", request.getHeader(HttpHeader.CONTENT_LENGTH));
  Assert.assertEquals(APPLICATION_OCTET_STREAM, request.getHeader(HttpHeader.CONTENT_TYPE));
  Assert.assertNotNull(request.getBody());
  Assert.assertEquals(-1, request.getBody().read());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:29,代码来源:BatchRequestParserTest.java

示例8: noBoundaryFound

@Test
public void noBoundaryFound() throws Exception {
  final String batch = BOUNDARY + CRLF
      + MIME_HEADERS
      + CRLF
      + HttpMethod.POST + " ESAllPrim" + HTTP_VERSION + CRLF
      + CRLF;

  parseInvalidBatchBody(batch, BatchDeserializerException.MessageKeys.MISSING_CLOSE_DELIMITER);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:10,代码来源:BatchRequestParserTest.java

示例9: getStreamUpdateRequest

@Override
public ODataStreamUpdateRequest getStreamUpdateRequest(final URI targetURI, final InputStream stream) {
  final ODataStreamUpdateRequest req;

  if (client.getConfiguration().isUseXHTTPMethod()) {
    req = new ODataStreamUpdateRequestImpl(client, HttpMethod.POST, targetURI, stream);
    req.setXHTTPMethod(HttpMethod.PUT.name());
  } else {
    req = new ODataStreamUpdateRequestImpl(client, HttpMethod.PUT, targetURI, stream);
  }

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

示例10: getDeleteRequest

@Override
public ODataDeleteRequest getDeleteRequest(final URI targetURI) {
  final ODataDeleteRequest req;

  if (client.getConfiguration().isUseXHTTPMethod()) {
    req = new ODataDeleteRequestImpl(client, HttpMethod.POST, targetURI);
    req.setXHTTPMethod(HttpMethod.DELETE.name());
  } else {
    req = new ODataDeleteRequestImpl(client, HttpMethod.DELETE, targetURI);
  }

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

示例11: getMediaEntityUpdateRequest

@Override
public <E extends ClientEntity> ODataMediaEntityUpdateRequest<E> getMediaEntityUpdateRequest(
    final URI editURI, final InputStream media) {

  final ODataMediaEntityUpdateRequest<E> req;

  if (client.getConfiguration().isUseXHTTPMethod()) {
    req = new ODataMediaEntityUpdateRequestImpl<E>(client, HttpMethod.POST, URIUtils.addValueSegment(editURI), media);
    req.setXHTTPMethod(HttpMethod.PUT.name());
  } else {
    req = new ODataMediaEntityUpdateRequestImpl<E>(client, HttpMethod.PUT, URIUtils.addValueSegment(editURI), media);
  }

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

示例12: AbstractODataBatchRequest

/**
 * Constructor.
 *
 * @param odataClient client instance getting this request
 * @param uri batch request URI (http://serviceRoot/$batch)
 */
protected AbstractODataBatchRequest(final ODataClient odataClient, final URI uri) {
  super(odataClient, HttpMethod.POST, uri);

  // create a random UUID value for boundary
  boundary = "batch_" + UUID.randomUUID().toString();

  // specify the contentType header
  setContentType(ContentType.MULTIPART_MIXED + ";" + ODataBatchConstants.BOUNDARY + "=" + boundary);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:15,代码来源:AbstractODataBatchRequest.java

示例13: getEntityUpdateRequest

@Override
public <E extends ClientEntity> ODataEntityUpdateRequest<E> getEntityUpdateRequest(
    final URI targetURI, final UpdateType type, final E changes) {

  final ODataEntityUpdateRequest<E> req;

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

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

示例14: getReferenceAddingRequest

@Override
public ODataReferenceAddingRequest getReferenceAddingRequest(final URI serviceRoot, final URI targetURI,
    final URI reference) {
  final URI contextURI = client.newURIBuilder(serviceRoot.toASCIIString()).appendMetadataSegment()
                                                                          .appendRefSegment().build();
  ResWrap<URI> wrappedPayload = new ResWrap<URI>(contextURI, null, reference);

  return new ODataReferenceAddingRequestImpl(client, HttpMethod.POST, targetURI, wrappedPayload);
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:9,代码来源:CUDRequestFactoryImpl.java

示例15: validateHttpMethod

private void validateHttpMethod(final ODataRequest request) throws BatchDeserializerException {
  if (request.getMethod() != HttpMethod.POST) {
    throw new BatchDeserializerException("Invalid HTTP method", MessageKeys.INVALID_METHOD, "0");
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:5,代码来源:BatchHandler.java


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