[OLINGO-852] less warnings + general clean-up

Signed-off-by: Christian Amend <christian.amend@sap.com>
This commit is contained in:
Klaus Straubinger 2016-02-04 12:28:35 +01:00 committed by Christian Amend
parent 110c7b0e5a
commit 5d7c1287f0
68 changed files with 2230 additions and 3058 deletions

View File

@ -69,7 +69,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
return service.getContext();
}
protected boolean isSelfMethod(final Method method, final Object[] args) {
protected boolean isSelfMethod(final Method method) {
final Method[] selfMethods = getClass().getMethods();
boolean result = false;
@ -161,7 +161,7 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
CoreUtils.addProperties(getClient(), handler.getPropertyChanges(), template);
final Object key = CoreUtils.getKey(getClient(), handler, handler.getUUID().getType(), template);
entityURI = CoreUtils.buildEditLink(getClient(), baseURI.toASCIIString(), template, key).build();
entityURI = CoreUtils.buildEditLink(getClient(), baseURI.toASCIIString(), key).build();
template.setEditLink(entityURI);
} else {
entityURI = handler.getEntityURI();
@ -182,32 +182,25 @@ abstract class AbstractInvocationHandler implements InvocationHandler {
}
}
protected static URIBuilder buildEntitySetURI(
final Class<?> ref,
final AbstractService<?> service) {
protected static URIBuilder buildEntitySetURI(final Class<?> ref, final AbstractService<?> service) {
final String containerNS;
final String entitySetName;
Annotation ann = ref.getAnnotation(EntitySet.class);
if (ann instanceof EntitySet) {
containerNS = EntitySet.class.cast(ann).container();
entitySetName = EntitySet.class.cast(ann).name();
} else {
ann = ref.getAnnotation(Singleton.class);
if (ann instanceof Singleton) {
containerNS = Singleton.class.cast(ann).container();
entitySetName = Singleton.class.cast(ann).name();
} else {
containerNS = null;
entitySetName = null;
}
}
return buildEntitySetURI(containerNS, entitySetName, service);
return buildEntitySetURI(entitySetName, service);
}
protected static URIBuilder buildEntitySetURI(
final String containerNS, final String entitySetName, final AbstractService<?> service) {
protected static URIBuilder buildEntitySetURI(final String entitySetName, final AbstractService<?> service) {
final URIBuilder uriBuilder = service.getClient().newURIBuilder();
final StringBuilder entitySetSegment = new StringBuilder();

View File

@ -210,7 +210,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca
|| "refs".equals(method.getName())) {
invokeSelfMethod(method, args);
return proxy;
} else if (isSelfMethod(method, args)) {
} else if (isSelfMethod(method)) {
return invokeSelfMethod(method, args);
} else if ("load".equals(method.getName()) && ArrayUtils.isEmpty(args)) {
load();

View File

@ -55,7 +55,7 @@ public class AnnotatationsInvocationHandler extends AbstractInvocationHandler {
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
if (isSelfMethod(method, args)) {
if (isSelfMethod(method)) {
return invokeSelfMethod(method, args);
} else if (method.getName().startsWith("get") && method.getName().endsWith("Annotations")) {
final Method getter = proxy.getClass().getInterfaces()[0].getMethod(method.getName());

View File

@ -80,7 +80,7 @@ public class ComplexCollectionInvocationHandler<T extends ComplexType<?>>
invokeSelfMethod(method, args);
return proxy;
} else if (isSelfMethod(method, args)) {
} else if (isSelfMethod(method)) {
return invokeSelfMethod(method, args);
} else if ("operations".equals(method.getName()) && ArrayUtils.isEmpty(args)) {
final Class<?> returnType = method.getReturnType();

View File

@ -63,11 +63,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
return new ImmutablePair<ClientComplexValue, Class<?>>(complex, complexTypeRef);
}
public static ComplexInvocationHandler getInstance(
final String propertyName,
final EntityInvocationHandler handler,
final Class<?> typeRef) {
public static ComplexInvocationHandler getInstance(final EntityInvocationHandler handler, final Class<?> typeRef) {
final Pair<ClientComplexValue, Class<?>> init = init(typeRef, handler.service);
return new ComplexInvocationHandler(init.getLeft(), init.getRight(), handler);
}

View File

@ -59,7 +59,7 @@ public class EdmStreamValueHandler extends AbstractInvocationHandler {
load();
return proxy;
} else {
if (isSelfMethod(method, args)) {
if (isSelfMethod(method)) {
return invokeSelfMethod(method, args);
} else {
throw new NoSuchMethodException(method.getName());

View File

@ -62,7 +62,7 @@ public class EntityCollectionInvocationHandler<T extends EntityType<?>>
|| "execute".equals(method.getName())) {
invokeSelfMethod(method, args);
return proxy;
} else if (isSelfMethod(method, args)) {
} else if (isSelfMethod(method)) {
return invokeSelfMethod(method, args);
} else if ("operations".equals(method.getName()) && ArrayUtils.isEmpty(args)) {
final Class<?> returnType = method.getReturnType();

View File

@ -80,7 +80,7 @@ public final class EntityContainerInvocationHandler extends AbstractInvocationHa
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
if (isSelfMethod(method, args)) {
if (isSelfMethod(method)) {
return invokeSelfMethod(method, args);
} else if ("flush".equals(method.getName()) && ArrayUtils.isEmpty(args)) {
service.getPersistenceManager().flush();
@ -114,7 +114,7 @@ public final class EntityContainerInvocationHandler extends AbstractInvocationHa
final Class<?> typeRef = method.getReturnType();
final Singleton singleton = method.getAnnotation(Singleton.class);
final URI uri = buildEntitySetURI(singleton.container(), singleton.name(), service).build();
final URI uri = buildEntitySetURI(singleton.name(), service).build();
final EntityUUID uuid = new EntityUUID(uri, typeRef);
LOG.debug("Ask for singleton '{}'", typeRef.getSimpleName());

View File

@ -191,7 +191,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
this.uri = getClient().newURIBuilder(baseURI.toASCIIString());
} else if (key != null) {
final URIBuilder uriBuilder =
CoreUtils.buildEditLink(getClient(), entitySetURI.toASCIIString(), entity, key);
CoreUtils.buildEditLink(getClient(), entitySetURI.toASCIIString(), key);
this.uri = uriBuilder;
this.baseURI = this.uri.build();
@ -219,7 +219,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
if (this.uri == null) {
final URIBuilder uriBuilder =
entity.getEditLink() == null
? CoreUtils.buildEditLink(getClient(), getUUID().getEntitySetURI().toASCIIString(), entity, key)
? CoreUtils.buildEditLink(getClient(), getUUID().getEntitySetURI().toASCIIString(), key)
: getClient().newURIBuilder(entity.getEditLink().toASCIIString());
this.uri = uriBuilder;
@ -252,7 +252,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler
if (this.uri == null) {
final URIBuilder uriBuilder =
getEntity().getEditLink() == null
? CoreUtils.buildEditLink(getClient(), entitySetURI.toASCIIString(), getEntity(), key)
? CoreUtils.buildEditLink(getClient(), entitySetURI.toASCIIString(), key)
: getClient().newURIBuilder(getEntity().getEditLink().toASCIIString());
this.uri = uriBuilder;

View File

@ -84,7 +84,7 @@ public class EntitySetInvocationHandler<
invokeSelfMethod(method, args);
return proxy;
} else if (isSelfMethod(method, args)) {
} else if (isSelfMethod(method)) {
return invokeSelfMethod(method, args);
} else {
throw new NoSuchMethodException(method.getName());

View File

@ -276,7 +276,7 @@ public class InvokerInvocationHandler<T, O extends Operations> extends AbstractI
return Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {operationRef}, handler);
} else if (isSelfMethod(method, args)) {
} else if (isSelfMethod(method)) {
return invokeSelfMethod(method, args);
} else {
throw new NoSuchMethodException(method.getName());

View File

@ -133,7 +133,7 @@ final class OperationInvocationHandler extends AbstractInvocationHandler {
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
if (isSelfMethod(method, args)) {
if (isSelfMethod(method)) {
return invokeSelfMethod(method, args);
} else {
final Operation operation = method.getAnnotation(Operation.class);

View File

@ -75,7 +75,7 @@ public class PrimitiveCollectionInvocationHandler<T extends Serializable>
invokeSelfMethod(method, args);
return proxy;
} else if (isSelfMethod(method, args)) {
} else if (isSelfMethod(method)) {
return invokeSelfMethod(method, args);
} else if ("operations".equals(method.getName()) && ArrayUtils.isEmpty(args)) {
final Class<?> returnType = method.getReturnType();

View File

@ -75,7 +75,7 @@ public class StructuredComposableInvokerInvocationHandler<T, O extends Operation
return super.invoke(proxy, method, args);
} else if ("operations".equals(method.getName()) && ArrayUtils.isEmpty(args)) {
return super.invoke(proxy, method, args);
} else if (isSelfMethod(method, args)) {
} else if (isSelfMethod(method)) {
return invokeSelfMethod(method, args);
} else {
throw new NoSuchMethodException(method.getName());

View File

@ -378,7 +378,6 @@ public final class CoreUtils {
public static URIBuilder buildEditLink(
final EdmEnabledODataClient client,
final String entitySetURI,
final ClientEntity entity,
final Object key) {
if (key == null) {
@ -506,7 +505,7 @@ public final class CoreUtils {
final Object complex = Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] { getter.getReturnType() },
ComplexInvocationHandler.getInstance(property.getName(), typeHandler, getter.getReturnType()));
ComplexInvocationHandler.getInstance(typeHandler, getter.getReturnType()));
populate(client, typeHandler, complex, Property.class, property.getValue().asComplex().iterator());
setPropertyValue(bean, getter, complex);
@ -530,7 +529,7 @@ public final class CoreUtils {
final Object collItem = Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] { collItemClass },
ComplexInvocationHandler.getInstance(property.getName(), typeHandler, collItemClass));
ComplexInvocationHandler.getInstance(typeHandler, collItemClass));
populate(client, typeHandler, collItem, Property.class, value.asComplex().iterator());
collection.add(collItem);

File diff suppressed because it is too large Load Diff

View File

@ -40,7 +40,6 @@ import javax.ws.rs.core.UriInfo;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.fit.metadata.Metadata;
import org.apache.olingo.fit.methods.PATCH;
import org.apache.olingo.fit.utils.Accept;
@ -54,7 +53,7 @@ import org.springframework.stereotype.Service;
public class Demo extends Services {
public Demo() throws IOException {
super(new Metadata(FSManager.instance(ODataServiceVersion.V40).
super(new Metadata(FSManager.instance().
readRes("demo" + StringUtils.capitalize(Constants.get(ConstantKey.METADATA)), Accept.XML)));
}
@ -166,9 +165,8 @@ public class Demo extends Services {
@HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
@PathParam("entitySetName") final String entitySetName,
@PathParam("entityId") final String entityId,
@QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
final String value) {
return super.replaceMediaEntity(uriInfo, prefer, entitySetName, entityId, format, value);
return super.replaceMediaEntity(uriInfo, prefer, entitySetName, entityId, value);
}
}

View File

@ -40,7 +40,6 @@ import javax.ws.rs.core.UriInfo;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.fit.metadata.Metadata;
import org.apache.olingo.fit.utils.Accept;
import org.apache.olingo.fit.utils.ConstantKey;
@ -53,8 +52,8 @@ import org.springframework.stereotype.Service;
public class OpenType extends Services {
public OpenType() throws IOException {
super(new Metadata(FSManager.instance(ODataServiceVersion.V40).
readRes("openType" + StringUtils.capitalize(Constants.get(ConstantKey.METADATA)), Accept.XML)));
super(new Metadata(FSManager.instance()
.readRes("openType" + StringUtils.capitalize(Constants.get(ConstantKey.METADATA)), Accept.XML)));
}
private Response replaceServiceName(final Response response) {

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,6 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.fit.metadata.Metadata;
import org.apache.olingo.fit.utils.Accept;
import org.apache.olingo.fit.utils.ConstantKey;
@ -43,8 +42,8 @@ public class Vocabularies {
private final XMLUtilities xml;
public Vocabularies() throws IOException {
Metadata metadata = new Metadata(FSManager.instance(ODataServiceVersion.V40).readRes(
"vocabularies-" + Constants.get(ConstantKey.METADATA), Accept.XML));
Metadata metadata = new Metadata(FSManager.instance()
.readRes("vocabularies-" + Constants.get(ConstantKey.METADATA), Accept.XML));
xml = new XMLUtilities(metadata);
}
@ -55,8 +54,7 @@ public class Vocabularies {
try {
return xml.createResponse(
null,
FSManager.instance(ODataServiceVersion.V40).readRes(
"vocabularies-" + Constants.get(ConstantKey.METADATA), Accept.XML),
FSManager.instance().readRes("vocabularies-" + Constants.get(ConstantKey.METADATA), Accept.XML),
null,
Accept.XML);
} catch (Exception e) {
@ -71,7 +69,7 @@ public class Vocabularies {
try {
return xml.createResponse(
null,
FSManager.instance(ODataServiceVersion.V40).readFile(vocabulary, null),
FSManager.instance().readFile(vocabulary, null),
null,
Accept.XML);
} catch (Exception e) {

View File

@ -24,18 +24,10 @@ import java.util.Map;
public class EntitySet extends AbstractMetadataElement {
private final String name;
private String type;
private final boolean singleton;
// --------------------------
// V4 only
// --------------------------
private final Map<String, String> binding;
// --------------------------
public EntitySet(final String name, final boolean singleton) {
this.name = name;
this.singleton = singleton;

View File

@ -19,14 +19,13 @@
package org.apache.olingo.fit.rest;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.ext.Provider;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.rs.security.oauth2.filters.OAuthRequestFilter;
@Provider
public class OAuth2RequestFilter extends OAuthRequestFilter implements ContainerRequestFilter {
public class OAuth2RequestFilter extends OAuthRequestFilter {
@Override
public void filter(final ContainerRequestContext context) {

View File

@ -21,7 +21,6 @@ package org.apache.olingo.fit.serializer;
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;
@ -32,19 +31,15 @@ import org.apache.olingo.commons.api.Constants;
public class FITAtomDeserializer extends AtomDeserializer {
private static final Charset ENCODING = Charset.forName(Constants.UTF8);
public FITAtomDeserializer() {
super();
}
@Override
protected XMLEventReader getReader(final InputStream input) throws XMLStreamException {
final CharsetDecoder decoder = ENCODING.newDecoder();
decoder.onMalformedInput(CodingErrorAction.IGNORE);
decoder.onUnmappableCharacter(CodingErrorAction.IGNORE);
return FACTORY.createXMLEventReader(new InputStreamReader(input, decoder));
return FACTORY.createXMLEventReader(new InputStreamReader(input,
Charset.forName(Constants.UTF8).newDecoder()
.onMalformedInput(CodingErrorAction.IGNORE)
.onUnmappableCharacter(CodingErrorAction.IGNORE)));
}
}

View File

@ -34,7 +34,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.core.Response;
@ -70,38 +69,19 @@ public abstract class AbstractUtilities {
*/
protected static final Logger LOG = LoggerFactory.getLogger(AbstractUtilities.class);
protected static final Pattern ENTITY_URI_PATTERN = Pattern.compile(".*\\/.*\\(.*\\)");
/**
* Batch/Changeset content type.
*/
public static final String MULTIPART_CONTENT_TYPE = "multipart/mixed";
/**
* Batch item content type.
*/
public static final String ITEM_CONTENT_TYPE = "application/http";
/**
* Boundary key.
*/
public static final String BOUNDARY = "boundary";
protected final Metadata metadata;
protected final FSManager fsManager;
protected final ODataDeserializer atomDeserializer;
protected final ODataDeserializer jsonDeserializer;
protected final ODataSerializer atomSerializer;
protected final ODataSerializer jsonSerializer;
public AbstractUtilities(final Metadata metadata) throws IOException {
this.metadata = metadata;
fsManager = FSManager.instance(ODataServiceVersion.V40);
fsManager = FSManager.instance();
atomDeserializer = new FITAtomDeserializer();
jsonDeserializer = new JsonDeserializer(true);
atomSerializer = new AtomSerializer(true);

View File

@ -20,33 +20,31 @@ package org.apache.olingo.fit.utils;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.fit.UnsupportedMediaTypeException;
public enum Accept {
TEXT(ContentType.TEXT_PLAIN.getMimeType(), ".txt"),
XML(ContentType.APPLICATION_XML.getMimeType(), ".xml"),
ATOM(ContentType.APPLICATION_ATOM_XML.getMimeType(), ".xml"),
JSON(ContentType.APPLICATION_JSON.getMimeType() + ";odata.metadata=minimal", ".full.json"),
JSON_NOMETA(ContentType.APPLICATION_JSON.getMimeType() + ";odata.metadata=none", ".full.json"),
JSON_FULLMETA(ContentType.APPLICATION_JSON.getMimeType() + ";odata.metadata=full", ".full.json");
private final String contentTypeV4;
private final String fileExtension;
TEXT(ContentType.TEXT_PLAIN, ".txt"),
XML(ContentType.APPLICATION_XML, ".xml"),
ATOM(ContentType.APPLICATION_ATOM_XML, ".xml"),
JSON(ContentType.JSON, ".full.json"),
JSON_NOMETA(ContentType.JSON_NO_METADATA, ".full.json"),
JSON_FULLMETA(ContentType.JSON_FULL_METADATA, ".full.json");
private static Pattern allTypesPattern = Pattern.compile("(.*,)?\\*/\\*([,;].*)?");
Accept(final String contentTypeV4, final String fileExtension) {
this.contentTypeV4 = contentTypeV4;
private final ContentType contentType;
private final String fileExtension;
Accept(final ContentType contentType, final String fileExtension) {
this.contentType = contentType;
this.fileExtension = fileExtension;
}
@Override
public String toString() {
return contentTypeV4;
return contentType.toContentTypeString();
}
public String getExtension() {
@ -58,15 +56,14 @@ public enum Accept {
}
public static Accept parse(final String contentType, final Accept def) {
if (StringUtils.isBlank(contentType) || allTypesPattern.matcher(contentType).matches()) {
if (contentType == null || contentType.isEmpty() || allTypesPattern.matcher(contentType).matches()) {
return def;
} else if (contentType.startsWith(JSON_NOMETA.toString())) {
return JSON_NOMETA;
} else if (contentType.startsWith(JSON_FULLMETA.toString())) {
return JSON_FULLMETA;
} else if (contentType.startsWith(JSON.toString())
|| contentType.startsWith(ContentType.APPLICATION_JSON.getMimeType())) {
|| contentType.startsWith(ContentType.APPLICATION_JSON.toContentTypeString())) {
return JSON;
} else if (contentType.startsWith(XML.toString())) {
return XML;

View File

@ -27,7 +27,6 @@ import java.net.URI;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@ -40,7 +39,6 @@ import org.apache.commons.lang3.tuple.Pair;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import org.apache.olingo.fit.metadata.Metadata;
import org.codehaus.plexus.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -59,9 +57,6 @@ public abstract class Commons {
*/
protected static final Logger LOG = LoggerFactory.getLogger(Commons.class);
private static final EnumMap<ODataServiceVersion, Metadata> METADATA =
new EnumMap<ODataServiceVersion, Metadata>(ODataServiceVersion.class);
protected static final Pattern MULTIKEY_PATTERN = Pattern.compile("(.*=.*,?)+");
protected static final Map<String, Integer> SEQUENCE = new HashMap<String, Integer>();
@ -99,14 +94,11 @@ public abstract class Commons {
new ImmutablePair<String, EdmPrimitiveTypeKind>("ID", EdmPrimitiveTypeKind.Guid));
}
public static Metadata getMetadata(final ODataServiceVersion version) {
if (!METADATA.containsKey(version)) {
final InputStream is = Commons.class.getResourceAsStream("/" + version.name() + "/metadata.xml");
private static final Metadata METADATA =
new Metadata(Commons.class.getResourceAsStream("/" + ODataServiceVersion.V40.name() + "/metadata.xml"));
METADATA.put(version, new Metadata(is));
}
return METADATA.get(version);
public static Metadata getMetadata() {
return METADATA;
}
public static Map<String, Pair<String, EdmPrimitiveTypeKind>> getMediaContent() {
@ -115,13 +107,13 @@ public abstract class Commons {
public static String getEntityURI(final String entitySetName, final String entityKey) {
// expected singleton in case of null key
return entitySetName + (StringUtils.isNotBlank(entityKey) ? "(" + entityKey + ")" : "");
return entitySetName + (entityKey == null || entityKey.isEmpty() ? "" : "(" + entityKey + ")");
}
public static String getEntityBasePath(final String entitySetName, final String entityKey) {
// expected singleton in case of null key
return entitySetName + File.separatorChar
+ (StringUtils.isNotBlank(entityKey) ? getEntityKey(entityKey) + File.separatorChar : "");
+ (entityKey == null || entityKey.isEmpty() ? "" : getEntityKey(entityKey) + File.separatorChar);
}
public static String getLinksURI(final String entitySetName, final String entityId, final String linkName)
@ -138,7 +130,7 @@ public abstract class Commons {
public static String getLinksPath(final String basePath, final String linkName, final Accept accept)
throws IOException {
try {
return FSManager.instance(ODataServiceVersion.V40)
return FSManager.instance()
.getAbsolutePath(basePath + Constants.get(ConstantKey.LINKS_FILE_PATH)
+ File.separatorChar + linkName, accept);
} catch (Exception e) {
@ -281,7 +273,7 @@ public abstract class Commons {
public static String getETag(final String basePath) throws Exception {
try {
final InputStream is = FSManager.instance(ODataServiceVersion.V40).readFile(basePath + "etag", Accept.TEXT);
final InputStream is = FSManager.instance().readFile(basePath + "etag", Accept.TEXT);
if (is.available() <= 0) {
return null;
} else {

View File

@ -25,20 +25,13 @@ public enum ConstantKey {
ODATA_COUNT_NAME,
ODATA_METADATA_PREFIX,
ODATA_METADATA_ENTITY_SUFFIX,
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,
@ -66,6 +59,5 @@ public enum ConstantKey {
JSON_TYPE_SUFFIX,
JSON_ID_NAME,
JSON_EDITLINK_NAME,
XHTTP_HEADER_NAME;
XHTTP_HEADER_NAME
};

View File

@ -55,19 +55,12 @@ public class Constants {
"http://localhost:9080/stub/StaticService/V40/Static.svc/$metadata#");
constants.put(ConstantKey.ODATA_METADATA_ENTITY_SUFFIX, "/$entity");
constants.put(ConstantKey.ODATA_COUNT_NAME, "odata.count");
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.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, "metadata");

View File

@ -25,8 +25,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.EnumMap;
import java.util.Map;
import javax.ws.rs.NotFoundException;
@ -61,37 +59,34 @@ public class FSManager {
private final FileSystemManager fsManager;
private static Map<ODataServiceVersion, FSManager> instance =
new EnumMap<ODataServiceVersion, FSManager>(ODataServiceVersion.class);
private static FSManager instance = null;
private final ODataServiceVersion version;
public static FSManager instance(final ODataServiceVersion version) throws IOException {
if (!instance.containsKey(version)) {
instance.put(version, new FSManager(version));
public static FSManager instance() throws IOException {
if (instance == null) {
instance = new FSManager();
}
return instance.get(version);
return instance;
}
private FSManager(final ODataServiceVersion version) throws IOException {
this.version = version;
private FSManager() throws IOException {
fsManager = VFS.getManager();
final FileObject basePath = fsManager.resolveFile(RES_PREFIX + File.separatorChar + version.name());
final FileObject basePath =
fsManager.resolveFile(RES_PREFIX + File.separatorChar + ODataServiceVersion.V40.name());
final String absoluteBaseFolder = basePath.getURL().getPath();
for (FileObject fo : find(basePath, null)) {
if (fo.getType() == FileType.FILE
&& !fo.getName().getBaseName().contains("Metadata")
&& !fo.getName().getBaseName().contains("metadata")) {
final String path = fo.getURL().getPath().replace(absoluteBaseFolder, "//" + version.name());
final String path = fo.getURL().getPath().replace(absoluteBaseFolder, "//" + ODataServiceVersion.V40.name());
putInMemory(fo.getContent().getInputStream(), path);
}
}
}
public String getAbsolutePath(final String relativePath, final Accept accept) {
return File.separatorChar + version.name() + File.separatorChar + relativePath
return File.separatorChar + ODataServiceVersion.V40.name() + File.separatorChar + relativePath
+ (accept == null ? "" : accept.getExtension());
}

View File

@ -1,42 +0,0 @@
/*
* 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 com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;
import com.fasterxml.jackson.databind.ser.SerializerFactory;
public class InjectableSerializerProvider extends DefaultSerializerProvider {
private static final long serialVersionUID = 3432260063063739646L;
public InjectableSerializerProvider(
final SerializerProvider src, final SerializationConfig config, final SerializerFactory factory) {
super(src, config, factory);
}
@Override
public InjectableSerializerProvider createInstance(
final SerializationConfig config, final SerializerFactory factory) {
return this;
}
}

View File

@ -39,7 +39,6 @@ import org.apache.olingo.fit.metadata.Metadata;
import org.apache.olingo.fit.metadata.NavigationProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.InjectableValues;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
@ -48,21 +47,10 @@ import com.fasterxml.jackson.databind.node.TextNode;
public class JSONUtilities extends AbstractUtilities {
private final ObjectMapper mapper;
private final ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
public JSONUtilities(final Metadata metadata) throws IOException {
super(metadata);
mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.setInjectableValues(new InjectableValues.Std().
addValue(Boolean.class, Boolean.TRUE));
// addValue(ODataServiceVersion.class, version))
mapper.setSerializerProvider(new InjectableSerializerProvider(mapper.getSerializerProvider(),
mapper.getSerializationConfig().
// withAttribute(ODataServiceVersion.class, version).
withAttribute(Boolean.class, Boolean.TRUE),
mapper.getSerializerFactory()));
}
@Override

View File

@ -1,182 +0,0 @@
/*
* 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.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.ws.rs.NotFoundException;
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();
}
public void addEntitySet(final String entitySetName) {
if (!entitySets.containsKey(entitySetName)) {
entitySets.put(entitySetName, new EntitySet(entitySetName));
}
}
public void addLink(
final String entitySetName, final String linkName, final String targetName, final boolean isFeed) {
final EntitySet entitySet;
if (entitySets.containsKey(entitySetName)) {
entitySet = entitySets.get(entitySetName);
} else {
entitySet = new EntitySet(entitySetName);
entitySets.put(entitySetName, entitySet);
}
entitySet.add(linkName, targetName, isFeed);
}
public Set<String> getNavigationLinkNames(final String entitySetName) {
final Set<String> res = new HashSet<String>();
if (!entitySets.containsKey(entitySetName)) {
throw new NotFoundException();
}
for (NavigationLink navigationLink : entitySets.get(entitySetName).getLinks()) {
res.add(navigationLink.getName());
}
return res;
}
public boolean exists(final String entitySetName, final String linkName) {
try {
return getNavigationLinkNames(entitySetName).contains(linkName);
} catch (Exception e) {
return false;
}
}
public boolean isFeed(final String entitySetName, final String linkName) {
return entitySets.containsKey(entitySetName) && entitySets.get(entitySetName).isFeed(linkName);
}
public String getTargetName(final String entitySetName, final String linkName) {
if (!entitySets.containsKey(entitySetName)) {
throw new NotFoundException();
}
final String targetName = entitySets.get(entitySetName).getLink(linkName).getTargetName();
return targetName.substring(targetName.lastIndexOf(".") + 1);
}
private static class EntitySet {
private String name;
private Set<NavigationLink> links;
private boolean singleton;
public EntitySet(final String name) {
this.name = name;
links = new HashSet<NavigationLink>();
}
public void add(final String linkName, final String targetName, final boolean isFeed) {
links.add(new NavigationLink(linkName, targetName, isFeed));
}
public Set<NavigationLink> getLinks() {
return links;
}
public NavigationLink getLink(final String linkName) {
for (NavigationLink navigationLink : links) {
if (linkName.equalsIgnoreCase(navigationLink.getName())) {
return navigationLink;
}
}
throw new NotFoundException();
}
public boolean isFeed(final String linkName) {
try {
return getLink(linkName).isFeed();
} catch (Exception e) {
return false;
}
}
public boolean isSingleton() {
return singleton;
}
public void setSingleton(final boolean singleton) {
this.singleton = singleton;
}
@Override
public String toString() {
return name + ": " + links;
}
}
private static class NavigationLink {
private final String name;
private final String targetName;
private final boolean feed;
public NavigationLink(final String name, final String targetName, final boolean feed) {
this.name = name;
this.targetName = targetName;
this.feed = feed;
}
public String getName() {
return name;
}
public String getTargetName() {
return targetName;
}
public boolean isFeed() {
return feed;
}
@Override
public String toString() {
return name + "(feed: " + isFeed() + ")";
}
}
}

View File

@ -38,6 +38,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import javax.ws.rs.NotFoundException;
import javax.xml.namespace.QName;
@ -61,6 +62,8 @@ import org.apache.olingo.fit.metadata.NavigationProperty;
public class XMLUtilities extends AbstractUtilities {
private static final Pattern ENTITY_URI_PATTERN = Pattern.compile(".*\\/.*\\(.*\\)");
protected static XMLInputFactory ifactory = null;
protected static XMLOutputFactory ofactory = null;

View File

@ -18,9 +18,7 @@
*/
package org.apache.olingo.fit.proxy.demo.odatademo.types;
// CHECKSTYLE:OFF (Maven checkstyle)
import java.util.concurrent.Future;
// CHECKSTYLE:ON (Maven checkstyle)
import org.apache.olingo.ext.proxy.api.annotations.Key;
@ -30,9 +28,7 @@ import org.apache.olingo.ext.proxy.api.annotations.Key;
hasStream = false,
isAbstract = false,
baseType = "ODataDemo.Person")
public interface Customer
extends org.apache.olingo.ext.proxy.api.Annotatable,
Person {
public interface Customer extends Person {
@Override
Customer load();

View File

@ -18,9 +18,7 @@
*/
package org.apache.olingo.fit.proxy.demo.odatademo.types;
// CHECKSTYLE:OFF (Maven checkstyle)
import java.util.concurrent.Future;
// CHECKSTYLE:ON (Maven checkstyle)
import org.apache.olingo.ext.proxy.api.annotations.Key;
@ -30,9 +28,7 @@ import org.apache.olingo.ext.proxy.api.annotations.Key;
hasStream = false,
isAbstract = false,
baseType = "ODataDemo.Person")
public interface Employee
extends org.apache.olingo.ext.proxy.api.Annotatable,
Person {
public interface Employee extends Person {
@Override
Employee load();

View File

@ -18,9 +18,7 @@
*/
package org.apache.olingo.fit.proxy.demo.odatademo.types;
// CHECKSTYLE:OFF (Maven checkstyle)
import java.util.concurrent.Future;
// CHECKSTYLE:ON (Maven checkstyle)
import org.apache.olingo.ext.proxy.api.annotations.Key;
@ -30,9 +28,7 @@ import org.apache.olingo.ext.proxy.api.annotations.Key;
hasStream = false,
isAbstract = false,
baseType = "ODataDemo.Product")
public interface FeaturedProduct
extends org.apache.olingo.ext.proxy.api.Annotatable,
Product {
public interface FeaturedProduct extends Product {
@Override
FeaturedProduct load();

View File

@ -18,11 +18,8 @@
*/
package org.apache.olingo.fit.proxy.opentype.microsoft.test.odata.services.opentypesservice.types;
// CHECKSTYLE:OFF (Maven checkstyle)
import java.util.concurrent.Future;
// CHECKSTYLE:ON (Maven checkstyle)
import org.apache.olingo.ext.proxy.api.AbstractOpenType;
import org.apache.olingo.ext.proxy.api.annotations.Key;
@org.apache.olingo.ext.proxy.api.annotations.Namespace("Microsoft.Test.OData.Services.OpenTypesServiceV4")
@ -31,10 +28,7 @@ import org.apache.olingo.ext.proxy.api.annotations.Key;
hasStream = false,
isAbstract = false,
baseType = "Microsoft.Test.OData.Services.OpenTypesServiceV4.Row")
public interface IndexedRow
extends org.apache.olingo.ext.proxy.api.Annotatable,
Row,
AbstractOpenType {
public interface IndexedRow extends Row {
@Override
IndexedRow load();

View File

@ -18,9 +18,7 @@
*/
package org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types;
// CHECKSTYLE:OFF (Maven checkstyle)
import java.util.concurrent.Future;
// CHECKSTYLE:ON (Maven checkstyle)
import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
import org.apache.olingo.ext.proxy.api.annotations.Key;
@ -31,9 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.Key;
hasStream = false,
isAbstract = false,
baseType = "Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument")
public interface CreditCardPI
extends org.apache.olingo.ext.proxy.api.Annotatable,
PaymentInstrument {
public interface CreditCardPI extends PaymentInstrument {
@Override
CreditCardPI load();

View File

@ -18,9 +18,7 @@
*/
package org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types;
// CHECKSTYLE:OFF (Maven checkstyle)
import java.util.concurrent.Future;
// CHECKSTYLE:ON (Maven checkstyle)
import org.apache.olingo.ext.proxy.api.annotations.Key;
@ -30,9 +28,7 @@ import org.apache.olingo.ext.proxy.api.annotations.Key;
hasStream = false,
isAbstract = false,
baseType = "Microsoft.Test.OData.Services.ODataWCFService.Person")
public interface Customer
extends org.apache.olingo.ext.proxy.api.Annotatable,
Person {
public interface Customer extends Person {
@Override
Customer load();

View File

@ -18,9 +18,7 @@
*/
package org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types;
// CHECKSTYLE:OFF (Maven checkstyle)
import java.util.concurrent.Future;
// CHECKSTYLE:ON (Maven checkstyle)
import org.apache.olingo.ext.proxy.api.annotations.Key;
@ -30,9 +28,7 @@ import org.apache.olingo.ext.proxy.api.annotations.Key;
hasStream = false,
isAbstract = false,
baseType = "Microsoft.Test.OData.Services.ODataWCFService.Person")
public interface Employee
extends org.apache.olingo.ext.proxy.api.Annotatable,
Person {
public interface Employee extends Person {
@Override
Employee load();

View File

@ -18,12 +18,9 @@
*/
package org.apache.olingo.fit.proxy.staticservice.microsoft.test.odata.services.odatawcfservice.types;
// CHECKSTYLE:OFF (Maven checkstyle)
import java.util.concurrent.Future;
// CHECKSTYLE:ON (Maven checkstyle)
import org.apache.olingo.ext.proxy.api.AbstractEntitySet;
import org.apache.olingo.ext.proxy.api.AbstractOpenType;
import org.apache.olingo.ext.proxy.api.annotations.Key;
@org.apache.olingo.ext.proxy.api.annotations.Namespace("Microsoft.Test.OData.Services.ODataWCFService")
@ -32,10 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.Key;
hasStream = false,
isAbstract = false,
baseType = "Microsoft.Test.OData.Services.ODataWCFService.Company")
public interface PublicCompany
extends org.apache.olingo.ext.proxy.api.Annotatable,
Company,
AbstractOpenType {
public interface PublicCompany extends Company {
@Override
PublicCompany load();

View File

@ -24,6 +24,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import java.net.URI;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -553,11 +554,11 @@ public class EntityReferencesITCase extends AbstractParamTecSvcITCase {
.getReferenceSingleChangeRequest(new URI(SERVICE_URI), uri, reference)
.execute();
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
final String cookie = response.getHeader(HttpHeader.SET_COOKIE).iterator().next();
Map<QueryOption, Object> expandOptions = new HashMap<QueryOption, Object>();
Map<QueryOption, Object> expandOptions = new EnumMap<QueryOption, Object>(QueryOption.class);
expandOptions.put(QueryOption.EXPAND, NAV_PROPERTY_ET_KEY_NAV_ONE);
final URI getURI = getClient().newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_TWO_KEY_NAV)
.appendKeySegment(esTwoKeyNavKey)
@ -601,12 +602,12 @@ public class EntityReferencesITCase extends AbstractParamTecSvcITCase {
.getReferenceAddingRequest(new URI(SERVICE_URI), uri, reference)
.execute();
assertEquals(HttpStatusCode.NO_CONTENT.getStatusCode(), response.getStatusCode());
final String cookie = response.getHeader(HttpHeader.SET_COOKIE).iterator().next();
final Map<QueryOption, Object> expandOptions = new HashMap<QueryOption, Object>();
final Map<QueryOption, Object> expandOptions = new EnumMap<QueryOption, Object>(QueryOption.class);
expandOptions.put(QueryOption.EXPAND, NAV_PROPERTY_ET_KEY_NAV_MANY);
expandOptions.put(QueryOption.FILTER, "PropertyInt16 eq 1");
final URI getURI = getClient().newURIBuilder(SERVICE_URI)
.appendEntitySetSegment(ES_TWO_KEY_NAV)
.appendKeySegment(esTwoKeyNavKey)

View File

@ -23,6 +23,8 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.net.URI;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -49,11 +51,10 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
@Test
public void filter() {
Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
options.put(QueryOption.FILTER, "PropertyString eq '2'");
final ODataRetrieveResponse<ClientEntitySet> response =
buildRequest(ES_TWO_KEY_NAV, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, options);
buildRequest(ES_TWO_KEY_NAV, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
Collections.singletonMap(QueryOption.FILTER, (Object) "PropertyString eq '2'"));
final List<ClientEntity> entities = response.getBody().getEntities();
assertEquals(4, entities.size());
@ -87,11 +88,9 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
@Test
public void orderBy() {
Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
options.put(QueryOption.ORDERBY, "PropertyString desc");
final ODataRetrieveResponse<ClientEntitySet> response =
buildRequest(ES_TWO_KEY_NAV, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, options);
buildRequest(ES_TWO_KEY_NAV, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
Collections.<QueryOption, Object> singletonMap(QueryOption.ORDERBY, "PropertyString desc"));
final List<ClientEntity> entities = response.getBody().getEntities();
assertEquals(4, entities.size());
@ -117,11 +116,9 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
@Test
public void skip() {
Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
options.put(QueryOption.SKIP, "1");
final ODataRetrieveResponse<ClientEntitySet> response =
buildRequest(ES_KEY_NAV, NAV_PROPERTY_ET_KEY_NAV_MANY, options);
buildRequest(ES_KEY_NAV, NAV_PROPERTY_ET_KEY_NAV_MANY,
Collections.singletonMap(QueryOption.SKIP, (Object) "1"));
final List<ClientEntity> entities = response.getBody().getEntities();
assertEquals(3, entities.size());
@ -148,11 +145,9 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
@Test
public void top() {
Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
options.put(QueryOption.TOP, "1");
final ODataRetrieveResponse<ClientEntitySet> response =
buildRequest(ES_KEY_NAV, NAV_PROPERTY_ET_KEY_NAV_MANY, options);
buildRequest(ES_KEY_NAV, NAV_PROPERTY_ET_KEY_NAV_MANY,
Collections.<QueryOption, Object> singletonMap(QueryOption.TOP, "1"));
final List<ClientEntity> entities = response.getBody().getEntities();
assertEquals(3, entities.size());
@ -179,7 +174,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
@Test
public void combinedSystemQueryOptions() {
Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
Map<QueryOption, Object> options = new EnumMap<QueryOption, Object>(QueryOption.class);
options.put(QueryOption.SELECT, "PropertyInt16,PropertyString");
options.put(QueryOption.FILTER, "PropertyInt16 eq 1");
options.put(QueryOption.SKIP, "1");
@ -217,7 +212,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
@Ignore("Server do not support navigation property count annotations")
public void count() {
final ODataClient client = getEdmEnabledClient();
Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
Map<QueryOption, Object> options = new EnumMap<QueryOption, Object>(QueryOption.class);
options.put(QueryOption.SELECT, "PropertyInt16");
options.put(QueryOption.COUNT, true);
@ -255,14 +250,14 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
public void singleEntityWithExpand() {
/* A single entity request will be dispatched to a different processor method than entity set request */
final ODataClient client = getEdmEnabledClient();
Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
options.put(QueryOption.FILTER, "PropertyInt16 lt 2");
Map<String, Object> keys = new HashMap<String, Object>();
keys.put("PropertyInt16", 1);
keys.put("PropertyString", "1");
final URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_TWO_KEY_NAV).appendKeySegment(keys)
.expandWithOptions(NAV_PROPERTY_ET_KEY_NAV_MANY, options).build();
.expandWithOptions(NAV_PROPERTY_ET_KEY_NAV_MANY,
Collections.singletonMap(QueryOption.FILTER, (Object) "PropertyInt16 lt 2"))
.build();
final ODataRetrieveResponse<ClientEntity> response =
client.getRetrieveRequestFactory().getEntityRequest(uri).execute();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
@ -275,11 +270,12 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
@Test
public void URIEscaping() {
Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
options.put(QueryOption.FILTER, "PropertyInt16 eq 1"
+ " and PropertyComp/PropertyComp/PropertyDuration eq duration'PT1S' and length(PropertyString) gt 4");
final ODataRetrieveResponse<ClientEntitySet> response =
buildRequest(ES_TWO_KEY_NAV, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, options);
buildRequest(ES_TWO_KEY_NAV, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
Collections.<QueryOption, Object> singletonMap(QueryOption.FILTER,
"PropertyInt16 eq 1"
+ " and PropertyComp/PropertyComp/PropertyDuration eq duration'PT1S'"
+ " and length(PropertyString) gt 4"));
final List<ClientEntity> entities = response.getBody().getEntities();
assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
@ -296,7 +292,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
// Define filters to select explicit the entities at any level => Circle
final ODataClient client = getEdmEnabledClient();
Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
Map<QueryOption, Object> options = new EnumMap<QueryOption, Object>(QueryOption.class);
options.put(QueryOption.EXPAND, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
+ "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
+ "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY + "))");
@ -371,7 +367,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
@Test
public void systemQueryOptionOnThirdLevel() {
final ODataClient client = getEdmEnabledClient();
Map<QueryOption, Object> options = new HashMap<QueryOption, Object>();
Map<QueryOption, Object> options = new EnumMap<QueryOption, Object>(QueryOption.class);
options.put(QueryOption.EXPAND, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
+ "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
+ "($expand=" + NAV_PROPERTY_ET_TWO_KEY_NAV_MANY
@ -444,7 +440,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
@Test
public void expandWithSearchQuery() {
final ODataClient client = getEdmEnabledClient();
Map<QueryOption, Object> expandOptions = new HashMap<QueryOption, Object>();
Map<QueryOption, Object> expandOptions = new EnumMap<QueryOption, Object>(QueryOption.class);
expandOptions.put(QueryOption.SEARCH, "abc");
expandOptions.put(QueryOption.FILTER, "PropertyInt16 eq 1");
@ -464,12 +460,10 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
@Test
public void expandWithLevels() {
final ODataClient client = getEdmEnabledClient();
Map<QueryOption, Object> expandOptions = new HashMap<QueryOption, Object>();
expandOptions.put(QueryOption.LEVELS, 2);
// expand=*($levels=2)
URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
.expandWithOptions("*", expandOptions)
.expandWithOptions("*", Collections.<QueryOption, Object> singletonMap(QueryOption.LEVELS, 2))
.build();
try {
@ -479,10 +473,9 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
}
// expand=NavPropertyETTwoKeyNavMany($levels=2)
expandOptions.clear();
expandOptions.put(QueryOption.LEVELS, 2);
uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
.expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, expandOptions)
.expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
Collections.<QueryOption, Object> singletonMap(QueryOption.LEVELS, 2))
.build();
try {
@ -492,10 +485,10 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
}
// expand=NavPropertyETTwoKeyNavMany($expand=NavPropertyETTwoKeyNavMany($levels=2))
expandOptions.clear();
expandOptions.put(QueryOption.EXPAND, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY + "($levels=2)");
uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
.expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, expandOptions)
.expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
Collections.<QueryOption, Object> singletonMap(QueryOption.EXPAND,
NAV_PROPERTY_ET_TWO_KEY_NAV_MANY + "($levels=2)"))
.build();
try {
@ -505,10 +498,9 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
}
// expand=NavPropertyETTwoKeyNavMany($expand=NavPropertyETTwoKeyNavMany($levels=2);$levels=3)
expandOptions.clear();
expandOptions.put(QueryOption.LEVELS, 2);
uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
.expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, expandOptions)
.expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY,
Collections.<QueryOption, Object> singletonMap(QueryOption.LEVELS, 2))
.build();
try {
@ -518,7 +510,7 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractParamTecSvcITCas
}
// expand=NavPropertyETTwoKeyNavMany($expand=NavPropertyETTwoKeyNavMany($levels=2))
expandOptions.clear();
Map<QueryOption, Object> expandOptions = new EnumMap<QueryOption, Object>(QueryOption.class);
expandOptions.put(QueryOption.EXPAND, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY + "($levels=2)");
expandOptions.put(QueryOption.LEVELS, 3);
uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)

View File

@ -1,114 +0,0 @@
/*
* 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.core.domain;
import java.net.URI;
import org.apache.olingo.client.api.domain.AbstractClientPayload;
import org.apache.olingo.client.api.domain.ClientEntitySet;
public abstract class AbstractClientEntitySet extends AbstractClientPayload implements ClientEntitySet {
/**
* Link to the next page.
*/
private URI next;
/**
* Number of ODataEntities contained in this entity set.
* <br/>
* If <tt>$count</tt> was requested, this value comes from there.
*/
private Integer count;
/**
* Constructor.
*/
public AbstractClientEntitySet() {
super(null);
}
/**
* Constructor.
*
* @param next next link.
*/
public AbstractClientEntitySet(final URI next) {
super(null);
this.next = next;
}
@Override
public URI getNext() {
return next;
}
@Override
public Integer getCount() {
return count;
}
@Override
public void setCount(final int count) {
this.count = count;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((count == null) ? 0 : count.hashCode());
result = prime * result + ((next == null) ? 0 : next.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof AbstractClientEntitySet)) {
return false;
}
AbstractClientEntitySet other = (AbstractClientEntitySet) obj;
if (count == null) {
if (other.count != null) {
return false;
}
} else if (!count.equals(other.count)) {
return false;
}
if (next == null) {
if (other.next != null) {
return false;
}
} else if (!next.equals(other.next)) {
return false;
}
return true;
}
@Override
public String toString() {
return "AbstractClientEntitySet [next=" + next + ", count=" + count + "super[" + super.toString() + "]]";
}
}

View File

@ -29,7 +29,7 @@ import org.apache.olingo.client.api.domain.ClientEnumValue;
import org.apache.olingo.client.api.domain.ClientValue;
public class ClientCollectionValueImpl<OV extends ClientValue> extends AbstractClientValue
implements ClientCollectionValue<OV>, ClientValue {
implements ClientCollectionValue<OV> {
/**
* Constructor.

View File

@ -22,11 +22,24 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import org.apache.olingo.client.api.domain.AbstractClientPayload;
import org.apache.olingo.client.api.domain.ClientAnnotation;
import org.apache.olingo.client.api.domain.ClientEntity;
import org.apache.olingo.client.api.domain.ClientEntitySet;
public class ClientEntitySetImpl extends AbstractClientEntitySet implements ClientEntitySet {
public class ClientEntitySetImpl extends AbstractClientPayload implements ClientEntitySet {
/**
* Link to the next page.
*/
private final URI next;
/**
* Number of ODataEntities contained in this entity set.
* <br/>
* If <tt>$count</tt> was requested, this value comes from there.
*/
private Integer count;
private URI deltaLink;
@ -35,11 +48,28 @@ public class ClientEntitySetImpl extends AbstractClientEntitySet implements Clie
private final List<ClientAnnotation> annotations = new ArrayList<ClientAnnotation>();
public ClientEntitySetImpl() {
super();
super(null);
next = null;
}
public ClientEntitySetImpl(final URI next) {
super(next);
super(null);
this.next = next;
}
@Override
public URI getNext() {
return next;
}
@Override
public Integer getCount() {
return count;
}
@Override
public void setCount(final int count) {
this.count = count;
}
@Override
@ -66,6 +96,8 @@ public class ClientEntitySetImpl extends AbstractClientEntitySet implements Clie
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((count == null) ? 0 : count.hashCode());
result = prime * result + ((next == null) ? 0 : next.hashCode());
result = prime * result + ((annotations == null) ? 0 : annotations.hashCode());
result = prime * result + ((deltaLink == null) ? 0 : deltaLink.hashCode());
result = prime * result + ((entities == null) ? 0 : entities.hashCode());
@ -77,40 +109,20 @@ public class ClientEntitySetImpl extends AbstractClientEntitySet implements Clie
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
if (obj == null || !(obj instanceof ClientEntitySetImpl)) {
return false;
}
if (!(obj instanceof ClientEntitySetImpl)) {
return false;
}
ClientEntitySetImpl other = (ClientEntitySetImpl) obj;
if (annotations == null) {
if (other.annotations != null) {
return false;
}
} else if (!annotations.equals(other.annotations)) {
return false;
}
if (deltaLink == null) {
if (other.deltaLink != null) {
return false;
}
} else if (!deltaLink.equals(other.deltaLink)) {
return false;
}
if (entities == null) {
if (other.entities != null) {
return false;
}
} else if (!entities.equals(other.entities)) {
return false;
}
return true;
final ClientEntitySetImpl other = (ClientEntitySetImpl) obj;
return (count == null ? other.count == null : count.equals(other.count))
&& (next == null ? other.next == null : next.equals(other.next))
&& annotations.equals(other.annotations)
&& (deltaLink == null ? other.deltaLink == null : deltaLink.equals(other.deltaLink))
&& entities.equals(other.entities);
}
@Override
public String toString() {
return "ClientEntitySetImpl [deltaLink=" + deltaLink + ", entities=" + entities + ", annotations=" + annotations
+ "super[" + super.toString() + "]]";
+ ", next=" + next + ", count=" + count + "super[" + super.toString() + "]]";
}
}

View File

@ -21,11 +21,10 @@ package org.apache.olingo.client.core.domain;
import java.math.BigDecimal;
import java.util.UUID;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.client.api.domain.AbstractClientValue;
import org.apache.olingo.client.api.domain.ClientEnumValue;
import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
import org.apache.olingo.client.api.domain.ClientValue;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
@ -33,7 +32,7 @@ import org.apache.olingo.commons.api.edm.EdmType;
import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
public class ClientPrimitiveValueImpl extends AbstractClientValue implements ClientValue, ClientPrimitiveValue {
public class ClientPrimitiveValueImpl extends AbstractClientValue implements ClientPrimitiveValue {
public static class BuilderImpl implements Builder {

View File

@ -18,30 +18,21 @@
*/
package org.apache.olingo.client.core.domain;
import org.apache.olingo.client.api.domain.ClientAnnotatable;
import org.apache.olingo.client.api.domain.ClientAnnotation;
import org.apache.olingo.client.api.domain.ClientCollectionValue;
import org.apache.olingo.client.api.domain.ClientComplexValue;
import org.apache.olingo.client.api.domain.ClientEnumValue;
import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
import org.apache.olingo.client.api.domain.ClientProperty;
import org.apache.olingo.client.api.domain.ClientValuable;
import org.apache.olingo.client.api.domain.ClientValue;
import java.util.ArrayList;
import java.util.List;
public final class ClientPropertyImpl implements ClientProperty, ClientAnnotatable, ClientValuable {
import org.apache.olingo.client.api.domain.ClientAnnotation;
import org.apache.olingo.client.api.domain.ClientProperty;
import org.apache.olingo.client.api.domain.ClientValue;
public final class ClientPropertyImpl extends ClientValuableImpl implements ClientProperty {
private final List<ClientAnnotation> annotations = new ArrayList<ClientAnnotation>();
private final String name;
private final ClientValue value;
private final ClientValuable valuable;
public ClientPropertyImpl(final String name, final ClientValue value) {
super(value);
this.name = name;
this.value = value;
this.valuable = new ClientValuableImpl(value);
}
/**
@ -54,16 +45,6 @@ public final class ClientPropertyImpl implements ClientProperty, ClientAnnotatab
return name;
}
/**
* Returns property value.
*
* @return property value.
*/
@Override
public ClientValue getValue() {
return value;
}
/**
* Checks if has null value.
*
@ -74,87 +55,18 @@ public final class ClientPropertyImpl implements ClientProperty, ClientAnnotatab
return value == null || value.isPrimitive() && value.asPrimitive().toValue() == null;
}
/**
* Checks if has primitive value.
*
* @return 'TRUE' if has primitive value; 'FALSE' otherwise.
*/
@Override
public boolean hasPrimitiveValue() {
return !hasNullValue() && value.isPrimitive();
}
/**
* Gets primitive value.
*
* @return primitive value if exists; null otherwise.
*/
@Override
public ClientPrimitiveValue getPrimitiveValue() {
return hasPrimitiveValue() ? value.asPrimitive() : null;
}
/**
* Checks if has complex value.
*
* @return 'TRUE' if has complex value; 'FALSE' otherwise.
*/
@Override
public boolean hasComplexValue() {
return !hasNullValue() && value.isComplex();
}
/**
* Checks if has collection value.
*
* @return 'TRUE' if has collection value; 'FALSE' otherwise.
*/
@Override
public boolean hasCollectionValue() {
return !hasNullValue() && value.isCollection();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
if (obj == null || !(obj instanceof ClientPropertyImpl)) {
return false;
}
if (!(obj instanceof ClientPropertyImpl)) {
return false;
}
ClientPropertyImpl other = (ClientPropertyImpl) obj;
if (annotations == null) {
if (other.annotations != null) {
return false;
}
} else if (!annotations.equals(other.annotations)) {
return false;
}
if (name == null) {
if (other.name != null) {
return false;
}
} else if (!name.equals(other.name)) {
return false;
}
if (valuable == null) {
if (other.valuable != null) {
return false;
}
} else if (!valuable.equals(other.valuable)) {
return false;
}
if (value == null) {
if (other.value != null) {
return false;
}
} else if (!value.equals(other.value)) {
return false;
}
return true;
final ClientPropertyImpl other = (ClientPropertyImpl) obj;
return annotations.equals(other.annotations)
&& (name == null ? other.name == null : name.equals(other.name))
&& (value == null ? other.value == null : value.equals(other.value));
}
@Override
@ -163,31 +75,10 @@ public final class ClientPropertyImpl implements ClientProperty, ClientAnnotatab
int result = 1;
result = prime * result + ((annotations == null) ? 0 : annotations.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((valuable == null) ? 0 : valuable.hashCode());
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public boolean hasEnumValue() {
return valuable.hasEnumValue();
}
@Override
public ClientEnumValue getEnumValue() {
return valuable.getEnumValue();
}
@Override
public ClientComplexValue getComplexValue() {
return valuable.getComplexValue();
}
@Override
public ClientCollectionValue<ClientValue> getCollectionValue() {
return valuable.getCollectionValue();
}
@Override
public List<ClientAnnotation> getAnnotations() {
return annotations;
@ -195,10 +86,6 @@ public final class ClientPropertyImpl implements ClientProperty, ClientAnnotatab
@Override
public String toString() {
return "ODataPropertyImpl{"
+ "name=" + getName()
+ ",valuable=" + valuable
+ ", annotations=" + annotations
+ '}';
return "ClientPropertyImpl{" + "name=" + name + ", value=" + value + ", annotations=" + annotations + '}';
}
}

View File

@ -25,9 +25,9 @@ import org.apache.olingo.client.api.domain.ClientPrimitiveValue;
import org.apache.olingo.client.api.domain.ClientValuable;
import org.apache.olingo.client.api.domain.ClientValue;
public final class ClientValuableImpl implements ClientValuable {
public class ClientValuableImpl implements ClientValuable {
private final ClientValue value;
protected final ClientValue value;
public ClientValuableImpl(final ClientValue value) {
this.value = value;
@ -60,9 +60,7 @@ public final class ClientValuableImpl implements ClientValuable {
@Override
public ClientCollectionValue<ClientValue> getCollectionValue() {
return hasCollectionValue()
? getValue().<ClientValue> asCollection()
: null;
return hasCollectionValue() ? getValue().<ClientValue> asCollection() : null;
}
@Override
@ -72,9 +70,7 @@ public final class ClientValuableImpl implements ClientValuable {
@Override
public ClientComplexValue getComplexValue() {
return hasComplexValue()
? getValue().asComplex()
: null;
return hasComplexValue() ? getValue().asComplex() : null;
}
@Override
@ -84,9 +80,7 @@ public final class ClientValuableImpl implements ClientValuable {
@Override
public ClientEnumValue getEnumValue() {
return hasEnumValue()
? getValue().asEnum()
: null;
return hasEnumValue() ? getValue().asEnum() : null;
}
@Override
@ -99,9 +93,7 @@ public final class ClientValuableImpl implements ClientValuable {
}
ClientValuableImpl that = (ClientValuableImpl) o;
return !(value != null ? !value.equals(that.value) : that.value != null);
}
@Override
@ -111,8 +103,6 @@ public final class ClientValuableImpl implements ClientValuable {
@Override
public String toString() {
return "ClientValuableImpl{" +
"value=" + value +
'}';
return "ClientValuableImpl{" + "value=" + value + '}';
}
}

View File

@ -714,7 +714,7 @@ public class ODataBinderImpl implements ODataBinder {
if (propertyType == null || propertyType.equals(EdmPrimitiveTypeKind.String.getFullQualifiedName().toString())) {
typeInfo = new EdmTypeInfo.Builder().setTypeExpression(typeName.toString()).build();
} else if(isPrimiteveType(typeName)) {
// Inheritance is not allowed for primitve types, so we use the type given by the EDM
// Inheritance is not allowed for primitive types, so we use the type given by the EDM.
typeInfo = new EdmTypeInfo.Builder().setTypeExpression(typeName.toString()).build();
} else {
typeInfo = new EdmTypeInfo.Builder().setTypeExpression(propertyType).build();

View File

@ -25,9 +25,7 @@ import org.junit.BeforeClass;
public abstract class AbstractTest {
protected static ODataClient v4Client;
protected abstract ODataClient getClient();
protected static final ODataClient client = ODataClientFactory.getClient();
@BeforeClass
public static void setUp() {
@ -38,11 +36,6 @@ public abstract class AbstractTest {
XMLUnit.setCompareUnmatched(false);
}
@BeforeClass
public static void setClientInstances() {
v4Client = ODataClientFactory.getClient();
}
protected String getSuffix(final ContentType contentType) {
return contentType.isCompatible(ContentType.APPLICATION_ATOM_SVC)
|| contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)

View File

@ -30,17 +30,11 @@ import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.commons.api.format.ContentType;
import org.custommonkey.xmlunit.Diff;
public class AtomTest extends JSONTest {
@Override
protected ODataClient getClient() {
return v4Client;
}
@Override
protected ContentType getODataPubFormat() {
return ContentType.APPLICATION_ATOM_XML;

View File

@ -26,7 +26,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.data.ResWrap;
import org.apache.olingo.client.api.domain.ClientEntity;
import org.apache.olingo.client.api.domain.ClientEntitySet;
@ -37,23 +36,18 @@ import org.junit.Test;
public class EntitySetTest extends AbstractTest {
@Override
protected ODataClient getClient() {
return v4Client;
}
private void read(final ContentType contentType) throws IOException, ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("Customers." + getSuffix(contentType));
final ClientEntitySet entitySet = getClient().getBinder().getODataEntitySet(
getClient().getDeserializer(contentType).toEntitySet(input));
final ClientEntitySet entitySet = client.getBinder().getODataEntitySet(
client.getDeserializer(contentType).toEntitySet(input));
assertNotNull(entitySet);
assertEquals(2, entitySet.getEntities().size());
assertNull(entitySet.getNext());
final ClientEntitySet written =
getClient().getBinder().getODataEntitySet(new ResWrap<EntityCollection>((URI) null, null,
getClient().getBinder().getEntitySet(entitySet)));
client.getBinder().getODataEntitySet(new ResWrap<EntityCollection>((URI) null, null,
client.getBinder().getEntitySet(entitySet)));
assertEquals(entitySet, written);
}
@ -69,8 +63,8 @@ public class EntitySetTest extends AbstractTest {
private void ref(final ContentType contentType) throws ODataDeserializerException {
final InputStream input = getClass().getResourceAsStream("collectionOfEntityReferences." + getSuffix(contentType));
final ClientEntitySet entitySet = getClient().getBinder().getODataEntitySet(
getClient().getDeserializer(contentType).toEntitySet(input));
final ClientEntitySet entitySet = client.getBinder().getODataEntitySet(
client.getDeserializer(contentType).toEntitySet(input));
assertNotNull(entitySet);
for (ClientEntity entity : entitySet.getEntities()) {
@ -79,8 +73,8 @@ public class EntitySetTest extends AbstractTest {
entitySet.setCount(entitySet.getEntities().size());
final ClientEntitySet written =
getClient().getBinder().getODataEntitySet(new ResWrap<EntityCollection>((URI) null, null,
getClient().getBinder().getEntitySet(entitySet)));
client.getBinder().getODataEntitySet(new ResWrap<EntityCollection>((URI) null, null,
client.getBinder().getEntitySet(entitySet)));
assertEquals(entitySet, written);
}

View File

@ -50,11 +50,6 @@ import org.junit.Test;
public class EntityTest extends AbstractTest {
@Override
protected ODataClient getClient() {
return v4Client;
}
private EdmEnabledODataClient getEdmEnabledClient() {
return new EdmEnabledODataClientImpl(null, null, null) {
@ -78,8 +73,8 @@ public class EntityTest extends AbstractTest {
private void singleton(final ContentType contentType) throws Exception {
final InputStream input = getClass().getResourceAsStream("VipCustomer." + getSuffix(contentType));
final ClientEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(contentType).toEntity(input));
final ClientEntity entity = client.getBinder().getODataEntity(
client.getDeserializer(contentType).toEntity(input));
assertNotNull(entity);
assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Customer", entity.getTypeName().toString());
@ -120,8 +115,8 @@ public class EntityTest extends AbstractTest {
// operations won't get serialized
entity.getOperations().clear();
final ClientEntity written = getClient().getBinder().getODataEntity(
new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
final ClientEntity written = client.getBinder().getODataEntity(
new ResWrap<Entity>((URI) null, null, client.getBinder().getEntity(entity)));
assertEquals(entity, written);
input.close();
}
@ -138,8 +133,8 @@ public class EntityTest extends AbstractTest {
private void withEnums(final ContentType contentType) throws Exception {
final InputStream input = getClass().getResourceAsStream("Products_5." + getSuffix(contentType));
final ClientEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(contentType).toEntity(input));
final ClientEntity entity = client.getBinder().getODataEntity(
client.getDeserializer(contentType).toEntity(input));
assertNotNull(entity);
final ClientProperty skinColor = entity.getProperty("SkinColor");
@ -156,8 +151,8 @@ public class EntityTest extends AbstractTest {
// operations won't get serialized
entity.getOperations().clear();
final ClientEntity written = getClient().getBinder().getODataEntity(
new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
final ClientEntity written = client.getBinder().getODataEntity(
new ResWrap<Entity>((URI) null, null, client.getBinder().getEntity(entity)));
assertEquals(entity, written);
input.close();
}
@ -175,8 +170,8 @@ public class EntityTest extends AbstractTest {
private void withInlineEntitySet(final ContentType contentType) throws Exception {
final InputStream input = getClass().getResourceAsStream(
"Accounts_101_expand_MyPaymentInstruments." + getSuffix(contentType));
final ClientEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(contentType).toEntity(input));
final ClientEntity entity = client.getBinder().getODataEntity(
client.getDeserializer(contentType).toEntity(input));
assertNotNull(entity);
final ClientLink instruments = entity.getNavigationLink("MyPaymentInstruments");
@ -191,8 +186,8 @@ public class EntityTest extends AbstractTest {
inline.getEntitySet().setCount(3);
// operations won't get serialized
entity.getOperations().clear();
final ClientEntity written = getClient().getBinder().getODataEntity(
new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
final ClientEntity written = client.getBinder().getODataEntity(
new ResWrap<Entity>((URI) null, null, client.getBinder().getEntity(entity)));
assertEquals(entity, written);
input.close();
}
@ -210,16 +205,16 @@ public class EntityTest extends AbstractTest {
private void mediaEntity(final ContentType contentType) throws Exception {
final InputStream input = getClass().getResourceAsStream(
"Advertisements_f89dee73-af9f-4cd4-b330-db93c25ff3c7." + getSuffix(contentType));
final ClientEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(contentType).toEntity(input));
final ClientEntity entity = client.getBinder().getODataEntity(
client.getDeserializer(contentType).toEntity(input));
assertNotNull(entity);
assertTrue(entity.isMediaEntity());
assertNotNull(entity.getMediaContentSource());
assertEquals("\"8zOOKKvgOtptr4gt8IrnapX3jds=\"", entity.getMediaETag());
final ClientEntity written = getClient().getBinder().getODataEntity(
new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
final ClientEntity written = client.getBinder().getODataEntity(
new ResWrap<Entity>((URI) null, null, client.getBinder().getEntity(entity)));
assertEquals(entity, written);
input.close();
}
@ -236,8 +231,8 @@ public class EntityTest extends AbstractTest {
private void withStream(final ContentType contentType) throws Exception {
final InputStream input = getClass().getResourceAsStream("PersonDetails_1." + getSuffix(contentType));
final ClientEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(contentType).toEntity(input));
final ClientEntity entity = client.getBinder().getODataEntity(
client.getDeserializer(contentType).toEntity(input));
assertNotNull(entity);
assertFalse(entity.isMediaEntity());
@ -245,8 +240,8 @@ public class EntityTest extends AbstractTest {
final ClientLink editMedia = entity.getMediaEditLink("Photo");
assertNotNull(editMedia);
final ClientEntity written = getClient().getBinder().getODataEntity(
new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
final ClientEntity written = client.getBinder().getODataEntity(
new ResWrap<Entity>((URI) null, null, client.getBinder().getEntity(entity)));
assertEquals(entity, written);
input.close();
}
@ -263,14 +258,14 @@ public class EntityTest extends AbstractTest {
private void ref(final ContentType contentType) throws Exception {
final InputStream input = getClass().getResourceAsStream("entityReference." + getSuffix(contentType));
final ClientEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(contentType).toEntity(input));
final ClientEntity entity = client.getBinder().getODataEntity(
client.getDeserializer(contentType).toEntity(input));
assertNotNull(entity);
assertNotNull(entity.getId());
final ClientEntity written = getClient().getBinder().getODataEntity(
new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
final ClientEntity written = client.getBinder().getODataEntity(
new ResWrap<Entity>((URI) null, null, client.getBinder().getEntity(entity)));
assertEquals(entity, written);
input.close();
}
@ -287,8 +282,8 @@ public class EntityTest extends AbstractTest {
private void complexNavigationProperties(final ContentType contentType) throws Exception {
final InputStream input = getClass().getResourceAsStream("entity.withcomplexnavigation." + getSuffix(contentType));
final ClientEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(contentType).toEntity(input));
final ClientEntity entity = client.getBinder().getODataEntity(
client.getDeserializer(contentType).toEntity(input));
assertNotNull(entity);
final ClientComplexValue addressValue = entity.getProperty("Address").getComplexValue();
@ -297,8 +292,8 @@ public class EntityTest extends AbstractTest {
// ETag is not serialized
entity.setETag(null);
final ClientEntity written = getClient().getBinder().getODataEntity(
new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
final ClientEntity written = client.getBinder().getODataEntity(
new ResWrap<Entity>((URI) null, null, client.getBinder().getEntity(entity)));
assertEquals(entity, written);
input.close();
}
@ -315,8 +310,8 @@ public class EntityTest extends AbstractTest {
private void annotated(final ContentType contentType) throws EdmPrimitiveTypeException, Exception {
final InputStream input = getClass().getResourceAsStream("annotated." + getSuffix(contentType));
final ClientEntity entity = getClient().getBinder().getODataEntity(
getClient().getDeserializer(contentType).toEntity(input));
final ClientEntity entity = client.getBinder().getODataEntity(
client.getDeserializer(contentType).toEntity(input));
assertNotNull(entity);
assertFalse(entity.getAnnotations().isEmpty());
@ -343,8 +338,8 @@ public class EntityTest extends AbstractTest {
assertEquals(2,
annotation.getValue().asComplex().get("order").getPrimitiveValue().toCastValue(Integer.class), 0);
final ClientEntity written = getClient().getBinder().getODataEntity(
new ResWrap<Entity>((URI) null, null, getClient().getBinder().getEntity(entity)));
final ClientEntity written = client.getBinder().getODataEntity(
new ResWrap<Entity>((URI) null, null, client.getBinder().getEntity(entity)));
assertEquals(entity, written);
input.close();
}
@ -374,7 +369,7 @@ public class EntityTest extends AbstractTest {
@Test
public void derivedFromAtom() throws Exception {
derived(getClient(), ContentType.APPLICATION_ATOM_XML);
derived(client, ContentType.APPLICATION_ATOM_XML);
}
@Test
@ -384,6 +379,6 @@ public class EntityTest extends AbstractTest {
@Test
public void derivedFromFullJSON() throws Exception {
derived(getClient(), ContentType.JSON_FULL_METADATA);
derived(client, ContentType.JSON_FULL_METADATA);
}
}

View File

@ -21,7 +21,6 @@ package org.apache.olingo.client.core;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
import org.apache.olingo.commons.api.ex.ODataError;
import org.apache.olingo.commons.api.format.ContentType;
@ -29,13 +28,8 @@ import org.junit.Test;
public class ErrorTest extends AbstractTest {
@Override
protected ODataClient getClient() {
return v4Client;
}
private ODataError error(final String name, final ContentType contentType) throws ODataDeserializerException {
final ODataError error = getClient().getDeserializer(contentType).toError(
final ODataError error = client.getDeserializer(contentType).toError(
getClass().getResourceAsStream(name + "." + getSuffix(contentType)));
assertNotNull(error);
return error;

View File

@ -30,7 +30,6 @@ import java.util.List;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.domain.ClientCollectionValue;
import org.apache.olingo.client.api.domain.ClientComplexValue;
import org.apache.olingo.client.api.domain.ClientEntity;
@ -50,11 +49,6 @@ public class JSONTest extends AbstractTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Override
protected ODataClient getClient() {
return v4Client;
}
protected ContentType getODataPubFormat() {
return ContentType.JSON;
}
@ -129,7 +123,7 @@ public class JSONTest extends AbstractTest {
protected void entitySet(final String filename, final ContentType contentType) throws Exception {
final StringWriter writer = new StringWriter();
getClient().getSerializer(contentType).write(writer, getClient().getDeserializer(contentType).toEntitySet(
client.getSerializer(contentType).write(writer, client.getDeserializer(contentType).toEntitySet(
getClass().getResourceAsStream(filename + "." + getSuffix(contentType))).getPayload());
assertSimilar(filename + "." + getSuffix(contentType), writer.toString());
@ -143,7 +137,7 @@ public class JSONTest extends AbstractTest {
protected void entity(final String filename, final ContentType contentType) throws Exception {
final StringWriter writer = new StringWriter();
getClient().getSerializer(contentType).write(writer, getClient().getDeserializer(contentType).toEntity(
client.getSerializer(contentType).write(writer, client.getDeserializer(contentType).toEntity(
getClass().getResourceAsStream(filename + "." + getSuffix(contentType))).getPayload());
assertSimilar(filename + "." + getSuffix(contentType), writer.toString());
}
@ -169,7 +163,7 @@ public class JSONTest extends AbstractTest {
protected void property(final String filename, final ContentType contentType) throws Exception {
final StringWriter writer = new StringWriter();
getClient().getSerializer(contentType).write(writer, getClient().getDeserializer(contentType).
client.getSerializer(contentType).write(writer, client.getDeserializer(contentType).
toProperty(getClass().getResourceAsStream(filename + "." + getSuffix(contentType))).getPayload());
assertSimilar(filename + "." + getSuffix(contentType), writer.toString());
@ -185,12 +179,12 @@ public class JSONTest extends AbstractTest {
@Test
public void crossjoin() throws Exception {
assertNotNull(getClient().getDeserializer(ContentType.JSON_FULL_METADATA).toEntitySet(
assertNotNull(client.getDeserializer(ContentType.JSON_FULL_METADATA).toEntitySet(
getClass().getResourceAsStream("crossjoin.json")));
}
protected void delta(final String filename, final ContentType contentType) throws Exception {
final Delta delta = getClient().getDeserializer(contentType).toDelta(
final Delta delta = client.getDeserializer(contentType).toDelta(
getClass().getResourceAsStream(filename + "." + getSuffix(contentType))).getPayload();
assertNotNull(delta);
assertNotNull(delta.getDeltaLink());
@ -223,30 +217,30 @@ public class JSONTest extends AbstractTest {
@Test
public void issueOLINGO390() throws Exception {
final ClientEntity message = getClient().getObjectFactory().
final ClientEntity message = client.getObjectFactory().
newEntity(new FullQualifiedName("Microsoft.Exchange.Services.OData.Model.Message"));
final ClientComplexValue toRecipient = getClient().getObjectFactory().
final ClientComplexValue toRecipient = client.getObjectFactory().
newComplexValue("Microsoft.Exchange.Services.OData.Model.Recipient");
toRecipient.add(getClient().getObjectFactory().newPrimitiveProperty("Name",
getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("challen_olingo_client")));
toRecipient.add(getClient().getObjectFactory().newPrimitiveProperty("Address",
getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("challenh@microsoft.com")));
final ClientCollectionValue<ClientValue> toRecipients = getClient().getObjectFactory().
toRecipient.add(client.getObjectFactory().newPrimitiveProperty("Name",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("challen_olingo_client")));
toRecipient.add(client.getObjectFactory().newPrimitiveProperty("Address",
client.getObjectFactory().newPrimitiveValueBuilder().buildString("challenh@microsoft.com")));
final ClientCollectionValue<ClientValue> toRecipients = client.getObjectFactory().
newCollectionValue("Microsoft.Exchange.Services.OData.Model.Recipient");
toRecipients.add(toRecipient);
message.getProperties().add(getClient().getObjectFactory().newCollectionProperty("ToRecipients", toRecipients));
message.getProperties().add(client.getObjectFactory().newCollectionProperty("ToRecipients", toRecipients));
final ClientComplexValue body =
getClient().getObjectFactory().newComplexValue("Microsoft.Exchange.Services.OData.Model.ItemBody");
body.add(getClient().getObjectFactory().newPrimitiveProperty("Content",
getClient().getObjectFactory().newPrimitiveValueBuilder().
client.getObjectFactory().newComplexValue("Microsoft.Exchange.Services.OData.Model.ItemBody");
body.add(client.getObjectFactory().newPrimitiveProperty("Content",
client.getObjectFactory().newPrimitiveValueBuilder().
buildString("this is a simple email body content")));
body.add(getClient().getObjectFactory().newEnumProperty("ContentType",
getClient().getObjectFactory().newEnumValue("Microsoft.Exchange.Services.OData.Model.BodyType", "text")));
message.getProperties().add(getClient().getObjectFactory().newComplexProperty("Body", body));
body.add(client.getObjectFactory().newEnumProperty("ContentType",
client.getObjectFactory().newEnumValue("Microsoft.Exchange.Services.OData.Model.BodyType", "text")));
message.getProperties().add(client.getObjectFactory().newComplexProperty("Body", body));
final String actual = IOUtils.toString(getClient().getWriter().writeEntity(message, ContentType.JSON));
final String actual = IOUtils.toString(client.getWriter().writeEntity(message, ContentType.JSON));
final JsonNode expected =
OBJECT_MAPPER.readTree(IOUtils.toString(getClass().getResourceAsStream("olingo390.json")).
replace(Constants.JSON_NAVIGATION_LINK, Constants.JSON_BIND_LINK_SUFFIX));

View File

@ -26,7 +26,6 @@ import static org.junit.Assert.assertTrue;
import java.io.InputStream;
import java.util.List;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.edm.xml.XMLMetadata;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.edm.Edm;
@ -72,14 +71,9 @@ import org.junit.Test;
public class MetadataTest extends AbstractTest {
@Override
protected ODataClient getClient() {
return v4Client;
}
@Test
public void parse() {
final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("metadata.xml"));
final Edm edm = client.getReader().readMetadata(getClass().getResourceAsStream("metadata.xml"));
assertNotNull(edm);
// 1. Enum
@ -140,7 +134,7 @@ public class MetadataTest extends AbstractTest {
@Test
public void demo() {
final XMLMetadata metadata = getClient().getDeserializer(ContentType.APPLICATION_XML).
final XMLMetadata metadata = client.getDeserializer(ContentType.APPLICATION_XML).
toMetadata(getClass().getResourceAsStream("demo-metadata.xml"));
assertNotNull(metadata);
@ -154,7 +148,7 @@ public class MetadataTest extends AbstractTest {
annots.getAnnotation("Org.OData.Publication.V1.PrivacyPolicyUrl").getExpression().asConstant().getValue());
// Now let's test some edm:Annotations
final Edm edm = getClient().getReader().
final Edm edm = client.getReader().
readMetadata(getClass().getResourceAsStream("demo-metadata.xml"));
assertNotNull(edm);
@ -181,7 +175,7 @@ public class MetadataTest extends AbstractTest {
@Test
public void multipleSchemas() {
final XMLMetadata metadata = getClient().getDeserializer(ContentType.APPLICATION_XML).
final XMLMetadata metadata = client.getDeserializer(ContentType.APPLICATION_XML).
toMetadata(getClass().getResourceAsStream("northwind-metadata.xml"));
assertNotNull(metadata);
@ -198,10 +192,10 @@ public class MetadataTest extends AbstractTest {
@Test
public void getContainerWithoutCallingGetSchemas() {
final XMLMetadata metadata = getClient().getDeserializer(ContentType.APPLICATION_XML).
final XMLMetadata metadata = client.getDeserializer(ContentType.APPLICATION_XML).
toMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml"));
Edm edm = getClient().getReader().readMetadata(metadata.getSchemaByNsOrAlias());
Edm edm = client.getReader().readMetadata(metadata.getSchemaByNsOrAlias());
assertNotNull(edm.getEntityContainer());
}
@ -211,7 +205,7 @@ public class MetadataTest extends AbstractTest {
*/
@Test
public void fromdoc1() {
final XMLMetadata metadata = getClient().getDeserializer(ContentType.APPLICATION_XML).
final XMLMetadata metadata = client.getDeserializer(ContentType.APPLICATION_XML).
toMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml"));
assertNotNull(metadata);
@ -249,7 +243,7 @@ public class MetadataTest extends AbstractTest {
functionImport.getFunction());
// Now let's go high-level
final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml"));
final Edm edm = client.getReader().readMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml"));
assertNotNull(edm);
List<EdmSchema> schemaList = edm.getSchemas();
@ -291,7 +285,7 @@ public class MetadataTest extends AbstractTest {
*/
@Test
public void fromdoc2() {
final XMLMetadata metadata = getClient().getDeserializer(ContentType.APPLICATION_XML)
final XMLMetadata metadata = client.getDeserializer(ContentType.APPLICATION_XML)
.toMetadata(getClass().getResourceAsStream("fromdoc2-metadata.xml"));
assertNotNull(metadata);
@ -336,7 +330,7 @@ public class MetadataTest extends AbstractTest {
*/
@Test
public void fromdoc3() {
final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc3-metadata.xml"));
final Edm edm = client.getReader().readMetadata(getClass().getResourceAsStream("fromdoc3-metadata.xml"));
assertNotNull(edm);
final EdmAnnotations group = edm.getSchema("Annotations").getAnnotationGroups().get(0);
@ -354,7 +348,7 @@ public class MetadataTest extends AbstractTest {
*/
@Test
public void fromdoc4() {
final XMLMetadata metadata = getClient().getDeserializer(ContentType.APPLICATION_XML).
final XMLMetadata metadata = client.getDeserializer(ContentType.APPLICATION_XML).
toMetadata(getClass().getResourceAsStream("fromdoc4-metadata.xml"));
assertNotNull(metadata);
@ -382,7 +376,7 @@ public class MetadataTest extends AbstractTest {
assertTrue(urlRef.getValue().asDynamic().isApply());
// Now let's go high-level
final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc4-metadata.xml"));
final Edm edm = client.getReader().readMetadata(getClass().getResourceAsStream("fromdoc4-metadata.xml"));
assertNotNull(edm);
final EdmAnnotations edmGroup = edm.getSchemas().get(0).getAnnotationGroups().get(0);
@ -410,8 +404,7 @@ public class MetadataTest extends AbstractTest {
@Test
public void metadataWithCapabilities() throws Exception {
InputStream input = getClass().getResourceAsStream("Metadata-With-Capabilities.xml");
final XMLMetadata metadata = getClient().getDeserializer(ContentType.APPLICATION_XML).
toMetadata(input);
final XMLMetadata metadata = client.getDeserializer(ContentType.APPLICATION_XML).toMetadata(input);
CsdlSchema schema = metadata.getSchema("Capabilities");
assertNotNull(schema);

View File

@ -18,31 +18,25 @@
*/
package org.apache.olingo.client.core;
import org.apache.olingo.client.api.ODataClient;
import static org.junit.Assert.assertEquals;
import java.util.Calendar;
import org.apache.olingo.client.api.domain.ClientValue;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.junit.Test;
import java.util.Calendar;
import static org.junit.Assert.assertEquals;
public class PrimitiveValueTest extends AbstractTest {
@Override
protected ODataClient getClient() {
return v4Client;
}
@Test
public void timeOfDay() throws EdmPrimitiveTypeException {
final Calendar expected = Calendar.getInstance();
expected.clear();
expected.set(2013, 0, 10, 21, 45, 17);
final ClientValue value = getClient().getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.TimeOfDay).setValue(expected).build();
final ClientValue value = client.getObjectFactory().newPrimitiveValueBuilder()
.setType(EdmPrimitiveTypeKind.TimeOfDay).setValue(expected).build();
assertEquals(EdmPrimitiveTypeKind.TimeOfDay, value.asPrimitive().getTypeKind());
final Calendar actual = value.asPrimitive().toCastValue(Calendar.class);
@ -59,8 +53,8 @@ public class PrimitiveValueTest extends AbstractTest {
expected.clear();
expected.set(2013, 0, 10);
final ClientValue value = getClient().getObjectFactory().newPrimitiveValueBuilder().
setType(EdmPrimitiveTypeKind.Date).setValue(expected).build();
final ClientValue value = client.getObjectFactory().newPrimitiveValueBuilder()
.setType(EdmPrimitiveTypeKind.Date).setValue(expected).build();
assertEquals(EdmPrimitiveTypeKind.Date, value.asPrimitive().getTypeKind());
final Calendar actual = value.asPrimitive().toCastValue(Calendar.class);

View File

@ -25,35 +25,29 @@ import static org.junit.Assert.assertTrue;
import java.io.InputStream;
import java.util.Iterator;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.domain.ClientCollectionValue;
import org.apache.olingo.client.api.domain.ClientComplexValue;
import org.apache.olingo.client.api.domain.ClientProperty;
import org.apache.olingo.client.api.domain.ClientValue;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.client.api.serialization.ODataDeserializerException;
import org.apache.olingo.client.api.serialization.ODataSerializerException;
import org.apache.olingo.commons.api.format.ContentType;
import org.junit.Test;
public class PropertyTest extends AbstractTest {
@Override
protected ODataClient getClient() {
return v4Client;
}
private void _enum(final ContentType contentType) throws ODataDeserializerException, ODataSerializerException {
final InputStream input = getClass().getResourceAsStream("Products_5_SkinColor." + getSuffix(contentType));
final ClientProperty property = getClient().getReader().readProperty(input, contentType);
final ClientProperty property = client.getReader().readProperty(input, contentType);
assertNotNull(property);
assertTrue(property.hasEnumValue());
final ClientProperty written = getClient().getReader().readProperty(
getClient().getWriter().writeProperty(property, contentType), contentType);
final ClientProperty written = client.getReader().readProperty(
client.getWriter().writeProperty(property, contentType), contentType);
// This is needed because type information gets lost with serialization
if (contentType.isCompatible(ContentType.APPLICATION_XML)) {
final ClientProperty comparable = getClient().getObjectFactory().newEnumProperty(property.getName(),
getClient().getObjectFactory().
final ClientProperty comparable = client.getObjectFactory().newEnumProperty(property.getName(),
client.getObjectFactory().
newEnumValue(property.getEnumValue().getTypeName(), written.getEnumValue().getValue()));
assertEquals(property, comparable);
@ -72,21 +66,21 @@ public class PropertyTest extends AbstractTest {
private void complex(final ContentType contentType) throws ODataDeserializerException, ODataSerializerException {
final InputStream input = getClass().getResourceAsStream("Employees_3_HomeAddress." + getSuffix(contentType));
final ClientProperty property = getClient().getReader().readProperty(input, contentType);
final ClientProperty property = client.getReader().readProperty(input, contentType);
assertNotNull(property);
assertTrue(property.hasComplexValue());
assertEquals(3, property.getComplexValue().size());
final ClientProperty written = getClient().getReader().readProperty(
getClient().getWriter().writeProperty(property, contentType), contentType);
final ClientProperty written = client.getReader().readProperty(
client.getWriter().writeProperty(property, contentType), contentType);
// This is needed because type information gets lost with JSON serialization
final ClientComplexValue typedValue = getClient().getObjectFactory().
final ClientComplexValue typedValue = client.getObjectFactory().
newComplexValue(property.getComplexValue().getTypeName());
for (final Iterator<ClientProperty> itor = written.getComplexValue().iterator(); itor.hasNext();) {
final ClientProperty prop = itor.next();
typedValue.add(prop);
}
final ClientProperty comparable = getClient().getObjectFactory().
final ClientProperty comparable = client.getObjectFactory().
newComplexProperty(property.getName(), typedValue);
assertEquals(property, comparable);
@ -104,22 +98,22 @@ public class PropertyTest extends AbstractTest {
private void collection(final ContentType contentType) throws ODataDeserializerException, ODataSerializerException {
final InputStream input = getClass().getResourceAsStream("Products_5_CoverColors." + getSuffix(contentType));
final ClientProperty property = getClient().getReader().readProperty(input, contentType);
final ClientProperty property = client.getReader().readProperty(input, contentType);
assertNotNull(property);
assertTrue(property.hasCollectionValue());
assertEquals(3, property.getCollectionValue().size());
final ClientProperty written = getClient().getReader().readProperty(
getClient().getWriter().writeProperty(property, contentType), contentType);
final ClientProperty written = client.getReader().readProperty(
client.getWriter().writeProperty(property, contentType), contentType);
// This is needed because type information gets lost with JSON serialization
if(contentType.isCompatible(ContentType.APPLICATION_XML)) {
final ClientCollectionValue<ClientValue> typedValue = getClient().getObjectFactory().
final ClientCollectionValue<ClientValue> typedValue = client.getObjectFactory().
newCollectionValue(property.getCollectionValue().getTypeName());
for (final Iterator<ClientValue> itor = written.getCollectionValue().iterator(); itor.hasNext();) {
final ClientValue value = itor.next();
typedValue.add(value);
}
final ClientProperty comparable = getClient().getObjectFactory().
final ClientProperty comparable = client.getObjectFactory().
newCollectionProperty(property.getName(), typedValue);
assertEquals(property, comparable);

View File

@ -24,7 +24,6 @@ import static org.junit.Assert.assertTrue;
import java.net.URI;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.data.ResWrap;
import org.apache.olingo.client.api.data.ServiceDocument;
import org.apache.olingo.client.api.domain.ClientServiceDocument;
@ -34,23 +33,14 @@ import org.junit.Test;
public class ServiceDocumentTest extends AbstractTest {
@Override
protected ODataClient getClient() {
return v4Client;
}
private String getFileExtension(final ContentType contentType) {
return contentType.isCompatible(ContentType.APPLICATION_XML) ? "xml" : "json";
}
private ClientServiceDocument parse(final ContentType contentType) throws ODataDeserializerException {
ResWrap<ServiceDocument> service = getClient().getDeserializer(contentType).toServiceDocument(
getClass().getResourceAsStream("serviceDocument." + getFileExtension(contentType)));
ResWrap<ServiceDocument> service = client.getDeserializer(contentType).toServiceDocument(
getClass().getResourceAsStream("serviceDocument." + getSuffix(contentType)));
assertEquals(URI.create("http://host/service/$metadata"), service.getContextURL());
assertEquals("W/\"MjAxMy0wNS0xM1QxNDo1NFo=\"", service.getMetadataETag());
final ClientServiceDocument serviceDocument = getClient().getBinder().getODataServiceDocument(service.getPayload());
final ClientServiceDocument serviceDocument = client.getBinder().getODataServiceDocument(service.getPayload());
assertNotNull(serviceDocument);
assertTrue(serviceDocument.getEntitySetNames().contains("Order Details"));

View File

@ -25,7 +25,6 @@ import java.net.URLEncoder;
import java.util.Calendar;
import java.util.TimeZone;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.uri.FilterArgFactory;
import org.apache.olingo.client.api.uri.FilterFactory;
import org.apache.olingo.client.api.uri.URIFilter;
@ -39,13 +38,8 @@ import org.junit.Test;
public class FilterFactoryTest extends AbstractTest {
@Override
protected ODataClient getClient() {
return v4Client;
}
private FilterFactory getFilterFactory() {
return getClient().getFilterFactory();
return client.getFilterFactory();
}
private FilterArgFactory getFilterArgFactory() {

View File

@ -26,32 +26,25 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.uri.QueryOption;
import org.apache.olingo.client.api.uri.URIBuilder;
import org.apache.olingo.client.core.AbstractTest;
import org.apache.olingo.client.core.uri.ParameterAlias;
import org.junit.Test;
public class URIBuilderTest extends AbstractTest {
private static final String SERVICE_ROOT = "http://host/service";
@Override
protected ODataClient getClient() {
return v4Client;
}
@Test
public void metadata() throws URISyntaxException {
final URI uri = getClient().newURIBuilder(SERVICE_ROOT).appendMetadataSegment().build();
final URI uri = client.newURIBuilder(SERVICE_ROOT).appendMetadataSegment().build();
assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/$metadata").build(), uri);
}
@Test
public void entity() throws URISyntaxException {
final URI uri = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("AnEntitySet").
final URI uri = client.newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("AnEntitySet").
appendKeySegment(11).build();
assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/AnEntitySet(11)").build(), uri);
@ -59,21 +52,21 @@ public class URIBuilderTest extends AbstractTest {
final Map<String, Object> multiKey = new LinkedHashMap<String, Object>();
multiKey.put("OrderId", -10);
multiKey.put("ProductId", -10);
URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).
URIBuilder uriBuilder = client.newURIBuilder(SERVICE_ROOT).
appendEntitySetSegment("OrderLine").appendKeySegment(multiKey).
appendPropertySegment("Quantity").appendValueSegment();
assertEquals(new org.apache.http.client.utils.URIBuilder(
SERVICE_ROOT + "/OrderLine(OrderId=-10,ProductId=-10)/Quantity/$value").build(), uriBuilder.build());
uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).
uriBuilder = client.newURIBuilder(SERVICE_ROOT).
appendEntitySetSegment("Customer").appendKeySegment(-10).
select("CustomerId", "Name", "Orders").expand("Orders");
assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Customer(-10)").
addParameter("$select", "CustomerId,Name,Orders").addParameter("$expand", "Orders").build(),
uriBuilder.build());
uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).
uriBuilder = client.newURIBuilder(SERVICE_ROOT).
appendEntitySetSegment("Customer").appendKeySegment(-10).appendNavigationSegment("Orders").appendRefSegment();
assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Customer(-10)/Orders/$ref").build(),
uriBuilder.build());
@ -81,7 +74,7 @@ public class URIBuilderTest extends AbstractTest {
@Test
public void expandWithOptions() throws URISyntaxException {
final URI uri = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").appendKeySegment(5).
final URI uri = client.newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").appendKeySegment(5).
expandWithOptions("ProductDetails", new LinkedHashMap<QueryOption, Object>() {
private static final long serialVersionUID = 3109256773218160485L;
@ -96,7 +89,7 @@ public class URIBuilderTest extends AbstractTest {
}
public void expandWithLevels() throws URISyntaxException {
final URI uri = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").appendKeySegment(1).
final URI uri = client.newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").appendKeySegment(1).
expandWithOptions("Customer", Collections.<QueryOption, Object> singletonMap(QueryOption.LEVELS, 4)).
build();
@ -106,11 +99,11 @@ public class URIBuilderTest extends AbstractTest {
@Test
public void count() throws URISyntaxException {
URI uri = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").count().build();
URI uri = client.newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").count().build();
assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Products/$count").build(), uri);
uri = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").count(true).build();
uri = client.newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").count(true).build();
assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Products").
addParameter("$count", "true").build(), uri);
@ -118,34 +111,34 @@ public class URIBuilderTest extends AbstractTest {
@Test
public void filter() throws URISyntaxException {
final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("AnEntitySet").
filter(getClient().getFilterFactory().lt("VIN", 16));
final URIBuilder uriBuilder = client.newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("AnEntitySet").
filter(client.getFilterFactory().lt("VIN", 16));
assertEquals("http://host/service/AnEntitySet?%24filter=%28VIN%20lt%2016%29", uriBuilder.build().toASCIIString());
// assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/AnEntitySet").
// addParameter("$filter", "(VIN lt 16)").build(),
// uriBuilder.build());
// assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/AnEntitySet").
// addParameter("$filter", "(VIN lt 16)").build(),
// uriBuilder.build());
}
@Test
public void filterWithParameter() throws URISyntaxException {
// http://host/service.svc/Employees?$filter=Region eq @p1&@p1='WA'
final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Employees").
filter(getClient().getFilterFactory().eq("Region", new ParameterAlias("p1"))).
final URIBuilder uriBuilder = client.newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Employees").
filter(client.getFilterFactory().eq("Region", new ParameterAlias("p1"))).
addParameterAlias("p1", "'WA'");
assertEquals("http://host/service/Employees?%24filter=%28Region%20eq%20%40p1%29&%40p1='WA'", uriBuilder.build()
.toASCIIString());
// assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Employees").
// addParameter("$filter", "(Region eq @p1)").addParameter("@p1", "'WA'").build(),
// uriBuilder.build());
// assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Employees").
// addParameter("$filter", "(Region eq @p1)").addParameter("@p1", "'WA'").build(),
// uriBuilder.build());
}
@Test
public void expandMoreThenOnce() throws URISyntaxException {
URI uri = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").appendKeySegment(5).
URI uri = client.newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").appendKeySegment(5).
expand("Orders", "Customers").expand("Info").build();
assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Products(5)").
@ -154,7 +147,7 @@ public class URIBuilderTest extends AbstractTest {
@Test
public void selectMoreThenOnce() throws URISyntaxException {
URI uri = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Customers").appendKeySegment(5).
URI uri = client.newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Customers").appendKeySegment(5).
select("Name", "Surname").expand("Info").select("Gender").build();
assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Customers(5)").
@ -163,7 +156,7 @@ public class URIBuilderTest extends AbstractTest {
@Test
public void singleton() throws URISyntaxException {
final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).
final URIBuilder uriBuilder = client.newURIBuilder(SERVICE_ROOT).
appendSingletonSegment("BestProductEverCreated");
assertEquals(new org.apache.http.client.utils.URIBuilder(
@ -172,7 +165,7 @@ public class URIBuilderTest extends AbstractTest {
@Test
public void entityId() throws URISyntaxException {
final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).
final URIBuilder uriBuilder = client.newURIBuilder(SERVICE_ROOT).
appendEntityIdSegment("Products(0)");
assertEquals(new org.apache.http.client.utils.URIBuilder(
@ -181,7 +174,7 @@ public class URIBuilderTest extends AbstractTest {
@Test
public void boundAction() throws URISyntaxException {
final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).
final URIBuilder uriBuilder = client.newURIBuilder(SERVICE_ROOT).
appendEntitySetSegment("Categories").appendKeySegment(1).
appendNavigationSegment("Products").
appendActionCallSegment("Model.AllOrders");
@ -189,10 +182,10 @@ public class URIBuilderTest extends AbstractTest {
assertEquals(new org.apache.http.client.utils.URIBuilder(
SERVICE_ROOT + "/Categories(1)/Products/Model.AllOrders").build(), uriBuilder.build());
}
@Test
public void boundOperation() throws URISyntaxException {
final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).
final URIBuilder uriBuilder = client.newURIBuilder(SERVICE_ROOT).
appendEntitySetSegment("Categories").appendKeySegment(1).
appendNavigationSegment("Products").
appendOperationCallSegment("Model.AllOrders");
@ -203,14 +196,14 @@ public class URIBuilderTest extends AbstractTest {
@Test
public void ref() throws URISyntaxException {
URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).
URIBuilder uriBuilder = client.newURIBuilder(SERVICE_ROOT).
appendEntitySetSegment("Categories").appendKeySegment(1).
appendNavigationSegment("Products").appendRefSegment();
assertEquals(new org.apache.http.client.utils.URIBuilder(
SERVICE_ROOT + "/Categories(1)/Products/$ref").build(), uriBuilder.build());
uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).
uriBuilder = client.newURIBuilder(SERVICE_ROOT).
appendEntitySetSegment("Categories").appendKeySegment(1).
appendNavigationSegment("Products").appendRefSegment().id("../../Products(0)");
@ -221,7 +214,7 @@ public class URIBuilderTest extends AbstractTest {
@Test
public void derived() throws URISyntaxException {
final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).
final URIBuilder uriBuilder = client.newURIBuilder(SERVICE_ROOT).
appendEntitySetSegment("Customers").appendDerivedEntityTypeSegment("Model.VipCustomer").appendKeySegment(1);
assertEquals(new org.apache.http.client.utils.URIBuilder(
@ -230,7 +223,7 @@ public class URIBuilderTest extends AbstractTest {
@Test
public void crossjoin() throws URISyntaxException {
final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).
final URIBuilder uriBuilder = client.newURIBuilder(SERVICE_ROOT).
appendCrossjoinSegment("Products", "Sales");
assertEquals(new org.apache.http.client.utils.URIBuilder(
@ -239,7 +232,7 @@ public class URIBuilderTest extends AbstractTest {
@Test
public void all() throws URISyntaxException {
final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).appendAllSegment();
final URIBuilder uriBuilder = client.newURIBuilder(SERVICE_ROOT).appendAllSegment();
assertEquals(new org.apache.http.client.utils.URIBuilder(
SERVICE_ROOT + "/$all").build(), uriBuilder.build());
@ -247,7 +240,7 @@ public class URIBuilderTest extends AbstractTest {
@Test
public void search() throws URISyntaxException {
final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).
final URIBuilder uriBuilder = client.newURIBuilder(SERVICE_ROOT).
appendEntitySetSegment("Products").search("blue OR green");
assertEquals(new URI("http://host/service/Products?%24search=blue%20OR%20green"), uriBuilder.build());

View File

@ -72,7 +72,6 @@ public abstract class Geospatial {
* The OGIS geometry type number for feature collections.
*/
GEOSPATIALCOLLECTION
}
protected final Dimension dimension;
@ -87,8 +86,8 @@ public abstract class Geospatial {
/**
* Constructor.
*
* @param dimension dimension.
* @param type type.
* @param dimension dimension
* @param type type
* @param srid SRID
*/
protected Geospatial(final Dimension dimension, final Type type, final SRID srid) {
@ -129,7 +128,7 @@ public abstract class Geospatial {
/**
* Returns the {@link EdmPrimitiveTypeKind}
* @return Edm primitve type kind
* @return EDM primitive type kind
*/
public abstract EdmPrimitiveTypeKind getEdmPrimitiveTypeKind();
}

View File

@ -23,7 +23,6 @@ import java.util.Collections;
import java.util.List;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmElement;
import org.apache.olingo.commons.api.edm.EdmEntityType;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
@ -32,7 +31,7 @@ import org.apache.olingo.commons.api.edm.EdmStructuredType;
import org.apache.olingo.commons.api.edm.provider.CsdlNavigationProperty;
import org.apache.olingo.commons.api.edm.provider.CsdlReferentialConstraint;
public class EdmNavigationPropertyImpl extends AbstractEdmNamed implements EdmElement, EdmNavigationProperty {
public class EdmNavigationPropertyImpl extends AbstractEdmNamed implements EdmNavigationProperty {
private final CsdlNavigationProperty navigationProperty;
private List<EdmReferentialConstraint> referentialConstraints;

View File

@ -19,7 +19,6 @@
package org.apache.olingo.commons.core.edm;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmElement;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmMapping;
import org.apache.olingo.commons.api.edm.EdmParameter;
@ -27,7 +26,7 @@ import org.apache.olingo.commons.api.edm.EdmType;
import org.apache.olingo.commons.api.edm.geo.SRID;
import org.apache.olingo.commons.api.edm.provider.CsdlParameter;
public class EdmParameterImpl extends AbstractEdmNamed implements EdmParameter, EdmElement {
public class EdmParameterImpl extends AbstractEdmNamed implements EdmParameter {
private final CsdlParameter parameter;
private EdmType typeImpl;

View File

@ -19,7 +19,6 @@
package org.apache.olingo.commons.core.edm;
import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmElement;
import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmMapping;
import org.apache.olingo.commons.api.edm.EdmProperty;
@ -27,7 +26,7 @@ import org.apache.olingo.commons.api.edm.EdmType;
import org.apache.olingo.commons.api.edm.geo.SRID;
import org.apache.olingo.commons.api.edm.provider.CsdlProperty;
public class EdmPropertyImpl extends AbstractEdmNamed implements EdmProperty, EdmElement {
public class EdmPropertyImpl extends AbstractEdmNamed implements EdmProperty {
private final CsdlProperty property;
private EdmTypeInfo typeInfo;
@ -59,7 +58,7 @@ public class EdmPropertyImpl extends AbstractEdmNamed implements EdmProperty, Ed
if (property.getType() == null) {
throw new EdmException("Property " + property.getName() + " must hava a full qualified type.");
}
typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(property.getType().toString()).build();
typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(property.getType()).build();
}
@Override

View File

@ -33,20 +33,26 @@ import org.apache.olingo.server.core.deserializer.batch.BatchParserCommon;
public class BatchFacadeImpl implements BatchFacade {
private final BatchPartHandler partHandler;
public BatchFacadeImpl(final ODataHandler oDataHandler, final ODataRequest request,
final BatchProcessor batchProcessor, final boolean isStrict) {
/**
* Creates a new BatchFacade.
* @param oDataHandler handler
* @param batchProcessor batch processor
* @param isStrict mode switch (currently not used)
*/
public BatchFacadeImpl(final ODataHandler oDataHandler, final BatchProcessor batchProcessor,
final boolean isStrict) {
partHandler = new BatchPartHandler(oDataHandler, batchProcessor, this);
}
@Override
public ODataResponse handleODataRequest(final ODataRequest request) throws ODataApplicationException,
ODataLibraryException {
public ODataResponse handleODataRequest(final ODataRequest request)
throws ODataApplicationException, ODataLibraryException {
return partHandler.handleODataRequest(request);
}
@Override
public ODataResponsePart handleBatchRequest(final BatchRequestPart request) throws ODataApplicationException,
ODataLibraryException {
public ODataResponsePart handleBatchRequest(final BatchRequestPart request)
throws ODataApplicationException, ODataLibraryException {
return partHandler.handleBatchRequest(request);
}

View File

@ -46,7 +46,7 @@ public class BatchHandler {
throws ODataApplicationException, ODataLibraryException {
validateRequest(request);
final BatchFacade operation = new BatchFacadeImpl(oDataHandler, request, batchProcessor, isStrict);
final BatchFacade operation = new BatchFacadeImpl(oDataHandler, batchProcessor, isStrict);
batchProcessor.processBatch(operation, request, response);
}