You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2014/03/16 10:06:05 UTC
[16/50] [abbrv] git commit: [OLINGO-123] fix
[OLINGO-123] fix
Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/commit/8ff7807b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/tree/8ff7807b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/diff/8ff7807b
Branch: refs/heads/Olingo-129_PocJpaDataStore
Commit: 8ff7807bf97a61394ea47719417fe26136fe1d4e
Parents: 16106f6
Author: Stephan Klevenz <sk...@apache.org>
Authored: Fri Jan 24 16:55:18 2014 +0100
Committer: Stephan Klevenz <sk...@apache.org>
Committed: Mon Feb 10 16:20:42 2014 +0100
----------------------------------------------------------------------
.../core/ep/consumer/XmlEntryConsumer.java | 31 +++--
.../core/ep/consumer/XmlEntityConsumerTest.java | 6 +
.../src/test/resources/expandedBuilding.xml | 113 ++++++++++---------
3 files changed, 77 insertions(+), 73 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/8ff7807b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntryConsumer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntryConsumer.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntryConsumer.java
index d464b1f..6b9cd5f 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntryConsumer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntryConsumer.java
@@ -229,25 +229,22 @@ public class XmlEntryConsumer {
final String etag = reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, FormatXml.M_ETAG);
// read to next tag to check if <link> contains any further tags
+ reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_LINK);
reader.nextTag();
- if (reader.isEndElement()) {
- reader.require(XMLStreamConstants.END_ELEMENT, Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_LINK);
-
- if (rel == null || uri == null) {
- throw new EntityProviderException(EntityProviderException.MISSING_ATTRIBUTE.addContent(
- FormatXml.ATOM_HREF + "' and/or '" + FormatXml.ATOM_REL).addContent(FormatXml.ATOM_LINK));
- } else if (rel.startsWith(Edm.NAMESPACE_REL_2007_08)) {
- final String navigationPropertyName = rel.substring(Edm.NAMESPACE_REL_2007_08.length());
- entryMetadata.putAssociationUri(navigationPropertyName, uri);
- } else if (rel.equals(Edm.LINK_REL_EDIT_MEDIA)) {
- mediaMetadata.setEditLink(uri);
- mediaMetadata.setEtag(etag);
- }
- } else {
- if (rel != null && rel.startsWith(Edm.NAMESPACE_REL_2007_08)) {
- readInlineContent(reader, eia, readProperties, type, rel);
- }
+ if (rel == null || uri == null) {
+ throw new EntityProviderException(EntityProviderException.MISSING_ATTRIBUTE.addContent(
+ FormatXml.ATOM_HREF + "' and/or '" + FormatXml.ATOM_REL).addContent(FormatXml.ATOM_LINK));
+ } else if (rel.startsWith(Edm.NAMESPACE_REL_2007_08)) {
+ final String navigationPropertyName = rel.substring(Edm.NAMESPACE_REL_2007_08.length());
+ entryMetadata.putAssociationUri(navigationPropertyName, uri);
+ } else if (rel.equals(Edm.LINK_REL_EDIT_MEDIA)) {
+ mediaMetadata.setEditLink(uri);
+ mediaMetadata.setEtag(etag);
+ }
+
+ if (!reader.isEndElement() && rel != null && rel.startsWith(Edm.NAMESPACE_REL_2007_08)) {
+ readInlineContent(reader, eia, readProperties, type, rel);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/8ff7807b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntityConsumerTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntityConsumerTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntityConsumerTest.java
index 361de02..b357c71 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntityConsumerTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntityConsumerTest.java
@@ -577,6 +577,9 @@ public class XmlEntityConsumerTest extends AbstractXmlConsumerTest {
assertEquals("Building 1", inlineBuildingProps.get("Name"));
assertNull(inlineBuildingProps.get("Image"));
assertNull(inlineBuildingProps.get("nb_Rooms"));
+
+ assertEquals("Rooms('1')/nr_Employees", entry.getMetadata().getAssociationUris("nr_Employees").get(0));
+ assertEquals("Rooms('1')/nr_Building", entry.getMetadata().getAssociationUris("nr_Building").get(0));
}
/** Teams('1')?$expand=nt_Employees */
@@ -2322,6 +2325,9 @@ public class XmlEntityConsumerTest extends AbstractXmlConsumerTest {
Map<String, Object> properties = result.getProperties();
assertEquals(1, properties.size());
assertEquals("1", properties.get("Id"));
+
+ assertEquals("Rooms('1')/nr_Building", result.getMetadata().getAssociationUris("nr_Building").get(0));
+ assertEquals("Rooms('1')/nr_Employees", result.getMetadata().getAssociationUris("nr_Employees").get(0));
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/8ff7807b/odata2-lib/odata-core/src/test/resources/expandedBuilding.xml
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/resources/expandedBuilding.xml b/odata2-lib/odata-core/src/test/resources/expandedBuilding.xml
index b4b34a4..e637969 100644
--- a/odata2-lib/odata-core/src/test/resources/expandedBuilding.xml
+++ b/odata2-lib/odata-core/src/test/resources/expandedBuilding.xml
@@ -1,60 +1,61 @@
<?xml version='1.0' encoding='utf-8'?>
<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
-->
-<entry xmlns="http://www.w3.org/2005/Atom"
- xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
- xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
- xml:base="http://some.host.com/service.root/ReferenceScenario.svc/">
- <id>http://some.host.com/service.root/ReferenceScenario.svc/Rooms('1')</id>
- <title type="text">Room 1</title>
- <updated>2013-04-19T10:58:03.646Z</updated>
- <category term="RefScenario.Room" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
- <link href="Rooms('1')" rel="edit" title="Room"/>
- <link href="Rooms('1')/nr_Employees" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/nr_Employees" title="nr_Employees" type="application/atom+xml; type=feed"/>
- <link href="Rooms('1')/nr_Building" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/nr_Building" title="nr_Building" type="application/atom+xml; type=entry">
- <m:inline>
- <entry>
- <id>http://some.host.com/service.root/ReferenceScenario.svc/Buildings('1')</id>
- <title type="text">Buildings</title>
- <updated>2013-04-19T10:58:03.646Z</updated>
- <author>
- <name>Building 1</name>
- </author>
- <category term="RefScenario.Building" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
- <link href="Buildings('1')" rel="edit" title="Building"/>
- <link href="Buildings('1')/nb_Rooms" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/nb_Rooms" title="nb_Rooms" type="application/atom+xml; type=feed"/>
- <content type="application/xml">
- <m:properties>
- <d:Id>1</d:Id>
- <d:Name>Building 1</d:Name>
- <d:Image m:null="true"/>
- </m:properties>
- </content>
- </entry>
- </m:inline>
- </link>
- <content type="application/xml">
- <m:properties>
- <d:Id>1</d:Id>
- <d:Name>Room 1</d:Name>
- <d:Seats>1</d:Seats>
- <d:Version>1</d:Version>
- </m:properties>
- </content>
+<entry xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
+ xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="http://some.host.com/service.root/ReferenceScenario.svc/">
+ <id>http://some.host.com/service.root/ReferenceScenario.svc/Rooms('1')</id>
+ <title type="text">Room 1</title>
+ <updated>2013-04-19T10:58:03.646Z</updated>
+ <category term="RefScenario.Room" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
+ <link href="Rooms('1')" rel="edit" title="Room" />
+ <link href="Rooms('1')/nr_Employees" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/nr_Employees"
+ title="nr_Employees" type="application/atom+xml; type=feed" />
+ <link href="Rooms('1')/nr_Building" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/nr_Building"
+ title="nr_Building" type="application/atom+xml; type=entry">
+ <m:inline>
+ <entry>
+ <id>http://some.host.com/service.root/ReferenceScenario.svc/Buildings('1')</id>
+ <title type="text">Buildings</title>
+ <updated>2013-04-19T10:58:03.646Z</updated>
+ <author>
+ <name>Building 1</name>
+ </author>
+ <category term="RefScenario.Building" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
+ <link href="Buildings('1')" rel="edit" title="Building" />
+ <link href="Buildings('1')/nb_Rooms" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/nb_Rooms"
+ title="nb_Rooms" type="application/atom+xml; type=feed" />
+ <content type="application/xml">
+ <m:properties>
+ <d:Id>1</d:Id>
+ <d:Name>Building 1</d:Name>
+ <d:Image m:null="true" />
+ </m:properties>
+ </content>
+ </entry>
+ </m:inline>
+ </link>
+ <content type="application/xml">
+ <m:properties>
+ <d:Id>1</d:Id>
+ <d:Name>Room 1</d:Name>
+ <d:Seats>1</d:Seats>
+ <d:Version>1</d:Version>
+ </m:properties>
+ </content>
</entry>