From ef6ed4e3efea2464faa5c08bdffad6f50bf2cccd Mon Sep 17 00:00:00 2001 From: Christian Amend Date: Wed, 1 Apr 2015 10:18:52 +0200 Subject: [PATCH 1/4] [OLINGO-603] Action Parameter deserialization based on type kind --- .../api/edm/constants/EdmTypeKind.java | 2 +- .../deserializer/DeserializerException.java | 4 +++- .../json/ODataJsonDeserializer.java | 20 +++++++++++++++---- .../server-core-exceptions-i18n.properties | 2 ++ .../core/edm/provider/EdmTypeImplTest.java | 4 ++-- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/EdmTypeKind.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/EdmTypeKind.java index bf24673ac..b55ec1689 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/EdmTypeKind.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/constants/EdmTypeKind.java @@ -23,6 +23,6 @@ package org.apache.olingo.commons.api.edm.constants; */ public enum EdmTypeKind { - UNDEFINED, PRIMITIVE, ENUM, DEFINITION, COMPLEX, ENTITY, NAVIGATION, ACTION, FUNCTION, SYSTEM + PRIMITIVE, ENUM, DEFINITION, COMPLEX, ENTITY, NAVIGATION, ACTION, FUNCTION } diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerException.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerException.java index 8ccb253ed..1989df11e 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerException.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/deserializer/DeserializerException.java @@ -45,7 +45,9 @@ public class DeserializerException extends ODataTranslatedException { /** parameter: navigationPropertyName */NAVIGATION_PROPERTY_NOT_FOUND, /** parameter: annotationName */INVALID_ANNOTATION_TYPE, /** parameter: annotationName */INVALID_NULL_ANNOTATION, - /** parameter: binding link */INVALID_ENTITY_BINDING_LINK; + /** parameter: binding link */INVALID_ENTITY_BINDING_LINK, + /** parameter: action parameter name */INVALID_ACTION_PARAMETER_TYPE, + /** parameter: parameterName */ INVALID_NULL_PARAMETER; @Override public String getKey() { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java index 74c73c8f1..b9fe77059 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java @@ -215,13 +215,17 @@ public class ODataJsonDeserializer implements ODataDeserializer { ParameterImpl parameter = new ParameterImpl(); parameter.setName(name); JsonNode jsonNode = node.get(name); - if (jsonNode == null) { + if (jsonNode == null || jsonNode.isNull()) { if (!edmParameter.isNullable()) { - // TODO: new message key. throw new DeserializerException("Non-nullable parameter not present or null", - DeserializerException.MessageKeys.INVALID_NULL_PROPERTY, name); + DeserializerException.MessageKeys.INVALID_NULL_PARAMETER, name); } - } else { + } + + switch (edmParameter.getType().getKind()) { + case PRIMITIVE: + case DEFINITION: + case ENUM: Property consumePropertyNode = consumePropertyNode(edmParameter.getName(), edmParameter.getType(), edmParameter.isCollection(), edmParameter.isNullable(), edmParameter.getMaxLength(), edmParameter.getPrecision(), edmParameter @@ -231,6 +235,14 @@ public class ODataJsonDeserializer implements ODataDeserializer { parameter.setValue(consumePropertyNode.getValueType(), consumePropertyNode.getValue()); parameters.add(parameter); node.remove(name); + break; + case COMPLEX: + case ENTITY: + throw new DeserializerException("Entity an complex parameters currently not Implemented", + DeserializerException.MessageKeys.NOT_IMPLEMENTED); + default: + throw new DeserializerException("Invalid type kind " + edmParameter.getType().getKind().toString() + + " for action parameter: " + name, DeserializerException.MessageKeys.INVALID_ACTION_PARAMETER_TYPE, name); } } } diff --git a/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties b/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties index 76266ea9c..71013d24f 100644 --- a/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties +++ b/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties @@ -115,6 +115,8 @@ DeserializerException.UNKNOWN_PRIMITIVE_TYPE=Unknown primitive type '%1$s' for p DeserializerException.NAVIGATION_PROPERTY_NOT_FOUND=Can`t find navigation property with name: '%1$s'. DeserializerException.INVALID_ANNOTATION_TYPE=The annotation '%1$s' has the wrong JSON type. DeserializerException.INVALID_ENTITY_BINDING_LINK=The binding link '%1$s' is malformed. +DeserializerException.INVALID_ACTION_PARAMETER_TYPE=The action parameter '%1$s' must be either primitive, complex or an entity or a collection of those types. +DeserializerException.INVALID_NULL_PARAMETER=The parameter '%1$s' must not be null. BatchDeserializerException.INVALID_BOUNDARY=Invalid boundary at line '%1$s'. BatchDeserializerException.INVALID_CHANGESET_METHOD=Invalid method: a ChangeSet cannot contain retrieve requests at line '%1$s'. diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeImplTest.java index ddfd15dc0..b9f6db6b5 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeImplTest.java @@ -37,10 +37,10 @@ public class EdmTypeImplTest { @Test public void getterTest() { - EdmType type = new EdmTypeImplTester(new FullQualifiedName("namespace", "name"), EdmTypeKind.UNDEFINED); + EdmType type = new EdmTypeImplTester(new FullQualifiedName("namespace", "name"), EdmTypeKind.PRIMITIVE); assertEquals("name", type.getName()); assertEquals("namespace", type.getNamespace()); - assertEquals(EdmTypeKind.UNDEFINED, type.getKind()); + assertEquals(EdmTypeKind.PRIMITIVE, type.getKind()); EdmAnnotatable an = (EdmAnnotatable) type; assertNotNull(an.getAnnotations().get(0)); } From d067037f40766f10c6b8d95566436cba67755abb Mon Sep 17 00:00:00 2001 From: Christian Amend Date: Wed, 1 Apr 2015 14:23:26 +0200 Subject: [PATCH 2/4] [OLINGO-603] Further refactoring --- .../commons/EntityInvocationHandler.java | 2 +- .../apache/olingo/fit/AbstractServices.java | 10 +- .../communication/request/ODataRequest.java | 2 - .../cud/ODataReferenceAddingRequest.java | 20 +-- .../response/ODataBatchResponse.java | 2 +- .../ODataReferenceAddingResponse.java | 2 +- .../olingo/client/api/uri/URIBuilder.java | 2 +- .../olingo/client/api/uri/URIFilter.java | 2 +- .../request/AbstractODataRequest.java | 2 - .../olingo/client/core/uri/FilterConst.java | 2 +- .../olingo/client/core/uri/FilterLiteral.java | 2 +- .../client/core/uri/FilterProperty.java | 2 +- .../olingo/client/core/uri/URIUtils.java | 1 - .../commons/api/domain/ODataComplexValue.java | 1 - .../commons/api/domain/ODataInlineEntity.java | 2 - .../olingo/commons/api/domain/ODataLink.java | 1 - .../commons/api/domain/ODataLinkType.java | 1 - .../commons/api/edm/EdmPrimitiveTypeKind.java | 2 - .../commons/api/edm/provider/Schema.java | 4 +- .../commons/api/format/ODataFormat.java | 1 - .../api/serializer/FixedFormatSerializer.java | 2 +- .../json/ODataJsonDeserializer.java | 45 +++-- .../tecsvc/provider/ActionProvider.java | 161 ++++++++---------- ...aJsonDeserializerActionParametersTest.java | 31 ++++ .../core/uri/testutil/FilterValidator.java | 2 +- .../core/uri/testutil/ParserValidator.java | 6 +- 26 files changed, 161 insertions(+), 149 deletions(-) diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java index 20ab3a590..d3d7476b2 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java @@ -277,7 +277,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler /** * Gets the current ETag defined into the wrapped entity. * - * @return + * @return the current etag */ public String getETag() { return getEntity().getETag(); diff --git a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java index a2ccbaea5..de8c10eaf 100644 --- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java +++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java @@ -1463,7 +1463,7 @@ public abstract class AbstractServices { * @param path * @param format * @param changes - * @return + * @return response */ @PUT @Path("/{entitySetName}({entityId})/{path:.*}/$value") @@ -1491,7 +1491,7 @@ public abstract class AbstractServices { * @param path * @param format * @param changes - * @return + * @return response */ @MERGE @Path("/{entitySetName}({entityId})/{path:.*}") @@ -1519,7 +1519,7 @@ public abstract class AbstractServices { * @param path * @param format * @param changes - * @return + * @return response */ @PATCH @Path("/{entitySetName}({entityId})/{path:.*}") @@ -1587,7 +1587,7 @@ public abstract class AbstractServices { * @param path * @param format * @param changes - * @return + * @return response */ @PUT @Path("/{entitySetName}({entityId})/{path:.*}") @@ -1650,7 +1650,7 @@ public abstract class AbstractServices { * @param entityId * @param path * @param format - * @return + * @return response */ @DELETE @Path("/{entitySetName}({entityId})/{path:.*}/$value") diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataRequest.java index b97085f68..55831b7e0 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataRequest.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataRequest.java @@ -28,9 +28,7 @@ import org.apache.olingo.commons.api.http.HttpMethod; /** * Abstract representation of an OData request. Get instance by using factories. * - * @see org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory * @see org.apache.olingo.client.api.communication.request.cud.CUDRequestFactory - * @see org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory * @see org.apache.olingo.client.api.communication.request.batch.BatchRequestFactory * @see org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory */ diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataReferenceAddingRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataReferenceAddingRequest.java index ad34ecbf3..82f001a4b 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataReferenceAddingRequest.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/ODataReferenceAddingRequest.java @@ -1,18 +1,18 @@ /* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file + * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file + * 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 - * + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -28,12 +28,12 @@ import org.apache.olingo.client.api.communication.response.ODataReferenceAddingR * ODataReferenceAdding requests eighter add or change the reference of navigation properties. * * If the navigation property is a collection of navigation references, the request adds a new reference to the - * collection. [OData Protocol 4.0 - 11.4.6.1] + * collection. [OData Protocol 4.0 - 11.4.6.1] * * If the request addresses an navigation property, which references a single entity, the reference will * be changed to the value provided by the request. [OData-Protocol 4.0 - 11.4.6.3] */ -public interface ODataReferenceAddingRequest - extends ODataBasicRequest, ODataBatchableRequest { +public interface ODataReferenceAddingRequest extends ODataBasicRequest, + ODataBatchableRequest { //No additional methods needed for now. } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataBatchResponse.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataBatchResponse.java index 744758e73..358c44155 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataBatchResponse.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataBatchResponse.java @@ -25,7 +25,7 @@ import org.apache.olingo.client.api.communication.request.batch.ODataBatchRespon /** * This class implements a response to a batch request. * - * @see org.apache.olingo.client.api.communication.request.batch.CommonODataBatchRequest + * @see org.apache.olingo.client.api.communication.request.batch.ODataBatchRequest */ public interface ODataBatchResponse extends ODataResponse { diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataReferenceAddingResponse.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataReferenceAddingResponse.java index adae48503..51bba0c95 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataReferenceAddingResponse.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/response/ODataReferenceAddingResponse.java @@ -25,7 +25,7 @@ package org.apache.olingo.client.api.communication.response; * If the request was successful, the service response has status code 204 and * the body has to be empty. * - * @see org.apache.olingo.client.api.communication.request.cud.api.request.cud.v4.ODataReferenceAddingRequest + * @see org.apache.olingo.client.api.communication.request.cud.ODataReferenceAddingRequest */ public interface ODataReferenceAddingResponse extends ODataResponse { //No additional methods needed for now. diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/uri/URIBuilder.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/uri/URIBuilder.java index d0eaac9dd..af6beb75b 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/uri/URIBuilder.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/uri/URIBuilder.java @@ -175,7 +175,7 @@ public interface URIBuilder { * @return current URIBuilder instance * @see QueryOption#FILTER * @see URIFilter - * @see org.apache.olingo.client.api.uri.CommonFilterFactory + * @see org.apache.olingo.client.api.uri.FilterFactory */ URIBuilder filter(URIFilter filter); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/uri/URIFilter.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/uri/URIFilter.java index 2162b87bc..517079dfd 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/uri/URIFilter.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/uri/URIFilter.java @@ -21,7 +21,7 @@ package org.apache.olingo.client.api.uri; /** * Interface for any available filter; obtain instances via FilterFactory. * - * @see org.apache.olingo.client.api.uri.CommonFilterFactory + * @see org.apache.olingo.client.api.uri.FilterFactory */ public interface URIFilter { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java index d10960a26..bdfd11831 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java @@ -47,9 +47,7 @@ import org.apache.olingo.commons.api.http.HttpMethod; /** * Abstract representation of an OData request. Get instance by using factories. * - * @see org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory * @see org.apache.olingo.client.api.communication.request.cud.CUDRequestFactory - * @see org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory * @see org.apache.olingo.client.api.communication.request.batch.BatchRequestFactory * @see org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory */ diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterConst.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterConst.java index c3e76692c..f1732cc72 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterConst.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterConst.java @@ -23,7 +23,7 @@ import org.apache.olingo.client.api.uri.FilterArg; /** * Filter property path; obtain instances via FilterArgFactory. * - * @see org.apache.olingo.client.api.uri.CommonFilterArgFactory + * @see org.apache.olingo.client.api.uri.FilterArgFactory */ public class FilterConst implements FilterArg { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterLiteral.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterLiteral.java index 4842a9630..501a7342d 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterLiteral.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterLiteral.java @@ -23,7 +23,7 @@ import org.apache.olingo.client.api.uri.FilterArg; /** * Filter value literals; obtain instances via FilterArgFactory. * - * @see org.apache.olingo.client.api.uri.v3.FilterArgFactory + * @see org.apache.olingo.client.api.uri.FilterArgFactory */ public class FilterLiteral implements FilterArg { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterProperty.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterProperty.java index bc99eb495..6073112b4 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterProperty.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/FilterProperty.java @@ -23,7 +23,7 @@ import org.apache.olingo.client.api.uri.FilterArg; /** * Filter property path; obtain instances via FilterArgFactory. * - * @see org.apache.olingo.client.api.uri.CommonFilterArgFactory + * @see org.apache.olingo.client.api.uri.FilterArgFactory */ public class FilterProperty implements FilterArg { 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 26399c268..608dc3a38 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 @@ -179,7 +179,6 @@ public final class URIUtils { /** * Turns primitive values into their respective URI representation. * - * @param version OData protocol version * @param obj primitive value * @return URI representation */ 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 04888d795..ad64559b4 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 @@ -23,7 +23,6 @@ import java.util.Map; /** * OData complex property value. * - * @param The actual ODataProperty interface. */ public interface ODataComplexValue extends ODataValue, ODataLinked, ODataAnnotatable, Iterable { diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntity.java index ff9a4203c..6ba0ad638 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntity.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataInlineEntity.java @@ -30,7 +30,6 @@ public class ODataInlineEntity extends ODataLink { /** * Constructor. * - * @param version OData service version. * @param uri edit link. * @param type type. * @param title title. @@ -45,7 +44,6 @@ public class ODataInlineEntity extends ODataLink { /** * Constructor. * - * @param version OData service version. * @param baseURI base URI. * @param href href. * @param type type. diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLink.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLink.java index 4bc8bdba2..859367918 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLink.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLink.java @@ -105,7 +105,6 @@ public class ODataLink extends ODataItem implements ODataAnnotatable { /** * Constructor. * - * @param version OData service version. * @param uri URI. * @param type type. * @param title title. diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java index f99aa3e33..5ae427cb8 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataLinkType.java @@ -73,7 +73,6 @@ public enum ODataLinkType { * Gets * LinkType instance from the given rel and type. * - * @param version OData protocol version. * @param rel rel. * @param type type. * @return ODataLinkType object. diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmPrimitiveTypeKind.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmPrimitiveTypeKind.java index b7efca716..78dd0139a 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmPrimitiveTypeKind.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmPrimitiveTypeKind.java @@ -81,7 +81,6 @@ public enum EdmPrimitiveTypeKind { /** * Gets EdmPrimitiveTypeKind from a full-qualified type name, for the given OData protocol version. * - * @param version OData protocol version. * @param fqn full-qualified type name. * @return EdmPrimitiveTypeKind object. */ @@ -93,7 +92,6 @@ public enum EdmPrimitiveTypeKind { * Gets EdmPrimitiveTypeKind from a full type expression (as Edm.Int32), for the given OData * protocol version. * - * @param version OData protocol version. * @param fqn string value type. * @return EdmPrimitiveTypeKind object. */ diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Schema.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Schema.java index 183478fe4..7ed27041e 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Schema.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/provider/Schema.java @@ -131,7 +131,7 @@ public class Schema extends AbstractEdmItem implements Annotatable{ /** * All actions with the given name * @param name - * @return + * @return a list of actions */ public List getActions(final String name) { return getAllByName(name, getActions()); @@ -149,7 +149,7 @@ public class Schema extends AbstractEdmItem implements Annotatable{ /** * All functions with the given name * @param name - * @return + * @return a list of functions */ public List getFunctions(final String name) { return getAllByName(name, getFunctions()); diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java index 6a4b494f3..52e4bec5d 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/format/ODataFormat.java @@ -57,7 +57,6 @@ public enum ODataFormat { /** * Gets format as {@link ContentType}. - * @param version OData service version. * @return format as ContentType. */ public ContentType getContentType() { diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/FixedFormatSerializer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/FixedFormatSerializer.java index a62531baf..9a0e6934d 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/FixedFormatSerializer.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/FixedFormatSerializer.java @@ -53,7 +53,7 @@ public interface FixedFormatSerializer { * Serializes a batch response * @param batchResponses * @param boundary - * @return + * @return response as an input stream * @throws BatchSerializerException */ InputStream batchResponse(List batchResponses, String boundary) throws BatchSerializerException; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java index b9fe77059..22e570ef7 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializer.java @@ -183,7 +183,7 @@ public class ODataJsonDeserializer implements ODataDeserializer { public List actionParameters(InputStream stream, final EdmAction edmAction) throws DeserializerException { try { ObjectNode tree = parseJsonTree(stream); - ArrayList parameters = new ArrayList(); + List parameters = new ArrayList(); consumeParameters(edmAction, tree, parameters); assertJsonNodeIsEmpty(tree); return parameters; @@ -208,33 +208,42 @@ public class ODataJsonDeserializer implements ODataDeserializer { return tree; } - private void consumeParameters(final EdmAction edmAction, ObjectNode node, ArrayList parameters) + private void consumeParameters(final EdmAction edmAction, ObjectNode node, List parameters) throws DeserializerException { - for (final String name : edmAction.getParameterNames()) { + List parameterNames = edmAction.getParameterNames(); + if (edmAction.isBound()) { + // The binding parameter must not occur in the payload. + parameterNames = parameterNames.subList(1, parameterNames.size()); + } + for (final String name : parameterNames) { final EdmParameter edmParameter = edmAction.getParameter(name); ParameterImpl parameter = new ParameterImpl(); parameter.setName(name); JsonNode jsonNode = node.get(name); - if (jsonNode == null || jsonNode.isNull()) { - if (!edmParameter.isNullable()) { - throw new DeserializerException("Non-nullable parameter not present or null", - DeserializerException.MessageKeys.INVALID_NULL_PARAMETER, name); - } - } switch (edmParameter.getType().getKind()) { case PRIMITIVE: case DEFINITION: case ENUM: - Property consumePropertyNode = - consumePropertyNode(edmParameter.getName(), edmParameter.getType(), edmParameter.isCollection(), - edmParameter.isNullable(), edmParameter.getMaxLength(), edmParameter.getPrecision(), edmParameter - .getScale(), - true, edmParameter.getMapping(), - jsonNode); - parameter.setValue(consumePropertyNode.getValueType(), consumePropertyNode.getValue()); - parameters.add(parameter); - node.remove(name); + if (jsonNode == null || jsonNode.isNull()) { + if (!edmParameter.isNullable()) { + throw new DeserializerException("Non-nullable parameter not present or null", + DeserializerException.MessageKeys.INVALID_NULL_PARAMETER, name); + } + if (edmParameter.isCollection()) { + throw new DeserializerException("Collection must not be null for parameter: " + name, + DeserializerException.MessageKeys.INVALID_NULL_PARAMETER, name); + } + parameter.setValue(ValueType.PRIMITIVE, null); + } else { + Property consumePropertyNode = + consumePropertyNode(edmParameter.getName(), edmParameter.getType(), edmParameter.isCollection(), + edmParameter.isNullable(), edmParameter.getMaxLength(), edmParameter.getPrecision(), edmParameter + .getScale(), true, edmParameter.getMapping(), jsonNode); + parameter.setValue(consumePropertyNode.getValueType(), consumePropertyNode.getValue()); + parameters.add(parameter); + node.remove(name); + } break; case COMPLEX: case ENTITY: diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ActionProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ActionProvider.java index 43183535f..d00b95301 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ActionProvider.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ActionProvider.java @@ -50,7 +50,7 @@ public class ActionProvider { new FullQualifiedName(SchemaProvider.NAMESPACE, "BAETTwoKeyNavRTETTwoKeyNav"); public static final FullQualifiedName nameBAETAllPrimRT = - new FullQualifiedName(SchemaProvider.NAMESPACE, "BAESAllPrimRT"); + new FullQualifiedName(SchemaProvider.NAMESPACE, "BAETAllPrimRT"); // Unbound Actions public static final FullQualifiedName nameUARTString = new FullQualifiedName(SchemaProvider.NAMESPACE, @@ -77,74 +77,67 @@ public class ActionProvider { public List getActions(final FullQualifiedName actionName) throws ODataException { if (actionName.equals(nameUARTString)) { - return Arrays.asList( - new Action().setName(nameUARTString.getName()) - .setReturnType(new ReturnType().setType(PropertyProvider.nameString)) - ); + return Collections.singletonList( + new Action().setName(nameUARTString.getName()) + .setReturnType(new ReturnType().setType(PropertyProvider.nameString))); + } else if (actionName.equals(nameUARTCollStringTwoParam)) { - return Arrays.asList( - new Action().setName(nameUARTCollStringTwoParam.getName()) - .setParameters(Arrays.asList( - new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16), - new Parameter().setName("ParameterDuration").setType(PropertyProvider.nameDuration))) - .setReturnType(new ReturnType().setType(PropertyProvider.nameString).setCollection(true)) - ); + return Collections.singletonList( + new Action().setName(nameUARTCollStringTwoParam.getName()) + .setParameters(Arrays.asList( + new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16), + new Parameter().setName("ParameterDuration").setType(PropertyProvider.nameDuration))) + .setReturnType(new ReturnType().setType(PropertyProvider.nameString).setCollection(true))); } else if (actionName.equals(nameUARTCTTwoPrimParam)) { - return Arrays.asList( - new Action().setName(nameUARTCTTwoPrimParam.getName()) - .setParameters(Arrays.asList( - new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16) - .setNullable(false))) - .setReturnType( - new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setNullable(false)) - ); - + return Collections.singletonList( + new Action().setName(nameUARTCTTwoPrimParam.getName()) + .setParameters(Collections.singletonList( + new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16) + .setNullable(false))) + .setReturnType( + new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setNullable(false))); + } else if (actionName.equals(nameUARTCollCTTwoPrimParam)) { - return Arrays.asList( - new Action().setName(nameUARTCollCTTwoPrimParam.getName()) - .setParameters(Arrays.asList( - new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16))) - .setReturnType( - new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setCollection(true)) - ); + return Collections.singletonList( + new Action().setName(nameUARTCollCTTwoPrimParam.getName()) + .setParameters(Collections.singletonList( + new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16))) + .setReturnType( + new ReturnType().setType(ComplexTypeProvider.nameCTTwoPrim).setCollection(true))); } else if (actionName.equals(nameUARTETTwoKeyTwoPrimParam)) { - return Arrays.asList( - new Action().setName(nameUARTETTwoKeyTwoPrimParam.getName()) - .setParameters(Arrays.asList( - new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16))) - .setReturnType( - new ReturnType().setType(EntityTypeProvider.nameETTwoKeyTwoPrim)) - ); + return Collections.singletonList( + new Action().setName(nameUARTETTwoKeyTwoPrimParam.getName()) + .setParameters(Collections.singletonList( + new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16))) + .setReturnType( + new ReturnType().setType(EntityTypeProvider.nameETTwoKeyTwoPrim))); } else if (actionName.equals(nameUARTCollETKeyNavParam)) { - return Arrays.asList( - new Action().setName(nameUARTCollETKeyNavParam.getName()) - .setParameters(Arrays.asList( - new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16))) - .setReturnType( - new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setCollection(true)) - ); + return Collections.singletonList( + new Action().setName(nameUARTCollETKeyNavParam.getName()) + .setParameters(Collections.singletonList( + new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16))) + .setReturnType( + new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setCollection(true))); } else if (actionName.equals(nameUARTETAllPrimParam)) { - return Arrays.asList( - new Action().setName(nameUARTETAllPrimParam.getName()) - .setParameters(Arrays.asList( - new Parameter().setName("ParameterDate").setType(PropertyProvider.nameDate))) - .setReturnType( - new ReturnType().setType(EntityTypeProvider.nameETAllPrim)) - ); + return Collections.singletonList( + new Action().setName(nameUARTETAllPrimParam.getName()) + .setParameters(Collections.singletonList( + new Parameter().setName("ParameterDate").setType(PropertyProvider.nameDate))) + .setReturnType( + new ReturnType().setType(EntityTypeProvider.nameETAllPrim))); } else if (actionName.equals(nameUARTCollETAllPrimParam)) { - return Arrays.asList( - new Action().setName(nameUARTCollETAllPrimParam.getName()) - .setParameters(Arrays.asList( - new Parameter().setName("ParameterTimeOfDay") - .setType(PropertyProvider.nameTimeOfDay))) - .setReturnType( - new ReturnType().setType(EntityTypeProvider.nameETAllPrim).setCollection(true)) - ); + return Collections.singletonList( + new Action().setName(nameUARTCollETAllPrimParam.getName()) + .setParameters(Collections.singletonList( + new Parameter().setName("ParameterTimeOfDay") + .setType(PropertyProvider.nameTimeOfDay))) + .setReturnType( + new ReturnType().setType(EntityTypeProvider.nameETAllPrim).setCollection(true))); } else if (actionName.equals(nameUART)) { return Collections.singletonList(new Action().setName(nameUART.getName())); @@ -186,26 +179,22 @@ public class ActionProvider { } else if (actionName.equals(nameBAESAllPrimRTETAllPrim)) { return Arrays.asList( new Action().setName("BAESAllPrimRTETAllPrim") - .setParameters( - Arrays.asList( - new Parameter().setName("ParameterESAllPrim").setType(EntityTypeProvider.nameETAllPrim) - .setCollection(true).setNullable(false))) + .setParameters(Arrays.asList( + new Parameter().setName("ParameterESAllPrim").setType(EntityTypeProvider.nameETAllPrim) + .setCollection(true).setNullable(false))) .setBound(true) .setReturnType( - new ReturnType().setType(EntityTypeProvider.nameETAllPrim)) - ); + new ReturnType().setType(EntityTypeProvider.nameETAllPrim))); } else if (actionName.equals(nameBAESTwoKeyNavRTESTwoKeyNav)) { return Arrays.asList( new Action().setName("BAESTwoKeyNavRTESTwoKeyNav") - .setParameters( - Arrays.asList( - new Parameter().setName("ParameterETTwoKeyNav").setType(EntityTypeProvider.nameETTwoKeyNav) - .setCollection(true).setNullable(false))) + .setParameters(Arrays.asList( + new Parameter().setName("ParameterETTwoKeyNav").setType(EntityTypeProvider.nameETTwoKeyNav) + .setCollection(true).setNullable(false))) .setBound(true) .setReturnType( - new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true)) - ); + new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav).setCollection(true))); } else if(actionName.equals(nameBAESTwoKeyNavRTESKeyNav)) { return Arrays.asList( @@ -214,12 +203,12 @@ public class ActionProvider { .setEntitySetPath("BindingParam/NavPropertyETKeyNavMany") .setParameters(Arrays.asList( new Parameter().setName("ParameterETTwoKeyNav") - .setType(EntityTypeProvider.nameETTwoKeyNav) - .setCollection(true) - .setNullable(false) - )) - .setReturnType(new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setCollection(true)) - ); + .setType(EntityTypeProvider.nameETTwoKeyNav) + .setCollection(true) + .setNullable(false))) + .setReturnType( + new ReturnType().setType(EntityTypeProvider.nameETKeyNav).setCollection(true))); + } else if (actionName.equals(nameBAETBaseTwoKeyNavRTETBaseTwoKeyNav)) { return Arrays.asList( new Action().setName("BAETBaseTwoKeyNavRTETBaseTwoKeyNav") @@ -228,20 +217,19 @@ public class ActionProvider { .setNullable(false))) .setBound(true) .setReturnType( - new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav)) - ); + new ReturnType().setType(EntityTypeProvider.nameETTwoKeyNav))); } else if (actionName.equals(nameBAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav)) { return Arrays.asList( new Action().setName("BAETTwoBaseTwoKeyNavRTETBaseTwoKeyNav") - .setParameters( - Arrays.asList( - new Parameter().setName("ParameterETTwoBaseTwoKeyNav").setType( - EntityTypeProvider.nameETTwoBaseTwoKeyNav).setNullable(false))) + .setParameters(Arrays.asList( + new Parameter().setName("ParameterETTwoBaseTwoKeyNav") + .setType(EntityTypeProvider.nameETTwoBaseTwoKeyNav) + .setNullable(false))) .setBound(true) .setReturnType( - new ReturnType().setType(EntityTypeProvider.nameETBaseTwoKeyNav)) - ); + new ReturnType().setType(EntityTypeProvider.nameETBaseTwoKeyNav))); + } else if(actionName.equals(nameBAETAllPrimRT)) { return Arrays.asList( new Action().setName("BAETAllPrimRT") @@ -249,17 +237,14 @@ public class ActionProvider { .setParameters(Arrays.asList( new Parameter().setName("ParameterETAllPrim") .setNullable(false) - .setType(EntityTypeProvider.nameETAllPrim) - )), + .setType(EntityTypeProvider.nameETAllPrim))), new Action().setName("BAETAllPrimRT") .setBound(true) .setParameters(Arrays.asList( new Parameter().setName("ParameterETAllPrim") .setNullable(false) .setCollection(true) - .setType(EntityTypeProvider.nameETAllPrim) - )) - ); + .setType(EntityTypeProvider.nameETAllPrim)))); } return null; diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java index 80668eb10..58777abc9 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/deserializer/json/ODataJsonDeserializerActionParametersTest.java @@ -57,6 +57,29 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese assertEquals(BigDecimal.valueOf(3669753), parameter.getValue()); } + @Test + public void boundEmpty() throws Exception { + final String input = "{}"; + final List parameters = deserialize(input, "BAETAllPrimRT", "ETAllPrim"); + assertNotNull(parameters); + assertTrue(parameters.isEmpty()); + } + + @Test(expected = DeserializerException.class) + public void bindingParameter() throws Exception { + deserialize("{\"ParameterETAllPrim\":{\"PropertyInt16\":42}}", "BAETAllPrimRT", "ETAllPrim"); + } + + @Test(expected = DeserializerException.class) + public void wrongName() throws Exception { + deserialize("{\"ParameterWrong\":null}", "UARTParam"); + } + + @Test(expected = DeserializerException.class) + public void nullNotNullable() throws Exception { + deserialize("{\"ParameterInt16\":null}", "UARTCTTwoPrimParam"); + } + @Test(expected = DeserializerException.class) public void missingParameter() throws Exception { deserialize("{}", "UARTCTTwoPrimParam"); @@ -77,4 +100,12 @@ public class ODataJsonDeserializerActionParametersTest extends AbstractODataDese .actionParameters(new ByteArrayInputStream(input.getBytes()), edm.getUnboundAction(new FullQualifiedName("Namespace1_Alias", actionName))); } + + private List deserialize(final String input, final String actionName, final String typeName) + throws DeserializerException { + return OData.newInstance().createDeserializer(ODataFormat.JSON) + .actionParameters(new ByteArrayInputStream(input.getBytes()), + edm.getBoundAction(new FullQualifiedName("Namespace1_Alias", actionName), + new FullQualifiedName("Namespace1_Alias", typeName), false)); + } } diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java index f5304566d..4d67fcdca 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterValidator.java @@ -286,7 +286,7 @@ public class FilterValidator implements TestValidator { * Validates the serialized filterTree against a given filterString * The given expected filterString is compressed before to allow better readable code in the unit tests * @param toBeCompr - * @return + * @return {@link FilterValidator} */ public FilterValidator isCompr(final String toBeCompr) { return is(compress(toBeCompr)); diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java index aeb130969..da65ff029 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ParserValidator.java @@ -57,7 +57,7 @@ public class ParserValidator { * Used in fast LL Parsing: * Don't stop the parsing process when the slower full context parsing (with prediction mode SLL) is * required - * @return + * @return {@link ParserValidator} */ public ParserValidator aFC() { allowFullContext = true; @@ -68,7 +68,7 @@ public class ParserValidator { * Used in fast LL Parsing: * Allows ContextSensitifity Errors which occur often when using the slower full context parsing * and indicate that there is a context sensitivity ( which may not be an error). - * @return + * @return {@link ParserValidator} */ public ParserValidator aCS() { allowContextSensitifity = true; @@ -78,7 +78,7 @@ public class ParserValidator { /** * Used in fast LL Parsing: * Allows ambiguities - * @return + * @return {@link ParserValidator} */ public ParserValidator aAM() { allowAmbiguity = true; From 5855c6b6241842cfc984f3a739f1ab9f55488fc4 Mon Sep 17 00:00:00 2001 From: Christian Amend Date: Wed, 1 Apr 2015 15:19:41 +0200 Subject: [PATCH 3/4] [OLINGO-603] Delete unnecessary deserializer constants --- .../olingo/commons/api/edm/EdmOperation.java | 4 +- .../serialization/JsonDeltaDeserializer.java | 12 ++-- .../core/serialization/JsonDeserializer.java | 50 +++---------- .../serialization/JsonEntityDeserializer.java | 70 ++++++++++--------- .../JsonEntitySetDeserializer.java | 18 ++--- .../JsonODataErrorDeserializer.java | 4 +- .../JsonPropertyDeserializer.java | 7 +- 7 files changed, 70 insertions(+), 95 deletions(-) diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java index d6101b3a6..c90316df7 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java @@ -32,6 +32,8 @@ public interface EdmOperation extends EdmType, EdmAnnotatable { EdmParameter getParameter(String name); /** + * A list of all parameter names. If this is a bound action or function the first parameter name in the list is the + * binding parameter * @return a list of all parameter names */ List getParameterNames(); @@ -63,7 +65,7 @@ public interface EdmOperation extends EdmType, EdmAnnotatable { * @return true if binding parameter is of type collection. */ Boolean isBindingParameterTypeCollection(); - + /** * @return the entity set path as a String or null if not present */ diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java index 5cb207632..de79cf72f 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java @@ -56,14 +56,14 @@ public class JsonDeltaDeserializer extends JsonDeserializer { delta.setBaseURI(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA)); } - if (tree.hasNonNull(jsonCount)) { - delta.setCount(tree.get(jsonCount).asInt()); + if (tree.hasNonNull(Constants.JSON_COUNT)) { + delta.setCount(tree.get(Constants.JSON_COUNT).asInt()); } - if (tree.hasNonNull(jsonNextLink)) { - delta.setNext(URI.create(tree.get(jsonNextLink).textValue())); + if (tree.hasNonNull(Constants.JSON_NEXT_LINK)) { + delta.setNext(URI.create(tree.get(Constants.JSON_NEXT_LINK).textValue())); } - if (tree.hasNonNull(jsonDeltaLink)) { - delta.setDeltaLink(URI.create(tree.get(jsonDeltaLink).textValue())); + if (tree.hasNonNull(Constants.JSON_DELTA_LINK)) { + delta.setDeltaLink(URI.create(tree.get(Constants.JSON_DELTA_LINK).textValue())); } if (tree.hasNonNull(Constants.VALUE)) { diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java index fc7e4f8cf..96416238a 100755 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java @@ -72,36 +72,6 @@ public class JsonDeserializer implements ODataDeserializer { protected final boolean serverMode; - protected String jsonType = Constants.JSON_TYPE; - - protected String jsonId = Constants.JSON_ID; - - protected String jsonETag = Constants.JSON_ETAG; - - protected String jsonReadLink = Constants.JSON_READ_LINK; - - protected String jsonEditLink = Constants.JSON_EDIT_LINK; - - protected String jsonMediaEditLink = Constants.JSON_MEDIA_EDIT_LINK; - - protected String jsonMediaReadLink = Constants.JSON_MEDIA_READ_LINK; - - protected String jsonMediaContentType = Constants.JSON_MEDIA_CONTENT_TYPE; - - protected String jsonMediaETag = Constants.JSON_MEDIA_ETAG; - - protected String jsonAssociationLink = Constants.JSON_ASSOCIATION_LINK; - - protected String jsonNavigationLink = Constants.JSON_NAVIGATION_LINK; - - protected String jsonCount = Constants.JSON_COUNT; - - protected String jsonNextLink = Constants.JSON_NEXT_LINK; - - protected String jsonDeltaLink = Constants.JSON_DELTA_LINK; - - protected String jsonError = Constants.JSON_ERROR; - private JsonGeoValueDeserializer geoDeserializer; private JsonParser parser; @@ -163,7 +133,7 @@ public class JsonDeserializer implements ODataDeserializer { private void clientLinks(final Map.Entry field, final Linked linked, final Set toRemove, final JsonNode tree, final ObjectCodec codec) throws IOException { - if (field.getKey().endsWith(jsonNavigationLink)) { + if (field.getKey().endsWith(Constants.JSON_NAVIGATION_LINK)) { final LinkImpl link = new LinkImpl(); link.setTitle(getTitle(field)); link.setRel(Constants.NS_NAVIGATION_LINK_REL + getTitle(field)); @@ -176,8 +146,8 @@ public class JsonDeserializer implements ODataDeserializer { linked.getNavigationLinks().add(link); toRemove.add(field.getKey()); - toRemove.add(setInline(field.getKey(), jsonNavigationLink, tree, codec, link)); - } else if (field.getKey().endsWith(jsonAssociationLink)) { + toRemove.add(setInline(field.getKey(), Constants.JSON_NAVIGATION_LINK, tree, codec, link)); + } else if (field.getKey().endsWith(Constants.JSON_ASSOCIATION_LINK)) { final LinkImpl link = new LinkImpl(); link.setTitle(getTitle(field)); link.setRel(Constants.NS_ASSOCIATION_LINK_REL + getTitle(field)); @@ -193,7 +163,7 @@ public class JsonDeserializer implements ODataDeserializer { final JsonNode tree, final ObjectCodec codec) throws IOException { if (field.getKey().endsWith(Constants.JSON_BIND_LINK_SUFFIX) - || field.getKey().endsWith(jsonNavigationLink)) { + || field.getKey().endsWith(Constants.JSON_NAVIGATION_LINK)) { if (field.getValue().isValueNode()) { final String suffix = field.getKey().replaceAll("^.*@", "@"); @@ -280,7 +250,7 @@ public class JsonDeserializer implements ODataDeserializer { if (annotatable != null) { annotatable.getAnnotations().add(entityAnnot); } - } else if (type == null && field.getKey().endsWith(getJSONAnnotation(jsonType))) { + } else if (type == null && field.getKey().endsWith(getJSONAnnotation(Constants.JSON_TYPE))) { type = field.getValue().asText(); } else if (annotation == null && customAnnotation.matches() && !"odata".equals(customAnnotation.group(2))) { annotation = new AnnotationImpl(); @@ -354,8 +324,8 @@ public class JsonDeserializer implements ODataDeserializer { values.add(child.asText()); } } else if (child.isContainerNode()) { - if (child.has(jsonType)) { - ((ObjectNode) child).remove(jsonType); + if (child.has(Constants.JSON_TYPE)) { + ((ObjectNode) child).remove(Constants.JSON_TYPE); } final Object value = fromComplex((ObjectNode) child, codec); valueType = ValueType.COLLECTION_COMPLEX; @@ -387,9 +357,9 @@ public class JsonDeserializer implements ODataDeserializer { break; case COMPLEX: - if (node.has(jsonType)) { - valuable.setType(node.get(jsonType).asText()); - ((ObjectNode) node).remove(jsonType); + if (node.has(Constants.JSON_TYPE)) { + valuable.setType(node.get(Constants.JSON_TYPE).asText()); + ((ObjectNode) node).remove(Constants.JSON_TYPE); } final Object value = fromComplex((ObjectNode) node, codec); valuable.setValue(ValueType.COMPLEX, value); diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java index b63950b27..228ac062d 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java @@ -82,7 +82,7 @@ public class JsonEntityDeserializer extends JsonDeserializer { if (contextURL != null) { entity.setBaseURI(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA)); } - + final String metadataETag; if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) { metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue(); @@ -91,56 +91,57 @@ public class JsonEntityDeserializer extends JsonDeserializer { metadataETag = null; } - if (tree.hasNonNull(jsonETag)) { - entity.setETag(tree.get(jsonETag).textValue()); - tree.remove(jsonETag); + if (tree.hasNonNull(Constants.JSON_ETAG)) { + entity.setETag(tree.get(Constants.JSON_ETAG).textValue()); + tree.remove(Constants.JSON_ETAG); } - if (tree.hasNonNull(jsonType)) { - entity.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(jsonType).textValue()).build().internal()); - tree.remove(jsonType); + if (tree.hasNonNull(Constants.JSON_TYPE)) { + entity.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(Constants.JSON_TYPE).textValue()).build() + .internal()); + tree.remove(Constants.JSON_TYPE); } - if (tree.hasNonNull(jsonId)) { - entity.setId(URI.create(tree.get(jsonId).textValue())); - tree.remove(jsonId); + if (tree.hasNonNull(Constants.JSON_ID)) { + entity.setId(URI.create(tree.get(Constants.JSON_ID).textValue())); + tree.remove(Constants.JSON_ID); } - if (tree.hasNonNull(jsonReadLink)) { + if (tree.hasNonNull(Constants.JSON_READ_LINK)) { final LinkImpl link = new LinkImpl(); link.setRel(Constants.SELF_LINK_REL); - link.setHref(tree.get(jsonReadLink).textValue()); + link.setHref(tree.get(Constants.JSON_READ_LINK).textValue()); entity.setSelfLink(link); - tree.remove(jsonReadLink); + tree.remove(Constants.JSON_READ_LINK); } - if (tree.hasNonNull(jsonEditLink)) { + if (tree.hasNonNull(Constants.JSON_EDIT_LINK)) { final LinkImpl link = new LinkImpl(); if (serverMode) { link.setRel(Constants.EDIT_LINK_REL); } - link.setHref(tree.get(jsonEditLink).textValue()); + link.setHref(tree.get(Constants.JSON_EDIT_LINK).textValue()); entity.setEditLink(link); - tree.remove(jsonEditLink); + tree.remove(Constants.JSON_EDIT_LINK); } - if (tree.hasNonNull(jsonMediaReadLink)) { - entity.setMediaContentSource(URI.create(tree.get(jsonMediaReadLink).textValue())); - tree.remove(jsonMediaReadLink); + if (tree.hasNonNull(Constants.JSON_MEDIA_READ_LINK)) { + entity.setMediaContentSource(URI.create(tree.get(Constants.JSON_MEDIA_READ_LINK).textValue())); + tree.remove(Constants.JSON_MEDIA_READ_LINK); } - if (tree.hasNonNull(jsonMediaEditLink)) { - entity.setMediaContentSource(URI.create(tree.get(jsonMediaEditLink).textValue())); - tree.remove(jsonMediaEditLink); + if (tree.hasNonNull(Constants.JSON_MEDIA_EDIT_LINK)) { + entity.setMediaContentSource(URI.create(tree.get(Constants.JSON_MEDIA_EDIT_LINK).textValue())); + tree.remove(Constants.JSON_MEDIA_EDIT_LINK); } - if (tree.hasNonNull(jsonMediaContentType)) { - entity.setMediaContentType(tree.get(jsonMediaContentType).textValue()); - tree.remove(jsonMediaContentType); + if (tree.hasNonNull(Constants.JSON_MEDIA_CONTENT_TYPE)) { + entity.setMediaContentType(tree.get(Constants.JSON_MEDIA_CONTENT_TYPE).textValue()); + tree.remove(Constants.JSON_MEDIA_CONTENT_TYPE); } - if (tree.hasNonNull(jsonMediaETag)) { - entity.setMediaETag(tree.get(jsonMediaETag).textValue()); - tree.remove(jsonMediaETag); + if (tree.hasNonNull(Constants.JSON_MEDIA_ETAG)) { + entity.setMediaETag(tree.get(Constants.JSON_MEDIA_ETAG).textValue()); + tree.remove(Constants.JSON_MEDIA_ETAG); } final Set toRemove = new HashSet(); @@ -151,7 +152,7 @@ public class JsonEntityDeserializer extends JsonDeserializer { final Matcher customAnnotation = CUSTOM_ANNOTATION.matcher(field.getKey()); links(field, entity, toRemove, tree, parser.getCodec()); - if (field.getKey().endsWith(getJSONAnnotation(jsonMediaEditLink))) { + if (field.getKey().endsWith(getJSONAnnotation(Constants.JSON_MEDIA_EDIT_LINK))) { final LinkImpl link = new LinkImpl(); link.setTitle(getTitle(field)); link.setRel(Constants.NS_MEDIA_EDIT_LINK_REL + getTitle(field)); @@ -159,14 +160,15 @@ public class JsonEntityDeserializer extends JsonDeserializer { link.setType(ODataLinkType.MEDIA_EDIT.toString()); entity.getMediaEditLinks().add(link); - if (tree.has(link.getTitle() + getJSONAnnotation(jsonMediaETag))) { - link.setMediaETag(tree.get(link.getTitle() + getJSONAnnotation(jsonMediaETag)).asText()); - toRemove.add(link.getTitle() + getJSONAnnotation(jsonMediaETag)); + if (tree.has(link.getTitle() + getJSONAnnotation(Constants.JSON_MEDIA_ETAG))) { + link.setMediaETag(tree.get(link.getTitle() + getJSONAnnotation(Constants.JSON_MEDIA_ETAG)).asText()); + toRemove.add(link.getTitle() + getJSONAnnotation(Constants.JSON_MEDIA_ETAG)); } toRemove.add(field.getKey()); - toRemove.add(setInline(field.getKey(), getJSONAnnotation(jsonMediaEditLink), tree, parser.getCodec(), link)); - } else if (field.getKey().endsWith(getJSONAnnotation(jsonMediaContentType))) { + toRemove.add(setInline(field.getKey(), getJSONAnnotation(Constants.JSON_MEDIA_EDIT_LINK), tree, parser + .getCodec(), link)); + } else if (field.getKey().endsWith(getJSONAnnotation(Constants.JSON_MEDIA_CONTENT_TYPE))) { final String linkTitle = getTitle(field); for (Link link : entity.getMediaEditLinks()) { if (linkTitle.equals(link.getTitle())) { diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java index 00b807e00..1e844b532 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java @@ -79,17 +79,17 @@ public class JsonEntitySetDeserializer extends JsonDeserializer { metadataETag = null; } - if (tree.hasNonNull(jsonCount)) { - entitySet.setCount(tree.get(jsonCount).asInt()); - tree.remove(jsonCount); + if (tree.hasNonNull(Constants.JSON_COUNT)) { + entitySet.setCount(tree.get(Constants.JSON_COUNT).asInt()); + tree.remove(Constants.JSON_COUNT); } - if (tree.hasNonNull(jsonNextLink)) { - entitySet.setNext(URI.create(tree.get(jsonNextLink).textValue())); - tree.remove(jsonNextLink); + if (tree.hasNonNull(Constants.JSON_NEXT_LINK)) { + entitySet.setNext(URI.create(tree.get(Constants.JSON_NEXT_LINK).textValue())); + tree.remove(Constants.JSON_NEXT_LINK); } - if (tree.hasNonNull(jsonDeltaLink)) { - entitySet.setDeltaLink(URI.create(tree.get(jsonDeltaLink).textValue())); - tree.remove(jsonDeltaLink); + if (tree.hasNonNull(Constants.JSON_DELTA_LINK)) { + entitySet.setDeltaLink(URI.create(tree.get(Constants.JSON_DELTA_LINK).textValue())); + tree.remove(Constants.JSON_DELTA_LINK); } if (tree.hasNonNull(Constants.VALUE)) { diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java index 8e49a28d6..89252dca3 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java @@ -43,8 +43,8 @@ public class JsonODataErrorDeserializer extends JsonDeserializer { final ODataError error = new ODataError(); final ObjectNode tree = parser.getCodec().readTree(parser); - if (tree.has(jsonError)) { - final JsonNode errorNode = tree.get(jsonError); + if (tree.has(Constants.JSON_ERROR)) { + final JsonNode errorNode = tree.get(Constants.JSON_ERROR); if (errorNode.has(Constants.ERROR_CODE)) { error.setCode(errorNode.get(Constants.ERROR_CODE).textValue()); diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java index 9a9498e39..e0732d5d9 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java @@ -75,9 +75,10 @@ public class JsonPropertyDeserializer extends JsonDeserializer { contextURL = null; } - if (tree.has(jsonType)) { - property.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(jsonType).textValue()).build().internal()); - tree.remove(jsonType); + if (tree.has(Constants.JSON_TYPE)) { + property.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(Constants.JSON_TYPE).textValue()).build() + .internal()); + tree.remove(Constants.JSON_TYPE); } if (tree.has(Constants.JSON_NULL) && tree.get(Constants.JSON_NULL).asBoolean()) { From fd9ba8bf27e80d99ef5012b821daa67e4148d669 Mon Sep 17 00:00:00 2001 From: Christian Holzer Date: Wed, 1 Apr 2015 15:20:11 +0200 Subject: [PATCH 4/4] [OLINGO-545] TecSvc EDM enhanced --- .../tecsvc/provider/ActionProvider.java | 27 +++++++++----- .../tecsvc/provider/ContainerProvider.java | 36 ++++++++++++++----- .../tecsvc/provider/FunctionProvider.java | 19 +++++++++- .../tecsvc/provider/PropertyProvider.java | 2 +- .../tecsvc/provider/SchemaProvider.java | 1 + 5 files changed, 66 insertions(+), 19 deletions(-) diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ActionProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ActionProvider.java index d00b95301..64263274a 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ActionProvider.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ActionProvider.java @@ -49,6 +49,9 @@ public class ActionProvider { public static final FullQualifiedName nameBAETTwoKeyNavRTETTwoKeyNav = new FullQualifiedName(SchemaProvider.NAMESPACE, "BAETTwoKeyNavRTETTwoKeyNav"); + public static final FullQualifiedName nameBAESAllPrimRT = + new FullQualifiedName(SchemaProvider.NAMESPACE, "BAESAllPrimRT"); + public static final FullQualifiedName nameBAETAllPrimRT = new FullQualifiedName(SchemaProvider.NAMESPACE, "BAETAllPrimRT"); @@ -75,6 +78,7 @@ public class ActionProvider { public static final FullQualifiedName nameUARTTwoParam = new FullQualifiedName(SchemaProvider.NAMESPACE, "UARTTwoParam"); + public List getActions(final FullQualifiedName actionName) throws ODataException { if (actionName.equals(nameUARTString)) { return Collections.singletonList( @@ -237,15 +241,20 @@ public class ActionProvider { .setParameters(Arrays.asList( new Parameter().setName("ParameterETAllPrim") .setNullable(false) - .setType(EntityTypeProvider.nameETAllPrim))), - new Action().setName("BAETAllPrimRT") - .setBound(true) - .setParameters(Arrays.asList( - new Parameter().setName("ParameterETAllPrim") - .setNullable(false) - .setCollection(true) - .setType(EntityTypeProvider.nameETAllPrim)))); - } + .setType(EntityTypeProvider.nameETAllPrim) + ))); + } else if(actionName.equals(nameBAESAllPrimRT)) { + return Arrays.asList( + new Action().setName("BAESAllPrimRT") + .setBound(true) + .setParameters(Arrays.asList( + new Parameter().setName("ParameterETAllPrim") + .setNullable(false) + .setCollection(true) + .setType(EntityTypeProvider.nameETAllPrim) + )) + ); + } return null; } diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java index 12cdb6f14..9b982aa22 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java @@ -98,7 +98,9 @@ public class ContainerProvider { entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESCompMixPrimCollComp")); entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESFourKeyAlias")); entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESMixEnumDefCollComp")); - + entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESTwoBaseTwoKeyNav")); + entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESKeyNavCont")); + // Singletons List singletons = new ArrayList(); container.setSingletons(singletons); @@ -135,6 +137,7 @@ public class ContainerProvider { functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCTAllPrimTwoParam")); functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTESMixPrimCollCompTwoParam")); functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollETMixPrimCollCompTwoParam")); + functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FINRTCollETMixPrimCollCompTwoParam")); functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollCTTwoPrim")); functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTESMedia")); functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollESMedia")); @@ -144,7 +147,9 @@ public class ContainerProvider { functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTString")); functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollESTwoKeyNavParam")); functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollCTTwoPrimParam")); - + functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FINRTCollCTNavFiveProp")); + functionImports.add(prov.getFunctionImport(ContainerProvider.nameContainer, "FICRTCollESKeyNavContParam")); + return container; } @@ -363,9 +368,6 @@ public class ContainerProvider { new NavigationPropertyBinding() .setPath("CollPropertyCompNav/NavPropertyETMediaMany") .setTarget("ESMedia"), - new NavigationPropertyBinding() - .setPath("CollPropertyCompNav/NavPropertyETTwoKeyNavMany") - .setTarget("ESTwoKeyNav"), new NavigationPropertyBinding() .setPath("NavPropertyETTwoBaseTwoKeyNavOne") .setTarget("ESBaseTwoKeyNav"), @@ -563,7 +565,13 @@ public class ContainerProvider { .setName(name) .setFunction(FunctionProvider.nameUFCRTESMixPrimCollCompTwoParam) .setIncludeInServiceDocument(true); - + + } else if(name.equals("FINRTCollETMixPrimCollCompTwoParam")) { + return new FunctionImport() + .setName(name) + .setFunction(FunctionProvider.nameUFNRTCollETMixPrimCollCompTwoParam) + .setIncludeInServiceDocument(true); + } else if (name.equals("FICRTCollETMixPrimCollCompTwoParam")) { return new FunctionImport() .setName(name) @@ -625,10 +633,22 @@ public class ContainerProvider { .setName(name) .setFunction(FunctionProvider.nameUFCRTCollCTTwoPrimParam) .setIncludeInServiceDocument(true); - + + } else if(name.equals("FINRTCollCTNavFiveProp")) { + return new FunctionImport() + .setName(name) + .setFunction(FunctionProvider.nameUFNRTCollCTNavFiveProp) + .setIncludeInServiceDocument(true); + + } else if(name.equals("FICRTCollESKeyNavContParam")) { + return new FunctionImport() + .setName(name) + .setFunction(FunctionProvider.nameUFCRTCollETKeyNavContParam) + .setEntitySet("ESKeyNavCont") + .setIncludeInServiceDocument(true); } } - + return null; } diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/FunctionProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/FunctionProvider.java index 84f57ff52..bcf08633a 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/FunctionProvider.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/FunctionProvider.java @@ -176,6 +176,9 @@ public class FunctionProvider { public static final FullQualifiedName nameUFNRTCollCTNavFiveProp = new FullQualifiedName(SchemaProvider.NAMESPACE, "UFNRTCollCTNavFiveProp"); + public static final FullQualifiedName nameUFNRTCollETMixPrimCollCompTwoParam + = new FullQualifiedName(SchemaProvider.NAMESPACE, "UFNRTCollETMixPrimCollCompTwoParam"); + public List getFunctions(final FullQualifiedName functionName) throws ODataException { if (functionName.equals(nameUFNRTInt16)) { @@ -332,6 +335,20 @@ public class FunctionProvider { new ReturnType().setType(ComplexTypeProvider.nameCTAllPrim).setNullable(false)) ); + } else if(functionName.equals(nameUFNRTCollETMixPrimCollCompTwoParam)) { + return Arrays.asList( + new Function() + .setName("UFNRTCollETMixPrimCollCompTwoParam") + .setParameters(Arrays.asList( + new Parameter().setName("ParameterString").setType(PropertyProvider.nameString).setNullable(false), + new Parameter().setName("ParameterInt16").setType(PropertyProvider.nameInt16).setNullable(false))) + .setComposable(false) + .setBound(false) + .setReturnType( + new ReturnType().setType(ComplexTypeProvider.nameCTMixPrimCollComp) + .setNullable(false) + .setCollection(true)) + ); } else if (functionName.equals(nameUFCRTCTTwoPrimParam)) { return Arrays.asList( new Function() @@ -855,7 +872,7 @@ public class FunctionProvider { Arrays.asList( new Parameter().setName("BindingParam").setType(EntityTypeProvider.nameETTwoKeyNav) .setCollection(true).setNullable(false), - new Parameter().setName("ParameterComplex").setType(ComplexTypeProvider.nameCTTwoPrim) + new Parameter().setName("ParameterComp").setType(ComplexTypeProvider.nameCTTwoPrim) .setNullable(false))) .setComposable(true) .setReturnType( diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java index ff2ad6507..07fbd25b3 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java @@ -733,7 +733,7 @@ public class PropertyProvider { .setType(EntityTypeProvider.nameETKeyNav); public static final NavigationProperty navPropertyETTwoKeyNavContOneCT_ETTwoKeyNav = new NavigationProperty() - .setName("NavPropertyETKeyNavContOne") + .setName("NavPropertyETTwoKeyNavContOne") .setContainsTarget(true) .setType(EntityTypeProvider.nameETTwoKeyNav); diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java index ad3693cfa..b8e5ad386 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java @@ -185,6 +185,7 @@ public class SchemaProvider { functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESTwoKeyNavRTStringParam)); functions.addAll(prov.getFunctions(FunctionProvider.nameBFCESKeyNavRTETKeyNavParam)); functions.addAll(prov.getFunctions(FunctionProvider.nameBFCCTPrimCompRTETTwoKeyNavParam)); + functions.addAll(prov.getFunctions(FunctionProvider.nameUFNRTCollETMixPrimCollCompTwoParam)); // functions.addAll(prov.getFunctions(FunctionProvider.nameBFCCTPrimCompRTESTwoKeyNavParam)); // EntityContainer