You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by sk...@apache.org on 2014/06/02 13:38:07 UTC
[11/12] git commit: [OLINGO-266] make metadata fit work
[OLINGO-266] make metadata fit work
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/85fb12ad
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/85fb12ad
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/85fb12ad
Branch: refs/heads/master
Commit: 85fb12ad83bf1c5b659dfdb175632d928d305215
Parents: 4cb3b32
Author: Stephan Klevenz <st...@sap.com>
Authored: Mon Jun 2 13:13:47 2014 +0200
Committer: Stephan Klevenz <st...@sap.com>
Committed: Mon Jun 2 13:13:58 2014 +0200
----------------------------------------------------------------------
.../server/api/processor/DefaultProcessor.java | 70 ++++++++++
.../olingo/server/core/DefaultProcessor.java | 81 -----------
.../server/core/DefaultRedirectProcessor.java | 41 ++++++
.../apache/olingo/server/core/ODataHandler.java | 4 +-
.../olingo/server/core/RedirectProcessor.java | 4 +-
.../xml/MetadataDocumentXmlSerializer.java | 18 +--
.../server/tecsvc/TechnicalProcessor.java | 8 +-
.../cs02/vocabularies/Org.OData.Core.V1.xml | 134 +++++++++++++++++++
8 files changed, 263 insertions(+), 97 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/85fb12ad/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
new file mode 100644
index 0000000..3a98543
--- /dev/null
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
@@ -0,0 +1,70 @@
+/*
+ * 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.processor;
+
+import java.io.InputStream;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.http.HttpContentType;
+import org.apache.olingo.commons.api.http.HttpHeader;
+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.serializer.ODataFormat;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.uri.UriInfo;
+
+public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProcessor {
+
+ private OData odata;
+ private Edm edm;
+
+ @Override
+ public void init(OData odata, Edm edm) {
+ this.odata = odata;
+ this.edm = edm;
+ }
+
+ @Override
+ public void readServiceDocument(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
+ ODataSerializer serializer;
+ InputStream responseEntity;
+
+ serializer = odata.createSerializer(ODataFormat.JSON);
+ responseEntity = serializer.serviceDocument(edm, request.getRawBaseUri());
+
+ response.setStatusCode(200);
+ response.setHeader(HttpHeader.CONTENT_TYPE, HttpContentType.APPLICATION_JSON);
+ response.setContent(responseEntity);
+
+ }
+
+ @Override
+ public void readMetadata(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
+ ODataSerializer serializer;
+ InputStream responseEntity;
+
+ serializer = odata.createSerializer(ODataFormat.XML);
+ responseEntity = serializer.metadataDocument(edm);
+ response.setStatusCode(200);
+ response.setHeader(HttpHeader.CONTENT_TYPE, HttpContentType.APPLICATION_XML);
+ response.setContent(responseEntity);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/85fb12ad/lib/server-core/src/main/java/org/apache/olingo/server/core/DefaultProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/DefaultProcessor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/DefaultProcessor.java
deleted file mode 100644
index 9a64b50..0000000
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/DefaultProcessor.java
+++ /dev/null
@@ -1,81 +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;
-
-import java.io.InputStream;
-
-import org.apache.olingo.commons.api.edm.Edm;
-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.ODataRequest;
-import org.apache.olingo.server.api.ODataResponse;
-import org.apache.olingo.server.api.processor.MetadataProcessor;
-import org.apache.olingo.server.api.processor.ServiceDocumentProcessor;
-import org.apache.olingo.server.api.serializer.ODataFormat;
-import org.apache.olingo.server.api.serializer.ODataSerializer;
-import org.apache.olingo.server.api.uri.UriInfo;
-
-public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProcessor, RedirectProcessor {
-
- private OData odata;
- private Edm edm;
-
- @Override
- public void init(OData odata, Edm edm) {
- this.odata = odata;
- this.edm = edm;
- }
-
- @Override
- public void readServiceDocument(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
- ODataSerializer serializer;
- InputStream responseEntity;
-
- serializer = odata.createSerializer(ODataFormat.JSON);
- responseEntity = serializer.serviceDocument(edm, request.getRawBaseUri());
-
- response.setStatusCode(200);
- response.setHeader(HttpHeader.CONTENT_TYPE, HttpContentType.APPLICATION_JSON);
- response.setContent(responseEntity);
-
- }
-
- @Override
- public void readMetadata(ODataRequest request, ODataResponse response, UriInfo uriInfo, String format) {
- ODataSerializer serializer;
- InputStream responseEntity;
-
- serializer = odata.createSerializer(ODataFormat.XML);
- responseEntity = serializer.metadataDocument(edm);
- response.setStatusCode(200);
- response.setHeader(HttpHeader.CONTENT_TYPE, HttpContentType.APPLICATION_XML);
- response.setContent(responseEntity);
- }
-
- @Override
- public void redirect(ODataRequest request, ODataResponse response) {
- response.setStatusCode(HttpStatusCode.TEMPORARY_REDIRECT.getStatusCode());
-
- String location = request.getRawRequestUri() + "/";
- response.setHeader(HttpHeader.LOCATION, location);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/85fb12ad/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
new file mode 100644
index 0000000..0d47d55
--- /dev/null
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/DefaultRedirectProcessor.java
@@ -0,0 +1,41 @@
+/*
+ * 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.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;
+
+public class DefaultRedirectProcessor implements RedirectProcessor {
+
+ @Override
+ public void init(OData odata, Edm edm) {}
+
+ @Override
+ public void redirect(ODataRequest request, ODataResponse response) {
+ response.setStatusCode(HttpStatusCode.TEMPORARY_REDIRECT.getStatusCode());
+
+ String location = request.getRawRequestUri() + "/";
+ response.setHeader(HttpHeader.LOCATION, location);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/85fb12ad/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 5d0f09f..bafb5bc 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,6 +27,7 @@ import org.apache.olingo.commons.api.http.HttpContentType;
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.processor.DefaultProcessor;
import org.apache.olingo.server.api.processor.MetadataProcessor;
import org.apache.olingo.server.api.processor.Processor;
import org.apache.olingo.server.api.processor.ServiceDocumentProcessor;
@@ -45,6 +46,7 @@ public class ODataHandler {
this.edm = edm;
register(new DefaultProcessor());
+ register(new DefaultRedirectProcessor());
}
public ODataResponse process(final ODataRequest request) {
@@ -100,7 +102,7 @@ public class ODataHandler {
processor.init(odata, edm);
for (Class<?> cls : processor.getClass().getInterfaces()) {
- if (Processor.class.isAssignableFrom(cls)) {
+ if (Processor.class.isAssignableFrom(cls) && cls != Processor.class) {
@SuppressWarnings("unchecked")
Class<? extends Processor> procClass = (Class<? extends Processor>) cls;
processors.put(procClass, processor);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/85fb12ad/lib/server-core/src/main/java/org/apache/olingo/server/core/RedirectProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/RedirectProcessor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/RedirectProcessor.java
index c741cac..4e99d31 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/RedirectProcessor.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/RedirectProcessor.java
@@ -23,7 +23,7 @@ import org.apache.olingo.server.api.ODataResponse;
import org.apache.olingo.server.api.processor.Processor;
public interface RedirectProcessor extends Processor {
-
+
void redirect(ODataRequest request, ODataResponse response);
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/85fb12ad/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 999cb36..e49430f 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
@@ -529,14 +529,14 @@ public class MetadataDocumentXmlSerializer {
}
private void appendReference(final XMLStreamWriter writer) throws XMLStreamException {
-// writer.writeStartElement(NS_EDMX, "Reference");
-// // TODO: Where is this value comming from?
-// writer.writeAttribute("Uri", "http://docs.oasis-open.org/odata/odata/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml");
-// writer.writeEmptyElement(NS_EDMX, "Include");
-// // TODO: Where is this value comming from?
-// writer.writeAttribute(XML_NAMESPACE, "Org.OData.Core.V1");
-// // TODO: Where is this value comming from?
-// writer.writeAttribute(XML_ALIAS, "Core");
-// writer.writeEndElement();
+ writer.writeStartElement(NS_EDMX, "Reference");
+ // TODO: Where is this value comming from?
+ writer.writeAttribute("Uri", "http://localhost:9080/tecsvc/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml");
+ writer.writeEmptyElement(NS_EDMX, "Include");
+ // TODO: Where is this value comming from?
+ writer.writeAttribute(XML_NAMESPACE, "Org.OData.Core.V1");
+ // TODO: Where is this value comming from?
+ writer.writeAttribute(XML_ALIAS, "Core");
+ writer.writeEndElement();
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/85fb12ad/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalProcessor.java
index 7f05862..ae0d34f 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/TechnicalProcessor.java
@@ -24,14 +24,14 @@ import org.apache.olingo.server.api.processor.Processor;
public class TechnicalProcessor implements Processor {
- private OData odata;
- private Edm edm;
+// private OData odata;
+// private Edm edm;
@Override
public void init(OData odata, Edm edm) {
- this.odata = odata;
- this.edm = edm;
+// this.odata = odata;
+// this.edm = edm;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/85fb12ad/lib/server-tecsvc/src/main/webapp/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/webapp/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml b/lib/server-tecsvc/src/main/webapp/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml
new file mode 100644
index 0000000..aeca931
--- /dev/null
+++ b/lib/server-tecsvc/src/main/webapp/v4.0/cs02/vocabularies/Org.OData.Core.V1.xml
@@ -0,0 +1,134 @@
+<?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.
+
+-->
+
+<!--
+ OData Version 4.0
+ Committee Specification 02
+ 17 November 2013
+ Copyright (c) OASIS Open 2013. All Rights Reserved.
+ Source: http://docs.oasis-open.org/odata/odata/v4.0/cs02/vocabularies/
+-->
+
+<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
+ <edmx:DataServices>
+ <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Org.OData.Core.V1" Alias="Core">
+ <Annotation Term="Core.Description">
+ <String>Core terms needed to write vocabularies</String>
+ </Annotation>
+
+ <!--Documentation -->
+
+ <Term Name="Description" Type="Edm.String">
+ <Annotation Term="Core.Description" String="A brief description of a model element" />
+ <Annotation Term="Core.IsLanguageDependent" />
+ </Term>
+
+ <Term Name="LongDescription" Type="Edm.String">
+ <Annotation Term="Core.Description" String="A lengthy description of a model element" />
+ <Annotation Term="Core.IsLanguageDependent" />
+ </Term>
+
+ <!-- Localization -->
+
+ <Term Name="IsLanguageDependent" Type="Core.Tag" DefaultValue="true" AppliesTo="Property Term">
+ <Annotation Term="Core.Description" String="Properties and terms annotated with this term are language-dependent" />
+ <Annotation Term="Core.RequiresType" String="Edm.String" />
+ </Term>
+
+ <!-- Term Restrictions -->
+
+ <TypeDefinition Name="Tag" UnderlyingType="Edm.Boolean">
+ <Annotation Term="Core.Description" String="This is the type to use for all tagging terms" />
+ </TypeDefinition>
+
+ <Term Name="RequiresType" Type="Edm.String" AppliesTo="Term">
+ <Annotation Term="Core.Description"
+ String="Properties and terms annotated with this annotation MUST have a type that is identical to or derived from the given type name" />
+ </Term>
+
+ <!--Resource Paths -->
+
+ <Term Name="ResourcePath" Type="Edm.String" AppliesTo="EntitySet Singleton ActionImport FunctionImport">
+ <Annotation Term="Core.Description"
+ String="Resource path for entity container child, can be relative to xml:base and the request URL" />
+ <Annotation Term="Core.IsUrl" />
+ </Term>
+
+ <Term Name="DereferenceableIDs" Type="Core.Tag" DefaultValue="true" AppliesTo="EntityContainer">
+ <Annotation Term="Core.Description" String="Entity-ids are URLs that locate the identified entity" />
+ </Term>
+
+ <Term Name="ConventionalIDs" Type="Core.Tag" DefaultValue="true" AppliesTo="EntityContainer">
+ <Annotation Term="Core.Description" String="Entity-ids follow OData URL conventions" />
+ </Term>
+
+ <!-- Permissions -->
+
+ <Term Name="Permissions" Type="Core.Permission" AppliesTo="Property">
+ <Annotation Term="Core.Description" String="Permissions available for a property.The value of 2 is reserved for future use." />
+ </Term>
+ <EnumType Name="Permission" IsFlags="true">
+ <Member Name="None" Value="0" />
+ <Member Name="Read" Value="1" />
+ <Member Name="ReadWrite" Value="3" />
+ </EnumType>
+
+ <!-- Metadata Extensions -->
+
+ <Term Name="Immutable" Type="Core.Tag" DefaultValue="true" AppliesTo="Property">
+ <Annotation Term="Core.Description"
+ String="A value for this non-key property can be provided on insert and remains unchanged on update" />
+ </Term>
+
+ <Term Name="Computed" Type="Core.Tag" DefaultValue="true" AppliesTo="Property">
+ <Annotation Term="Core.Description" String="A value for this property is generated on both insert and update" />
+ </Term>
+
+ <Term Name="IsURL" Type="Core.Tag" DefaultValue="true" AppliesTo="Property Term">
+ <Annotation Term="Core.Description" String="Properties and terms annotated with this term MUST contain a valid URL" />
+ <Annotation Term="Core.RequiresType" String="Edm.String" />
+ </Term>
+
+ <Term Name="AcceptableMediaTypes" Type="Collection(Edm.String)" AppliesTo="EntityType Property">
+ <Annotation Term="Core.Description"
+ String="Lists the MIME types acceptable for the annotated entity type marked with HasStream="true" or the annotated stream property" />
+ <Annotation Term="Core.IsMediaType" />
+ </Term>
+
+ <Term Name="MediaType" Type="Edm.String" AppliesTo="Property">
+ <Annotation Term="Core.IsMediaType" />
+ <Annotation Term="Core.RequiresType" String="Edm.Binary" />
+ </Term>
+
+ <Term Name="IsMediaType" Type="Core.Tag" DefaultValue="true" AppliesTo="Property Term">
+ <Annotation Term="Core.Description" String="Properties and terms annotated with this term MUST contain a valid MIME type" />
+ <Annotation Term="Core.RequiresType" String="Edm.String" />
+ </Term>
+
+ <Term Name="OptimisticConcurrency" Type="Collection(Edm.PropertyPath)" AppliesTo="EntitySet">
+ <Annotation Term="Core.Description"
+ String="Data modification requires the use of Etags. A non-empty collection contains the set of properties that are used to compute the ETag" />
+ </Term>
+
+ </Schema>
+ </edmx:DataServices>
+</edmx:Edmx>
\ No newline at end of file