You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/04/08 14:44:14 UTC
git commit: [OLINGO-234] Everything ready for V4 function / action
import invoke, integration tests cannot be committed yet,
need fit counterparts
Repository: olingo-odata4
Updated Branches:
refs/heads/master 338ed7078 -> 4f59dba76
[OLINGO-234] Everything ready for V4 function / action import invoke, integration tests cannot be committed yet, need fit counterparts
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/4f59dba7
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/4f59dba7
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/4f59dba7
Branch: refs/heads/master
Commit: 4f59dba769c7351a3d2a3cfafdac9f335f8ba03a
Parents: 338ed70
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Tue Apr 8 14:43:55 2014 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Tue Apr 8 14:43:55 2014 +0200
----------------------------------------------------------------------
.../olingo/client/api/op/CommonODataBinder.java | 13 +-
.../olingo/client/api/op/ODataWriter.java | 20 --
.../invoke/AbstractODataInvokeRequest.java | 233 +++++++++++++++++++
.../request/invoke/ODataInvokeRequestImpl.java | 233 -------------------
.../invoke/v3/InvokeRequestFactoryImpl.java | 19 +-
.../invoke/v3/ODataInvokeRequestImpl.java | 64 +++++
.../invoke/v4/InvokeRequestFactoryImpl.java | 37 ++-
.../invoke/v4/ODataInvokeRequestImpl.java | 92 ++++++++
.../client/core/op/AbstractODataBinder.java | 15 +-
.../olingo/client/core/op/ODataWriterImpl.java | 20 +-
.../client/core/op/impl/v3/ODataBinderImpl.java | 22 +-
.../client/core/op/impl/v4/ODataBinderImpl.java | 34 ++-
.../apache/olingo/client/core/uri/URIUtils.java | 22 +-
.../core/it/v3/ActionOverloadingTestITCase.java | 2 +-
.../client/core/it/v3/ErrorTestITCase.java | 2 +-
.../client/core/it/v3/InvokeTestITCase.java | 8 +-
.../olingo/client/core/uri/URIEscapeTest.java | 3 +-
.../api/domain/ODataCollectionValue.java | 9 +
.../commons/api/domain/ODataComplexValue.java | 8 +
.../commons/api/domain/v4/ODataEnumValue.java | 3 +
.../domain/AbstractODataCollectionValue.java | 20 +-
.../core/domain/AbstractODataComplexValue.java | 22 +-
.../domain/v4/ODataCollectionValueImpl.java | 21 ++
.../core/domain/v4/ODataComplexValueImpl.java | 23 ++
.../core/domain/v4/ODataEnumValueImpl.java | 7 +
.../core/domain/v4/ODataPropertyImpl.java | 4 +-
26 files changed, 597 insertions(+), 359 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java
index 14fa946..0d8da52 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataBinder.java
@@ -52,16 +52,6 @@ public interface CommonODataBinder extends Serializable {
Entry getEntry(CommonODataEntity entity, Class<? extends Entry> reference);
/**
- * Gets an <tt>Entry</tt> from the given OData entity.
- *
- * @param entity OData entity.
- * @param reference reference class.
- * @param setType whether to explicitly output type information.
- * @return <tt>Entry</tt> object.
- */
- Entry getEntry(CommonODataEntity entity, Class<? extends Entry> reference, boolean setType);
-
- /**
* Gets a <tt>Link</tt> from the given OData link.
*
* @param link OData link.
@@ -75,10 +65,9 @@ public interface CommonODataBinder extends Serializable {
*
* @param property OData property.
* @param reference reference class.
- * @param setType whether to explicitly output type information.
* @return <tt>Property</tt> object.
*/
- Property getProperty(CommonODataProperty property, Class<? extends Entry> reference, boolean setType);
+ Property getProperty(CommonODataProperty property, Class<? extends Entry> reference);
/**
* Adds the given property to the given entity.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ODataWriter.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ODataWriter.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ODataWriter.java
index a7ead37..2f54ecd 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ODataWriter.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/ODataWriter.java
@@ -46,16 +46,6 @@ public interface ODataWriter extends Serializable {
InputStream writeEntities(Collection<CommonODataEntity> entities, ODataPubFormat format);
/**
- * Writes a collection of OData entities.
- *
- * @param entities entities to be serialized.
- * @param format serialization format.
- * @param outputType whether to explicitly output type information.
- * @return stream of serialized objects.
- */
- InputStream writeEntities(Collection<CommonODataEntity> entities, ODataPubFormat format, boolean outputType);
-
- /**
* Serializes a single OData entity.
*
* @param entity entity to be serialized.
@@ -65,16 +55,6 @@ public interface ODataWriter extends Serializable {
InputStream writeEntity(CommonODataEntity entity, ODataPubFormat format);
/**
- * Serializes a single OData entity.
- *
- * @param entity entity to be serialized.
- * @param format serialization format.
- * @param outputType whether to explicitly output type information.
- * @return stream of serialized object.
- */
- InputStream writeEntity(CommonODataEntity entity, ODataPubFormat format, boolean outputType);
-
- /**
* Writes a single OData entity property.
*
* @param property entity property to be serialized.
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
new file mode 100644
index 0000000..7018baf
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
@@ -0,0 +1,233 @@
+/*
+ * 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.communication.request.invoke;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
+import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
+import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent;
+import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
+import org.apache.olingo.commons.api.domain.CommonODataEntity;
+import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
+import org.apache.olingo.commons.api.domain.ODataInvokeResult;
+import org.apache.olingo.commons.api.domain.CommonODataProperty;
+import org.apache.olingo.commons.api.domain.ODataValue;
+import org.apache.olingo.commons.api.format.ODataFormat;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+import org.apache.olingo.client.api.http.HttpClientException;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.api.v4.ODataClient;
+import org.apache.olingo.client.core.uri.URIUtils;
+import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
+import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
+
+/**
+ * This class implements an OData invoke operation request.
+ */
+public abstract class AbstractODataInvokeRequest<T extends ODataInvokeResult>
+ extends AbstractODataBasicRequest<ODataInvokeResponse<T>, ODataPubFormat>
+ implements ODataInvokeRequest<T>, ODataBatchableRequest {
+
+ private final Class<T> reference;
+
+ /**
+ * Function parameters.
+ */
+ protected Map<String, ODataValue> parameters;
+
+ /**
+ * Constructor.
+ *
+ * @param odataClient client instance getting this request
+ * @param reference reference class for invoke result
+ * @param method HTTP method of the request.
+ * @param uri URI that identifies the operation.
+ */
+ public AbstractODataInvokeRequest(
+ final CommonODataClient odataClient,
+ final Class<T> reference,
+ final HttpMethod method,
+ final URI uri) {
+
+ super(odataClient, ODataPubFormat.class, method, uri);
+
+ this.reference = reference;
+ this.parameters = new LinkedHashMap<String, ODataValue>();
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public void setParameters(final Map<String, ODataValue> parameters) {
+ this.parameters.clear();
+ if (parameters != null && !parameters.isEmpty()) {
+ this.parameters.putAll(parameters);
+ }
+ }
+
+ private String getActualFormat(final ODataPubFormat format) {
+ return (CommonODataProperty.class.isAssignableFrom(reference) && format == ODataPubFormat.ATOM)
+ ? ODataFormat.XML.toString(odataClient.getServiceVersion())
+ : format.toString(odataClient.getServiceVersion());
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public void setFormat(final ODataPubFormat format) {
+ final String _format = getActualFormat(format);
+ setAccept(_format);
+ setContentType(_format);
+ }
+
+ protected abstract ODataPubFormat getPOSTParameterFormat();
+
+ @Override
+ protected InputStream getPayload() {
+ if (!this.parameters.isEmpty() && this.method == HttpMethod.POST) {
+ // Additional, non-binding parameters MUST be sent as JSON
+ final CommonODataEntity tmp = odataClient.getObjectFactory().newEntity(StringUtils.EMPTY);
+ for (Map.Entry<String, ODataValue> param : parameters.entrySet()) {
+ CommonODataProperty property = null;
+
+ if (param.getValue().isPrimitive()) {
+ property = odataClient.getObjectFactory().
+ newPrimitiveProperty(param.getKey(), param.getValue().asPrimitive());
+ } else if (param.getValue().isComplex()) {
+ property = odataClient.getObjectFactory().
+ newComplexProperty(param.getKey(), param.getValue().asComplex());
+ } else if (param.getValue().isCollection()) {
+ property = odataClient.getObjectFactory().
+ newCollectionProperty(param.getKey(), param.getValue().asCollection());
+ } else if (param.getValue() instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
+ && ((org.apache.olingo.commons.api.domain.v4.ODataValue) param.getValue()).isEnum()) {
+
+ property = ((ODataClient) odataClient).getObjectFactory().
+ newEnumProperty(param.getKey(),
+ ((org.apache.olingo.commons.api.domain.v4.ODataValue) param.getValue()).asEnum());
+ }
+
+ if (property != null) {
+ odataClient.getBinder().add(tmp, property);
+ }
+ }
+
+ return odataClient.getWriter().writeEntity(tmp, getPOSTParameterFormat());
+ }
+
+ return null;
+ }
+
+ protected abstract URI buildGETURI();
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public ODataInvokeResponse<T> execute() {
+ final InputStream input = getPayload();
+
+ if (!this.parameters.isEmpty()) {
+ if (this.method == HttpMethod.GET) {
+ ((HttpRequestBase) this.request).setURI(buildGETURI());
+ } else if (this.method == HttpMethod.POST) {
+ ((HttpPost) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
+
+ setContentType(getActualFormat(getPOSTParameterFormat()));
+ }
+ }
+
+ try {
+ return new ODataInvokeResponseImpl(httpClient, doExecute());
+ } finally {
+ IOUtils.closeQuietly(input);
+ }
+ }
+
+ /**
+ * Response class about an ODataInvokeRequest.
+ */
+ protected class ODataInvokeResponseImpl extends AbstractODataResponse implements ODataInvokeResponse<T> {
+
+ private T invokeResult = null;
+
+ /**
+ * Constructor.
+ * <p>
+ * Just to create response templates to be initialized from batch.
+ */
+ private ODataInvokeResponseImpl() {
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param client HTTP client.
+ * @param res HTTP response.
+ */
+ private ODataInvokeResponseImpl(final HttpClient client, final HttpResponse res) {
+ super(client, res);
+ }
+
+ /**
+ * {@inheritDoc }
+ */
+ @Override
+ public T getBody() {
+ if (invokeResult == null) {
+ if (ODataNoContent.class.isAssignableFrom(reference)) {
+ invokeResult = reference.cast(new ODataNoContent());
+ }
+
+ try {
+ if (CommonODataEntitySet.class.isAssignableFrom(reference)) {
+ invokeResult = reference.cast(odataClient.getReader().readEntitySet(res.getEntity().getContent(),
+ ODataPubFormat.fromString(getContentType())));
+ }
+ if (CommonODataEntity.class.isAssignableFrom(reference)) {
+ invokeResult = reference.cast(odataClient.getReader().readEntity(res.getEntity().getContent(),
+ ODataPubFormat.fromString(getContentType())));
+ }
+ if (CommonODataProperty.class.isAssignableFrom(reference)) {
+ invokeResult = reference.cast(odataClient.getReader().readProperty(res.getEntity().getContent(),
+ ODataFormat.fromString(getContentType())));
+ }
+ } catch (IOException e) {
+ throw new HttpClientException(e);
+ } finally {
+ this.close();
+ }
+ }
+ return invokeResult;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestImpl.java
deleted file mode 100644
index 4e7be37..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestImpl.java
+++ /dev/null
@@ -1,233 +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.communication.request.invoke;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.olingo.client.api.CommonODataClient;
-import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
-import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
-import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent;
-import org.apache.olingo.client.api.communication.response.ODataInvokeResponse;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
-import org.apache.olingo.commons.api.domain.ODataInvokeResult;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
-import org.apache.olingo.commons.api.domain.ODataValue;
-import org.apache.olingo.commons.api.format.ODataFormat;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.client.api.http.HttpClientException;
-import org.apache.olingo.client.api.http.HttpMethod;
-import org.apache.olingo.client.core.uri.URIUtils;
-import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
-import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
-
-/**
- * This class implements an OData invoke operation request.
- */
-public class ODataInvokeRequestImpl<T extends ODataInvokeResult>
- extends AbstractODataBasicRequest<ODataInvokeResponse<T>, ODataPubFormat>
- implements ODataInvokeRequest<T>, ODataBatchableRequest {
-
- private final Class<T> reference;
-
- /**
- * Function parameters.
- */
- private Map<String, ODataValue> parameters;
-
- /**
- * Constructor.
- *
- * @param odataClient client instance getting this request
- * @param reference reference class for invoke result
- * @param method HTTP method of the request.
- * @param uri URI that identifies the operation.
- */
- public ODataInvokeRequestImpl(
- final CommonODataClient odataClient,
- final Class<T> reference,
- final HttpMethod method,
- final URI uri) {
-
- super(odataClient, ODataPubFormat.class, method, uri);
-
- this.reference = reference;
- this.parameters = new LinkedHashMap<String, ODataValue>();
- }
-
- /**
- * {@inheritDoc }
- */
- @Override
- public void setParameters(final Map<String, ODataValue> parameters) {
- this.parameters.clear();
- if (parameters != null && !parameters.isEmpty()) {
- this.parameters.putAll(parameters);
- }
- }
-
- /**
- * {@inheritDoc }
- */
- @Override
- public void setFormat(final ODataPubFormat format) {
- final String _format = (reference.isAssignableFrom(CommonODataProperty.class) && format == ODataPubFormat.ATOM)
- ? ODataFormat.XML.toString(odataClient.getServiceVersion())
- : format.toString(odataClient.getServiceVersion());
- setAccept(_format);
- setContentType(_format);
- }
-
- @Override
- protected InputStream getPayload() {
- if (!this.parameters.isEmpty() && this.method == HttpMethod.POST) {
- // Additional, non-binding parameters MUST be sent as JSON
- final CommonODataEntity tmp = odataClient.getObjectFactory().newEntity(StringUtils.EMPTY);
- for (Map.Entry<String, ODataValue> param : parameters.entrySet()) {
- CommonODataProperty property = null;
-
- if (param.getValue().isPrimitive()) {
- property = odataClient.getObjectFactory().
- newPrimitiveProperty(param.getKey(), param.getValue().asPrimitive());
- } else if (param.getValue().isComplex()) {
- property = odataClient.getObjectFactory().
- newComplexProperty(param.getKey(), param.getValue().asComplex());
- } else if (param.getValue().isCollection()) {
- property = odataClient.getObjectFactory().
- newCollectionProperty(param.getKey(), param.getValue().asCollection());
- }
-
- if (property != null) {
- odataClient.getBinder().add(tmp, property);
- }
- }
-
- return odataClient.getWriter().writeEntity(tmp, ODataPubFormat.JSON, false);
- }
-
- return null;
- }
-
- /**
- * {@inheritDoc }
- */
- @Override
- public ODataInvokeResponse<T> execute() {
- final InputStream input = getPayload();
-
- if (!this.parameters.isEmpty()) {
- if (this.method == HttpMethod.GET) {
- final URIBuilder uriBuilder = new URIBuilder(this.uri);
- for (Map.Entry<String, ODataValue> param : parameters.entrySet()) {
- if (!param.getValue().isPrimitive()) {
- throw new IllegalArgumentException("Only primitive values can be passed via GET");
- }
-
- uriBuilder.addParameter(param.getKey(), URIUtils.escape(odataClient.getServiceVersion(), param.getValue()));
- }
- try {
- ((HttpRequestBase) this.request).setURI(uriBuilder.build());
- } catch (URISyntaxException e) {
- throw new IllegalArgumentException("While adding GET parameters", e);
- }
- } else if (this.method == HttpMethod.POST) {
- ((HttpPost) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
-
- setContentType(ODataPubFormat.JSON.toString(odataClient.getServiceVersion()));
- }
- }
-
- try {
- return new ODataInvokeResponseImpl(httpClient, doExecute());
- } finally {
- IOUtils.closeQuietly(input);
- }
- }
-
- /**
- * Response class about an ODataInvokeRequest.
- */
- protected class ODataInvokeResponseImpl extends AbstractODataResponse implements ODataInvokeResponse<T> {
-
- private T invokeResult = null;
-
- /**
- * Constructor.
- * <p>
- * Just to create response templates to be initialized from batch.
- */
- private ODataInvokeResponseImpl() {
- }
-
- /**
- * Constructor.
- *
- * @param client HTTP client.
- * @param res HTTP response.
- */
- private ODataInvokeResponseImpl(final HttpClient client, final HttpResponse res) {
- super(client, res);
- }
-
- /**
- * {@inheritDoc }
- */
- @Override
- @SuppressWarnings("unchecked")
- public T getBody() {
- if (invokeResult == null) {
- if (reference.isAssignableFrom(ODataNoContent.class)) {
- invokeResult = (T) new ODataNoContent();
- }
-
- try {
- if (reference.isAssignableFrom(CommonODataEntitySet.class)) {
- invokeResult = (T) odataClient.getReader().readEntitySet(res.getEntity().getContent(),
- ODataPubFormat.fromString(getContentType()));
- }
- if (reference.isAssignableFrom(CommonODataEntity.class)) {
- invokeResult = (T) odataClient.getReader().readEntity(res.getEntity().getContent(),
- ODataPubFormat.fromString(getContentType()));
- }
- if (reference.isAssignableFrom(CommonODataProperty.class)) {
- invokeResult = (T) odataClient.getReader().readProperty(res.getEntity().getContent(),
- ODataFormat.fromString(getContentType()));
- }
- } catch (IOException e) {
- throw new HttpClientException(e);
- } finally {
- this.close();
- }
- }
- return invokeResult;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java
index 8781840..662f9db 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java
@@ -24,14 +24,13 @@ import org.apache.olingo.client.api.v3.ODataClient;
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent;
import org.apache.olingo.client.api.communication.request.invoke.v3.InvokeRequestFactory;
-import org.apache.olingo.commons.api.domain.CommonODataEntity;
-import org.apache.olingo.commons.api.domain.CommonODataEntitySet;
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
-import org.apache.olingo.commons.api.domain.CommonODataProperty;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.communication.request.invoke.AbstractInvokeRequestFactory;
-import org.apache.olingo.client.core.communication.request.invoke.ODataInvokeRequestImpl;
+import org.apache.olingo.commons.api.domain.v3.ODataEntity;
+import org.apache.olingo.commons.api.domain.v3.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v3.ODataProperty;
import org.apache.olingo.commons.api.edm.EdmAction;
import org.apache.olingo.commons.api.edm.EdmOperation;
import org.apache.olingo.commons.api.edm.EdmReturnType;
@@ -61,14 +60,14 @@ public class InvokeRequestFactoryImpl extends AbstractInvokeRequestFactory imple
client, ODataNoContent.class, method, uri);
} else {
if (returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
- request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<CommonODataEntitySet>(
- client, CommonODataEntitySet.class, method, uri);
+ request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataEntitySet>(
+ client, ODataEntitySet.class, method, uri);
} else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
- request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<CommonODataEntity>(
- client, CommonODataEntity.class, method, uri);
+ request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataEntity>(
+ client, ODataEntity.class, method, uri);
} else {
- request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<CommonODataProperty>(
- client, CommonODataProperty.class, method, uri);
+ request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataProperty>(
+ client, ODataProperty.class, method, uri);
}
}
if (parameters != null) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/ODataInvokeRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/ODataInvokeRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/ODataInvokeRequestImpl.java
new file mode 100644
index 0000000..1d0fb65
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/ODataInvokeRequestImpl.java
@@ -0,0 +1,64 @@
+/*
+ * 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.communication.request.invoke.v3;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.core.communication.request.invoke.AbstractODataInvokeRequest;
+import org.apache.olingo.client.core.uri.URIUtils;
+import org.apache.olingo.commons.api.domain.ODataInvokeResult;
+import org.apache.olingo.commons.api.domain.ODataValue;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+
+public class ODataInvokeRequestImpl<T extends ODataInvokeResult> extends AbstractODataInvokeRequest<T> {
+
+ public ODataInvokeRequestImpl(final CommonODataClient odataClient, final Class<T> reference, final HttpMethod method,
+ final URI uri) {
+
+ super(odataClient, reference, method, uri);
+ }
+
+ @Override
+ protected ODataPubFormat getPOSTParameterFormat() {
+ return ODataPubFormat.JSON;
+ }
+
+ @Override
+ protected URI buildGETURI() {
+ final URIBuilder uriBuilder = new URIBuilder(this.uri);
+ for (Map.Entry<String, ODataValue> param : parameters.entrySet()) {
+ if (!param.getValue().isPrimitive()) {
+ throw new IllegalArgumentException("Only primitive values can be passed via GET");
+ }
+
+ uriBuilder.addParameter(param.getKey(), URIUtils.escape(odataClient.getServiceVersion(), param.getValue()));
+ }
+
+ try {
+ return uriBuilder.build();
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException("While adding GET parameters", e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/InvokeRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/InvokeRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/InvokeRequestFactoryImpl.java
index da49df4..4d5a4b1 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/InvokeRequestFactoryImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/InvokeRequestFactoryImpl.java
@@ -20,14 +20,21 @@ package org.apache.olingo.client.core.communication.request.invoke.v4;
import java.net.URI;
import java.util.Map;
-import org.apache.commons.lang3.NotImplementedException;
import org.apache.olingo.client.api.v4.ODataClient;
import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest;
+import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent;
import org.apache.olingo.client.api.communication.request.invoke.v4.InvokeRequestFactory;
+import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.commons.api.domain.ODataInvokeResult;
import org.apache.olingo.commons.api.domain.ODataValue;
import org.apache.olingo.client.core.communication.request.invoke.AbstractInvokeRequestFactory;
+import org.apache.olingo.commons.api.domain.v4.ODataEntity;
+import org.apache.olingo.commons.api.domain.v4.ODataEntitySet;
+import org.apache.olingo.commons.api.domain.v4.ODataProperty;
+import org.apache.olingo.commons.api.edm.EdmAction;
import org.apache.olingo.commons.api.edm.EdmOperation;
+import org.apache.olingo.commons.api.edm.EdmReturnType;
+import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
public class InvokeRequestFactoryImpl extends AbstractInvokeRequestFactory implements InvokeRequestFactory {
@@ -37,10 +44,36 @@ public class InvokeRequestFactoryImpl extends AbstractInvokeRequestFactory imple
super(client);
}
+ @SuppressWarnings("unchecked")
@Override
public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getInvokeRequest(
final URI uri, final EdmOperation operation, final Map<String, ODataValue> parameters) {
- throw new NotImplementedException("Not available yet.");
+ final HttpMethod method = operation instanceof EdmAction
+ ? HttpMethod.POST
+ : HttpMethod.GET;
+ final EdmReturnType returnType = operation.getReturnType();
+
+ ODataInvokeRequest<RES> request;
+ if (returnType == null) {
+ request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataNoContent>(
+ client, ODataNoContent.class, method, uri);
+ } else {
+ if (returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
+ request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataEntitySet>(
+ client, ODataEntitySet.class, method, uri);
+ } else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
+ request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataEntity>(
+ client, ODataEntity.class, method, uri);
+ } else {
+ request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataProperty>(
+ client, ODataProperty.class, method, uri);
+ }
+ }
+ if (parameters != null) {
+ request.setParameters(parameters);
+ }
+
+ return request;
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/ODataInvokeRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/ODataInvokeRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/ODataInvokeRequestImpl.java
new file mode 100644
index 0000000..a59b727
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/ODataInvokeRequestImpl.java
@@ -0,0 +1,92 @@
+/*
+ * 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.communication.request.invoke.v4;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URLEncoder;
+import java.util.Map;
+import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.http.HttpMethod;
+import org.apache.olingo.client.core.communication.request.invoke.AbstractODataInvokeRequest;
+import org.apache.olingo.client.core.uri.URIUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.domain.ODataInvokeResult;
+import org.apache.olingo.commons.api.domain.ODataValue;
+import org.apache.olingo.commons.api.format.ODataPubFormat;
+
+public class ODataInvokeRequestImpl<T extends ODataInvokeResult> extends AbstractODataInvokeRequest<T> {
+
+ private ODataPubFormat format;
+
+ public ODataInvokeRequestImpl(final CommonODataClient odataClient, final Class<T> reference, final HttpMethod method,
+ final URI uri) {
+
+ super(odataClient, reference, method, uri);
+ }
+
+ @Override
+ public void setFormat(final ODataPubFormat format) {
+ super.setFormat(format);
+ this.format = format;
+ }
+
+ @Override
+ protected ODataPubFormat getPOSTParameterFormat() {
+ return format;
+ }
+
+ @Override
+ protected URI buildGETURI() {
+ String baseURI = this.uri.toASCIIString();
+ if (baseURI.endsWith("()")) {
+ baseURI = baseURI.substring(0, baseURI.length() - 2);
+ } else if (!baseURI.endsWith("(")) {
+ baseURI = baseURI.substring(0, baseURI.length() - 1);
+ }
+
+ final StringBuilder inlineParams = new StringBuilder();
+ for (Map.Entry<String, ODataValue> param : parameters.entrySet()) {
+ inlineParams.append(param.getKey()).append("=");
+
+ Object value = null;
+ if (param.getValue().isPrimitive()) {
+ value = param.getValue().asPrimitive().toValue();
+ } else if (param.getValue().isComplex()) {
+ value = param.getValue().asComplex().asJavaMap();
+ } else if (param.getValue().isCollection()) {
+ value = param.getValue().asCollection().asJavaCollection();
+ } else if (param.getValue() instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
+ && ((org.apache.olingo.commons.api.domain.v4.ODataValue) param.getValue()).isEnum()) {
+
+ value = ((org.apache.olingo.commons.api.domain.v4.ODataValue) param.getValue()).asEnum().toString();
+ }
+
+ inlineParams.append(URIUtils.escape(odataClient.getServiceVersion(), value)).append(',');
+ }
+ inlineParams.deleteCharAt(inlineParams.length() - 1);
+
+ try {
+ return URI.create(baseURI + "(" + URLEncoder.encode(inlineParams.toString(), Constants.UTF8) + ")");
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalArgumentException("While adding GET parameters", e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
index 71e08bb..d927136 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/AbstractODataBinder.java
@@ -110,11 +110,6 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
return feed;
}
- @Override
- public Entry getEntry(final CommonODataEntity entity, final Class<? extends Entry> reference) {
- return getEntry(entity, reference, true);
- }
-
protected void links(final ODataLinked odataLinked, final Linked linked, final Class<? extends Entry> reference) {
// -------------------------------------------------------------
// Append navigation links (handling inline entry / feed as well)
@@ -140,7 +135,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
}
@Override
- public Entry getEntry(final CommonODataEntity entity, final Class<? extends Entry> reference, final boolean setType) {
+ public Entry getEntry(final CommonODataEntity entity, final Class<? extends Entry> reference) {
final Entry entry = ResourceFactory.newEntry(reference);
entry.setType(entity.getName());
@@ -185,7 +180,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
}
for (CommonODataProperty property : entity.getProperties()) {
- entry.getProperties().add(getProperty(property, reference, setType));
+ entry.getProperties().add(getProperty(property, reference));
}
return entry;
@@ -217,7 +212,7 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
return linkResource;
}
- protected Value getValue(final ODataValue value, final Class<? extends Entry> reference, final boolean setType) {
+ protected Value getValue(final ODataValue value, final Class<? extends Entry> reference) {
Value valueResource = null;
if (value == null) {
@@ -231,14 +226,14 @@ public abstract class AbstractODataBinder implements CommonODataBinder {
valueResource = new ComplexValueImpl();
for (final Iterator<? extends CommonODataProperty> itor = _value.iterator(); itor.hasNext();) {
- valueResource.asComplex().get().add(getProperty(itor.next(), reference, setType));
+ valueResource.asComplex().get().add(getProperty(itor.next(), reference));
}
} else if (value.isCollection()) {
final ODataCollectionValue<? extends ODataValue> _value = value.asCollection();
valueResource = new CollectionValueImpl();
for (final Iterator<? extends ODataValue> itor = _value.iterator(); itor.hasNext();) {
- valueResource.asCollection().get().add(getValue(itor.next(), reference, setType));
+ valueResource.asCollection().get().add(getValue(itor.next(), reference));
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java
index 7ea9c99..7230704 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/ODataWriterImpl.java
@@ -45,18 +45,11 @@ public class ODataWriterImpl implements ODataWriter {
@Override
public InputStream writeEntities(final Collection<CommonODataEntity> entities, final ODataPubFormat format) {
- return writeEntities(entities, format, true);
- }
-
- @Override
- public InputStream writeEntities(
- final Collection<CommonODataEntity> entities, final ODataPubFormat format, final boolean outputType) {
-
final ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
for (CommonODataEntity entity : entities) {
client.getSerializer().entry(client.getBinder().getEntry(
- entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM), outputType), output);
+ entity, ResourceFactory.entryClassForFormat(format == ODataPubFormat.ATOM)), output);
}
return new ByteArrayInputStream(output.toByteArray());
@@ -67,14 +60,7 @@ public class ODataWriterImpl implements ODataWriter {
@Override
public InputStream writeEntity(final CommonODataEntity entity, final ODataPubFormat format) {
- return writeEntity(entity, format, true);
- }
-
- @Override
- public InputStream writeEntity(final CommonODataEntity entity, final ODataPubFormat format,
- final boolean outputType) {
-
- return writeEntities(Collections.<CommonODataEntity>singleton(entity), format, outputType);
+ return writeEntities(Collections.<CommonODataEntity>singleton(entity), format);
}
@Override
@@ -82,7 +68,7 @@ public class ODataWriterImpl implements ODataWriter {
final ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
client.getSerializer().property(client.getBinder().getProperty(
- property, ResourceFactory.entryClassForFormat(format == ODataFormat.XML), true), output);
+ property, ResourceFactory.entryClassForFormat(format == ODataFormat.XML)), output);
return new ByteArrayInputStream(output.toByteArray());
} finally {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
index ab973d3..c0ce3f3 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataBinderImpl.java
@@ -56,21 +56,17 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
}
@Override
- public Property getProperty(final CommonODataProperty property, final Class<? extends Entry> reference,
- final boolean setType) {
-
+ public Property getProperty(final CommonODataProperty property, final Class<? extends Entry> reference) {
final Property propertyResource = ResourceFactory.newProperty(reference);
propertyResource.setName(property.getName());
- propertyResource.setValue(getValue(property.getValue(), reference, setType));
-
- if (setType) {
- if (property.hasPrimitiveValue()) {
- propertyResource.setType(property.getPrimitiveValue().getTypeName());
- } else if (property.hasComplexValue()) {
- propertyResource.setType(((ODataProperty) property).getComplexValue().getTypeName());
- } else if (property.hasCollectionValue()) {
- propertyResource.setType(((ODataProperty) property).getCollectionValue().getTypeName());
- }
+ propertyResource.setValue(getValue(property.getValue(), reference));
+
+ if (property.hasPrimitiveValue()) {
+ propertyResource.setType(property.getPrimitiveValue().getTypeName());
+ } else if (property.hasComplexValue()) {
+ propertyResource.setType(((ODataProperty) property).getComplexValue().getTypeName());
+ } else if (property.hasCollectionValue()) {
+ propertyResource.setType(((ODataProperty) property).getCollectionValue().getTypeName());
}
return propertyResource;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
index adce2ee..950ea53 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java
@@ -88,39 +88,35 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
}
@Override
- public Entry getEntry(final CommonODataEntity entity, final Class<? extends Entry> reference, final boolean setType) {
- final Entry entry = super.getEntry(entity, reference, setType);
+ public Entry getEntry(final CommonODataEntity entity, final Class<? extends Entry> reference) {
+ final Entry entry = super.getEntry(entity, reference);
entry.setId(((ODataEntity) entity).getReference());
return entry;
}
@Override
- public Property getProperty(final CommonODataProperty property, final Class<? extends Entry> reference,
- final boolean setType) {
-
+ public Property getProperty(final CommonODataProperty property, final Class<? extends Entry> reference) {
final ODataProperty _property = (ODataProperty) property;
final Property propertyResource = ResourceFactory.newProperty(reference);
propertyResource.setName(_property.getName());
- propertyResource.setValue(getValue(_property.getValue(), reference, setType));
-
- if (setType) {
- if (_property.hasPrimitiveValue()) {
- propertyResource.setType(_property.getPrimitiveValue().getTypeName());
- } else if (_property.hasEnumValue()) {
- propertyResource.setType(_property.getEnumValue().getTypeName());
- } else if (_property.hasComplexValue()) {
- propertyResource.setType(_property.getComplexValue().getTypeName());
- } else if (_property.hasCollectionValue()) {
- propertyResource.setType(_property.getCollectionValue().getTypeName());
- }
+ propertyResource.setValue(getValue(_property.getValue(), reference));
+
+ if (_property.hasPrimitiveValue()) {
+ propertyResource.setType(_property.getPrimitiveValue().getTypeName());
+ } else if (_property.hasEnumValue()) {
+ propertyResource.setType(_property.getEnumValue().getTypeName());
+ } else if (_property.hasComplexValue()) {
+ propertyResource.setType(_property.getComplexValue().getTypeName());
+ } else if (_property.hasCollectionValue()) {
+ propertyResource.setType(_property.getCollectionValue().getTypeName());
}
return propertyResource;
}
@Override
- protected Value getValue(final ODataValue value, final Class<? extends Entry> reference, final boolean setType) {
+ protected Value getValue(final ODataValue value, final Class<? extends Entry> reference) {
Value valueResource;
if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
&& ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).isEnum()) {
@@ -128,7 +124,7 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
valueResource = new EnumValueImpl(
((org.apache.olingo.commons.api.domain.v4.ODataValue) value).asEnum().getValue());
} else {
- valueResource = super.getValue(value, reference, setType);
+ valueResource = super.getValue(value, reference);
if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue
&& ((org.apache.olingo.commons.api.domain.v4.ODataValue) value).isLinkedComplex()) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
index 841af8f..3496cec 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java
@@ -41,7 +41,6 @@ import org.apache.http.entity.InputStreamEntity;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.commons.api.edm.EdmOperationImport;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
@@ -143,17 +142,17 @@ public final class URIUtils {
* Gets operation import URI segment.
*
* @param entityContainer entity container.
- * @param operationImport function import.
+ * @param operationImportName action / function import name.
* @return URI segment.
*/
public static String operationImportURISegment(
- final EdmEntityContainer entityContainer, final EdmOperationImport operationImport) {
+ final EdmEntityContainer entityContainer, final String operationImportName) {
final StringBuilder result = new StringBuilder();
if (!entityContainer.isDefault()) {
result.append(entityContainer.getName()).append('.');
}
- result.append(operationImport.getName());
+ result.append(operationImportName);
return result.toString();
}
@@ -282,12 +281,11 @@ public final class URIUtils {
private static String quoteString(final String string, final boolean singleQuoteEscape)
throws UnsupportedEncodingException {
- final String encoded = URLEncoder.encode(string, Constants.UTF8);
return ENUM_VALUE.matcher(string).matches()
- ? encoded
+ ? string
: singleQuoteEscape
- ? "'" + encoded + "'"
- : "\"" + encoded + "\"";
+ ? "'" + string + "'"
+ : "\"" + string + "\"";
}
/**
@@ -322,11 +320,11 @@ public final class URIUtils {
} else if (version.compareTo(ODataServiceVersion.V40) >= 0 && obj instanceof Map) {
final StringBuffer buffer = new StringBuffer("{");
for (@SuppressWarnings("unchecked")
- final Iterator<Map.Entry<Object, Object>> itor =
- ((Map<Object, Object>) obj).entrySet().iterator(); itor.hasNext();) {
+ final Iterator<Map.Entry<String, Object>> itor =
+ ((Map<String, Object>) obj).entrySet().iterator(); itor.hasNext();) {
- final Map.Entry<Object, Object> entry = itor.next();
- buffer.append("\"").append(URLEncoder.encode(entry.getKey().toString(), Constants.UTF8)).append("\"");
+ final Map.Entry<String, Object> entry = itor.next();
+ buffer.append("\"").append(entry.getKey()).append("\"");
buffer.append(':').append(escape(version, entry.getValue(), false));
if (itor.hasNext()) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ActionOverloadingTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ActionOverloadingTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ActionOverloadingTestITCase.java
index 19cf96f..1031fbe 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ActionOverloadingTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ActionOverloadingTestITCase.java
@@ -62,7 +62,7 @@ public class ActionOverloadingTestITCase extends AbstractTestITCase {
assertEquals(EdmInt32.getInstance(), unbound.getReturnType().getType());
final URIBuilder unboundBuilder = getClient().getURIBuilder(testActionOverloadingServiceRootURL).
- appendOperationCallSegment(URIUtils.operationImportURISegment(container, actImp));
+ appendOperationCallSegment(URIUtils.operationImportURISegment(container, actImp.getName()));
final ODataInvokeResponse<ODataProperty> unboundRes = getClient().getInvokeRequestFactory().
<ODataProperty>getInvokeRequest(unboundBuilder.build(), unbound).execute();
assertNotNull(unboundRes);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ErrorTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ErrorTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ErrorTestITCase.java
index e25c9fd..17e6c1d 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ErrorTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/ErrorTestITCase.java
@@ -153,7 +153,7 @@ public class ErrorTestITCase extends AbstractTestITCase {
final EdmEntityContainer container = metadata.getSchemas().get(0).getEntityContainer();
final EdmFunctionImport funcImp = container.getFunctionImport("InStreamErrorGetCustomer");
final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment(URIUtils.operationImportURISegment(container, funcImp));
+ appendOperationCallSegment(URIUtils.operationImportURISegment(container, funcImp.getName()));
final ODataInvokeRequest<ODataEntitySet> req =
client.getInvokeRequestFactory().getInvokeRequest(builder.build(), funcImp.getUnboundFunction(null));
req.setFormat(format);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/InvokeTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/InvokeTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/InvokeTestITCase.java
index 1cc4e14..50e95c5 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/InvokeTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/InvokeTestITCase.java
@@ -73,7 +73,7 @@ public class InvokeTestITCase extends AbstractTestITCase {
EdmFunction func = funcImp.getUnboundFunction(null);
URIBuilder builder = getClient().getURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment(URIUtils.operationImportURISegment(container, funcImp));
+ appendOperationCallSegment(URIUtils.operationImportURISegment(container, funcImp.getName()));
ODataInvokeRequest<ODataProperty> req = getClient().getInvokeRequestFactory().
getInvokeRequest(builder.build(), func);
@@ -90,7 +90,7 @@ public class InvokeTestITCase extends AbstractTestITCase {
func = funcImp.getUnboundFunction(null);
builder = getClient().getURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment(URIUtils.operationImportURISegment(container, funcImp));
+ appendOperationCallSegment(URIUtils.operationImportURISegment(container, funcImp.getName()));
req = getClient().getInvokeRequestFactory().getInvokeRequest(builder.build(), func);
req.setFormat(format);
@@ -123,7 +123,7 @@ public class InvokeTestITCase extends AbstractTestITCase {
EdmFunctionImport funcImp = container.getFunctionImport("GetArgumentPlusOne");
URIBuilder builder = getClient().getURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment(URIUtils.operationImportURISegment(container, funcImp));
+ appendOperationCallSegment(URIUtils.operationImportURISegment(container, funcImp.getName()));
EdmFunction function = funcImp.getUnboundFunction(Collections.singletonList("arg1"));
EdmParameter param = function.getParameter(function.getParameterNames().get(0));
@@ -148,7 +148,7 @@ public class InvokeTestITCase extends AbstractTestITCase {
funcImp = container.getFunctionImport("GetSpecificCustomer");
builder = getClient().getURIBuilder(testStaticServiceRootURL).
- appendOperationCallSegment(URIUtils.operationImportURISegment(container, funcImp));
+ appendOperationCallSegment(URIUtils.operationImportURISegment(container, funcImp.getName()));
function = funcImp.getUnboundFunction(Collections.singletonList("Name"));
param = function.getParameter(function.getParameterNames().get(0));
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java
index 886d1e8..ca226a3 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java
@@ -51,8 +51,7 @@ public class URIEscapeTest {
final EdmEnumType pattern = new EdmEnumTypeImpl(ODataServiceVersion.V40,
null, new FullQualifiedName("Sales", "Pattern"), new EnumTypeImpl());
- assertEquals(URLEncoder.encode("Sales.Pattern'Yellow'", Constants.UTF8),
- URIUtils.escape(ODataServiceVersion.V40, pattern.toUriLiteral("Yellow")));
+ assertEquals("Sales.Pattern'Yellow'", URIUtils.escape(ODataServiceVersion.V40, pattern.toUriLiteral("Yellow")));
}
@Test
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataCollectionValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataCollectionValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataCollectionValue.java
index 088bbc0..8b5f531 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataCollectionValue.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataCollectionValue.java
@@ -18,6 +18,8 @@
*/
package org.apache.olingo.commons.api.domain;
+import java.util.Collection;
+
/**
* OData collection property value.
*
@@ -45,4 +47,11 @@ public interface ODataCollectionValue<OV extends ODataValue> extends ODataValue,
* @return collection size.
*/
int size();
+
+ /**
+ * Converts this instance as POJO collection.
+ *
+ * @return this instance as POJO collection
+ */
+ Collection<Object> asJavaCollection();
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java
index 7eb02c0..b66aed6 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataComplexValue.java
@@ -18,6 +18,8 @@
*/
package org.apache.olingo.commons.api.domain;
+import java.util.Map;
+
/**
* OData complex property value.
*
@@ -47,4 +49,10 @@ public interface ODataComplexValue<OP extends CommonODataProperty> extends OData
*/
int size();
+ /**
+ * Converts this instance as POJO collection.
+ *
+ * @return this instance as POJO collection
+ */
+ Map<String, Object> asJavaMap();
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEnumValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEnumValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEnumValue.java
index 2e3699d..e614808 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEnumValue.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEnumValue.java
@@ -21,4 +21,7 @@ package org.apache.olingo.commons.api.domain.v4;
public interface ODataEnumValue extends ODataValue {
String getValue();
+
+ @Override
+ String toString();
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataCollectionValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataCollectionValue.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataCollectionValue.java
index 2f8236b..619cf02 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataCollectionValue.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataCollectionValue.java
@@ -19,6 +19,7 @@
package org.apache.olingo.commons.core.domain;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.apache.olingo.commons.api.domain.AbstractODataValue;
@@ -38,7 +39,7 @@ public abstract class AbstractODataCollectionValue<OV extends ODataValue>
/**
* Values.
*/
- private final List<OV> values = new ArrayList<OV>();
+ protected final List<OV> values = new ArrayList<OV>();
/**
* Constructor.
@@ -89,4 +90,21 @@ public abstract class AbstractODataCollectionValue<OV extends ODataValue>
public boolean isEmpty() {
return values.isEmpty();
}
+
+ @Override
+ public Collection<Object> asJavaCollection() {
+ final List<Object> result = new ArrayList<Object>();
+ for (OV value : values) {
+ if (value.isPrimitive()) {
+ result.add(value.asPrimitive().toValue());
+ } else if (value.isComplex()) {
+ result.add(value.asComplex().asJavaMap());
+ } else if (value.isCollection()) {
+ result.add(value.asCollection().asJavaCollection());
+ }
+ }
+
+ return result;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataComplexValue.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataComplexValue.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataComplexValue.java
index 6a09664..4e4e40d 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataComplexValue.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractODataComplexValue.java
@@ -38,7 +38,7 @@ public abstract class AbstractODataComplexValue<OP extends CommonODataProperty>
/**
* Complex type fields.
*/
- private final Map<String, OP> fields = new LinkedHashMap<String, OP>();
+ protected final Map<String, OP> fields = new LinkedHashMap<String, OP>();
/**
* Constructor.
@@ -90,4 +90,24 @@ public abstract class AbstractODataComplexValue<OP extends CommonODataProperty>
public int size() {
return fields.size();
}
+
+ @Override
+ public Map<String, Object> asJavaMap() {
+ final Map<String, Object> result = new LinkedHashMap<String, Object>();
+ for (Map.Entry<String, OP> entry : fields.entrySet()) {
+ Object value = null;
+ if (entry.getValue().hasPrimitiveValue()) {
+ value = entry.getValue().getPrimitiveValue().toValue();
+ } else if (entry.getValue().hasComplexValue()) {
+ value = entry.getValue().getValue().asComplex().asJavaMap();
+ } else if (entry.getValue().hasCollectionValue()) {
+ value = entry.getValue().getValue().asCollection().asJavaCollection();
+ }
+
+ result.put(entry.getKey(), value);
+ }
+
+ return result;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataCollectionValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataCollectionValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataCollectionValueImpl.java
index f130d90..46a553c 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataCollectionValueImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataCollectionValueImpl.java
@@ -18,6 +18,9 @@
*/
package org.apache.olingo.commons.core.domain.v4;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
import org.apache.olingo.commons.api.domain.v4.ODataLinkedComplexValue;
import org.apache.olingo.commons.api.domain.v4.ODataEnumValue;
import org.apache.olingo.commons.api.domain.v4.ODataValue;
@@ -50,4 +53,22 @@ public class ODataCollectionValueImpl extends AbstractODataCollectionValue<OData
public ODataLinkedComplexValue asLinkedComplex() {
return null;
}
+
+ @Override
+ public Collection<Object> asJavaCollection() {
+ final List<Object> result = new ArrayList<Object>();
+ for (ODataValue value : values) {
+ if (value.isPrimitive()) {
+ result.add(value.asPrimitive().toValue());
+ } else if (value.isComplex()) {
+ result.add(value.asComplex().asJavaMap());
+ } else if (value.isCollection()) {
+ result.add(value.asCollection().asJavaCollection());
+ } else if (value.isEnum()) {
+ result.add(value.asEnum().toString());
+ }
+ }
+
+ return result;
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataComplexValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataComplexValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataComplexValueImpl.java
index 711fd53..d8d5fc9 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataComplexValueImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataComplexValueImpl.java
@@ -19,7 +19,9 @@
package org.apache.olingo.commons.core.domain.v4;
import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.v4.ODataLinkedComplexValue;
import org.apache.olingo.commons.api.domain.v4.ODataEnumValue;
@@ -123,4 +125,25 @@ public class ODataComplexValueImpl extends AbstractODataComplexValue<ODataProper
return associationLinks;
}
+ @Override
+ public Map<String, Object> asJavaMap() {
+ final Map<String, Object> result = new LinkedHashMap<String, Object>();
+ for (Map.Entry<String, ODataProperty> entry : fields.entrySet()) {
+ Object value = null;
+ if (entry.getValue().hasPrimitiveValue()) {
+ value = entry.getValue().getPrimitiveValue().toValue();
+ } else if (entry.getValue().hasComplexValue()) {
+ value = entry.getValue().getComplexValue().asJavaMap();
+ } else if (entry.getValue().hasCollectionValue()) {
+ value = entry.getValue().getCollectionValue().asJavaCollection();
+ } else if (entry.getValue().hasEnumValue()) {
+ value = entry.getValue().getEnumValue().toString();
+ }
+
+ result.put(entry.getKey(), value);
+ }
+
+ return result;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEnumValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEnumValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEnumValueImpl.java
index f68fc7f..6828033 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEnumValueImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataEnumValueImpl.java
@@ -57,4 +57,11 @@ public class ODataEnumValueImpl extends AbstractODataValue implements ODataEnumV
public ODataLinkedComplexValue asLinkedComplex() {
return null;
}
+
+ @Override
+ public String toString() {
+ return getTypeName() + "'" + getValue() + "'";
+
+ }
+
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/4f59dba7/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java
index 34b4cfa..541c360 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPropertyImpl.java
@@ -49,7 +49,9 @@ public class ODataPropertyImpl extends AbstractODataProperty implements ODataPro
@Override
public ODataComplexValue<ODataProperty> getComplexValue() {
- return hasComplexValue() ? getValue().<ODataProperty>asComplex() : null;
+ return hasComplexValue()
+ ? getValue().<ODataProperty>asComplex()
+ : null;
}
@Override