mirror of
https://github.com/apache/olingo-odata4.git
synced 2025-03-08 17:59:41 +00:00
[OLINGO-266] make metadata fit work
This commit is contained in:
parent
4cb3b32afe
commit
85fb12ad83
@ -16,24 +16,21 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.server.core;
|
||||
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.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 {
|
||||
public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProcessor {
|
||||
|
||||
private OData odata;
|
||||
private Edm edm;
|
||||
@ -70,12 +67,4 @@ public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProce
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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>
|
Loading…
x
Reference in New Issue
Block a user