[ 
https://issues.apache.org/jira/browse/OLINGO-1452?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Joshua Darnell updated OLINGO-1452:
-----------------------------------
    Description: 
Using the [Olingo XML Metadata validation 
methods|https://github.com/apache/olingo-odata4/blob/ddaab6b0fa6778869f03edc8d10dcf933098242b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataMetadataValidationImpl.java#L77-L116],
 they correctly catch the case where there is no Key property defined in the 
metadata for a given EntityType definition.  

For example, this will produce an error:
{code:java}
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"; Version="4.0">
  <edmx:DataServices>
    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"; 
Namespace="org.example">
      <EntityType Name="SomeEntityType">
        <Property Name="SomeEntityTypeKey" Type="edm.String" Nullable="false" />
      </EntityType>
    </Schema>
    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"; Namespace="Default">
      <EntityContainer Name="Container">
        <EntitySet Name="SomeEntityType" 
EntityType="org.example.SomeEntityType"/>
      </EntityContainer>
    </Schema>
  </edmx:DataServices>
</edmx:Edmx>{code}
 

However, the Key can be defined without the EntityType's Property definition 
for that field being present, and this is something that the metadata 
validation does not catch. 
{code:java}
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"; Version="4.0">
  <edmx:DataServices>
    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"; 
Namespace="org.example">
      <EntityType Name="SomeEntityType">
        <Key>
          <PropertyRef Name="SomeEntityTypeKey"/>
        </Key>
      </EntityType>
    </Schema>
    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"; Namespace="Default">
      <EntityContainer Name="Container">
        <EntitySet Name="SomeEntityType" 
EntityType="org.example.SomeEntityType"/>
      </EntityContainer>
    </Schema>
  </edmx:DataServices>
</edmx:Edmx>{code}
 

This ticket was created to request that XML metadata validation check both 
whether a Key is present, and that the defined key also has a corresponding 
{{Property}} definition in the metadata. Otherwise, metadata validation should 
fail. 

  was:
Using the Olingo XML Metadata validation methods, they correctly catch the case 
where there is no Key property defined in the metadata for a given EntityType 
definition.  

For example, this will produce an error:
{code:java}
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"; Version="4.0">
  <edmx:DataServices>
    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"; 
Namespace="org.example">
      <EntityType Name="SomeEntityType">
        <Property Name="SomeEntityTypeKey" Type="edm.String" Nullable="false" />
      </EntityType>
    </Schema>
    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"; Namespace="Default">
      <EntityContainer Name="Container">
        <EntitySet Name="SomeEntityType" 
EntityType="org.example.SomeEntityType"/>
      </EntityContainer>
    </Schema>
  </edmx:DataServices>
</edmx:Edmx>{code}
 

However, the Key can be defined without the EntityType's Property definition 
for that field being present, and this is something that the metadata 
validation does not catch. 
{code:java}
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"; Version="4.0">
  <edmx:DataServices>
    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"; 
Namespace="org.example">
      <EntityType Name="SomeEntityType">
        <Key>
          <PropertyRef Name="SomeEntityTypeKey"/>
        </Key>
      </EntityType>
    </Schema>
    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"; Namespace="Default">
      <EntityContainer Name="Container">
        <EntitySet Name="SomeEntityType" 
EntityType="org.example.SomeEntityType"/>
      </EntityContainer>
    </Schema>
  </edmx:DataServices>
</edmx:Edmx>{code}
 

This ticket was created to request that XML metadata validation check both 
whether a Key is present, and that the defined key also has a corresponding 
{{Property}} definition in the metadata. Otherwise, metadata validation should 
fail. 


> Metadata Validation Does Not Enforce that Key Field Exists in EntityType 
> Definition
> -----------------------------------------------------------------------------------
>
>                 Key: OLINGO-1452
>                 URL: https://issues.apache.org/jira/browse/OLINGO-1452
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata4-client
>    Affects Versions: (Java) V4 4.7.1
>         Environment: Linux, OSX, Windows.
>            Reporter: Joshua Darnell
>            Priority: Major
>             Fix For: (Java) V4 4.7.1
>
>
> Using the [Olingo XML Metadata validation 
> methods|https://github.com/apache/olingo-odata4/blob/ddaab6b0fa6778869f03edc8d10dcf933098242b/lib/client-core/src/main/java/org/apache/olingo/client/core/serialization/ODataMetadataValidationImpl.java#L77-L116],
>  they correctly catch the case where there is no Key property defined in the 
> metadata for a given EntityType definition.  
> For example, this will produce an error:
> {code:java}
> <?xml version="1.0" encoding="utf-8"?>
> <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"; 
> Version="4.0">
>   <edmx:DataServices>
>     <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"; 
> Namespace="org.example">
>       <EntityType Name="SomeEntityType">
>         <Property Name="SomeEntityTypeKey" Type="edm.String" Nullable="false" 
> />
>       </EntityType>
>     </Schema>
>     <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"; 
> Namespace="Default">
>       <EntityContainer Name="Container">
>         <EntitySet Name="SomeEntityType" 
> EntityType="org.example.SomeEntityType"/>
>       </EntityContainer>
>     </Schema>
>   </edmx:DataServices>
> </edmx:Edmx>{code}
>  
> However, the Key can be defined without the EntityType's Property definition 
> for that field being present, and this is something that the metadata 
> validation does not catch. 
> {code:java}
> <?xml version="1.0" encoding="utf-8"?>
> <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"; 
> Version="4.0">
>   <edmx:DataServices>
>     <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"; 
> Namespace="org.example">
>       <EntityType Name="SomeEntityType">
>         <Key>
>           <PropertyRef Name="SomeEntityTypeKey"/>
>         </Key>
>       </EntityType>
>     </Schema>
>     <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm"; 
> Namespace="Default">
>       <EntityContainer Name="Container">
>         <EntitySet Name="SomeEntityType" 
> EntityType="org.example.SomeEntityType"/>
>       </EntityContainer>
>     </Schema>
>   </edmx:DataServices>
> </edmx:Edmx>{code}
>  
> This ticket was created to request that XML metadata validation check both 
> whether a Key is present, and that the defined key also has a corresponding 
> {{Property}} definition in the metadata. Otherwise, metadata validation 
> should fail. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to