[OLINGO-856] Merge branch 'OLINGO-856_ODataHandlerInAPI'
This commit is contained in:
commit
59699da030
|
@ -97,6 +97,13 @@ public abstract class OData {
|
||||||
*/
|
*/
|
||||||
public abstract ODataHttpHandler createHandler(ServiceMetadata serviceMetadata);
|
public abstract ODataHttpHandler createHandler(ServiceMetadata serviceMetadata);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ODataHandler for handling OData requests.
|
||||||
|
*
|
||||||
|
* @param serviceMetadata - metadata object required to handle an OData request
|
||||||
|
*/
|
||||||
|
public abstract ODataHandler createBasicHandler(ServiceMetadata serviceMetadata);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a metadata object for this service.
|
* Creates a metadata object for this service.
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* 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.server.api.processor.Processor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Handles requests as OData requests.</p>
|
||||||
|
*
|
||||||
|
* <p>This includes URI parsing, content negotiation, dispatching the request
|
||||||
|
* to a specific custom processor implementation for handling data and
|
||||||
|
* creating the serialized content for the response object.</p>
|
||||||
|
*/
|
||||||
|
public interface ODataHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Processes an OData request.</p>
|
||||||
|
* <p>This includes URI parsing, content negotiation, dispatching the request
|
||||||
|
* to a specific custom processor implementation for handling data and
|
||||||
|
* creating the serialized content for the response object.</p>
|
||||||
|
* @param request the OData request
|
||||||
|
* @return OData response
|
||||||
|
*/
|
||||||
|
ODataResponse process(final ODataRequest request);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Registers additional custom processor implementations for handling OData requests.</p>
|
||||||
|
* <p>If request processing requires a processor that is not registered then a
|
||||||
|
* "not implemented" exception will happen.</p>
|
||||||
|
*/
|
||||||
|
void register(Processor processor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Registers additional extensions for handling OData requests.</p>
|
||||||
|
* <p>This method is used for registration of all possible extensions
|
||||||
|
* and provide the extensibility for further extensions and
|
||||||
|
* different ODataHandler implementations/extensions.</p>
|
||||||
|
*/
|
||||||
|
void register(OlingoExtension extension);
|
||||||
|
}
|
|
@ -23,16 +23,15 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.olingo.server.api.debug.DebugSupport;
|
import org.apache.olingo.server.api.debug.DebugSupport;
|
||||||
import org.apache.olingo.server.api.etag.CustomETagSupport;
|
import org.apache.olingo.server.api.etag.CustomETagSupport;
|
||||||
import org.apache.olingo.server.api.processor.Processor;
|
|
||||||
import org.apache.olingo.server.api.serializer.CustomContentTypeSupport;
|
import org.apache.olingo.server.api.serializer.CustomContentTypeSupport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles HTTP requests as OData requests.
|
* Handles HTTP requests as OData requests.
|
||||||
*/
|
*/
|
||||||
public interface ODataHttpHandler {
|
public interface ODataHttpHandler extends ODataHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Processes an OData request.</p>
|
* <p>Processes a HttpServletRequest as an OData request.</p>
|
||||||
* <p>This includes URI parsing, content negotiation, dispatching the request
|
* <p>This includes URI parsing, content negotiation, dispatching the request
|
||||||
* to a specific custom processor implementation for handling data and
|
* to a specific custom processor implementation for handling data and
|
||||||
* creating the serialized content for the response object.</p>
|
* creating the serialized content for the response object.</p>
|
||||||
|
@ -42,11 +41,17 @@ public interface ODataHttpHandler {
|
||||||
void process(HttpServletRequest request, HttpServletResponse response);
|
void process(HttpServletRequest request, HttpServletResponse response);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Registers additional custom processor implementations for handling OData requests.</p>
|
* Sets the split parameter which is used for service resolution.
|
||||||
* <p>If request processing requires a processor that is not registered then a
|
* @param split the number of path segments reserved for service resolution; default is 0
|
||||||
* "not implemented" exception will happen.</p>
|
|
||||||
*/
|
*/
|
||||||
void register(Processor processor);
|
void setSplit(int split);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers the debug support handler.
|
||||||
|
* @param debugSupport handler to register
|
||||||
|
*/
|
||||||
|
void register(DebugSupport debugSupport);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a service implementation for modifying the standard list of supported
|
* Registers a service implementation for modifying the standard list of supported
|
||||||
|
@ -55,22 +60,9 @@ public interface ODataHttpHandler {
|
||||||
*/
|
*/
|
||||||
void register(CustomContentTypeSupport customContentTypeSupport);
|
void register(CustomContentTypeSupport customContentTypeSupport);
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the split parameter which is used for service resolution.
|
|
||||||
* @param split the number of path segments reserved for service resolution; default is 0
|
|
||||||
*/
|
|
||||||
void setSplit(int split);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers support for concurrency control for certain entity sets.
|
* Registers support for concurrency control for certain entity sets.
|
||||||
* @param customETagSupport
|
* @param customETagSupport handler to register
|
||||||
*/
|
*/
|
||||||
void register(CustomETagSupport customConcurrencyControlSupport);
|
void register(CustomETagSupport customETagSupport);
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers the debug support handler.
|
|
||||||
* @param debugSupport
|
|
||||||
*/
|
|
||||||
void register(DebugSupport debugSupport);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marker interface for all possible Olingo extensions.
|
||||||
|
*/
|
||||||
|
public interface OlingoExtension {
|
||||||
|
}
|
|
@ -20,16 +20,17 @@ package org.apache.olingo.server.api.debug;
|
||||||
|
|
||||||
import org.apache.olingo.server.api.OData;
|
import org.apache.olingo.server.api.OData;
|
||||||
import org.apache.olingo.server.api.ODataResponse;
|
import org.apache.olingo.server.api.ODataResponse;
|
||||||
|
import org.apache.olingo.server.api.OlingoExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register this interface to add debug support to your service.
|
* Register this interface to add debug support to your service.
|
||||||
*/
|
*/
|
||||||
public interface DebugSupport {
|
public interface DebugSupport extends OlingoExtension {
|
||||||
|
|
||||||
public static final String ODATA_DEBUG_QUERY_PARAMETER = "odata-debug";
|
String ODATA_DEBUG_QUERY_PARAMETER = "odata-debug";
|
||||||
public static final String ODATA_DEBUG_JSON = "json";
|
String ODATA_DEBUG_JSON = "json";
|
||||||
public static final String ODATA_DEBUG_HTML = "html";
|
String ODATA_DEBUG_HTML = "html";
|
||||||
public static final String ODATA_DEBUG_DOWNLOAD = "download";
|
String ODATA_DEBUG_DOWNLOAD = "download";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the debug support implementation.
|
* Initializes the debug support implementation.
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.apache.olingo.server.api.etag;
|
package org.apache.olingo.server.api.etag;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.edm.EdmBindingTarget;
|
import org.apache.olingo.commons.api.edm.EdmBindingTarget;
|
||||||
|
import org.apache.olingo.server.api.OlingoExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Processors that would like to support etags for certain entity sets can implement this
|
* <p>Processors that would like to support etags for certain entity sets can implement this
|
||||||
|
@ -27,7 +28,7 @@ import org.apache.olingo.commons.api.edm.EdmBindingTarget;
|
||||||
* require an if-match/if-none-match or an if-modified-since/if-unmodified-since header. Otherwise the request will
|
* require an if-match/if-none-match or an if-modified-since/if-unmodified-since header. Otherwise the request will
|
||||||
* result in a "Precondition Required" response</p>
|
* result in a "Precondition Required" response</p>
|
||||||
*/
|
*/
|
||||||
public interface CustomETagSupport {
|
public interface CustomETagSupport extends OlingoExtension {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will be called for update requests which target an entity or a property of an entity.
|
* This method will be called for update requests which target an entity or a property of an entity.
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.olingo.server.api.serializer;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
|
import org.apache.olingo.server.api.OlingoExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Processors that supports custom content types can implement this interface.</p>
|
* <p>Processors that supports custom content types can implement this interface.</p>
|
||||||
|
@ -33,7 +34,7 @@ import org.apache.olingo.commons.api.format.ContentType;
|
||||||
* 406 (Not Acceptable); sending content of an unsupported type results in an
|
* 406 (Not Acceptable); sending content of an unsupported type results in an
|
||||||
* HTTP error 415 (Unsupported Media Type).</p>
|
* HTTP error 415 (Unsupported Media Type).</p>
|
||||||
*/
|
*/
|
||||||
public interface CustomContentTypeSupport {
|
public interface CustomContentTypeSupport extends OlingoExtension {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of supported content types.
|
* Returns a list of supported content types.
|
||||||
|
@ -41,6 +42,6 @@ public interface CustomContentTypeSupport {
|
||||||
* @param type the current type of representation
|
* @param type the current type of representation
|
||||||
* @return modified list of supported content types
|
* @return modified list of supported content types
|
||||||
*/
|
*/
|
||||||
public List<ContentType> modifySupportedContentTypes(
|
List<ContentType> modifySupportedContentTypes(
|
||||||
List<ContentType> defaultContentTypes, RepresentationType type);
|
List<ContentType> defaultContentTypes, RepresentationType type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class OData4Impl extends ODataImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataHttpHandler createHandler(final ServiceMetadata edm) {
|
public ODataHttpHandler createHandler(final ServiceMetadata serviceMetadata) {
|
||||||
return new OData4HttpHandler(this, edm);
|
return new OData4HttpHandler(this, serviceMetadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,9 +75,9 @@ public class ODataDispatcher {
|
||||||
|
|
||||||
private static final String NOT_IMPLEMENTED_MESSAGE = "not implemented";
|
private static final String NOT_IMPLEMENTED_MESSAGE = "not implemented";
|
||||||
private final UriInfo uriInfo;
|
private final UriInfo uriInfo;
|
||||||
private final ODataHandler handler;
|
private final ODataHandlerImpl handler;
|
||||||
|
|
||||||
public ODataDispatcher(final UriInfo uriInfo, final ODataHandler handler) {
|
public ODataDispatcher(final UriInfo uriInfo, final ODataHandlerImpl handler) {
|
||||||
this.uriInfo = uriInfo;
|
this.uriInfo = uriInfo;
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,15 +22,18 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||||
|
import org.apache.olingo.commons.api.ex.ODataRuntimeException;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.api.http.HttpHeader;
|
import org.apache.olingo.commons.api.http.HttpHeader;
|
||||||
import org.apache.olingo.commons.api.http.HttpMethod;
|
import org.apache.olingo.commons.api.http.HttpMethod;
|
||||||
import org.apache.olingo.server.api.OData;
|
import org.apache.olingo.server.api.OData;
|
||||||
import org.apache.olingo.server.api.ODataApplicationException;
|
import org.apache.olingo.server.api.ODataApplicationException;
|
||||||
|
import org.apache.olingo.server.api.ODataHandler;
|
||||||
import org.apache.olingo.server.api.ODataLibraryException;
|
import org.apache.olingo.server.api.ODataLibraryException;
|
||||||
import org.apache.olingo.server.api.ODataRequest;
|
import org.apache.olingo.server.api.ODataRequest;
|
||||||
import org.apache.olingo.server.api.ODataResponse;
|
import org.apache.olingo.server.api.ODataResponse;
|
||||||
import org.apache.olingo.server.api.ODataServerError;
|
import org.apache.olingo.server.api.ODataServerError;
|
||||||
|
import org.apache.olingo.server.api.OlingoExtension;
|
||||||
import org.apache.olingo.server.api.ServiceMetadata;
|
import org.apache.olingo.server.api.ServiceMetadata;
|
||||||
import org.apache.olingo.server.api.deserializer.DeserializerException;
|
import org.apache.olingo.server.api.deserializer.DeserializerException;
|
||||||
import org.apache.olingo.server.api.etag.CustomETagSupport;
|
import org.apache.olingo.server.api.etag.CustomETagSupport;
|
||||||
|
@ -50,7 +53,7 @@ import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException;
|
||||||
import org.apache.olingo.server.core.uri.validator.UriValidationException;
|
import org.apache.olingo.server.core.uri.validator.UriValidationException;
|
||||||
import org.apache.olingo.server.core.uri.validator.UriValidator;
|
import org.apache.olingo.server.core.uri.validator.UriValidator;
|
||||||
|
|
||||||
public class ODataHandler {
|
public class ODataHandlerImpl implements ODataHandler {
|
||||||
|
|
||||||
private final OData odata;
|
private final OData odata;
|
||||||
private final ServiceMetadata serviceMetadata;
|
private final ServiceMetadata serviceMetadata;
|
||||||
|
@ -63,8 +66,8 @@ public class ODataHandler {
|
||||||
private UriInfo uriInfo;
|
private UriInfo uriInfo;
|
||||||
private Exception lastThrownException;
|
private Exception lastThrownException;
|
||||||
|
|
||||||
public ODataHandler(final OData server, final ServiceMetadata serviceMetadata, final ServerCoreDebugger debugger) {
|
public ODataHandlerImpl(final OData odata, final ServiceMetadata serviceMetadata, final ServerCoreDebugger debugger) {
|
||||||
odata = server;
|
this.odata = odata;
|
||||||
this.serviceMetadata = serviceMetadata;
|
this.serviceMetadata = serviceMetadata;
|
||||||
this.debugger = debugger;
|
this.debugger = debugger;
|
||||||
|
|
||||||
|
@ -206,18 +209,22 @@ public class ODataHandler {
|
||||||
processors.add(0, processor);
|
processors.add(0, processor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(final CustomContentTypeSupport customContentTypeSupport) {
|
@Override
|
||||||
this.customContentTypeSupport = customContentTypeSupport;
|
public void register(OlingoExtension extension) {
|
||||||
|
if(extension instanceof CustomContentTypeSupport) {
|
||||||
|
this.customContentTypeSupport = (CustomContentTypeSupport) extension;
|
||||||
|
} else if(extension instanceof CustomETagSupport) {
|
||||||
|
this.customETagSupport = (CustomETagSupport) extension;
|
||||||
|
} else {
|
||||||
|
throw new ODataRuntimeException("Got not supported exception with class name " +
|
||||||
|
extension.getClass().getSimpleName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomContentTypeSupport getCustomContentTypeSupport() {
|
public CustomContentTypeSupport getCustomContentTypeSupport() {
|
||||||
return customContentTypeSupport;
|
return customContentTypeSupport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(final CustomETagSupport customETagSupport) {
|
|
||||||
this.customETagSupport = customETagSupport;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CustomETagSupport getCustomETagSupport() {
|
public CustomETagSupport getCustomETagSupport() {
|
||||||
return customETagSupport;
|
return customETagSupport;
|
||||||
}
|
}
|
|
@ -45,6 +45,7 @@ import org.apache.olingo.server.api.ODataLibraryException;
|
||||||
import org.apache.olingo.server.api.ODataRequest;
|
import org.apache.olingo.server.api.ODataRequest;
|
||||||
import org.apache.olingo.server.api.ODataResponse;
|
import org.apache.olingo.server.api.ODataResponse;
|
||||||
import org.apache.olingo.server.api.ODataServerError;
|
import org.apache.olingo.server.api.ODataServerError;
|
||||||
|
import org.apache.olingo.server.api.OlingoExtension;
|
||||||
import org.apache.olingo.server.api.ServiceMetadata;
|
import org.apache.olingo.server.api.ServiceMetadata;
|
||||||
import org.apache.olingo.server.api.debug.DebugSupport;
|
import org.apache.olingo.server.api.debug.DebugSupport;
|
||||||
import org.apache.olingo.server.api.deserializer.DeserializerException;
|
import org.apache.olingo.server.api.deserializer.DeserializerException;
|
||||||
|
@ -57,14 +58,19 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
|
||||||
|
|
||||||
public static final int COPY_BUFFER_SIZE = 8192;
|
public static final int COPY_BUFFER_SIZE = 8192;
|
||||||
|
|
||||||
private final ODataHandler handler;
|
private final ODataHandlerImpl handler;
|
||||||
private final ServerCoreDebugger debugger;
|
private final ServerCoreDebugger debugger;
|
||||||
|
|
||||||
private int split = 0;
|
private int split = 0;
|
||||||
|
|
||||||
public ODataHttpHandlerImpl(final OData odata, final ServiceMetadata serviceMetadata) {
|
public ODataHttpHandlerImpl(final OData odata, final ServiceMetadata serviceMetadata) {
|
||||||
debugger = new ServerCoreDebugger(odata);
|
debugger = new ServerCoreDebugger(odata);
|
||||||
handler = new ODataHandler(odata, serviceMetadata, debugger);
|
handler = new ODataHandlerImpl(odata, serviceMetadata, debugger);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ODataResponse process(ODataRequest request) {
|
||||||
|
return handler.process(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -78,7 +84,7 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
|
||||||
try {
|
try {
|
||||||
fillODataRequest(odRequest, request, split);
|
fillODataRequest(odRequest, request, split);
|
||||||
|
|
||||||
odResponse = handler.process(odRequest);
|
odResponse = process(odRequest);
|
||||||
// ALL future methods after process must not throw exceptions!
|
// ALL future methods after process must not throw exceptions!
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
exception = e;
|
exception = e;
|
||||||
|
@ -306,6 +312,11 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
|
||||||
handler.register(processor);
|
handler.register(processor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void register(OlingoExtension extension) {
|
||||||
|
handler.register(extension);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(final CustomContentTypeSupport customContentTypeSupport) {
|
public void register(final CustomContentTypeSupport customContentTypeSupport) {
|
||||||
handler.register(customContentTypeSupport);
|
handler.register(customContentTypeSupport);
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.olingo.commons.api.edm.provider.CsdlEdmProvider;
|
||||||
import org.apache.olingo.commons.api.format.ContentType;
|
import org.apache.olingo.commons.api.format.ContentType;
|
||||||
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
|
import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
|
||||||
import org.apache.olingo.server.api.OData;
|
import org.apache.olingo.server.api.OData;
|
||||||
|
import org.apache.olingo.server.api.ODataHandler;
|
||||||
import org.apache.olingo.server.api.ODataHttpHandler;
|
import org.apache.olingo.server.api.ODataHttpHandler;
|
||||||
import org.apache.olingo.server.api.ServiceMetadata;
|
import org.apache.olingo.server.api.ServiceMetadata;
|
||||||
import org.apache.olingo.server.api.debug.DebugResponseHelper;
|
import org.apache.olingo.server.api.debug.DebugResponseHelper;
|
||||||
|
@ -42,6 +43,7 @@ import org.apache.olingo.server.api.serializer.ODataSerializer;
|
||||||
import org.apache.olingo.server.api.serializer.SerializerException;
|
import org.apache.olingo.server.api.serializer.SerializerException;
|
||||||
import org.apache.olingo.server.api.uri.UriHelper;
|
import org.apache.olingo.server.api.uri.UriHelper;
|
||||||
import org.apache.olingo.server.core.debug.DebugResponseHelperImpl;
|
import org.apache.olingo.server.core.debug.DebugResponseHelperImpl;
|
||||||
|
import org.apache.olingo.server.core.debug.ServerCoreDebugger;
|
||||||
import org.apache.olingo.server.core.deserializer.FixedFormatDeserializerImpl;
|
import org.apache.olingo.server.core.deserializer.FixedFormatDeserializerImpl;
|
||||||
import org.apache.olingo.server.core.deserializer.json.ODataJsonDeserializer;
|
import org.apache.olingo.server.core.deserializer.json.ODataJsonDeserializer;
|
||||||
import org.apache.olingo.server.core.deserializer.xml.ODataXmlDeserializer;
|
import org.apache.olingo.server.core.deserializer.xml.ODataXmlDeserializer;
|
||||||
|
@ -84,8 +86,13 @@ public class ODataImpl extends OData {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ODataHttpHandler createHandler(final ServiceMetadata edm) {
|
public ODataHttpHandler createHandler(final ServiceMetadata serviceMetadata) {
|
||||||
return new ODataHttpHandlerImpl(this, edm);
|
return new ODataHttpHandlerImpl(this, serviceMetadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ODataHandler createBasicHandler(ServiceMetadata serviceMetadata) {
|
||||||
|
return new ODataHandlerImpl(this, serviceMetadata, new ServerCoreDebugger(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.olingo.server.api.deserializer.batch.BatchDeserializerExceptio
|
||||||
import org.apache.olingo.server.api.deserializer.batch.BatchRequestPart;
|
import org.apache.olingo.server.api.deserializer.batch.BatchRequestPart;
|
||||||
import org.apache.olingo.server.api.deserializer.batch.ODataResponsePart;
|
import org.apache.olingo.server.api.deserializer.batch.ODataResponsePart;
|
||||||
import org.apache.olingo.server.api.processor.BatchProcessor;
|
import org.apache.olingo.server.api.processor.BatchProcessor;
|
||||||
import org.apache.olingo.server.core.ODataHandler;
|
import org.apache.olingo.server.core.ODataHandlerImpl;
|
||||||
import org.apache.olingo.server.core.deserializer.batch.BatchParserCommon;
|
import org.apache.olingo.server.core.deserializer.batch.BatchParserCommon;
|
||||||
|
|
||||||
public class BatchFacadeImpl implements BatchFacade {
|
public class BatchFacadeImpl implements BatchFacade {
|
||||||
|
@ -39,8 +39,8 @@ public class BatchFacadeImpl implements BatchFacade {
|
||||||
* @param batchProcessor batch processor
|
* @param batchProcessor batch processor
|
||||||
* @param isStrict mode switch (currently not used)
|
* @param isStrict mode switch (currently not used)
|
||||||
*/
|
*/
|
||||||
public BatchFacadeImpl(final ODataHandler oDataHandler, final BatchProcessor batchProcessor,
|
public BatchFacadeImpl(final ODataHandlerImpl oDataHandler, final BatchProcessor batchProcessor,
|
||||||
final boolean isStrict) {
|
final boolean isStrict) {
|
||||||
partHandler = new BatchPartHandler(oDataHandler, batchProcessor, this);
|
partHandler = new BatchPartHandler(oDataHandler, batchProcessor, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,14 +29,14 @@ import org.apache.olingo.server.api.batch.BatchFacade;
|
||||||
import org.apache.olingo.server.api.deserializer.batch.BatchDeserializerException;
|
import org.apache.olingo.server.api.deserializer.batch.BatchDeserializerException;
|
||||||
import org.apache.olingo.server.api.deserializer.batch.BatchDeserializerException.MessageKeys;
|
import org.apache.olingo.server.api.deserializer.batch.BatchDeserializerException.MessageKeys;
|
||||||
import org.apache.olingo.server.api.processor.BatchProcessor;
|
import org.apache.olingo.server.api.processor.BatchProcessor;
|
||||||
import org.apache.olingo.server.core.ODataHandler;
|
import org.apache.olingo.server.core.ODataHandlerImpl;
|
||||||
import org.apache.olingo.server.core.deserializer.batch.BatchParserCommon;
|
import org.apache.olingo.server.core.deserializer.batch.BatchParserCommon;
|
||||||
|
|
||||||
public class BatchHandler {
|
public class BatchHandler {
|
||||||
private final BatchProcessor batchProcessor;
|
private final BatchProcessor batchProcessor;
|
||||||
private final ODataHandler oDataHandler;
|
private final ODataHandlerImpl oDataHandler;
|
||||||
|
|
||||||
public BatchHandler(final ODataHandler oDataHandler, final BatchProcessor batchProcessor) {
|
public BatchHandler(final ODataHandlerImpl oDataHandler, final BatchProcessor batchProcessor) {
|
||||||
|
|
||||||
this.batchProcessor = batchProcessor;
|
this.batchProcessor = batchProcessor;
|
||||||
this.oDataHandler = oDataHandler;
|
this.oDataHandler = oDataHandler;
|
||||||
|
|
|
@ -28,17 +28,17 @@ import org.apache.olingo.server.api.deserializer.batch.BatchDeserializerExceptio
|
||||||
import org.apache.olingo.server.api.deserializer.batch.BatchRequestPart;
|
import org.apache.olingo.server.api.deserializer.batch.BatchRequestPart;
|
||||||
import org.apache.olingo.server.api.deserializer.batch.ODataResponsePart;
|
import org.apache.olingo.server.api.deserializer.batch.ODataResponsePart;
|
||||||
import org.apache.olingo.server.api.processor.BatchProcessor;
|
import org.apache.olingo.server.api.processor.BatchProcessor;
|
||||||
import org.apache.olingo.server.core.ODataHandler;
|
import org.apache.olingo.server.core.ODataHandlerImpl;
|
||||||
import org.apache.olingo.server.core.batchhandler.referenceRewriting.BatchReferenceRewriter;
|
import org.apache.olingo.server.core.batchhandler.referenceRewriting.BatchReferenceRewriter;
|
||||||
|
|
||||||
public class BatchPartHandler {
|
public class BatchPartHandler {
|
||||||
private final ODataHandler oDataHandler;
|
private final ODataHandlerImpl oDataHandler;
|
||||||
private final BatchProcessor batchProcessor;
|
private final BatchProcessor batchProcessor;
|
||||||
private final BatchFacade batchFacade;
|
private final BatchFacade batchFacade;
|
||||||
private final BatchReferenceRewriter rewriter;
|
private final BatchReferenceRewriter rewriter;
|
||||||
|
|
||||||
public BatchPartHandler(final ODataHandler oDataHandler, final BatchProcessor processor,
|
public BatchPartHandler(final ODataHandlerImpl oDataHandler, final BatchProcessor processor,
|
||||||
final BatchFacade batchFacade) {
|
final BatchFacade batchFacade) {
|
||||||
this.oDataHandler = oDataHandler;
|
this.oDataHandler = oDataHandler;
|
||||||
batchProcessor = processor;
|
batchProcessor = processor;
|
||||||
this.batchFacade = batchFacade;
|
this.batchFacade = batchFacade;
|
||||||
|
|
|
@ -52,7 +52,7 @@ import org.apache.olingo.server.api.deserializer.batch.BatchRequestPart;
|
||||||
import org.apache.olingo.server.api.deserializer.batch.ODataResponsePart;
|
import org.apache.olingo.server.api.deserializer.batch.ODataResponsePart;
|
||||||
import org.apache.olingo.server.api.processor.BatchProcessor;
|
import org.apache.olingo.server.api.processor.BatchProcessor;
|
||||||
import org.apache.olingo.server.api.serializer.BatchSerializerException;
|
import org.apache.olingo.server.api.serializer.BatchSerializerException;
|
||||||
import org.apache.olingo.server.core.ODataHandler;
|
import org.apache.olingo.server.core.ODataHandlerImpl;
|
||||||
import org.apache.olingo.server.core.deserializer.batch.BatchLineReader;
|
import org.apache.olingo.server.core.deserializer.batch.BatchLineReader;
|
||||||
import org.apache.olingo.server.core.deserializer.batch.BatchParserCommon;
|
import org.apache.olingo.server.core.deserializer.batch.BatchParserCommon;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -67,7 +67,7 @@ public class MockedBatchHandlerTest {
|
||||||
private static final String BATCH_REQUEST_URI = "http://localhost:8080/odata/$batch";
|
private static final String BATCH_REQUEST_URI = "http://localhost:8080/odata/$batch";
|
||||||
private static final String BASE_URI = "http://localhost:8080/odata";
|
private static final String BASE_URI = "http://localhost:8080/odata";
|
||||||
private static final String CRLF = "\r\n";
|
private static final String CRLF = "\r\n";
|
||||||
private ODataHandler oDataHandler;
|
private ODataHandlerImpl oDataHandler;
|
||||||
private BatchHandler batchHandler;
|
private BatchHandler batchHandler;
|
||||||
private int entityCounter = 1;
|
private int entityCounter = 1;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class MockedBatchHandlerTest {
|
||||||
batchProcessor.init(OData.newInstance(), null);
|
batchProcessor.init(OData.newInstance(), null);
|
||||||
|
|
||||||
entityCounter = 1;
|
entityCounter = 1;
|
||||||
oDataHandler = mock(ODataHandler.class);
|
oDataHandler = mock(ODataHandlerImpl.class);
|
||||||
batchHandler = new BatchHandler(oDataHandler, batchProcessor);
|
batchHandler = new BatchHandler(oDataHandler, batchProcessor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ import org.apache.olingo.server.tecsvc.provider.ContainerProvider;
|
||||||
import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
|
import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class ODataHandlerTest {
|
public class ODataHandlerImplTest {
|
||||||
|
|
||||||
private static final String BASE_URI = "http://localhost/odata";
|
private static final String BASE_URI = "http://localhost/odata";
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ public class ODataHandlerTest {
|
||||||
request.setRawODataPath("EdmException");
|
request.setRawODataPath("EdmException");
|
||||||
|
|
||||||
final ODataResponse response =
|
final ODataResponse response =
|
||||||
new ODataHandler(odata, serviceMetadata, new ServerCoreDebugger(odata)).process(request);
|
new ODataHandlerImpl(odata, serviceMetadata, new ServerCoreDebugger(odata)).process(request);
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertEquals(HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode());
|
assertEquals(HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode());
|
||||||
}
|
}
|
||||||
|
@ -784,7 +784,7 @@ public class ODataHandlerTest {
|
||||||
final ServiceMetadata metadata = odata.createServiceMetadata(
|
final ServiceMetadata metadata = odata.createServiceMetadata(
|
||||||
new EdmTechProvider(), Collections.<EdmxReference> emptyList());
|
new EdmTechProvider(), Collections.<EdmxReference> emptyList());
|
||||||
|
|
||||||
ODataHandler handler = new ODataHandler(odata, metadata, new ServerCoreDebugger(odata));
|
ODataHandlerImpl handler = new ODataHandlerImpl(odata, metadata, new ServerCoreDebugger(odata));
|
||||||
|
|
||||||
if (processor != null) {
|
if (processor != null) {
|
||||||
handler.register(processor);
|
handler.register(processor);
|
Loading…
Reference in New Issue