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


Java InternalUtil类代码示例

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


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

示例1: setStreamBufferSize

import org.odata4j.internal.InternalUtil; //导入依赖的package包/类
/**
 * Gets the  stream buffer size for reading input stream which will only be called when the client starts reading the stream.
 *   
 * @return the output stream from input stream
 */
private static Integer setStreamBufferSize(){
 Integer defaultStreamBuffsize = ODataConstants.COPY_BUFFER_SIZE;
 //Property is read from the dsdsAppConfig.properties.
 String streamBufferSize = InternalUtil.getSystemPropertyValue(ODataConstants.ODATA_STREAM_BUFFER_SIZE);
 if (streamBufferSize != null && !streamBufferSize.isEmpty()) {
   try {
     int convertedSysVarValue = Integer.parseInt(streamBufferSize);
     //The value passed on the system variable is in MB and we need to convert it to bytes
     defaultStreamBuffsize = convertedSysVarValue * 1024 * 1024;
   } catch (NumberFormatException numFormatException) {
     // We ignore the exception and use default;
   }
 }
 
 return defaultStreamBuffsize;
}
 
开发者ID:teiid,项目名称:oreva,代码行数:22,代码来源:ValueRequestResource.java

示例2: 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

示例3: getRequest

import org.odata4j.internal.InternalUtil; //导入依赖的package包/类
private ODataClientRequest getRequest() {
  EdmEntitySet ees = metadata.getEdmEntitySet(entitySetName);
  Entry entry = client.createRequestEntry(ees, null, props, links);
  entity = entry.getEntity();
  StringBuilder url = new StringBuilder(serviceRootUri);
  if (parent != null) {
    url.append(InternalUtil.getEntityRelId(parent))
        .append("/")
        .append(navProperty);
  } else {
    url.append(entitySetName);
  }
  ODataClientRequest request;

  if (Boolean.TRUE.equals(ees.getType().getHasStream())) {
    setMediaStream(entity);
    request = new ODataClientRequest("POST", url.toString(), prepareSlugHeaders(ees), null, entity.getMediaLinkStream());
  } else {
    request = ODataClientRequest.post(url.toString(), entry);
  }
  return request;
}
 
开发者ID:teiid,项目名称:oreva,代码行数:23,代码来源:ConsumerCreateEntityRequest.java

示例4: setBufferThresholdSize

import org.odata4j.internal.InternalUtil; //导入依赖的package包/类
/**
 * Sets the buffer threshold size.
 */
private void setBufferThresholdSize() {
  Integer bufferThresholdSize = ODataConstants.DEFAULT_BUFFER_THRESHOLD_LIMIT;
  String thresholdSizeSysVarValue = InternalUtil.getSystemPropertyValue(ODataConstants.ODATA_WRITER_THRESHOLD_SIZE);
  if (thresholdSizeSysVarValue != null && !thresholdSizeSysVarValue.isEmpty()) {
    try {
      int convertedSysVarValue = Integer.parseInt(thresholdSizeSysVarValue);
      //The value passed on the system variable is in MB and we need to convert it to bytes
      bufferThresholdSize = convertedSysVarValue * 1024 * 1024;
    } catch (NumberFormatException numFormatException) {
      // We ignore the exception and use default;
    }
  }
  //Set the threshold size
  this.bufferThresholdSize = bufferThresholdSize;
}
 
开发者ID:teiid,项目名称:oreva,代码行数:19,代码来源:BufferOrFileResponseHolder.java

示例5: writeRequestEntry

import org.odata4j.internal.InternalUtil; //导入依赖的package包/类
public void writeRequestEntry(Writer w, Entry entry) {

    DateTime utc = new DateTime().withZone(DateTimeZone.UTC);
    String updated = InternalUtil.toString(utc);

    XMLWriter2 writer = XMLFactoryProvider2.getInstance().newXMLWriterFactory2().createXMLWriter(w);
    writer.startDocument();

    writer.startElement(new QName2("entry"), atom);
    writer.writeNamespace("d", d);
    writer.writeNamespace("m", m);

    OEntity entity = entry.getEntity();
    writeEntry(writer, null, entity.getProperties(), entity.getLinks(),
        null, updated, entity.getEntitySet(), false);
    writer.endDocument();

  }
 
