You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Hector Navarro <he...@mes-view.com> on 2016/07/18 10:43:22 UTC

Bind Operation

Why can't I use the value null to remove a relationship?

According to OData 4 documentation: "For nullable single-valued 
navigation properties the value null may be used to remove the 
relationship"

I defined a navigation property as nullable (CsdlNavigationProperty 
.setNullable(true)) and I try to update that navigation property to null 
(PATCH) with @odata.bind annotation. Olingo response with 400 - "Missing 
message for key 'INVALID_NULL_ANNOTATION". Is this a bug?

Request example:

PATCH http://host/service/Products(42) HTTP/1.1

{
     "Category@odata.bind":null
}

In any case, how can I update a navigation property to null?


Héctor Navarro
Ingeniero de software
hector.navarro@mes-view.com


NOTA LEGAL:Este mensaje y los documentos que en su caso lleve anexos, 
pueden contener información confidencial dirigida exclusivamente a su 
destinatario. Si ha recibido este mensaje por error, le notificamos que 
cualquier uso, difusión copia están prohibidos legalmente y rogamos que 
nos lo comunique por la misma vía y proceda a destruirlo inmediatamente.

Re[4]: Bind Operation

Posted by Hector Navarro <he...@mes-view.com>.
I believe, but, if the navigation property is a single entity (to one 
relationship) and it is defined as nullable, it can be null, as sais at 
OData documentation ("For nullable single-valued navigation properties 
the value null may be used to remove the relationship.").

As example, we can use 
org.apache.olingo.server.core.deserializer.json.ODataJsonDeserializerEntityTest.bindingOperationNullOnToOne():

   @Test
   public void bindingOperationNullOnToOne() throws Exception {
     String entityString =
         "{\"PropertyInt16\":32767,"
             + "\"PropertyString\":\"First Resource - positive values\","
             + "\"NavPropertyETTwoPrimOne@odata.bind\":null"
             + "}";
     expectException(entityString, "ETAllPrim",
         DeserializerException.MessageKeys.INVALID_NULL_ANNOTATION);
   }

I believe that if we define NavPropertyETTwoPrimOne as nullable, it 
shouldn't throw INVALID_NULL_ANNOTATION exception.


Héctor Navarro
Ingeniero de software
hector.navarro@mes-view.com


NOTA LEGAL:Este mensaje y los documentos que en su caso lleve anexos, 
pueden contener información confidencial dirigida exclusivamente a su 
destinatario. Si ha recibido este mensaje por error, le notificamos que 
cualquier uso, difusión copia están prohibidos legalmente y rogamos que 
nos lo comunique por la misma vía y proceda a destruirlo inmediatamente.



------ Mensaje original ------
De: "Ramesh Reddy" <ra...@redhat.com>
Para: "Hector Navarro" <he...@mes-view.com>
CC: user@olingo.apache.org
Enviado: 18/07/2016 16:48:01
Asunto: Re: Re[2]: Bind Operation

>I read the code wrong previously, the code is enforcing the non-null 
>value which is wrong, it is not even consulting the metadata in that 
>scenario. I believe, if the navigation property is collection then it 
>can not be null, it needs to be an empty array. Log a JIRA, you are 
>welcome to submit a patch, if not please at least provide a unit 
>testcase, that would be fastest route to providing a fix.
>
>Ramesh..
>
>--------------------------------------------------------------------------------
>>I'm using Olingo 4.2.0.
>>
>>This is my EntityType metadata definition:
>>@Override
>>public CsdlEntityType getEntityType(FullQualifiedName entityTypeName) throws ODataException {
>>     CsdlEntityType entityType = null;
>>if (entityTypeName.equals(ET_AREA_FQN)) {
>>// EntityType properties
>>CsdlProperty id = new CsdlProperty().setName(PRP_ID).setType(EdmPrimitiveTypeKind.Int64.getFullQualifiedName());
>>         CsdlProperty nombre = new CsdlProperty().setName(PRP_NAME).setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
>>         CsdlProperty created = new CsdlProperty().setName(PRP_CREATED).setType(EdmPrimitiveTypeKind.Date.getFullQualifiedName());
>>         CsdlProperty updated = new CsdlProperty().setName(PRP_UPDATED).setType(EdmPrimitiveTypeKind.Date.getFullQualifiedName());
>>
>>// Key
>>CsdlPropertyRef propertyRef = new CsdlPropertyRef();
>>         propertyRef.setName(PRP_ID);
>>
>>// Navigation properties
>>List<CsdlNavigationProperty> navigationPropertyList = new ArrayList<>();
>>
>>         CsdlNavigationProperty plantaNavigationProperty = new CsdlNavigationProperty()
>>                 .setName(PRP_NAV_CATEGORY)
>>                 .setType(PlantaEdmProvider.ET_CATEGORY_FQN)
>>                 .setNullable(true)
>>                 .setPartner(PlantaEdmProvider.PRP_NAV_AREAS);
>>         navigationPropertyList.add(plantaNavigationProperty);
>>
>>
>>// EntityType conf
>>entityType = new CsdlEntityType();
>>         entityType.setName(ET_AREA_NAME);
>>         entityType.setProperties(Arrays.asList(id, nombre, created, updated));
>>         entityType.setKey(Collections.singletonList(propertyRef));
>>         entityType.setNavigationProperties(navigationPropertyList);
>>     }
>>return entityType;
>>}
>>
>>
>>Héctor Navarro
>>Ingeniero de software
>>hector.navarro@mes-view.com
>>
>>
>>NOTA LEGAL:Este mensaje y los documentos que en su caso lleve anexos, 
>>pueden contener información confidencial dirigida exclusivamente a su 
>>destinatario. Si ha recibido este mensaje por error, le notificamos 
>>que cualquier uso, difusión copia están prohibidos legalmente y 
>>rogamos que nos lo comunique por la misma vía y proceda a destruirlo 
>>inmediatamente.
>>
>>
>>
>>------ Mensaje original ------
>>De: "Ramesh Reddy" <ra...@redhat.com>
>>Para: user@olingo.apache.org; "Hector Navarro" 
>><he...@mes-view.com>
>>Enviado: 18/07/2016 13:10:28
>>Asunto: Re: Bind Operation
>>
>>>1) INVALID_NULL_ANNOTATION is definitely a bug, as its message for 
>>>default locale is missing, you can log a JIRA issue for it.
>>>2) As per the real issue of @odata.bind being null, according to the 
>>>code your metadata is not defined as that property can be nullable. 
>>>How are you defining your metadata, and which version of Olingo?
>>>
>>>--------------------------------------------------------------------------------
>>>>Why can't I use the value null to remove a relationship?
>>>>
>>>>According to OData 4 documentation: "For nullable single-valued 
>>>>navigation properties the value null may be used to remove the 
>>>>relationship"
>>>>
>>>>I defined a navigation property as nullable (CsdlNavigationProperty 
>>>>.setNullable(true)) and I try to update that navigation property to 
>>>>null (PATCH) with @odata.bind annotation. Olingo response with 400 - 
>>>>"Missing message for key 'INVALID_NULL_ANNOTATION". Is this a bug?
>>>>
>>>>Request example:
>>>>
>>>>PATCH http://host/service/Products(42) HTTP/1.1
>>>>
>>>>{
>>>>     "Category@odata.bind":null
>>>>}
>>>>
>>>>In any case, how can I update a navigation property to null?
>>>>
>>>>
>>>>Héctor Navarro
>>>>Ingeniero de software
>>>>hector.navarro@mes-view.com
>>>>
>>>>
>>>>NOTA LEGAL:Este mensaje y los documentos que en su caso lleve 
>>>>anexos, pueden contener información confidencial dirigida 
>>>>exclusivamente a su destinatario. Si ha recibido este mensaje por 
>>>>error, le notificamos que cualquier uso, difusión copia están 
>>>>prohibidos legalmente y rogamos que nos lo comunique por la misma 
>>>>vía y proceda a destruirlo inmediatamente.
>>>>
>>>
>

