[OLINGO-206] merge master

This commit is contained in:
Stephan Klevenz 2014-04-02 09:43:09 +02:00
commit 929fb65560
564 changed files with 20132 additions and 7954 deletions

View File

@ -24,8 +24,6 @@ import org.apache.olingo.fit.utils.AbstractJSONUtilities;
import org.apache.olingo.fit.utils.ODataVersion;
import org.apache.olingo.fit.utils.FSManager;
import static org.apache.olingo.fit.utils.Constants.*;
import org.apache.olingo.fit.methods.MERGE;
import org.apache.olingo.fit.methods.PATCH;
import org.apache.olingo.fit.utils.AbstractUtilities;
@ -54,8 +52,10 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.fit.utils.ConstantKey;
import org.apache.olingo.fit.utils.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -67,7 +67,7 @@ public abstract class AbstractServices {
*/
protected static final Logger LOG = LoggerFactory.getLogger(AbstractServices.class);
private static Set<ODataVersion> initialized = EnumSet.noneOf(ODataVersion.class);
private static final Set<ODataVersion> INITIALIZED = EnumSet.noneOf(ODataVersion.class);
protected abstract ODataVersion getVersion();
protected final AbstractXMLUtilities xml;
@ -83,9 +83,9 @@ public abstract class AbstractServices {
this.json = new org.apache.olingo.fit.utils.v4.JSONUtilities();
}
if (!initialized.contains(getVersion())) {
if (!INITIALIZED.contains(getVersion())) {
xml.retrieveLinkInfoFromMetadata();
initialized.add(getVersion());
INITIALIZED.add(getVersion());
}
}
@ -105,7 +105,8 @@ public abstract class AbstractServices {
}
return xml.createResponse(
FSManager.instance(getVersion()).readFile(SERVICES, acceptType), null, acceptType);
FSManager.instance(getVersion()).readFile(Constants.get(getVersion(), ConstantKey.SERVICES), acceptType),
null, acceptType);
} catch (Exception e) {
return xml.createFaultResponse(accept, e);
}
@ -120,7 +121,7 @@ public abstract class AbstractServices {
@Path("/$metadata")
@Produces("application/xml")
public Response getMetadata() {
return getMetadata(METADATA);
return getMetadata(Constants.get(getVersion(), ConstantKey.METADATA));
}
/**
@ -132,17 +133,57 @@ public abstract class AbstractServices {
@Path("/large/$metadata")
@Produces("application/xml")
public Response getLargeMetadata() {
return getMetadata("large" + StringUtils.capitalize(METADATA));
return getMetadata("large" + StringUtils.capitalize(Constants.get(getVersion(), ConstantKey.METADATA)));
}
private Response getMetadata(final String filename) {
protected Response getMetadata(final String filename) {
try {
return xml.
createResponse(FSManager.instance(getVersion()).readFile(filename, Accept.XML), null, Accept.XML);
return xml.createResponse(FSManager.instance(getVersion()).readFile(filename, Accept.XML), null, Accept.XML);
} catch (Exception e) {
return xml.createFaultResponse(Accept.XML.toString(getVersion()), e);
}
}
//
// @GET
// @Path("/$entity")
// public Response getEntityReference(@QueryParam("$id") String id){
// return null;
// }
/**
* Retrieve entity reference sample.
*
* @param accept Accept header.
* @param path path.
* @param format format query option.
* @return entity reference or feed of entity reference.
*/
@GET
@Path("/{path:.*}/$ref")
public Response getEntityReference(
@HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept,
@PathParam("path") String path,
@QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) {
try {
final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
if (utils.getKey() == Accept.TEXT) {
throw new UnsupportedMediaTypeException("Unsupported media type");
}
final String filename = Base64.encodeBase64String(path.getBytes("UTF-8"));
return utils.getValue().createResponse(
FSManager.instance(getVersion()).readFile(Constants.get(getVersion(), ConstantKey.REF)
+ File.separatorChar + filename, utils.getKey()),
null,
utils.getKey());
} catch (Exception e) {
LOG.error("Error retrieving entity", e);
return xml.createFaultResponse(accept, e);
}
}
@MERGE
@Path("/{entitySetName}/{entityId}")
@ -378,15 +419,20 @@ public abstract class AbstractServices {
builder.append(basePath);
if (StringUtils.isNotBlank(orderby)) {
builder.append(ORDERBY).append(File.separatorChar).append(orderby).append(File.separatorChar);
builder.append(Constants.get(getVersion(), ConstantKey.ORDERBY)).append(File.separatorChar).
append(orderby).append(File.separatorChar);
}
if (StringUtils.isNotBlank(filter)) {
builder.append(FILTER).append(File.separatorChar).append(filter.replaceAll("/", "."));
builder.append(Constants.get(getVersion(), ConstantKey.FILTER)).append(File.separatorChar).
append(filter.replaceAll("/", "."));
} else if (StringUtils.isNotBlank(skiptoken)) {
builder.append(SKIP_TOKEN).append(File.separatorChar).append(skiptoken);
builder.append(Constants.get(getVersion(), ConstantKey.SKIP_TOKEN)).append(File.separatorChar).
append(skiptoken);
} else {
builder.append(FEED);
builder.append(Commons.getLinkInfo().get(getVersion()).isSingleton(name)
? Constants.get(getVersion(), ConstantKey.ENTITY)
: Constants.get(getVersion(), ConstantKey.FEED));
}
InputStream feed = FSManager.instance(getVersion()).readFile(builder.toString(), acceptType);
@ -483,7 +529,8 @@ public abstract class AbstractServices {
if (keyAsSegment) {
entity = utils.getValue().addEditLink(
entity, entitySetName, Constants.DEFAULT_SERVICE_URL + entitySetName + "/" + entityId);
entity, entitySetName,
Constants.get(getVersion(), ConstantKey.DEFAULT_SERVICE_URL) + entitySetName + "/" + entityId);
}
if (StringUtils.isNotBlank(select)) {
@ -548,7 +595,7 @@ public abstract class AbstractServices {
final String basePath =
entitySetName + File.separatorChar + Commons.getEntityKey(entityId) + File.separatorChar;
FSManager.instance(getVersion()).deleteFile(basePath + ENTITY);
FSManager.instance(getVersion()).deleteFile(basePath + Constants.get(getVersion(), ConstantKey.ENTITY));
return xml.createResponse(null, null, null, Response.Status.NO_CONTENT);
} catch (Exception e) {
@ -970,15 +1017,17 @@ public abstract class AbstractServices {
final String basePath = Commons.getEntityBasePath(entitySetName, entityId);
InputStream stream = FSManager.instance(getVersion()).readFile(
basePath + ENTITY, acceptType == null || acceptType == Accept.TEXT
? Accept.XML : acceptType);
final AbstractUtilities utils = getUtilities(acceptType);
final List<String> pathElements = Arrays.asList(path.split("\\/"));
InputStream stream;
if (searchForValue) {
stream = FSManager.instance(getVersion()).readFile(
basePath + Constants.get(getVersion(), ConstantKey.ENTITY),
acceptType == null || acceptType == Accept.TEXT ? Accept.XML : acceptType);
stream = utils.getPropertyValue(stream, pathElements);
} else {
String edmType = xml.getEdmTypeFromAtom(entitySetName, entityId, pathElements);

View File

@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.fit;
import org.apache.olingo.fit.utils.ODataVersion;
import org.apache.olingo.fit.utils.XHTTPMethodInterceptor;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import org.apache.cxf.interceptor.InInterceptors;
import org.apache.olingo.fit.utils.ConstantKey;
import org.apache.olingo.fit.utils.Constants;
@Path("/V40/NorthWind.svc")
@InInterceptors(classes = XHTTPMethodInterceptor.class)
public class V4NorthWind extends AbstractServices {
public V4NorthWind() throws Exception {
super();
}
@Override
protected ODataVersion getVersion() {
return ODataVersion.v4;
}
@Override
public Response getMetadata() {
return getMetadata("northwind-" + Constants.get(getVersion(), ConstantKey.METADATA));
}
}

View File

@ -0,0 +1,48 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.fit;
import org.apache.olingo.fit.utils.ODataVersion;
import org.apache.olingo.fit.utils.XHTTPMethodInterceptor;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import org.apache.cxf.interceptor.InInterceptors;
import org.apache.olingo.fit.utils.ConstantKey;
import org.apache.olingo.fit.utils.Constants;
import org.apache.olingo.fit.utils.ResolvingReferencesInterceptor;
@Path("/V40/NorthWindExt.svc")
@InInterceptors(classes = {XHTTPMethodInterceptor.class, ResolvingReferencesInterceptor.class})
public class V4NorthWindExt extends AbstractServices {
public V4NorthWindExt() throws Exception {
super();
}
@Override
protected ODataVersion getVersion() {
return ODataVersion.v4;
}
@Override
public Response getMetadata() {
return getMetadata("northwindExt-" + Constants.get(getVersion(), ConstantKey.METADATA));
}
}

View File

@ -22,9 +22,10 @@ import org.apache.olingo.fit.utils.ODataVersion;
import org.apache.olingo.fit.utils.XHTTPMethodInterceptor;
import javax.ws.rs.Path;
import org.apache.cxf.interceptor.InInterceptors;
import org.apache.olingo.fit.utils.ResolvingReferencesInterceptor;
@Path("/V40/Static.svc")
@InInterceptors(classes = XHTTPMethodInterceptor.class)
@InInterceptors(classes = {XHTTPMethodInterceptor.class, ResolvingReferencesInterceptor.class})
public class V4Services extends AbstractServices {
public V4Services() throws Exception {

View File

@ -18,8 +18,6 @@
*/
package org.apache.olingo.fit.utils;
import static org.apache.olingo.fit.utils.Constants.*;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
@ -61,11 +59,11 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
IOUtils.closeQuietly(is);
for (String link : links) {
srcNode.set(link + JSON_NAVIGATION_SUFFIX,
srcNode.set(link + Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX),
new TextNode(Commons.getLinksURI(version, entitySetName, entitykey, link)));
}
return IOUtils.toInputStream(srcNode.toString());
return IOUtils.toInputStream(srcNode.toString(), "UTf-8");
}
@Override
@ -81,10 +79,10 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
while (fieldIter.hasNext()) {
final String field = fieldIter.next();
if (field.endsWith(JSON_NAVIGATION_BIND_SUFFIX)
|| field.endsWith(JSON_NAVIGATION_SUFFIX)
|| field.endsWith(JSON_MEDIA_SUFFIX)
|| field.endsWith(JSON_EDITLINK_NAME)) {
if (field.endsWith(Constants.get(version, ConstantKey.JSON_NAVIGATION_BIND_SUFFIX))
|| field.endsWith(Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX))
|| field.endsWith(Constants.get(version, ConstantKey.JSON_MEDIA_SUFFIX))
|| field.endsWith(Constants.get(version, ConstantKey.JSON_EDITLINK_NAME))) {
if (field.indexOf('@') > 0) {
links.add(field.substring(0, field.indexOf('@')));
} else {
@ -113,7 +111,7 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
while (fieldIter.hasNext()) {
final Map.Entry<String, JsonNode> field = fieldIter.next();
if (field.getKey().endsWith(JSON_NAVIGATION_BIND_SUFFIX)) {
if (field.getKey().endsWith(Constants.get(version, ConstantKey.JSON_NAVIGATION_BIND_SUFFIX))) {
final String title = field.getKey().substring(0, field.getKey().indexOf('@'));
final List<String> hrefs = new ArrayList<String>();
if (field.getValue().isArray()) {
@ -128,7 +126,7 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
links.addLinks(title, hrefs);
} else if (Commons.linkInfo.get(version).exists(entitySetName, field.getKey())) {
links.addInlines(field.getKey(), IOUtils.toInputStream(field.getValue().toString()));
links.addInlines(field.getKey(), IOUtils.toInputStream(field.getValue().toString(), "UTf-8"));
}
}
@ -148,17 +146,17 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
if (links != null) {
for (String linkTitle : links.getLinkNames()) {
// normalize link
srcNode.remove(linkTitle + JSON_NAVIGATION_BIND_SUFFIX);
srcNode.remove(linkTitle + Constants.get(version, ConstantKey.JSON_NAVIGATION_BIND_SUFFIX));
srcNode.set(
linkTitle + JSON_NAVIGATION_SUFFIX,
linkTitle + Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX),
new TextNode(String.format("%s(%s)/%s", entitySetName, entityKey, linkTitle)));
}
for (String linkTitle : links.getInlineNames()) {
// normalize link if exist; declare a new one if missing
srcNode.remove(linkTitle + JSON_NAVIGATION_BIND_SUFFIX);
srcNode.remove(linkTitle + Constants.get(version, ConstantKey.JSON_NAVIGATION_BIND_SUFFIX));
srcNode.set(
linkTitle + JSON_NAVIGATION_SUFFIX,
linkTitle + Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX),
new TextNode(String.format("%s(%s)/%s", entitySetName, entityKey, linkTitle)));
// remove inline
@ -170,10 +168,10 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
}
srcNode.set(
JSON_EDITLINK_NAME,
new TextNode(Constants.DEFAULT_SERVICE_URL + entitySetName + "(" + entityKey + ")"));
Constants.get(version, ConstantKey.JSON_EDITLINK_NAME), new TextNode(
Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + entitySetName + "(" + entityKey + ")"));
return IOUtils.toInputStream(srcNode.toString());
return IOUtils.toInputStream(srcNode.toString(), "UTf-8");
}
@Override
@ -190,8 +188,9 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
final String entitySetName, final String entityId, final List<String> path, final String edmType)
throws Exception {
final InputStream src =
fsManager.readFile(Commons.getEntityBasePath(entitySetName, entityId) + ENTITY, Accept.JSON_FULLMETA);
final InputStream src = fsManager.readFile(
Commons.getEntityBasePath(entitySetName, entityId) + Constants.get(version, ConstantKey.ENTITY),
Accept.JSON_FULLMETA);
final ObjectMapper mapper = new ObjectMapper();
final JsonNode srcNode = mapper.readTree(src);
@ -199,7 +198,9 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
final ObjectNode propertyNode = new ObjectNode(JsonNodeFactory.instance);
if (StringUtils.isNotBlank(edmType)) {
propertyNode.put(JSON_ODATAMETADATA_NAME, ODATA_METADATA_PREFIX + edmType);
propertyNode.put(Constants.get(
version, ConstantKey.JSON_ODATAMETADATA_NAME),
Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + edmType);
}
JsonNode jsonNode = getProperty(srcNode, path);
@ -241,7 +242,7 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
final ObjectMapper mapper = new ObjectMapper();
final JsonNode srcNode = mapper.readTree(src);
((ObjectNode) srcNode).put(ODATA_COUNT_NAME, count);
((ObjectNode) srcNode).put(Constants.get(version, ConstantKey.ODATA_COUNT_NAME), count);
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
mapper.writeValue(bos, srcNode);
@ -258,14 +259,14 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
final ObjectNode res;
final JsonNode value = node.get(JSON_VALUE_NAME);
final JsonNode value = node.get(Constants.get(version, ConstantKey.JSON_VALUE_NAME));
if (value.isArray()) {
res = mapper.createObjectNode();
res.set("value", value);
final JsonNode next = node.get(JSON_NEXTLINK_NAME);
final JsonNode next = node.get(Constants.get(version, ConstantKey.JSON_NEXTLINK_NAME));
if (next != null) {
res.set(JSON_NEXTLINK_NAME, next);
res.set(Constants.get(version, ConstantKey.JSON_NEXTLINK_NAME), next);
}
} else {
res = (ObjectNode) value;
@ -286,23 +287,23 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
final ObjectNode srcNode = (ObjectNode) mapper.readTree(src);
final Set<String> retain = new HashSet<String>();
retain.add(JSON_ID_NAME);
retain.add(JSON_TYPE_NAME);
retain.add(JSON_EDITLINK_NAME);
retain.add(JSON_NEXTLINK_NAME);
retain.add(JSON_ODATAMETADATA_NAME);
retain.add(JSON_VALUE_NAME);
retain.add(Constants.get(version, ConstantKey.JSON_ID_NAME));
retain.add(Constants.get(version, ConstantKey.JSON_TYPE_NAME));
retain.add(Constants.get(version, ConstantKey.JSON_EDITLINK_NAME));
retain.add(Constants.get(version, ConstantKey.JSON_NEXTLINK_NAME));
retain.add(Constants.get(version, ConstantKey.JSON_ODATAMETADATA_NAME));
retain.add(Constants.get(version, ConstantKey.JSON_VALUE_NAME));
for (String name : propertyNames) {
retain.add(name);
retain.add(name + JSON_NAVIGATION_SUFFIX);
retain.add(name + JSON_MEDIA_SUFFIX);
retain.add(name + JSON_TYPE_SUFFIX);
retain.add(name + Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX));
retain.add(name + Constants.get(version, ConstantKey.JSON_MEDIA_SUFFIX));
retain.add(name + Constants.get(version, ConstantKey.JSON_TYPE_SUFFIX));
}
srcNode.retain(retain);
return IOUtils.toInputStream(srcNode.toString());
return IOUtils.toInputStream(srcNode.toString(), "UTf-8");
}
@Override
@ -344,13 +345,14 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
bos.write("]".getBytes());
}
node.set(JSON_VALUE_NAME, mapper.readTree(new ByteArrayInputStream(bos.toByteArray())));
node.set(Constants.get(version, ConstantKey.JSON_VALUE_NAME),
mapper.readTree(new ByteArrayInputStream(bos.toByteArray())));
if (StringUtils.isNotBlank(next)) {
node.set(JSON_NEXTLINK_NAME, new TextNode(next));
node.set(Constants.get(version, ConstantKey.JSON_NEXTLINK_NAME), new TextNode(next));
}
return IOUtils.toInputStream(node.toString());
return IOUtils.toInputStream(node.toString(), "UTf-8");
}
@Override
@ -362,18 +364,18 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
final ObjectNode toBeChangedNode = (ObjectNode) mapper.readTree(toBeChanged);
final ObjectNode replacementNode = (ObjectNode) mapper.readTree(replacement);
if (toBeChangedNode.get(linkName + JSON_NAVIGATION_SUFFIX) == null) {
if (toBeChangedNode.get(linkName + Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX)) == null) {
throw new NotFoundException();
}
toBeChangedNode.set(linkName, replacementNode.get(JSON_VALUE_NAME));
toBeChangedNode.set(linkName, replacementNode.get(Constants.get(version, ConstantKey.JSON_VALUE_NAME)));
final JsonNode next = replacementNode.get(linkName + JSON_NEXTLINK_NAME);
final JsonNode next = replacementNode.get(linkName + Constants.get(version, ConstantKey.JSON_NEXTLINK_NAME));
if (next != null) {
toBeChangedNode.set(linkName + JSON_NEXTLINK_SUFFIX, next);
toBeChangedNode.set(linkName + Constants.get(version, ConstantKey.JSON_NEXTLINK_SUFFIX), next);
}
return IOUtils.toInputStream(toBeChangedNode.toString());
return IOUtils.toInputStream(toBeChangedNode.toString(), "UTf-8");
}
@Override
@ -386,7 +388,7 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
final Iterator<Map.Entry<String, JsonNode>> fields = srcObject.fields();
while (fields.hasNext()) {
final Map.Entry<String, JsonNode> field = fields.next();
res.put(field.getKey(), IOUtils.toInputStream(field.getValue().toString()));
res.put(field.getKey(), IOUtils.toInputStream(field.getValue().toString(), "UTf-8"));
}
return res;
@ -404,7 +406,7 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
toBeChangedObject.set(property.getKey(), propertyNode);
}
return IOUtils.toInputStream(toBeChangedObject.toString());
return IOUtils.toInputStream(toBeChangedObject.toString(), "UTf-8");
}
@Override
@ -437,7 +439,7 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
}
}
final JsonNode next = srcNode.get(JSON_NEXTLINK_NAME);
final JsonNode next = srcNode.get(Constants.get(version, ConstantKey.JSON_NEXTLINK_NAME));
return new SimpleEntry<String, List<String>>(next == null ? null : next.asText(), links);
}
@ -449,8 +451,8 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
final ObjectNode srcNode = (ObjectNode) mapper.readTree(content);
IOUtils.closeQuietly(content);
srcNode.set(JSON_EDITLINK_NAME, new TextNode(href));
return IOUtils.toInputStream(srcNode.toString());
srcNode.set(Constants.get(version, ConstantKey.JSON_EDITLINK_NAME), new TextNode(href));
return IOUtils.toInputStream(srcNode.toString(), "UTf-8");
}
@Override
@ -479,7 +481,7 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
((ObjectNode) node).set(path.get(path.size() - 1), replacementNode);
return IOUtils.toInputStream(srcNode.toString());
return IOUtils.toInputStream(srcNode.toString(), "UTf-8");
}
@Override
@ -498,6 +500,6 @@ public abstract class AbstractJSONUtilities extends AbstractUtilities {
((ObjectNode) node).set(path.get(path.size() - 1), null);
return IOUtils.toInputStream(srcNode.toString());
return IOUtils.toInputStream(srcNode.toString(), "UTf-8");
}
}

View File