开发者ID:teiid,项目名称:oreva,代码行数:19,代码来源:AtomEntryFormatWriter.java

示例6: write

import org.odata4j.internal.InternalUtil; //导入依赖的package包/类
@Override
public void write(UriInfo uriInfo, Writer w, EntityResponse target) {
  String baseUri = uriInfo.getBaseUri().toString();
  EdmEntitySet ees = target.getEntity().getEntitySet();

  DateTime utc = new DateTime().withZone(DateTimeZone.UTC);
  String updated = InternalUtil.toString(utc);

  XMLWriter2 writer = XMLFactoryProvider2.getInstance().newXMLWriterFactory2().createXMLWriter(w);
  writer.startDocument();

  writer.startElement(new QName2("entry"), atom);
  writer.writeNamespace("m", m);
  writer.writeNamespace("d", d);
  writer.writeAttribute("xml:base", baseUri);

  writeEntry(writer, target.getEntity(), target.getEntity().getProperties(), target.getEntity().getLinks(), baseUri, updated, ees, true);
  writer.endDocument();
}
 
开发者ID:teiid,项目名称:oreva,代码行数:20,代码来源:AtomEntryFormatWriter.java

示例7: dtoCheck

import org.odata4j.internal.InternalUtil; //导入依赖的package包/类
private void dtoCheck(DateTime lhs, String tzS, int tzOffsetMillis) {
  // DateTime---->String
  Assert.assertTrue(lhs.getZone().getOffset(0) == tzOffsetMillis);
  String f = InternalUtil.formatDateTimeOffsetForXml(lhs);
  //System.out.println("lhs : " + f);
  Assert.assertTrue(f.endsWith(tzS));

  // back to DateTime
  DateTime utcp = InternalUtil.parseDateTimeOffsetFromXml(f);
  f = InternalUtil.formatDateTimeOffsetForXml(lhs);
  //System.out.println("rhs: " + f);
  Assert.assertTrue(f.endsWith(tzS));

  // make sure the timezone was preserved.
  //System.out.println(" lhs zone: " + utc.getZone().getID() + " rhs zone: " + utcp.getZone().getID());
  Assert.assertTrue(utcp.getZone().getOffset(0) == tzOffsetMillis);
  Assert.assertEquals(lhs.getMillis(), utcp.getMillis());

  // zomg, DateTime.equals is all messed up...
}
 
开发者ID:teiid,项目名称:oreva,代码行数:21,代码来源:DateTimeFormatTest.java

示例8: createEntity

import org.odata4j.internal.InternalUtil; //导入依赖的package包/类
protected Response createEntity(
    HttpHeaders httpHeaders,
    UriInfo uriInfo,
    SecurityContext securityContext,
    ODataProducer producer,
    String entitySetName,
    OEntity entity,
    ODataContext odataContext, List<MediaType> mediaTypeList) throws Exception {

  EntityResponse response = producer.createEntity(odataContext, entitySetName, entity);
  FormatWriter<EntityResponse> writer = null;
  if (mediaTypeList != null) {
    writer = FormatWriterFactory.getFormatWriter(EntityResponse.class, mediaTypeList, null, null);
  }
  else {
    writer = FormatWriterFactory.getFormatWriter(EntityResponse.class, httpHeaders.getAcceptableMediaTypes(), null, null);
  }

  StringWriter sw = new StringWriter();
  writer.write(uriInfo, sw, response);

  String relid = InternalUtil.getEntityRelId(response.getEntity());
  String entryId = uriInfo.getBaseUri().toString() + relid;

  String responseEntity = sw.toString();

  return Response
      .ok(responseEntity, writer.getContentType())
      .status(Status.CREATED)
      .location(URI.create(entryId))
      .header(ODataConstants.Headers.DATA_SERVICE_VERSION,
          ODataConstants.DATA_SERVICE_VERSION_HEADER).build();
}
 
开发者ID:teiid,项目名称:oreva,代码行数:34,代码来源:EntitiesRequestResource.java

示例9: createResponseForBatch

import org.odata4j.internal.InternalUtil; //导入依赖的package包/类
/**
 * Creates the response for batch.
 *
 * @param httpHeaders the http headers
 * @param uriInfo the uri info
 * @param producer the producer
 * @param entitySetName the entity set name
 * @param entity the entity
 * @param mediaTypeList 
 * @return the response
 * @throws Exception the exception
 */