Re: Re[2]: Bind Operation

Posted by Ramesh Reddy <ra...@redhat.com>.
I read the code wrong previously, the code is enforcing the non-null value which is wrong, it is not even consulting the metadata in that scenario. I believe, if the navigation property is collection then it can not be null, it needs to be an empty array. Log a JIRA, you are welcome to submit a patch, if not please at least provide a unit testcase, that would be fastest route to providing a fix. 

Ramesh.. 

----- Original Message -----

> I'm using Olingo 4.2.0.
> This is my EntityType metadata definition:
> @Override
> public CsdlEntityType getEntityType(FullQualifiedName entityTypeName) throws
> ODataException {
> CsdlEntityType entityType = null ;
> if (entityTypeName.equals( ET_AREA_FQN )) {
> // EntityType properties
> CsdlProperty id = new CsdlProperty().setName( PRP_ID
> ).setType(EdmPrimitiveTypeKind. Int64 .getFullQualifiedName());
> CsdlProperty nombre = new CsdlProperty().setName( PRP_NAME
> ).setType(EdmPrimitiveTypeKind. String .getFullQualifiedName());
> CsdlProperty created = new CsdlProperty().setName( PRP_CREATED
> ).setType(EdmPrimitiveTypeKind. Date .getFullQualifiedName());
> CsdlProperty updated = new CsdlProperty().setName( PRP_UPDATED
> ).setType(EdmPrimitiveTypeKind. Date .getFullQualifiedName());

> // Key
> CsdlPropertyRef propertyRef = new CsdlPropertyRef();
> propertyRef.setName( PRP_ID );

> // Navigation properties
> List<CsdlNavigationProperty> navigationPropertyList = new ArrayList<>();

> CsdlNavigationProperty plantaNavigationProperty = new
> CsdlNavigationProperty()
> .setName( PRP_NAV_CATEGORY )
> .setType(PlantaEdmProvider. ET_CATEGORY_FQN )
> .setNullable( true )
> .setPartner(PlantaEdmProvider. PRP_NAV_AREAS );
> navigationPropertyList.add(plantaNavigationProperty);

> // EntityType conf
> entityType = new CsdlEntityType();
> entityType.setName( ET_AREA_NAME );
> entityType.setProperties(Arrays. asList (id, nombre, created, updated));
> entityType.setKey(Collections. singletonList (propertyRef));
> entityType.setNavigationProperties(navigationPropertyList);
> }
> return entityType;
> }
> Héctor Navarro
> Ingeniero de software
> hector.navarro@mes-view.com
> NOTA LEGAL:Este mensaje y los documentos que en su caso lleve anexos, pueden
> contener información confidencial dirigida exclusivamente a su destinatario.
> Si ha recibido este mensaje por error, le notificamos que cualquier uso,
> difusión copia están prohibidos legalmente y rogamos que nos lo comunique
> por la misma vía y proceda a destruirlo inmediatamente.
> ------ Mensaje original ------
> De: "Ramesh Reddy" < rareddy@redhat.com >
> Para: user@olingo.apache.org ; "Hector Navarro" < hector.navarro@mes-view.com
> >
> Enviado: 18/07/2016 13:10:28
> Asunto: Re: Bind Operation

