當前位置: 首頁>>代碼示例>>Java>>正文


Java InternalUtil.getDataServiceVersion方法代碼示例

本文整理匯總了Java中org.odata4j.internal.InternalUtil.getDataServiceVersion方法的典型用法代碼示例。如果您正苦於以下問題:Java InternalUtil.getDataServiceVersion方法的具體用法?Java InternalUtil.getDataServiceVersion怎麽用?Java InternalUtil.getDataServiceVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.odata4j.internal.InternalUtil的用法示例。


在下文中一共展示了InternalUtil.getDataServiceVersion方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRequestEntity

import org.odata4j.internal.InternalUtil; //導入方法依賴的package包/類
protected OEntity getRequestEntity(HttpHeaders httpHeaders, UriInfo uriInfo, InputStream payload, EdmDataServices metadata, String entitySetName, OEntityKey entityKey) throws UnsupportedEncodingException {
  // TODO validation of MaxDataServiceVersion against DataServiceVersion
  // see spec [ms-odata] section 1.7

  ODataVersion version = InternalUtil.getDataServiceVersion(httpHeaders.getRequestHeaders().getFirst(ODataConstants.Headers.DATA_SERVICE_VERSION));
  FormatParser<Entry> parser = FormatParserFactory.getParser(Entry.class, httpHeaders.getMediaType(),
      new Settings(version, metadata, entitySetName, entityKey, null, false));

  String charset = httpHeaders.getMediaType().getParameters().get("charset");
  if (charset == null) {
    charset = ODataConstants.Charsets.Upper.ISO_8859_1; // from HTTP 1.1
  }

  Entry entry = parser.parse(new BufferedReader(
      new InputStreamReader(payload, charset)));

  return entry.getEntity();
}
 
開發者ID:teiid,項目名稱:oreva,代碼行數:19,代碼來源:BaseResource.java

示例2: getResult

import org.odata4j.internal.InternalUtil; //導入方法依賴的package包/類
private T getResult(ODataClientResponse response) {
  if (response == null)
    return null;

  ODataVersion version = InternalUtil.getDataServiceVersion(response.getHeaders()
      .getFirst(ODataConstants.Headers.DATA_SERVICE_VERSION));

  T result = getResult(version, getClient().getFeedReader(response), getClient().getFormatType());
  response.close();

  return result;
}
 
開發者ID:teiid,項目名稱:oreva,代碼行數:13,代碼來源:ConsumerGetEntityRequest.java

示例3: doRequest

import org.odata4j.internal.InternalUtil; //導入方法依賴的package包/類
private Feed doRequest(ODataClientResponse response) throws ODataProducerException {
  ODataVersion version = InternalUtil.getDataServiceVersion(response.getHeaders()
      .getFirst(ODataConstants.Headers.DATA_SERVICE_VERSION));

  FormatParser<Feed> parser = FormatParserFactory.getParser(Feed.class, getClient().getFormatType(),
      new Settings(version, getMetadata(), getEntitySet().getName(), null, fcMapping));

  Feed feed = parser.parse(getClient().getFeedReader(response));
  response.close();
  return feed;
}
 
開發者ID:teiid,項目名稱:oreva,代碼行數:12,代碼來源:ConsumerQueryEntitiesRequest.java

示例4: getResult

import org.odata4j.internal.InternalUtil; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private T getResult(ODataClientResponse response) {
  ODataVersion version = InternalUtil.getDataServiceVersion(response.getHeaders()
      .getFirst(ODataConstants.Headers.DATA_SERVICE_VERSION));

  Entry entry = getResult(version, client.getFeedReader(response));
  response.close();

  return (T) entry.getEntity();

}
 
開發者ID:teiid,項目名稱:oreva,代碼行數:12,代碼來源:ConsumerCreateEntityRequest.java

示例5: parseSingleOperationResponse