protected Response createResponseForBatch(
    HttpHeaders httpHeaders,
    UriInfo uriInfo,
    ODataProducer producer,
    String entitySetName,
    OEntity entity, List<MediaType> mediaTypeList) throws Exception {

  EntityResponse response = producer.createResponseForBatchPostOperation(entitySetName, entity);
  FormatWriter<EntityResponse> writer = null;
  if (mediaTypeList != null) {
    writer = FormatWriterFactory
        .getFormatWriter(EntityResponse.class, mediaTypeList, null, null);
  } else {
    writer = FormatWriterFactory
        .getFormatWriter(EntityResponse.class, httpHeaders.getAcceptableMediaTypes(), null, null);
  }

  StringWriter sw = new StringWriter();
  writer.write(uriInfo, sw, response);

  String relid = InternalUtil.getEntityRelId(response.getEntity());
  String entryId = uriInfo.getBaseUri().toString() + relid;

  String responseEntity = sw.toString();

  return Response
      .ok(responseEntity, writer.getContentType())
      .status(Status.CREATED)
      .location(URI.create(entryId))
      .header(ODataConstants.Headers.DATA_SERVICE_VERSION,
          ODataConstants.DATA_SERVICE_VERSION_HEADER).build();
}
 
开发者ID:teiid,项目名称:oreva,代码行数:45,代码来源:BatchRequestResource.java

示例10: execute

import org.odata4j.internal.InternalUtil; //导入依赖的package包/类
@Override
public void execute() throws ODataProducerException {
  OLink link = findLInk();
  
  if (link == null) {
    throw new BadRequestException(String.format("the entity: %1s does not contain updatable requested named resrouce stream: %2s", InternalUtil.getEntityRelId(entity), resoruceName));
  }

  ODataClientRequest request = new ODataClientRequest("PUT", uri + link.getHref(), null, null, is);
  client.updateEntity(request);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:12,代码来源:ConsumerUpdateNamedStreamRequest.java

示例11: 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

示例12: 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

示例13: getResult

import org.odata4j.internal.InternalUtil; //导入依赖的package包/类
private Enumerable<T> getResult(final Feed feed) {
  Enumerable<Entry> entries = Enumerable.createFromIterator(new Func<Iterator<Entry>>() {
    public Iterator<Entry> apply() {
      return new EntryIterator(buildRequest(null), feed);
    }
  });

  return entries.select(new Func1<Entry, T>() {
    public T apply(Entry input) {
      return InternalUtil.toEntity(entityType, input.getEntity());
    }
  }).cast(entityType);
}
 
开发者ID:teiid,项目名称:oreva,代码行数:14,代码来源:ConsumerQueryEntitiesRequest.java

示例14: 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

示例15: link

import org.odata4j.internal.InternalUtil; //导入依赖的package包/类
private <T> T link(T rt, String navProperty, EdmEntitySet targetEntitySet, OEntityKey targetKey) {
  EdmEntitySet entitySet = metadata.getEdmEntitySet(entitySetName);
  EdmNavigationProperty navProp = entitySet.getType().findNavigationProperty(navProperty);
  if (navProp == null)
    throw new IllegalArgumentException("unknown navigation property " + navProperty);

  if (navProp.getToRole().getMultiplicity() == EdmMultiplicity.MANY)
    throw new IllegalArgumentException("many associations are not supported");

  StringBuilder href = new StringBuilder(serviceRootUri);
  if (!serviceRootUri.endsWith("/"))
    href.append("/");

  if (targetEntitySet == null)
    targetEntitySet = metadata.getEdmEntitySet(navProp.getToRole().getType());

  href.append(InternalUtil.getEntityRelId(targetEntitySet, targetKey));

  // TODO get rid of XmlFormatWriter
  // We may need to rethink the rel property on a link
  // since it adds no new information. The title is
  // already there and rel has only a fixed prefix valid for
  // the atom format.
  String rel = XmlFormatWriter.related + navProperty;

  this.links.add(OLinks.relatedEntity(rel, navProperty, href.toString()));
  return rt;
}
 
开发者ID:teiid,项目名称:oreva,代码行数:29,代码来源:AbstractConsumerEntityPayloadRequest.java


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