> > 1) INVALID_NULL_ANNOTATION is definitely a bug, as its message for default
> > locale is missing, you can log a JIRA issue for it.
> 
> > 2) As per the real issue of @odata.bind being null, according to the code
> > your metadata is not defined as that property can be nullable. How are you
> > defining your metadata, and which version of Olingo?
> 

> > ----- Original Message -----
> 

> > > Why can't I use the value null to remove a relationship?
> > 
> 
> > > According to OData 4 documentation : "For nullable single-valued
> > > navigation
> > > properties the value null may be used to remove the relationship"
> > 
> 
> > > I defined a navigation property as nullable ( CsdlNavigationProperty
> > > .setNullable(true) ) and I try to update that navigation property to null
> > > (PATCH) with @odata.bind annotation. Olingo response with 400 - "Missing
> > > message for key 'INVALID_NULL_ANNOTATION". Is this a bug?
> > 
> 
> > > Request example:
> > 
> 
> > > PATCH http://host/service/Products(42 ) HTTP/1.1
> > 
> 
> > > {
> > 
> 
> > > " Category@odata.bind ":null
> > 
> 
> > > }
> > 
> 
> > > In any case, h ow can I update a navigation property to null?
> > 
> 
> > > Héctor Navarro
> > 
> 
> > > Ingeniero de software
> > 
> 
> > > hector.navarro@mes-view.com
> > 
> 
> > > NOTA LEGAL:Este mensaje y los documentos que en su caso lleve anexos,
> > > pueden
> > > contener información confidencial dirigida exclusivamente a su
> > > destinatario.
> > > Si ha recibido este mensaje por error, le notificamos que cualquier uso,
> > > difusión copia están prohibidos legalmente y rogamos que nos lo comunique
> > > por la misma vía y proceda a destruirlo inmediatamente.
> > 
> 

Re[2]: Bind Operation

Posted by Hector Navarro <he...@mes-view.com>.
I'm using Olingo 4.2.0.