@ -19,7 +19,6 @@
package org.apache.olingo.fit.utils;
import static org.apache.olingo.fit.utils.Commons.sequence;
import static org.apache.olingo.fit.utils.Constants.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@ -134,7 +133,8 @@ public abstract class AbstractUtilities {
// 0. Get the path
// -----------------------------------------
final String path =
entitySetName + File.separatorChar + Commons.getEntityKey(key) + File.separatorChar + ENTITY;
entitySetName + File.separatorChar + Commons.getEntityKey(key) + File.separatorChar
+ Constants.get(version, ConstantKey.ENTITY);
// -----------------------------------------
// -----------------------------------------
@ -229,7 +229,7 @@ public abstract class AbstractUtilities {
// -----------------------------------------
final FileObject fo = fsManager.putInMemory(
normalizedEntity,
fsManager.getAbsolutePath(path + ENTITY, getDefaultFormat()));
fsManager.getAbsolutePath(path + Constants.get(version, ConstantKey.ENTITY), getDefaultFormat()));
// -----------------------------------------
// -----------------------------------------
@ -282,7 +282,8 @@ public abstract class AbstractUtilities {
// -----------------------------------------
// 1. save the media entity value
// -----------------------------------------
fsManager.putInMemory(is, fsManager.getAbsolutePath(path + MEDIA_CONTENT_FILENAME, null));
fsManager.putInMemory(is, fsManager.getAbsolutePath(path
+ Constants.get(version, ConstantKey.MEDIA_CONTENT_FILENAME), null));
IOUtils.closeQuietly(is);
// -----------------------------------------
@ -291,13 +292,13 @@ public abstract class AbstractUtilities {
// -----------------------------------------
final String entityURI = Commons.getEntityURI(entitySetName, entityKey);
String entity = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<entry xml:base=\"" + DEFAULT_SERVICE_URL + "\" "
+ "<entry xml:base=\"" + Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + "\" "
+ "xmlns=\"http://www.w3.org/2005/Atom\" "
+ "xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\" "
+ "xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\" "
+ "xmlns:georss=\"http://www.georss.org/georss\" "
+ "xmlns:gml=\"http://www.opengis.net/gml\">"
+ "<id>" + DEFAULT_SERVICE_URL + entityURI + "</id>"
+ "<id>" + Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + entityURI + "</id>"
+ "<category term=\"Microsoft.Test.OData.Services.AstoriaDefaultService." + entitySetName + "\" "
+ "scheme=\"http://schemas.microsoft.com/ado/2007/08/dataservices/scheme\" />"
+ "<link rel=\"edit\" title=\"Car\" href=\"" + entityURI + "\" />"
@ -310,16 +311,18 @@ public abstract class AbstractUtilities {
+ "</entry>";
fsManager.putInMemory(
IOUtils.toInputStream(entity), fsManager.getAbsolutePath(path + ENTITY, Accept.ATOM));
IOUtils.toInputStream(entity),
fsManager.getAbsolutePath(path + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM));
// -----------------------------------------
// -----------------------------------------
// 3. save entity as json
// -----------------------------------------
entity = "{"
+ "\"odata.metadata\": \"" + DEFAULT_SERVICE_URL + "/$metadata#" + entitySetName + "/@Element\","
+ "\"odata.metadata\": \"" + Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL)
+ "/$metadata#" + entitySetName + "/@Element\","
+ "\"odata.type\": \"Microsoft.Test.OData.Services.AstoriaDefaultService." + entitySetName + "\","
+ "\"odata.id\": \"" + DEFAULT_SERVICE_URL + entityURI + "\","
+ "\"odata.id\": \"" + Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + entityURI + "\","
+ "\"odata.editLink\": \"" + entityURI + "\","
+ "\"odata.mediaEditLink\": \"" + entityURI + "/$value\","
+ "\"odata.mediaReadLink\": \"" + entityURI + "/$value\","
@ -328,7 +331,8 @@ public abstract class AbstractUtilities {
+ "\"Description\": null" + "}";
fsManager.putInMemory(
IOUtils.toInputStream(entity), fsManager.getAbsolutePath(path + ENTITY, Accept.JSON_FULLMETA));
IOUtils.toInputStream(entity), fsManager.getAbsolutePath(path + Constants.get(version, ConstantKey.ENTITY),
Accept.JSON_FULLMETA));
// -----------------------------------------
return readEntity(entitySetName, entityKey, getDefaultFormat()).getValue();
@ -376,25 +380,21 @@ public abstract class AbstractUtilities {
final InputStream entity, final String etag, final Accept accept, final Response.Status status) {
final Response.ResponseBuilder builder = Response.ok();
if (version == ODataVersion.v3) {
builder.header(ODATA_SERVICE_VERSION, version.getVersion() + ";");
builder.header(Constants.get(version, ConstantKey.ODATA_SERVICE_VERSION), version.getVersion() + ";");
}
if (StringUtils.isNotBlank(etag)) {
builder.header("ETag", etag);
}
if (accept != null) {
builder.header("Content-Type", accept.toString(version));
} else {
builder.header("Content-Type", "*/*");
}
if (status != null) {
builder.status(status);
}
int contentLength = 0;
String contentTypeEncoding = StringUtils.EMPTY;
if (entity != null) {
try {
final InputStream toBeStreamedBack;
@ -411,12 +411,15 @@ public abstract class AbstractUtilities {
contentLength = bos.size();
builder.entity(new ByteArrayInputStream(bos.toByteArray()));
contentTypeEncoding = ";odata.streaming=true;charset=utf-8";
} catch (IOException ioe) {
LOG.error("Error streaming response entity back", ioe);
}
}
builder.header("Content-Length", contentLength);
builder.header("Content-Type", (accept == null ? "*/*" : accept.toString(version)) + contentTypeEncoding);
return builder.build();
}
@ -426,7 +429,7 @@ public abstract class AbstractUtilities {
final Response.ResponseBuilder builder = Response.serverError();
if (version == ODataVersion.v3) {
builder.header(ODATA_SERVICE_VERSION, version.getVersion() + ";");
builder.header(Constants.get(version, ConstantKey.ODATA_SERVICE_VERSION), version + ";");
}
final String ext;
@ -507,6 +510,19 @@ public abstract class AbstractUtilities {
}
}
sequence.put(entitySetName, Integer.valueOf(res));
} else if ("Orders".equals(entitySetName)) {
try {
final Map<String, InputStream> value =
getPropertyValues(entity, Collections.<String>singletonList("OrderID"));
res = value.isEmpty() ? null : IOUtils.toString(value.values().iterator().next());
} catch (Exception e) {
if (sequence.containsKey(entitySetName)) {
res = String.valueOf(sequence.get(entitySetName) + 1);
} else {
throw new Exception(String.format("Unable to retrieve entity key value for %s", entitySetName));
}
}
sequence.put(entitySetName, Integer.valueOf(res));
} else if ("Customer".equals(entitySetName)) {
try {
final Map<String, InputStream> value =
@ -612,7 +628,7 @@ public abstract class AbstractUtilities {
final String basePath =
entitySetName + File.separatorChar + Commons.getEntityKey(entityId) + File.separatorChar
+ LINKS_FILE_PATH + File.separatorChar;
+ Constants.get(version, ConstantKey.LINKS_FILE_PATH) + File.separatorChar;
final LinkInfo linkInfo = new LinkInfo(fsManager.readFile(basePath + linkName, accept));
linkInfo.setEtag(Commons.getETag(basePath, version));
@ -631,7 +647,8 @@ public abstract class AbstractUtilities {
final String entitySetName, final String entityId, final String name, final InputStream value)
throws IOException {
final FileObject fo = fsManager.putInMemory(value, fsManager.getAbsolutePath(
Commons.getEntityBasePath(entitySetName, entityId) + (name == null ? MEDIA_CONTENT_FILENAME : name), null));
Commons.getEntityBasePath(entitySetName, entityId)
+ (name == null ? Constants.get(version, ConstantKey.MEDIA_CONTENT_FILENAME) : name), null));
return fo.getContent().getInputStream();
}
@ -644,7 +661,7 @@ public abstract class AbstractUtilities {
final String entitySetName, final String entityId, final String name) {
final String basePath = Commons.getEntityBasePath(entitySetName, entityId);
return new SimpleEntry<String, InputStream>(basePath, fsManager.readFile(basePath
+ (name == null ? MEDIA_CONTENT_FILENAME : name)));
+ (name == null ? Constants.get(version, ConstantKey.MEDIA_CONTENT_FILENAME) : name)));
}
public Map.Entry<String, InputStream> readEntity(
@ -654,7 +671,8 @@ public abstract class AbstractUtilities {
}
final String basePath = Commons.getEntityBasePath(entitySetName, entityId);
return new SimpleEntry<String, InputStream>(basePath, fsManager.readFile(basePath + ENTITY, accept));
return new SimpleEntry<String, InputStream>(basePath,
fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), accept));
}
public InputStream expandEntity(
@ -719,15 +737,16 @@ public abstract class AbstractUtilities {
? Accept.XML : accept.getExtension().equals(Accept.JSON.getExtension()) ? Accept.JSON_FULLMETA : accept;
// read atom
InputStream stream = fsManager.readFile(basePath + ENTITY, acceptType);
InputStream stream = fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), acceptType);
// change atom
stream = replaceProperty(stream, changes, path, justValue);
// save atom
fsManager.putInMemory(stream, fsManager.getAbsolutePath(basePath + ENTITY, acceptType));
fsManager.putInMemory(stream,
fsManager.getAbsolutePath(basePath + Constants.get(version, ConstantKey.ENTITY), acceptType));
return fsManager.readFile(basePath + ENTITY, acceptType);
return fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), acceptType);
}
public InputStream deleteProperty(
@ -741,15 +760,16 @@ public abstract class AbstractUtilities {
? Accept.XML : accept.getExtension().equals(Accept.JSON.getExtension()) ? Accept.JSON_FULLMETA : accept;
// read atom
InputStream stream = fsManager.readFile(basePath + ENTITY, acceptType);
InputStream stream = fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), acceptType);
// change atom
stream = deleteProperty(stream, path);
// save atom
fsManager.putInMemory(stream, fsManager.getAbsolutePath(basePath + ENTITY, acceptType));
fsManager.putInMemory(stream,
fsManager.getAbsolutePath(basePath + Constants.get(version, ConstantKey.ENTITY), acceptType));
return fsManager.readFile(basePath + ENTITY, acceptType);
return fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), acceptType);
}
public abstract InputStream readEntities(

View File

@ -18,15 +18,13 @@
*/
package org.apache.olingo.fit.utils;
import static org.apache.olingo.fit.utils.Constants.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.nio.charset.Charset;
import java.util.AbstractMap;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
@ -77,7 +75,7 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
ifactory = XMLInputFactory.newInstance();
}
ifactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, false);
return ifactory.createXMLEventReader(is);
return ifactory.createXMLEventReader(is, "utf-8");
}
protected static XMLEventWriter getEventWriter(final OutputStream os) throws XMLStreamException {
@ -85,7 +83,7 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
ofactory = XMLOutputFactory.newInstance();
}
return ofactory.createXMLEventWriter(os);
return ofactory.createXMLEventWriter(os, "utf-8");
}
private void writeEvent(final XMLEvent event, final XMLEventWriter writer) {
@ -154,13 +152,16 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
attributes.add(eventFactory.createAttribute(new QName("title"), link));
attributes.add(eventFactory.createAttribute(new QName("href"),
Commons.getLinksURI(version, entitySetName, entitykey, link)));
attributes.add(eventFactory.createAttribute(new QName("rel"), Constants.ATOM_LINK_REL + link));
attributes.add(eventFactory.createAttribute(new QName("rel"),
Constants.get(version, ConstantKey.ATOM_LINK_REL) + link));
attributes.add(eventFactory.createAttribute(new QName("type"),
Commons.linkInfo.get(version).isFeed(entitySetName, link) ? Constants.ATOM_LINK_FEED
: Constants.ATOM_LINK_ENTRY));
Commons.linkInfo.get(version).isFeed(entitySetName, link)
? Constants.get(version, ConstantKey.ATOM_LINK_FEED)
: Constants.get(version, ConstantKey.ATOM_LINK_ENTRY)));
writer.add(eventFactory.createStartElement(new QName(LINK), attributes.iterator(), null));
writer.add(eventFactory.createEndElement(new QName(LINK), null));
writer.add(eventFactory.createStartElement(
new QName(Constants.get(version, ConstantKey.LINK)), attributes.iterator(), null));
writer.add(eventFactory.createEndElement(new QName(Constants.get(version, ConstantKey.LINK)), null));
}
writer.add(entry.getValue().getContentReader());
@ -190,7 +191,8 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
while (true) {
final Map.Entry<Integer, XmlElement> linkInfo =
extractElement(reader, null, Collections.<String>singletonList(LINK), startDepth, 2, 2);
extractElement(reader, null,
Collections.<String>singletonList(Constants.get(version, ConstantKey.LINK)), startDepth, 2, 2);
startDepth = linkInfo.getKey();
@ -228,7 +230,8 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
while (true) {
// a. search for link with type attribute equals to "application/atom+xml;type=entry/feed"
final Map.Entry<Integer, XmlElement> linkInfo = extractElement(
reader, null, Collections.<String>singletonList(LINK), filter, true, startDepth, 2, 2);
reader, null, Collections.<String>singletonList(Constants.get(version, ConstantKey.LINK)),
filter, true, startDepth, 2, 2);
final XmlElement link = linkInfo.getValue();
startDepth = linkInfo.getKey();
@ -239,7 +242,8 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
try {
final XmlElement inlineElement =
extractElement(link.getContentReader(), null, Collections.<String>singletonList(INLINE), 0, -1, -1).
extractElement(link.getContentReader(), null,
Collections.<String>singletonList(Constants.get(version, ConstantKey.INLINE)), 0, -1, -1).
getValue();
final XMLEventReader inlineReader = inlineElement.getContentReader();
@ -307,7 +311,8 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
while (true) {
// a. search for link with type attribute equals to "application/atom+xml;type=entry/feed"
linkInfo = extractElement(
reader, writer, Collections.<String>singletonList(LINK), filter, true,
reader, writer,
Collections.<String>singletonList(Constants.get(version, ConstantKey.LINK)), filter, true,
linkInfo == null ? 0 : linkInfo.getKey(), 2, 2);
final XmlElement link = linkInfo.getValue();
@ -342,7 +347,7 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
final InputStream content = addEditLink(
new ByteArrayInputStream(tmpBos.toByteArray()),
entitySetName,
Constants.DEFAULT_SERVICE_URL + entitySetName + "(" + entityKey + ")");
Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + entitySetName + "(" + entityKey + ")");
// -----------------------------------------
// -----------------------------------------
@ -351,7 +356,7 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
return addAtomContent(
content,
entitySetName,
Constants.DEFAULT_SERVICE_URL + entitySetName + "(" + entityKey + ")");
Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + entitySetName + "(" + entityKey + ")");
// -----------------------------------------
}
@ -364,7 +369,9 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
final XmlElement res = new XmlElement();
res.setStart(start);
StringWriter content = new StringWriter();
final Charset encoding = Charset.forName("UTF-8");
final ByteArrayOutputStream content = new ByteArrayOutputStream();
final OutputStreamWriter writer = new OutputStreamWriter(content, encoding);
int depth = 1;
@ -380,14 +387,14 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
if (depth == 0) {
res.setEnd(event.asEndElement());
} else {
event.writeAsEncodedUnicode(content);
event.writeAsEncodedUnicode(writer);
}
}
content.flush();
content.close();
writer.flush();
writer.close();
res.setContent(new ByteArrayInputStream(content.toString().getBytes()));
res.setContent(new ByteArrayInputStream(content.toByteArray()));
return res;
}
@ -439,7 +446,7 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
try {
// check edit link existence
extractElement(reader, writer, Collections.<String>singletonList(LINK),
extractElement(reader, writer, Collections.<String>singletonList(Constants.get(version, ConstantKey.LINK)),
Collections.<Map.Entry<String, String>>singletonList(
new AbstractMap.SimpleEntry<String, String>("rel", "edit")), false, 0, -1, -1);
@ -518,7 +525,8 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
} else {
try {
final XmlElement entryElement =
extractElement(reader, writer, Collections.<String>singletonList(PROPERTIES), 0, 2, 3).getValue();
extractElement(reader, writer, Collections.<String>singletonList(
Constants.get(version, ConstantKey.PROPERTIES)), 0, 2, 3).getValue();
addAtomElement(
IOUtils.toInputStream("<content type=\"application/xml\">"),
@ -564,9 +572,11 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
public int countAllElements(final String entitySetName) throws Exception {
final String basePath = entitySetName + File.separatorChar;
int count = countFeedElements(fsManager.readFile(basePath + FEED, Accept.XML), "entry");
int count = countFeedElements(fsManager.readFile(basePath + Constants.get(version, ConstantKey.FEED), Accept.XML),
"entry");
final String skipTokenDirPath = fsManager.getAbsolutePath(basePath + SKIP_TOKEN, null);
final String skipTokenDirPath = fsManager.getAbsolutePath(basePath + Constants.get(version, ConstantKey.SKIP_TOKEN),
null);
try {
@ -575,7 +585,8 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
for (FileObject file : files) {
count += countFeedElements(fsManager.readFile(
basePath + SKIP_TOKEN + File.separatorChar + file.getName().getBaseName(), null), "entry");
basePath + Constants.get(version, ConstantKey.SKIP_TOKEN) + File.separatorChar
+ file.getName().getBaseName(), null), "entry");
}
} catch (FileSystemException fse) {
LOG.debug("Resource path '{}' not found", skipTokenDirPath);
@ -739,7 +750,7 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
final List<String> pathElements = new ArrayList<String>();
for (String element : path) {
pathElements.add(ATOM_PROPERTY_PREFIX + element);
pathElements.add(Constants.get(version, ConstantKey.ATOM_PROPERTY_PREFIX) + element);
}
final XMLEventReader reader = getEventReader(is);
@ -770,28 +781,30 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
while (reader.hasNext()) {
final XMLEvent event = reader.nextEvent();
if (event.getEventType() == XMLStreamConstants.START_ELEMENT
&& LINK.equals(event.asStartElement().getName().getLocalPart())
&& Constants.get(version, ConstantKey.LINK).equals(event.asStartElement().getName().getLocalPart())
&& !fieldToBeSaved.contains(
event.asStartElement().getAttributeByName(new QName("title")).getValue())
&& !"edit".equals(event.asStartElement().getAttributeByName(new QName("rel")).getValue())) {
writeCurrent = false;
} else if (event.getEventType() == XMLStreamConstants.END_ELEMENT
&& LINK.equals(event.asEndElement().getName().getLocalPart())) {
&& Constants.get(version, ConstantKey.LINK).equals(event.asEndElement().getName().getLocalPart())) {
writeNext = true;
} else if (event.getEventType() == XMLStreamConstants.START_ELEMENT
&& (PROPERTIES).equals(event.asStartElement().getName().getLocalPart())) {
&& (Constants.get(version, ConstantKey.PROPERTIES)).equals(
event.asStartElement().getName().getLocalPart())) {
writeCurrent = true;
writeNext = false;
inProperties = true;
} else if (event.getEventType() == XMLStreamConstants.END_ELEMENT
&& (PROPERTIES).equals(event.asEndElement().getName().getLocalPart())) {
&& (Constants.get(version, ConstantKey.PROPERTIES)).equals(
event.asEndElement().getName().getLocalPart())) {
writeCurrent = true;
} else if (inProperties) {
if (event.getEventType() == XMLStreamConstants.START_ELEMENT) {
final String elementName = event.asStartElement().getName().getLocalPart();
for (String propertyName : propertyNames) {
if ((ATOM_PROPERTY_PREFIX + propertyName.trim()).equals(elementName)) {
if ((Constants.get(version, ConstantKey.ATOM_PROPERTY_PREFIX) + propertyName.trim()).equals(elementName)) {
writeCurrent = true;
found.remove(propertyName);
currentName = propertyName;
@ -800,7 +813,7 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
} else if (event.getEventType() == XMLStreamConstants.END_ELEMENT
&& StringUtils.isNotBlank(currentName)
&& (ATOM_PROPERTY_PREFIX + currentName.trim()).equals(
&& (Constants.get(version, ConstantKey.ATOM_PROPERTY_PREFIX) + currentName.trim()).equals(
event.asEndElement().getName().getLocalPart())) {
writeNext = false;
currentName = null;
@ -840,23 +853,28 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
throw new NotFoundException();
}
final Charset encoding = Charset.forName("UTF-8");
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final OutputStreamWriter writer = new OutputStreamWriter(bos, encoding);
writer.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>".toCharArray());
if (forceFeed || links.size() > 1) {
// build a feed
bos.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>".getBytes());
bos.write(("<feed xml:base=\"" + DEFAULT_SERVICE_URL + "\" "
writer.write(("<feed xml:base=\"" + Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + "\" "
+ "xmlns=\"http://www.w3.org/2005/Atom\" "
+ "xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\" "
+ "xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">")
.getBytes());
.toCharArray());
bos.write(("<id>" + DEFAULT_SERVICE_URL + "entityset(entityid)/" + linkName + "</id>").getBytes());
writer.write(("<id>" + Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + "entityset(entityid)/" + linkName
+ "</id>").toCharArray());
bos.write(("<title type=\"text\">" + linkName + "</title>").getBytes());
bos.write("<updated>2014-03-03T13:40:49Z</updated>".getBytes());
bos.write(("<link rel=\"self\" title=\"" + linkName + "\" href=\"" + linkName + "\" />").getBytes());
writer.write(("<title type=\"text\">" + linkName + "</title>").toCharArray());
writer.write("<updated>2014-03-03T13:40:49Z</updated>".toCharArray());
writer.write(("<link rel=\"self\" title=\"" + linkName + "\" href=\"" + linkName + "\" />").toCharArray());
}
for (String link : links) {
@ -870,7 +888,7 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
Collections.<String>singletonList("entry"),
0, 1, 1).getValue();
IOUtils.copy(entry.toStream(), bos);
IOUtils.copy(entry.toStream(), writer, encoding);
} catch (Exception e) {
// log and ignore link
LOG.warn("Error parsing uri {}", link, e);
@ -880,12 +898,15 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
if (forceFeed || links.size() > 1) {
if (StringUtils.isNotBlank(next)) {
bos.write(String.format("<link rel=\"next\" href=\"%s\" />", next).getBytes());
writer.write(String.format("<link rel=\"next\" href=\"%s\" />", next).toCharArray());
}
bos.write("</feed>".getBytes());
writer.write("</feed>".toCharArray());
}
writer.flush();
writer.close();
return new ByteArrayInputStream(bos.toByteArray());
}
@ -901,7 +922,8 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
XMLEventReader reader = getEventReader(new ByteArrayInputStream(bos.toByteArray()));
final Map.Entry<Integer, XmlElement> propertyElement =
extractElement(reader, null, Collections.<String>singletonList(PROPERTIES), 0, 2, 3);
extractElement(reader, null,
Collections.<String>singletonList(Constants.get(version, ConstantKey.PROPERTIES)), 0, 2, 3);
reader.close();
reader = propertyElement.getValue().getContentReader();
@ -924,9 +946,11 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
int pos = 0;
while (true) {
final Map.Entry<Integer, XmlElement> linkElement =
extractElement(reader, null, Collections.<String>singletonList(LINK), pos, 2, 2);
extractElement(reader, null,
Collections.<String>singletonList(Constants.get(version, ConstantKey.LINK)), pos, 2, 2);
res.put("[LINK]" + linkElement.getValue().getStart().getAttributeByName(new QName("title")).getValue(),
res.put("[Constants.get(version, ConstantKey.LINK)]"
+ linkElement.getValue().getStart().getAttributeByName(new QName("title")).getValue(),
linkElement.getValue().toStream());
pos = linkElement.getKey();
@ -952,7 +976,8 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
// add property changes
// ---------------------------------
Map.Entry<Integer, XmlElement> propertyElement =
extractElement(reader, writer, Collections.<String>singletonList(PROPERTIES), 0, 2, 3);
extractElement(reader, writer,
Collections.<String>singletonList(Constants.get(version, ConstantKey.PROPERTIES)), 0, 2, 3);
writer.flush();
@ -981,7 +1006,7 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
}
for (Map.Entry<String, InputStream> remains : properties.entrySet()) {
if (!remains.getKey().startsWith("[LINK]")) {
if (!remains.getKey().startsWith("[Constants.get(version, ConstantKey.LINK)]")) {
pwriter.append(IOUtils.toString(remains.getValue()));
IOUtils.closeQuietly(remains.getValue());
}
@ -1009,7 +1034,7 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
// remove existent links
for (Map.Entry<String, InputStream> remains : properties.entrySet()) {
if (remains.getKey().startsWith("[LINK]")) {
if (remains.getKey().startsWith("[Constants.get(version, ConstantKey.LINK)]")) {
reader = getEventReader(new ByteArrayInputStream(bos.toByteArray()));
bos.reset();
@ -1018,7 +1043,7 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
try {
final String linkName = remains.getKey().substring(remains.getKey().indexOf("]") + 1);
extractElement(reader, writer, Collections.<String>singletonList(LINK),
extractElement(reader, writer, Collections.<String>singletonList(Constants.get(version, ConstantKey.LINK)),
Collections.<Map.Entry<String, String>>singleton(new SimpleEntry<String, String>("title", linkName)),
false, 0, 2, 2);
@ -1038,14 +1063,15 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
bos.reset();
writer = getEventWriter(bos);
propertyElement = extractElement(reader, writer, Collections.<String>singletonList(CONTENT), 0, 2, 2);
propertyElement = extractElement(reader, writer,
Collections.<String>singletonList(Constants.get(version, ConstantKey.CONTENT)), 0, 2, 2);
writer.flush();
pbos.reset();
pwriter = new OutputStreamWriter(pbos);
for (Map.Entry<String, InputStream> remains : properties.entrySet()) {
if (remains.getKey().startsWith("[LINK]")) {
if (remains.getKey().startsWith("[Constants.get(version, ConstantKey.LINK)]")) {
pwriter.append(IOUtils.toString(remains.getValue()));
IOUtils.closeQuietly(remains.getValue());
}
@ -1084,7 +1110,8 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
try {
final XmlElement linkElement =
extractElement(reader, writer, Collections.<String>singletonList(LINK),
extractElement(reader, writer,
Collections.<String>singletonList(Constants.get(version, ConstantKey.LINK)),
Collections.<Map.Entry<String, String>>singletonList(new SimpleEntry<String, String>("title", linkName)),
false, 0, -1, -1).getValue();
writer.add(linkElement.getStart());
@ -1116,23 +1143,26 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
public String getEdmTypeFromAtom(final String entitySetName, final String entityId, final List<String> path)
throws Exception {
InputStream src = fsManager.readFile(Commons.getEntityBasePath(entitySetName, entityId) + ENTITY, Accept.XML);
InputStream src = fsManager.readFile(Commons.getEntityBasePath(entitySetName, entityId)
+ Constants.get(version, ConstantKey.ENTITY), Accept.XML);
final List<String> atomPathElements = new ArrayList<String>();
for (String element : path) {
atomPathElements.add(ATOM_PROPERTY_PREFIX + element);
atomPathElements.add(Constants.get(version, ConstantKey.ATOM_PROPERTY_PREFIX) + element);
}
final Map.Entry<Integer, XmlElement> prop = extractElement(getEventReader(src), null, atomPathElements, 0, 3, 4);
IOUtils.closeQuietly(src);
final Attribute type = prop.getValue().getStart().getAttributeByName(new QName(TYPE));
final Attribute type =
prop.getValue().getStart().getAttributeByName(new QName(Constants.get(version, ConstantKey.TYPE)));
final String edmType;
if (type == null) {
edmType = Constants.ATOM_DEF_TYPE;
edmType = Constants.get(version, ConstantKey.ATOM_DEF_TYPE);
} else {
edmType = type.getValue();
}
@ -1189,11 +1219,12 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
final List<String> pathElements = new ArrayList<String>();
for (String element : path) {
pathElements.add(ATOM_PROPERTY_PREFIX + element);
pathElements.add(Constants.get(version, ConstantKey.ATOM_PROPERTY_PREFIX) + element);
}
final InputStream src =
fsManager.readFile(Commons.getEntityBasePath(entitySetName, entityId) + ENTITY, Accept.XML);
fsManager.readFile(Commons.getEntityBasePath(entitySetName, entityId)
+ Constants.get(version, ConstantKey.ENTITY), Accept.XML);
final XMLEventReader reader = getEventReader(src);
final XmlElement property = extractElement(reader, null, pathElements, 0, 3, 4).getValue();
@ -1205,14 +1236,20 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
final XMLEventWriter writer = getEventWriter(bos);
final XMLEventFactory eventFactory = XMLEventFactory.newInstance();
writer.add(eventFactory.createStartDocument("UTF-8", "1.0"));
writer.add(eventFactory.createStartDocument("utf-8", "1.0"));
writer.add(property.getStart());
if (property.getStart().getAttributeByName(new QName(ATOM_DATASERVICE_NS)) == null) {
writer.add(eventFactory.createNamespace(ATOM_PROPERTY_PREFIX.substring(0, 1), DATASERVICES_NS));
if (property.getStart().getAttributeByName(new QName(
Constants.get(version, ConstantKey.ATOM_DATASERVICE_NS))) == null) {
writer.add(eventFactory.createNamespace(
Constants.get(version, ConstantKey.ATOM_PROPERTY_PREFIX).substring(0, 1),
Constants.get(version, ConstantKey.DATASERVICES_NS)));
}
if (property.getStart().getAttributeByName(new QName(ATOM_METADATA_NS)) == null) {
writer.add(eventFactory.createNamespace(ATOM_METADATA_PREFIX.substring(0, 1), METADATA_NS));
if (property.getStart().getAttributeByName(new QName(
Constants.get(version, ConstantKey.ATOM_METADATA_NS))) == null) {
writer.add(eventFactory.createNamespace(
Constants.get(version, ConstantKey.ATOM_METADATA_PREFIX).substring(0, 1),
Constants.get(version, ConstantKey.METADATA_NS)));
}
writer.add(property.getContentReader());
@ -1232,7 +1269,7 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
final List<String> pathElements = new ArrayList<String>();
for (String element : path) {
pathElements.add(ATOM_PROPERTY_PREFIX + element);
pathElements.add(Constants.get(version, ConstantKey.ATOM_PROPERTY_PREFIX) + element);
}
final XMLEventReader reader = getEventReader(src);
@ -1248,7 +1285,16 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
final XMLEventReader changesReader = new XMLEventReaderWrapper(replacement);
writer.add(changesReader);
while (changesReader.hasNext()) {
final XMLEvent event = changesReader.nextEvent();
if (event.isStartElement() && event.asStartElement().getName().equals(element.getValue().getStart().getName())) {
writer.add(element.getValue().getStart());
writer.add(changesReader);
} else {
writer.add(event);
}
}
changesReader.close();
IOUtils.closeQuietly(replacement);
@ -1273,7 +1319,7 @@ public abstract class AbstractXMLUtilities extends AbstractUtilities {
final List<String> pathElements = new ArrayList<String>();
for (String element : path) {
pathElements.add(ATOM_PROPERTY_PREFIX + element);
pathElements.add(Constants.get(version, ConstantKey.ATOM_PROPERTY_PREFIX) + element);
}
final XMLEventReader reader = getEventReader(src);

View File

@ -18,8 +18,6 @@
*/
package org.apache.olingo.fit.utils;
import static org.apache.olingo.fit.utils.Constants.*;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
@ -41,6 +39,7 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import org.apache.commons.io.IOUtils;
import org.codehaus.plexus.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -68,6 +67,7 @@ public abstract class Commons {
sequence.put("Order", 1000);
sequence.put("ComputerDetail", 1000);
sequence.put("AllGeoTypesSet", 1000);
sequence.put("Orders", 1000);
mediaContent.put("CustomerInfo", "CustomerinfoId");
mediaContent.put("Car", "VIN");
@ -79,11 +79,14 @@ public abstract class Commons {
}
public static String getEntityURI(final String entitySetName, final String entityKey) {
return entitySetName + "(" + entityKey + ")";
// expected singleton in case of null key
return entitySetName + (StringUtils.isNotBlank(entityKey) ? "(" + entityKey + ")" : "");
}
public static String getEntityBasePath(final String entitySetName, final String entityKey) {
return entitySetName + File.separatorChar + getEntityKey(entityKey) + File.separatorChar;
// expected singleton in case of null key
return entitySetName + File.separatorChar
+ (StringUtils.isNotBlank(entityKey) ? getEntityKey(entityKey) + File.separatorChar : "");
}
public static String getLinksURI(
@ -109,7 +112,8 @@ public abstract class Commons {
throws IOException {
try {
return FSManager.instance(version)
.getAbsolutePath(basePath + LINKS_FILE_PATH + File.separatorChar + linkName, accept);
.getAbsolutePath(basePath + Constants.get(version, ConstantKey.LINKS_FILE_PATH)
+ File.separatorChar + linkName, accept);
} catch (Exception e) {
throw new IOException(e);
}
@ -143,7 +147,7 @@ public abstract class Commons {
if (URI.create(uri).isAbsolute()) {
builder.append(uri);
} else {
builder.append(DEFAULT_SERVICE_URL).append(uri);
builder.append(Constants.get(ConstantKey.DEFAULT_SERVICE_URL)).append(uri);
}
builder.append("</uri>");
}
@ -158,8 +162,8 @@ public abstract class Commons {
throws IOException {
final ObjectNode links = new ObjectNode(JsonNodeFactory.instance);
links.put(
JSON_ODATAMETADATA_NAME,
ODATA_METADATA_PREFIX + entitySetName + "/$links/" + link.getKey());
Constants.get(ConstantKey.JSON_ODATAMETADATA_NAME),
Constants.get(ConstantKey.ODATA_METADATA_PREFIX) + entitySetName + "/$links/" + link.getKey());
final ArrayNode uris = new ArrayNode(JsonNodeFactory.instance);
@ -168,7 +172,7 @@ public abstract class Commons {
if (URI.create(uri).isAbsolute()) {
absoluteURI = uri;
} else {
absoluteURI = DEFAULT_SERVICE_URL + uri;
absoluteURI = Constants.get(ConstantKey.DEFAULT_SERVICE_URL) + uri;
}
uris.add(new ObjectNode(JsonNodeFactory.instance).put("url", absoluteURI));
}
@ -179,7 +183,7 @@ public abstract class Commons {
links.set("value", uris);
}
return IOUtils.toInputStream(links.toString());
return IOUtils.toInputStream(links.toString(), "UTf-8");
}
public static InputStream changeFormat(final InputStream is, final Accept target) {
@ -193,7 +197,7 @@ public abstract class Commons {
final JsonNode node =
changeFormat((ObjectNode) mapper.readTree(new ByteArrayInputStream(bos.toByteArray())), target);
return IOUtils.toInputStream(node.toString());
return IOUtils.toInputStream(node.toString(), "UTF-8");
} catch (Exception e) {
LOG.error("Error changing format", e);
return new ByteArrayInputStream(bos.toByteArray());
@ -210,20 +214,20 @@ public abstract class Commons {
switch (target) {
case JSON_NOMETA:
// nometa + minimal
toBeRemoved.add(JSON_ODATAMETADATA_NAME);
toBeRemoved.add(Constants.get(ConstantKey.JSON_ODATAMETADATA_NAME));
case JSON:
// minimal
toBeRemoved.add(JSON_EDITLINK_NAME);
toBeRemoved.add(JSON_ID_NAME);
toBeRemoved.add(JSON_TYPE_NAME);
toBeRemoved.add(Constants.get(ConstantKey.JSON_EDITLINK_NAME));
toBeRemoved.add(Constants.get(ConstantKey.JSON_ID_NAME));
toBeRemoved.add(Constants.get(ConstantKey.JSON_TYPE_NAME));
final Iterator<Map.Entry<String, JsonNode>> fields = node.fields();
while (fields.hasNext()) {
final Map.Entry<String, JsonNode> field = fields.next();
if (field.getKey().endsWith(JSON_MEDIA_SUFFIX)
|| field.getKey().endsWith(JSON_NAVIGATION_SUFFIX)
|| field.getKey().endsWith(JSON_TYPE_SUFFIX)) {
if (field.getKey().endsWith(Constants.get(ConstantKey.JSON_MEDIA_SUFFIX))
|| field.getKey().endsWith(Constants.get(ConstantKey.JSON_NAVIGATION_SUFFIX))
|| field.getKey().endsWith(Constants.get(ConstantKey.JSON_TYPE_SUFFIX))) {
toBeRemoved.add(field.getKey());
} else if (field.getValue().isObject()) {
toBeReplaced.put(field.getKey(), changeFormat((ObjectNode) field.getValue(), target));
@ -266,8 +270,18 @@ public abstract class Commons {
public static Map.Entry<String, String> parseEntityURI(final String uri) {
final String relPath = uri.substring(uri.lastIndexOf("/"));
final int branchIndex = relPath.indexOf('(');
final String es = relPath.substring(0, branchIndex);
final String eid = relPath.substring(branchIndex + 1, relPath.indexOf(')'));
final String es;
final String eid;
if (branchIndex > -1) {
es = relPath.substring(0, branchIndex);
eid = relPath.substring(branchIndex + 1, relPath.indexOf(')'));
} else {
es = relPath;
eid = null;
}
return new SimpleEntry<String, String>(es, eid);
}
}

View File

@ -0,0 +1,67 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.fit.utils;
public enum ConstantKey {
ODATA_SERVICE_VERSION,
DEFAULT_SERVICE_URL,
ODATA_COUNT_NAME,
ODATA_METADATA_PREFIX,
ATOM_DEF_TYPE,
ATOM_PROPERTY_PREFIX,
ATOM_METADATA_PREFIX,
ATOM_METADATA_NS,
ATOM_DATASERVICE_NS,
ATOM_LINK_ENTRY,
ATOM_LINK_FEED,
ATOM_LINK_REL,
TYPE,
INLINE_LOCAL,
INLINE_FILE_PATH,
LINKS_FILE_PATH,
INLINE,
CONTENT,
PROPERTIES,
LINK,
DATASERVICES_NS,
METADATA_NS,
METADATA,
SERVICES,
FEED,
ENTITY,
REF,
MEDIA_CONTENT_FILENAME,
SKIP_TOKEN,
FILTER,
ORDERBY,
JSON_VALUE_NAME,
JSON_NEXTLINK_NAME,
JSON_NEXTLINK_SUFFIX,
JSON_ODATAMETADATA_NAME,
JSON_NAVIGATION_BIND_SUFFIX,
JSON_NAVIGATION_SUFFIX,
JSON_MEDIA_SUFFIX,
JSON_TYPE_NAME,
JSON_TYPE_SUFFIX,
JSON_ID_NAME,
JSON_EDITLINK_NAME,
XHTTP_HEADER_NAME;
};

View File

@ -18,90 +18,83 @@
*/
package org.apache.olingo.fit.utils;
import java.util.EnumMap;
import java.util.Map;
public class Constants {
public final static String ODATA_SERVICE_VERSION = "DataServiceVersion";
private final static Map<ConstantKey, String> v4constants = new EnumMap<ConstantKey, String>(ConstantKey.class);
public final static String DEFAULT_SERVICE_URL = "http://localhost:9080/StaticService/V30/Static.svc/";
private final static Map<ConstantKey, String> constants = new EnumMap<ConstantKey, String>(ConstantKey.class);
public final static String ODATA_COUNT_NAME = "odata.count";
static {
public final static String ODATA_METADATA_PREFIX = DEFAULT_SERVICE_URL + "$metadata#";
// -----------------------------
// V4 only
// -----------------------------
v4constants.put(ConstantKey.JSON_NAVIGATION_SUFFIX, "@odata.navigationLink");
v4constants.put(ConstantKey.DATASERVICES_NS, "http://docs.oasis-open.org/odata/ns/dataservices");
v4constants.put(ConstantKey.METADATA_NS, "http://docs.oasis-open.org/odata/ns/metadata");
v4constants.put(ConstantKey.ODATA_SERVICE_VERSION, "OData-Version");
v4constants.put(ConstantKey.DEFAULT_SERVICE_URL, "http://localhost:9080/StaticService/V40/Static.svc/");
v4constants.put(ConstantKey.ODATA_METADATA_PREFIX, "http://localhost:9080/StaticService/V40/Static.svc/$metadata#");
// -----------------------------
public final static String ATOM_DEF_TYPE = "Edm.String";
// -----------------------------
// V3 and defaults
// -----------------------------
constants.put(ConstantKey.ODATA_SERVICE_VERSION, "DataServiceVersion");
constants.put(ConstantKey.DEFAULT_SERVICE_URL, "http://localhost:9080/StaticService/V30/Static.svc/");
constants.put(ConstantKey.ODATA_COUNT_NAME, "odata.count");
constants.put(ConstantKey.ODATA_METADATA_PREFIX, "http://localhost:9080/StaticService/V30/Static.svc/$metadata#");
constants.put(ConstantKey.ATOM_DEF_TYPE, "Edm.String");
constants.put(ConstantKey.ATOM_PROPERTY_PREFIX, "d:");
constants.put(ConstantKey.ATOM_METADATA_PREFIX, "m:");
constants.put(ConstantKey.ATOM_METADATA_NS, "xmlns:m");
constants.put(ConstantKey.ATOM_DATASERVICE_NS, "xmlns:d");
constants.put(ConstantKey.ATOM_LINK_ENTRY, "application/atom+xml;type=entry");
constants.put(ConstantKey.ATOM_LINK_FEED, "application/atom+xml;type=feed");
constants.put(ConstantKey.ATOM_LINK_REL, "http://schemas.microsoft.com/ado/2007/08/dataservices/related/");
constants.put(ConstantKey.TYPE, "m:type");
constants.put(ConstantKey.INLINE_LOCAL, "inline");
constants.put(ConstantKey.INLINE_FILE_PATH, "inline");
constants.put(ConstantKey.LINKS_FILE_PATH, "links");
constants.put(ConstantKey.INLINE, "m:inline");
constants.put(ConstantKey.CONTENT, "content");
constants.put(ConstantKey.PROPERTIES, "m:properties");
constants.put(ConstantKey.LINK, "link");
constants.put(ConstantKey.METADATA_NS, "http://schemas.microsoft.com/ado/2007/08/dataservices/metadta");
constants.put(ConstantKey.DATASERVICES_NS, "http://schemas.microsoft.com/ado/2007/08/dataservices");
constants.put(ConstantKey.METADATA, "metadata");
constants.put(ConstantKey.SERVICES, "services");
constants.put(ConstantKey.FEED, "feed");
constants.put(ConstantKey.ENTITY, "entity");
constants.put(ConstantKey.REF, "references");
constants.put(ConstantKey.MEDIA_CONTENT_FILENAME, "$value.bin");
constants.put(ConstantKey.SKIP_TOKEN, "skiptoken");
constants.put(ConstantKey.FILTER, "filter");
constants.put(ConstantKey.ORDERBY, "orderby");
constants.put(ConstantKey.JSON_VALUE_NAME, "value");
constants.put(ConstantKey.JSON_NEXTLINK_NAME, "odata.nextLink");
constants.put(ConstantKey.JSON_NEXTLINK_SUFFIX, "@odata.nextLink");
constants.put(ConstantKey.JSON_ODATAMETADATA_NAME, "odata.metadata");
constants.put(ConstantKey.JSON_NAVIGATION_BIND_SUFFIX, "@odata.bind");
constants.put(ConstantKey.JSON_NAVIGATION_SUFFIX, "@odata.navigationLinkUrl");
constants.put(ConstantKey.JSON_MEDIA_SUFFIX, "@odata.mediaEditLink");
constants.put(ConstantKey.JSON_TYPE_NAME, "odata.type");
constants.put(ConstantKey.JSON_TYPE_SUFFIX, "@odata.type");
constants.put(ConstantKey.JSON_ID_NAME, "odata.id");
constants.put(ConstantKey.JSON_EDITLINK_NAME, "odata.editLink");
constants.put(ConstantKey.XHTTP_HEADER_NAME, "X-HTTP-METHOD");
// -----------------------------
}
public final static String ATOM_PROPERTY_PREFIX = "d:";
public final static String ATOM_METADATA_PREFIX = "m:";
public final static String ATOM_METADATA_NS = "xmlns:m";
public final static String ATOM_DATASERVICE_NS = "xmlns:d";
public final static String ATOM_LINK_ENTRY = "application/atom+xml;type=entry";
public final static String ATOM_LINK_FEED = "application/atom+xml;type=feed";
public final static String ATOM_LINK_REL = "http://schemas.microsoft.com/ado/2007/08/dataservices/related/";
public final static String TYPE = ATOM_METADATA_PREFIX + "type";
public final static String INLINE_LOCAL = "inline";
public final static String INLINE_FILE_PATH = "inline";
public final static String LINKS_FILE_PATH = "links";
public final static String INLINE = ATOM_METADATA_PREFIX + INLINE_LOCAL;
public final static String CONTENT = "content";
public final static String PROPERTIES = ATOM_METADATA_PREFIX + "properties";
public final static String LINK = "link";
public final static String DATASERVICES_NS = "http://schemas.microsoft.com/ado/2007/08/dataservices";
public final static String METADATA_NS = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";
public final static String METADATA = "metadata";
public final static String SERVICES = "services";
public final static String FEED = "feed";
public final static String ENTITY = "entity";
public final static String MEDIA_CONTENT_FILENAME = "$value.bin";
public final static String SKIP_TOKEN = "skiptoken";
public final static String FILTER = "filter";
public final static String ORDERBY = "orderby";
public final static String JSON_VALUE_NAME = "value";
public final static String JSON_NEXTLINK_NAME = "odata.nextLink";
public final static String JSON_NEXTLINK_SUFFIX = "@" + JSON_NEXTLINK_NAME;
public final static String JSON_ODATAMETADATA_NAME = "odata.metadata";
public final static String JSON_NAVIGATION_BIND_SUFFIX = "@odata.bind";
public final static String JSON_NAVIGATION_SUFFIX = "@odata.navigationLinkUrl";
public final static String JSON_MEDIA_SUFFIX = "@odata.mediaEditLink";
public final static String JSON_TYPE_NAME = "odata.type";
public final static String JSON_TYPE_SUFFIX = "@" + JSON_TYPE_NAME;
public final static String JSON_ID_NAME = "odata.id";
public final static String JSON_EDITLINK_NAME = "odata.editLink";
public final static String XHTTP_HEADER_NAME = "X-HTTP-METHOD";
public static String get(final ConstantKey key) {
return get(null, key);
}
public static String get(final ODataVersion version, final ConstantKey key) {
return (version == null || version == ODataVersion.v3 || !v4constants.containsKey(key)
? constants : v4constants).get(key);
}
}

View File

@ -28,6 +28,14 @@ public class MetadataLinkInfo {
private Map<String, EntitySet> entitySets = new HashMap<String, EntitySet>();
public void setSingleton(final String entitySetName) {
entitySets.get(entitySetName).setSingleton(true);
}
public boolean isSingleton(final String entitySetName) {
return entitySets.get(entitySetName).isSingleton();
}
public Set<String> getEntitySets() {
return entitySets.keySet();
}
@ -92,6 +100,8 @@ public class MetadataLinkInfo {
private Set<NavigationLink> links;
private boolean singleton;
public EntitySet(final String name) {
this.name = name;
links = new HashSet<NavigationLink>();
@ -135,6 +145,18 @@ public class MetadataLinkInfo {
this.links = links;
}
public EntitySet(boolean singleton) {
this.singleton = singleton;
}
public boolean isSingleton() {
return singleton;
}
public void setSingleton(boolean singleton) {
this.singleton = singleton;
}
@Override
public String toString() {
return name + ": " + links;

View File

@ -32,4 +32,4 @@ public enum ODataVersion {
public String getVersion() {
return version;
}
};
}

View File

@ -0,0 +1,57 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.fit.utils;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLDecoder;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
public class ResolvingReferencesInterceptor extends AbstractPhaseInterceptor<Message> {
public ResolvingReferencesInterceptor() {
super(Phase.PRE_PROTOCOL);
}
@Override
public void handleMessage(final Message message) throws Fault {
final String path = (String) message.get(Message.PATH_INFO);
final String query = (String) message.get(Message.QUERY_STRING);
try {
if (path.endsWith("$entity") && StringUtils.isNotBlank(query)
&& URLDecoder.decode(query, "UTF-8").contains("$id=")) {
final String id = URLDecoder.decode(query, "UTF-8");
final String newURL = id.substring(id.indexOf("$id=") + 4);
final URI uri = URI.create(newURL);
message.put(Message.REQUEST_URL, uri.toASCIIString());
message.put(Message.REQUEST_URI, uri.getPath());
message.put(Message.PATH_INFO, uri.getPath());
}
} catch (UnsupportedEncodingException ignore) {
}
}
}

View File

@ -36,8 +36,9 @@ public class XHTTPMethodInterceptor extends AbstractPhaseInterceptor<Message> {
@SuppressWarnings("unchecked")
final Map<String, List<String>> headers = (Map<String, List<String>>) message.get(Message.PROTOCOL_HEADERS);
if (headers.containsKey(Constants.XHTTP_HEADER_NAME)) {
message.put(Message.HTTP_REQUEST_METHOD, headers.get(Constants.XHTTP_HEADER_NAME).iterator().next());
if (headers.containsKey(Constants.get(ConstantKey.XHTTP_HEADER_NAME))) {
message.put(Message.HTTP_REQUEST_METHOD, headers.get(Constants.get(ConstantKey.XHTTP_HEADER_NAME))
.iterator().next());
}
}
}

View File

@ -20,6 +20,10 @@ package org.apache.olingo.fit.utils;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CodingErrorAction;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
@ -28,6 +32,8 @@ import org.apache.commons.io.IOUtils;
public class XMLEventReaderWrapper implements XMLEventReader {
private static Charset encoding = Charset.forName("UTF-8");
public final static String CONTENT = "CONTENT_TAG";
public final static String CONTENT_STAG = "<" + CONTENT + ">";
@ -43,12 +49,17 @@ public class XMLEventReaderWrapper implements XMLEventReader {
factory.setProperty(XMLInputFactory.IS_VALIDATING, false);
factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, false);
final CharsetDecoder decoder = encoding.newDecoder();
decoder.onMalformedInput(CodingErrorAction.IGNORE);
decoder.onUnmappableCharacter(CodingErrorAction.IGNORE);
this.wrapped = factory.createXMLEventReader(
new ByteArrayInputStream(
(XMLEventReaderWrapper.CONTENT_STAG
+ IOUtils.toString(stream).replaceAll("^<\\?xml.*\\?>", "")
+ XMLEventReaderWrapper.CONTENT_ETAG).getBytes()));
InputStreamReader reader = new InputStreamReader(
new ByteArrayInputStream((XMLEventReaderWrapper.CONTENT_STAG
+ IOUtils.toString(stream, encoding).replaceAll("^<\\?xml.*\\?>", "")
+ XMLEventReaderWrapper.CONTENT_ETAG).getBytes(encoding)),
decoder);
this.wrapped = factory.createXMLEventReader(reader);
init();
}

View File

@ -22,7 +22,9 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.EndElement;
@ -38,6 +40,8 @@ public class XmlElement {
*/
protected static final Logger LOG = LoggerFactory.getLogger(XmlElement.class);
private static Charset encoding = Charset.forName("UTF-8");
private StartElement start;
private EndElement end;
@ -70,20 +74,26 @@ public class XmlElement {
public void setContent(final InputStream content) throws IOException {
this.content.reset();
IOUtils.copyLarge(content, this.content);
content.close();
final InputStreamReader reader = new InputStreamReader(content, encoding);
final OutputStreamWriter writer = new OutputStreamWriter(this.content, encoding);
IOUtils.copyLarge(reader, writer);
writer.flush();
IOUtils.closeQuietly(reader);
IOUtils.closeQuietly(writer);
IOUtils.closeQuietly(content);
}
public InputStream toStream() throws Exception {
InputStream res;
try {
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final OutputStreamWriter osw = new OutputStreamWriter(bos);
final OutputStreamWriter osw = new OutputStreamWriter(bos, encoding);
getStart().writeAsEncodedUnicode(osw);
osw.flush();
IOUtils.copy(getContent(), bos);
IOUtils.copy(getContent(), osw, encoding);
getEnd().writeAsEncodedUnicode(osw);
osw.flush();

View File

@ -32,6 +32,7 @@ import javax.xml.stream.events.StartElement;
import org.apache.commons.io.IOUtils;
import org.apache.olingo.fit.utils.Accept;
import org.apache.olingo.fit.utils.Commons;
import org.apache.olingo.fit.utils.ConstantKey;
import org.apache.olingo.fit.utils.Constants;
import org.apache.olingo.fit.utils.MetadataLinkInfo;
import org.apache.olingo.fit.utils.ODataVersion;
@ -49,7 +50,7 @@ public class XMLUtilities extends org.apache.olingo.fit.utils.AbstractXMLUtiliti
final MetadataLinkInfo metadataLinkInfo = new MetadataLinkInfo();
Commons.getLinkInfo().put(version, metadataLinkInfo);
final InputStream metadata = fsManager.readFile(Constants.METADATA, Accept.XML);
final InputStream metadata = fsManager.readFile(Constants.get(version, ConstantKey.METADATA), Accept.XML);
final XMLEventReader reader = getEventReader(metadata);
try {
@ -69,7 +70,7 @@ public class XMLUtilities extends org.apache.olingo.fit.utils.AbstractXMLUtiliti
private void retrieveLinks(final XmlElement entitySetElement, final MetadataLinkInfo metadataLinkInfo)
throws Exception {
final InputStream metadata = fsManager.readFile(Constants.METADATA, Accept.XML);
final InputStream metadata = fsManager.readFile(Constants.get(version, ConstantKey.METADATA), Accept.XML);
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
IOUtils.copy(metadata, bos);
@ -120,7 +121,7 @@ public class XMLUtilities extends org.apache.olingo.fit.utils.AbstractXMLUtiliti
private Map.Entry<String, Boolean> getTargetInfo(final StartElement element, final String linkName)
throws Exception {
final InputStream metadata = fsManager.readFile(Constants.METADATA, Accept.XML);
final InputStream metadata = fsManager.readFile(Constants.get(version, ConstantKey.METADATA), Accept.XML);
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
IOUtils.copy(metadata, bos);

View File

@ -30,6 +30,7 @@ import javax.xml.stream.XMLEventReader;
import org.apache.commons.io.IOUtils;
import org.apache.olingo.fit.utils.Accept;
import org.apache.olingo.fit.utils.Commons;
import org.apache.olingo.fit.utils.ConstantKey;
import org.apache.olingo.fit.utils.Constants;
import org.apache.olingo.fit.utils.MetadataLinkInfo;
import org.apache.olingo.fit.utils.ODataVersion;
@ -47,7 +48,7 @@ public class XMLUtilities extends org.apache.olingo.fit.utils.AbstractXMLUtiliti
final MetadataLinkInfo metadataLinkInfo = new MetadataLinkInfo();
Commons.getLinkInfo().put(version, metadataLinkInfo);
final InputStream metadata = fsManager.readFile(Constants.METADATA, Accept.XML);
final InputStream metadata = fsManager.readFile(Constants.get(version, ConstantKey.METADATA), Accept.XML);
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
IOUtils.copy(metadata, bos);
@ -138,5 +139,9 @@ public class XMLUtilities extends org.apache.olingo.fit.utils.AbstractXMLUtiliti
if (size == 0) {
metadataLinkInfo.addEntitySet(entitySetName);
}
if (singletons.contains(entitySetName)) {
metadataLinkInfo.setSingleton(entitySetName);
}
}
}

View File

@ -0,0 +1,38 @@
{
"@odata.context": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#Company",
"@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Company",
"@odata.id": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company",
"@odata.editLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company",
"CompanyID": 0,
"CompanyCategory@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.CompanyCategory",
"CompanyCategory": "IT",
"Revenue@odata.type": "#Int64",
"Revenue": 100000,
"Name": "MS",
"Address":
{
"@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.CompanyAddress",
"Street": "1 Microsoft Way",
"City": "Redmond",
"PostalCode": "98052",
"CompanyName": "Microsoft"
},
"Employees@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company/Employees/$ref",
"Employees@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company/Employees",
"VipCustomer@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company/VipCustomer/$ref",
"VipCustomer@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company/VipCustomer",
"Departments@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company/Departments/$ref",
"Departments@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company/Departments",
"CoreDepartment@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company/CoreDepartment/$ref",
"CoreDepartment@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company/CoreDepartment",
"#Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue":
{
"title": "Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue",
"target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company/Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue"
},
"#Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount":
{
"title": "Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount",
"target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company/Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount"
}
}

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<entry xml:base="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:context="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#Company">
<id>http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company</id>
<category term="#Microsoft.Test.OData.Services.ODataWCFService.Company" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
<link rel="edit" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company" />
<link rel="http://docs.oasis-open.org/odata/ns/related/Employees" type="application/atom+xml;type=feed" title="Employees" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company/Employees" />
<link rel="http://docs.oasis-open.org/odata/ns/related/VipCustomer" type="application/atom+xml;type=entry" title="VipCustomer" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company/VipCustomer" />
<link rel="http://docs.oasis-open.org/odata/ns/related/Departments" type="application/atom+xml;type=feed" title="Departments" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company/Departments" />
<link rel="http://docs.oasis-open.org/odata/ns/related/CoreDepartment" type="application/atom+xml;type=entry" title="CoreDepartment" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company/CoreDepartment" />
<title />
<updated>2014-03-24T17:09:31Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:CompanyID m:type="Int32">0</d:CompanyID>
<d:CompanyCategory m:type="#Microsoft.Test.OData.Services.ODataWCFService.CompanyCategory">IT</d:CompanyCategory>
<d:Revenue m:type="Int64">100000</d:Revenue>
<d:Name>MS</d:Name>
<d:Address m:type="#Microsoft.Test.OData.Services.ODataWCFService.CompanyAddress">
<d:Street>1 Microsoft Way</d:Street>
<d:City>Redmond</d:City>
<d:PostalCode>98052</d:PostalCode>
<d:CompanyName>Microsoft</d:CompanyName>
</d:Address>
</m:properties>
</content>
</entry>

View File

@ -0,0 +1,67 @@
{
"@odata.context": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#Customers/$entity",
"@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Customer",
"@odata.id": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)",
"@odata.editLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)",
"PersonID": 1,
"FirstName": "Bob",
"LastName": "Cat",
"MiddleName": null,
"HomeAddress":
{
"@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.HomeAddress",
"Street": "1 Microsoft Way",
"City": "London",
"PostalCode": "98052",
"FamilyName": "Cats"
},
"Home@odata.type": "#GeographyPoint",
"Home":
{
"type": "Point",
"coordinates":
[
23.1,
32.1
],
"crs":
{
"type": "name",
"properties":
{
"name": "EPSG:4326"
}
}
},
"Numbers@odata.type": "#Collection(String)",
"Numbers":
[
"111-111-1111"
],
"Emails@odata.type": "#Collection(String)",
"Emails":
[
"abc@abc.com"
],
"City": "London",
"Birthday@odata.type": "#DateTimeOffset",
"Birthday": "1957-04-03T00:00:00Z",
"TimeBetweenLastTwoOrders@odata.type": "#Duration",
"TimeBetweenLastTwoOrders": "PT0.0000001S",
"Parent@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)/Parent/$ref",
"Parent@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)/Parent",
"Orders@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)/Orders/$ref",
"Orders@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)/Orders",
"Company@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)/Company/$ref",
"Company@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)/Company",
"#Microsoft.Test.OData.Services.ODataWCFService.ResetAddress":
{
"title": "Microsoft.Test.OData.Services.ODataWCFService.ResetAddress",
"target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress"
},
"#Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress":
{
"title": "Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress",
"target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)/Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress"
}
}

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<entry xml:base="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/"
xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data"
xmlns:m="http://docs.oasis-open.org/odata/ns/metadata"
xmlns:georss="http://www.georss.org/georss"
xmlns:gml="http://www.opengis.net/gml"
m:context="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#Customers/$entity">
<id>http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)</id>
<category term="#Microsoft.Test.OData.Services.ODataWCFService.Customer" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
<link rel="edit" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)" />
<link rel="http://docs.oasis-open.org/odata/ns/related/Parent" type="application/atom+xml;type=entry" title="Parent" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)/Parent" />
<link rel="http://docs.oasis-open.org/odata/ns/related/Orders" type="application/atom+xml;type=feed" title="Orders" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)/Orders" />
<link rel="http://docs.oasis-open.org/odata/ns/related/Company" type="application/atom+xml;type=entry" title="Company" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)/Company" />
<title />
<updated>2014-03-24T17:03:20Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:PersonID m:type="Int32">1</d:PersonID>
<d:FirstName>Bob</d:FirstName>
<d:LastName>Cat</d:LastName>
<d:MiddleName m:null="true" />
<d:HomeAddress m:type="#Microsoft.Test.OData.Services.ODataWCFService.HomeAddress">
<d:Street>1 Microsoft Way</d:Street>
<d:City>London</d:City>
<d:PostalCode>98052</d:PostalCode>
<d:FamilyName>Cats</d:FamilyName>
</d:HomeAddress>
<d:Home m:type="GeographyPoint">
<gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
<gml:pos>32.1 23.1</gml:pos>
</gml:Point>
</d:Home>
<d:Numbers m:type="#Collection(String)">
<m:element>111-111-1111</m:element>
</d:Numbers>
<d:Emails m:type="#Collection(String)">
<m:element>abc@abc.com</m:element>
</d:Emails>
<d:City>London</d:City>
<d:Birthday m:type="DateTimeOffset">1957-04-03T00:00:00Z</d:Birthday>
<d:TimeBetweenLastTwoOrders m:type="Duration">PT0.0000001S</d:TimeBetweenLastTwoOrders>
</m:properties>
</content>
</entry>

View File

@ -0,0 +1,4 @@
{
"odata.metadata": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#Customer/$links/Info",
"url": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company"
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<uri xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Company</uri>

View File

@ -0,0 +1,10 @@
{
"odata.metadata": "http://localhost:${cargo.servlet.port}/StaticService/V30/Static.svc/$metadata#Customer/$links/Orders",
"value":
[
{
"url": "http://localhost:${cargo.servlet.port}/StaticService/V30/Static.svc/Orders(8)"
}
],
"odata.nextLink": "http://localhost:${cargo.servlet.port}/StaticService/V30/Static.svc/Customers(1)/$links/Orders?$skiptoken=2"
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<links xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">
<uri>http://localhost:${cargo.servlet.port}/StaticService/V30/Static.svc/Orders(8)</uri>
<next>http://localhost:${cargo.servlet.port}/StaticService/V30/Static.svc/Customers(1)/$links/Orders?$skiptoken=2</next>
</links>

View File

@ -0,0 +1,23 @@
{
"@odata.context": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#Orders/$entity",
"@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Order",
"@odata.id": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)",
"@odata.editLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)",
"@odata.etag": "W/\"123456789001\"",
"OrderID": 8,
"OrderDate@odata.type": "#DateTimeOffset",
"OrderDate": "2011-03-04T16:03:57Z",
"ShelfLife@odata.type": "#Duration",
"ShelfLife": "PT0.0000001S",
"OrderShelfLifes@odata.type": "#Collection(Duration)",
"OrderShelfLifes":
[
"PT0.0000001S"
],
"LoggedInEmployee@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/LoggedInEmployee/$ref",
"LoggedInEmployee@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/LoggedInEmployee",
"CustomerForOrder@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/CustomerForOrder/$ref",
"CustomerForOrder@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/CustomerForOrder",
"OrderDetails@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/OrderDetails/$ref",
"OrderDetails@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/OrderDetails"
}

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<entry xml:base="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/"
xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data"
xmlns:m="http://docs.oasis-open.org/odata/ns/metadata"
xmlns:georss="http://www.georss.org/georss"
xmlns:gml="http://www.opengis.net/gml"
m:context="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#Orders/$entity"
m:etag="W/&quot;123456789001&quot;">
<id>http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)</id>
<category term="#Microsoft.Test.OData.Services.ODataWCFService.Order" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
<link rel="edit" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)" />
<link rel="http://docs.oasis-open.org/odata/ns/related/LoggedInEmployee" type="application/atom+xml;type=entry" title="LoggedInEmployee" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/LoggedInEmployee" />
<link rel="http://docs.oasis-open.org/odata/ns/related/CustomerForOrder" type="application/atom+xml;type=entry" title="CustomerForOrder" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/CustomerForOrder" />
<link rel="http://docs.oasis-open.org/odata/ns/related/OrderDetails" type="application/atom+xml;type=feed" title="OrderDetails" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/OrderDetails" />
<title />
<updated>2014-03-24T17:36:01Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:OrderID m:type="Int32">8</d:OrderID>
<d:OrderDate m:type="DateTimeOffset">2011-03-04T16:03:57Z</d:OrderDate>
<d:ShelfLife m:type="Duration">PT0.0000001S</d:ShelfLife>
<d:OrderShelfLifes m:type="#Collection(Duration)">
<m:element>PT0.0000001S</m:element>
</d:OrderShelfLifes>
</m:properties>
</content>
</entry>

View File

@ -0,0 +1 @@
W/"123456789001"

View File

@ -0,0 +1,4 @@
{
"odata.metadata": "http://localhost:${cargo.servlet.port}/StaticService/V30/Static.svc/$metadata#Customer/$links/Info",
"url": "http://localhost:${cargo.servlet.port}/StaticService/V30/Static.svc/CustomerInfo(11)"
}

View File

@ -0,0 +1,4 @@
{
"odata.metadata": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#Orders/$links/CustomerForOrder",
"url": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(1)"
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<uri xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(1)</uri>

View File

@ -0,0 +1,48 @@
{
"@odata.context": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#Orders",
"value":
[
{
"@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Order",
"@odata.id": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(7)",
"@odata.editLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(7)",
"OrderID": 7,
"OrderDate@odata.type": "#DateTimeOffset",
"OrderDate": "2011-05-29T14:21:12Z",
"ShelfLife@odata.type": "#Duration",
"ShelfLife": "PT0.0000001S",
"OrderShelfLifes@odata.type": "#Collection(Duration)",
"OrderShelfLifes":
[
"PT0.0000001S"
],
"LoggedInEmployee@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(7)/LoggedInEmployee/$ref",
"LoggedInEmployee@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(7)/LoggedInEmployee",
"CustomerForOrder@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(7)/CustomerForOrder/$ref",
"CustomerForOrder@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(7)/CustomerForOrder",
"OrderDetails@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(7)/OrderDetails/$ref",
"OrderDetails@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(7)/OrderDetails"
},
{
"@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Order",
"@odata.id": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)",
"@odata.editLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)",
"OrderID": 8,
"OrderDate@odata.type": "#DateTimeOffset",
"OrderDate": "2011-03-04T16:03:57Z",
"ShelfLife@odata.type": "#Duration",
"ShelfLife": "PT0.0000001S",
"OrderShelfLifes@odata.type": "#Collection(Duration)",
"OrderShelfLifes":
[
"PT0.0000001S"
],
"LoggedInEmployee@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/LoggedInEmployee/$ref",
"LoggedInEmployee@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/LoggedInEmployee",
"CustomerForOrder@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/CustomerForOrder/$ref",
"CustomerForOrder@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/CustomerForOrder",
"OrderDetails@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/OrderDetails/$ref",
"OrderDetails@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/OrderDetails"
}
]
}

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<feed xml:base="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:context="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#Orders">
<id>http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders</id>
<title />
<updated>2014-03-24T17:17:25Z</updated>
<entry>
<id>http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(7)</id>
<category term="#Microsoft.Test.OData.Services.ODataWCFService.Order" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
<link rel="edit" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(7)" />
<link rel="http://docs.oasis-open.org/odata/ns/related/LoggedInEmployee" type="application/atom+xml;type=entry" title="LoggedInEmployee" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(7)/LoggedInEmployee" />
<link rel="http://docs.oasis-open.org/odata/ns/related/CustomerForOrder" type="application/atom+xml;type=entry" title="CustomerForOrder" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(7)/CustomerForOrder" />
<link rel="http://docs.oasis-open.org/odata/ns/related/OrderDetails" type="application/atom+xml;type=feed" title="OrderDetails" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(7)/OrderDetails" />
<title />
<updated>2014-03-24T17:17:25Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:OrderID m:type="Int32">7</d:OrderID>
<d:OrderDate m:type="DateTimeOffset">2011-05-29T14:21:12Z</d:OrderDate>
<d:ShelfLife m:type="Duration">PT0.0000001S</d:ShelfLife>
<d:OrderShelfLifes m:type="#Collection(Duration)">
<m:element>PT0.0000001S</m:element>
</d:OrderShelfLifes>
</m:properties>
</content>
</entry>
<entry>
<id>http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)</id>
<category term="#Microsoft.Test.OData.Services.ODataWCFService.Order" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
<link rel="edit" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)" />
<link rel="http://docs.oasis-open.org/odata/ns/related/LoggedInEmployee" type="application/atom+xml;type=entry" title="LoggedInEmployee" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/LoggedInEmployee" />
<link rel="http://docs.oasis-open.org/odata/ns/related/CustomerForOrder" type="application/atom+xml;type=entry" title="CustomerForOrder" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/CustomerForOrder" />
<link rel="http://docs.oasis-open.org/odata/ns/related/OrderDetails" type="application/atom+xml;type=feed" title="OrderDetails" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Orders(8)/OrderDetails" />
<title />
<updated>2014-03-24T17:17:25Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:OrderID m:type="Int32">8</d:OrderID>
<d:OrderDate m:type="DateTimeOffset">2011-03-04T16:03:57Z</d:OrderDate>
<d:ShelfLife m:type="Duration">PT0.0000001S</d:ShelfLife>
<d:OrderShelfLifes m:type="#Collection(Duration)">
<m:element>PT0.0000001S</m:element>
</d:OrderShelfLifes>
</m:properties>
</content>
</entry>
</feed>

View File

@ -0,0 +1,51 @@
{
"@odata.context": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#People/$entity",
"@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Person",
"@odata.id": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/People(5)",
"@odata.editLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/People(5)",
"PersonID": 5,
"FirstName": "Peter",
"LastName": "Bee",
"MiddleName": null,
"HomeAddress": null,
"Home@odata.type": "#GeographyPoint",
"Home":
{
"type": "Point",
"coordinates":
[
-261.8,
-16
],
"crs":
{
"type": "name",
"properties":
{
"name": "EPSG:4326"
}
}
},
"Numbers@odata.type": "#Collection(String)",
"Numbers":
[
"555-555-5555"
],
"Emails@odata.type": "#Collection(String)",
"Emails":
[
"def@test.msn"
],
"Parent@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/People(5)/Parent/$ref",
"Parent@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/People(5)/Parent",
"#Microsoft.Test.OData.Services.ODataWCFService.ResetAddress":
{
"title": "Microsoft.Test.OData.Services.ODataWCFService.ResetAddress",
"target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/People(5)/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress"
},
"#Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress":
{
"title": "Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress",
"target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/People(5)/Microsoft.Test.OData.Services.ODataWCFService.GetHomeAddress"
}
}

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<entry xml:base="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:context="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#People/$entity">
<id>http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/People(5)</id>
<category term="#Microsoft.Test.OData.Services.ODataWCFService.Person" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
<link rel="edit" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/People(5)" />
<link rel="http://docs.oasis-open.org/odata/ns/related/Parent" type="application/atom+xml;type=entry" title="Parent" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/People(5)/Parent" />
<title />
<updated>2014-03-24T17:20:17Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:PersonID m:type="Int32">5</d:PersonID>
<d:FirstName>Peter</d:FirstName>
<d:LastName>Bee</d:LastName>
<d:MiddleName m:null="true" />
<d:HomeAddress m:null="true" />
<d:Home m:type="GeographyPoint">
<gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
<gml:pos>-16 -261.8</gml:pos>
</gml:Point>
</d:Home>
<d:Numbers m:type="#Collection(String)">
<m:element>555-555-5555</m:element>
</d:Numbers>
<d:Emails m:type="#Collection(String)">
<m:element>def@test.msn</m:element>
</d:Emails>
<d:IsRegistered m:type="Boolean">true</d:IsRegistered>
<d:Height m:type="Decimal">179</d:Height>
<d:PDC m:type="Binary">fi653p3+MklA/LdoBlhWgnMTUUEo8tEgtbMXnF0a3CUNL9BZxXpSRiD9ebTnmNR0zWPjJVIDx4tdmCnq55XrJh+RW9aI/b34wAogK3kcORw=</d:PDC>
</m:properties>
</content>
</entry>

View File

@ -0,0 +1,19 @@
{
"@odata.context": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#ProductDetails/$entity",
"@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.ProductDetail",
"@odata.id": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/ProductDetails(ProductID=6,ProductDetailID=1)",
"@odata.editLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/ProductDetails(ProductID=6,ProductDetailID=1)",
"ProductID": 6,
"ProductDetailID": 1,
"ProductName": "Candy",
"Description": "sweet snack",
"RelatedProduct@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/ProductDetails(ProductID=6,ProductDetailID=1)/RelatedProduct/$ref",
"RelatedProduct@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/ProductDetails(ProductID=6,ProductDetailID=1)/RelatedProduct",
"Reviews@odata.associationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/ProductDetails(ProductID=6,ProductDetailID=1)/Reviews/$ref",
"Reviews@odata.navigationLink": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/ProductDetails(ProductID=6,ProductDetailID=1)/Reviews",
"#Microsoft.Test.OData.Services.ODataWCFService.GetRelatedProduct":
{
"title": "Microsoft.Test.OData.Services.ODataWCFService.GetRelatedProduct",
"target": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/ProductDetails(ProductID=6,ProductDetailID=1)/Microsoft.Test.OData.Services.ODataWCFService.GetRelatedProduct"
}
}

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<entry xml:base="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:context="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#ProductDetails/$entity">
<id>http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/ProductDetails(ProductID=6,ProductDetailID=1)</id>
<category term="#Microsoft.Test.OData.Services.ODataWCFService.ProductDetail" scheme="http://docs.oasis-open.org/odata/ns/scheme" />
<link rel="edit" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/ProductDetails(ProductID=6,ProductDetailID=1)" />
<link rel="http://docs.oasis-open.org/odata/ns/related/RelatedProduct" type="application/atom+xml;type=entry" title="RelatedProduct" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/ProductDetails(ProductID=6,ProductDetailID=1)/RelatedProduct" />
<link rel="http://docs.oasis-open.org/odata/ns/related/Reviews" type="application/atom+xml;type=feed" title="Reviews" href="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/ProductDetails(ProductID=6,ProductDetailID=1)/Reviews" />
<title />
<updated>2014-03-24T17:23:51Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:ProductID m:type="Int32">6</d:ProductID>
<d:ProductDetailID m:type="Int32">1</d:ProductDetailID>
<d:ProductName>Candy</d:ProductName>
<d:Description>sweet snack</d:Description>
</m:properties>
</content>
</entry>

View File

@ -0,0 +1,17 @@
{
"odata.error":
{
"code": "",
"message":
{
"lang": "en-US",
"value": "Bad request."
},
"innererror":
{
"message": "Bad request.",
"type": "Microsoft.Data.OData.BadRequest",
"stacktrace": " at Microsoft.Data.OData.MediaTypeUtils.GetContentTypeFromSettings...."
}
}
}

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code />
<m:message xml:lang="en-US">Bad request.</m:message>
<m:innererror>
<m:message>Bad request.</m:message>
<m:type>Microsoft.Data.OData.BadRequest</m:type>
<m:stacktrace> at Microsoft.Data.OData.MediaTypeUtils.GetContentTypeFromSettings...</m:stacktrace>
</m:innererror>
</m:error>

View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
<edmx:Reference Uri="http://localhost:${cargo.servlet.port}/StaticService/V40/NorthWindExt.svc">
<edmx:Include Namespace="NorthwindModel"/>
</edmx:Reference>
<edmx:DataServices>
<Schema Namespace="ODataWebExperimental.Northwind.Model" xmlns="http://docs.oasis-open.org/odata/ns/edm">
<EntityContainer Name="NorthwindEntities" p4:LazyLoadingEnabled="true" xmlns:p4="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
<EntitySet Name="Categories" EntityType="NorthwindModel.Category">
<NavigationPropertyBinding Path="Products" Target="Products" />
</EntitySet>
<EntitySet Name="CustomerDemographics" EntityType="NorthwindModel.CustomerDemographic">
<NavigationPropertyBinding Path="Customers" Target="Customers" />
</EntitySet>
<EntitySet Name="Customers" EntityType="NorthwindModel.Customer">
<NavigationPropertyBinding Path="CustomerDemographics" Target="CustomerDemographics" />
<NavigationPropertyBinding Path="Orders" Target="Orders" />
</EntitySet>
<EntitySet Name="Employees" EntityType="NorthwindModel.Employee">
<NavigationPropertyBinding Path="Employees1" Target="Employees" />
<NavigationPropertyBinding Path="Employee1" Target="Employees" />
<NavigationPropertyBinding Path="Orders" Target="Orders" />
<NavigationPropertyBinding Path="Territories" Target="Territories" />
</EntitySet>
<EntitySet Name="Order_Details" EntityType="NorthwindModel.Order_Detail">
<NavigationPropertyBinding Path="Order" Target="Orders" />
<NavigationPropertyBinding Path="Product" Target="Products" />
</EntitySet>
<EntitySet Name="Orders" EntityType="NorthwindModel.Order">
<NavigationPropertyBinding Path="Customer" Target="Customers" />
<NavigationPropertyBinding Path="Employee" Target="Employees" />
<NavigationPropertyBinding Path="Order_Details" Target="Order_Details" />
<NavigationPropertyBinding Path="Shipper" Target="Shippers" />
</EntitySet>
<EntitySet Name="Products" EntityType="NorthwindModel.Product">
<NavigationPropertyBinding Path="Category" Target="Categories" />
<NavigationPropertyBinding Path="Order_Details" Target="Order_Details" />
<NavigationPropertyBinding Path="Supplier" Target="Suppliers" />
</EntitySet>
<EntitySet Name="Regions" EntityType="NorthwindModel.Region">
<NavigationPropertyBinding Path="Territories" Target="Territories" />
</EntitySet>
<EntitySet Name="Shippers" EntityType="NorthwindModel.Shipper">
<NavigationPropertyBinding Path="Orders" Target="Orders" />
</EntitySet>
<EntitySet Name="Suppliers" EntityType="NorthwindModel.Supplier">
<NavigationPropertyBinding Path="Products" Target="Products" />
</EntitySet>
<EntitySet Name="Territories" EntityType="NorthwindModel.Territory">
<NavigationPropertyBinding Path="Employees" Target="Employees" />
<NavigationPropertyBinding Path="Region" Target="Regions" />
</EntitySet>
<EntitySet Name="Alphabetical_list_of_products" EntityType="NorthwindModel.Alphabetical_list_of_product" />
<EntitySet Name="Category_Sales_for_1997" EntityType="NorthwindModel.Category_Sales_for_1997" />
<EntitySet Name="Current_Product_Lists" EntityType="NorthwindModel.Current_Product_List" />
<EntitySet Name="Customer_and_Suppliers_by_Cities" EntityType="NorthwindModel.Customer_and_Suppliers_by_City" />
<EntitySet Name="Invoices" EntityType="NorthwindModel.Invoice" />
<EntitySet Name="Order_Details_Extendeds" EntityType="NorthwindModel.Order_Details_Extended" />
<EntitySet Name="Order_Subtotals" EntityType="NorthwindModel.Order_Subtotal" />
<EntitySet Name="Orders_Qries" EntityType="NorthwindModel.Orders_Qry" />
<EntitySet Name="Product_Sales_for_1997" EntityType="NorthwindModel.Product_Sales_for_1997" />
<EntitySet Name="Products_Above_Average_Prices" EntityType="NorthwindModel.Products_Above_Average_Price" />
<EntitySet Name="Products_by_Categories" EntityType="NorthwindModel.Products_by_Category" />
<EntitySet Name="Sales_by_Categories" EntityType="NorthwindModel.Sales_by_Category" />
<EntitySet Name="Sales_Totals_by_Amounts" EntityType="NorthwindModel.Sales_Totals_by_Amount" />
<EntitySet Name="Summary_of_Sales_by_Quarters" EntityType="NorthwindModel.Summary_of_Sales_by_Quarter" />
<EntitySet Name="Summary_of_Sales_by_Years" EntityType="NorthwindModel.Summary_of_Sales_by_Year" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>

View File

@ -0,0 +1,408 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
<edmx:DataServices>
<Schema Namespace="NorthwindModel" xmlns="http://docs.oasis-open.org/odata/ns/edm">
<EntityType Name="Category">
<Key>
<PropertyRef Name="CategoryID" />
</Key>
<Property Name="CategoryID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
<Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
<Property Name="Description" Type="Edm.String" MaxLength="max" />
<Property Name="Picture" Type="Edm.Binary" MaxLength="max" />
<NavigationProperty Name="Products" Type="Collection(NorthwindModel.Product)" Partner="Category" />
</EntityType>
<EntityType Name="CustomerDemographic">
<Key>
<PropertyRef Name="CustomerTypeID" />
</Key>
<Property Name="CustomerTypeID" Type="Edm.String" Nullable="false" MaxLength="10" />
<Property Name="CustomerDesc" Type="Edm.String" MaxLength="max" />
<NavigationProperty Name="Customers" Type="Collection(NorthwindModel.Customer)" Partner="CustomerDemographics" />
</EntityType>
<EntityType Name="Customer">
<Key>
<PropertyRef Name="CustomerID" />
</Key>
<Property Name="CustomerID" Type="Edm.String" Nullable="false" MaxLength="5" />
<Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
<Property Name="ContactName" Type="Edm.String" MaxLength="30" />
<Property Name="ContactTitle" Type="Edm.String" MaxLength="30" />
<Property Name="Address" Type="Edm.String" MaxLength="60" />
<Property Name="City" Type="Edm.String" MaxLength="15" />
<Property Name="Region" Type="Edm.String" MaxLength="15" />
<Property Name="PostalCode" Type="Edm.String" MaxLength="10" />
<Property Name="Country" Type="Edm.String" MaxLength="15" />
<Property Name="Phone" Type="Edm.String" MaxLength="24" />
<Property Name="Fax" Type="Edm.String" MaxLength="24" />
<NavigationProperty Name="Orders" Type="Collection(NorthwindModel.Order)" Partner="Customer" />
<NavigationProperty Name="CustomerDemographics" Type="Collection(NorthwindModel.CustomerDemographic)" Partner="Customers" />
</EntityType>
<EntityType Name="Employee">
<Key>
<PropertyRef Name="EmployeeID" />
</Key>
<Property Name="EmployeeID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
<Property Name="LastName" Type="Edm.String" Nullable="false" MaxLength="20" />
<Property Name="FirstName" Type="Edm.String" Nullable="false" MaxLength="10" />
<Property Name="Title" Type="Edm.String" MaxLength="30" />
<Property Name="TitleOfCourtesy" Type="Edm.String" MaxLength="25" />
<Property Name="BirthDate" Type="Edm.DateTimeOffset" />
<Property Name="HireDate" Type="Edm.DateTimeOffset" />
<Property Name="Address" Type="Edm.String" MaxLength="60" />
<Property Name="City" Type="Edm.String" MaxLength="15" />
<Property Name="Region" Type="Edm.String" MaxLength="15" />
<Property Name="PostalCode" Type="Edm.String" MaxLength="10" />
<Property Name="Country" Type="Edm.String" MaxLength="15" />
<Property Name="HomePhone" Type="Edm.String" MaxLength="24" />
<Property Name="Extension" Type="Edm.String" MaxLength="4" />
<Property Name="Photo" Type="Edm.Binary" MaxLength="max" />
<Property Name="Notes" Type="Edm.String" MaxLength="max" />
<Property Name="ReportsTo" Type="Edm.Int32" />
<Property Name="PhotoPath" Type="Edm.String" MaxLength="255" />
<NavigationProperty Name="Employees1" Type="Collection(NorthwindModel.Employee)" Partner="Employee1" />
<NavigationProperty Name="Employee1" Type="NorthwindModel.Employee" Partner="Employees1">
<ReferentialConstraint Property="ReportsTo" ReferencedProperty="EmployeeID" />
</NavigationProperty>
<NavigationProperty Name="Orders" Type="Collection(NorthwindModel.Order)" Partner="Employee" />
<NavigationProperty Name="Territories" Type="Collection(NorthwindModel.Territory)" Partner="Employees" />
</EntityType>
<EntityType Name="Order_Detail">
<Key>
<PropertyRef Name="OrderID" />
<PropertyRef Name="ProductID" />
</Key>
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
<Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
<Property Name="UnitPrice" Type="Edm.Decimal" Nullable="false" Precision="19" Scale="4" />
<Property Name="Quantity" Type="Edm.Int16" Nullable="false" />
<Property Name="Discount" Type="Edm.Single" Nullable="false" />
<NavigationProperty Name="Order" Type="NorthwindModel.Order" Nullable="false" Partner="Order_Details">
<ReferentialConstraint Property="OrderID" ReferencedProperty="OrderID" />
</NavigationProperty>
<NavigationProperty Name="Product" Type="NorthwindModel.Product" Nullable="false" Partner="Order_Details">
<ReferentialConstraint Property="ProductID" ReferencedProperty="ProductID" />
</NavigationProperty>
</EntityType>
<EntityType Name="Order">
<Key>
<PropertyRef Name="OrderID" />
</Key>
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
<Property Name="CustomerID" Type="Edm.String" MaxLength="5" />
<Property Name="EmployeeID" Type="Edm.Int32" />
<Property Name="OrderDate" Type="Edm.DateTimeOffset" />
<Property Name="RequiredDate" Type="Edm.DateTimeOffset" />
<Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
<Property Name="ShipVia" Type="Edm.Int32" />
<Property Name="Freight" Type="Edm.Decimal" Precision="19" Scale="4" />
<Property Name="ShipName" Type="Edm.String" MaxLength="40" />
<Property Name="ShipAddress" Type="Edm.String" MaxLength="60" />
<Property Name="ShipCity" Type="Edm.String" MaxLength="15" />
<Property Name="ShipRegion" Type="Edm.String" MaxLength="15" />
<Property Name="ShipPostalCode" Type="Edm.String" MaxLength="10" />
<Property Name="ShipCountry" Type="Edm.String" MaxLength="15" />
<NavigationProperty Name="Customer" Type="NorthwindModel.Customer" Partner="Orders">
<ReferentialConstraint Property="CustomerID" ReferencedProperty="CustomerID" />
</NavigationProperty>
<NavigationProperty Name="Employee" Type="NorthwindModel.Employee" Partner="Orders">
<ReferentialConstraint Property="EmployeeID" ReferencedProperty="EmployeeID" />
</NavigationProperty>
<NavigationProperty Name="Order_Details" Type="Collection(NorthwindModel.Order_Detail)" Partner="Order" />
<NavigationProperty Name="Shipper" Type="NorthwindModel.Shipper" Partner="Orders">
<ReferentialConstraint Property="ShipVia" ReferencedProperty="ShipperID" />
</NavigationProperty>
</EntityType>
<EntityType Name="Product">
<Key>
<PropertyRef Name="ProductID" />
</Key>
<Property Name="ProductID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
<Property Name="SupplierID" Type="Edm.Int32" />
<Property Name="CategoryID" Type="Edm.Int32" />
<Property Name="QuantityPerUnit" Type="Edm.String" MaxLength="20" />
<Property Name="UnitPrice" Type="Edm.Decimal" Precision="19" Scale="4" />
<Property Name="UnitsInStock" Type="Edm.Int16" />
<Property Name="UnitsOnOrder" Type="Edm.Int16" />
<Property Name="ReorderLevel" Type="Edm.Int16" />
<Property Name="Discontinued" Type="Edm.Boolean" Nullable="false" />
<NavigationProperty Name="Category" Type="NorthwindModel.Category" Partner="Products">
<ReferentialConstraint Property="CategoryID" ReferencedProperty="CategoryID" />
</NavigationProperty>
<NavigationProperty Name="Order_Details" Type="Collection(NorthwindModel.Order_Detail)" Partner="Product" />
<NavigationProperty Name="Supplier" Type="NorthwindModel.Supplier" Partner="Products">
<ReferentialConstraint Property="SupplierID" ReferencedProperty="SupplierID" />
</NavigationProperty>
</EntityType>
<EntityType Name="Region">
<Key>
<PropertyRef Name="RegionID" />
</Key>
<Property Name="RegionID" Type="Edm.Int32" Nullable="false" />
<Property Name="RegionDescription" Type="Edm.String" Nullable="false" MaxLength="50" />
<NavigationProperty Name="Territories" Type="Collection(NorthwindModel.Territory)" Partner="Region" />
</EntityType>
<EntityType Name="Shipper">
<Key>
<PropertyRef Name="ShipperID" />
</Key>
<Property Name="ShipperID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
<Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
<Property Name="Phone" Type="Edm.String" MaxLength="24" />
<NavigationProperty Name="Orders" Type="Collection(NorthwindModel.Order)" Partner="Shipper" />
</EntityType>
<EntityType Name="Supplier">
<Key>
<PropertyRef Name="SupplierID" />
</Key>
<Property Name="SupplierID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
<Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
<Property Name="ContactName" Type="Edm.String" MaxLength="30" />
<Property Name="ContactTitle" Type="Edm.String" MaxLength="30" />
<Property Name="Address" Type="Edm.String" MaxLength="60" />
<Property Name="City" Type="Edm.String" MaxLength="15" />
<Property Name="Region" Type="Edm.String" MaxLength="15" />
<Property Name="PostalCode" Type="Edm.String" MaxLength="10" />
<Property Name="Country" Type="Edm.String" MaxLength="15" />
<Property Name="Phone" Type="Edm.String" MaxLength="24" />
<Property Name="Fax" Type="Edm.String" MaxLength="24" />
<Property Name="HomePage" Type="Edm.String" MaxLength="max" />
<NavigationProperty Name="Products" Type="Collection(NorthwindModel.Product)" Partner="Supplier" />
</EntityType>
<EntityType Name="Territory">
<Key>
<PropertyRef Name="TerritoryID" />
</Key>
<Property Name="TerritoryID" Type="Edm.String" Nullable="false" MaxLength="20" />
<Property Name="TerritoryDescription" Type="Edm.String" Nullable="false" MaxLength="50" />
<Property Name="RegionID" Type="Edm.Int32" Nullable="false" />
<NavigationProperty Name="Region" Type="NorthwindModel.Region" Nullable="false" Partner="Territories">
<ReferentialConstraint Property="RegionID" ReferencedProperty="RegionID" />
</NavigationProperty>
<NavigationProperty Name="Employees" Type="Collection(NorthwindModel.Employee)" Partner="Territories" />
</EntityType>
<EntityType Name="Alphabetical_list_of_product">
<Key>
<PropertyRef Name="CategoryName" />
<PropertyRef Name="Discontinued" />
<PropertyRef Name="ProductID" />
<PropertyRef Name="ProductName" />
</Key>
<Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
<Property Name="SupplierID" Type="Edm.Int32" />
<Property Name="CategoryID" Type="Edm.Int32" />
<Property Name="QuantityPerUnit" Type="Edm.String" MaxLength="20" />
<Property Name="UnitPrice" Type="Edm.Decimal" Precision="19" Scale="4" />
<Property Name="UnitsInStock" Type="Edm.Int16" />
<Property Name="UnitsOnOrder" Type="Edm.Int16" />
<Property Name="ReorderLevel" Type="Edm.Int16" />
<Property Name="Discontinued" Type="Edm.Boolean" Nullable="false" />
<Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
</EntityType>
<EntityType Name="Category_Sales_for_1997">
<Key>
<PropertyRef Name="CategoryName" />
</Key>
<Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
<Property Name="CategorySales" Type="Edm.Decimal" Precision="19" Scale="4" />
</EntityType>
<EntityType Name="Current_Product_List">
<Key>
<PropertyRef Name="ProductID" />
<PropertyRef Name="ProductName" />
</Key>
<Property Name="ProductID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
</EntityType>
<EntityType Name="Customer_and_Suppliers_by_City">
<Key>
<PropertyRef Name="CompanyName" />
<PropertyRef Name="Relationship" />
</Key>
<Property Name="City" Type="Edm.String" MaxLength="15" />
<Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
<Property Name="ContactName" Type="Edm.String" MaxLength="30" />
<Property Name="Relationship" Type="Edm.String" Nullable="false" MaxLength="9" Unicode="false" />
</EntityType>
<EntityType Name="Invoice">
<Key>
<PropertyRef Name="CustomerName" />
<PropertyRef Name="Discount" />
<PropertyRef Name="OrderID" />
<PropertyRef Name="ProductID" />
<PropertyRef Name="ProductName" />
<PropertyRef Name="Quantity" />
<PropertyRef Name="Salesperson" />
<PropertyRef Name="ShipperName" />
<PropertyRef Name="UnitPrice" />
</Key>
<Property Name="ShipName" Type="Edm.String" MaxLength="40" />
<Property Name="ShipAddress" Type="Edm.String" MaxLength="60" />
<Property Name="ShipCity" Type="Edm.String" MaxLength="15" />
<Property Name="ShipRegion" Type="Edm.String" MaxLength="15" />
<Property Name="ShipPostalCode" Type="Edm.String" MaxLength="10" />
<Property Name="ShipCountry" Type="Edm.String" MaxLength="15" />
<Property Name="CustomerID" Type="Edm.String" MaxLength="5" />
<Property Name="CustomerName" Type="Edm.String" Nullable="false" MaxLength="40" />
<Property Name="Address" Type="Edm.String" MaxLength="60" />
<Property Name="City" Type="Edm.String" MaxLength="15" />
<Property Name="Region" Type="Edm.String" MaxLength="15" />
<Property Name="PostalCode" Type="Edm.String" MaxLength="10" />
<Property Name="Country" Type="Edm.String" MaxLength="15" />
<Property Name="Salesperson" Type="Edm.String" Nullable="false" MaxLength="31" />
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
<Property Name="OrderDate" Type="Edm.DateTimeOffset" />
<Property Name="RequiredDate" Type="Edm.DateTimeOffset" />
<Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
<Property Name="ShipperName" Type="Edm.String" Nullable="false" MaxLength="40" />
<Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
<Property Name="UnitPrice" Type="Edm.Decimal" Nullable="false" Precision="19" Scale="4" />
<Property Name="Quantity" Type="Edm.Int16" Nullable="false" />
<Property Name="Discount" Type="Edm.Single" Nullable="false" />
<Property Name="ExtendedPrice" Type="Edm.Decimal" Precision="19" Scale="4" />
<Property Name="Freight" Type="Edm.Decimal" Precision="19" Scale="4" />
</EntityType>
<EntityType Name="Order_Details_Extended">
<Key>
<PropertyRef Name="Discount" />
<PropertyRef Name="OrderID" />
<PropertyRef Name="ProductID" />
<PropertyRef Name="ProductName" />
<PropertyRef Name="Quantity" />
<PropertyRef Name="UnitPrice" />
</Key>
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
<Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
<Property Name="UnitPrice" Type="Edm.Decimal" Nullable="false" Precision="19" Scale="4" />
<Property Name="Quantity" Type="Edm.Int16" Nullable="false" />
<Property Name="Discount" Type="Edm.Single" Nullable="false" />
<Property Name="ExtendedPrice" Type="Edm.Decimal" Precision="19" Scale="4" />
</EntityType>
<EntityType Name="Order_Subtotal">
<Key>
<PropertyRef Name="OrderID" />
</Key>
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
<Property Name="Subtotal" Type="Edm.Decimal" Precision="19" Scale="4" />
</EntityType>
<EntityType Name="Orders_Qry">
<Key>
<PropertyRef Name="CompanyName" />
<PropertyRef Name="OrderID" />
</Key>
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
<Property Name="CustomerID" Type="Edm.String" MaxLength="5" />
<Property Name="EmployeeID" Type="Edm.Int32" />
<Property Name="OrderDate" Type="Edm.DateTimeOffset" />
<Property Name="RequiredDate" Type="Edm.DateTimeOffset" />
<Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
<Property Name="ShipVia" Type="Edm.Int32" />
<Property Name="Freight" Type="Edm.Decimal" Precision="19" Scale="4" />
<Property Name="ShipName" Type="Edm.String" MaxLength="40" />
<Property Name="ShipAddress" Type="Edm.String" MaxLength="60" />
<Property Name="ShipCity" Type="Edm.String" MaxLength="15" />
<Property Name="ShipRegion" Type="Edm.String" MaxLength="15" />
<Property Name="ShipPostalCode" Type="Edm.String" MaxLength="10" />
<Property Name="ShipCountry" Type="Edm.String" MaxLength="15" />
<Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
<Property Name="Address" Type="Edm.String" MaxLength="60" />
<Property Name="City" Type="Edm.String" MaxLength="15" />
<Property Name="Region" Type="Edm.String" MaxLength="15" />
<Property Name="PostalCode" Type="Edm.String" MaxLength="10" />
<Property Name="Country" Type="Edm.String" MaxLength="15" />
</EntityType>
<EntityType Name="Product_Sales_for_1997">
<Key>
<PropertyRef Name="CategoryName" />
<PropertyRef Name="ProductName" />
</Key>
<Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
<Property Name="ProductSales" Type="Edm.Decimal" Precision="19" Scale="4" />
</EntityType>
<EntityType Name="Products_Above_Average_Price">
<Key>
<PropertyRef Name="ProductName" />
</Key>
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
<Property Name="UnitPrice" Type="Edm.Decimal" Precision="19" Scale="4" />
</EntityType>
<EntityType Name="Products_by_Category">
<Key>
<PropertyRef Name="CategoryName" />
<PropertyRef Name="Discontinued" />
<PropertyRef Name="ProductName" />
</Key>
<Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
<Property Name="QuantityPerUnit" Type="Edm.String" MaxLength="20" />
<Property Name="UnitsInStock" Type="Edm.Int16" />
<Property Name="Discontinued" Type="Edm.Boolean" Nullable="false" />
</EntityType>
<EntityType Name="Sales_by_Category">
<Key>
<PropertyRef Name="CategoryID" />
<PropertyRef Name="CategoryName" />
<PropertyRef Name="ProductName" />
</Key>
<Property Name="CategoryID" Type="Edm.Int32" Nullable="false" />
<Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
<Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
<Property Name="ProductSales" Type="Edm.Decimal" Precision="19" Scale="4" />
</EntityType>
<EntityType Name="Sales_Totals_by_Amount">
<Key>
<PropertyRef Name="CompanyName" />
<PropertyRef Name="OrderID" />
</Key>
<Property Name="SaleAmount" Type="Edm.Decimal" Precision="19" Scale="4" />
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
<Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
<Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
</EntityType>
<EntityType Name="Summary_of_Sales_by_Quarter">
<Key>
<PropertyRef Name="OrderID" />
</Key>
<Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
<Property Name="Subtotal" Type="Edm.Decimal" Precision="19" Scale="4" />
</EntityType>
<EntityType Name="Summary_of_Sales_by_Year">
<Key>
<PropertyRef Name="OrderID" />
</Key>
<Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
<Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
<Property Name="Subtotal" Type="Edm.Decimal" Precision="19" Scale="4" />
</EntityType>
<Annotations Target="ODataWebExperimental.Northwind.Model.NorthwindEntities">
<Annotation Term="Com.Microsoft.OData.Service.Conventions.V1.UrlConventions" String="KeyAsSegment" />
</Annotations>
</Schema>
</edmx:DataServices>
</edmx:Edmx>

View File

@ -0,0 +1,11 @@
{
"odata.error":
{
"code": "",
"message":
{
"lang": "en-US",
"value": "Resource not found for the segment 'Customer'."
}
}
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code />
<m:message xml:lang="en-US">Resource not found for the segment 'Customer'.</m:message>
</m:error>

View File

@ -0,0 +1,4 @@
{
"@odata.context": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#$ref",
"@odata.id": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)"
}

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<m:ref m:context="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata#$ref" id="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/Customers(PersonID=1)" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" />

View File

@ -0,0 +1,126 @@
{
"@odata.context": "http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata",
"value":
[
{
"name": "People",
"kind": "EntitySet",
"url": "People"
},
{
"name": "Customers",
"kind": "EntitySet",
"url": "Customers"
},
{
"name": "Employees",
"kind": "EntitySet",
"url": "Employees"
},
{
"name": "Products",
"kind": "EntitySet",
"url": "Products"
},
{
"name": "ProductDetails",
"kind": "EntitySet",
"url": "ProductDetails"
},
{
"name": "ProductReviews",
"kind": "EntitySet",
"url": "ProductReviews"
},
{
"name": "Orders",
"kind": "EntitySet",
"url": "Orders"
},
{
"name": "OrderDetails",
"kind": "EntitySet",
"url": "OrderDetails"
},
{
"name": "Departments",
"kind": "EntitySet",
"url": "Departments"
},
{
"name": "Accounts",
"kind": "EntitySet",
"url": "Accounts"
},
{
"name": "StoredPIs",
"kind": "EntitySet",
"url": "StoredPIs"
},
{
"name": "SubscriptionTemplates",
"kind": "EntitySet",
"url": "SubscriptionTemplates"
},
{
"name": "Boss",
"kind": "Singleton",
"url": "Boss"
},
{
"name": "VipCustomer",
"kind": "Singleton",
"url": "VipCustomer"
},
{
"name": "Company",
"kind": "Singleton",
"url": "Company"
},
{
"name": "PublicCompany",
"kind": "Singleton",
"url": "PublicCompany"
},
{
"name": "LabourUnion",
"kind": "Singleton",
"url": "LabourUnion"
},
{
"name": "DefaultStoredPI",
"kind": "Singleton",
"url": "DefaultStoredPI"
},
{
"name": "GetDefaultColor",
"kind": "FunctionImport",
"url": "GetDefaultColor"
},
{
"name": "GetPerson",
"kind": "FunctionImport",
"url": "GetPerson"
},
{
"name": "GetPerson2",
"kind": "FunctionImport",
"url": "GetPerson2"
},
{
"name": "GetAllProducts",
"kind": "FunctionImport",
"url": "GetAllProducts"
},
{
"name": "GetBossEmails",
"kind": "FunctionImport",
"url": "GetBossEmails"
},
{
"name": "GetProductsByAccessLevel",
"kind": "FunctionImport",
"url": "GetProductsByAccessLevel"
}
]
}

View File

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<service xml:base="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/"
xmlns="http://www.w3.org/2007/app"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:m="http://docs.oasis-open.org/odata/ns/metadata"
m:context="http://localhost:${cargo.servlet.port}/StaticService/V40/Static.svc/$metadata">
<workspace>
<atom:title type="text">InMemoryEntities</atom:title>
<collection href="People">
<atom:title type="text">People</atom:title>
</collection>
<collection href="Customers">
<atom:title type="text">Customers</atom:title>
</collection>
<collection href="Employees">
<atom:title type="text">Employees</atom:title>
</collection>
<collection href="Products">
<atom:title type="text">Products</atom:title>
</collection>
<collection href="ProductDetails">
<atom:title type="text">ProductDetails</atom:title>
</collection>
<collection href="ProductReviews">
<atom:title type="text">ProductReviews</atom:title>
</collection>
<collection href="Orders">
<atom:title type="text">Orders</atom:title>
</collection>
<collection href="OrderDetails">
<atom:title type="text">OrderDetails</atom:title>
</collection>
<collection href="Departments">
<atom:title type="text">Departments</atom:title>
</collection>
<collection href="Accounts">
<atom:title type="text">Accounts</atom:title>
</collection>
<collection href="StoredPIs">
<atom:title type="text">StoredPIs</atom:title>
</collection>
<collection href="SubscriptionTemplates">
<atom:title type="text">SubscriptionTemplates</atom:title>
</collection>
<m:singleton href="Boss">
<atom:title type="text">Boss</atom:title>
</m:singleton>
<m:singleton href="VipCustomer">
<atom:title type="text">VipCustomer</atom:title>
</m:singleton>
<m:singleton href="Company">
<atom:title type="text">Company</atom:title>
</m:singleton>
<m:singleton href="PublicCompany">
<atom:title type="text">PublicCompany</atom:title>
</m:singleton>
<m:singleton href="LabourUnion">
<atom:title type="text">LabourUnion</atom:title>
</m:singleton>
<m:singleton href="DefaultStoredPI">
<atom:title type="text">DefaultStoredPI</atom:title>
</m:singleton>
<m:function-import href="GetDefaultColor">
<atom:title type="text">GetDefaultColor</atom:title>
</m:function-import>
<m:function-import href="GetPerson">
<atom:title type="text">GetPerson</atom:title>
</m:function-import>
<m:function-import href="GetPerson2">
<atom:title type="text">GetPerson2</atom:title>
</m:function-import>
<m:function-import href="GetAllProducts">
<atom:title type="text">GetAllProducts</atom:title>
</m:function-import>
<m:function-import href="GetBossEmails">
<atom:title type="text">GetBossEmails</atom:title>
</m:function-import>
<m:function-import href="GetProductsByAccessLevel">
<atom:title type="text">GetProductsByAccessLevel</atom:title>
</m:function-import>
</workspace>
</service>

View File

@ -0,0 +1,17 @@
{
"odata.error":
{
"code": "",
"message":
{
"lang": "en-US",
"value": "Unsupported media type requested."
},
"innererror":
{
"message": "Unsupported media type requested.",
"type": "Microsoft.Data.OData.ODataContentTypeException",
"stacktrace": " at Microsoft.Data.OData.MediaTypeUtils.GetContentTypeFromSettings(ODataMessageWriterSettings settings, ODataPayloadKind payloadKind, MediaTypeResolver mediaTypeResolver, MediaType&amp; mediaType, Encoding&amp; encoding)\n at Microsoft.Data.OData.ODataMessageWriter.EnsureODataFormatAndContentType()\n at Microsoft.Data.OData.ODataMessageWriter.SetHeaders(ODataPayloadKind payloadKind)\n at Microsoft.Data.OData.ODataUtils.SetHeadersForPayload(ODataMessageWriter messageWriter, ODataPayloadKind payloadKind)\n at System.Data.Services.ResponseContentTypeNegotiator.DetermineResponseFormat(ODataPayloadKind payloadKind, String acceptableMediaTypes, String acceptableCharSets)"
}
}
}

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code />
<m:message xml:lang="en-US">Unsupported media type requested.</m:message>
<m:innererror>
<m:message>A supported MIME type could not be found that matches the acceptable MIME types for the request. The supported type(s) 'application/atom+xml;type=feed, application/atom+xml, application/json;odata=minimalmetadata;streaming=true, application/json;odata=minimalmetadata;streaming=false, application/json;odata=minimalmetadata, application/json;odata=fullmetadata;streaming=true, application/json;odata=fullmetadata;streaming=false, application/json;odata=fullmetadata, application/json;odata=nometadata;streaming=true, application/json;odata=nometadata;streaming=false, application/json;odata=nometadata, application/json;streaming=true, application/json;streaming=false, application/json;odata=verbose, application/json' do not match any of the acceptable MIME types 'application/xml'.</m:message>
<m:type>Microsoft.Data.OData.ODataContentTypeException</m:type>
<m:stacktrace> at Microsoft.Data.OData.MediaTypeUtils.GetContentTypeFromSettings(ODataMessageWriterSettings settings, ODataPayloadKind payloadKind, MediaTypeResolver mediaTypeResolver, MediaType&amp; mediaType, Encoding&amp; encoding)&#xD;
at Microsoft.Data.OData.ODataMessageWriter.EnsureODataFormatAndContentType()&#xD;
at Microsoft.Data.OData.ODataMessageWriter.SetHeaders(ODataPayloadKind payloadKind)&#xD;
at Microsoft.Data.OData.ODataUtils.SetHeadersForPayload(ODataMessageWriter messageWriter, ODataPayloadKind payloadKind)&#xD;
at System.Data.Services.ResponseContentTypeNegotiator.DetermineResponseFormat(ODataPayloadKind payloadKind, String acceptableMediaTypes, String acceptableCharSets)</m:stacktrace>
</m:innererror>
</m:error>

View File

@ -39,8 +39,10 @@
<jaxrs:server id="services" address="/">
<jaxrs:serviceBeans>
<bean class="org.apache.olingo.fit.V4Services"/>
<bean class="org.apache.olingo.fit.V3Services"/>
<bean class="org.apache.olingo.fit.V4Services"/>
<bean class="org.apache.olingo.fit.V4NorthWind"/>
<bean class="org.apache.olingo.fit.V4NorthWindExt"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<bean class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider"/>

View File

@ -25,9 +25,7 @@ import org.apache.olingo.client.api.communication.request.invoke.CommonInvokeReq
import org.apache.olingo.client.api.communication.request.retrieve.CommonRetrieveRequestFactory;
import org.apache.olingo.client.api.communication.request.streamed.CommonStreamedRequestFactory;
import org.apache.olingo.client.api.op.ClientODataDeserializer;
import org.apache.olingo.commons.api.domain.ODataObjectFactory;
import org.apache.olingo.commons.api.domain.ODataGeospatialValue;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.CommonODataObjectFactory;
import org.apache.olingo.client.api.op.CommonODataBinder;
import org.apache.olingo.client.api.op.CommonODataReader;
import org.apache.olingo.commons.api.op.ODataSerializer;
@ -48,10 +46,6 @@ public interface CommonODataClient {
CommonFilterFactory getFilterFactory();
ODataPrimitiveValue.Builder getPrimitiveValueBuilder();
ODataGeospatialValue.Builder getGeospatialValueBuilder();
ODataSerializer getSerializer();
ClientODataDeserializer getDeserializer();
@ -62,7 +56,7 @@ public interface CommonODataClient {
CommonODataBinder getBinder();
ODataObjectFactory getObjectFactory();
CommonODataObjectFactory getObjectFactory();
CommonRetrieveRequestFactory getRetrieveRequestFactory();

View File

@ -18,11 +18,6 @@
*/
package org.apache.olingo.client.api.communication;
import java.io.IOException;
import java.io.StringReader;
import java.util.Collections;
import java.util.List;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.StatusLine;
import org.apache.olingo.commons.api.domain.ODataError;
@ -60,34 +55,10 @@ public class ODataClientErrorException extends RuntimeException {
*/
public ODataClientErrorException(final StatusLine statusLine, final ODataError error) {
super((StringUtils.isBlank(error.getCode()) ? StringUtils.EMPTY : "(" + error.getCode() + ") ")
+ error.getMessageValue() + " [" + statusLine.toString() + "]");
+ error.getMessage() + " [" + statusLine.toString() + "]");
this.statusLine = statusLine;
this.error = error;
if (this.error.getInnerErrorType() != null && this.error.getInnerErrorMessage() != null) {
final RuntimeException cause =
new RuntimeException(this.error.getInnerErrorType() + ": " + this.error.getInnerErrorMessage());
if (this.error.getInnerErrorStacktrace() != null) {
List<String> stLines;
try {
stLines = IOUtils.readLines(new StringReader(this.error.getInnerErrorStacktrace()));
} catch (IOException e) {
stLines = Collections.<String>emptyList();
}
StackTraceElement[] stElements = new StackTraceElement[stLines.size()];
for (int i = 0; i < stLines.size(); i++) {
final String stLine = stLines.get(i).substring(stLines.get(i).indexOf("at ") + 3);
final int lastDotPos = stLine.lastIndexOf('.');
stElements[i] = new StackTraceElement(
stLine.substring(0, lastDotPos), stLine.substring(lastDotPos + 1), null, 0);
}
cause.setStackTrace(stElements);
}
initCause(cause);
}
}
/**

View File

@ -18,6 +18,11 @@
*/
package org.apache.olingo.client.api.communication.header;
import java.util.Arrays;
import java.util.List;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
/**
* Major OData request/response header names.
*/
@ -26,7 +31,17 @@ public enum HeaderName {
/**
* The OData protocol uses the Accept request-header field, as specified in [RFC2616].
*/
accept("Accept"),
accept("Accept", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
/**
* As specified in [RFC2616], the client MAY specify the set of accepted character sets with the Accept-Charset
* header.
*/
acceptCharset("Accept-Charset", Arrays.asList(ODataServiceVersion.V40)),
/**
* As specified in [RFC2616], the client MAY specify the set of accepted natural languages with the Accept-Language
* header.
*/
acceptLanguage("Accept-Language", Arrays.asList(ODataServiceVersion.V40)),
/**
* The Content-Type header is used as specified in [RFC2616].
* <br/>
@ -44,76 +59,129 @@ public enum HeaderName {
* <li>multipart/mixed</li>
* </ul>
*/
contentType("Content-Type"),
contentType("Content-Type", Arrays.asList(ODataServiceVersion.V30)),
/**
* This header is a custom HTTP header defined for protocol versioning purposes. This header MAY be present on any
* request or response message.
*/
dataServiceVersion("DataServiceVersion"),
dataServiceVersion("DataServiceVersion", Arrays.asList(ODataServiceVersion.V30)),
/**
* This header is a custom HTTP header defined for protocol versioning purposes. This header MAY be present on any
* request or response message.
*/
odataVersion("OData-Version", Arrays.asList(ODataServiceVersion.V40)),
/**
* A response to a create operation that returns 204 No Content MUST include an OData-EntityId response header. The
* value of the header is the entity-id of the entity that was acted on by the request. The syntax of the
* OData-EntityId preference is specified in [OData-ABNF].
*/
odataEntityId("OData-EntityId", Arrays.asList(ODataServiceVersion.V40)),
/**
* An ETag (entity tag) is an HTTP response header returned by an HTTP/1.1 compliant web server used to determine
* change in content of a resource at a given URL. The value of the header is an opaque string representing the state
* of the resource at the time the response was generated.
*/
etag("ETag"),
etag("ETag", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
/**
* The If-Match request-header field is used with a method to make it conditional. As specified in [RFC2616], "the
* purpose of this feature is to allow efficient updates of cached information with a minimum amount of transaction
* overhead. It is also used, on updating requests, to prevent inadvertent modification of the wrong version of a
* resource".
*/
ifMatch("If-Match"),
ifMatch("If-Match", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
/**
* The If-None-Match request header is used with a method to make it conditional. As specified in [RFC2616], "The
* purpose of this feature is to allow efficient updates of cached information with a minimum amount of transaction
* overhead. It is also used to prevent a method (for example, PUT) from inadvertently modifying an existing resource
* when the client believes that the resource does not exist."
*/
ifNoneMatch("If-None-Match"),
ifNoneMatch("If-None-Match", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
/**
* Clients SHOULD specify an OData-MaxVersion request header.
* <br />
* If specified the service MUST generate a response with an OData-Version less than or equal to the specified
* OData-MaxVersion.
* <br />
* If OData-MaxVersion is not specified, then the service SHOULD interpret the request as having an OData-MaxVersion
* equal to the maximum version supported by the service.
*/
odataMaxVersion("OData-MaxVersion", Arrays.asList(ODataServiceVersion.V40)),
/**
* This header is a custom HTTP request only header defined for protocol versioning purposes. This header MAY be
* present on any request message from client to server.
*/
maxDataServiceVersion("MaxDataServiceVersion"),
maxDataServiceVersion("MaxDataServiceVersion", Arrays.asList(ODataServiceVersion.V30)),
/**
* This header is a custom HTTP request only header defined for protocol versioning purposes. This header MAY be
* present on any request message from client to server.
*/
minDataServiceVersion("MinDataServiceVersion"),
minDataServiceVersion("MinDataServiceVersion", Arrays.asList(ODataServiceVersion.V30)),
/**
* The OData-Isolation header specifies the isolation of the current request from external changes. The only supported
* value for this header is snapshot.
* <br />
* If the service doesnt support OData-Isolation:snapshot and this header was specified on the request, the service
* MUST NOT process the request and MUST respond with 412 Precondition Failed.
* <br />
* Snapshot isolation guarantees that all data returned for a request, including multiple requests within a batch or
* results retrieved across multiple pages, will be consistent as of a single point in time. Only data modifications
* made within the request (for example, by a data modification request within the same batch) are visible. The effect
* is as if the request generates a "snapshot" of the committed data as it existed at the start of the request.
* <br />
* The OData-Isolation header may be specified on a single or batch request. If it is specified on a batch then the
* value is applied to all statements within the batch.
* <br />
* Next links returned within a snapshot return results within the same snapshot as the initial request; the client is
* not required to repeat the header on each individual page request.
* <br />
* The OData-Isolation header has no effect on links other than the next link. Navigation links, read links, and edit
* links return the current version of the data.
* <br />
* A service returns 410 Gone or 404 Not Found if a consumer tries to follow a next link referring to a snapshot that
* is no longer available.
* <br />
* The syntax of the OData-Isolation header is specified in [OData-ABNF].
* <br />
* A service MAY specify the support for OData-Isolation:snapshot using an annotation with term
* Capabilities.IsolationSupport, see [OData-VocCap].
*/
odataIsolation("OData-Isolation", Arrays.asList(ODataServiceVersion.V40)),
/**
* A Prefer header is included in a request to state the clients preferred, but not required, server behavior (that
* is, a hint to the server). The Prefer header MAY be included on any request type (within a standalone or batch
* request), and a server MAY honor the header for HTTP POST, PUT, PATCH, and MERGE requests. A Prefer header with a
* value of return-content MUST NOT be specified on a DELETE request, a batch request as a whole, or a PUT request
* to update a named stream.
*
* @see ODataPreferenceNames.
*/
prefer("Prefer"),
prefer("Prefer", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
/**
* When a Prefer header value is successfully honored by the server, it MAY include a Preference-Applied response
* header that states which preference values were honored by the server.
*/
preferenceApplied("Preference-Applied"),
preferenceApplied("Preference-Applied", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
/**
* The DataServiceId response header is returned by the server when the response payload for an HTTP PUT, POST, PATCH,
* or MERGE request is empty. The value of the header is the identifier of the entity that was acted on by the PUT,
* POST, PATCH, or MERGE request. The identifier, in this case, is the same identifier that would have been returned
* in the response payload (for example, as the value of the atom:id element for Atom responses)
*/
dataServiceId("DataServiceId"),
dataServiceId("DataServiceId", Arrays.asList(ODataServiceVersion.V30)),
/**
* Location header is used to specify the URL of an entity modified through a Data Modification request, or the
* request URL to check on the status of an asynchronous operation as described in
* <code>202 Accepted</code>.
*/
location("Location"),
location("Location", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
/**
* A service must include a
* <code>Retry-After</code> header in a
* <code>202 Accepted</code>.
*/
retryAfter("Retry-After"),
dataServiceUrlConventions("DataServiceUrlConventions"),
slug("Slug"),
retryAfter("Retry-After", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
dataServiceUrlConventions("DataServiceUrlConventions", Arrays.asList(ODataServiceVersion.V30)),
slug("Slug", Arrays.asList(ODataServiceVersion.V30)),
/**
* This header is a custom HTTP request header.
* <br/>
@ -132,12 +200,21 @@ public enum HeaderName {
* <br/>
* This header is only valid when on POST requests.
*/
xHttpMethod("X-HTTP-METHOD");
xHttpMethod("X-HTTP-METHOD", Arrays.asList(ODataServiceVersion.V30));
private final String headerName;
private HeaderName(final String headerName) {
private final List<ODataServiceVersion> supportedVersions;
private HeaderName(final String headerName, final List<ODataServiceVersion> supportedVersions) {
this.headerName = headerName;
this.supportedVersions = supportedVersions;
}
final void isSupportedBy(final ODataServiceVersion serviceVersion) {
if (!supportedVersions.contains(serviceVersion)) {
throw new ODataRuntimeException("Unsupported header " + this.toString());
}
}
@Override

View File

@ -0,0 +1,424 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.api.communication.header;
import java.util.Arrays;
import java.util.List;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
/**
* Values of the Prefer header.
*/
public class ODataPreferences {
final ODataServiceVersion serviceVersion;
public ODataPreferences(final ODataServiceVersion serviceVersion) {
this.serviceVersion = serviceVersion;
}
/**
* <code>Prefer</code> header, return content.
*
* @see HeaderName#prefer
*/
public String returnContent() {
return PreferenceNames.returnContent.isSupportedBy(serviceVersion).toString();
}
/**
* <code>Prefer</code> header, return no content.
*
* @see HeaderName#prefer
*/
public String returnNoContent() {
return PreferenceNames.returnNoContent.isSupportedBy(serviceVersion).toString();
}
/**
* @see HeaderName#dataServiceUrlConventions
*/
public String keyAsSegment() {
return PreferenceNames.keyAsSegment.isSupportedBy(serviceVersion).toString();
}
/**
* The odata.allow-entityreferences preference indicates that the service is allowed to return entity references in
* place of entities that have previously been returned, with at least the properties requested, in the same response
* (for example, when serializing the expanded results of many-to-many relationships). The service MUST NOT return
* entity references in place of requested entities if odata.allow-entityreferences has not been specified in the
* request, unless explicitly defined by other rules in this document. The syntax of the odata.allow-entityreferences
* preference is specified in [OData-ABNF].
* <br />
* In the case the service applies the odata.allow-entityreferences preference it MUST include a Preference-Applied
* response header containing the odata.allow-entityreferences preference to indicate that entity references MAY be
* returned in place of entities that have previously been returned.
* <br/><br/>
* Supported by OData version 4.0 only.
*
* @see HeaderName#prefer
* @return preference.
*/
public String allowEntityReferences() {
return PreferenceNames.allowEntityReferences.isSupportedBy(serviceVersion).toString();
}
/**
* For scenarios in which links returned by the service are used by the client to poll for additional information, the
* client can specify the odata.callback preference to request that the service notify the client when data is
* available.
* <br />
* The odata.callback preference can be specified:
* <ul>
* <li>when requesting asynchronous processing of a request with the respond-async preference, or</li>
* <li>on a GET request to a delta link.</li>
* </ul>
* <br />
* The odata.callback preference MUST include the parameter url whose value is the URL of a callback endpoint to be
* invoked by the OData service when data is available. The syntax of the odata.callback preference is specified in
* [OData-ABNF]. For HTTP based callbacks, the OData service executes an HTTP GET request against the specified URL.
* <br />
* Services that support odata.callback SHOULD support notifying the client through HTTP. Services can advertise
* callback support using the Capabilities.CallbackSupport annotation term defined in [OData-VocCap].
* <br />
* If the service applies the odata.callback preference it MUST include the odata.callback preference in the
* Preference-Applied response header.
* <br />
* When the odata.callback preference is applied to asynchronous requests, the OData service invokes the callback
* endpoint once it has finished processing the request. The status monitor resource, returned in the Location header
* of the previously returned 202 Accepted response, can then be used to retrieve the results of the asynchronously
* executed request.
* <br />
* When the odata.callback preference is specified on a GET request to a delta link and there are no changes
* available, the OData service returns a 202 Accepted response with a Location header specifying the delta link to be
* used to check for future updates. The OData service then invokes the specified callback endpoint once new changes
* become available.
* <br />
* Combining respond-async, odata.callback and odata.track-changes preferences on a GET request to a delta-link might
* influence the response in a couple of ways.
* <ul>
* <li>If the service processes the request synchronously, and no updates are available, then the response is the same
* as if the respond-async hadnt been specified and results in a response as described above.</li>
* <li>If the service processes the request asynchronously, then it responds with a 202 Accepted response specifying
* the URL to the status monitor resource as it would have with any other asynchronous request. Once the service has
* finished processing the asynchronous request to the delta link resource, if changes are available it invokes the
* specified callback endpoint. If no changes are available, the service SHOULD wait to notify the client until
* changes are available. Once notified, the client uses the status monitor resource from the Location header of the
* previously returned 202 Accepted response to retrieve the results. In case no updates were available after
* processing the initial request, the result will contain no updates and the client can use the delta-link contained
* in the result to retrieve the updates that have since become available.</li>
* </ul>
* <br />
* If the consumer specifies the same URL as callback endpoint in multiple requests, the service MAY collate them into
* a single notification once additional data is available for any of the requests. However, the consumer MUST be
* prepared to deal with receiving up to as many notifications as it requested.
* <br /><br />
* Example: using a HTTP callback endpoint to receive notification
* <br /><br />
* Prefer: odata.callback; url="http://myserver/notfication/token/12345"
* <br/><br/>
* Supported by OData version 4.0 only.
*
* @see HeaderName#prefer
* @return preference.
*/
public String callback(final String url) {
return PreferenceNames.callback.isSupportedBy(serviceVersion).toString() + ";url=\"" + url + "\"";
}
/**
* The odata.continue-on-error preference on a batch request is used to request that, upon encountering a request
* within the batch that returns an error, the service return the error for that request and continue processing
* additional requests within the batch. The syntax of the odata.continue-on-error preference is specified in
* [OData-ABNF].
* <br />
* If not specified, upon encountering an error the service MUST return the error within the batch and stop processing
* additional requests within the batch.
* <br />
* A service MAY specify the support for the odata.continue-on-error preference using an annotation with term
* Capabilities.BatchContinueOnErrorSupported, see [OData-VocCap].
* <br/><br/>
* Supported by OData version 4.0 only.
*
* @see HeaderName#prefer
* @return preference.
*/
public String continueOnError() {
return PreferenceNames.callback.isSupportedBy(serviceVersion).toString();
}
/**
* The odata.include-annotations preference in a request for data or metadata is used to specify the set of
* annotations the client requests to be included, where applicable, in the response.
* <br/>
* The value of the odata.include-annotations preference is a comma-separated list of namespaces or namespace
* qualified term names to include or exclude, with "*" representing all. The full syntax of the
* odata.include-annotations preference is defined in [OData-ABNF].
* <br/>
* The most specific identifier always takes precedence. If the same identifier value is requested to both be excluded
* and included the behavior is undefined; the service MAY return or omit the specified vocabulary but MUST NOT raise
* an exception.
* <br/><br/>
* Example 1: a Prefer header requesting all annotations within a metadata document to be returned
* <br/><br/>
* Prefer: odata.include-annotations="*"
* <br/><br/>
* Example 2: a Prefer header requesting that no annotations are returned
* <br/><br/>
* Prefer: odata.include-annotations="-*"
* <br/><br/>
* Example 3: a Prefer header requesting that all annotations defined under the "display" namespace (recursively) be
* returned
* <br/><br/>
* Prefer: odata.include-annotations="display.*"
* <br/><br/>
* Example 4: a Prefer header requesting that the annotation with the term name subject within the display namespace
* be returned if applied
* <br/><br/>
* Prefer: odata.include-annotations="display.subject"
* <br/><br/>
* The odata.include-annotations preference is only a hint to the service. The service MAY ignore the preference and
* is free to decide whether or not to return annotations not specified in the odata.include-annotations preference.
* <br/>
* In the case that the client has specified the odata.include-annotations preference in the request, the service
* SHOULD include a Preference-Applied response header containing the odata.include-annotations preference to specify
* the annotations actually included, where applicable, in the response. This value may differ from the annotations
* requested in the Prefer header of the request.
* <br/><br/>
* Supported by OData version 4.0 only.
*
* @see HeaderName#prefer
* @return preference.
*/
public String includeAnnotations(final String value) {
return PreferenceNames.includeAnnotations.isSupportedBy(serviceVersion).toString() + "=" + value;
}
/**
* The odata.maxpagesize preference is used to request that each collection within the response contain no more than
* the number of items specified as the positive integer value of this preference. The syntax of the odata.maxpagesize
* preference is specified in [OData-ABNF].
* <br/><br/>
* Example: a request for customers and their orders would result in a response containing one collection with
* customer entities and for every customer a separate collection with order entities. The client could specify
* <br/>
* odata.maxpagesize=50
* <br/>in order to request that each page of results contain a maximum of 50 customers, each with a maximum of 50
* orders.
* <br/><br/>
* If a collection within the result contains more than the specified odata.maxpagesize, the collection SHOULD be a
* partial set of the results with a next link to the next page of results. The client MAY specify a different value
* for this preference with every request following a next link.
* <br/>
* In the example given above, the result page should include a next link for the customer collection, if there are
* more than 50 customers, and additional next links for all returned orders collections with more than 50 entities.
* <br/>
* If the client has specified the odata.maxpagesize preference in the request, and the service limits the number of
* items in collections within the response through server-driven paging, the service MAY include a Preference-Applied
* response header containing the odata.maxpagesize preference and the maximum page size applied. This value may
* differ from the value requested by the client.
* <br/><br/>
* Supported by OData version 4.0 only.
*
* @see HeaderName#prefer
* @return preference.
*/
public String maxPageSize(final int size) {
return PreferenceNames.maxPageSize.isSupportedBy(serviceVersion).toString() + "=" + size;
}
/**
* The odata.track-changes preference is used to request that the service return a delta link that can subsequently be
* used to obtain changes (deltas) to this result. The syntax of the odata.track-changes preference is specified in
* [OData-ABNF].
* <br />
* For paged results, the preference MUST be specified on the initial request. Services MUST ignore the
* odata.track-changes preference if applied to the next link.
* <br />
* The delta link MUST NOT be returned prior to the final page of results.
* <br />
* The service includes a Preference-Applied response header in the first page of the response containing the
* odata.track-changes preference to signal that changes are being tracked.
* <br />
* A service MAY specify the support for the odata.track-changes preference using an annotation with term
* Capabilities.ChangeTrackingSupport, see [OData-VocCap].
* <br/><br/>
* Supported by OData version 4.0 only.
*
* @see HeaderName#prefer
* @return preference.
*/
public String trackChanges() {
return PreferenceNames.trackChanges.isSupportedBy(serviceVersion).toString();
}
/**
* The respond-async preference, as defined in [HTTP-Prefer], allows clients to request that the service process the
* request asynchronously.
* <br/>
* If the client has specified respond-async in the request, the service MAY process the request asynchronously and
* return a 202 Accepted response.
* <br/>
* The respond-async preference MAY be used for batch requests, but the service MUST ignore the respond-async
* preference for individual requests within a batch request.
* <br/>
* In the case that the service applies the respond-async preference it MUST include a Preference-Applied response
* header containing the respond-async preference.
* <br/>
* A service MAY specify the support for the respond-async preference using an annotation with term
* Capabilities.AsynchronousRequestsSupported, see [OData-VocCap].
* <br/><br/>
* Example: a service receiving the following header might choose to respond
* <ul>
* <li>asynchronously if the synchronous processing of the request will take longer than 10 seconds</li>
* <li>synchronously after 5 seconds</li>
* <li>asynchronously (ignoring the wait preference)</li>
* <li>synchronously after 15 seconds (ignoring respond-async preference and the wait preference)</li>
* </ul>
* <br/>
* Prefer: respond-async, wait=10
* <br/><br/>
* Supported by OData version 4.0 only.
*
* @see HeaderName#prefer
* @return preference.
*/
public String respondAsync() {
return PreferenceNames.respondAsync.isSupportedBy(serviceVersion).toString();
}
/**
* The wait preference, as defined in [HTTP-Prefer], is used to establish an upper bound on the length of time, in
* seconds, the client is prepared to wait for the service to process the request synchronously once it has been
* received.
* <br/>
* If the respond-async preference is also specified, the client requests that the service respond asynchronously
* after the specified length of time.
* <br/>
* If the respond-async preference has not been specified, the service MAY interpret the wait as a request to timeout
* after the specified period of time.
* <br/><br/>
* Supported by OData version 4.0 only.
*
* @see HeaderName#prefer
* @return preference.
*/
public String wait(final int value) {
return PreferenceNames.wait.isSupportedBy(serviceVersion).toString() + "=" + value;
}
/**
* The return=representation and return=minimal preferences are defined in [HTTP-Prefer],
* <br/>
* In OData, return=representation or return=minimal is defined for use with a POST, PUT, or PATCH Data Modification
* Request other than to a stream property, or to an Action Request. Specifying a preference of return=representation
* or return=minimal in a GET or DELETE request, or any request to a stream property, SHOULD return a 4xx Client
* Error.
* <br/>
* A preference of return=representation or return=minimal is allowed on an individual Data Modification Request or
* Action Request within a batch, subject to the same restrictions, but SHOULD return a 4xx Client Error if specified
* on the batch request itself.
* <br/>
* A preference of return=minimal requests that the service invoke the request but does not return content in the
* response. The service MAY apply this preference by returning 204 No Content in which case it MAY include a
* Preference-Applied response header containing the return=minimal preference.
* <br/>
* A preference of return=representation requests that the service invokes the request and returns the modified
* entity. The service MAY apply this preference by returning the successfully modified resource in the body of the
* response, formatted according to the rules specified for the requested format. In this case the service MAY include
* a Preference-Applied response header containing the return=representation preference.
* <br/><br/>
* Supported by OData version 4.0 only.
*
* @see HeaderName#prefer
* @return preference.
*/
public String returnMinimal() {
return PreferenceNames.odataReturn.isSupportedBy(serviceVersion).toString() + "=minimal";
}
/**
* The return=representation and return=minimal preferences are defined in [HTTP-Prefer],
* <br/>
* In OData, return=representation or return=minimal is defined for use with a POST, PUT, or PATCH Data Modification
* Request other than to a stream property, or to an Action Request. Specifying a preference of return=representation
* or return=minimal in a GET or DELETE request, or any request to a stream property, SHOULD return a 4xx Client
* Error.
* <br/>
* A preference of return=representation or return=minimal is allowed on an individual Data Modification Request or
* Action Request within a batch, subject to the same restrictions, but SHOULD return a 4xx Client Error if specified
* on the batch request itself.
* <br/>
* A preference of return=minimal requests that the service invoke the request but does not return content in the
* response. The service MAY apply this preference by returning 204 No Content in which case it MAY include a
* Preference-Applied response header containing the return=minimal preference.
* <br/>
* A preference of return=representation requests that the service invokes the request and returns the modified
* entity. The service MAY apply this preference by returning the successfully modified resource in the body of the
* response, formatted according to the rules specified for the requested format. In this case the service MAY include
* a Preference-Applied response header containing the return=representation preference.
* <br/><br/>
* Supported by OData version 4.0 only.
*
* @see HeaderName#prefer
* @return preference.
*/
public String returnRepresentation() {
return PreferenceNames.odataReturn.isSupportedBy(serviceVersion).toString() + "=representation";
}
private static enum PreferenceNames {
returnContent("return-content", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
returnNoContent("return-no-content", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
keyAsSegment("KeyAsSegment", Arrays.asList(ODataServiceVersion.V30, ODataServiceVersion.V40)),
allowEntityReferences("odata.allow-entityreferences", Arrays.asList(ODataServiceVersion.V40)),
callback("odata.callback", Arrays.asList(ODataServiceVersion.V40)),
continueOnError("odata.continue-on-error", Arrays.asList(ODataServiceVersion.V40)),
includeAnnotations("odata.include-annotations", Arrays.asList(ODataServiceVersion.V40)),
maxPageSize("odata.maxpagesize", Arrays.asList(ODataServiceVersion.V40)),
trackChanges("odata.track-changes", Arrays.asList(ODataServiceVersion.V40)),
respondAsync("respond-async", Arrays.asList(ODataServiceVersion.V40)),
wait("wait", Arrays.asList(ODataServiceVersion.V40)),
odataReturn("return", Arrays.asList(ODataServiceVersion.V40));
private final String preferenceName;
private final List<ODataServiceVersion> supportedVersions;
private PreferenceNames(final String preferenceName, final List<ODataServiceVersion> supportedVersions) {
this.preferenceName = preferenceName;
this.supportedVersions = supportedVersions;
}
final PreferenceNames isSupportedBy(final ODataServiceVersion serviceVersion) {
if (!supportedVersions.contains(serviceVersion)) {
throw new ODataRuntimeException("Unsupported header " + this.toString());
}
return this;
}
@Override
public String toString() {
return preferenceName;
}
}
}

View File

@ -21,16 +21,20 @@ package org.apache.olingo.client.api.communication.request;
import java.io.InputStream;
import java.net.URI;
import java.util.Collection;
import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.http.HttpMethod;
/**
* Abstract representation of an OData request. Get instance by using factories.
*
* @see CUDRequestFactory
* @see RetrieveRequestFactory
* @see BatchRequestFactory
* @see InvokeRequestFactory
* @see StreamedRequestFactory
* @see org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory
* @see org.apache.olingo.client.api.communication.request.cud.v4.CUDRequestFactory
* @see org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory
* @see org.apache.olingo.client.api.communication.request.batch.v4.BatchRequestFactory
* @see org.apache.olingo.client.api.communication.request.invoke.v3.InvokeRequestFactory
* @see org.apache.olingo.client.api.communication.request.invoke.v4.InvokeRequestFactory
* @see org.apache.olingo.client.api.communication.request.streamed.v3.StreamedRequestFactory
* @see org.apache.olingo.client.api.communication.request.streamed.v4.StreamedRequestFactory
*/
public interface ODataRequest {
@ -175,6 +179,16 @@ public interface ODataRequest {
*/
ODataRequest addCustomHeader(final String name, final String value);
/**
* Adds a custom OData request header. The method fails in case of the header name is not supported by the current
* working version.
*
* @param name header name.
* @param value header value.
* @return current object
*/
ODataRequest addCustomHeader(final HeaderName name, final String value);
/**
* Gets byte array representation of the full request header.
*

View File

@ -20,11 +20,10 @@ package org.apache.olingo.client.api.communication.request.cud;
import java.io.Serializable;
import java.net.URI;
import org.apache.olingo.client.api.communication.request.UpdateType;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
/**
* OData request factory class.
@ -36,21 +35,24 @@ public interface CommonCUDRequestFactory extends Serializable {
* <br/>
* Use this kind of request to create a new entity.
*
* @param <E> concrete ODataEntity implementation
* @param targetURI entity set URI.
* @param entity entity to be created.
* @return new ODataEntityCreateRequest instance.
*/
ODataEntityCreateRequest getEntityCreateRequest(URI targetURI, ODataEntity entity);
<E extends CommonODataEntity> ODataEntityCreateRequest<E> getEntityCreateRequest(URI targetURI, E entity);
/**
* Gets an update request object instance.
*
* @param <UT> concrete UpdateType.
* @param targetURI edit link of the object to be updated.
* @param type type of update to be performed.
* @param changes changes to be applied.
* @return new ODataEntityUpdateRequest instance.
*/
ODataEntityUpdateRequest getEntityUpdateRequest(URI targetURI, UpdateType type, ODataEntity changes);
<UT extends UpdateType> ODataEntityUpdateRequest getEntityUpdateRequest(URI targetURI, UT type,
CommonODataEntity changes);
/**
* Gets an update request object instance; uses entity's edit link as endpoint.
@ -59,7 +61,7 @@ public interface CommonCUDRequestFactory extends Serializable {
* @param entity changes to be applied.
* @return new ODataEntityUpdateRequest instance.
*/
ODataEntityUpdateRequest getEntityUpdateRequest(UpdateType type, ODataEntity entity);
ODataEntityUpdateRequest getEntityUpdateRequest(UpdateType type, CommonODataEntity entity);
/**
* Gets a create request object instance.
@ -82,7 +84,7 @@ public interface CommonCUDRequestFactory extends Serializable {
* @param property value to be update.
* @return new ODataPropertyUpdateRequest instance.
*/
ODataPropertyUpdateRequest getPropertyPrimitiveValueUpdateRequest(URI targetURI, ODataProperty property);
ODataPropertyUpdateRequest getPropertyPrimitiveValueUpdateRequest(URI targetURI, CommonODataProperty property);
/**
* Gets an update request object instance.
@ -95,7 +97,7 @@ public interface CommonCUDRequestFactory extends Serializable {
* @return new ODataPropertyUpdateRequest instance.
*/
ODataPropertyUpdateRequest getPropertyComplexValueUpdateRequest(
URI targetURI, UpdateType type, ODataProperty property);
URI targetURI, UpdateType type, CommonODataProperty property);
/**
* Gets an update request object instance.
@ -106,7 +108,7 @@ public interface CommonCUDRequestFactory extends Serializable {
* @param property value to be update.
* @return new ODataPropertyUpdateRequest instance.
*/
ODataPropertyUpdateRequest getPropertyCollectionValueUpdateRequest(URI targetURI, ODataProperty property);
ODataPropertyUpdateRequest getPropertyCollectionValueUpdateRequest(URI targetURI, CommonODataProperty property);
/**
* Gets an add link request object instance.

View File

@ -20,10 +20,14 @@ package org.apache.olingo.client.api.communication.request.cud;
import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
* This class implements an OData create request.
* This interface describes an OData create request.
*
* @param <E> concrete ODataEntity implementation
*/
public interface ODataEntityCreateRequest extends ODataBasicRequest<ODataEntityCreateResponse, ODataPubFormat>{
public interface ODataEntityCreateRequest<E extends CommonODataEntity>
extends ODataBasicRequest<ODataEntityCreateResponse<E>, ODataPubFormat> {
}

View File

@ -16,19 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.commons.api.edm;
package org.apache.olingo.client.api.communication.request.cud;
import org.apache.olingo.commons.api.edm.geo.Geospatial;
import org.apache.olingo.client.api.http.HttpMethod;
public interface EdmGeospatialType extends EdmType {
String EDM_NAMESPACE = EdmPrimitiveType.EDM_NAMESPACE;
public interface UpdateType {
/**
* Returns the Java type for this EDM geospatial type.
* Gets HTTP request method.
*
* @return the geospatial Java type
* @return HTTP request method.
*/
Class<? extends Geospatial> getJavaType();
HttpMethod getMethod();
}

View File

@ -16,14 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.api.communication.request;
package org.apache.olingo.client.api.communication.request.cud.v3;
import org.apache.olingo.client.api.http.HttpMethod;
/**
* Update type.
*/
public enum UpdateType {
public enum UpdateType implements org.apache.olingo.client.api.communication.request.cud.UpdateType {
/**
* Replace all and remove missing attributes.
@ -49,6 +49,7 @@ public enum UpdateType {
*
* @return HTTP request method.
*/
@Override
public HttpMethod getMethod() {
return method;
}

View File

@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.api.communication.request.cud.v4;
import org.apache.olingo.client.api.http.HttpMethod;
/**
* Update type.
*/
public enum UpdateType implements org.apache.olingo.client.api.communication.request.cud.UpdateType {
/**
* Replace all and remove missing attributes.
*/
REPLACE(HttpMethod.PUT),
/**
* Differential update with only specified input property values to be replaced.
*/
PATCH(HttpMethod.PATCH);
private final HttpMethod method;
private UpdateType(final HttpMethod method) {
this.method = method;
}
/**
* Gets HTTP request method.
*
* @return HTTP request method.
*/
@Override
public HttpMethod getMethod() {
return method;
}
}

View File

@ -20,6 +20,9 @@ package org.apache.olingo.client.api.communication.request.retrieve;
import java.io.Serializable;
import java.net.URI;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
/**
* OData request factory class.
@ -27,79 +30,97 @@ import java.net.URI;
public interface CommonRetrieveRequestFactory extends Serializable {
/**
* Gets a service document request instance.
* Gets a metadata request instance.
* <br/>
* Compared to {@link #getMetadataRequest(java.lang.String)}, this method returns a request instance for fetching
* low-level metadata representation.
*
* @param serviceRoot absolute URL (schema, host and port included) representing the location of the root of the data
* service.
* @return new ODataServiceDocumentRequest instance.
* @return new {@link XMLMetadataRequest} instance.
*/
ODataServiceDocumentRequest getServiceDocumentRequest(String serviceRoot);
XMLMetadataRequest getXMLMetadataRequest(String serviceRoot);
/**
* Gets a metadata request instance.
*
* @param serviceRoot absolute URL (schema, host and port included) representing the location of the root of the data
* service.
* @return new ODataMetadataRequest instance.
* @return new {@link EdmMetadataRequest} instance.
*/
ODataMetadataRequest getMetadataRequest(String serviceRoot);
EdmMetadataRequest getMetadataRequest(String serviceRoot);
/**
* Gets a query request returning a set of one or more OData entities.
* Gets a service document request instance.
*
* @param query query to be performed.
* @return new ODataEntitySetRequest instance.
* @param serviceRoot absolute URL (schema, host and port included) representing the location of the root of the data
* service.
* @return new {@link ODataServiceDocumentRequest} instance.
*/
ODataEntitySetRequest getEntitySetRequest(URI query);
ODataServiceDocumentRequest getServiceDocumentRequest(String serviceRoot);
/**
* Gets a query request returning a set of one or more OData entities.
* Gets a uri request returning a set of one or more OData entities.
*
* @param <T> concrete ODataEntitySet implementation.
* @param uri request URI.
* @return new {@link ODataEntitySetRequest} instance.
*/
<T extends CommonODataEntitySet> ODataEntitySetRequest<T> getEntitySetRequest(URI uri);
/**
* Gets a uri request returning a set of one or more OData entities.
* <br/>
* Returned request gives the possibility to consume entities iterating on them without parsing and loading in memory
* the entire entity set.
*
* @param query query to be performed.
* @return new ODataEntitySetIteratorRequest instance.
* @param <ES> concreate ODataEntitySet implementation.
* @param <E> concrete ODataEntity implementation.
* @param uri request URI.
* @return new {@link ODataEntitySetIteratorRequest} instance.
*/
ODataEntitySetIteratorRequest getEntitySetIteratorRequest(URI query);
<ES extends CommonODataEntitySet, E extends CommonODataEntity>
ODataEntitySetIteratorRequest<ES, E> getEntitySetIteratorRequest(URI uri);
/**
* Gets a query request returning a single OData entity.
* Gets a uri request returning a single OData entity.
*
* @param query query to be performed.
* @return new ODataEntityRequest instance.
* @param <T> concrete ODataEntity implementation.
* @param uri request URI.
* @return new {@link ODataEntityRequest} instance.
*/
ODataEntityRequest getEntityRequest(URI query);
<T extends CommonODataEntity> ODataEntityRequest<T> getEntityRequest(URI uri);
/**
* Gets a query request returning a single OData entity property.
* Gets a uri request returning a single OData entity property.
*
* @param query query to be performed.
* @return new ODataPropertyRequest instance.
* @param <T> concrete ODataProperty implementation.
* @param uri request URI.
* @return new {@link ODataPropertyRequest} instance.
*/
ODataPropertyRequest getPropertyRequest(URI query);
<T extends CommonODataProperty> ODataPropertyRequest<T> getPropertyRequest(URI uri);
/**
* Gets a query request returning a single OData entity property value.
* Gets a uri request returning a single OData entity property value.
*
* @param query query to be performed.
* @return new ODataValueRequest instance.
* @param uri request URI.
* @return new {@link ODataValueRequest} instance.
*/
ODataValueRequest getValueRequest(URI query);
ODataValueRequest getValueRequest(URI uri);
/**
* Gets a query request returning a media stream.
* Gets a uri request returning a media stream.
*
* @param query query to be performed.
* @return new ODataMediaRequest instance.
* @param uri request URI.
* @return new {@link ODataMediaRequest} instance.
*/
ODataMediaRequest getMediaRequest(URI query);
ODataMediaRequest getMediaRequest(URI uri);
/**
* Implements a raw request request without specifying any return type.
*
* @param uri query to be performed.
* @return new ODataRawRequest instance.
* @param uri request URI.
* @return new {@link ODataRawRequest} instance.
*/
ODataRawRequest getRawRequest(URI uri);
}

View File

@ -18,11 +18,11 @@
*/
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements a metadata query request.
*/
public interface ODataMetadataRequest extends ODataRetrieveRequest<Edm, ODataPubFormat> {
public interface EdmMetadataRequest extends ODataRetrieveRequest<Edm, ODataFormat> {
}

View File

@ -18,11 +18,11 @@
*/
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
* This class implements an OData retrieve query request returning a single entity.
*/
public interface ODataEntityRequest extends ODataRetrieveRequest<ODataEntity, ODataPubFormat> {
public interface ODataEntityRequest<T extends CommonODataEntity> extends ODataRetrieveRequest<T, ODataPubFormat> {
}

View File

@ -19,10 +19,13 @@
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.client.api.domain.ODataEntitySetIterator;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
* This class implements an OData EntitySet query request.
*/
public interface ODataEntitySetIteratorRequest extends ODataRetrieveRequest<ODataEntitySetIterator, ODataPubFormat> {
public interface ODataEntitySetIteratorRequest<ES extends CommonODataEntitySet, E extends CommonODataEntity>
extends ODataRetrieveRequest<ODataEntitySetIterator<ES, E>, ODataPubFormat> {
}

View File

@ -18,11 +18,14 @@
*/
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.format.ODataPubFormat;
/**
* This class implements an OData EntitySet query request.
* This interface describes an OData EntitySet query request.
*
* @param <ES> concrete ODataEntitySet implementation
*/
public interface ODataEntitySetRequest extends ODataRetrieveRequest<ODataEntitySet, ODataPubFormat> {
public interface ODataEntitySetRequest<ES extends CommonODataEntitySet>
extends ODataRetrieveRequest<ES, ODataPubFormat> {
}

View File

@ -18,11 +18,11 @@
*/
package org.apache.olingo.client.api.communication.request.retrieve;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements an OData entity property query request.
*/
public interface ODataPropertyRequest extends ODataRetrieveRequest<ODataProperty, ODataFormat> {
public interface ODataPropertyRequest<T extends CommonODataProperty> extends ODataRetrieveRequest<T, ODataFormat> {
}

View File

@ -0,0 +1,29 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.olingo.client.api.communication.request.retrieve;
import java.util.List;
import org.apache.olingo.client.api.edm.xml.Schema;
import org.apache.olingo.commons.api.format.ODataFormat;
/**
* This class implements an XML metadata request.
*/
public interface XMLMetadataRequest extends ODataRetrieveRequest<List<? extends Schema>, ODataFormat> {
}

View File

@ -20,11 +20,31 @@ package org.apache.olingo.client.api.communication.request.retrieve.v3;
import java.net.URI;
import org.apache.olingo.client.api.communication.request.retrieve.CommonRetrieveRequestFactory;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetIteratorRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
@SuppressWarnings("unchecked")
public interface RetrieveRequestFactory extends CommonRetrieveRequestFactory {
@Override
ODataEntitySetRequest<ODataEntitySet> getEntitySetRequest(URI uri);
@Override
ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> getEntitySetIteratorRequest(URI uri);
@Override
ODataEntityRequest<ODataEntity> getEntityRequest(URI uri);
@Override
ODataPropertyRequest<ODataProperty> getPropertyRequest(URI uri);
/**
* Gets a query request returning a single OData link.
* Gets a uri request returning a single OData link.
*
* @param targetURI target URI.
* @param linkName link name.

View File

@ -18,7 +18,28 @@
*/
package org.apache.olingo.client.api.communication.request.retrieve.v4;
import java.net.URI;
import org.apache.olingo.client.api.communication.request.retrieve.CommonRetrieveRequestFactory;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetIteratorRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
@SuppressWarnings("unchecked")
public interface RetrieveRequestFactory extends CommonRetrieveRequestFactory {
@Override
ODataEntitySetRequest<ODataEntitySet> getEntitySetRequest(URI uri);
@Override
ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> getEntitySetIteratorRequest(URI uri);
@Override
ODataEntityRequest<ODataEntity> getEntityRequest(URI uri);
@Override
ODataPropertyRequest<ODataProperty> getPropertyRequest(URI uri);
}

View File

@ -18,19 +18,20 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
/**
* This class implements the response to an OData entity create request.
* This interface describes the response to an OData entity create request.
*
* @param <E> concrete ODataEntity implementation
* @see org.apache.olingo.client.core.communication.request.cud.ODataEntityCreateRequest
*/
public interface ODataEntityCreateResponse extends ODataResponse {
public interface ODataEntityCreateResponse<E extends CommonODataEntity> extends ODataResponse {
/**
* Gets created object.
*
* @return created object.
*/
ODataEntity getBody();
E getBody();
}

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
/**
* This class implements the response to an OData update request.
@ -32,5 +32,5 @@ public interface ODataEntityUpdateResponse extends ODataResponse {
*
* @return updated object.
*/
ODataEntity getBody();
CommonODataEntity getBody();
}

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
/**
* This class implements the response to an Odata media entity create request.
@ -32,5 +32,5 @@ public interface ODataMediaEntityCreateResponse extends ODataResponse {
*
* @return created object.
*/
ODataEntity getBody();
CommonODataEntity getBody();
}

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
/**
* This class implements the response to an Odata media entity update request.
@ -32,5 +32,5 @@ public interface ODataMediaEntityUpdateResponse extends ODataResponse {
*
* @return updated object.
*/
ODataEntity getBody();
CommonODataEntity getBody();
}

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.api.communication.response;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
/**
* This class implements the response to an OData update entity property request.
@ -32,5 +32,5 @@ public interface ODataPropertyUpdateResponse extends ODataResponse {
*
* @return updated object.
*/
ODataProperty getBody();
CommonODataProperty getBody();
}

View File

@ -19,6 +19,7 @@
package org.apache.olingo.client.api.communication.response;
import java.io.InputStream;
import java.net.URI;
import java.util.Collection;
import java.util.Map;
import org.apache.olingo.client.api.communication.header.HeaderName;
@ -58,6 +59,30 @@ public interface ODataResponse {
* @return ETag header value, if provided
*/
String getEtag();
/**
* The context URL describes the content of the payload. It consists of the canonical metadata document URL and a
* fragment identifying the relevant portion of the metadata document.
* <br />
* Request payloads generally do not require context URLs as the type of the payload can generally be determined from
* the request URL.
* <br />
* For details on how the context URL is used to describe a payload, see the relevant sections in the particular
* format.
*
* @return context URL.
*/
URI getContextURL();
/**
* An ETag header MAY also be returned on a metadata document request or service document request to allow the client
* subsequently to make a conditional request for the metadata or service document. Clients can also compare the value
* of the ETag header returned from a metadata document request to the metadata ETag returned in a response in order
* to verify the version of the metadata used to generate that response.
*
* @return metadata ETag.
*/
String getMetadataETag();
/**
* Gets the content type.

View File

@ -37,20 +37,6 @@ public interface ServiceDocument {
*/
URI getBaseURI();
/**
* Returns metadata context.
*
* @return metadata context
*/
String getMetadataContext();
/**
* Returns metadata ETag.
*
* @return metadata ETag
*/
String getMetadataETag();
/**
* Gets top level entity sets.
*
@ -134,5 +120,4 @@ public interface ServiceDocument {
* @return related service document with given title if found, otherwise null
*/
ServiceDocumentItem getRelatedServiceDocumentByTitle(String title);
}

View File

@ -32,8 +32,8 @@ import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.data.Entry;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -41,8 +41,12 @@ import org.slf4j.LoggerFactory;
* OData entity set iterator class.
* <br/>
* <b>Please don't forget to call the <tt>close()>/<tt> method when not needed any more.</b>
*
* @param <E> concrete ODataEntity implementation
* @param <ES> concrete ODataEntitySet implementation
*/
public class ODataEntitySetIterator implements Iterator<ODataEntity> {
public class ODataEntitySetIterator<ES extends CommonODataEntitySet, E extends CommonODataEntity>
implements Iterator<E> {
/**
* Logger.
@ -59,7 +63,7 @@ public class ODataEntitySetIterator implements Iterator<ODataEntity> {
private Entry cached;
private ODataEntitySet entitySet;
private ES entitySet;
private final ByteArrayOutputStream osFeed;
@ -104,6 +108,7 @@ public class ODataEntitySetIterator implements Iterator<ODataEntity> {
* {@inheritDoc }
*/
@Override
@SuppressWarnings("unchecked")
public boolean hasNext() {
if (available && cached == null) {
if (format == ODataPubFormat.ATOM) {
@ -114,7 +119,7 @@ public class ODataEntitySetIterator implements Iterator<ODataEntity> {
if (cached == null) {
available = false;
entitySet = odataClient.getReader().
entitySet = (ES) odataClient.getReader().
readEntitySet(new ByteArrayInputStream(osFeed.toByteArray()), format);
close();
}
@ -127,9 +132,10 @@ public class ODataEntitySetIterator implements Iterator<ODataEntity> {
* {@inheritDoc }
*/
@Override
public ODataEntity next() {
public E next() {
if (hasNext()) {
final ODataEntity res = odataClient.getBinder().getODataEntity(cached);
@SuppressWarnings("unchecked")
final E res = (E) odataClient.getBinder().getODataEntity(cached);
cached = null;
return res;
}
@ -170,7 +176,7 @@ public class ODataEntitySetIterator implements Iterator<ODataEntity> {
Entry jsonEntry = null;
try {
int c = 0;
int c;
boolean foundNewOne = false;
@ -203,7 +209,7 @@ public class ODataEntitySetIterator implements Iterator<ODataEntity> {
if (c >= 0) {
jsonEntry = odataClient.getDeserializer().toEntry(
new ByteArrayInputStream(entry.toByteArray()), ODataPubFormat.JSON);
new ByteArrayInputStream(entry.toByteArray()), ODataPubFormat.JSON).getObject();
}
} else {
while ((c = input.read()) >= 0) {
@ -237,7 +243,7 @@ public class ODataEntitySetIterator implements Iterator<ODataEntity> {
if (consume(input, "</entry>", entry, true) >= 0) {
atomEntry = odataClient.getDeserializer().
toEntry(new ByteArrayInputStream(entry.toByteArray()), ODataPubFormat.ATOM);
toEntry(new ByteArrayInputStream(entry.toByteArray()), ODataPubFormat.ATOM).getObject();
}
}
} catch (Exception e) {

View File

@ -21,6 +21,7 @@ package org.apache.olingo.client.api.op;
import java.io.InputStream;
import org.apache.olingo.client.api.data.ServiceDocument;
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
import org.apache.olingo.commons.api.data.Container;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.op.CommonODataDeserializer;
@ -35,5 +36,5 @@ public interface ClientODataDeserializer extends CommonODataDeserializer {
* @param format OData service document format.
* @return <tt>ServiceDocument</tt> object.
*/
ServiceDocument toServiceDocument(InputStream input, ODataFormat format);
Container<ServiceDocument> toServiceDocument(InputStream input, ODataFormat format);
}

View File

@ -25,10 +25,10 @@ import org.apache.olingo.commons.api.data.Feed;
import org.apache.olingo.commons.api.data.Link;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.client.api.data.ServiceDocument;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
public interface CommonODataBinder extends Serializable {
@ -40,7 +40,7 @@ public interface CommonODataBinder extends Serializable {
* @param reference reference class.
* @return <tt>Feed</tt> object.
*/
Feed getFeed(ODataEntitySet feed, Class<? extends Feed> reference);
Feed getFeed(CommonODataEntitySet feed, Class<? extends Feed> reference);
/**
* Gets an <tt>Entry</tt> from the given OData entity.
@ -49,7 +49,7 @@ public interface CommonODataBinder extends Serializable {
* @param reference reference class.
* @return <tt>Entry</tt> object.
*/
Entry getEntry(ODataEntity entity, Class<? extends Entry> reference);
Entry getEntry(CommonODataEntity entity, Class<? extends Entry> reference);
/**
* Gets an <tt>Entry</tt> from the given OData entity.
@ -59,7 +59,7 @@ public interface CommonODataBinder extends Serializable {
* @param setType whether to explicitly output type information.
* @return <tt>Entry</tt> object.
*/
Entry getEntry(ODataEntity entity, Class<? extends Entry> reference, boolean setType);
Entry getEntry(CommonODataEntity entity, Class<? extends Entry> reference, boolean setType);
/**
* Gets a <tt>Link</tt> from the given OData link.
@ -78,7 +78,16 @@ public interface CommonODataBinder extends Serializable {
* @param setType whether to explicitly output type information.
* @return <tt>Property</tt> object.
*/
Property getProperty(ODataProperty property, Class<? extends Entry> reference, boolean setType);
Property getProperty(CommonODataProperty property, Class<? extends Entry> reference, boolean setType);
/**
* Adds the given property to the given entity.
*
* @param entity OData entity.
* @param property OData property.
* @return whether add was successful or not.
*/
boolean add(CommonODataEntity entity, CommonODataProperty property);
/**
* Gets <tt>ODataServiceDocument</tt> from the given service document resource.
@ -94,7 +103,7 @@ public interface CommonODataBinder extends Serializable {
* @param resource feed resource.
* @return <tt>ODataEntitySet</tt> object.
*/
ODataEntitySet getODataEntitySet(Feed resource);
CommonODataEntitySet getODataEntitySet(Feed resource);
/**
* Gets <tt>ODataEntitySet</tt> from the given feed resource.
@ -103,7 +112,7 @@ public interface CommonODataBinder extends Serializable {
* @param defaultBaseURI default base URI.
* @return <tt>ODataEntitySet</tt> object.
*/
ODataEntitySet getODataEntitySet(Feed resource, URI defaultBaseURI);
CommonODataEntitySet getODataEntitySet(Feed resource, URI defaultBaseURI);
/**
* Gets <tt>ODataEntity</tt> from the given entry resource.
@ -111,7 +120,7 @@ public interface CommonODataBinder extends Serializable {
* @param resource entry resource.
* @return <tt>ODataEntity</tt> object.
*/
ODataEntity getODataEntity(Entry resource);
CommonODataEntity getODataEntity(Entry resource);
/**
* Gets <tt>ODataEntity</tt> from the given entry resource.
@ -120,7 +129,7 @@ public interface CommonODataBinder extends Serializable {
* @param defaultBaseURI default base URI.
* @return <tt>ODataEntity</tt> object.
*/
ODataEntity getODataEntity(Entry resource, URI defaultBaseURI);
CommonODataEntity getODataEntity(Entry resource, URI defaultBaseURI);
/**
* Gets an <tt>ODataProperty</tt> from the given property resource.
@ -128,5 +137,5 @@ public interface CommonODataBinder extends Serializable {
* @param property property resource.
* @return <tt>ODataProperty</tt> object.
*/
ODataProperty getODataProperty(Property property);
CommonODataProperty getODataProperty(Property property);
}

View File

@ -20,14 +20,17 @@ package org.apache.olingo.client.api.op;
import java.io.InputStream;
import java.io.Serializable;
import java.util.List;
import org.apache.olingo.client.api.edm.xml.Schema;
import org.apache.olingo.commons.api.data.Container;
import org.apache.olingo.commons.api.domain.ODataError;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.ODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataServiceDocument;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.api.edm.Edm;
/**
* OData reader.
@ -46,6 +49,15 @@ public interface CommonODataReader extends Serializable {
*/
Edm readMetadata(InputStream input);
/**
* Parses a stream into metadata representation, including referenced metadata documents.
*
* @param xmlSchemas XML representation of the requested metadata document + any other referenced (via
* <tt>&lt;edmx:Reference/&gt;</tt>) metadata document
* @return metadata representation.
*/
Edm readMetadata(List<? extends Schema> xmlSchemas);
/**
* Parses an OData service document.
*
@ -62,7 +74,7 @@ public interface CommonODataReader extends Serializable {
* @param format de-serialize as AtomFeed or JSONFeed
* @return de-serialized entity set.
*/
ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format);
CommonODataEntitySet readEntitySet(InputStream input, ODataPubFormat format);
/**
* Parses a stream taking care to de-serializes the first OData entity found.
@ -71,7 +83,7 @@ public interface CommonODataReader extends Serializable {
* @param format de-serialize as AtomEntry or JSONEntry
* @return entity de-serialized.
*/
ODataEntity readEntity(InputStream input, ODataPubFormat format);
CommonODataEntity readEntity(InputStream input, ODataPubFormat format);
/**
* Parses a stream taking care to de-serialize the first OData entity property found.
@ -80,7 +92,7 @@ public interface CommonODataReader extends Serializable {
* @param format de-serialize as XML or JSON
* @return OData entity property de-serialized.
*/
ODataProperty readProperty(InputStream input, ODataFormat format);
CommonODataProperty readProperty(InputStream input, ODataFormat format);
/**
* Parses a stream into an OData error.
@ -100,5 +112,5 @@ public interface CommonODataReader extends Serializable {
* @param reference reference.
* @return read object.
*/
<T> T read(InputStream src, String format, Class<T> reference);
<T> Container<T> read(InputStream src, String format, Class<T> reference);
}

View File

@ -21,9 +21,9 @@ package org.apache.olingo.client.api.op;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Collection;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.format.ODataPubFormat;
@ -43,7 +43,7 @@ public interface ODataWriter extends Serializable {
* @param format serialization format.
* @return stream of serialized objects.
*/
InputStream writeEntities(Collection<ODataEntity> entities, ODataPubFormat format);
InputStream writeEntities(Collection<CommonODataEntity> entities, ODataPubFormat format);
/**
* Writes a collection of OData entities.
@ -53,7 +53,7 @@ public interface ODataWriter extends Serializable {
* @param outputType whether to explicitly output type information.
* @return stream of serialized objects.
*/
InputStream writeEntities(Collection<ODataEntity> entities, ODataPubFormat format, boolean outputType);
InputStream writeEntities(Collection<CommonODataEntity> entities, ODataPubFormat format, boolean outputType);
/**
* Serializes a single OData entity.
@ -62,7 +62,7 @@ public interface ODataWriter extends Serializable {
* @param format serialization format.
* @return stream of serialized object.
*/
InputStream writeEntity(ODataEntity entity, ODataPubFormat format);
InputStream writeEntity(CommonODataEntity entity, ODataPubFormat format);
/**
* Serializes a single OData entity.
@ -72,7 +72,7 @@ public interface ODataWriter extends Serializable {
* @param outputType whether to explicitly output type information.
* @return stream of serialized object.
*/
InputStream writeEntity(ODataEntity entity, ODataPubFormat format, boolean outputType);
InputStream writeEntity(CommonODataEntity entity, ODataPubFormat format, boolean outputType);
/**
* Writes a single OData entity property.
@ -81,7 +81,7 @@ public interface ODataWriter extends Serializable {
* @param format serialization format.
* @return stream of serialized object.
*/
InputStream writeProperty(ODataProperty property, ODataFormat format);
InputStream writeProperty(CommonODataProperty property, ODataFormat format);
/**
* Writes an OData link.

View File

@ -18,12 +18,34 @@
*/
package org.apache.olingo.client.api.op.v3;
import java.net.URI;
import org.apache.olingo.commons.api.data.v3.LinkCollection;
import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
import org.apache.olingo.client.api.op.CommonODataBinder;
import org.apache.olingo.commons.api.data.Entry;
import org.apache.olingo.commons.api.data.Feed;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
public interface ODataBinder extends CommonODataBinder {
@Override
ODataEntitySet getODataEntitySet(Feed resource);
@Override
ODataEntitySet getODataEntitySet(Feed resource, URI defaultBaseURI);
@Override
ODataEntity getODataEntity(Entry resource);
@Override
ODataEntity getODataEntity(Entry resource, URI defaultBaseURI);
@Override
ODataProperty getODataProperty(Property property);
/**
* Gets <tt>ODataLinkCollection</tt> from the given link collection resource.
*

View File

@ -20,6 +20,7 @@ package org.apache.olingo.client.api.op.v3;
import java.io.InputStream;
import org.apache.olingo.client.api.op.ClientODataDeserializer;
import org.apache.olingo.commons.api.data.Container;
import org.apache.olingo.commons.api.data.v3.LinkCollection;
import org.apache.olingo.commons.api.format.ODataFormat;
@ -32,6 +33,6 @@ public interface ODataDeserializer extends ClientODataDeserializer {
* @param format OData format.
* @return de-serialized links.
*/
LinkCollection toLinkCollection(InputStream input, ODataFormat format);
Container<LinkCollection> toLinkCollection(InputStream input, ODataFormat format);
}

View File

@ -22,9 +22,22 @@ import java.io.InputStream;
import org.apache.olingo.client.api.domain.v3.ODataLinkCollection;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.client.api.op.CommonODataReader;
import org.apache.olingo.commons.api.domain.v3.ODataEntity;
import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v3.ODataProperty;
import org.apache.olingo.commons.api.format.ODataPubFormat;
public interface ODataReader extends CommonODataReader {
@Override
ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format);
@Override
ODataEntity readEntity(InputStream input, ODataPubFormat format);
@Override
ODataProperty readProperty(InputStream input, ODataFormat format);
/**
* Parses a $links request response.
*

View File

@ -18,8 +18,29 @@
*/
package org.apache.olingo.client.api.op.v4;
import java.net.URI;
import org.apache.olingo.client.api.op.CommonODataBinder;
import org.apache.olingo.commons.api.data.Entry;
import org.apache.olingo.commons.api.data.Feed;
import org.apache.olingo.commons.api.data.Property;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
public interface ODataBinder extends CommonODataBinder {
@Override
ODataEntitySet getODataEntitySet(Feed resource);
@Override
ODataEntitySet getODataEntitySet(Feed resource, URI defaultBaseURI);
@Override
ODataEntity getODataEntity(Entry resource);
@Override
ODataEntity getODataEntity(Entry resource, URI defaultBaseURI);
@Override
ODataProperty getODataProperty(Property property);
}

View File

@ -18,8 +18,22 @@
*/
package org.apache.olingo.client.api.op.v4;
import java.io.InputStream;
import org.apache.olingo.client.api.op.CommonODataReader;
import org.apache.olingo.commons.api.domain.v4.ODataEntity;
import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
import org.apache.olingo.commons.api.domain.v4.ODataProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.format.ODataPubFormat;
public interface ODataReader extends CommonODataReader {
@Override
ODataEntitySet readEntitySet(InputStream input, ODataPubFormat format);
@Override
ODataEntity readEntity(InputStream input, ODataPubFormat format);
@Override
ODataProperty readProperty(InputStream input, ODataFormat format);
}

View File

@ -18,7 +18,6 @@
*/
package org.apache.olingo.client.api.uri;
import java.net.URI;
import java.util.Map;
@ -41,10 +40,19 @@ public interface CommonURIBuilder<UB extends CommonURIBuilder<?>> {
*
* @param option query option.
* @param value query option value.
* @return current URIBuilder instance
* @return current URIBuilder instance.
*/
UB addQueryOption(String option, String value);
/**
* Adds the specified (custom) parameter alias to the URI.
*
* @param alias parameter alias.
* @param exp expression value.
* @return current URIBuilder instance.
*/
UB addParameterAlias(final String alias, final String exp);
/**
* Appends EntitySet segment to the URI.
*
@ -220,5 +228,4 @@ public interface CommonURIBuilder<UB extends CommonURIBuilder<?>> {
* @return OData URI.
*/
URI build();
}

View File

@ -34,6 +34,7 @@ public enum SegmentType {
NAVIGATION,
DERIVED_ENTITY_TYPE,
VALUE("$value"),
COUNT("$count"),
BOUND_OPERATION,
UNBOUND_OPERATION,
METADATA("$metadata"),

View File

@ -42,8 +42,7 @@ public interface URIBuilder extends CommonURIBuilder<URIBuilder> {
*
* @param inlineCount value
* @return current URIBuilder instance
* @see QueryOption#INLINECOUNT
* @see org.apache.olingo.client.api.uri.QueryOption#INLINECOUNT
*/
URIBuilder inlineCount(InlineCount inlineCount);
}

View File

@ -18,10 +18,31 @@
*/
package org.apache.olingo.client.api.uri.v4;
import java.util.Map;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.client.api.uri.CommonURIBuilder;
public interface URIBuilder extends CommonURIBuilder<URIBuilder> {
/**
* Appends enum key segment to the URI.
*
* @param enumType enum type
* @param memberName enum member name
* @return current URIBuilder instance
*/
URIBuilder appendKeySegment(EdmEnumType enumType, String memberName);
/**
* Appends key segment to the URI, for multiple keys.
*
* @param enumValues enum segment values.
* @param segmentValues segment values.
* @return current URIBuilder instance
*/
URIBuilder appendKeySegment(Map<String, Pair<EdmEnumType, String>> enumValues, Map<String, Object> segmentValues);
/**
* Appends Singleton segment to the URI.
*
@ -65,7 +86,7 @@ public interface URIBuilder extends CommonURIBuilder<URIBuilder> {
*
* @param idValue opaque token.
* @return current URIBuilder instance
* @see QueryOption#ID
* @see org.apache.olingo.client.api.uri.QueryOption#ID
*/
URIBuilder id(String idValue);
@ -74,7 +95,7 @@ public interface URIBuilder extends CommonURIBuilder<URIBuilder> {
*
* @param value true or false
* @return current URIBuilder instance
* @see QueryOption#COUNT
* @see org.apache.olingo.client.api.uri.QueryOption#COUNT
*/
URIBuilder count(boolean value);
@ -83,7 +104,19 @@ public interface URIBuilder extends CommonURIBuilder<URIBuilder> {
*
* @param expression search expression
* @return current URIBuilder instance
* @see QueryOption#SEARCH
* @see org.apache.olingo.client.api.uri.QueryOption#SEARCH
*/
URIBuilder search(String expression);
/**
* The set of expanded entities can be refined through the application of expand options, expressed as a
* semicolon-separated list of system query options, enclosed in parentheses, see [OData-URL].
*
* @param expandItem item to be expanded.
* @param options System query options. Allowed query options are: $filter, $select, $orderby, $skip, $top, $count,
* $search, $expand, and $levels.
* @return current URIBuilder instance.
* @see org.apache.olingo.client.api.uri.QueryOption#EXPAND
*/
URIBuilder expandWithOptions(String expandItem, Map<String, Object> options);
}

View File

@ -29,9 +29,13 @@ import org.apache.olingo.client.api.op.v3.ODataDeserializer;
import org.apache.olingo.client.api.op.v3.ODataReader;
import org.apache.olingo.client.api.uri.v3.URIBuilder;
import org.apache.olingo.client.api.uri.v3.FilterFactory;
import org.apache.olingo.commons.api.domain.v3.ODataObjectFactory;
public interface ODataClient extends CommonODataClient {
@Override
Configuration getConfiguration();
@Override
ODataDeserializer getDeserializer();
@ -41,15 +45,15 @@ public interface ODataClient extends CommonODataClient {
@Override
ODataBinder getBinder();
@Override
Configuration getConfiguration();
@Override
URIBuilder getURIBuilder(String serviceRoot);
@Override
FilterFactory getFilterFactory();
@Override
ODataObjectFactory getObjectFactory();
@Override
RetrieveRequestFactory getRetrieveRequestFactory();

View File

@ -29,9 +29,13 @@ import org.apache.olingo.client.api.op.v4.ODataDeserializer;
import org.apache.olingo.client.api.op.v4.ODataReader;
import org.apache.olingo.client.api.uri.v4.URIBuilder;
import org.apache.olingo.client.api.uri.v4.FilterFactory;
import org.apache.olingo.commons.api.domain.v4.ODataObjectFactory;
public interface ODataClient extends CommonODataClient {
@Override
Configuration getConfiguration();
@Override
ODataDeserializer getDeserializer();
@ -41,15 +45,15 @@ public interface ODataClient extends CommonODataClient {
@Override
ODataBinder getBinder();
@Override
Configuration getConfiguration();
@Override
URIBuilder getURIBuilder(String serviceRoot);
@Override
FilterFactory getFilterFactory();
@Override
ODataObjectFactory getObjectFactory();
@Override
RetrieveRequestFactory getRetrieveRequestFactory();

View File

@ -19,11 +19,7 @@
package org.apache.olingo.client.core;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.commons.api.domain.ODataObjectFactory;
import org.apache.olingo.client.api.op.ODataWriter;
import org.apache.olingo.client.core.domain.ODataGeospatialValueImpl;
import org.apache.olingo.client.core.domain.ODataPrimitiveValueImpl;
import org.apache.olingo.commons.core.op.ODataObjectFactoryImpl;
import org.apache.olingo.client.core.op.ODataWriterImpl;
public abstract class AbstractODataClient implements CommonODataClient {
@ -32,26 +28,9 @@ public abstract class AbstractODataClient implements CommonODataClient {
private final ODataWriter writer = new ODataWriterImpl(this);
private final ODataObjectFactory objectFactory = new ODataObjectFactoryImpl(getServiceVersion());
@Override
public ODataPrimitiveValueImpl.BuilderImpl getPrimitiveValueBuilder() {
return new ODataPrimitiveValueImpl.BuilderImpl(this.getServiceVersion());
}
@Override
public ODataGeospatialValueImpl.BuilderImpl getGeospatialValueBuilder() {
return new ODataGeospatialValueImpl.BuilderImpl();
}
@Override
public ODataWriter getWriter() {
return writer;
}
@Override
public ODataObjectFactory getObjectFactory() {
return objectFactory;
}
}

View File

@ -24,7 +24,6 @@ import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.net.URI;
import java.util.Collection;
import java.util.Collections;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.Header;
@ -38,14 +37,10 @@ import org.apache.olingo.client.api.v3.Configuration;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.ODataServerErrorException;
import org.apache.olingo.client.api.communication.header.HeaderName;
import org.apache.olingo.client.api.communication.header.ODataHeaderValues;
import org.apache.olingo.client.api.communication.header.ODataHeaders;
import org.apache.olingo.client.api.communication.header.ODataPreferences;
import org.apache.olingo.client.api.communication.request.ODataRequest;
import org.apache.olingo.client.api.communication.request.ODataStreamer;
import org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory;
import org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory;
import org.apache.olingo.client.api.communication.request.invoke.v3.InvokeRequestFactory;
import org.apache.olingo.client.api.communication.request.streamed.v3.StreamedRequestFactory;
import org.apache.olingo.client.api.communication.response.ODataResponse;
import org.apache.olingo.commons.api.format.Format;
import org.apache.olingo.client.api.http.HttpClientException;
@ -56,8 +51,8 @@ import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.commons.api.format.ODataMediaFormat;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.commons.api.format.ODataValueFormat;
import org.apache.olingo.commons.core.data.JSONErrorImpl;
import org.apache.olingo.commons.core.data.XMLErrorImpl;
import org.apache.olingo.commons.core.data.JSONODataErrorImpl;
import org.apache.olingo.commons.core.data.XMLODataErrorImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -66,10 +61,14 @@ import org.slf4j.LoggerFactory;
*
* @param <T> Accepted content-type formats by the request in object.
*
* @see CUDRequestFactory
* @see BatchRequestFactory
* @see InvokeRequestFactory
* @see StreamedRequestFactory
* @see org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory
* @see org.apache.olingo.client.api.communication.request.cud.v4.CUDRequestFactory
* @see org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory
* @see org.apache.olingo.client.api.communication.request.batch.v4.BatchRequestFactory
* @see org.apache.olingo.client.api.communication.request.invoke.v3.InvokeRequestFactory
* @see org.apache.olingo.client.api.communication.request.invoke.v4.InvokeRequestFactory
* @see org.apache.olingo.client.api.communication.request.streamed.v3.StreamedRequestFactory
* @see org.apache.olingo.client.api.communication.request.streamed.v4.StreamedRequestFactory
*/
public class ODataRequestImpl<T extends Format> implements ODataRequest {
@ -80,7 +79,7 @@ public class ODataRequestImpl<T extends Format> implements ODataRequest {
protected final CommonODataClient odataClient;
protected final Class<T> formatRef;
private final Class<T> formatRef;
/**
* OData request method.
@ -250,6 +249,15 @@ public class ODataRequestImpl<T extends Format> implements ODataRequest {
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ODataRequest addCustomHeader(final HeaderName name, final String value) {
odataHeaders.setHeader(name, value);
return this;
}
/**
* {@inheritDoc}
*/
@ -384,7 +392,8 @@ public class ODataRequestImpl<T extends Format> implements ODataRequest {
if (odataClient.getServiceVersion() == ODataServiceVersion.V30
&& ((Configuration) odataClient.getConfiguration()).isKeyAsSegment()) {
addCustomHeader(
HeaderName.dataServiceUrlConventions.toString(), ODataHeaderValues.keyAsSegment);
HeaderName.dataServiceUrlConventions.toString(),
new ODataPreferences(odataClient.getServiceVersion()).keyAsSegment());
}
// Add all available headers
@ -469,19 +478,13 @@ public class ODataRequestImpl<T extends Format> implements ODataRequest {
private ODataError getGenericError(final int code, final String errorMsg, final boolean isXML) {
final ODataError error;
if (isXML) {
error = new XMLErrorImpl();
final XMLErrorImpl.Message msg = new XMLErrorImpl.Message(
Collections.singletonMap("", (Object) errorMsg));
((XMLErrorImpl) error).setMessage(msg);
((XMLErrorImpl) error).setCode(String.valueOf(code));
error = new XMLODataErrorImpl();
((XMLODataErrorImpl) error).setCode(String.valueOf(code));
((XMLODataErrorImpl) error).setMessage(errorMsg);
} else {
error = new JSONErrorImpl();
final JSONErrorImpl.Message msg = new JSONErrorImpl.Message();
msg.setValue(errorMsg);
((JSONErrorImpl) error).setMessage(msg);
((JSONErrorImpl) error).setCode(String.valueOf(code));
error = new JSONODataErrorImpl();
((JSONODataErrorImpl) error).setCode(String.valueOf(code));
((JSONODataErrorImpl) error).setMessage(errorMsg);
}
return error;

View File

@ -20,7 +20,6 @@ package org.apache.olingo.client.core.communication.request.cud;
import java.net.URI;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.UpdateType;
import org.apache.olingo.client.api.communication.request.cud.CommonCUDRequestFactory;
import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
@ -29,10 +28,11 @@ import org.apache.olingo.client.api.communication.request.cud.ODataLinkCreateReq
import org.apache.olingo.client.api.communication.request.cud.ODataLinkUpdateRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.client.api.communication.request.cud.UpdateType;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.client.api.http.HttpMethod;
public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFactory {
@ -46,13 +46,15 @@ public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFacto
}
@Override
public ODataEntityCreateRequest getEntityCreateRequest(final URI targetURI, final ODataEntity entity) {
return new ODataEntityCreateRequestImpl(client, targetURI, entity);
public <E extends CommonODataEntity> ODataEntityCreateRequest<E> getEntityCreateRequest(
final URI targetURI, final E entity) {
return new ODataEntityCreateRequestImpl<E>(client, targetURI, entity);
}
@Override
public ODataEntityUpdateRequest getEntityUpdateRequest(
final URI targetURI, final UpdateType type, final ODataEntity changes) {
final URI targetURI, final UpdateType type, final CommonODataEntity changes) {
final ODataEntityUpdateRequest req;
@ -67,7 +69,7 @@ public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFacto
}
@Override
public ODataEntityUpdateRequest getEntityUpdateRequest(final UpdateType type, final ODataEntity entity) {
public ODataEntityUpdateRequest getEntityUpdateRequest(final UpdateType type, final CommonODataEntity entity) {
if (entity.getEditLink() == null) {
throw new IllegalArgumentException("No edit link found");
}
@ -102,7 +104,7 @@ public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFacto
@Override
public ODataPropertyUpdateRequest getPropertyPrimitiveValueUpdateRequest(
final URI targetURI, final ODataProperty property) {
final URI targetURI, final CommonODataProperty property) {
if (!property.hasPrimitiveValue()) {
throw new IllegalArgumentException("A primitive value is required");
@ -122,7 +124,7 @@ public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFacto
@Override
public ODataPropertyUpdateRequest getPropertyComplexValueUpdateRequest(
final URI targetURI, final UpdateType type, final ODataProperty property) {
final URI targetURI, final UpdateType type, final CommonODataProperty property) {
if (!property.hasComplexValue()) {
throw new IllegalArgumentException("A complex value is required");
@ -142,7 +144,7 @@ public abstract class AbstractCUDRequestFactory implements CommonCUDRequestFacto
@Override
public ODataPropertyUpdateRequest getPropertyCollectionValueUpdateRequest(
final URI targetURI, final ODataProperty property) {
final URI targetURI, final CommonODataProperty property) {
if (!property.hasCollectionValue()) {
throw new IllegalArgumentException("A collection value is required");

View File

@ -28,23 +28,28 @@ import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest;
import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
import org.apache.olingo.commons.api.data.Container;
import org.apache.olingo.commons.api.data.Entry;
/**
* This class implements an OData create request.
*
* @param <E> concrete ODataEntity implementation
*/
public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODataEntityCreateResponse, ODataPubFormat>
implements ODataEntityCreateRequest, ODataBatchableRequest {
public class ODataEntityCreateRequestImpl<E extends CommonODataEntity>
extends AbstractODataBasicRequest<ODataEntityCreateResponse<E>, ODataPubFormat>
implements ODataEntityCreateRequest<E>, ODataBatchableRequest {
/**
* Entity to be created.
*/
private final ODataEntity entity;
private final E entity;
/**
* Constructor.
@ -53,7 +58,7 @@ public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODat
* @param targetURI entity set URI.
* @param entity entity to be created.
*/
ODataEntityCreateRequestImpl(final CommonODataClient odataClient, final URI targetURI, final ODataEntity entity) {
ODataEntityCreateRequestImpl(final CommonODataClient odataClient, final URI targetURI, final E entity) {
super(odataClient, ODataPubFormat.class, HttpMethod.POST, targetURI);
this.entity = entity;
}
@ -70,7 +75,7 @@ public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODat
* {@inheritDoc }
*/
@Override
public ODataEntityCreateResponse execute() {
public ODataEntityCreateResponse<E> execute() {
final InputStream input = getPayload();
((HttpPost) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
@ -84,9 +89,9 @@ public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODat
/**
* Response class about an ODataEntityCreateRequest.
*/
private class ODataEntityCreateResponseImpl extends AbstractODataResponse implements ODataEntityCreateResponse {
private class ODataEntityCreateResponseImpl extends AbstractODataResponse implements ODataEntityCreateResponse<E> {
private ODataEntity entity = null;
private E entity = null;
/**
* Constructor.
@ -94,6 +99,7 @@ public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODat
* Just to create response templates to be initialized from batch.
*/
private ODataEntityCreateResponseImpl() {
super();
}
/**
@ -110,11 +116,14 @@ public class ODataEntityCreateRequestImpl extends AbstractODataBasicRequest<ODat
* {@inheritDoc }
*/
@Override
public ODataEntity getBody() {
@SuppressWarnings("unchecked")
public E getBody() {
if (entity == null) {
try {
entity = odataClient.getReader().
readEntity(getRawResponse(), ODataPubFormat.fromString(getAccept()));
final Container<Entry> container = odataClient.getDeserializer().toEntry(getRawResponse(),
ODataPubFormat.fromString(getAccept()));
entity = (E) odataClient.getBinder().getODataEntity(extractFromContainer(container));
} finally {
this.close();
}

View File

@ -28,12 +28,14 @@ import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest;
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
import org.apache.olingo.commons.api.domain.ODataEntity;
import org.apache.olingo.commons.api.domain.CommonODataEntity;
import org.apache.olingo.commons.api.format.ODataPubFormat;
import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
import org.apache.olingo.commons.api.data.Container;
import org.apache.olingo.commons.api.data.Entry;
/**
* This class implements an OData update request.
@ -44,7 +46,7 @@ public class ODataEntityUpdateRequestImpl extends AbstractODataBasicRequest<ODat
/**
* Changes to be applied.
*/
private final ODataEntity changes;
private final CommonODataEntity changes;
/**
* Constructor.
@ -55,7 +57,7 @@ public class ODataEntityUpdateRequestImpl extends AbstractODataBasicRequest<ODat
* @param changes changes to be applied.
*/
ODataEntityUpdateRequestImpl(final CommonODataClient odataClient,
final HttpMethod method, final URI uri, final ODataEntity changes) {
final HttpMethod method, final URI uri, final CommonODataEntity changes) {
super(odataClient, ODataPubFormat.class, method, uri);
this.changes = changes;
@ -92,7 +94,7 @@ public class ODataEntityUpdateRequestImpl extends AbstractODataBasicRequest<ODat
/**
* Changes.
*/
private ODataEntity entity = null;
private CommonODataEntity entity = null;
/**
* Constructor.
@ -116,11 +118,13 @@ public class ODataEntityUpdateRequestImpl extends AbstractODataBasicRequest<ODat
* {@inheritDoc ]
*/
@Override
public ODataEntity getBody() {
public CommonODataEntity getBody() {
if (entity == null) {
try {
entity = odataClient.getReader().
readEntity(getRawResponse(), ODataPubFormat.fromString(getAccept()));
final Container<Entry> container = odataClient.getDeserializer().toEntry(getRawResponse(),
ODataPubFormat.fromString(getAccept()));
entity = odataClient.getBinder().getODataEntity(extractFromContainer(container));
} finally {
this.close();
}

View File

@ -28,12 +28,14 @@ import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest;
import org.apache.olingo.client.api.communication.response.ODataPropertyUpdateResponse;
import org.apache.olingo.commons.api.domain.ODataProperty;
import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
import org.apache.olingo.commons.api.data.Container;
import org.apache.olingo.commons.api.data.Property;
/**
* This class implements an OData update entity property request.
@ -44,7 +46,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
/**
* Value to be created.
*/
private final ODataProperty property;
private final CommonODataProperty property;
/**
* Constructor.
@ -55,7 +57,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
* @param property value to be created.
*/
ODataPropertyUpdateRequestImpl(final CommonODataClient odataClient,
final HttpMethod method, final URI targetURI, final ODataProperty property) {
final HttpMethod method, final URI targetURI, final CommonODataProperty property) {
super(odataClient, ODataFormat.class, method, targetURI);
// set request body
@ -90,7 +92,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
*/
private class ODataPropertyUpdateResponseImpl extends AbstractODataResponse implements ODataPropertyUpdateResponse {
private ODataProperty property = null;
private CommonODataProperty property = null;
/**
* Constructor.
@ -114,11 +116,13 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD
* {@inheritDoc }
*/
@Override
public ODataProperty getBody() {
public CommonODataProperty getBody() {
if (property == null) {
try {
property = odataClient.getReader().
readProperty(getRawResponse(), ODataFormat.fromString(getAccept()));
final Container<Property> container = odataClient.getDeserializer().toProperty(getRawResponse(),
ODataFormat.fromString(getAccept()));
property = odataClient.getBinder().getODataProperty(extractFromContainer(container));
} finally {
this.close();
}

View File

@ -35,7 +35,6 @@ import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
import org.apache.olingo.client.core.domain.ODataPrimitiveValueImpl;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
/**
@ -101,6 +100,7 @@ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<OData
* Just to create response templates to be initialized from batch.
*/
private ODataValueUpdateResponseImpl() {
super();
}
/**
@ -122,7 +122,7 @@ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<OData
final ODataValueFormat format = ODataValueFormat.fromString(getAccept());
try {
value = new ODataPrimitiveValueImpl.BuilderImpl(odataClient.getServiceVersion()).
value = odataClient.getObjectFactory().newPrimitiveValueBuilder().
setType(format == ODataValueFormat.TEXT
? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
setText(IOUtils.toString(getRawResponse())).

Some files were not shown because too many files have changed in this diff Show More