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/10/14 08:38:35 UTC

[1/6] [OLINGO-423] Refactoring for EdmxReferenceHandling

Repository: olingo-odata4
Updated Branches:
  refs/heads/master cf032b690 -> b006070be


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceImpl.java
new file mode 100644
index 0000000..31f64d2
--- /dev/null
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceImpl.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.edmx;
+
+
+import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.apache.olingo.server.api.edmx.EdmxReferenceInclude;
+import org.apache.olingo.server.api.edmx.EdmxReferenceIncludeAnnotation;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+
+public class EdmxReferenceImpl implements EdmxReference {
+  private final URI uri;
+  private final List<EdmxReferenceInclude> edmxIncludes;
+  private final List<EdmxReferenceIncludeAnnotation> edmxIncludeAnnotations;
+
+  public EdmxReferenceImpl(URI uri) {
+    this.uri = uri;
+    edmxIncludes = new ArrayList<EdmxReferenceInclude>();
+    edmxIncludeAnnotations = new ArrayList<EdmxReferenceIncludeAnnotation>();
+  }
+
+  @Override
+  public URI getUri() {
+    return uri;
+  }
+
+  @Override
+  public List<EdmxReferenceInclude> getIncludes() {
+    return Collections.unmodifiableList(edmxIncludes);
+  }
+
+  public void addInclude(EdmxReferenceInclude include) {
+    edmxIncludes.add(include);
+  }
+
+  @Override
+  public List<EdmxReferenceIncludeAnnotation> getIncludeAnnotations() {
+    return Collections.unmodifiableList(edmxIncludeAnnotations);
+  }
+
+  public void addIncludeAnnotation(EdmxReferenceIncludeAnnotation includeAnnotation) {
+    edmxIncludeAnnotations.add(includeAnnotation);
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeAnnotationImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeAnnotationImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeAnnotationImpl.java
new file mode 100644
index 0000000..1a4d7b4
--- /dev/null
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeAnnotationImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.edmx;
+
+import org.apache.olingo.server.api.edmx.EdmxReferenceIncludeAnnotation;
+
+/**
+ */
+public class EdmxReferenceIncludeAnnotationImpl implements EdmxReferenceIncludeAnnotation {
+
+  private final String termNamespace;
+  private final String qualifier;
+  private final String targetNamespace;
+
+  public EdmxReferenceIncludeAnnotationImpl(String termNamespace, String qualifier, String targetNamespace) {
+    this.termNamespace = termNamespace;
+    this.qualifier = qualifier;
+    this.targetNamespace = targetNamespace;
+  }
+
+  @Override
+  public String getTermNamespace() {
+    return termNamespace;
+  }
+
+  @Override
+  public String getQualifier() {
+    return qualifier;
+  }
+
+  @Override
+  public String getTargetNamespace() {
+    return targetNamespace;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeImpl.java
new file mode 100644
index 0000000..0da95df
--- /dev/null
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.edmx;
+
+import org.apache.olingo.server.api.edmx.EdmxReferenceInclude;
+
+/**
+ */
+public class EdmxReferenceIncludeImpl implements EdmxReferenceInclude {
+  private final String namespace;
+  private final String alias;
+
+  public EdmxReferenceIncludeImpl(String namespace, String alias) {
+    this.namespace = namespace;
+    this.alias = alias;
+  }
+
+  @Override
+  public String getNamespace() {
+    return namespace;
+  }
+
+  @Override
+  public String getAlias() {
+    return alias;
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java
index 0b13381..8956a6d 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/ODataXmlSerializerImpl.java
@@ -31,6 +31,7 @@ import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.server.api.ODataServerError;
+import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.serializer.SerializerException;
 import org.apache.olingo.server.api.serializer.ODataSerializerOptions;
@@ -53,7 +54,7 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
   }
 
   @Override
-  public InputStream metadataDocument(final Edm edm) throws SerializerException {
+  public InputStream metadataDocument(final ServiceMetadata serviceMetadata) throws SerializerException {
     CircleStreamBuffer buffer;
     XMLStreamWriter xmlStreamWriter = null;
 
@@ -61,7 +62,7 @@ public class ODataXmlSerializerImpl implements ODataSerializer {
     try {
       buffer = new CircleStreamBuffer();
       xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(buffer.getOutputStream(), DEFAULT_CHARSET);
-      MetadataDocumentXmlSerializer serializer = new MetadataDocumentXmlSerializer(edm);
+      MetadataDocumentXmlSerializer serializer = new MetadataDocumentXmlSerializer(serviceMetadata);
       serializer.writeMetadataDocument(xmlStreamWriter);
       xmlStreamWriter.flush();
       xmlStreamWriter.close();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
index 0066f73..324c5aa 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializer.java
@@ -42,6 +42,7 @@ import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.apache.olingo.server.api.ODataServerError;
+import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.serializer.SerializerException;
 import org.apache.olingo.server.api.serializer.ODataSerializerOptions;
@@ -107,7 +108,7 @@ public class ODataJsonSerializer implements ODataSerializer {
   }
 
   @Override
-  public InputStream metadataDocument(final Edm edm) throws SerializerException {
+  public InputStream metadataDocument(final ServiceMetadata serviceMetadata) throws SerializerException {
     throw new SerializerException("Metadata in JSON format not supported!",
         SerializerException.MessageKeys.JSON_METADATA);
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java
index d07360c..ec3dd5f 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java
@@ -18,31 +18,9 @@
  */
 package org.apache.olingo.server.core.serializer.xml;
 
-import org.apache.olingo.commons.api.edm.Edm;
-import org.apache.olingo.commons.api.edm.EdmAction;
-import org.apache.olingo.commons.api.edm.EdmActionImport;
-import org.apache.olingo.commons.api.edm.EdmBindingTarget;
-import org.apache.olingo.commons.api.edm.EdmComplexType;
-import org.apache.olingo.commons.api.edm.EdmEntityContainer;
-import org.apache.olingo.commons.api.edm.EdmEntitySet;
-import org.apache.olingo.commons.api.edm.EdmEntityType;
-import org.apache.olingo.commons.api.edm.EdmEnumType;
-import org.apache.olingo.commons.api.edm.EdmFunction;
-import org.apache.olingo.commons.api.edm.EdmFunctionImport;
-import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef;
-import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
-import org.apache.olingo.commons.api.edm.EdmNavigationPropertyBinding;
-import org.apache.olingo.commons.api.edm.EdmOperation;
-import org.apache.olingo.commons.api.edm.EdmParameter;
-import org.apache.olingo.commons.api.edm.EdmProperty;
-import org.apache.olingo.commons.api.edm.EdmReferentialConstraint;
-import org.apache.olingo.commons.api.edm.EdmReturnType;
-import org.apache.olingo.commons.api.edm.EdmSchema;
-import org.apache.olingo.commons.api.edm.EdmSingleton;
-import org.apache.olingo.commons.api.edm.EdmStructuredType;
-import org.apache.olingo.commons.api.edm.EdmType;
-import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.*;
+import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 
 import javax.xml.stream.XMLStreamException;
@@ -93,7 +71,7 @@ public class MetadataDocumentXmlSerializer {
   private static final String XML_NAMESPACE = "Namespace";
   private static final String XML_TYPE_DEFINITION = "TypeDefinition";
 
-  private final Edm edm;
+  private final ServiceMetadata serviceMetadata;
 
   private final static String EDMX = "Edmx";
   private final static String PREFIX_EDMX = "edmx";
@@ -101,8 +79,8 @@ public class MetadataDocumentXmlSerializer {
 
   private final static String NS_EDM = "http://docs.oasis-open.org/odata/ns/edm";
 
-  public MetadataDocumentXmlSerializer(final Edm edm) {
-    this.edm = edm;
+  public MetadataDocumentXmlSerializer(final ServiceMetadata edm) {
+    this.serviceMetadata = edm;
   }
 
   public void writeMetadataDocument(final XMLStreamWriter writer) throws XMLStreamException {
@@ -122,7 +100,7 @@ public class MetadataDocumentXmlSerializer {
   private void appendDataServices(final XMLStreamWriter writer) throws XMLStreamException {
     writer.setDefaultNamespace(NS_EDM);
     writer.writeStartElement(NS_EDMX, "DataServices");
-    for (EdmSchema schema : edm.getSchemas()) {
+    for (EdmSchema schema : serviceMetadata.getEdm().getSchemas()) {
       appendSchema(writer, schema);
     }
     writer.writeEndElement();
@@ -531,15 +509,17 @@ public class MetadataDocumentXmlSerializer {
    * and mentioned in its Common Schema Definition Language (CSDL) document.
    */
   private void appendReference(final XMLStreamWriter writer) throws XMLStreamException {
-    writer.writeStartElement(NS_EDMX, "Reference");
-    // TODO: Which value can we use here?
-    // <http://docs.oasis-open.org/odata/odata/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml>
-    // is an external site we don't want to query each time an EDM-enabled client is used.
-    writer.writeAttribute("Uri",
-        "http://localhost:9080/odata-server-tecsvc/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml");
-    writer.writeEmptyElement(NS_EDMX, "Include");
-    writer.writeAttribute(XML_NAMESPACE, "Org.OData.Core.V1");
-    writer.writeAttribute(XML_ALIAS, "Core");
-    writer.writeEndElement();
+    List<EdmxReference> references = serviceMetadata.getReferences();
+    for (EdmxReference reference: references) {
+      writer.writeStartElement(NS_EDMX, "Reference");
+      // TODO: Which value can we use here?
+      // <http://docs.oasis-open.org/odata/odata/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml>
+      // is an external site we don't want to query each time an EDM-enabled client is used.
+      writer.writeAttribute("Uri", reference.getUri().toASCIIString());
+  //    writer.writeEmptyElement(NS_EDMX, "Include");
+  //    writer.writeAttribute(XML_NAMESPACE, reference.getIncludeNamespace());
+  //    writer.writeAttribute(XML_ALIAS, reference.getIncludeAlias());
+  //    writer.writeEndElement();
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
index 6230a9e..5462327 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
@@ -35,6 +35,7 @@ import org.apache.olingo.commons.api.http.HttpMethod;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.processor.CustomContentTypeSupport;
 import org.apache.olingo.server.api.processor.EntitySetProcessor;
 import org.apache.olingo.server.api.processor.MetadataProcessor;
@@ -199,7 +200,7 @@ public class ContentNegotiatorTest {
     }
 
     @Override
-    public void init(final OData odata, final Edm edm) {}
+    public void init(final OData odata, final ServiceMetadata edm) {}
 
     @Override
     public List<ContentType> modifySupportedContentTypes(final List<ContentType> supportedContentTypes,

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMetadataImplTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMetadataImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMetadataImplTest.java
new file mode 100644
index 0000000..7090f5b
--- /dev/null
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMetadataImplTest.java
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.edm.provider;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.EdmEntitySetInfo;
+import org.apache.olingo.commons.api.edm.EdmException;
+import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
+import org.apache.olingo.commons.api.edm.EdmMetadata;
+import org.apache.olingo.commons.api.edm.EdmSingletonInfo;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.server.api.edm.provider.EdmProvider;
+import org.apache.olingo.server.api.edm.provider.EntityContainer;
+import org.apache.olingo.server.api.edm.provider.EntitySet;
+import org.apache.olingo.server.api.edm.provider.FunctionImport;
+import org.apache.olingo.server.api.edm.provider.Schema;
+import org.apache.olingo.server.api.edm.provider.Singleton;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class EdmMetadataImplTest {
+
+  @Test
+  public void allGettersMustDeliver() {
+    EdmMetadata serviceMetadata = new EdmMetadataImpl(new CustomProvider(true));
+    List<EdmEntitySetInfo> entitySetInfos = serviceMetadata.getEntitySetInfos();
+    assertNotNull(entitySetInfos);
+    assertEquals(2, entitySetInfos.size());
+
+    List<EdmSingletonInfo> singletonInfos = serviceMetadata.getSingletonInfos();
+    assertNotNull(singletonInfos);
+    assertEquals(2, singletonInfos.size());
+
+    List<EdmFunctionImportInfo> functionImportInfos = serviceMetadata.getFunctionImportInfos();
+    assertNotNull(functionImportInfos);
+    assertEquals(2, functionImportInfos.size());
+
+    // Cache test
+    assertTrue(entitySetInfos == serviceMetadata.getEntitySetInfos());
+    assertTrue(singletonInfos == serviceMetadata.getSingletonInfos());
+    assertTrue(functionImportInfos == serviceMetadata.getFunctionImportInfos());
+  }
+
+  @Test
+  public void initialProvider() {
+    EdmProvider provider = new EdmProvider() {};
+    EdmMetadata serviceMetadata = new EdmMetadataImpl(provider);
+    assertEquals(ODataServiceVersion.V40, serviceMetadata.getDataServiceVersion());
+  }
+
+  @Test(expected = EdmException.class)
+  public void initialProviderEntitySetInfo() {
+    EdmProvider provider = new EdmProvider() {};
+    EdmMetadata serviceMetadata = new EdmMetadataImpl(provider);
+    serviceMetadata.getEntitySetInfos();
+  }
+
+  @Test(expected = EdmException.class)
+  public void initialProviderSingletonInfo() {
+    EdmProvider provider = new EdmProvider() {};
+    EdmMetadata serviceMetadata = new EdmMetadataImpl(provider);
+    serviceMetadata.getSingletonInfos();
+  }
+
+  @Test(expected = EdmException.class)
+  public void initialProviderFunctionImportInfo() {
+    EdmProvider provider = new EdmProvider() {};
+    EdmMetadata serviceMetadata = new EdmMetadataImpl(provider);
+    serviceMetadata.getFunctionImportInfos();
+  }
+
+  @Test
+  public void emptySchemaMustNotResultInException() {
+    EdmMetadata serviceMetadata = new EdmMetadataImpl(new CustomProvider(false));
+    assertNotNull(serviceMetadata.getEntitySetInfos());
+    assertEquals(0, serviceMetadata.getEntitySetInfos().size());
+
+    assertNotNull(serviceMetadata.getSingletonInfos());
+    assertEquals(0, serviceMetadata.getSingletonInfos().size());
+
+    assertNotNull(serviceMetadata.getFunctionImportInfos());
+    assertEquals(0, serviceMetadata.getFunctionImportInfos().size());
+  }
+
+  @Test
+  public void oDataExceptionsGetCaughtAndTransformed() {
+    EdmProvider provider = new EdmProvider() {
+      @Override
+      public List<Schema> getSchemas() throws ODataException {
+        throw new ODataException("msg");
+      }
+    };
+
+    EdmMetadata serviceMetadata = new EdmMetadataImpl(provider);
+    callGetEntitySetInfosAndExpectException(serviceMetadata);
+    callGetSingletonInfosAndExpectException(serviceMetadata);
+    callGetFunctionImportInfosAndExpectException(serviceMetadata);
+  }
+
+  private void callGetFunctionImportInfosAndExpectException(final EdmMetadata svc) {
+    try {
+      svc.getFunctionImportInfos();
+    } catch (EdmException e) {
+      assertEquals("org.apache.olingo.commons.api.ODataException: msg", e.getMessage());
+      return;
+    }
+    fail("Expected EdmException was not thrown");
+
+  }
+
+  private void callGetSingletonInfosAndExpectException(final EdmMetadata svc) {
+    try {
+      svc.getSingletonInfos();
+    } catch (EdmException e) {
+      assertEquals("org.apache.olingo.commons.api.ODataException: msg", e.getMessage());
+      return;
+    }
+    fail("Expected EdmException was not thrown");
+  }
+
+  private void callGetEntitySetInfosAndExpectException(final EdmMetadata svc) {
+    try {
+      svc.getEntitySetInfos();
+    } catch (EdmException e) {
+      assertEquals("org.apache.olingo.commons.api.ODataException: msg", e.getMessage());
+      return;
+    }
+    fail("Expected EdmException was not thrown");
+  }
+
+  private class CustomProvider extends EdmProvider {
+    private List<Schema> schemas;
+
+    public CustomProvider(final boolean fillSchema) {
+      schemas = new ArrayList<Schema>();
+      if (fillSchema) {
+        List<EntitySet> entitySets = new ArrayList<EntitySet>();
+        entitySets.add(new EntitySet().setName("1"));
+        entitySets.add(new EntitySet().setName("2"));
+        List<Singleton> singletons = new ArrayList<Singleton>();
+        singletons.add(new Singleton().setName("1"));
+        singletons.add(new Singleton().setName("2"));
+        List<FunctionImport> functionImports = new ArrayList<FunctionImport>();
+        functionImports.add(new FunctionImport().setName("1"));
+        functionImports.add(new FunctionImport().setName("2"));
+        EntityContainer entityContainer =
+            new EntityContainer().setName("cont").setEntitySets(entitySets).setSingletons(singletons)
+                .setFunctionImports(functionImports);
+        Schema schema = new Schema().setEntityContainer(entityContainer);
+        schemas.add(schema);
+      }
+    }
+
+    @Override
+    public List<Schema> getSchemas() throws ODataException {
+      return schemas;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmServiceMetadataImplTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmServiceMetadataImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmServiceMetadataImplTest.java
deleted file mode 100644
index 3d08d35..0000000
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmServiceMetadataImplTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.edm.provider;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.EdmEntitySetInfo;
-import org.apache.olingo.commons.api.edm.EdmException;
-import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
-import org.apache.olingo.commons.api.edm.EdmSingletonInfo;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.server.api.edm.provider.EdmProvider;
-import org.apache.olingo.server.api.edm.provider.EntityContainer;
-import org.apache.olingo.server.api.edm.provider.EntitySet;
-import org.apache.olingo.server.api.edm.provider.FunctionImport;
-import org.apache.olingo.server.api.edm.provider.Schema;
-import org.apache.olingo.server.api.edm.provider.Singleton;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-public class EdmServiceMetadataImplTest {
-
-  @Test
-  public void allGettersMustDeliver() {
-    EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImpl(new CustomProvider(true));
-    List<EdmEntitySetInfo> entitySetInfos = serviceMetadata.getEntitySetInfos();
-    assertNotNull(entitySetInfos);
-    assertEquals(2, entitySetInfos.size());
-
-    List<EdmSingletonInfo> singletonInfos = serviceMetadata.getSingletonInfos();
-    assertNotNull(singletonInfos);
-    assertEquals(2, singletonInfos.size());
-
-    List<EdmFunctionImportInfo> functionImportInfos = serviceMetadata.getFunctionImportInfos();
-    assertNotNull(functionImportInfos);
-    assertEquals(2, functionImportInfos.size());
-
-    // Cache test
-    assertTrue(entitySetInfos == serviceMetadata.getEntitySetInfos());
-    assertTrue(singletonInfos == serviceMetadata.getSingletonInfos());
-    assertTrue(functionImportInfos == serviceMetadata.getFunctionImportInfos());
-  }
-
-  @Test(expected = RuntimeException.class)
-  public void getMetadataAsInputStreamIsNotImplemented() {
-    EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImpl(new CustomProvider(true));
-    serviceMetadata.getMetadata();
-  }
-
-  @Test
-  public void initialProvider() {
-    EdmProvider provider = new EdmProvider() {};
-    EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImpl(provider);
-    assertEquals(ODataServiceVersion.V40, serviceMetadata.getDataServiceVersion());
-  }
-
-  @Test(expected = EdmException.class)
-  public void initialProviderEntitySetInfo() {
-    EdmProvider provider = new EdmProvider() {};
-    EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImpl(provider);
-    serviceMetadata.getEntitySetInfos();
-  }
-
-  @Test(expected = EdmException.class)
-  public void initialProviderSingletonInfo() {
-    EdmProvider provider = new EdmProvider() {};
-    EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImpl(provider);
-    serviceMetadata.getSingletonInfos();
-  }
-
-  @Test(expected = EdmException.class)
-  public void initialProviderFunctionImportInfo() {
-    EdmProvider provider = new EdmProvider() {};
-    EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImpl(provider);
-    serviceMetadata.getFunctionImportInfos();
-  }
-
-  @Test
-  public void emptySchemaMustNotResultInException() {
-    EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImpl(new CustomProvider(false));
-    assertNotNull(serviceMetadata.getEntitySetInfos());
-    assertEquals(0, serviceMetadata.getEntitySetInfos().size());
-
-    assertNotNull(serviceMetadata.getSingletonInfos());
-    assertEquals(0, serviceMetadata.getSingletonInfos().size());
-
-    assertNotNull(serviceMetadata.getFunctionImportInfos());
-    assertEquals(0, serviceMetadata.getFunctionImportInfos().size());
-  }
-
-  @Test
-  public void oDataExceptionsGetCaughtAndTransformed() {
-    EdmProvider provider = new EdmProvider() {
-      @Override
-      public List<Schema> getSchemas() throws ODataException {
-        throw new ODataException("msg");
-      }
-    };
-
-    EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImpl(provider);
-    callGetEntitySetInfosAndExpectException(serviceMetadata);
-    callGetSingletonInfosAndExpectException(serviceMetadata);
-    callGetFunctionImportInfosAndExpectException(serviceMetadata);
-  }
-
-  private void callGetFunctionImportInfosAndExpectException(final EdmServiceMetadata svc) {
-    try {
-      svc.getFunctionImportInfos();
-    } catch (EdmException e) {
-      assertEquals("org.apache.olingo.commons.api.ODataException: msg", e.getMessage());
-      return;
-    }
-    fail("Expected EdmException was not thrown");
-
-  }
-
-  private void callGetSingletonInfosAndExpectException(final EdmServiceMetadata svc) {
-    try {
-      svc.getSingletonInfos();
-    } catch (EdmException e) {
-      assertEquals("org.apache.olingo.commons.api.ODataException: msg", e.getMessage());
-      return;
-    }
-    fail("Expected EdmException was not thrown");
-  }
-
-  private void callGetEntitySetInfosAndExpectException(final EdmServiceMetadata svc) {
-    try {
-      svc.getEntitySetInfos();
-    } catch (EdmException e) {
-      assertEquals("org.apache.olingo.commons.api.ODataException: msg", e.getMessage());
-      return;
-    }
-    fail("Expected EdmException was not thrown");
-  }
-
-  private class CustomProvider extends EdmProvider {
-    private List<Schema> schemas;
-
-    public CustomProvider(final boolean fillSchema) {
-      schemas = new ArrayList<Schema>();
-      if (fillSchema) {
-        List<EntitySet> entitySets = new ArrayList<EntitySet>();
-        entitySets.add(new EntitySet().setName("1"));
-        entitySets.add(new EntitySet().setName("2"));
-        List<Singleton> singletons = new ArrayList<Singleton>();
-        singletons.add(new Singleton().setName("1"));
-        singletons.add(new Singleton().setName("2"));
-        List<FunctionImport> functionImports = new ArrayList<FunctionImport>();
-        functionImports.add(new FunctionImport().setName("1"));
-        functionImports.add(new FunctionImport().setName("2"));
-        EntityContainer entityContainer =
-            new EntityContainer().setName("cont").setEntitySets(entitySets).setSingletons(singletons)
-                .setFunctionImports(functionImports);
-        Schema schema = new Schema().setEntityContainer(entityContainer);
-        schemas.add(schema);
-      }
-    }
-
-    @Override
-    public List<Schema> getSchemas() throws ODataException {
-      return schemas;
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
index 996385f..27defff 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalServlet.java
@@ -18,9 +18,10 @@
  */
 package org.apache.olingo.server.tecsvc;
 
-import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataHttpHandler;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.tecsvc.data.DataProvider;
 import org.apache.olingo.server.tecsvc.processor.TechnicalProcessor;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
@@ -33,6 +34,9 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 
 public class TechnicalServlet extends HttpServlet {
 
@@ -44,7 +48,8 @@ public class TechnicalServlet extends HttpServlet {
           throws ServletException, IOException {
     try {
       OData odata = OData.newInstance();
-      Edm edm = odata.createEdm(new EdmTechProvider());
+      List<EdmxReference> references = Collections.emptyList();
+      ServiceMetadata serviceMetadata = odata.createServiceMetadata(new EdmTechProvider(references), references);
 
       HttpSession session = req.getSession(true);
       DataProvider dataProvider = (DataProvider) session.getAttribute(DataProvider.class.getName());
@@ -54,7 +59,7 @@ public class TechnicalServlet extends HttpServlet {
         LOG.info("Created new data provider.");
       }
 
-      ODataHttpHandler handler = odata.createHandler(edm);
+      ODataHttpHandler handler = odata.createHandler(serviceMetadata);
       handler.register(new TechnicalProcessor(dataProvider));
       handler.process(req, resp);
     } catch (RuntimeException e) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
index 8609b0e..06eef4c 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
@@ -37,10 +37,7 @@ import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpContentType;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.ODataApplicationException;
-import org.apache.olingo.server.api.ODataRequest;
-import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.*;
 import org.apache.olingo.server.api.processor.EntityProcessor;
 import org.apache.olingo.server.api.processor.EntitySetProcessor;
 import org.apache.olingo.server.api.processor.PropertyProcessor;
@@ -71,7 +68,7 @@ public class TechnicalProcessor implements EntitySetProcessor, EntityProcessor,
   }
 
   @Override
-  public void init(final OData odata, final Edm edm) {
+  public void init(final OData odata, final ServiceMetadata edm) {
     this.odata = odata;
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EdmTechProvider.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EdmTechProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EdmTechProvider.java
index c15727b..aadc45b 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EdmTechProvider.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EdmTechProvider.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.server.tecsvc.provider;
 
 import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.server.api.edm.provider.Action;
 import org.apache.olingo.server.api.edm.provider.ActionImport;
@@ -38,6 +39,7 @@ import org.apache.olingo.server.api.edm.provider.Term;
 import org.apache.olingo.server.api.edm.provider.TypeDefinition;
 
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 public class EdmTechProvider extends EdmProvider {
@@ -52,8 +54,13 @@ public class EdmTechProvider extends EdmProvider {
   private final ActionProvider actionProvider;
   private final FunctionProvider functionProvider;
   private final TypeDefinitionProvider typeDefinitionProvider;
+  private final List<EdmxReference> references;
 
   public EdmTechProvider() {
+    this(Collections.<EdmxReference>emptyList());
+  }
+
+  public EdmTechProvider(List<EdmxReference> references) {
     containerProvider = new ContainerProvider(this);
     entityTypeProvider = new EntityTypeProvider();
     complexTypeProvider = new ComplexTypeProvider();
@@ -62,6 +69,7 @@ public class EdmTechProvider extends EdmProvider {
     functionProvider = new FunctionProvider();
     typeDefinitionProvider = new TypeDefinitionProvider();
     schemaProvider = new SchemaProvider(this);
+    this.references = references;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
index 943b589..b42bedb 100644
--- a/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
+++ b/lib/server-tecsvc/src/test/java/org/apache/olingo/server/tecsvc/data/DataProviderTest.java
@@ -19,6 +19,7 @@
 package org.apache.olingo.server.tecsvc.data;
 
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.olingo.commons.api.data.Entity;
@@ -30,6 +31,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.api.uri.UriParameter;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
 import org.junit.Assert;
@@ -38,7 +40,10 @@ import org.mockito.Mockito;
 
 public class DataProviderTest {
 
-  private final Edm edm = OData.newInstance().createEdm(new EdmTechProvider());
+  private final Edm edm =
+          OData.newInstance().createServiceMetadata(new EdmTechProvider(
+                          Collections.<EdmxReference>emptyList()),
+                          Collections.<EdmxReference>emptyList()).getEdm();
   private final EdmEntityContainer entityContainer = edm.getEntityContainer(
           new FullQualifiedName("olingo.odata.test1", "Container"));
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerExceptionHandlingTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerExceptionHandlingTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerExceptionHandlingTest.java
index f227f29..c0c8f18 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerExceptionHandlingTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerExceptionHandlingTest.java
@@ -24,20 +24,18 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 
+import java.util.Collections;
 import java.util.Locale;
 
 import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.http.HttpMethod;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.ODataApplicationException;
-import org.apache.olingo.server.api.ODataRequest;
-import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.*;
 import org.apache.olingo.server.api.edm.provider.EdmProvider;
 import org.apache.olingo.server.api.edm.provider.EntitySet;
+import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.api.processor.MetadataProcessor;
 import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
@@ -50,9 +48,10 @@ public class ODataHandlerExceptionHandlingTest {
   @Before
   public void before() {
     OData odata = OData.newInstance();
-    Edm edm = odata.createEdm(new EdmTechProvider());
+    ServiceMetadata metadata = odata.createServiceMetadata(
+            new EdmTechProvider(), Collections.<EdmxReference>emptyList());
 
-    handler = new ODataHandler(odata, edm);
+    handler = new ODataHandler(odata, metadata);
   }
 
   @Test
@@ -173,14 +172,14 @@ public class ODataHandlerExceptionHandlingTest {
     request.setRawODataPath("EdmException");
 
     OData odata = OData.newInstance();
-    Edm edm = odata.createEdm(new EdmProvider() {
+    ServiceMetadata serviceMetadata = odata.createServiceMetadata(new EdmProvider() {
       public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName)
           throws ODataException {
         throw new ODataException("msg");
       }
-    });
+    }, Collections.<EdmxReference>emptyList());
 
-    ODataHandler localHandler = new ODataHandler(odata, edm);
+    ODataHandler localHandler = new ODataHandler(odata, serviceMetadata);
 
     ODataResponse response = localHandler.process(request);
     assertNotNull(response);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
index 1ae9ea3..b8c6553 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
@@ -24,9 +24,9 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 
 import java.util.Arrays;
+import java.util.Collections;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.http.HttpContentType;
@@ -36,6 +36,8 @@ import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.api.processor.*;
 import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
@@ -50,9 +52,10 @@ public class ODataHandlerTest {
   @Before
   public void before() {
     OData odata = OData.newInstance();
-    Edm edm = odata.createEdm(new EdmTechProvider());
+    ServiceMetadata metadata = odata.createServiceMetadata(
+            new EdmTechProvider(), Collections.<EdmxReference>emptyList());
 
-    handler = new ODataHandler(odata, edm);
+    handler = new ODataHandler(odata, metadata);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
index 36e3887..562787d 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/json/ODataJsonSerializerTest.java
@@ -21,6 +21,7 @@ package org.apache.olingo.server.core.serializer.json;
 import java.io.InputStream;
 import java.net.URI;
 import java.util.Arrays;
+import java.util.Collections;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.commons.api.data.ContextURL;
@@ -37,6 +38,7 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.core.data.PropertyImpl;
 import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.serializer.SerializerException;
 import org.apache.olingo.server.api.serializer.ODataSerializerOptions;
@@ -56,7 +58,8 @@ import org.mockito.Mockito;
 
 public class ODataJsonSerializerTest {
 
-  private static final Edm edm = OData.newInstance().createEdm(new EdmTechProvider());
+  private static final Edm edm = OData.newInstance().createServiceMetadata(
+          new EdmTechProvider(), Collections.<EdmxReference>emptyList()).getEdm();
   private static final EdmEntityContainer entityContainer = edm.getEntityContainer(
       new FullQualifiedName("olingo.odata.test1", "Container"));
   private final DataProvider data = new DataProvider();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelperTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelperTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelperTest.java
index f622cd1..a880c60 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelperTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/utils/ContextURLHelperTest.java
@@ -21,6 +21,7 @@ package org.apache.olingo.server.core.serializer.utils;
 import static org.junit.Assert.assertEquals;
 
 import java.util.Arrays;
+import java.util.Collections;
 
 import org.apache.olingo.commons.api.data.ContextURL;
 import org.apache.olingo.commons.api.edm.Edm;
@@ -28,6 +29,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityContainer;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.api.uri.queryoption.ExpandItem;
 import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
 import org.apache.olingo.server.api.uri.queryoption.SelectItem;
@@ -39,7 +41,8 @@ import org.mockito.Mockito;
 
 public class ContextURLHelperTest {
 
-  private static final Edm edm = OData.newInstance().createEdm(new EdmTechProvider());
+  private static final Edm edm = OData.newInstance().createServiceMetadata(
+          new EdmTechProvider(), Collections.<EdmxReference>emptyList()).getEdm();
   private static final EdmEntityContainer entityContainer = edm.getEntityContainer(
       new FullQualifiedName("olingo.odata.test1", "Container"));
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
index 2dbce10..8fbbf15 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
@@ -21,10 +21,12 @@ package org.apache.olingo.server.core.serializer.xml;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.commons.io.IOUtils;
@@ -33,8 +35,10 @@ import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.Target;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.edm.provider.Action;
 import org.apache.olingo.server.api.edm.provider.ActionImport;
 import org.apache.olingo.server.api.edm.provider.ComplexType;
@@ -54,32 +58,31 @@ import org.apache.olingo.server.api.edm.provider.ReturnType;
 import org.apache.olingo.server.api.edm.provider.Schema;
 import org.apache.olingo.server.api.edm.provider.Singleton;
 import org.apache.olingo.server.api.edm.provider.TypeDefinition;
+import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.serializer.SerializerException;
+import org.apache.olingo.server.core.ServiceMetadataImpl;
 import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
 import org.junit.Test;
 
 public class MetadataDocumentTest {
 
-  @Test(expected = SerializerException.class)
-  public void metadataOnJsonResultsInException() throws Exception {
-    ODataSerializer serializer = OData.newInstance().createSerializer(ODataFormat.JSON);
-    serializer.metadataDocument(mock(Edm.class));
-  }
-
   @Test
   public void writeMetadataWithEmptyMockedEdm() throws Exception {
     ODataSerializer serializer = OData.newInstance().createSerializer(ODataFormat.XML);
+    ServiceMetadata metadata = mock(ServiceMetadata.class);
     Edm edm = mock(Edm.class);
-    serializer.metadataDocument(edm);
+    when(metadata.getEdm()).thenReturn(edm);
+    serializer.metadataDocument(metadata);
   }
 
   @Test
   public void writeMetadataWithLocalTestEdm() throws Exception {
     ODataSerializer serializer = OData.newInstance().createSerializer(ODataFormat.XML);
-    Edm edm = new EdmProviderImpl(new TestMetadataProvider());
-    InputStream metadata = serializer.metadataDocument(edm);
+    ServiceMetadata serviceMetadata = new ServiceMetadataImpl(ODataServiceVersion.V40,
+            new TestMetadataProvider(), Collections.<EdmxReference>emptyList());
+    InputStream metadata = serializer.metadataDocument(serviceMetadata);
     assertNotNull(metadata);
 
     String metadataString = IOUtils.toString(metadata);
@@ -147,8 +150,9 @@ public class MetadataDocumentTest {
   @Test
   public void writeMetadataWithTechnicalScenario() throws Exception {
     ODataSerializer serializer = OData.newInstance().createSerializer(ODataFormat.XML);
-    EdmProviderImpl edm = new EdmProviderImpl(new EdmTechProvider());
-    InputStream metadata = serializer.metadataDocument(edm);
+    ServiceMetadata serviceMetadata = new ServiceMetadataImpl(ODataServiceVersion.V40,
+            new TestMetadataProvider(), Collections.<EdmxReference>emptyList());
+    InputStream metadata = serializer.metadataDocument(serviceMetadata);
     assertNotNull(metadata);
     // The technical scenario is too big to verify. We are content for now to make sure we can serialize it.
     // System.out.println(StringUtils.inputStreamToString(metadata, false));


[3/6] git commit: [OLINGO-456] Removed deprecated classes

Posted by mi...@apache.org.
[OLINGO-456] Removed deprecated classes


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/87f0f06a
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/87f0f06a
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/87f0f06a

Branch: refs/heads/master
Commit: 87f0f06a39f426bccbb2a0496ad40781850fd7db
Parents: 188574f
Author: Michael Bolz <mi...@sap.com>
Authored: Mon Oct 13 08:18:53 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Mon Oct 13 08:18:53 2014 +0200

----------------------------------------------------------------------
 .../core/edm/AbstractEdmMetadataImpl.java       |  92 ----------
 .../client/core/edm/EdmAnnotationImpl.java      |   2 +-
 .../olingo/client/core/edm/EdmClientImpl.java   |  10 -
 .../client/core/edm/v3/EdmMetadataImpl.java     |  97 ----------
 .../client/core/edm/v4/EdmMetadataImpl.java     | 103 -----------
 .../EdmConstantAnnotationExpressionImpl.java    |   6 +-
 .../olingo/client/core/v3/MetadataTest.java     |  18 +-
 .../olingo/client/core/v4/MetadataTest.java     |  42 +++--
 .../org/apache/olingo/commons/api/edm/Edm.java  |   9 -
 .../olingo/commons/api/edm/EdmMetadata.java     |  57 ------
 .../olingo/commons/core/edm/AbstractEdm.java    |  13 --
 .../commons/core/edm/EdmImplCachingTest.java    |  15 --
 .../commons/core/edm/EdmImplCallCreateTest.java |  11 --
 .../core/edm/provider/EdmMetadataImpl.java      | 173 ------------------
 .../core/edm/provider/EdmProviderImpl.java      |   6 -
 .../core/edm/provider/EdmMetadataImplTest.java  | 182 -------------------
 .../core/edm/provider/EdmProviderImplTest.java  |   7 -
 17 files changed, 37 insertions(+), 806 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmMetadataImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmMetadataImpl.java
deleted file mode 100644
index 88c95fa..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmMetadataImpl.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.core.edm;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import org.apache.olingo.client.api.edm.xml.EntityContainer;
-import org.apache.olingo.client.api.edm.xml.EntitySet;
-import org.apache.olingo.client.api.edm.xml.Schema;
-import org.apache.olingo.client.core.edm.v3.EdmMetadataImpl;
-import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmEntitySetInfo;
-import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmMetadata;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.edm.EdmEntitySetInfoImpl;
-
-public abstract class AbstractEdmMetadataImpl implements EdmMetadata {
-
-  protected final List<? extends Schema> xmlSchemas;
-
-  private List<EdmEntitySetInfo> entitySetInfos;
-
-  protected List<EdmFunctionImportInfo> functionImportInfos;
-
-  protected List<EdmActionImportInfo> actionImportInfos;
-
-  public static EdmMetadata getInstance(final ODataServiceVersion version, final List<Schema> xmlSchemas) {
-
-    return version.compareTo(ODataServiceVersion.V40) < 0
-            ? new EdmMetadataImpl(xmlSchemas)
-            : new org.apache.olingo.client.core.edm.v4.EdmMetadataImpl(xmlSchemas);
-  }
-
-  public AbstractEdmMetadataImpl(final List<? extends Schema> xmlSchemas) {
-    this.xmlSchemas = xmlSchemas;
-  }
-
-  @Override
-  public List<EdmEntitySetInfo> getEntitySetInfos() {
-    synchronized (this) {
-      if (entitySetInfos == null) {
-        entitySetInfos = new ArrayList<EdmEntitySetInfo>();
-        for (Schema schema : xmlSchemas) {
-          for (EntityContainer entityContainer : schema.getEntityContainers()) {
-            for (EntitySet entitySet : entityContainer.getEntitySets()) {
-              entitySetInfos.add(new EdmEntitySetInfoImpl(entityContainer.getName(), entitySet.getName()));
-            }
-          }
-        }
-      }
-      return entitySetInfos;
-    }
-  }
-
-  @Override
-  public boolean equals(final Object obj) {
-    return EqualsBuilder.reflectionEquals(this, obj);
-  }
-
-  @Override
-  public int hashCode() {
-    return HashCodeBuilder.reflectionHashCode(this);
-  }
-
-  @Override
-  public String toString() {
-    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java
index ea1ef27..81b89a9 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java
@@ -96,7 +96,7 @@ public class EdmAnnotationImpl implements EdmAnnotation {
     EdmAnnotationExpression _expression = null;
 
     if (exp.isConstant()) {
-      _expression = new EdmConstantAnnotationExpressionImpl(edm, exp.asConstant());
+      _expression = new EdmConstantAnnotationExpressionImpl(exp.asConstant());
     } else if (annotation.getExpression().isDynamic()) {
       _expression = getDynamicExpression(exp.asDynamic());
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
index d2084b6..f2dedcc 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
@@ -58,7 +58,6 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmEnumType;
 import org.apache.olingo.commons.api.edm.EdmFunction;
 import org.apache.olingo.commons.api.edm.EdmSchema;
-import org.apache.olingo.commons.api.edm.EdmMetadata;
 import org.apache.olingo.commons.api.edm.EdmTerm;
 import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
@@ -74,8 +73,6 @@ public class EdmClientImpl extends AbstractEdm {
 
   private final Map<String, Schema> xmlSchemaByNamespace;
 
-  private final EdmMetadata serviceMetadata;
-
   public EdmClientImpl(final ODataServiceVersion version, final Map<String, Schema> xmlSchemas) {
     this.version = version;
 
@@ -87,13 +84,6 @@ public class EdmClientImpl extends AbstractEdm {
         this.xmlSchemas.add(schema);
       }
     }
-
-    this.serviceMetadata = AbstractEdmMetadataImpl.getInstance(version, this.xmlSchemas);
-  }
-
-  @Override
-  protected EdmMetadata createServiceMetadata() {
-    return serviceMetadata;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmMetadataImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmMetadataImpl.java
deleted file mode 100644
index b6ace40..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmMetadataImpl.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.core.edm.v3;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.client.api.edm.xml.CommonFunctionImport;
-import org.apache.olingo.client.api.edm.xml.EntityContainer;
-import org.apache.olingo.client.api.edm.xml.Schema;
-import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
-import org.apache.olingo.client.api.v3.UnsupportedInV3Exception;
-import org.apache.olingo.client.core.edm.AbstractEdmMetadataImpl;
-import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmSingletonInfo;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.edm.EdmActionImportInfoImpl;
-import org.apache.olingo.commons.core.edm.EdmFunctionImportInfoImpl;
-
-public class EdmMetadataImpl extends AbstractEdmMetadataImpl {
-
-  private static final ODataServiceVersion SERVICE_VERSION = ODataServiceVersion.V30;
-
-  public EdmMetadataImpl(final List<? extends Schema> xmlSchemas) {
-    super(xmlSchemas);
-  }
-
-  @Override
-  public ODataServiceVersion getDataServiceVersion() {
-    return SERVICE_VERSION;
-  }
-
-  @Override
-  public List<EdmSingletonInfo> getSingletonInfos() {
-    throw new UnsupportedInV3Exception();
-  }
-
-  @Override
-  public List<EdmFunctionImportInfo> getFunctionImportInfos() {
-    synchronized (this) {
-      if (functionImportInfos == null) {
-        functionImportInfos = new ArrayList<EdmFunctionImportInfo>();
-        for (Schema schema : xmlSchemas) {
-          for (EntityContainer entityContainer : schema.getEntityContainers()) {
-            for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
-              final FunctionImport _funFunctionImport = (FunctionImport) functionImport;
-              if (FunctionImportUtils.canProxyFunction(_funFunctionImport)) {
-                functionImportInfos.add(
-                        new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
-              }
-            }
-          }
-        }
-      }
-      return functionImportInfos;
-    }
-  }
-
-  @Override
-  public List<EdmActionImportInfo> getActionImportInfos() {
-    synchronized (this) {
-      if (actionImportInfos == null) {
-        actionImportInfos = new ArrayList<EdmActionImportInfo>();
-        for (Schema schema : xmlSchemas) {
-          for (EntityContainer entityContainer : schema.getEntityContainers()) {
-            for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
-              final FunctionImport _funFunctionImport = (FunctionImport) functionImport;
-              if (!FunctionImportUtils.canProxyFunction(_funFunctionImport)) {
-                actionImportInfos.add(
-                        new EdmActionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
-              }
-            }
-          }
-        }
-      }
-      return actionImportInfos;
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/EdmMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/EdmMetadataImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/EdmMetadataImpl.java
deleted file mode 100644
index c9a0e75..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/EdmMetadataImpl.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.core.edm.v4;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.client.api.edm.xml.CommonFunctionImport;
-import org.apache.olingo.client.api.edm.xml.Schema;
-import org.apache.olingo.client.api.edm.xml.v4.ActionImport;
-import org.apache.olingo.client.api.edm.xml.v4.EntityContainer;
-import org.apache.olingo.client.api.edm.xml.v4.Singleton;
-import org.apache.olingo.client.core.edm.AbstractEdmMetadataImpl;
-import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmSingletonInfo;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.edm.EdmActionImportInfoImpl;
-import org.apache.olingo.commons.core.edm.EdmFunctionImportInfoImpl;
-import org.apache.olingo.commons.core.edm.EdmSingletonInfoImpl;
-
-public class EdmMetadataImpl extends AbstractEdmMetadataImpl {
-
-  private static final ODataServiceVersion SERVICE_VERSION = ODataServiceVersion.V40;
-
-  private List<EdmSingletonInfo> singletonInfos;
-
-  public EdmMetadataImpl(final List<Schema> xmlSchemas) {
-    super(xmlSchemas);
-  }
-
-  @Override
-  public ODataServiceVersion getDataServiceVersion() {
-    return SERVICE_VERSION;
-  }
-
-  @Override
-  public List<EdmSingletonInfo> getSingletonInfos() {
-    synchronized (this) {
-      if (singletonInfos == null) {
-        singletonInfos = new ArrayList<EdmSingletonInfo>();
-        for (Schema schema : xmlSchemas) {
-          final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
-          for (Singleton singleton : entityContainer.getSingletons()) {
-            singletonInfos.add(new EdmSingletonInfoImpl(entityContainer.getName(), singleton.getName()));
-          }
-        }
-      }
-      return singletonInfos;
-    }
-  }
-
-  @Override
-  public List<EdmFunctionImportInfo> getFunctionImportInfos() {
-    synchronized (this) {
-      if (functionImportInfos == null) {
-        functionImportInfos = new ArrayList<EdmFunctionImportInfo>();
-        for (Schema schema : xmlSchemas) {
-          final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
-
-          for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
-            functionImportInfos.add(
-                    new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
-          }
-        }
-      }
-    }
-
-    return functionImportInfos;
-  }
-
-  @Override
-  public List<EdmActionImportInfo> getActionImportInfos() {
-    synchronized (this) {
-      if (actionImportInfos == null) {
-        actionImportInfos = new ArrayList<EdmActionImportInfo>();
-        for (Schema schema : xmlSchemas) {
-          final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
-          for (ActionImport actionImport : entityContainer.getActionImports()) {
-            actionImportInfos.add(new EdmActionImportInfoImpl(entityContainer.getName(), actionImport.getName()));
-          }
-        }
-      }
-      return actionImportInfos;
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmConstantAnnotationExpressionImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmConstantAnnotationExpressionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmConstantAnnotationExpressionImpl.java
index e0ce3ba..aeded52 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmConstantAnnotationExpressionImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmConstantAnnotationExpressionImpl.java
@@ -26,12 +26,12 @@ import org.apache.olingo.client.api.edm.xml.v4.annotation.ConstantAnnotationExpr
 import org.apache.olingo.commons.api.Constants;
 import org.apache.olingo.commons.api.domain.v4.ODataEnumValue;
 import org.apache.olingo.commons.api.domain.v4.ODataValue;
-import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.annotation.EdmConstantAnnotationExpression;
 import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.core.domain.v4.ODataCollectionValueImpl;
 import org.apache.olingo.commons.core.domain.v4.ODataEnumValueImpl;
 import org.apache.olingo.commons.core.domain.v4.ODataPrimitiveValueImpl;
@@ -41,7 +41,7 @@ public class EdmConstantAnnotationExpressionImpl implements EdmConstantAnnotatio
 
   private final ODataValue value;
 
-  public EdmConstantAnnotationExpressionImpl(final Edm edm, final ConstantAnnotationExpression constExprConstruct) {
+  public EdmConstantAnnotationExpressionImpl(final ConstantAnnotationExpression constExprConstruct) {
     if (constExprConstruct.getType() == ConstantAnnotationExpression.Type.EnumMember) {
       final List<ODataEnumValue> enumValues = new ArrayList<ODataEnumValue>();
       String enumTypeName = null;
@@ -97,7 +97,7 @@ public class EdmConstantAnnotationExpressionImpl implements EdmConstantAnnotatio
           kind = EdmPrimitiveTypeKind.String;
       }
       final ODataPrimitiveValueImpl.BuilderImpl primitiveValueBuilder =
-          new ODataPrimitiveValueImpl.BuilderImpl(edm.getServiceMetadata().getDataServiceVersion());
+          new ODataPrimitiveValueImpl.BuilderImpl(ODataServiceVersion.V40);
       primitiveValueBuilder.setType(kind);
       try {
         final EdmPrimitiveType primitiveType = EdmPrimitiveTypeFactory.getInstance(kind);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java
index 75f1c2a..b84e115 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java
@@ -23,13 +23,9 @@ import org.apache.olingo.client.api.edm.xml.EntityType;
 import org.apache.olingo.client.api.edm.xml.Schema;
 import org.apache.olingo.client.api.edm.xml.XMLMetadata;
 import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
-import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.client.api.v3.ODataClient;
-import org.apache.olingo.client.core.AbstractTest;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmAction;
 import org.apache.olingo.commons.api.edm.EdmActionImport;
-import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
 import org.apache.olingo.commons.api.edm.EdmBindingTarget;
 import org.apache.olingo.commons.api.edm.EdmComplexType;
 import org.apache.olingo.commons.api.edm.EdmEntityContainer;
@@ -37,11 +33,14 @@ import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmFunction;
 import org.apache.olingo.commons.api.edm.EdmFunctionImport;
-import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
 import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmReturnType;
+import org.apache.olingo.commons.api.edm.EdmSchema;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.http.HttpMethod;
+import org.apache.olingo.client.api.v3.ODataClient;
+import org.apache.olingo.client.core.AbstractTest;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.junit.Test;
@@ -260,10 +259,11 @@ public class MetadataTest extends AbstractTest {
     final Edm metadata = getClient().getReader().
             readMetadata(getClass().getResourceAsStream("metadata.xml"));
     assertNotNull(metadata);
+    final EdmSchema schema = metadata.getSchemas().get(0);
 
     final Set<String> actionImports = new HashSet<String>();
-    for (EdmActionImportInfo info : metadata.getServiceMetadata().getActionImportInfos()) {
-      actionImports.add(info.getActionImportName());
+    for (EdmAction info : schema.getActions()) {
+      actionImports.add(info.getName());
     }
     final Set<String> expectedAI = new HashSet<String>(Arrays.asList(new String[] {
       "ResetDataSource",
@@ -274,8 +274,8 @@ public class MetadataTest extends AbstractTest {
       "ResetComputerDetailsSpecifications"}));
     assertEquals(expectedAI, actionImports);
     final Set<String> functionImports = new HashSet<String>();
-    for (EdmFunctionImportInfo info : metadata.getServiceMetadata().getFunctionImportInfos()) {
-      functionImports.add(info.getFunctionImportName());
+    for (EdmFunction info : schema.getFunctions()) {
+      functionImports.add(info.getName());
     }
     final Set<String> expectedFI = new HashSet<String>(Arrays.asList(new String[] {
       "GetPrimitiveString",

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java
index c804d13..ab58fff 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java
@@ -55,7 +55,6 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmEnumType;
 import org.apache.olingo.commons.api.edm.EdmFunction;
 import org.apache.olingo.commons.api.edm.EdmFunctionImport;
-import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.EdmSchema;
 import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
@@ -68,6 +67,8 @@ import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32;
 import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
 import org.junit.Test;
 
+import java.util.List;
+
 public class MetadataTest extends AbstractTest {
 
   @Override
@@ -240,24 +241,29 @@ public class MetadataTest extends AbstractTest {
     final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml"));
     assertNotNull(edm);
 
-    final EdmFunctionImportInfo fiInfo = edm.getServiceMetadata().getFunctionImportInfos().get(0);
-    final EdmEntityContainer demoService = edm.getEntityContainer(
-            new FullQualifiedName(metadata.getSchema(0).getNamespace(), fiInfo.getEntityContainerName()));
+    List<EdmSchema> schemaList = edm.getSchemas();
+    assertNotNull(schemaList);
+    assertEquals(1, schemaList.size());
+    EdmSchema schema = schemaList.get(0);
+
+    EdmEntityContainer demoService = schema.getEntityContainer();
     assertNotNull(demoService);
-    final EdmFunctionImport fi = demoService.getFunctionImport(fiInfo.getFunctionImportName());
-    assertNotNull(fi);
-    assertEquals(demoService.getEntitySet("Products"), fi.getReturnedEntitySet());
-
-    final EdmFunction function = edm.getUnboundFunction(
-            new FullQualifiedName(metadata.getSchema(0).getNamespace(), "ProductsByRating"), null);
-    assertNotNull(function);
-    assertEquals(function.getName(), fi.getUnboundFunction(null).getName());
-    assertEquals(function.getNamespace(), fi.getUnboundFunction(null).getNamespace());
-    assertEquals(function.getParameterNames(), fi.getUnboundFunction(null).getParameterNames());
-    assertEquals(function.getReturnType().getType().getName(),
-            fi.getUnboundFunction(null).getReturnType().getType().getName());
-    assertEquals(function.getReturnType().getType().getNamespace(),
-            fi.getUnboundFunction(null).getReturnType().getType().getNamespace());
+    for (EdmFunction function : schema.getFunctions()) {
+      final EdmFunctionImport fi = demoService.getFunctionImport(function.getName());
+      assertNotNull(fi);
+      assertEquals(demoService.getEntitySet("Products"), fi.getReturnedEntitySet());
+
+      final EdmFunction edmFunction = edm.getUnboundFunction(
+              new FullQualifiedName(metadata.getSchema(0).getNamespace(), "ProductsByRating"), null);
+      assertNotNull(edmFunction);
+      assertEquals(edmFunction.getName(), fi.getUnboundFunction(null).getName());
+      assertEquals(edmFunction.getNamespace(), fi.getUnboundFunction(null).getNamespace());
+      assertEquals(edmFunction.getParameterNames(), fi.getUnboundFunction(null).getParameterNames());
+      assertEquals(edmFunction.getReturnType().getType().getName(),
+              fi.getUnboundFunction(null).getReturnType().getType().getName());
+      assertEquals(edmFunction.getReturnType().getType().getNamespace(),
+              fi.getUnboundFunction(null).getReturnType().getType().getNamespace());
+    }
 
     final EdmTypeDefinition weight = edm.getTypeDefinition(new FullQualifiedName("ODataDemo", "Weight"));
     assertNotNull(weight);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java
index eb609cd..8790afb 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java
@@ -172,13 +172,4 @@ public interface Edm {
    * @return {@link EdmAnnotation}
    */
   EdmAnnotation getAnnotation(FullQualifiedName annotatableName, EdmTerm term);
-
-  /**
-   * Get service metadata.
-   * <br/>
-   * See {@link EdmMetadata} for more information.
-   * 
-   * @return {@link EdmMetadata}
-   */
-  EdmMetadata getServiceMetadata();
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmMetadata.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmMetadata.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmMetadata.java
deleted file mode 100644
index 04b16ab..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmMetadata.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.api.edm;
-
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-import java.util.List;
-
-/**
- * This interface gives an info list of all
- * entity sets, singletons, and function imports inside the EntityDataModel.
- */
-@Deprecated
-public interface EdmMetadata {
-
-  /**
-   * @return a list of {@link EdmEntitySetInfo} objects inside the data model
-   */
-  List<EdmEntitySetInfo> getEntitySetInfos();
-
-  /**
-   * @return a list of {@link EdmSingletonInfo} objects inside the data model
-   */
-  List<EdmSingletonInfo> getSingletonInfos();
-
-  /**
-   * @return a list of {@link EdmActionImportInfo} objects inside the data model
-   */
-  List<EdmActionImportInfo> getActionImportInfos();
-
-  /**
-   * @return a list of {@link EdmFunctionImportInfo} objects inside the data model
-   */
-  List<EdmFunctionImportInfo> getFunctionImportInfos();
-
-  /**
-   *
-   * @return
-   */
-  ODataServiceVersion getDataServiceVersion();
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
index 2646038..e9aea82 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
@@ -28,7 +28,6 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmEnumType;
 import org.apache.olingo.commons.api.edm.EdmFunction;
 import org.apache.olingo.commons.api.edm.EdmSchema;
-import org.apache.olingo.commons.api.edm.EdmMetadata;
 import org.apache.olingo.commons.api.edm.EdmTerm;
 import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
@@ -76,8 +75,6 @@ public abstract class AbstractEdm implements Edm {
   private final Map<FullQualifiedName, List<EdmAnnotation>> annotations =
       new HashMap<FullQualifiedName, List<EdmAnnotation>>();
 
-  private EdmMetadata serviceMetadata;
-
   private Map<String, String> aliasToNamespaceInfo;
 
   @Override
@@ -402,14 +399,6 @@ public abstract class AbstractEdm implements Edm {
     return result;
   }
 
-  @Override
-  public EdmMetadata getServiceMetadata() {
-    if (serviceMetadata == null) {
-      serviceMetadata = createServiceMetadata();
-    }
-    return serviceMetadata;
-  }
-
   private FullQualifiedName resolvePossibleAlias(final FullQualifiedName namespaceOrAliasFQN) {
     if (aliasToNamespaceInfo == null) {
       aliasToNamespaceInfo = createAliasToNamespaceInfo();
@@ -455,8 +444,6 @@ public abstract class AbstractEdm implements Edm {
       FullQualifiedName bindingParameterTypeName, Boolean isBindingParameterCollection,
       List<String> parameterNames);
 
-  protected abstract EdmMetadata createServiceMetadata();
-
   protected abstract EdmTerm createTerm(FullQualifiedName termName);
 
   protected abstract EdmAnnotations createAnnotationGroup(FullQualifiedName targetName);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java
index e12229a..f358543 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java
@@ -29,7 +29,6 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmEnumType;
 import org.apache.olingo.commons.api.edm.EdmFunction;
 import org.apache.olingo.commons.api.edm.EdmSchema;
-import org.apache.olingo.commons.api.edm.EdmMetadata;
 import org.apache.olingo.commons.api.edm.EdmTerm;
 import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
@@ -249,15 +248,6 @@ public class EdmImplCachingTest {
     assertNotSame(function, function2);
   }
 
-  @Test
-  public void cacheServiceMetadata() {
-    EdmMetadata serviceMetadata = edm.getServiceMetadata();
-    EdmMetadata cachedMetadata = edm.getServiceMetadata();
-
-    assertTrue(serviceMetadata == cachedMetadata);
-    assertEquals(serviceMetadata, cachedMetadata);
-  }
-
   @Before
   public void setup() {
     edm = new LocalEdm();
@@ -361,11 +351,6 @@ public class EdmImplCachingTest {
     }
 
     @Override
-    public EdmMetadata createServiceMetadata() {
-      return mock(EdmMetadata.class);
-    }
-
-    @Override
     protected Map<String, String> createAliasToNamespaceInfo() {
       return new HashMap<String, String>();
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java
index 5b8adc9..87fe0e6 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java
@@ -28,7 +28,6 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmEnumType;
 import org.apache.olingo.commons.api.edm.EdmFunction;
 import org.apache.olingo.commons.api.edm.EdmSchema;
-import org.apache.olingo.commons.api.edm.EdmMetadata;
 import org.apache.olingo.commons.api.edm.EdmTerm;
 import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
@@ -151,11 +150,6 @@ public class EdmImplCallCreateTest {
     assertNull(edm.getUnboundFunction(WRONG_FQN, null));
   }
 
-  @Test
-  public void callCreateServiceMetadata() {
-    assertNotNull(edm.getServiceMetadata());
-  }
-
   @Before
   public void setup() {
     edm = new LocalEdm();
@@ -244,11 +238,6 @@ public class EdmImplCallCreateTest {
     }
 
     @Override
-    public EdmMetadata createServiceMetadata() {
-      return mock(EdmMetadata.class);
-    }
-
-    @Override
     protected Map<String, String> createAliasToNamespaceInfo() {
       return new HashMap<String, String>();
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmMetadataImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmMetadataImpl.java
deleted file mode 100644
index 8306954..0000000
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmMetadataImpl.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.edm.provider;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.*;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.edm.EdmActionImportInfoImpl;
-import org.apache.olingo.commons.core.edm.EdmEntitySetInfoImpl;
-import org.apache.olingo.commons.core.edm.EdmFunctionImportInfoImpl;
-import org.apache.olingo.commons.core.edm.EdmSingletonInfoImpl;
-import org.apache.olingo.server.api.edm.provider.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class EdmMetadataImpl implements EdmMetadata {
-
-  private EdmProvider provider;
-
-  private List<Schema> schemas;
-
-  private List<EdmEntitySetInfo> entitySetInfos;
-
-  private List<EdmSingletonInfo> singletonInfos;
-
-  private List<EdmActionImportInfo> actionImportInfos;
-
-  private List<EdmFunctionImportInfo> functionImportInfos;
-
-  public EdmMetadataImpl(final EdmProvider provider) {
-    this.provider = provider;
-  }
-
-  @Override
-  public List<EdmEntitySetInfo> getEntitySetInfos() {
-    if (entitySetInfos == null) {
-      try {
-        entitySetInfos = new ArrayList<EdmEntitySetInfo>();
-        if (schemas == null) {
-          schemas = provider.getSchemas();
-          if (schemas == null) {
-            throw new EdmException("Provider doe not define any schemas.");
-          }
-        }
-        for (Schema schema : schemas) {
-          final EntityContainer entityContainer = schema.getEntityContainer();
-          if (entityContainer != null) {
-            final List<EntitySet> entitySets = entityContainer.getEntitySets();
-            if (entitySets != null) {
-              for (EntitySet set : entitySets) {
-                entitySetInfos.add(new EdmEntitySetInfoImpl(entityContainer.getName(), set.getName()));
-              }
-            }
-          }
-        }
-      } catch (ODataException e) {
-        throw new EdmException(e);
-      }
-    }
-    return entitySetInfos;
-  }
-
-  @Override
-  public List<EdmSingletonInfo> getSingletonInfos() {
-    if (singletonInfos == null) {
-      try {
-        singletonInfos = new ArrayList<EdmSingletonInfo>();
-        if (schemas == null) {
-          schemas = provider.getSchemas();
-          if (schemas == null) {
-            throw new EdmException("Provider doe not define any schemas.");
-          }
-        }
-        for (Schema schema : schemas) {
-          final EntityContainer entityContainer = schema.getEntityContainer();
-          if (entityContainer != null) {
-            final List<Singleton> singletons = entityContainer.getSingletons();
-            if (singletons != null) {
-              for (Singleton singleton : singletons) {
-                singletonInfos.add(new EdmSingletonInfoImpl(entityContainer.getName(), singleton.getName()));
-              }
-            }
-          }
-        }
-      } catch (ODataException e) {
-        throw new EdmException(e);
-      }
-    }
-    return singletonInfos;
-  }
-
-  @Override
-  public List<EdmActionImportInfo> getActionImportInfos() {
-    if (actionImportInfos == null) {
-      try {
-        actionImportInfos = new ArrayList<EdmActionImportInfo>();
-        if (schemas == null) {
-          schemas = provider.getSchemas();
-          if (schemas == null) {
-            throw new EdmException("Provider doe not define any schemas.");
-          }
-        }
-        for (Schema schema : schemas) {
-          final EntityContainer entityContainer = schema.getEntityContainer();
-          if (entityContainer != null) {
-            final List<ActionImport> actionImports = entityContainer.getActionImports();
-            if (actionImports != null) {
-              for (ActionImport actionImport : actionImports) {
-                actionImportInfos.add(new EdmActionImportInfoImpl(entityContainer.getName(), actionImport.getName()));
-              }
-            }
-          }
-        }
-      } catch (ODataException e) {
-        throw new EdmException(e);
-      }
-    }
-    return actionImportInfos;
-  }
-
-  @Override
-  public List<EdmFunctionImportInfo> getFunctionImportInfos() {
-    if (functionImportInfos == null) {
-      try {
-        functionImportInfos = new ArrayList<EdmFunctionImportInfo>();
-        if (schemas == null) {
-          schemas = provider.getSchemas();
-          if (schemas == null) {
-            throw new EdmException("Provider doe not define any schemas.");
-          }
-        }
-        for (Schema schema : schemas) {
-          final EntityContainer entityContainer = schema.getEntityContainer();
-          if (entityContainer != null) {
-            final List<FunctionImport> functionImports = entityContainer.getFunctionImports();
-            if (functionImports != null) {
-              for (FunctionImport functionImport : functionImports) {
-                functionImportInfos.add(
-                    new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
-              }
-            }
-          }
-        }
-      } catch (ODataException e) {
-        throw new EdmException(e);
-      }
-    }
-    return functionImportInfos;
-  }
-
-  @Override
-  public ODataServiceVersion getDataServiceVersion() {
-    return ODataServiceVersion.V40;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java
index bf3bb4a..baf8093 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java
@@ -29,7 +29,6 @@ import org.apache.olingo.commons.api.edm.EdmEnumType;
 import org.apache.olingo.commons.api.edm.EdmException;
 import org.apache.olingo.commons.api.edm.EdmFunction;
 import org.apache.olingo.commons.api.edm.EdmSchema;
-import org.apache.olingo.commons.api.edm.EdmMetadata;
 import org.apache.olingo.commons.api.edm.EdmTerm;
 import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
@@ -210,11 +209,6 @@ public class EdmProviderImpl extends AbstractEdm {
   }
 
   @Override
-  public EdmMetadata createServiceMetadata() {
-    return new EdmMetadataImpl(provider);
-  }
-
-  @Override
   protected Map<String, String> createAliasToNamespaceInfo() {
     final Map<String, String> aliasToNamespaceInfos = new HashMap<String, String>();
     try {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMetadataImplTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMetadataImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMetadataImplTest.java
deleted file mode 100644
index 7090f5b..0000000
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMetadataImplTest.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.edm.provider;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.EdmEntitySetInfo;
-import org.apache.olingo.commons.api.edm.EdmException;
-import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmMetadata;
-import org.apache.olingo.commons.api.edm.EdmSingletonInfo;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.server.api.edm.provider.EdmProvider;
-import org.apache.olingo.server.api.edm.provider.EntityContainer;
-import org.apache.olingo.server.api.edm.provider.EntitySet;
-import org.apache.olingo.server.api.edm.provider.FunctionImport;
-import org.apache.olingo.server.api.edm.provider.Schema;
-import org.apache.olingo.server.api.edm.provider.Singleton;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-public class EdmMetadataImplTest {
-
-  @Test
-  public void allGettersMustDeliver() {
-    EdmMetadata serviceMetadata = new EdmMetadataImpl(new CustomProvider(true));
-    List<EdmEntitySetInfo> entitySetInfos = serviceMetadata.getEntitySetInfos();
-    assertNotNull(entitySetInfos);
-    assertEquals(2, entitySetInfos.size());
-
-    List<EdmSingletonInfo> singletonInfos = serviceMetadata.getSingletonInfos();
-    assertNotNull(singletonInfos);
-    assertEquals(2, singletonInfos.size());
-
-    List<EdmFunctionImportInfo> functionImportInfos = serviceMetadata.getFunctionImportInfos();
-    assertNotNull(functionImportInfos);
-    assertEquals(2, functionImportInfos.size());
-
-    // Cache test
-    assertTrue(entitySetInfos == serviceMetadata.getEntitySetInfos());
-    assertTrue(singletonInfos == serviceMetadata.getSingletonInfos());
-    assertTrue(functionImportInfos == serviceMetadata.getFunctionImportInfos());
-  }
-
-  @Test
-  public void initialProvider() {
-    EdmProvider provider = new EdmProvider() {};
-    EdmMetadata serviceMetadata = new EdmMetadataImpl(provider);
-    assertEquals(ODataServiceVersion.V40, serviceMetadata.getDataServiceVersion());
-  }
-
-  @Test(expected = EdmException.class)
-  public void initialProviderEntitySetInfo() {
-    EdmProvider provider = new EdmProvider() {};
-    EdmMetadata serviceMetadata = new EdmMetadataImpl(provider);
-    serviceMetadata.getEntitySetInfos();
-  }
-
-  @Test(expected = EdmException.class)
-  public void initialProviderSingletonInfo() {
-    EdmProvider provider = new EdmProvider() {};
-    EdmMetadata serviceMetadata = new EdmMetadataImpl(provider);
-    serviceMetadata.getSingletonInfos();
-  }
-
-  @Test(expected = EdmException.class)
-  public void initialProviderFunctionImportInfo() {
-    EdmProvider provider = new EdmProvider() {};
-    EdmMetadata serviceMetadata = new EdmMetadataImpl(provider);
-    serviceMetadata.getFunctionImportInfos();
-  }
-
-  @Test
-  public void emptySchemaMustNotResultInException() {
-    EdmMetadata serviceMetadata = new EdmMetadataImpl(new CustomProvider(false));
-    assertNotNull(serviceMetadata.getEntitySetInfos());
-    assertEquals(0, serviceMetadata.getEntitySetInfos().size());
-
-    assertNotNull(serviceMetadata.getSingletonInfos());
-    assertEquals(0, serviceMetadata.getSingletonInfos().size());
-
-    assertNotNull(serviceMetadata.getFunctionImportInfos());
-    assertEquals(0, serviceMetadata.getFunctionImportInfos().size());
-  }
-
-  @Test
-  public void oDataExceptionsGetCaughtAndTransformed() {
-    EdmProvider provider = new EdmProvider() {
-      @Override
-      public List<Schema> getSchemas() throws ODataException {
-        throw new ODataException("msg");
-      }
-    };
-
-    EdmMetadata serviceMetadata = new EdmMetadataImpl(provider);
-    callGetEntitySetInfosAndExpectException(serviceMetadata);
-    callGetSingletonInfosAndExpectException(serviceMetadata);
-    callGetFunctionImportInfosAndExpectException(serviceMetadata);
-  }
-
-  private void callGetFunctionImportInfosAndExpectException(final EdmMetadata svc) {
-    try {
-      svc.getFunctionImportInfos();
-    } catch (EdmException e) {
-      assertEquals("org.apache.olingo.commons.api.ODataException: msg", e.getMessage());
-      return;
-    }
-    fail("Expected EdmException was not thrown");
-
-  }
-
-  private void callGetSingletonInfosAndExpectException(final EdmMetadata svc) {
-    try {
-      svc.getSingletonInfos();
-    } catch (EdmException e) {
-      assertEquals("org.apache.olingo.commons.api.ODataException: msg", e.getMessage());
-      return;
-    }
-    fail("Expected EdmException was not thrown");
-  }
-
-  private void callGetEntitySetInfosAndExpectException(final EdmMetadata svc) {
-    try {
-      svc.getEntitySetInfos();
-    } catch (EdmException e) {
-      assertEquals("org.apache.olingo.commons.api.ODataException: msg", e.getMessage());
-      return;
-    }
-    fail("Expected EdmException was not thrown");
-  }
-
-  private class CustomProvider extends EdmProvider {
-    private List<Schema> schemas;
-
-    public CustomProvider(final boolean fillSchema) {
-      schemas = new ArrayList<Schema>();
-      if (fillSchema) {
-        List<EntitySet> entitySets = new ArrayList<EntitySet>();
-        entitySets.add(new EntitySet().setName("1"));
-        entitySets.add(new EntitySet().setName("2"));
-        List<Singleton> singletons = new ArrayList<Singleton>();
-        singletons.add(new Singleton().setName("1"));
-        singletons.add(new Singleton().setName("2"));
-        List<FunctionImport> functionImports = new ArrayList<FunctionImport>();
-        functionImports.add(new FunctionImport().setName("1"));
-        functionImports.add(new FunctionImport().setName("2"));
-        EntityContainer entityContainer =
-            new EntityContainer().setName("cont").setEntitySets(entitySets).setSingletons(singletons)
-                .setFunctionImports(functionImports);
-        Schema schema = new Schema().setEntityContainer(entityContainer);
-        schemas.add(schema);
-      }
-    }
-
-    @Override
-    public List<Schema> getSchemas() throws ODataException {
-      return schemas;
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/87f0f06a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmProviderImplTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmProviderImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmProviderImplTest.java
index d25d4c4..c8a4e38 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmProviderImplTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmProviderImplTest.java
@@ -98,7 +98,6 @@ public class EdmProviderImplTest {
     localEdm.getEntityType(FQN);
     localEdm.getEnumType(FQN);
     localEdm.getTypeDefinition(FQN);
-    localEdm.getServiceMetadata();
   }
 
   @Test
@@ -222,10 +221,4 @@ public class EdmProviderImplTest {
 
     assertNull(edm.getComplexType(WRONG_FQN));
   }
-
-  @Test
-  public void getServiceMetadata() {
-    assertNotNull(edm.getServiceMetadata());
-  }
-
 }


[4/6] git commit: [OLINGO-423] Added implementation

Posted by mi...@apache.org.
[OLINGO-423] Added implementation


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/e3121831
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/e3121831
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/e3121831

Branch: refs/heads/master
Commit: e3121831b426e192890855a2db8671a525a76571
Parents: 87f0f06
Author: Michael Bolz <mi...@sap.com>
Authored: Mon Oct 13 14:59:00 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Mon Oct 13 14:59:00 2014 +0200

----------------------------------------------------------------------
 .../xml/MetadataDocumentXmlSerializer.java      |  47 ++++++--
 .../serializer/xml/MetadataDocumentTest.java    | 111 ++++++++++++++++++-
 2 files changed, 144 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e3121831/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java
index ec3dd5f..a9cf2f8 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java
@@ -21,6 +21,8 @@ package org.apache.olingo.server.core.serializer.xml;
 import org.apache.olingo.commons.api.edm.*;
 import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.edmx.EdmxReferenceInclude;
+import org.apache.olingo.server.api.edmx.EdmxReferenceIncludeAnnotation;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 
 import javax.xml.stream.XMLStreamException;
@@ -70,6 +72,13 @@ public class MetadataDocumentXmlSerializer {
   private static final String XML_ALIAS = "Alias";
   private static final String XML_NAMESPACE = "Namespace";
   private static final String XML_TYPE_DEFINITION = "TypeDefinition";
+  private static final String REFERENCE = "Reference";
+  private static final String INCLUDE = "Include";
+  private static final String INCLUDE_ANNOTATIONS = "IncludeAnnotations";
+  private static final String XML_TERM_NAMESPACE = "TermNamespace";
+  private static final String XML_TARGET_NAMESPACE = "TargetNamespace";
+  private static final String XML_QUALIFIER = "Qualifier";
+  private static final String URI = "Uri";
 
   private final ServiceMetadata serviceMetadata;
 
@@ -463,7 +472,7 @@ public class MetadataDocumentXmlSerializer {
       writer.writeStartElement(XML_KEY);
       for (EdmKeyPropertyRef keyRef : keyPropertyRefs) {
         writer.writeEmptyElement(XML_PROPERTY_REF);
-        String keyName = null;
+        final String keyName;
         if (keyRef.getPath() != null) {
           keyName = keyRef.getPath() + "/" + keyRef.getKeyPropertyName();
         } else {
@@ -511,15 +520,33 @@ public class MetadataDocumentXmlSerializer {
   private void appendReference(final XMLStreamWriter writer) throws XMLStreamException {
     List<EdmxReference> references = serviceMetadata.getReferences();
     for (EdmxReference reference: references) {
-      writer.writeStartElement(NS_EDMX, "Reference");
-      // TODO: Which value can we use here?
-      // <http://docs.oasis-open.org/odata/odata/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml>
-      // is an external site we don't want to query each time an EDM-enabled client is used.
-      writer.writeAttribute("Uri", reference.getUri().toASCIIString());
-  //    writer.writeEmptyElement(NS_EDMX, "Include");
-  //    writer.writeAttribute(XML_NAMESPACE, reference.getIncludeNamespace());
-  //    writer.writeAttribute(XML_ALIAS, reference.getIncludeAlias());
-  //    writer.writeEndElement();
+      writer.writeStartElement(PREFIX_EDMX, REFERENCE, NS_EDMX);
+      writer.writeAttribute(URI, reference.getUri().toASCIIString());
+
+      List<EdmxReferenceInclude> includes = reference.getIncludes();
+      for (EdmxReferenceInclude include : includes) {
+        writer.writeStartElement(PREFIX_EDMX, INCLUDE, NS_EDMX);
+        writer.writeAttribute(XML_NAMESPACE, include.getNamespace());
+        if(include.getAlias() != null) {
+          writer.writeAttribute(XML_ALIAS, include.getAlias());
+        }
+        writer.writeEndElement();
+      }
+
+      List<EdmxReferenceIncludeAnnotation> includeAnnotations = reference.getIncludeAnnotations();
+      for (EdmxReferenceIncludeAnnotation includeAnnotation : includeAnnotations) {
+        writer.writeStartElement(PREFIX_EDMX, INCLUDE_ANNOTATIONS, NS_EDMX);
+        writer.writeAttribute(XML_TERM_NAMESPACE, includeAnnotation.getTermNamespace());
+        if(includeAnnotation.getQualifier() != null) {
+          writer.writeAttribute(XML_QUALIFIER, includeAnnotation.getQualifier());
+        }
+        if(includeAnnotation.getTargetNamespace() != null) {
+          writer.writeAttribute(XML_TARGET_NAMESPACE, includeAnnotation.getTargetNamespace());
+        }
+        writer.writeEndElement();
+      }
+
+      writer.writeEndElement();
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e3121831/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
index 8fbbf15..85ac1e8 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.io.InputStream;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -59,11 +60,12 @@ import org.apache.olingo.server.api.edm.provider.Schema;
 import org.apache.olingo.server.api.edm.provider.Singleton;
 import org.apache.olingo.server.api.edm.provider.TypeDefinition;
 import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.apache.olingo.server.api.edmx.EdmxReferenceInclude;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
-import org.apache.olingo.server.api.serializer.SerializerException;
 import org.apache.olingo.server.core.ServiceMetadataImpl;
-import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
-import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
+import org.apache.olingo.server.core.edmx.EdmxReferenceImpl;
+import org.apache.olingo.server.core.edmx.EdmxReferenceIncludeAnnotationImpl;
+import org.apache.olingo.server.core.edmx.EdmxReferenceIncludeImpl;
 import org.junit.Test;
 
 public class MetadataDocumentTest {
@@ -78,14 +80,96 @@ public class MetadataDocumentTest {
   }
 
   @Test
+  public void writeEdmxWithLocalTestEdm() throws Exception {
+    ODataSerializer serializer = OData.newInstance().createSerializer(ODataFormat.XML);
+
+    List<EdmxReference> edmxReferences = new ArrayList<EdmxReference>();
+    EdmxReferenceImpl reference = new EdmxReferenceImpl(URI.create("http://example.com"));
+    edmxReferences.add(reference);
+
+    EdmxReferenceImpl referenceWithInclude = new EdmxReferenceImpl(
+            URI.create("http://localhost/odata/odata/v4.0/referenceWithInclude"));
+    EdmxReferenceInclude include = new EdmxReferenceIncludeImpl("Org.OData.Core.V1", "Core");
+    referenceWithInclude.addInclude(include);
+    edmxReferences.add(referenceWithInclude);
+
+    EdmxReferenceImpl referenceWithTwoIncludes = new EdmxReferenceImpl(
+            URI.create("http://localhost/odata/odata/v4.0/referenceWithTwoIncludes"));
+    referenceWithTwoIncludes.addInclude(new EdmxReferenceIncludeImpl("Org.OData.Core.2", "Core2"));
+    referenceWithTwoIncludes.addInclude(new EdmxReferenceIncludeImpl("Org.OData.Core.3", "Core3"));
+    edmxReferences.add(referenceWithTwoIncludes);
+
+    EdmxReferenceImpl referenceWithIncludeAnnos = new EdmxReferenceImpl(
+            URI.create("http://localhost/odata/odata/v4.0/referenceWithIncludeAnnos"));
+    referenceWithIncludeAnnos.addIncludeAnnotation(
+            new EdmxReferenceIncludeAnnotationImpl("TermNs.2", "Q.2", "TargetNS.2"));
+    referenceWithIncludeAnnos.addIncludeAnnotation(
+            new EdmxReferenceIncludeAnnotationImpl("TermNs.3", "Q.3","TargetNS.3"));
+    edmxReferences.add(referenceWithIncludeAnnos);
+
+    EdmxReferenceImpl referenceWithAll = new EdmxReferenceImpl(
+            URI.create("http://localhost/odata/odata/v4.0/referenceWithAll"));
+    referenceWithAll.addInclude(new EdmxReferenceIncludeImpl("ReferenceWithAll.1", "Core1"));
+    referenceWithAll.addInclude(new EdmxReferenceIncludeImpl("ReferenceWithAll.2", "Core2"));
+    referenceWithAll.addIncludeAnnotation(
+            new EdmxReferenceIncludeAnnotationImpl("ReferenceWithAllTermNs.4", "Q.4", "TargetNS.4"));
+    referenceWithAll.addIncludeAnnotation(
+            new EdmxReferenceIncludeAnnotationImpl("ReferenceWithAllTermNs.5", "Q.5", "TargetNS.5"));
+    edmxReferences.add(referenceWithAll);
+
+    ServiceMetadata serviceMetadata = new ServiceMetadataImpl(ODataServiceVersion.V40,
+            new TestMetadataProvider(), edmxReferences);
+    InputStream metadata = serializer.metadataDocument(serviceMetadata);
+    assertNotNull(metadata);
+
+    String metadataString = IOUtils.toString(metadata);
+    // edmx reference
+    assertTrue(metadataString.contains(
+            "<edmx:Reference Uri=\"http://example.com\"/>"));
+    assertTrue(metadataString.contains(
+            "<edmx:Reference " +
+                    "Uri=\"http://localhost/odata/odata/v4.0/referenceWithInclude\">" +
+            "<edmx:Include Namespace=\"Org.OData.Core.V1\" Alias=\"Core\"/>" +
+            "</edmx:Reference>"));
+    assertTrue(metadataString.contains(
+            "<edmx:Reference " +
+                    "Uri=\"http://localhost/odata/odata/v4.0/referenceWithTwoIncludes\">" +
+            "<edmx:Include Namespace=\"Org.OData.Core.2\" Alias=\"Core2\"/>" +
+            "<edmx:Include Namespace=\"Org.OData.Core.3\" Alias=\"Core3\"/>" +
+            "</edmx:Reference>"));
+    assertTrue(metadataString.contains(
+            "<edmx:Reference Uri=\"http://localhost/odata/odata/v4.0/referenceWithIncludeAnnos\">" +
+            "<edmx:IncludeAnnotations TermNamespace=\"TermNs.2\" Qualifier=\"Q.2\" TargetNamespace=\"TargetNS.2\"/>" +
+            "<edmx:IncludeAnnotations TermNamespace=\"TermNs.3\" Qualifier=\"Q.3\" TargetNamespace=\"TargetNS.3\"/>" +
+            "</edmx:Reference>"));
+    assertTrue(metadataString.contains(
+            "<edmx:Reference Uri=\"http://localhost/odata/odata/v4.0/referenceWithAll\">" +
+            "<edmx:Include Namespace=\"ReferenceWithAll.1\" Alias=\"Core1\"/>" +
+            "<edmx:Include Namespace=\"ReferenceWithAll.2\" Alias=\"Core2\"/>" +
+            "<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermNs.4\" " +
+                    "Qualifier=\"Q.4\" TargetNamespace=\"TargetNS.4\"/>" +
+            "<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermNs.5\" " +
+                    "Qualifier=\"Q.5\" TargetNamespace=\"TargetNS.5\"/>" +
+            "</edmx:Reference>"));
+  }
+
+  @Test
   public void writeMetadataWithLocalTestEdm() throws Exception {
     ODataSerializer serializer = OData.newInstance().createSerializer(ODataFormat.XML);
+    List<EdmxReference> edmxReferences = getEdmxReferences();
     ServiceMetadata serviceMetadata = new ServiceMetadataImpl(ODataServiceVersion.V40,
-            new TestMetadataProvider(), Collections.<EdmxReference>emptyList());
+            new TestMetadataProvider(), edmxReferences);
     InputStream metadata = serializer.metadataDocument(serviceMetadata);
     assertNotNull(metadata);
 
     String metadataString = IOUtils.toString(metadata);
+    // edmx reference
+    assertTrue(metadataString
+            .contains("<edmx:Reference " +
+                    "Uri=\"http://docs.oasis-open.org/odata/odata/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml\">" +
+                    "<edmx:Include Namespace=\"Org.OData.Core.V1\" Alias=\"Core\"/>" +
+                    "</edmx:Reference>"));
+
     assertTrue(metadataString
         .contains("<edmx:Edmx Version=\"4.0\" xmlns:edmx=\"http://docs.oasis-open.org/odata/ns/edmx\">"));
 
@@ -147,6 +231,25 @@ public class MetadataDocumentTest {
     assertTrue(metadataString.contains("</EntityContainer></Schema></edmx:DataServices></edmx:Edmx>"));
   }
 
+  /**
+   * <code>
+   *  <edmx:Reference Uri="http://docs.oasis-open.org/odata/odata/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml">
+   *    <edmx:Include Namespace="Org.OData.Core.V1" Alias="Core"/>
+   *  </edmx:Reference>
+   * </code>
+   *
+   * @return default emdx reference
+   */
+  private List<EdmxReference> getEdmxReferences() {
+    List<EdmxReference> edmxReferences = new ArrayList<EdmxReference>();
+    EdmxReferenceImpl reference = new EdmxReferenceImpl(
+            URI.create("http://docs.oasis-open.org/odata/odata/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml"));
+    EdmxReferenceInclude include = new EdmxReferenceIncludeImpl("Org.OData.Core.V1", "Core");
+    reference.addInclude(include);
+    edmxReferences.add(reference);
+    return edmxReferences;
+  }
+
   @Test
   public void writeMetadataWithTechnicalScenario() throws Exception {
     ODataSerializer serializer = OData.newInstance().createSerializer(ODataFormat.XML);


[6/6] git commit: [OLINGO-423] Added BasicITCase for metadata

Posted by mi...@apache.org.
[OLINGO-423] Added BasicITCase for metadata


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/b006070b
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/b006070b
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/b006070b

Branch: refs/heads/master
Commit: b006070bea5a6cd2813dc7bd0480864a7bbc82ee
Parents: fd033d7
Author: mibo <mi...@apache.org>
Authored: Tue Oct 14 08:28:34 2014 +0200
Committer: mibo <mi...@apache.org>
Committed: Tue Oct 14 08:30:55 2014 +0200

----------------------------------------------------------------------
 .../olingo/fit/AbstractBaseTestITCase.java      |  10 ++
 .../olingo/fit/tecsvc/client/BasicITCase.java   |  25 +++-
 fit/src/test/resources/metadata-ref.xml         | 123 +++++++++++++++++++
 3 files changed, 155 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b006070b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
index 3b219b0..a300518 100644
--- a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
@@ -58,6 +58,7 @@ public abstract class AbstractBaseTestITCase {
     TomcatTestServer.init(9080)
         .addServlet(TechnicalServlet.class, "/odata-server-tecsvc/odata.svc/*")
         .addServlet(StaticContent.class, "/odata-server-tecsvc/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml")
+        .addServlet(MetadataContent.class, "/odata-metadata/$metadata")
         .addWebApp()
         .start();
   }
@@ -135,4 +136,13 @@ public abstract class AbstractBaseTestITCase {
           Thread.currentThread().getContextClassLoader().getResourceAsStream("org-odata-core-v1.xml")));
     }
   }
+
+  public static class MetadataContent extends HttpServlet {
+    private static final long serialVersionUID = -6663569573355398997L;
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+      resp.getOutputStream().write(IOUtils.toByteArray(
+          Thread.currentThread().getContextClassLoader().getResourceAsStream("metadata-ref.xml")));
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b006070b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
index 7a645ef..47737b7 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.io.IOException;
@@ -38,7 +39,9 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRe
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
 import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.edm.xml.XMLMetadata;
 import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.core.ODataClientFactory;
 import org.apache.olingo.commons.api.domain.ODataError;
@@ -79,7 +82,6 @@ public class BasicITCase extends AbstractBaseTestITCase {
   }
 
   @Test
-  @Ignore("Ignored till refactoring is finished")
   public void readMetadata() {
     EdmMetadataRequest request = getClient().getRetrieveRequestFactory().getMetadataRequest(SERVICE_URI);
     assertNotNull(request);
@@ -92,8 +94,25 @@ public class BasicITCase extends AbstractBaseTestITCase {
     assertNotNull(edm);
     assertEquals("olingo.odata.test1", edm.getSchema("olingo.odata.test1").getNamespace());
     assertEquals("Namespace1_Alias", edm.getSchema("olingo.odata.test1").getAlias());
-    assertNotNull(edm.getTerm(new FullQualifiedName("Core.Description")));
-    assertEquals(2, edm.getSchemas().size());
+    assertEquals(1, edm.getSchemas().size());
+  }
+
+  @Test
+  public void readViaXmlMetadata() {
+    XMLMetadataRequest request = getClient().getRetrieveRequestFactory()
+        .getXMLMetadataRequest(SERVICE_URI.replace("odata-server-tecsvc/odata.svc", "odata-metadata"));
+    assertNotNull(request);
+
+    ODataRetrieveResponse<XMLMetadata> response = request.execute();
+    assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode());
+
+    XMLMetadata xmlMetadata = response.getBody();
+
+    assertNotNull(xmlMetadata);
+    assertTrue(xmlMetadata instanceof org.apache.olingo.client.api.edm.xml.v4.XMLMetadata);
+    assertEquals("ODataDemo", xmlMetadata.getSchema("ODataDemo").getNamespace());
+    assertEquals(1, ((org.apache.olingo.client.api.edm.xml.v4.XMLMetadata) xmlMetadata).getReferences().size());
+    assertEquals(2, xmlMetadata.getSchemas().size());
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/b006070b/fit/src/test/resources/metadata-ref.xml
----------------------------------------------------------------------
diff --git a/fit/src/test/resources/metadata-ref.xml b/fit/src/test/resources/metadata-ref.xml
new file mode 100644
index 0000000..b2f2eb0
--- /dev/null
+++ b/fit/src/test/resources/metadata-ref.xml
@@ -0,0 +1,123 @@
+<?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.
+
+-->
+<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
+  <edmx:Reference Uri="http://docs.oasis-open.org/odata/odata/v4.0/cs01/vocabularies/Org.OData.Core.V1.xml">
+    <edmx:Include Namespace="Org.OData.Core.V1" Alias="Core"/>
+  </edmx:Reference>
+  <edmx:DataServices>
+    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="ODataDemo">
+      <TypeDefinition Name="Length" UnderlyingType="Edm.Int32">
+        <Annotation Term="Org.OData.Measures.V1.Unit" String="Centimeters"/>
+      </TypeDefinition>
+      <TypeDefinition Name="Weight" UnderlyingType="Edm.Int32">
+        <Annotation Term="Org.OData.Measures.V1.Unit" String="Kilograms"/>
+      </TypeDefinition>
+      <ComplexType Name="Size">
+        <Property Name="Height" Type="Self.Length" />
+        <Property Name="Weight" Type="Self.Weight" />
+      </ComplexType>
+      <EntityType Name="Product" HasStream="true">
+        <Key>
+          <PropertyRef Name="ID"/>
+        </Key>
+        <Property Name="ID" Type="Edm.Int32" Nullable="false"/>
+        <Property Name="Description" Type="Edm.String">
+          <Annotation Term="Core.IsLanguageDependent"/>
+        </Property>
+        <Property Name="ReleaseDate" Type="Edm.Date"/>
+        <Property Name="DiscontinuedDate" Type="Edm.Date"/>
+        <Property Name="Rating" Type="Edm.Int32"/>
+        <Property Name="Price" Type="Edm.Decimal">
+          <Annotation Term="UoM.ISOCurrency" Path="Currency"/>
+        </Property>
+        <Property Name="Currency" Type="Edm.String" MaxLength="3"/>
+        <NavigationProperty Name="Category" Type="ODataDemo.Category" Nullable="false" Partner="Products"/>
+        <NavigationProperty Name="Supplier" Type="ODataDemo.Supplier" Partner="Products"/>
+      </EntityType>
+      <EntityType Name="Category">
+        <Key>
+          <PropertyRef Name="ID"/>
+        </Key>
+        <Property Name="ID" Type="Edm.Int32" Nullable="false"/>
+        <Property Name="Name" Type="Edm.String">
+          <Annotation Term="Core.IsLanguageDependent"/>
+        </Property>
+        <NavigationProperty Name="Products" Partner="Category" Type="Collection(ODataDemo.Product)">
+          <OnDelete Action="Cascade"/>
+        </NavigationProperty>
+      </EntityType>
+      <EntityType Name="Supplier">
+        <Key>
+          <PropertyRef Name="ID"/>
+        </Key>
+        <Property Name="ID" Type="Edm.String" Nullable="false"/>
+        <Property Name="Name" Type="Edm.String"/>
+        <Property Name="Address" Type="ODataDemo.Address" Nullable="false"/>
+        <Property Name="Concurrency" Type="Edm.Int32" Nullable="false"/>
+        <NavigationProperty Name="Products" Partner="Supplier"/>                                                                                                                                                    Type="Collection(ODataDemo.Product)"/>
+      </EntityType>
+      <EntityType Name="Country">
+        <Key>
+          <PropertyRef Name="Code"/>
+        </Key>
+        <Property Name="Code" Type="Edm.String" MaxLength="2" Nullable="false"/>
+        <Property Name="Name" Type="Edm.String"/>
+      </EntityType>
+      <ComplexType Name="Address">
+        <Property Name="Street" Type="Edm.String"/>
+        <Property Name="City" Type="Edm.String"/>
+        <Property Name="State" Type="Edm.String"/>
+        <Property Name="ZipCode" Type="Edm.String"/>
+        <Property Name="CountryName" Type="Edm.String"/>
+        <NavigationProperty Name="Country" Type="ODataDemo.Country">
+          <ReferentialConstraint Property="CountryName" ReferencedProperty="Name"/>
+        </NavigationProperty>
+      </ComplexType>
+      <Function Name="ProductsByRating">
+        <Parameter Name="Rating" Type="Edm.Int32"/>
+        <ReturnType Type="Collection(ODataDemo.Product)"/>
+      </Function>
+      <EntityContainer Name="DemoService">
+        <EntitySet Name="Products" EntityType="ODataDemo.Product">
+          <NavigationPropertyBinding Path="Category" Target="Categories"/>
+        </EntitySet>
+        <EntitySet Name="Categories" EntityType="ODataDemo.Category">
+          <NavigationPropertyBinding Path="Products" Target="Products"/>
+        </EntitySet>
+        <EntitySet Name="Suppliers" EntityType="ODataDemo.Supplier">
+          <NavigationPropertyBinding Path="Products" Target="Products"/>
+          <NavigationPropertyBinding Path="Address/Country" Target="Countries"/>
+          <Annotation Term="Core.OptimisticConcurrencyControl">
+            <Collection>
+              <PropertyPath>Concurrency</PropertyPath>
+            </Collection>
+          </Annotation>
+        </EntitySet>
+        <Singleton Name="Contoso" Type="Self.Supplier">
+          <NavigationPropertyBinding Path="Products" Target="Products"/>
+        </Singleton>
+        <EntitySet Name="Countries" EntityType="ODataDemo.Country"/>
+        <FunctionImport Name="ProductsByRating" EntitySet="Products" Function="ODataDemo.ProductsByRating"/>
+      </EntityContainer>
+    </Schema>
+  </edmx:DataServices>
+</edmx:Edmx>


[5/6] git commit: [OLINGO-423] Added convenience and tests

Posted by mi...@apache.org.
[OLINGO-423] Added convenience and tests


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/fd033d7d
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/fd033d7d
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/fd033d7d

Branch: refs/heads/master
Commit: fd033d7deccc833a2df2cb42530079bd2a7deea5
Parents: e312183
Author: Michael Bolz <mi...@sap.com>
Authored: Mon Oct 13 15:23:22 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Mon Oct 13 15:23:22 2014 +0200

----------------------------------------------------------------------
 .../EdmxReferenceIncludeAnnotationImpl.java     |  4 +++
 .../core/edmx/EdmxReferenceIncludeImpl.java     |  4 +++
 .../serializer/xml/MetadataDocumentTest.java    | 35 +++++++++++++++++---
 3 files changed, 38 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fd033d7d/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeAnnotationImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeAnnotationImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeAnnotationImpl.java
index 1a4d7b4..575c115 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeAnnotationImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeAnnotationImpl.java
@@ -34,6 +34,10 @@ public class EdmxReferenceIncludeAnnotationImpl implements EdmxReferenceIncludeA
     this.targetNamespace = targetNamespace;
   }
 
+  public EdmxReferenceIncludeAnnotationImpl(String termNamespace) {
+    this(termNamespace, null, null);
+  }
+
   @Override
   public String getTermNamespace() {
     return termNamespace;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fd033d7d/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeImpl.java
index 0da95df..0a4ecd3 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edmx/EdmxReferenceIncludeImpl.java
@@ -31,6 +31,10 @@ public class EdmxReferenceIncludeImpl implements EdmxReferenceInclude {
     this.alias = alias;
   }
 
+  public EdmxReferenceIncludeImpl(String namespace) {
+    this(namespace, null);
+  }
+
   @Override
   public String getNamespace() {
     return namespace;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fd033d7d/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
index 85ac1e8..2856cc4 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentTest.java
@@ -117,11 +117,26 @@ public class MetadataDocumentTest {
             new EdmxReferenceIncludeAnnotationImpl("ReferenceWithAllTermNs.5", "Q.5", "TargetNS.5"));
     edmxReferences.add(referenceWithAll);
 
+    EdmxReferenceImpl referenceWithAllAndNull = new EdmxReferenceImpl(
+            URI.create("http://localhost/odata/odata/v4.0/referenceWithAllAndNull"));
+    referenceWithAllAndNull.addInclude(new EdmxReferenceIncludeImpl("referenceWithAllAndNull.1"));
+    referenceWithAllAndNull.addInclude(new EdmxReferenceIncludeImpl("referenceWithAllAndNull.2", null));
+    referenceWithAllAndNull.addIncludeAnnotation(
+            new EdmxReferenceIncludeAnnotationImpl("ReferenceWithAllTermNs.4"));
+    referenceWithAllAndNull.addIncludeAnnotation(
+            new EdmxReferenceIncludeAnnotationImpl("ReferenceWithAllTermAndNullNs.5", "Q.5", null));
+    referenceWithAllAndNull.addIncludeAnnotation(
+            new EdmxReferenceIncludeAnnotationImpl("ReferenceWithAllTermAndNullNs.6", null, "TargetNS"));
+    referenceWithAllAndNull.addIncludeAnnotation(
+            new EdmxReferenceIncludeAnnotationImpl("ReferenceWithAllTermAndNullNs.7", null, null));
+    edmxReferences.add(referenceWithAllAndNull);
+
     ServiceMetadata serviceMetadata = new ServiceMetadataImpl(ODataServiceVersion.V40,
             new TestMetadataProvider(), edmxReferences);
     InputStream metadata = serializer.metadataDocument(serviceMetadata);
     assertNotNull(metadata);
 
+
     String metadataString = IOUtils.toString(metadata);
     // edmx reference
     assertTrue(metadataString.contains(
@@ -144,13 +159,23 @@ public class MetadataDocumentTest {
             "</edmx:Reference>"));
     assertTrue(metadataString.contains(
             "<edmx:Reference Uri=\"http://localhost/odata/odata/v4.0/referenceWithAll\">" +
-            "<edmx:Include Namespace=\"ReferenceWithAll.1\" Alias=\"Core1\"/>" +
-            "<edmx:Include Namespace=\"ReferenceWithAll.2\" Alias=\"Core2\"/>" +
-            "<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermNs.4\" " +
+                    "<edmx:Include Namespace=\"ReferenceWithAll.1\" Alias=\"Core1\"/>" +
+                    "<edmx:Include Namespace=\"ReferenceWithAll.2\" Alias=\"Core2\"/>" +
+                    "<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermNs.4\" " +
                     "Qualifier=\"Q.4\" TargetNamespace=\"TargetNS.4\"/>" +
-            "<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermNs.5\" " +
+                    "<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermNs.5\" " +
                     "Qualifier=\"Q.5\" TargetNamespace=\"TargetNS.5\"/>" +
-            "</edmx:Reference>"));
+                    "</edmx:Reference>"));
+    assertTrue(metadataString.contains(
+            "<edmx:Reference Uri=\"http://localhost/odata/odata/v4.0/referenceWithAllAndNull\">" +
+                    "<edmx:Include Namespace=\"referenceWithAllAndNull.1\"/>" +
+                    "<edmx:Include Namespace=\"referenceWithAllAndNull.2\"/>" +
+                    "<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermNs.4\"/>" +
+                    "<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermAndNullNs.5\" Qualifier=\"Q.5\"/>" +
+                    "<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermAndNullNs.6\" " +
+                                              "TargetNamespace=\"TargetNS\"/>" +
+                    "<edmx:IncludeAnnotations TermNamespace=\"ReferenceWithAllTermAndNullNs.7\"/>" +
+                    "</edmx:Reference>"));
   }
 
   @Test


[2/6] git commit: [OLINGO-423] Refactoring for EdmxReferenceHandling

Posted by mi...@apache.org.
[OLINGO-423] Refactoring for EdmxReferenceHandling


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/188574f5
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/188574f5
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/188574f5

Branch: refs/heads/master
Commit: 188574f5c372bb95caca4a78d7cc10855947e5e1
Parents: cf032b6
Author: Michael Bolz <mi...@sap.com>
Authored: Sat Oct 11 08:58:40 2014 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Sat Oct 11 09:50:15 2014 +0200

----------------------------------------------------------------------
 .../olingo/fit/tecsvc/client/BasicITCase.java   |   2 +
 .../core/edm/AbstractEdmMetadataImpl.java       |  92 +++++++++
 .../edm/AbstractEdmServiceMetadataImpl.java     |  96 ----------
 .../olingo/client/core/edm/EdmClientImpl.java   |   8 +-
 .../client/core/edm/v3/EdmMetadataImpl.java     |  97 ++++++++++
 .../core/edm/v3/EdmServiceMetadataImpl.java     |  97 ----------
 .../client/core/edm/v4/EdmMetadataImpl.java     | 103 ++++++++++
 .../core/edm/v4/EdmServiceMetadataImpl.java     | 103 ----------
 .../org/apache/olingo/commons/api/edm/Edm.java  |   6 +-
 .../olingo/commons/api/edm/EdmMetadata.java     |  57 ++++++
 .../commons/api/edm/EdmServiceMetadata.java     |  61 ------
 .../olingo/commons/core/edm/AbstractEdm.java    |   8 +-
 .../commons/core/edm/EdmImplCachingTest.java    |  10 +-
 .../commons/core/edm/EdmImplCallCreateTest.java |   6 +-
 .../org/apache/olingo/server/api/OData.java     |  21 +-
 .../olingo/server/api/ServiceMetadata.java      |  48 +++++
 .../olingo/server/api/edmx/EdmxReference.java   |  46 +++++
 .../server/api/edmx/EdmxReferenceInclude.java   |  34 ++++
 .../edmx/EdmxReferenceIncludeAnnotation.java    |  39 ++++
 .../server/api/processor/DefaultProcessor.java  |  37 ++--
 .../olingo/server/api/processor/Processor.java  |   4 +-
 .../server/api/serializer/ODataSerializer.java  |   5 +-
 .../server/core/DefaultRedirectProcessor.java   |   4 +-
 .../apache/olingo/server/core/ODataHandler.java |  19 +-
 .../server/core/ODataHttpHandlerImpl.java       |  11 +-
 .../apache/olingo/server/core/ODataImpl.java    |  14 +-
 .../olingo/server/core/ServiceMetadataImpl.java |  60 ++++++
 .../core/edm/provider/EdmMetadataImpl.java      | 173 +++++++++++++++++
 .../core/edm/provider/EdmProviderImpl.java      |   6 +-
 .../edm/provider/EdmServiceMetadataImpl.java    | 190 -------------------
 .../server/core/edmx/EdmxReferenceImpl.java     |  65 +++++++
 .../EdmxReferenceIncludeAnnotationImpl.java     |  51 +++++
 .../core/edmx/EdmxReferenceIncludeImpl.java     |  43 +++++
 .../core/serializer/ODataXmlSerializerImpl.java |   5 +-
 .../serializer/json/ODataJsonSerializer.java    |   3 +-
 .../xml/MetadataDocumentXmlSerializer.java      |  58 ++----
 .../server/core/ContentNegotiatorTest.java      |   3 +-
 .../core/edm/provider/EdmMetadataImplTest.java  | 182 ++++++++++++++++++
 .../provider/EdmServiceMetadataImplTest.java    | 188 ------------------
 .../olingo/server/tecsvc/TechnicalServlet.java  |  11 +-
 .../tecsvc/processor/TechnicalProcessor.java    |   7 +-
 .../server/tecsvc/provider/EdmTechProvider.java |   8 +
 .../server/tecsvc/data/DataProviderTest.java    |   7 +-
 .../core/ODataHandlerExceptionHandlingTest.java |  19 +-
 .../olingo/server/core/ODataHandlerTest.java    |   9 +-
 .../json/ODataJsonSerializerTest.java           |   5 +-
 .../serializer/utils/ContextURLHelperTest.java  |   5 +-
 .../serializer/xml/MetadataDocumentTest.java    |  26 +--
 48 files changed, 1254 insertions(+), 898 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
index 46a6b96..7a645ef 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/BasicITCase.java
@@ -54,6 +54,7 @@ import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.fit.AbstractBaseTestITCase;
 import org.apache.olingo.fit.tecsvc.TecSvcConst;
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class BasicITCase extends AbstractBaseTestITCase {
@@ -78,6 +79,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
   }
 
   @Test
+  @Ignore("Ignored till refactoring is finished")
   public void readMetadata() {
     EdmMetadataRequest request = getClient().getRetrieveRequestFactory().getMetadataRequest(SERVICE_URI);
     assertNotNull(request);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmMetadataImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmMetadataImpl.java
new file mode 100644
index 0000000..88c95fa
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmMetadataImpl.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.edm;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.apache.olingo.client.api.edm.xml.EntityContainer;
+import org.apache.olingo.client.api.edm.xml.EntitySet;
+import org.apache.olingo.client.api.edm.xml.Schema;
+import org.apache.olingo.client.core.edm.v3.EdmMetadataImpl;
+import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
+import org.apache.olingo.commons.api.edm.EdmEntitySetInfo;
+import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
+import org.apache.olingo.commons.api.edm.EdmMetadata;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.edm.EdmEntitySetInfoImpl;
+
+public abstract class AbstractEdmMetadataImpl implements EdmMetadata {
+
+  protected final List<? extends Schema> xmlSchemas;
+
+  private List<EdmEntitySetInfo> entitySetInfos;
+
+  protected List<EdmFunctionImportInfo> functionImportInfos;
+
+  protected List<EdmActionImportInfo> actionImportInfos;
+
+  public static EdmMetadata getInstance(final ODataServiceVersion version, final List<Schema> xmlSchemas) {
+
+    return version.compareTo(ODataServiceVersion.V40) < 0
+            ? new EdmMetadataImpl(xmlSchemas)
+            : new org.apache.olingo.client.core.edm.v4.EdmMetadataImpl(xmlSchemas);
+  }
+
+  public AbstractEdmMetadataImpl(final List<? extends Schema> xmlSchemas) {
+    this.xmlSchemas = xmlSchemas;
+  }
+
+  @Override
+  public List<EdmEntitySetInfo> getEntitySetInfos() {
+    synchronized (this) {
+      if (entitySetInfos == null) {
+        entitySetInfos = new ArrayList<EdmEntitySetInfo>();
+        for (Schema schema : xmlSchemas) {
+          for (EntityContainer entityContainer : schema.getEntityContainers()) {
+            for (EntitySet entitySet : entityContainer.getEntitySets()) {
+              entitySetInfos.add(new EdmEntitySetInfoImpl(entityContainer.getName(), entitySet.getName()));
+            }
+          }
+        }
+      }
+      return entitySetInfos;
+    }
+  }
+
+  @Override
+  public boolean equals(final Object obj) {
+    return EqualsBuilder.reflectionEquals(this, obj);
+  }
+
+  @Override
+  public int hashCode() {
+    return HashCodeBuilder.reflectionHashCode(this);
+  }
+
+  @Override
+  public String toString() {
+    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmServiceMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmServiceMetadataImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmServiceMetadataImpl.java
deleted file mode 100644
index d598d78..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmServiceMetadataImpl.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.core.edm;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import org.apache.olingo.client.api.edm.xml.EntityContainer;
-import org.apache.olingo.client.api.edm.xml.EntitySet;
-import org.apache.olingo.client.api.edm.xml.Schema;
-import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmEntitySetInfo;
-import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.edm.EdmEntitySetInfoImpl;
-
-public abstract class AbstractEdmServiceMetadataImpl implements EdmServiceMetadata {
-
-  protected final List<? extends Schema> xmlSchemas;
-
-  private List<EdmEntitySetInfo> entitySetInfos;
-
-  protected List<EdmFunctionImportInfo> functionImportInfos;
-
-  protected List<EdmActionImportInfo> actionImportInfos;
-
-  public static EdmServiceMetadata getInstance(final ODataServiceVersion version, final List<Schema> xmlSchemas) {
-
-    return version.compareTo(ODataServiceVersion.V40) < 0
-            ? new org.apache.olingo.client.core.edm.v3.EdmServiceMetadataImpl(xmlSchemas)
-            : new org.apache.olingo.client.core.edm.v4.EdmServiceMetadataImpl(xmlSchemas);
-  }
-
-  public AbstractEdmServiceMetadataImpl(final List<? extends Schema> xmlSchemas) {
-    this.xmlSchemas = xmlSchemas;
-  }
-
-  @Override
-  public InputStream getMetadata() {
-    throw new UnsupportedOperationException("Not supported in client code.");
-  }
-
-  @Override
-  public List<EdmEntitySetInfo> getEntitySetInfos() {
-    synchronized (this) {
-      if (entitySetInfos == null) {
-        entitySetInfos = new ArrayList<EdmEntitySetInfo>();
-        for (Schema schema : xmlSchemas) {
-          for (EntityContainer entityContainer : schema.getEntityContainers()) {
-            for (EntitySet entitySet : entityContainer.getEntitySets()) {
-              entitySetInfos.add(new EdmEntitySetInfoImpl(entityContainer.getName(), entitySet.getName()));
-            }
-          }
-        }
-      }
-      return entitySetInfos;
-    }
-  }
-
-  @Override
-  public boolean equals(final Object obj) {
-    return EqualsBuilder.reflectionEquals(this, obj);
-  }
-
-  @Override
-  public int hashCode() {
-    return HashCodeBuilder.reflectionHashCode(this);
-  }
-
-  @Override
-  public String toString() {
-    return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
index 752cc0d..d2084b6 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java
@@ -58,7 +58,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmEnumType;
 import org.apache.olingo.commons.api.edm.EdmFunction;
 import org.apache.olingo.commons.api.edm.EdmSchema;
-import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
+import org.apache.olingo.commons.api.edm.EdmMetadata;
 import org.apache.olingo.commons.api.edm.EdmTerm;
 import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
@@ -74,7 +74,7 @@ public class EdmClientImpl extends AbstractEdm {
 
   private final Map<String, Schema> xmlSchemaByNamespace;
 
-  private final EdmServiceMetadata serviceMetadata;
+  private final EdmMetadata serviceMetadata;
 
   public EdmClientImpl(final ODataServiceVersion version, final Map<String, Schema> xmlSchemas) {
     this.version = version;
@@ -88,11 +88,11 @@ public class EdmClientImpl extends AbstractEdm {
       }
     }
 
-    this.serviceMetadata = AbstractEdmServiceMetadataImpl.getInstance(version, this.xmlSchemas);
+    this.serviceMetadata = AbstractEdmMetadataImpl.getInstance(version, this.xmlSchemas);
   }
 
   @Override
-  protected EdmServiceMetadata createServiceMetadata() {
+  protected EdmMetadata createServiceMetadata() {
     return serviceMetadata;
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmMetadataImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmMetadataImpl.java
new file mode 100644
index 0000000..b6ace40
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmMetadataImpl.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.edm.v3;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.client.api.edm.xml.CommonFunctionImport;
+import org.apache.olingo.client.api.edm.xml.EntityContainer;
+import org.apache.olingo.client.api.edm.xml.Schema;
+import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
+import org.apache.olingo.client.api.v3.UnsupportedInV3Exception;
+import org.apache.olingo.client.core.edm.AbstractEdmMetadataImpl;
+import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
+import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
+import org.apache.olingo.commons.api.edm.EdmSingletonInfo;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.edm.EdmActionImportInfoImpl;
+import org.apache.olingo.commons.core.edm.EdmFunctionImportInfoImpl;
+
+public class EdmMetadataImpl extends AbstractEdmMetadataImpl {
+
+  private static final ODataServiceVersion SERVICE_VERSION = ODataServiceVersion.V30;
+
+  public EdmMetadataImpl(final List<? extends Schema> xmlSchemas) {
+    super(xmlSchemas);
+  }
+
+  @Override
+  public ODataServiceVersion getDataServiceVersion() {
+    return SERVICE_VERSION;
+  }
+
+  @Override
+  public List<EdmSingletonInfo> getSingletonInfos() {
+    throw new UnsupportedInV3Exception();
+  }
+
+  @Override
+  public List<EdmFunctionImportInfo> getFunctionImportInfos() {
+    synchronized (this) {
+      if (functionImportInfos == null) {
+        functionImportInfos = new ArrayList<EdmFunctionImportInfo>();
+        for (Schema schema : xmlSchemas) {
+          for (EntityContainer entityContainer : schema.getEntityContainers()) {
+            for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
+              final FunctionImport _funFunctionImport = (FunctionImport) functionImport;
+              if (FunctionImportUtils.canProxyFunction(_funFunctionImport)) {
+                functionImportInfos.add(
+                        new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
+              }
+            }
+          }
+        }
+      }
+      return functionImportInfos;
+    }
+  }
+
+  @Override
+  public List<EdmActionImportInfo> getActionImportInfos() {
+    synchronized (this) {
+      if (actionImportInfos == null) {
+        actionImportInfos = new ArrayList<EdmActionImportInfo>();
+        for (Schema schema : xmlSchemas) {
+          for (EntityContainer entityContainer : schema.getEntityContainers()) {
+            for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
+              final FunctionImport _funFunctionImport = (FunctionImport) functionImport;
+              if (!FunctionImportUtils.canProxyFunction(_funFunctionImport)) {
+                actionImportInfos.add(
+                        new EdmActionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
+              }
+            }
+          }
+        }
+      }
+      return actionImportInfos;
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmServiceMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmServiceMetadataImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmServiceMetadataImpl.java
deleted file mode 100644
index 451f094..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmServiceMetadataImpl.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.core.edm.v3;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.client.api.edm.xml.CommonFunctionImport;
-import org.apache.olingo.client.api.edm.xml.EntityContainer;
-import org.apache.olingo.client.api.edm.xml.Schema;
-import org.apache.olingo.client.api.edm.xml.v3.FunctionImport;
-import org.apache.olingo.client.api.v3.UnsupportedInV3Exception;
-import org.apache.olingo.client.core.edm.AbstractEdmServiceMetadataImpl;
-import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmSingletonInfo;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.edm.EdmActionImportInfoImpl;
-import org.apache.olingo.commons.core.edm.EdmFunctionImportInfoImpl;
-
-public class EdmServiceMetadataImpl extends AbstractEdmServiceMetadataImpl {
-
-  private static final ODataServiceVersion SERVICE_VERSION = ODataServiceVersion.V30;
-
-  public EdmServiceMetadataImpl(final List<? extends Schema> xmlSchemas) {
-    super(xmlSchemas);
-  }
-
-  @Override
-  public ODataServiceVersion getDataServiceVersion() {
-    return SERVICE_VERSION;
-  }
-
-  @Override
-  public List<EdmSingletonInfo> getSingletonInfos() {
-    throw new UnsupportedInV3Exception();
-  }
-
-  @Override
-  public List<EdmFunctionImportInfo> getFunctionImportInfos() {
-    synchronized (this) {
-      if (functionImportInfos == null) {
-        functionImportInfos = new ArrayList<EdmFunctionImportInfo>();
-        for (Schema schema : xmlSchemas) {
-          for (EntityContainer entityContainer : schema.getEntityContainers()) {
-            for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
-              final FunctionImport _funFunctionImport = (FunctionImport) functionImport;
-              if (FunctionImportUtils.canProxyFunction(_funFunctionImport)) {
-                functionImportInfos.add(
-                        new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
-              }
-            }
-          }
-        }
-      }
-      return functionImportInfos;
-    }
-  }
-
-  @Override
-  public List<EdmActionImportInfo> getActionImportInfos() {
-    synchronized (this) {
-      if (actionImportInfos == null) {
-        actionImportInfos = new ArrayList<EdmActionImportInfo>();
-        for (Schema schema : xmlSchemas) {
-          for (EntityContainer entityContainer : schema.getEntityContainers()) {
-            for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
-              final FunctionImport _funFunctionImport = (FunctionImport) functionImport;
-              if (!FunctionImportUtils.canProxyFunction(_funFunctionImport)) {
-                actionImportInfos.add(
-                        new EdmActionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
-              }
-            }
-          }
-        }
-      }
-      return actionImportInfos;
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/EdmMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/EdmMetadataImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/EdmMetadataImpl.java
new file mode 100644
index 0000000..c9a0e75
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/EdmMetadataImpl.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.edm.v4;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.olingo.client.api.edm.xml.CommonFunctionImport;
+import org.apache.olingo.client.api.edm.xml.Schema;
+import org.apache.olingo.client.api.edm.xml.v4.ActionImport;
+import org.apache.olingo.client.api.edm.xml.v4.EntityContainer;
+import org.apache.olingo.client.api.edm.xml.v4.Singleton;
+import org.apache.olingo.client.core.edm.AbstractEdmMetadataImpl;
+import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
+import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
+import org.apache.olingo.commons.api.edm.EdmSingletonInfo;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.edm.EdmActionImportInfoImpl;
+import org.apache.olingo.commons.core.edm.EdmFunctionImportInfoImpl;
+import org.apache.olingo.commons.core.edm.EdmSingletonInfoImpl;
+
+public class EdmMetadataImpl extends AbstractEdmMetadataImpl {
+
+  private static final ODataServiceVersion SERVICE_VERSION = ODataServiceVersion.V40;
+
+  private List<EdmSingletonInfo> singletonInfos;
+
+  public EdmMetadataImpl(final List<Schema> xmlSchemas) {
+    super(xmlSchemas);
+  }
+
+  @Override
+  public ODataServiceVersion getDataServiceVersion() {
+    return SERVICE_VERSION;
+  }
+
+  @Override
+  public List<EdmSingletonInfo> getSingletonInfos() {
+    synchronized (this) {
+      if (singletonInfos == null) {
+        singletonInfos = new ArrayList<EdmSingletonInfo>();
+        for (Schema schema : xmlSchemas) {
+          final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
+          for (Singleton singleton : entityContainer.getSingletons()) {
+            singletonInfos.add(new EdmSingletonInfoImpl(entityContainer.getName(), singleton.getName()));
+          }
+        }
+      }
+      return singletonInfos;
+    }
+  }
+
+  @Override
+  public List<EdmFunctionImportInfo> getFunctionImportInfos() {
+    synchronized (this) {
+      if (functionImportInfos == null) {
+        functionImportInfos = new ArrayList<EdmFunctionImportInfo>();
+        for (Schema schema : xmlSchemas) {
+          final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
+
+          for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
+            functionImportInfos.add(
+                    new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
+          }
+        }
+      }
+    }
+
+    return functionImportInfos;
+  }
+
+  @Override
+  public List<EdmActionImportInfo> getActionImportInfos() {
+    synchronized (this) {
+      if (actionImportInfos == null) {
+        actionImportInfos = new ArrayList<EdmActionImportInfo>();
+        for (Schema schema : xmlSchemas) {
+          final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
+          for (ActionImport actionImport : entityContainer.getActionImports()) {
+            actionImportInfos.add(new EdmActionImportInfoImpl(entityContainer.getName(), actionImport.getName()));
+          }
+        }
+      }
+      return actionImportInfos;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/EdmServiceMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/EdmServiceMetadataImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/EdmServiceMetadataImpl.java
deleted file mode 100644
index 798716c..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/EdmServiceMetadataImpl.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.core.edm.v4;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.olingo.client.api.edm.xml.CommonFunctionImport;
-import org.apache.olingo.client.api.edm.xml.Schema;
-import org.apache.olingo.client.api.edm.xml.v4.ActionImport;
-import org.apache.olingo.client.api.edm.xml.v4.EntityContainer;
-import org.apache.olingo.client.api.edm.xml.v4.Singleton;
-import org.apache.olingo.client.core.edm.AbstractEdmServiceMetadataImpl;
-import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmSingletonInfo;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.edm.EdmActionImportInfoImpl;
-import org.apache.olingo.commons.core.edm.EdmFunctionImportInfoImpl;
-import org.apache.olingo.commons.core.edm.EdmSingletonInfoImpl;
-
-public class EdmServiceMetadataImpl extends AbstractEdmServiceMetadataImpl {
-
-  private static final ODataServiceVersion SERVICE_VERSION = ODataServiceVersion.V40;
-
-  private List<EdmSingletonInfo> singletonInfos;
-
-  public EdmServiceMetadataImpl(final List<Schema> xmlSchemas) {
-    super(xmlSchemas);
-  }
-
-  @Override
-  public ODataServiceVersion getDataServiceVersion() {
-    return SERVICE_VERSION;
-  }
-
-  @Override
-  public List<EdmSingletonInfo> getSingletonInfos() {
-    synchronized (this) {
-      if (singletonInfos == null) {
-        singletonInfos = new ArrayList<EdmSingletonInfo>();
-        for (Schema schema : xmlSchemas) {
-          final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
-          for (Singleton singleton : entityContainer.getSingletons()) {
-            singletonInfos.add(new EdmSingletonInfoImpl(entityContainer.getName(), singleton.getName()));
-          }
-        }
-      }
-      return singletonInfos;
-    }
-  }
-
-  @Override
-  public List<EdmFunctionImportInfo> getFunctionImportInfos() {
-    synchronized (this) {
-      if (functionImportInfos == null) {
-        functionImportInfos = new ArrayList<EdmFunctionImportInfo>();
-        for (Schema schema : xmlSchemas) {
-          final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
-
-          for (CommonFunctionImport functionImport : entityContainer.getFunctionImports()) {
-            functionImportInfos.add(
-                    new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
-          }
-        }
-      }
-    }
-
-    return functionImportInfos;
-  }
-
-  @Override
-  public List<EdmActionImportInfo> getActionImportInfos() {
-    synchronized (this) {
-      if (actionImportInfos == null) {
-        actionImportInfos = new ArrayList<EdmActionImportInfo>();
-        for (Schema schema : xmlSchemas) {
-          final EntityContainer entityContainer = (EntityContainer) schema.getDefaultEntityContainer();
-          for (ActionImport actionImport : entityContainer.getActionImports()) {
-            actionImportInfos.add(new EdmActionImportInfoImpl(entityContainer.getName(), actionImport.getName()));
-          }
-        }
-      }
-      return actionImportInfos;
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java
index 794a811..eb609cd 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java
@@ -176,9 +176,9 @@ public interface Edm {
   /**
    * Get service metadata.
    * <br/>
-   * See {@link EdmServiceMetadata} for more information.
+   * See {@link EdmMetadata} for more information.
    * 
-   * @return {@link EdmServiceMetadata}
+   * @return {@link EdmMetadata}
    */
-  EdmServiceMetadata getServiceMetadata();
+  EdmMetadata getServiceMetadata();
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmMetadata.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmMetadata.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmMetadata.java
new file mode 100644
index 0000000..04b16ab
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmMetadata.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.api.edm;
+
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+import java.util.List;
+
+/**
+ * This interface gives an info list of all
+ * entity sets, singletons, and function imports inside the EntityDataModel.
+ */
+@Deprecated
+public interface EdmMetadata {
+
+  /**
+   * @return a list of {@link EdmEntitySetInfo} objects inside the data model
+   */
+  List<EdmEntitySetInfo> getEntitySetInfos();
+
+  /**
+   * @return a list of {@link EdmSingletonInfo} objects inside the data model
+   */
+  List<EdmSingletonInfo> getSingletonInfos();
+
+  /**
+   * @return a list of {@link EdmActionImportInfo} objects inside the data model
+   */
+  List<EdmActionImportInfo> getActionImportInfos();
+
+  /**
+   * @return a list of {@link EdmFunctionImportInfo} objects inside the data model
+   */
+  List<EdmFunctionImportInfo> getFunctionImportInfos();
+
+  /**
+   *
+   * @return
+   */
+  ODataServiceVersion getDataServiceVersion();
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmServiceMetadata.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmServiceMetadata.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmServiceMetadata.java
deleted file mode 100644
index 3279b5f..0000000
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmServiceMetadata.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.api.edm;
-
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-
-import java.io.InputStream;
-import java.util.List;
-
-/**
- * This interface gives access to the metadata of a service, the calculated Data Service Version and an info list of all
- * entity sets, singletons, and function imports inside this EntityDataModel.
- */
-public interface EdmServiceMetadata {
-
-  /**
-   * @return {@link InputStream} containing the metadata document
-   */
-  InputStream getMetadata();
-
-  /**
-   * @return <b>String</b> data service version of this service
-   */
-  ODataServiceVersion getDataServiceVersion();
-
-  /**
-   * @return a list of {@link EdmEntitySetInfo} objects inside the data model
-   */
-  List<EdmEntitySetInfo> getEntitySetInfos();
-
-  /**
-   * @return a list of {@link EdmSingletonInfo} objects inside the data model
-   */
-  List<EdmSingletonInfo> getSingletonInfos();
-
-  /**
-   * @return a list of {@link EdmActionImportInfo} objects inside the data model
-   */
-  List<EdmActionImportInfo> getActionImportInfos();
-
-  /**
-   * @return a list of {@link EdmFunctionImportInfo} objects inside the data model
-   */
-  List<EdmFunctionImportInfo> getFunctionImportInfos();
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
index 8427cf3..2646038 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java
@@ -28,7 +28,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmEnumType;
 import org.apache.olingo.commons.api.edm.EdmFunction;
 import org.apache.olingo.commons.api.edm.EdmSchema;
-import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
+import org.apache.olingo.commons.api.edm.EdmMetadata;
 import org.apache.olingo.commons.api.edm.EdmTerm;
 import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
@@ -76,7 +76,7 @@ public abstract class AbstractEdm implements Edm {
   private final Map<FullQualifiedName, List<EdmAnnotation>> annotations =
       new HashMap<FullQualifiedName, List<EdmAnnotation>>();
 
-  private EdmServiceMetadata serviceMetadata;
+  private EdmMetadata serviceMetadata;
 
   private Map<String, String> aliasToNamespaceInfo;
 
@@ -403,7 +403,7 @@ public abstract class AbstractEdm implements Edm {
   }
 
   @Override
-  public EdmServiceMetadata getServiceMetadata() {
+  public EdmMetadata getServiceMetadata() {
     if (serviceMetadata == null) {
       serviceMetadata = createServiceMetadata();
     }
@@ -455,7 +455,7 @@ public abstract class AbstractEdm implements Edm {
       FullQualifiedName bindingParameterTypeName, Boolean isBindingParameterCollection,
       List<String> parameterNames);
 
-  protected abstract EdmServiceMetadata createServiceMetadata();
+  protected abstract EdmMetadata createServiceMetadata();
 
   protected abstract EdmTerm createTerm(FullQualifiedName termName);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java
index 416f99d..e12229a 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java
@@ -29,7 +29,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmEnumType;
 import org.apache.olingo.commons.api.edm.EdmFunction;
 import org.apache.olingo.commons.api.edm.EdmSchema;
-import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
+import org.apache.olingo.commons.api.edm.EdmMetadata;
 import org.apache.olingo.commons.api.edm.EdmTerm;
 import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
@@ -251,8 +251,8 @@ public class EdmImplCachingTest {
 
   @Test
   public void cacheServiceMetadata() {
-    EdmServiceMetadata serviceMetadata = edm.getServiceMetadata();
-    EdmServiceMetadata cachedMetadata = edm.getServiceMetadata();
+    EdmMetadata serviceMetadata = edm.getServiceMetadata();
+    EdmMetadata cachedMetadata = edm.getServiceMetadata();
 
     assertTrue(serviceMetadata == cachedMetadata);
     assertEquals(serviceMetadata, cachedMetadata);
@@ -361,8 +361,8 @@ public class EdmImplCachingTest {
     }
 
     @Override
-    public EdmServiceMetadata createServiceMetadata() {
-      return mock(EdmServiceMetadata.class);
+    public EdmMetadata createServiceMetadata() {
+      return mock(EdmMetadata.class);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java
index 24955be..5b8adc9 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java
@@ -28,7 +28,7 @@ import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmEnumType;
 import org.apache.olingo.commons.api.edm.EdmFunction;
 import org.apache.olingo.commons.api.edm.EdmSchema;
-import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
+import org.apache.olingo.commons.api.edm.EdmMetadata;
 import org.apache.olingo.commons.api.edm.EdmTerm;
 import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
@@ -244,8 +244,8 @@ public class EdmImplCallCreateTest {
     }
 
     @Override
-    public EdmServiceMetadata createServiceMetadata() {
-      return mock(EdmServiceMetadata.class);
+    public EdmMetadata createServiceMetadata() {
+      return mock(EdmMetadata.class);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
index 34d79fe..67408d1 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java
@@ -19,12 +19,14 @@
 package org.apache.olingo.server.api;
 
 import org.apache.olingo.commons.api.ODataRuntimeException;
-import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.server.api.edm.provider.EdmProvider;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.serializer.SerializerException;
 
+import java.util.List;
+
 /**
  * Root object for serving factory tasks and support loose coupling of implementation (core) from the API.
  * This is not a singleton (static variables) to avoid issues with synchronization, OSGi, hot deployment and so on.
@@ -54,20 +56,23 @@ public abstract class OData {
   /**
    * Creates a new serializer object for rendering content in the specified format.
    * Serializers are used in Processor implementations.
+   *
    * @param format - any format supported by Olingo (XML, JSON ...)
    */
   public abstract ODataSerializer createSerializer(ODataFormat format) throws SerializerException;
 
   /**
-   * Creates a new ODataHttpHandler for handling OData requests in an HTTP context. 
-   * @param edm - metadata object required to handle an OData request
+   * Creates a new ODataHttpHandler for handling OData requests in an HTTP context.
+   *
+   * @param serviceMetadata - metadata object required to handle an OData request
    */
-  public abstract ODataHttpHandler createHandler(Edm edm);
+  public abstract ODataHttpHandler createHandler(ServiceMetadata serviceMetadata);
 
   /**
-   * Creates a metadata object.
-   * @param edmProvider - a custom or default implementation for creating metadata
+   * Creates a metadata object for this service.
+   *
+   * @param edmProvider a custom or default implementation for creating metadata
+   * @param references list of edmx references
    */
-  public abstract Edm createEdm(EdmProvider edmProvider);
-
+  public abstract ServiceMetadata createServiceMetadata(EdmProvider edmProvider, List<EdmxReference> references);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-api/src/main/java/org/apache/olingo/server/api/ServiceMetadata.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ServiceMetadata.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ServiceMetadata.java
new file mode 100644
index 0000000..f0ece5c
--- /dev/null
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ServiceMetadata.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.api;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+import java.util.List;
+
+/**
+ *
+ */
+public interface ServiceMetadata {
+  /**
+   *
+   * @return entity data model of this service
+   */
+  Edm getEdm();
+
+  /**
+   *
+   * @return data service version of this service
+   */
+  ODataServiceVersion getDataServiceVersion();
+
+  /**
+   *
+   * @return list of defined emdx references of this service
+   */
+  List<EdmxReference> getReferences();
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-api/src/main/java/org/apache/olingo/server/api/edmx/EdmxReference.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/edmx/EdmxReference.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/edmx/EdmxReference.java
new file mode 100644
index 0000000..c14b7e6
--- /dev/null
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/edmx/EdmxReference.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.api.edmx;
+
+import java.net.URI;
+import java.util.List;
+
+/**
+ */
+public interface EdmxReference {
+  /**
+   * Get URI for the Reference
+   * @return
+   */
+  URI getUri();
+
+  /**
+   * edmx:Include elements that specify the schemas to include from the target document
+   *
+   * @return list of {@link EdmxReferenceInclude} in reference or null if none specified
+   */
+  List<EdmxReferenceInclude> getIncludes();
+
+  /**
+   * edmx:IncludeAnnotations elements that specify the annotations to include from the target document.
+   *
+   * @return List of {@link EdmxReferenceIncludeAnnotation} or null if none specified
+   */
+  List<EdmxReferenceIncludeAnnotation> getIncludeAnnotations();
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-api/src/main/java/org/apache/olingo/server/api/edmx/EdmxReferenceInclude.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/edmx/EdmxReferenceInclude.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/edmx/EdmxReferenceInclude.java
new file mode 100644
index 0000000..f75e502
--- /dev/null
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/edmx/EdmxReferenceInclude.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.api.edmx;
+
+/**
+ * edmx:Include elements that specify the schemas to include from the target document.
+ */
+public interface EdmxReferenceInclude {
+	/**
+	 * @return Namespace of the include
+	 */
+	String getNamespace();
+	
+	/**
+	 * @return alias of the include if one defined; null otherwise
+	 */
+	String getAlias();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-api/src/main/java/org/apache/olingo/server/api/edmx/EdmxReferenceIncludeAnnotation.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/edmx/EdmxReferenceIncludeAnnotation.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/edmx/EdmxReferenceIncludeAnnotation.java
new file mode 100644
index 0000000..4067012
--- /dev/null
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/edmx/EdmxReferenceIncludeAnnotation.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.api.edmx;
+
+/**
+ *
+ */
+public interface EdmxReferenceIncludeAnnotation {
+	/**
+	 * @return TermNamespace of the include annotation
+	 */
+	String getTermNamespace();
+	
+	/**
+	 * @return Qualifier if one defined; null otherwise
+	 */
+	String getQualifier();
+	
+	/**
+	 * @return targetNamespace if defined; null otherwise
+	 */
+	String getTargetNamespace();
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
index b674e02..2e41175 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
@@ -27,11 +27,7 @@ import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
-import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.ODataApplicationException;
-import org.apache.olingo.server.api.ODataRequest;
-import org.apache.olingo.server.api.ODataResponse;
-import org.apache.olingo.server.api.ODataServerError;
+import org.apache.olingo.server.api.*;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.serializer.SerializerException;
 import org.apache.olingo.server.api.uri.UriInfo;
@@ -47,38 +43,31 @@ import org.apache.olingo.server.api.uri.UriInfo;
 public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProcessor, ExceptionProcessor {
 
   private OData odata;
-  private Edm edm;
+  private ServiceMetadata serviceMetadata;
 
   @Override
-  public void init(final OData odata, final Edm edm) {
+  public void init(final OData odata, final ServiceMetadata serviceMetadata) {
     this.odata = odata;
-    this.edm = edm;
+    this.serviceMetadata = serviceMetadata;
   }
 
   @Override
   public void readServiceDocument(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
       final ContentType requestedContentType) throws ODataApplicationException, SerializerException {
-    try {
-      ODataSerializer serializer = odata.createSerializer(ODataFormat.fromContentType(requestedContentType));
-      response.setContent(serializer.serviceDocument(edm, request.getRawBaseUri()));
-      response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-      response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
-    } catch (final SerializerException e) {
-      response.setStatusCode(HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode());
-    }
+    ODataSerializer serializer = odata.createSerializer(ODataFormat.fromContentType(requestedContentType));
+    response.setContent(serializer.serviceDocument(serviceMetadata.getEdm(), request.getRawBaseUri()));
+    response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+    response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
   }
 
   @Override
   public void readMetadata(final ODataRequest request, final ODataResponse response, final UriInfo uriInfo,
       final ContentType requestedContentType) throws ODataApplicationException, SerializerException {
-    try {
-      ODataSerializer serializer = odata.createSerializer(ODataFormat.fromContentType(requestedContentType));
-      response.setContent(serializer.metadataDocument(edm));
-      response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-      response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
-    } catch (final SerializerException e) {
-      response.setStatusCode(HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode());
-    }
+    ODataSerializer serializer = odata.createSerializer(ODataFormat.fromContentType(requestedContentType));
+//      response.setContent(serializer.metadataDocument(serviceMetadata.getEdmMetadata()));
+    response.setContent(serializer.metadataDocument(serviceMetadata));
+    response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+    response.setHeader(HttpHeader.CONTENT_TYPE, requestedContentType.toContentTypeString());
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/Processor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/Processor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/Processor.java
index 1d7e1fb..bec28b4 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/Processor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/Processor.java
@@ -18,8 +18,8 @@
  */
 package org.apache.olingo.server.api.processor;
 
-import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ServiceMetadata;
 
 /**
  * <p>Base interface for all processor types.</p>
@@ -33,5 +33,5 @@ public interface Processor {
    * @param odata - Olingo's root object, acting as a factory for various object types
    * @param edm - the EDM which needs to be created before the OData request handling takes place
    */
-  void init(OData odata, Edm edm);
+  void init(OData odata, ServiceMetadata edm);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
index ba01f2f..1331247 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/ODataSerializer.java
@@ -27,6 +27,7 @@ import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmProperty;
 import org.apache.olingo.server.api.ODataServerError;
+import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.uri.queryoption.ExpandOption;
 import org.apache.olingo.server.api.uri.queryoption.SelectOption;
 
@@ -45,9 +46,9 @@ public interface ODataSerializer {
 
   /**
    * Writes the metadata document into an InputStream.
-   * @param edm the Entity Data Model
+   * @param serviceMetadata the metadata information for the service
    */
-  InputStream metadataDocument(Edm edm) throws SerializerException;
+  InputStream metadataDocument(ServiceMetadata serviceMetadata) throws SerializerException;
 
   /**
    * Writes entity data into an InputStream.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/main/java/org/apache/olingo/server/core/DefaultRedirectProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/DefaultRedirectProcessor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/DefaultRedirectProcessor.java
index 97cd511..1dc3e9c 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/DefaultRedirectProcessor.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/DefaultRedirectProcessor.java
@@ -18,17 +18,17 @@
  */
 package org.apache.olingo.server.core;
 
-import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ServiceMetadata;
 
 public class DefaultRedirectProcessor implements RedirectProcessor {
 
   @Override
-  public void init(final OData odata, final Edm edm) {}
+  public void init(final OData odata, final ServiceMetadata edm) {}
 
   @Override
   public void redirect(final ODataRequest request, final ODataResponse response) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
index 12e84ed..ac15d40 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
@@ -27,12 +27,7 @@ import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.ODataApplicationException;
-import org.apache.olingo.server.api.ODataRequest;
-import org.apache.olingo.server.api.ODataResponse;
-import org.apache.olingo.server.api.ODataServerError;
-import org.apache.olingo.server.api.ODataTranslatedException;
+import org.apache.olingo.server.api.*;
 import org.apache.olingo.server.api.processor.DefaultProcessor;
 import org.apache.olingo.server.api.processor.EntitySetProcessor;
 import org.apache.olingo.server.api.processor.EntityProcessor;
@@ -56,14 +51,14 @@ import org.apache.olingo.server.core.uri.validator.UriValidator;
 public class ODataHandler {
 
   private final OData odata;
-  private final Edm edm;
+  private final ServiceMetadata serviceMetadata;
   private final Map<Class<? extends Processor>, Processor> processors =
       new HashMap<Class<? extends Processor>, Processor>();
   private ContentType requestedContentType;
 
-  public ODataHandler(final OData server, final Edm edm) {
+  public ODataHandler(final OData server, final ServiceMetadata serviceMetadata) {
     odata = server;
-    this.edm = edm;
+    this.serviceMetadata = serviceMetadata;
 
     register(new DefaultProcessor());
     register(new DefaultRedirectProcessor());
@@ -112,7 +107,9 @@ public class ODataHandler {
     validateODataVersion(request, response);
 
     Parser parser = new Parser();
-    final UriInfo uriInfo = parser.parseUri(request.getRawODataPath(), request.getRawQueryPath(), null, edm);
+    final UriInfo uriInfo = parser.parseUri(
+            request.getRawODataPath(), request.getRawQueryPath(),
+            null, serviceMetadata.getEdm());
 
     UriValidator validator = new UriValidator();
     validator.validate(uriInfo, request.getMethod());
@@ -302,7 +299,7 @@ public class ODataHandler {
   }
 
   public void register(final Processor processor) {
-    processor.init(odata, edm);
+    processor.init(odata, serviceMetadata);
 
     for (Class<?> cls : processor.getClass().getInterfaces()) {
       if (Processor.class.isAssignableFrom(cls) && cls != Processor.class) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
index 3b77bfd..239cb94 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
@@ -33,12 +33,7 @@ import org.apache.olingo.commons.api.ODataRuntimeException;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpMethod;
-import org.apache.olingo.server.api.OData;
-import org.apache.olingo.server.api.ODataHttpHandler;
-import org.apache.olingo.server.api.ODataRequest;
-import org.apache.olingo.server.api.ODataResponse;
-import org.apache.olingo.server.api.ODataServerError;
-import org.apache.olingo.server.api.ODataTranslatedException;
+import org.apache.olingo.server.api.*;
 import org.apache.olingo.server.api.processor.Processor;
 import org.apache.olingo.server.api.serializer.SerializerException;
 import org.slf4j.Logger;
@@ -51,8 +46,8 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
   private ODataHandler handler;
   private int split = 0;
 
-  public ODataHttpHandlerImpl(final OData odata, final Edm edm) {
-    handler = new ODataHandler(odata, edm);
+  public ODataHttpHandlerImpl(final OData odata, final ServiceMetadata serviceMetadata) {
+    handler = new ODataHandler(odata, serviceMetadata);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
index 4c80676..9171839 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataImpl.java
@@ -18,17 +18,20 @@
  */
 package org.apache.olingo.server.core;
 
-import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.server.api.edmx.EdmxReference;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataHttpHandler;
+import org.apache.olingo.server.api.ServiceMetadata;
 import org.apache.olingo.server.api.edm.provider.EdmProvider;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.serializer.SerializerException;
-import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
 import org.apache.olingo.server.core.serializer.ODataXmlSerializerImpl;
 import org.apache.olingo.server.core.serializer.json.ODataJsonSerializer;
 
+import java.util.List;
+
 public class ODataImpl extends OData {
 
   @Override
@@ -52,13 +55,12 @@ public class ODataImpl extends OData {
   }
 
   @Override
-  public ODataHttpHandler createHandler(final Edm edm) {
+  public ODataHttpHandler createHandler(final ServiceMetadata edm) {
     return new ODataHttpHandlerImpl(this, edm);
   }
 
   @Override
-  public Edm createEdm(final EdmProvider edmProvider) {
-    return new EdmProviderImpl(edmProvider);
+  public ServiceMetadata createServiceMetadata(EdmProvider edmProvider, List<EdmxReference> references) {
+    return new ServiceMetadataImpl(ODataServiceVersion.V40, edmProvider, references);
   }
-
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/main/java/org/apache/olingo/server/core/ServiceMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ServiceMetadataImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ServiceMetadataImpl.java
new file mode 100644
index 0000000..5008092
--- /dev/null
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ServiceMetadataImpl.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.edm.provider.EdmProvider;
+import org.apache.olingo.server.core.edm.provider.EdmProviderImpl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ */
+public class ServiceMetadataImpl implements ServiceMetadata {
+
+  private final EdmProviderImpl edm;
+  private final ODataServiceVersion version;
+  private final List<EdmxReference> references = new ArrayList<EdmxReference>();
+
+  public ServiceMetadataImpl(ODataServiceVersion version, EdmProvider edmProvider, List<EdmxReference> references) {
+    this.edm = new EdmProviderImpl(edmProvider);
+    this.version = version;
+    this.references.addAll(references);
+  }
+
+  @Override
+  public Edm getEdm() {
+    return edm;
+  }
+
+  @Override
+  public ODataServiceVersion getDataServiceVersion() {
+    return version;
+  }
+
+  @Override
+  public List<EdmxReference> getReferences() {
+    return Collections.unmodifiableList(references);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmMetadataImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmMetadataImpl.java
new file mode 100644
index 0000000..8306954
--- /dev/null
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmMetadataImpl.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core.edm.provider;
+
+import org.apache.olingo.commons.api.ODataException;
+import org.apache.olingo.commons.api.edm.*;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.edm.EdmActionImportInfoImpl;
+import org.apache.olingo.commons.core.edm.EdmEntitySetInfoImpl;
+import org.apache.olingo.commons.core.edm.EdmFunctionImportInfoImpl;
+import org.apache.olingo.commons.core.edm.EdmSingletonInfoImpl;
+import org.apache.olingo.server.api.edm.provider.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class EdmMetadataImpl implements EdmMetadata {
+
+  private EdmProvider provider;
+
+  private List<Schema> schemas;
+
+  private List<EdmEntitySetInfo> entitySetInfos;
+
+  private List<EdmSingletonInfo> singletonInfos;
+
+  private List<EdmActionImportInfo> actionImportInfos;
+
+  private List<EdmFunctionImportInfo> functionImportInfos;
+
+  public EdmMetadataImpl(final EdmProvider provider) {
+    this.provider = provider;
+  }
+
+  @Override
+  public List<EdmEntitySetInfo> getEntitySetInfos() {
+    if (entitySetInfos == null) {
+      try {
+        entitySetInfos = new ArrayList<EdmEntitySetInfo>();
+        if (schemas == null) {
+          schemas = provider.getSchemas();
+          if (schemas == null) {
+            throw new EdmException("Provider doe not define any schemas.");
+          }
+        }
+        for (Schema schema : schemas) {
+          final EntityContainer entityContainer = schema.getEntityContainer();
+          if (entityContainer != null) {
+            final List<EntitySet> entitySets = entityContainer.getEntitySets();
+            if (entitySets != null) {
+              for (EntitySet set : entitySets) {
+                entitySetInfos.add(new EdmEntitySetInfoImpl(entityContainer.getName(), set.getName()));
+              }
+            }
+          }
+        }
+      } catch (ODataException e) {
+        throw new EdmException(e);
+      }
+    }
+    return entitySetInfos;
+  }
+
+  @Override
+  public List<EdmSingletonInfo> getSingletonInfos() {
+    if (singletonInfos == null) {
+      try {
+        singletonInfos = new ArrayList<EdmSingletonInfo>();
+        if (schemas == null) {
+          schemas = provider.getSchemas();
+          if (schemas == null) {
+            throw new EdmException("Provider doe not define any schemas.");
+          }
+        }
+        for (Schema schema : schemas) {
+          final EntityContainer entityContainer = schema.getEntityContainer();
+          if (entityContainer != null) {
+            final List<Singleton> singletons = entityContainer.getSingletons();
+            if (singletons != null) {
+              for (Singleton singleton : singletons) {
+                singletonInfos.add(new EdmSingletonInfoImpl(entityContainer.getName(), singleton.getName()));
+              }
+            }
+          }
+        }
+      } catch (ODataException e) {
+        throw new EdmException(e);
+      }
+    }
+    return singletonInfos;
+  }
+
+  @Override
+  public List<EdmActionImportInfo> getActionImportInfos() {
+    if (actionImportInfos == null) {
+      try {
+        actionImportInfos = new ArrayList<EdmActionImportInfo>();
+        if (schemas == null) {
+          schemas = provider.getSchemas();
+          if (schemas == null) {
+            throw new EdmException("Provider doe not define any schemas.");
+          }
+        }
+        for (Schema schema : schemas) {
+          final EntityContainer entityContainer = schema.getEntityContainer();
+          if (entityContainer != null) {
+            final List<ActionImport> actionImports = entityContainer.getActionImports();
+            if (actionImports != null) {
+              for (ActionImport actionImport : actionImports) {
+                actionImportInfos.add(new EdmActionImportInfoImpl(entityContainer.getName(), actionImport.getName()));
+              }
+            }
+          }
+        }
+      } catch (ODataException e) {
+        throw new EdmException(e);
+      }
+    }
+    return actionImportInfos;
+  }
+
+  @Override
+  public List<EdmFunctionImportInfo> getFunctionImportInfos() {
+    if (functionImportInfos == null) {
+      try {
+        functionImportInfos = new ArrayList<EdmFunctionImportInfo>();
+        if (schemas == null) {
+          schemas = provider.getSchemas();
+          if (schemas == null) {
+            throw new EdmException("Provider doe not define any schemas.");
+          }
+        }
+        for (Schema schema : schemas) {
+          final EntityContainer entityContainer = schema.getEntityContainer();
+          if (entityContainer != null) {
+            final List<FunctionImport> functionImports = entityContainer.getFunctionImports();
+            if (functionImports != null) {
+              for (FunctionImport functionImport : functionImports) {
+                functionImportInfos.add(
+                    new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
+              }
+            }
+          }
+        }
+      } catch (ODataException e) {
+        throw new EdmException(e);
+      }
+    }
+    return functionImportInfos;
+  }
+
+  @Override
+  public ODataServiceVersion getDataServiceVersion() {
+    return ODataServiceVersion.V40;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java
index 7973c43..bf3bb4a 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java
@@ -29,7 +29,7 @@ import org.apache.olingo.commons.api.edm.EdmEnumType;
 import org.apache.olingo.commons.api.edm.EdmException;
 import org.apache.olingo.commons.api.edm.EdmFunction;
 import org.apache.olingo.commons.api.edm.EdmSchema;
-import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
+import org.apache.olingo.commons.api.edm.EdmMetadata;
 import org.apache.olingo.commons.api.edm.EdmTerm;
 import org.apache.olingo.commons.api.edm.EdmTypeDefinition;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
@@ -210,8 +210,8 @@ public class EdmProviderImpl extends AbstractEdm {
   }
 
   @Override
-  public EdmServiceMetadata createServiceMetadata() {
-    return new EdmServiceMetadataImpl(provider);
+  public EdmMetadata createServiceMetadata() {
+    return new EdmMetadataImpl(provider);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/188574f5/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmServiceMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmServiceMetadataImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmServiceMetadataImpl.java
deleted file mode 100644
index cde3d83..0000000
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmServiceMetadataImpl.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.core.edm.provider;
-
-import org.apache.olingo.commons.api.ODataException;
-import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmEntitySetInfo;
-import org.apache.olingo.commons.api.edm.EdmException;
-import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
-import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
-import org.apache.olingo.commons.api.edm.EdmSingletonInfo;
-import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
-import org.apache.olingo.commons.core.edm.EdmActionImportInfoImpl;
-import org.apache.olingo.commons.core.edm.EdmEntitySetInfoImpl;
-import org.apache.olingo.commons.core.edm.EdmFunctionImportInfoImpl;
-import org.apache.olingo.commons.core.edm.EdmSingletonInfoImpl;
-import org.apache.olingo.server.api.edm.provider.ActionImport;
-import org.apache.olingo.server.api.edm.provider.EdmProvider;
-import org.apache.olingo.server.api.edm.provider.EntityContainer;
-import org.apache.olingo.server.api.edm.provider.EntitySet;
-import org.apache.olingo.server.api.edm.provider.FunctionImport;
-import org.apache.olingo.server.api.edm.provider.Schema;
-import org.apache.olingo.server.api.edm.provider.Singleton;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-public class EdmServiceMetadataImpl implements EdmServiceMetadata {
-
-  private EdmProvider provider;
-
-  private List<Schema> schemas;
-
-  private List<EdmEntitySetInfo> entitySetInfos;
-
-  private List<EdmSingletonInfo> singletonInfos;
-
-  private List<EdmActionImportInfo> actionImportInfos;
-
-  private List<EdmFunctionImportInfo> functionImportInfos;
-
-  public EdmServiceMetadataImpl(final EdmProvider provider) {
-    this.provider = provider;
-  }
-
-  @Override
-  public InputStream getMetadata() {
-    throw new RuntimeException("Not yet implemented");
-  }
-
-  @Override
-  public ODataServiceVersion getDataServiceVersion() {
-    return ODataServiceVersion.V40;
-  }
-
-  @Override
-  public List<EdmEntitySetInfo> getEntitySetInfos() {
-    if (entitySetInfos == null) {
-      try {
-        entitySetInfos = new ArrayList<EdmEntitySetInfo>();
-        if (schemas == null) {
-          schemas = provider.getSchemas();
-          if (schemas == null) {
-            throw new EdmException("Provider doe not define any schemas.");
-          }
-        }
-        for (Schema schema : schemas) {
-          final EntityContainer entityContainer = schema.getEntityContainer();
-          if (entityContainer != null) {
-            final List<EntitySet> entitySets = entityContainer.getEntitySets();
-            if (entitySets != null) {
-              for (EntitySet set : entitySets) {
-                entitySetInfos.add(new EdmEntitySetInfoImpl(entityContainer.getName(), set.getName()));
-              }
-            }
-          }
-        }
-      } catch (ODataException e) {
-        throw new EdmException(e);
-      }
-    }
-    return entitySetInfos;
-  }
-
-  @Override
-  public List<EdmSingletonInfo> getSingletonInfos() {
-    if (singletonInfos == null) {
-      try {
-        singletonInfos = new ArrayList<EdmSingletonInfo>();
-        if (schemas == null) {
-          schemas = provider.getSchemas();
-          if (schemas == null) {
-            throw new EdmException("Provider doe not define any schemas.");
-          }
-        }
-        for (Schema schema : schemas) {
-          final EntityContainer entityContainer = schema.getEntityContainer();
-          if (entityContainer != null) {
-            final List<Singleton> singletons = entityContainer.getSingletons();
-            if (singletons != null) {
-              for (Singleton singleton : singletons) {
-                singletonInfos.add(new EdmSingletonInfoImpl(entityContainer.getName(), singleton.getName()));
-              }
-            }
-          }
-        }
-      } catch (ODataException e) {
-        throw new EdmException(e);
-      }
-    }
-    return singletonInfos;
-  }
-
-  @Override
-  public List<EdmActionImportInfo> getActionImportInfos() {
-    if (actionImportInfos == null) {
-      try {
-        actionImportInfos = new ArrayList<EdmActionImportInfo>();
-        if (schemas == null) {
-          schemas = provider.getSchemas();
-          if (schemas == null) {
-            throw new EdmException("Provider doe not define any schemas.");
-          }
-        }
-        for (Schema schema : schemas) {
-          final EntityContainer entityContainer = schema.getEntityContainer();
-          if (entityContainer != null) {
-            final List<ActionImport> actionImports = entityContainer.getActionImports();
-            if (actionImports != null) {
-              for (ActionImport actionImport : actionImports) {
-                actionImportInfos.add(new EdmActionImportInfoImpl(entityContainer.getName(), actionImport.getName()));
-              }
-            }
-          }
-        }
-      } catch (ODataException e) {
-        throw new EdmException(e);
-      }
-    }
-    return actionImportInfos;
-  }
-
-  @Override
-  public List<EdmFunctionImportInfo> getFunctionImportInfos() {
-    if (functionImportInfos == null) {
-      try {
-        functionImportInfos = new ArrayList<EdmFunctionImportInfo>();
-        if (schemas == null) {
-          schemas = provider.getSchemas();
-          if (schemas == null) {
-            throw new EdmException("Provider doe not define any schemas.");
-          }
-        }
-        for (Schema schema : schemas) {
-          final EntityContainer entityContainer = schema.getEntityContainer();
-          if (entityContainer != null) {
-            final List<FunctionImport> functionImports = entityContainer.getFunctionImports();
-            if (functionImports != null) {
-              for (FunctionImport functionImport : functionImports) {
-                functionImportInfos.add(
-                    new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName()));
-              }
-            }
-          }
-        }
-      } catch (ODataException e) {
-        throw new EdmException(e);
-      }
-    }
-    return functionImportInfos;
-  }
-
-}