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 14fa946b9..0d8da5226 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
@@ -51,16 +51,6 @@ public interface CommonODataBinder extends Serializable {
*/
Entry getEntry(CommonODataEntity entity, Class extends Entry> reference);
- /**
- * Gets an Entry from the given OData entity.
- *
- * @param entity OData entity.
- * @param reference reference class.
- * @param setType whether to explicitly output type information.
- * @return Entry object.
- */
- Entry getEntry(CommonODataEntity entity, Class extends Entry> reference, boolean setType);
-
/**
* Gets a Link from the given 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 Property 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.
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 a7ead37b2..2f54ecd37 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
@@ -45,16 +45,6 @@ public interface ODataWriter extends Serializable {
*/
InputStream writeEntities(Collection 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 entities, ODataPubFormat format, boolean outputType);
-
/**
* Serializes a single OData entity.
*
@@ -64,16 +54,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.
*
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/AbstractODataInvokeRequest.java
similarity index 77%
rename from lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/ODataInvokeRequestImpl.java
rename to lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractODataInvokeRequest.java
index 4e7be37ee..7018baf9d 100644
--- 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/AbstractODataInvokeRequest.java
@@ -21,7 +21,6 @@ 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;
@@ -30,7 +29,6 @@ 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;
@@ -45,6 +43,7 @@ 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;
@@ -52,7 +51,7 @@ import org.apache.olingo.client.core.communication.response.AbstractODataRespons
/**
* This class implements an OData invoke operation request.
*/
-public class ODataInvokeRequestImpl
+public abstract class AbstractODataInvokeRequest
extends AbstractODataBasicRequest, ODataPubFormat>
implements ODataInvokeRequest, ODataBatchableRequest {
@@ -61,7 +60,7 @@ public class ODataInvokeRequestImpl
/**
* Function parameters.
*/
- private Map parameters;
+ protected Map parameters;
/**
* Constructor.
@@ -71,7 +70,7 @@ public class ODataInvokeRequestImpl
* @param method HTTP method of the request.
* @param uri URI that identifies the operation.
*/
- public ODataInvokeRequestImpl(
+ public AbstractODataInvokeRequest(
final CommonODataClient odataClient,
final Class reference,
final HttpMethod method,
@@ -94,18 +93,24 @@ public class ODataInvokeRequestImpl
}
}
+ 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 = (reference.isAssignableFrom(CommonODataProperty.class) && format == ODataPubFormat.ATOM)
- ? ODataFormat.XML.toString(odataClient.getServiceVersion())
- : format.toString(odataClient.getServiceVersion());
+ 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) {
@@ -123,6 +128,12 @@ public class ODataInvokeRequestImpl
} 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) {
@@ -130,12 +141,14 @@ public class ODataInvokeRequestImpl
}
}
- return odataClient.getWriter().writeEntity(tmp, ODataPubFormat.JSON, false);
+ return odataClient.getWriter().writeEntity(tmp, getPOSTParameterFormat());
}
return null;
}
+ protected abstract URI buildGETURI();
+
/**
* {@inheritDoc }
*/
@@ -145,23 +158,11 @@ public class ODataInvokeRequestImpl
if (!this.parameters.isEmpty()) {
if (this.method == HttpMethod.GET) {
- final URIBuilder uriBuilder = new URIBuilder(this.uri);
- for (Map.Entry 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);
- }
+ ((HttpRequestBase) this.request).setURI(buildGETURI());
} else if (this.method == HttpMethod.POST) {
((HttpPost) request).setEntity(URIUtils.buildInputStreamEntity(odataClient, input));
- setContentType(ODataPubFormat.JSON.toString(odataClient.getServiceVersion()));
+ setContentType(getActualFormat(getPOSTParameterFormat()));
}
}
@@ -201,25 +202,24 @@ public class ODataInvokeRequestImpl
* {@inheritDoc }
*/
@Override
- @SuppressWarnings("unchecked")
public T getBody() {
if (invokeResult == null) {
- if (reference.isAssignableFrom(ODataNoContent.class)) {
- invokeResult = (T) new ODataNoContent();
+ if (ODataNoContent.class.isAssignableFrom(reference)) {
+ invokeResult = reference.cast(new ODataNoContent());
}
try {
- if (reference.isAssignableFrom(CommonODataEntitySet.class)) {
- invokeResult = (T) odataClient.getReader().readEntitySet(res.getEntity().getContent(),
- ODataPubFormat.fromString(getContentType()));
+ if (CommonODataEntitySet.class.isAssignableFrom(reference)) {
+ invokeResult = reference.cast(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 (CommonODataEntity.class.isAssignableFrom(reference)) {
+ invokeResult = reference.cast(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()));
+ if (CommonODataProperty.class.isAssignableFrom(reference)) {
+ invokeResult = reference.cast(odataClient.getReader().readProperty(res.getEntity().getContent(),
+ ODataFormat.fromString(getContentType())));
}
} catch (IOException e) {
throw new HttpClientException(e);
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 8781840a6..662f9db40 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) new ODataInvokeRequestImpl(
- client, CommonODataEntitySet.class, method, uri);
+ request = (ODataInvokeRequest) new ODataInvokeRequestImpl(
+ client, ODataEntitySet.class, method, uri);
} else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
- request = (ODataInvokeRequest) new ODataInvokeRequestImpl(
- client, CommonODataEntity.class, method, uri);
+ request = (ODataInvokeRequest) new ODataInvokeRequestImpl(
+ client, ODataEntity.class, method, uri);
} else {
- request = (ODataInvokeRequest) new ODataInvokeRequestImpl(
- client, CommonODataProperty.class, method, uri);
+ request = (ODataInvokeRequest) new ODataInvokeRequestImpl(
+ client, ODataProperty.class, method, uri);
}
}
if (parameters != null) {
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 000000000..1d0fb6521
--- /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 extends AbstractODataInvokeRequest {
+
+ public ODataInvokeRequestImpl(final CommonODataClient odataClient, final Class 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 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);
+ }
+ }
+
+}
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 da49df48a..4d5a4b1f8 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 ODataInvokeRequest getInvokeRequest(
final URI uri, final EdmOperation operation, final Map parameters) {
- throw new NotImplementedException("Not available yet.");
+ final HttpMethod method = operation instanceof EdmAction
+ ? HttpMethod.POST
+ : HttpMethod.GET;
+ final EdmReturnType returnType = operation.getReturnType();
+
+ ODataInvokeRequest request;
+ if (returnType == null) {
+ request = (ODataInvokeRequest) new ODataInvokeRequestImpl(
+ client, ODataNoContent.class, method, uri);
+ } else {
+ if (returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
+ request = (ODataInvokeRequest) new ODataInvokeRequestImpl(
+ client, ODataEntitySet.class, method, uri);
+ } else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) {
+ request = (ODataInvokeRequest) new ODataInvokeRequestImpl(
+ client, ODataEntity.class, method, uri);
+ } else {
+ request = (ODataInvokeRequest) new ODataInvokeRequestImpl(
+ client, ODataProperty.class, method, uri);
+ }
+ }
+ if (parameters != null) {
+ request.setParameters(parameters);
+ }
+
+ return request;
}
}
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 000000000..a59b727a2
--- /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 extends AbstractODataInvokeRequest {
+
+ private ODataPubFormat format;
+
+ public ODataInvokeRequestImpl(final CommonODataClient odataClient, final Class 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 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);
+ }
+ }
+
+}
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 71e08bb18..d927136d2 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));
}
}
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 7ea9c99b1..723070410 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 entities, final ODataPubFormat format) {
- return writeEntities(entities, format, true);
- }
-
- @Override
- public InputStream writeEntities(
- final Collection 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.singleton(entity), format, outputType);
+ return writeEntities(Collections.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 {
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 ab973d32d..c0ce3f384 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));
+ propertyResource.setValue(getValue(property.getValue(), reference));
- 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());
- }
+ 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;
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 adce2eedf..950ea532c 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));
+ propertyResource.setValue(getValue(_property.getValue(), reference));
- 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());
- }
+ 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()) {
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 841af8ff6..3496cec2c 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> itor =
- ((Map