本文整理汇总了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;
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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...
}
示例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();
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}