import org.odata4j.internal.InternalUtil; //導入方法依賴的package包/類
public static ODataClientBatchResponse parseSingleOperationResponse(ODataVersion topVersion, String content, OBatchSupport so, FormatType formatType) {
  // first create a buffered reader
  BufferedReader reader = new BufferedReader(new StringReader(content));

  ODataVersion version = topVersion;

  try {
    // 1st line should be status line line HTTP/1.1 200 OK
    String line = reader.readLine();
    String[] statusLine = line.split("\\s");
    int status = Integer.parseInt(statusLine[1]);

    boolean isHeader = true;
    Map<String, String> headers = new HashMap<String, String>();
    MultivaluedMap<String, String> inboundHeaders = new HeaderMap();
    StringBuilder sb = new StringBuilder();
    while ((line = reader.readLine()) != null) {
      // \n\n indicates the end of header for the response
      if (line.isEmpty()) {
        isHeader = false;
        continue;
      }
      if (isHeader) {
        int idx = line.indexOf(":");
        String key = line.substring(0, idx).toUpperCase().trim();
        String value = line.substring(idx + 1).trim();
        headers.put(key, value);
        inboundHeaders.add(key, value);

        if (key.equalsIgnoreCase(ODataConstants.Headers.DATA_SERVICE_VERSION) && value != null && !value.isEmpty()) {
          version = InternalUtil.getDataServiceVersion(value);
        }

      } else {
        sb.append(line);
      }
    }

    Object result = null;
    if (inboundHeaders.containsKey(ODataConstants.Headers.CONTENT_TYPE.toUpperCase())) {
      // we are storing the string inside the batch response, 
      // in this.getFeedReader(), we will check if it is JerseyClientBatchResponse, 
      // if so, it will use parsed String value directly instead of calling workers to
      // parse it agin.
      result = so.getResult(version, sb.toString(), formatType);
    }
    ODataClientBatchResponse ocbr = new ODataClientBatchResponseImpl(status, inboundHeaders, result);

    return ocbr;

  } catch (IOException e) {
    throw new RuntimeException("parseSingleOperationResponse got IOExcepton:", e);
  }

}
 
開發者ID:teiid,項目名稱:oreva,代碼行數:56,代碼來源:ConsumerBatchRequestHelper.java

示例6: getRequestEntity

import org.odata4j.internal.InternalUtil; //導入方法依賴的package包/類
/**
 * get the entity, but the medial type will not be from httpHeaders which is the batch request content-type, instead it will
 * from each batch request header (the content-type for each part in the multi-parts body).
 * @param httpHeaders the top level batch request http headers
 * @param batchRequestHeader each operation's header
 * @param uriInfo the uriInfo of the top batch request
 * @param payload the content of the each operation part
 * @param metadata the meatadata 
 * @param entitySetName the entity set name to be retrieved
 * @param entityKey the entity's key
 * @return the OEntity
 */
protected OEntity getRequestEntity(HttpHeaders httpHeaders, MultivaluedMap<String, String> batchRequestHeader, UriInfo uriInfo, String payload, EdmDataServices metadata, String entitySetName, OEntityKey entityKey, Boolean isResponse) {
  // TODO validation of MaxDataServiceVersion against DataServiceVersion
  // see spec [ms-odata] section 1.7

  ODataVersion version = InternalUtil.getDataServiceVersion(httpHeaders.getRequestHeaders().getFirst(ODataConstants.Headers.DATA_SERVICE_VERSION));
  String contentType = batchRequestHeader.getFirst(ODataConstants.Headers.CONTENT_TYPE);

  MediaType type = getMediaType(contentType);

  return convertFromString(payload, type, version, metadata, entitySetName, entityKey, isResponse);
}
 
開發者ID:teiid,項目名稱:oreva,代碼行數:24,代碼來源:BatchRequestResource.java

示例7: getResult

import org.odata4j.internal.InternalUtil; //導入方法依賴的package包/類
private Object getResult(ODataClientResponse response) {
  ODataVersion version = InternalUtil.getDataServiceVersion(response.getHeaders().getFirst(ODataConstants.Headers.DATA_SERVICE_VERSION));

  Object object = getResult(version, getClient().getFeedReader(response), getClient().getFormatType());

  response.close();
  return object;

}
 
開發者ID:teiid,項目名稱:oreva,代碼行數:10,代碼來源:ConsumerFunctionCallRequest.java


注:本文中的org.odata4j.internal.InternalUtil.getDataServiceVersion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。