This is my EntityType metadata definition:
@Override
public CsdlEntityType getEntityType(FullQualifiedName entityTypeName) throws ODataException {
     CsdlEntityType entityType = null;
if (entityTypeName.equals(ET_AREA_FQN)) {
// EntityType properties
CsdlProperty id = new CsdlProperty().setName(PRP_ID).setType(EdmPrimitiveTypeKind.Int64.getFullQualifiedName());
         CsdlProperty nombre = new CsdlProperty().setName(PRP_NAME).setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
         CsdlProperty created = new CsdlProperty().setName(PRP_CREATED).setType(EdmPrimitiveTypeKind.Date.getFullQualifiedName());
         CsdlProperty updated = new CsdlProperty().setName(PRP_UPDATED).setType(EdmPrimitiveTypeKind.Date.getFullQualifiedName());

// Key
CsdlPropertyRef propertyRef = new CsdlPropertyRef();
         propertyRef.setName(PRP_ID);

// Navigation properties
List<CsdlNavigationProperty> navigationPropertyList = new ArrayList<>();

         CsdlNavigationProperty plantaNavigationProperty = new CsdlNavigationProperty()
                 .setName(PRP_NAV_CATEGORY)
                 .setType(PlantaEdmProvider.ET_CATEGORY_FQN)
                 .setNullable(true)
                 .setPartner(PlantaEdmProvider.PRP_NAV_AREAS);
         navigationPropertyList.add(plantaNavigationProperty);


// EntityType conf
entityType = new CsdlEntityType();
         entityType.setName(ET_AREA_NAME);
         entityType.setProperties(Arrays.asList(id, nombre, created, updated));
         entityType.setKey(Collections.singletonList(propertyRef));
         entityType.setNavigationProperties(navigationPropertyList);
     }
return entityType;
}


Héctor Navarro
Ingeniero de software
hector.navarro@mes-view.com


NOTA LEGAL:Este mensaje y los documentos que en su caso lleve anexos, 
pueden contener información confidencial dirigida exclusivamente a su 
destinatario. Si ha recibido este mensaje por error, le notificamos que 
cualquier uso, difusión copia están prohibidos legalmente y rogamos que 
nos lo comunique por la misma vía y proceda a destruirlo inmediatamente.



------ Mensaje original ------
De: "Ramesh Reddy" <ra...@redhat.com>
Para: user@olingo.apache.org; "Hector Navarro" 
<he...@mes-view.com>
Enviado: 18/07/2016 13:10:28
Asunto: Re: Bind Operation

>1) INVALID_NULL_ANNOTATION is definitely a bug, as its message for 
>default locale is missing, you can log a JIRA issue for it.
>2) As per the real issue of @odata.bind being null, according to the 
>code your metadata is not defined as that property can be nullable. How 
>are you defining your metadata, and which version of Olingo?
>
>--------------------------------------------------------------------------------
>>Why can't I use the value null to remove a relationship?
>>
>>According to OData 4 documentation: "For nullable single-valued 
>>navigation properties the value null may be used to remove the 
>>relationship"
>>
>>I defined a navigation property as nullable (CsdlNavigationProperty 
>>.setNullable(true)) and I try to update that navigation property to 
>>null (PATCH) with @odata.bind annotation. Olingo response with 400 - 
>>"Missing message for key 'INVALID_NULL_ANNOTATION". Is this a bug?
>>
>>Request example:
>>
>>PATCH http://host/service/Products(42) HTTP/1.1
>>
>>{
>>     "Category@odata.bind":null
>>}
>>
>>In any case, how can I update a navigation property to null?
>>
>>
>>Héctor Navarro
>>Ingeniero de software
>>hector.navarro@mes-view.com
>>
>>
>>NOTA LEGAL:Este mensaje y los documentos que en su caso lleve anexos, 
>>pueden contener información confidencial dirigida exclusivamente a su 
>>destinatario. Si ha recibido este mensaje por error, le notificamos 
>>que cualquier uso, difusión copia están prohibidos legalmente y 
>>rogamos que nos lo comunique por la misma vía y proceda a destruirlo 
>>inmediatamente.
>>
>

Re: Bind Operation

Posted by Ramesh Reddy <ra...@redhat.com>.
1) INVALID_NULL_ANNOTATION is definitely a bug, as its message for default locale is missing, you can log a JIRA issue for it. 
2) As per the real issue of @odata.bind being null, according to the code your metadata is not defined as that property can be nullable. How are you defining your metadata, and which version of Olingo? 

----- Original Message -----

> Why can't I use the value null to remove a relationship?
> According to OData 4 documentation : "For nullable single-valued navigation
> properties the value null may be used to remove the relationship"
> I defined a navigation property as nullable ( CsdlNavigationProperty
> .setNullable(true) ) and I try to update that navigation property to null
> (PATCH) with @odata.bind annotation. Olingo response with 400 - "Missing
> message for key 'INVALID_NULL_ANNOTATION". Is this a bug?
> Request example:
> PATCH http://host/service/Products(42 ) HTTP/1.1
> {
> "Category@odata.bind":null
> }
> In any case, h ow can I update a navigation property to null?
> Héctor Navarro
> Ingeniero de software
> hector.navarro@mes-view.com
> NOTA LEGAL:Este mensaje y los documentos que en su caso lleve anexos, pueden
> contener información confidencial dirigida exclusivamente a su destinatario.
> Si ha recibido este mensaje por error, le notificamos que cualquier uso,
> difusión copia están prohibidos legalmente y rogamos que nos lo comunique
> por la misma vía y proceda a destruirlo inmediatamente.