http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/main/java/org/apache/olingo/fit/Vocabularies.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/Vocabularies.java b/fit/src/main/java/org/apache/olingo/fit/Vocabularies.java index 0390eae..c13bf35 100644 --- a/fit/src/main/java/org/apache/olingo/fit/Vocabularies.java +++ b/fit/src/main/java/org/apache/olingo/fit/Vocabularies.java @@ -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) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/main/java/org/apache/olingo/fit/metadata/EntitySet.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/metadata/EntitySet.java b/fit/src/main/java/org/apache/olingo/fit/metadata/EntitySet.java index 15285d2..c165bb7 100644 --- a/fit/src/main/java/org/apache/olingo/fit/metadata/EntitySet.java +++ b/fit/src/main/java/org/apache/olingo/fit/metadata/EntitySet.java @@ -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; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/main/java/org/apache/olingo/fit/rest/OAuth2RequestFilter.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/rest/OAuth2RequestFilter.java b/fit/src/main/java/org/apache/olingo/fit/rest/OAuth2RequestFilter.java index 17476dd..a7ab945 100644 --- a/fit/src/main/java/org/apache/olingo/fit/rest/OAuth2RequestFilter.java +++ b/fit/src/main/java/org/apache/olingo/fit/rest/OAuth2RequestFilter.java @@ -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) { http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/main/java/org/apache/olingo/fit/serializer/FITAtomDeserializer.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/serializer/FITAtomDeserializer.java b/fit/src/main/java/org/apache/olingo/fit/serializer/FITAtomDeserializer.java index d02475d..357dc5a 100644 --- a/fit/src/main/java/org/apache/olingo/fit/serializer/FITAtomDeserializer.java +++ b/fit/src/main/java/org/apache/olingo/fit/serializer/FITAtomDeserializer.java @@ -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))); } - } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java index ee87eb0..a14cb8b 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java +++ b/fit/src/main/java/org/apache/olingo/fit/utils/AbstractUtilities.java @@ -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); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/main/java/org/apache/olingo/fit/utils/Accept.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/Accept.java b/fit/src/main/java/org/apache/olingo/fit/utils/Accept.java index 5f9a724..9acda31 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/Accept.java +++ b/fit/src/main/java/org/apache/olingo/fit/utils/Accept.java @@ -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"); + 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 final String contentTypeV4; + private static Pattern allTypesPattern = Pattern.compile("(.*,)?\\*/\\*([,;].*)?"); + private final ContentType contentType; private final String fileExtension; - private static Pattern allTypesPattern = Pattern.compile("(.*,)?\\*/\\*([,;].*)?"); - - Accept(final String contentTypeV4, final String fileExtension) { - this.contentTypeV4 = contentTypeV4; + 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; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java b/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java index 32644d9..5ee4d25 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java +++ b/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java @@ -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"); - - METADATA.put(version, new Metadata(is)); - } + private static final Metadata METADATA = + new Metadata(Commons.class.getResourceAsStream("/" + ODataServiceVersion.V40.name() + "/metadata.xml")); - 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 { http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/main/java/org/apache/olingo/fit/utils/ConstantKey.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/ConstantKey.java b/fit/src/main/java/org/apache/olingo/fit/utils/ConstantKey.java index 7315652..a8425df 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/ConstantKey.java +++ b/fit/src/main/java/org/apache/olingo/fit/utils/ConstantKey.java @@ -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 }; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/main/java/org/apache/olingo/fit/utils/Constants.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/Constants.java b/fit/src/main/java/org/apache/olingo/fit/utils/Constants.java index d0915a4..6a1d16a 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/Constants.java +++ b/fit/src/main/java/org/apache/olingo/fit/utils/Constants.java @@ -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"); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java b/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java index d3530c8..8202619 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java +++ b/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java @@ -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()); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/main/java/org/apache/olingo/fit/utils/InjectableSerializerProvider.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/InjectableSerializerProvider.java b/fit/src/main/java/org/apache/olingo/fit/utils/InjectableSerializerProvider.java deleted file mode 100644 index 02ada09..0000000 --- a/fit/src/main/java/org/apache/olingo/fit/utils/InjectableSerializerProvider.java +++ /dev/null @@ -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; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java index 8be6b11..b18886d 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java +++ b/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java @@ -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 http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/main/java/org/apache/olingo/fit/utils/MetadataLinkInfo.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/MetadataLinkInfo.java b/fit/src/main/java/org/apache/olingo/fit/utils/MetadataLinkInfo.java deleted file mode 100644 index e79ce96..0000000 --- a/fit/src/main/java/org/apache/olingo/fit/utils/MetadataLinkInfo.java +++ /dev/null @@ -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() + ")"; - } - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java ---------------------------------------------------------------------- diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java index 1078e2f..c7930f0 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java +++ b/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java @@ -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; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/test/java/org/apache/olingo/fit/proxy/demo/odatademo/types/Customer.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/demo/odatademo/types/Customer.java b/fit/src/test/java/org/apache/olingo/fit/proxy/demo/odatademo/types/Customer.java index 405ce0a..b9d15cc 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/demo/odatademo/types/Customer.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/demo/odatademo/types/Customer.java @@ -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(); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/test/java/org/apache/olingo/fit/proxy/demo/odatademo/types/Employee.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/demo/odatademo/types/Employee.java b/fit/src/test/java/org/apache/olingo/fit/proxy/demo/odatademo/types/Employee.java index 4b55f53..8b48599 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/demo/odatademo/types/Employee.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/demo/odatademo/types/Employee.java @@ -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(); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/test/java/org/apache/olingo/fit/proxy/demo/odatademo/types/FeaturedProduct.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/demo/odatademo/types/FeaturedProduct.java b/fit/src/test/java/org/apache/olingo/fit/proxy/demo/odatademo/types/FeaturedProduct.java index 0d09511..b38852c 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/demo/odatademo/types/FeaturedProduct.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/demo/odatademo/types/FeaturedProduct.java @@ -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(); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/test/java/org/apache/olingo/fit/proxy/opentype/microsoft/test/odata/services/opentypesservice/types/IndexedRow.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/opentype/microsoft/test/odata/services/opentypesservice/types/IndexedRow.java b/fit/src/test/java/org/apache/olingo/fit/proxy/opentype/microsoft/test/odata/services/opentypesservice/types/IndexedRow.java index 2de8869..f2618f2 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/opentype/microsoft/test/odata/services/opentypesservice/types/IndexedRow.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/opentype/microsoft/test/odata/services/opentypesservice/types/IndexedRow.java @@ -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(); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/CreditCardPI.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/CreditCardPI.java b/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/CreditCardPI.java index 6873492..179f2e1 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/CreditCardPI.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/CreditCardPI.java @@ -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(); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/Customer.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/Customer.java b/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/Customer.java index ed6fdc1..af66869 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/Customer.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/Customer.java @@ -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(); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/Employee.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/Employee.java b/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/Employee.java index f33ccb3..f0b4e80 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/Employee.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/Employee.java @@ -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(); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/PublicCompany.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/PublicCompany.java b/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/PublicCompany.java index cdace92..40144ef 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/PublicCompany.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/staticservice/microsoft/test/odata/services/odatawcfservice/types/PublicCompany.java @@ -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(); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EntityReferencesITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EntityReferencesITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EntityReferencesITCase.java index 94867af..bac2927 100644 --- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EntityReferencesITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/EntityReferencesITCase.java @@ -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) http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java ---------------------------------------------------------------------- diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java index 507b9a9..0f3743b 100644 --- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java @@ -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) http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/AbstractClientEntitySet.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/AbstractClientEntitySet.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/AbstractClientEntitySet.java deleted file mode 100644 index d59af93..0000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/AbstractClientEntitySet.java +++ /dev/null @@ -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() + "]]"; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientCollectionValueImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientCollectionValueImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientCollectionValueImpl.java index c83fceb..2a3aebc 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientCollectionValueImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientCollectionValueImpl.java @@ -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. http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientEntitySetImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientEntitySetImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientEntitySetImpl.java index 29ede4c..21e13b4 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientEntitySetImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientEntitySetImpl.java @@ -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)) { - 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)) { + if (obj == null || !(obj instanceof ClientEntitySetImpl)) { 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() + "]]"; } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientPrimitiveValueImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientPrimitiveValueImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientPrimitiveValueImpl.java index cdfe623..4824632 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientPrimitiveValueImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientPrimitiveValueImpl.java @@ -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 { http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientPropertyImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientPropertyImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientPropertyImpl.java index f78c506..8c8c3ee 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientPropertyImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientPropertyImpl.java @@ -18,30 +18,21 @@ */ package org.apache.olingo.client.core.domain; -import org.apache.olingo.client.api.domain.ClientAnnotatable; +import java.util.ArrayList; +import java.util.List; + 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 { +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); } /** @@ -55,16 +46,6 @@ public final class ClientPropertyImpl implements ClientProperty, ClientAnnotatab } /** - * Returns property value. - * - * @return property value. - */ - @Override - public ClientValue getValue() { - return value; - } - - /** * Checks if has null value. * * @return 'TRUE' if has null value; 'FALSE' otherwise. @@ -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) { - 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)) { + if (obj == null || !(obj instanceof ClientPropertyImpl)) { 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,42 +75,17 @@ 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; } @Override public String toString() { - return "ODataPropertyImpl{" - + "name=" + getName() - + ",valuable=" + valuable - + ", annotations=" + annotations - + '}'; + return "ClientPropertyImpl{" + "name=" + name + ", value=" + value + ", annotations=" + annotations + '}'; } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientValuableImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientValuableImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientValuableImpl.java index 4a032ce..4b94be6 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientValuableImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/domain/ClientValuableImpl.java @@ -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 + '}'; } } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java index 33144ec..f9f29e7 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataBinderImpl.java @@ -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(); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractTest.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractTest.java index bc116a8..d03b6d9 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractTest.java @@ -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) http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/lib/client-core/src/test/java/org/apache/olingo/client/core/AtomTest.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/AtomTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/AtomTest.java index 9d5346b..ba20144 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/AtomTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/AtomTest.java @@ -30,18 +30,12 @@ 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; } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5d7c1287/lib/client-core/src/test/java/org/apache/olingo/client/core/EntitySetTest.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/EntitySetTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/EntitySetTest.java index 199cd05..254e83f 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/EntitySetTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/EntitySetTest.java @@ -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); }
