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 2013/09/24 14:42:51 UTC

[24/51] [partial] Refactored project structure

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-api/src/main/java/org/apache/olingo/odata2/api/uri/package-info.java
----------------------------------------------------------------------
diff --git a/odata-api/src/main/java/org/apache/olingo/odata2/api/uri/package-info.java b/odata-api/src/main/java/org/apache/olingo/odata2/api/uri/package-info.java
deleted file mode 100644
index 014fab7..0000000
--- a/odata-api/src/main/java/org/apache/olingo/odata2/api/uri/package-info.java
+++ /dev/null
@@ -1,28 +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.
- ******************************************************************************/
-/**
- * <p>URI Parser Facade</p>
- * <p>The URI package has one central class {@link org.apache.olingo.odata2.api.uri.UriParser} to parse a request URI
- * as well as several interfaces that provide access to parsed parts of the URI.
- * <br>The {@link org.apache.olingo.odata2.api.uri.UriParser} class also provides the possibility to parse a filter or
- * an orderBy Statement. Both are specified in the OData Protocol Specification.
- * <br>The URI syntax is specified in the OData Protocol Specification in the form of an ABNF. </p>
- */
-package org.apache.olingo.odata2.api.uri;
-

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/pom.xml
----------------------------------------------------------------------
diff --git a/odata-core/pom.xml b/odata-core/pom.xml
deleted file mode 100644
index 071f815..0000000
--- a/odata-core/pom.xml
+++ /dev/null
@@ -1,203 +0,0 @@
-<?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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-	<modelVersion>4.0.0</modelVersion>
-
-	<artifactId>olingo.odata2.core</artifactId>
-	<packaging>jar</packaging>
-	<name>${project.artifactId}</name>
-
-	<parent>
-		<groupId>org.apache.olingo</groupId>
-		<artifactId>olingo.odata2.parent</artifactId>
-		<version>1.0.0-SNAPSHOT</version>
-		<relativePath>..</relativePath>
-	</parent>
-
-	<!-- not supported because of static behaviour of serialization tests -->
-	<!-- <build> -->
-	<!-- <plugins> -->
-	<!-- <plugin> -->
-	<!-- <groupId>org.apache.maven.plugins</groupId> -->
-	<!-- <artifactId>maven-surefire-plugin</artifactId> -->
-	<!-- <configuration> -->
-	<!-- <parallel>classes</parallel> -->
-	<!-- <threadCount>10</threadCount> -->
-	<!-- </configuration> -->
-	<!-- </plugin> -->
-	<!-- </plugins> -->
-	<!-- </build> -->
-
-	<build>
-		<plugins>
-			<plugin>
-				<artifactId>maven-jar-plugin</artifactId>
-				<configuration>
-					<archive>
-						<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
-					</archive>
-				</configuration>
-			</plugin>
-			<plugin>
-				<groupId>org.apache.felix</groupId>
-				<artifactId>maven-bundle-plugin</artifactId>
-				<extensions>true</extensions>
-				<executions>
-					<execution>
-						<id>bundle-manifest</id>
-						<phase>process-classes</phase>
-						<goals>
-							<goal>manifest</goal>
-						</goals>
-					</execution>
-				</executions>
-				<configuration>
-					<instructions>
-						<Import-Package>
-							javax.ws.rs,
-							javax.ws.rs.*,
-							*
-						</Import-Package>
-						<Export-Package>
-							org.apache.olingo.odata2.core.rest.app;version=${project.version},
-							org.apache.olingo.odata2.core.rt;version=${project.version},
-						</Export-Package>
-						<Bundle-DocURL>${project.url}</Bundle-DocURL>
-						<Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
-						<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-					</instructions>
-				</configuration>
-			</plugin>
-		</plugins>
-	</build>
-
-	<profiles>
-		<profile>
-			<id>coverage</id>
-			<activation>
-				<property>
-					<name>ldi.parent.emma-coverage</name>
-				</property>
-			</activation>
-			<build>
-				<plugins>
-					<plugin>
-						<!-- copy api during test to target/api_dependency -->
-						<groupId>org.apache.maven.plugins</groupId>
-						<artifactId>maven-dependency-plugin</artifactId>
-						<executions>
-							<execution>
-								<id>copy api classes</id>
-								<phase>generate-test-resources</phase>
-								<goals>
-									<goal>unpack</goal>
-								</goals>
-								<configuration>
-									<artifactItems>
-										<artifactItem>
-											<groupId>org.apache.olingo</groupId>
-											<artifactId>org.apache.olingo.odata2.api</artifactId>
-											<version>${project.version}</version>
-											<outputDirectory>${project.build.directory}/api_dependency</outputDirectory>
-											<overWrite>true</overWrite>
-										</artifactItem>
-									</artifactItems>
-								</configuration>
-							</execution>
-						</executions>
-					</plugin>
-					<plugin>
-						<!-- instrument the copied api classes -->
-						<groupId>org.sonatype.maven.plugin</groupId>
-						<artifactId>emma-maven-plugin</artifactId>
-						<executions>
-							<execution>
-								<id>instrument api classes</id>
-								<phase>process-test-resources</phase>
-								<goals>
-									<goal>instrument</goal>
-								</goals>
-								<configuration>
-									<instrumentationPaths>
-										<param>${project.build.directory}/api_dependency</param>
-									</instrumentationPaths>
-								</configuration>
-							</execution>
-						</executions>
-					</plugin>
-					<plugin>
-						<groupId>org.apache.maven.plugins</groupId>
-						<artifactId>maven-surefire-plugin</artifactId>
-						<configuration>
-							<!-- use the instrumented classes for test execution -->
-							<classesDirectory>${project.build.directory}/generated-classes/emma/classes</classesDirectory>
-						</configuration>
-					</plugin>
-				</plugins>
-			</build>
-		</profile>
-	</profiles>
-
-	<dependencies>
-		<dependency>
-			<groupId>javax.servlet</groupId>
-			<artifactId>servlet-api</artifactId>
-			<version>2.5</version>
-			<scope>provided</scope>
-		</dependency>
-        <dependency>
-          <groupId>javax.ws.rs</groupId>
-          <artifactId>javax.ws.rs-api</artifactId>
-          <version>${jax.ws.rs.version}</version>
-        </dependency>
-
-		<dependency>
-			<groupId>org.apache.olingo</groupId>
-			<artifactId>olingo.odata2.api</artifactId>
-			<version>${project.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>commons-codec</groupId>
-			<artifactId>commons-codec</artifactId>
-			<version>${commonscodec.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>com.google.code.gson</groupId>
-			<artifactId>gson</artifactId>
-			<version>${gson.version}</version>
-		</dependency>
-    
-        <!-- Test dependencies -->
-        <dependency>
-            <groupId>org.apache.olingo</groupId>
-            <artifactId>olingo.odata2.testutil</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.cxf</groupId>
-            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
-            <version>${cxf.version}</version>
-            <scope>test</scope>
-        </dependency>
-	</dependencies>
-
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/ContentNegotiator.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ContentNegotiator.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ContentNegotiator.java
deleted file mode 100644
index 824cf83..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ContentNegotiator.java
+++ /dev/null
@@ -1,195 +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.odata2.core;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.olingo.odata2.api.exception.ODataBadRequestException;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.exception.ODataNotAcceptableException;
-import org.apache.olingo.odata2.api.processor.ODataRequest;
-import org.apache.olingo.odata2.core.commons.ContentType;
-import org.apache.olingo.odata2.core.uri.UriInfoImpl;
-import org.apache.olingo.odata2.core.uri.UriType;
-
-/**
- * Handles content negotiation with handling of OData special cases.
- */
-public class ContentNegotiator {
-  private static final String URI_INFO_FORMAT_JSON = "json";
-  private static final String URI_INFO_FORMAT_ATOM = "atom";
-  private static final String URI_INFO_FORMAT_XML = "xml";
-  static final String DEFAULT_CHARSET = "utf-8";
-
-  /**
-   * Do the content negotiation for <code>accept header value</code> based on
-   * requested content type (in HTTP accept header from {@link ODataRequest})
-   * in combination with uri information from {@link org.apache.olingo.odata2.api.uri.UriInfo} and from given supported
-   * content types (via
-   * <code>supportedContentTypes</code>).
-   * 
-   * @param request specific request
-   * @param uriInfo specific uri information
-   * @param supportedContentTypes list of supported content types
-   * @return best fitting content type or <code>NULL</code> if content type is not set and for given
-   * {@link org.apache.olingo.odata2.api.uri.UriInfo} is
-   * ignored
-   * @throws ODataException if no supported content type was found
-   * @throws IllegalArgumentException if one of the input parameter is <code>NULL</code>
-   */
-  public ContentType doContentNegotiation(final ODataRequest odataRequest, final UriInfoImpl uriInfo,
-      final List<String> supportedContentTypes) throws ODataException {
-    validateNotNull(odataRequest, uriInfo, supportedContentTypes);
-
-    if (uriInfo.isCount()) {
-      return ContentType.TEXT_PLAIN_CS_UTF_8;
-    } else if (uriInfo.isValue()) {
-      if (uriInfo.getUriType() == UriType.URI5 || uriInfo.getUriType() == UriType.URI4) {
-        return ContentType.TEXT_PLAIN_CS_UTF_8;
-      }
-      return doContentNegotiationForAcceptHeader(Arrays.asList("*/*"), ContentType.create(supportedContentTypes));
-    }
-
-    if (uriInfo.getFormat() == null) {
-      return doContentNegotiationForAcceptHeader(odataRequest.getAcceptHeaders(), ContentType
-          .create(supportedContentTypes));
-    } else {
-      return doContentNegotiationForFormat(uriInfo, ContentType.createAsCustom(supportedContentTypes));
-    }
-  }
-
-  private void validateNotNull(final ODataRequest odataRequest, final UriInfoImpl uriInfo,
-      final List<String> supportedContentTypes) {
-    if (uriInfo == null) {
-      throw new IllegalArgumentException("Parameter uriInfo MUST NOT be null.");
-    }
-    if (odataRequest == null) {
-      throw new IllegalArgumentException("Parameter odataRequest MUST NOT be null.");
-    }
-    if (supportedContentTypes == null) {
-      throw new IllegalArgumentException("Parameter supportedContentTypes MUST NOT be null.");
-    }
-  }
-
-  private ContentType doContentNegotiationForFormat(final UriInfoImpl uriInfo,
-      final List<ContentType> supportedContentTypes) throws ODataException {
-    validateFormatQuery(uriInfo);
-    ContentType formatContentType = mapFormat(uriInfo);
-    formatContentType = ensureCharset(formatContentType);
-
-    for (final ContentType contentType : supportedContentTypes) {
-      if (contentType.equals(formatContentType)) {
-        return formatContentType;
-      }
-    }
-
-    throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE.addContent(uriInfo
-        .getFormat()));
-  }
-
-  /**
-   * Validates that <code>dollar format query/syntax</code> is correct for further processing.
-   * If some validation error occurs an exception is thrown.
-   * 
-   * @param uriInfo
-   * @throws ODataBadRequestException
-   */
-  private void validateFormatQuery(final UriInfoImpl uriInfo) throws ODataBadRequestException {
-    if (uriInfo.isValue()) {
-      throw new ODataBadRequestException(ODataBadRequestException.INVALID_SYNTAX);
-    }
-  }
-
-  private ContentType mapFormat(final UriInfoImpl uriInfo) {
-    final String format = uriInfo.getFormat();
-    if (URI_INFO_FORMAT_XML.equals(format)) {
-      return ContentType.APPLICATION_XML;
-    } else if (URI_INFO_FORMAT_ATOM.equals(format)) {
-      if (uriInfo.getUriType() == UriType.URI0) {
-        // special handling for serviceDocument uris (UriType.URI0)
-        return ContentType.APPLICATION_ATOM_SVC;
-      } else if (uriInfo.getUriType() == UriType.URI1) {
-        return ContentType.APPLICATION_ATOM_XML_FEED;
-      } else if (uriInfo.getUriType() == UriType.URI2) {
-        return ContentType.APPLICATION_ATOM_XML_ENTRY;
-      }
-    } else if (URI_INFO_FORMAT_JSON.equals(format)) {
-      return ContentType.APPLICATION_JSON;
-    }
-
-    return ContentType.createAsCustom(format);
-  }
-
-  private ContentType doContentNegotiationForAcceptHeader(final List<String> acceptHeaderContentTypes,
-      final List<ContentType> supportedContentTypes) throws ODataException {
-    return contentNegotiation(extractAcceptHeaders(acceptHeaderContentTypes), supportedContentTypes);
-  }
-
-  private List<ContentType> extractAcceptHeaders(final List<String> acceptHeaderValues)
-      throws ODataBadRequestException {
-    final List<ContentType> mediaTypes = new ArrayList<ContentType>();
-    if (acceptHeaderValues != null) {
-      for (final String mediaType : acceptHeaderValues) {
-        try {
-          mediaTypes.add(ContentType.create(mediaType.toString()));
-        } catch (IllegalArgumentException e) {
-          throw new ODataBadRequestException(ODataBadRequestException.INVALID_HEADER.addContent("Accept")
-              .addContent(mediaType.toString()), e);
-        }
-      }
-    }
-
-    return mediaTypes;
-  }
-
-  ContentType contentNegotiation(final List<ContentType> acceptedContentTypes,
-      final List<ContentType> supportedContentTypes) throws ODataException {
-    final Set<ContentType> setSupported = new HashSet<ContentType>(supportedContentTypes);
-
-    if (acceptedContentTypes.isEmpty()) {
-      if (!setSupported.isEmpty()) {
-        return supportedContentTypes.get(0);
-      }
-    } else {
-      for (ContentType contentType : acceptedContentTypes) {
-        contentType = ensureCharset(contentType);
-        final ContentType match = contentType.match(supportedContentTypes);
-        if (match != null) {
-          return match;
-        }
-      }
-    }
-
-    throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_ACCEPT_HEADER
-        .addContent(acceptedContentTypes.toString()));
-  }
-
-  private ContentType ensureCharset(final ContentType contentType) {
-    if (ContentType.APPLICATION_ATOM_XML.isCompatible(contentType)
-        || ContentType.APPLICATION_ATOM_SVC.isCompatible(contentType)
-        || ContentType.APPLICATION_XML.isCompatible(contentType)) {
-      return contentType.receiveWithCharsetParameter(DEFAULT_CHARSET);
-    }
-    return contentType;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/Dispatcher.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/Dispatcher.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/Dispatcher.java
deleted file mode 100644
index 5809bfd..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/Dispatcher.java
+++ /dev/null
@@ -1,309 +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.odata2.core;
-
-import java.io.InputStream;
-
-import org.apache.olingo.odata2.api.ODataService;
-import org.apache.olingo.odata2.api.ODataServiceFactory;
-import org.apache.olingo.odata2.api.batch.BatchHandler;
-import org.apache.olingo.odata2.api.commons.ODataHttpMethod;
-import org.apache.olingo.odata2.api.exception.ODataBadRequestException;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.exception.ODataMethodNotAllowedException;
-import org.apache.olingo.odata2.api.processor.ODataProcessor;
-import org.apache.olingo.odata2.api.processor.ODataResponse;
-import org.apache.olingo.odata2.api.processor.part.BatchProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntityComplexPropertyProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntityLinkProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntityLinksProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntityMediaProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntityProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntitySetProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntitySimplePropertyProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntitySimplePropertyValueProcessor;
-import org.apache.olingo.odata2.api.processor.part.FunctionImportProcessor;
-import org.apache.olingo.odata2.api.processor.part.FunctionImportValueProcessor;
-import org.apache.olingo.odata2.api.processor.part.MetadataProcessor;
-import org.apache.olingo.odata2.api.processor.part.ServiceDocumentProcessor;
-import org.apache.olingo.odata2.core.batch.BatchHandlerImpl;
-import org.apache.olingo.odata2.core.exception.ODataRuntimeException;
-import org.apache.olingo.odata2.core.uri.UriInfoImpl;
-
-/**
- * Request dispatching according to URI type and HTTP method.
- * 
- */
-public class Dispatcher {
-
-  private final ODataService service;
-  private final ODataServiceFactory serviceFactory;
-
-  public Dispatcher(final ODataServiceFactory serviceFactory, final ODataService service) {
-    this.service = service;
-    this.serviceFactory = serviceFactory;
-  }
-
-  public ODataResponse dispatch(final ODataHttpMethod method, final UriInfoImpl uriInfo, final InputStream content,
-      final String requestContentType, final String contentType) throws ODataException {
-    switch (uriInfo.getUriType()) {
-    case URI0:
-      if (method == ODataHttpMethod.GET) {
-        return service.getServiceDocumentProcessor().readServiceDocument(uriInfo, contentType);
-      } else {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-
-    case URI1:
-    case URI6B:
-      switch (method) {
-      case GET:
-        return service.getEntitySetProcessor().readEntitySet(uriInfo, contentType);
-      case POST:
-        return service.getEntitySetProcessor().createEntity(uriInfo, content, requestContentType, contentType);
-      default:
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-
-    case URI2:
-      switch (method) {
-      case GET:
-        return service.getEntityProcessor().readEntity(uriInfo, contentType);
-      case PUT:
-        return service.getEntityProcessor().updateEntity(uriInfo, content, requestContentType, false, contentType);
-      case PATCH:
-      case MERGE:
-        return service.getEntityProcessor().updateEntity(uriInfo, content, requestContentType, true, contentType);
-      case DELETE:
-        return service.getEntityProcessor().deleteEntity(uriInfo, contentType);
-      default:
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-
-    case URI3:
-      switch (method) {
-      case GET:
-        return service.getEntityComplexPropertyProcessor().readEntityComplexProperty(uriInfo, contentType);
-      case PUT:
-        return service.getEntityComplexPropertyProcessor().updateEntityComplexProperty(uriInfo, content,
-            requestContentType, false, contentType);
-      case PATCH:
-      case MERGE:
-        return service.getEntityComplexPropertyProcessor().updateEntityComplexProperty(uriInfo, content,
-            requestContentType, true, contentType);
-      default:
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-
-    case URI4:
-    case URI5:
-      switch (method) {
-      case GET:
-        if (uriInfo.isValue()) {
-          return service.getEntitySimplePropertyValueProcessor().readEntitySimplePropertyValue(uriInfo, contentType);
-        } else {
-          return service.getEntitySimplePropertyProcessor().readEntitySimpleProperty(uriInfo, contentType);
-        }
-      case PUT:
-      case PATCH:
-      case MERGE:
-        if (uriInfo.isValue()) {
-          return service.getEntitySimplePropertyValueProcessor().updateEntitySimplePropertyValue(uriInfo, content,
-              requestContentType, contentType);
-        } else {
-          return service.getEntitySimplePropertyProcessor().updateEntitySimpleProperty(uriInfo, content,
-              requestContentType, contentType);
-        }
-      case DELETE:
-        if (uriInfo.isValue()) {
-          return service.getEntitySimplePropertyValueProcessor().deleteEntitySimplePropertyValue(uriInfo, contentType);
-        } else {
-          throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-        }
-      default:
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-
-    case URI6A:
-      switch (method) {
-      case GET:
-        return service.getEntityProcessor().readEntity(uriInfo, contentType);
-      case PUT:
-      case PATCH:
-      case MERGE:
-      case DELETE:
-        throw new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED);
-      default:
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-
-    case URI7A:
-      switch (method) {
-      case GET:
-        return service.getEntityLinkProcessor().readEntityLink(uriInfo, contentType);
-      case PUT:
-      case PATCH:
-      case MERGE:
-        return service.getEntityLinkProcessor().updateEntityLink(uriInfo, content, requestContentType, contentType);
-      case DELETE:
-        return service.getEntityLinkProcessor().deleteEntityLink(uriInfo, contentType);
-      default:
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-
-    case URI7B:
-      switch (method) {
-      case GET:
-        return service.getEntityLinksProcessor().readEntityLinks(uriInfo, contentType);
-      case POST:
-        return service.getEntityLinksProcessor().createEntityLink(uriInfo, content, requestContentType, contentType);
-      default:
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-
-    case URI8:
-      if (method == ODataHttpMethod.GET) {
-        return service.getMetadataProcessor().readMetadata(uriInfo, contentType);
-      } else {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-
-    case URI9:
-      if (method == ODataHttpMethod.POST) {
-        BatchHandler handler = new BatchHandlerImpl(serviceFactory, service);
-        return service.getBatchProcessor().executeBatch(handler, requestContentType, content);
-      } else {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-
-    case URI10:
-    case URI11:
-    case URI12:
-    case URI13:
-      return service.getFunctionImportProcessor().executeFunctionImport(uriInfo, contentType);
-
-    case URI14:
-      if (uriInfo.isValue()) {
-        return service.getFunctionImportValueProcessor().executeFunctionImportValue(uriInfo, contentType);
-      } else {
-        return service.getFunctionImportProcessor().executeFunctionImport(uriInfo, contentType);
-      }
-
-    case URI15:
-      if (method == ODataHttpMethod.GET) {
-        return service.getEntitySetProcessor().countEntitySet(uriInfo, contentType);
-      } else {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-
-    case URI16:
-      if (method == ODataHttpMethod.GET) {
-        return service.getEntityProcessor().existsEntity(uriInfo, contentType);
-      } else {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-
-    case URI17:
-      switch (method) {
-      case GET:
-        return service.getEntityMediaProcessor().readEntityMedia(uriInfo, contentType);
-      case PUT:
-        return service.getEntityMediaProcessor().updateEntityMedia(uriInfo, content, requestContentType, contentType);
-      case DELETE:
-        return service.getEntityMediaProcessor().deleteEntityMedia(uriInfo, contentType);
-      default:
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-
-    case URI50A:
-      if (method == ODataHttpMethod.GET) {
-        return service.getEntityLinkProcessor().existsEntityLink(uriInfo, contentType);
-      } else {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-
-    case URI50B:
-      if (method == ODataHttpMethod.GET) {
-        return service.getEntityLinksProcessor().countEntityLinks(uriInfo, contentType);
-      } else {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-
-    default:
-      throw new ODataRuntimeException("Unknown or not implemented URI type: " + uriInfo.getUriType());
-    }
-  }
-
-  protected static Class<? extends ODataProcessor> mapUriTypeToProcessorFeature(final UriInfoImpl uriInfo) {
-    Class<? extends ODataProcessor> feature;
-
-    switch (uriInfo.getUriType()) {
-    case URI0:
-      feature = ServiceDocumentProcessor.class;
-      break;
-    case URI1:
-    case URI6B:
-    case URI15:
-      feature = EntitySetProcessor.class;
-      break;
-    case URI2:
-    case URI6A:
-    case URI16:
-      feature = EntityProcessor.class;
-      break;
-    case URI3:
-      feature = EntityComplexPropertyProcessor.class;
-      break;
-    case URI4:
-    case URI5:
-      feature = uriInfo.isValue() ? EntitySimplePropertyValueProcessor.class : EntitySimplePropertyProcessor.class;
-      break;
-    case URI7A:
-    case URI50A:
-      feature = EntityLinkProcessor.class;
-      break;
-    case URI7B:
-    case URI50B:
-      feature = EntityLinksProcessor.class;
-      break;
-    case URI8:
-      feature = MetadataProcessor.class;
-      break;
-    case URI9:
-      feature = BatchProcessor.class;
-      break;
-    case URI10:
-    case URI11:
-    case URI12:
-    case URI13:
-      feature = FunctionImportProcessor.class;
-      break;
-    case URI14:
-      feature = uriInfo.isValue() ? FunctionImportValueProcessor.class : FunctionImportProcessor.class;
-      break;
-    case URI17:
-      feature = EntityMediaProcessor.class;
-      break;
-    default:
-      throw new ODataRuntimeException("Unknown or not implemented URI type: " + uriInfo.getUriType());
-    }
-
-    return feature;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataContextImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataContextImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataContextImpl.java
deleted file mode 100644
index aba98ee..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataContextImpl.java
+++ /dev/null
@@ -1,315 +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.odata2.core;
-
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.ODataDebugCallback;
-import org.apache.olingo.odata2.api.ODataService;
-import org.apache.olingo.odata2.api.ODataServiceFactory;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.processor.ODataContext;
-import org.apache.olingo.odata2.api.processor.ODataRequest;
-import org.apache.olingo.odata2.api.uri.PathInfo;
-import org.apache.olingo.odata2.core.debug.ODataDebugResponseWrapper;
-
-/**
- *  
- */
-public class ODataContextImpl implements ODataContext {
-
-  private static final String ODATA_BATCH_PARENT_CONTEXT = "~odataBatchParentContext";
-  private static final String ODATA_REQUEST = "~odataRequest";
-  private static final String DEBUG_MODE = "~debugMode";
-  private static final String SERVICE = "~service";
-  private static final String SERVICE_FACTORY = "~serviceFactory";
-  private static final String PATH_INFO = "~pathInfo";
-  private static final String RUNTIME_MEASUREMENTS = "~runtimeMeasurements";
-  private static final String HTTP_METHOD = "~httpMethod";
-
-  private Map<String, Object> parameterTable = new HashMap<String, Object>();
-
-  private List<Locale> acceptableLanguages;
-
-  public ODataContextImpl(final ODataRequest request, final ODataServiceFactory factory) {
-    setServiceFactory(factory);
-    setRequest(request);
-    setPathInfo(request.getPathInfo());
-    if (request.getMethod() != null) {
-      setHttpMethod(request.getMethod().name());
-    }
-    setAcceptableLanguages(request.getAcceptableLanguages());
-    setDebugMode(checkDebugMode(request.getQueryParameters()));
-  }
-
-  @Override
-  public void setParameter(final String name, final Object value) {
-    parameterTable.put(name, value);
-  }
-
-  @Override
-  public void removeParameter(final String name) {
-    parameterTable.remove(name);
-  }
-
-  @Override
-  public Object getParameter(final String name) {
-    return parameterTable.get(name);
-  }
-
-  @Override
-  public boolean isInDebugMode() {
-    return getParameter(DEBUG_MODE) != null && (Boolean) getParameter(DEBUG_MODE);
-  }
-
-  @Override
-  public void setDebugMode(final boolean debugMode) {
-    setParameter(DEBUG_MODE, debugMode);
-  }
-
-  public void setService(final ODataService service) {
-    setParameter(SERVICE, service);
-  }
-
-  @Override
-  public ODataService getService() throws ODataException {
-    return (ODataService) getParameter(SERVICE);
-  }
-
-  public void setPathInfo(final PathInfo uriInfo) {
-    setParameter(PATH_INFO, uriInfo);
-  }
-
-  @Override
-  public PathInfo getPathInfo() throws ODataException {
-    return (PathInfo) getParameter(PATH_INFO);
-  }
-
-  public void setServiceFactory(final ODataServiceFactory serviceFactory) {
-    setParameter(SERVICE_FACTORY, serviceFactory);
-  }
-
-  @Override
-  public ODataServiceFactory getServiceFactory() {
-    return (ODataServiceFactory) getParameter(SERVICE_FACTORY);
-  }
-
-  @Override
-  public int startRuntimeMeasurement(final String className, final String methodName) {
-    if (isInDebugMode()) {
-      List<RuntimeMeasurement> runtimeMeasurements = getRuntimeMeasurements();
-      int handleId = runtimeMeasurements.size();
-
-      final RuntimeMeasurement measurement = new RuntimeMeasurementImpl();
-      measurement.setTimeStarted(System.nanoTime());
-      measurement.setClassName(className);
-      measurement.setMethodName(methodName);
-      measurement.setMemoryStarted(ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed());
-
-      runtimeMeasurements.add(measurement);
-
-      return handleId;
-    } else {
-      return 0;
-    }
-  }
-
-  @Override
-  public void stopRuntimeMeasurement(final int handle) {
-    if (isInDebugMode()) {
-      long stopTime = System.nanoTime();
-      long stopMemory = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed();
-
-      RuntimeMeasurement runtimeMeasurement = getRuntimeMeasurement(handle);
-      if (runtimeMeasurement != null) {
-        runtimeMeasurement.setTimeStopped(stopTime);
-        runtimeMeasurement.setMemoryStopped(stopMemory);
-      }
-    }
-  }
-
-  private RuntimeMeasurement getRuntimeMeasurement(final int handle) {
-    List<RuntimeMeasurement> runtimeMeasurements = getRuntimeMeasurements();
-    if (handle >= 0 && handle < runtimeMeasurements.size()) {
-      return runtimeMeasurements.get(handle);
-    }
-    return null;
-  }
-
-  @SuppressWarnings("unchecked")
-  @Override
-  public List<RuntimeMeasurement> getRuntimeMeasurements() {
-    List<RuntimeMeasurement> runtimeMeasurements = (List<RuntimeMeasurement>) getParameter(RUNTIME_MEASUREMENTS);
-    if (runtimeMeasurements == null) {
-      runtimeMeasurements = new ArrayList<RuntimeMeasurement>();
-      setParameter(RUNTIME_MEASUREMENTS, runtimeMeasurements);
-    }
-    return runtimeMeasurements;
-  }
-
-  protected class RuntimeMeasurementImpl implements RuntimeMeasurement {
-    private String className;
-    private String methodName;
-    private long timeStarted;
-    private long timeStopped;
-    private long memoryStarted;
-    private long memoryStopped;
-
-    @Override
-    public void setClassName(final String className) {
-      this.className = className;
-    }
-
-    @Override
-    public String getClassName() {
-      return className;
-    }
-
-    @Override
-    public void setMethodName(final String methodName) {
-      this.methodName = methodName;
-    }
-
-    @Override
-    public String getMethodName() {
-      return methodName;
-    }
-
-    @Override
-    public void setTimeStarted(final long start) {
-      timeStarted = start;
-    }
-
-    @Override
-    public long getTimeStarted() {
-      return timeStarted;
-    }
-
-    @Override
-    public void setTimeStopped(final long stop) {
-      timeStopped = stop;
-    }
-
-    @Override
-    public long getTimeStopped() {
-      return timeStopped;
-    }
-
-    @Override
-    public String toString() {
-      return className + "." + methodName + ": duration: " + (timeStopped - timeStarted) + ", memory: "
-          + (memoryStopped - memoryStarted);
-    }
-
-    @Override
-    public void setMemoryStarted(final long used) {
-      memoryStarted = used;
-    }
-
-    @Override
-    public void setMemoryStopped(final long used) {
-      memoryStopped = used;
-    }
-
-    @Override
-    public long getMemoryStarted() {
-      return memoryStarted;
-    }
-
-    @Override
-    public long getMemoryStopped() {
-      return memoryStopped;
-    }
-  }
-
-  @Override
-  public String getRequestHeader(final String name) {
-    ODataRequest request = (ODataRequest) parameterTable.get(ODATA_REQUEST);
-    return request.getRequestHeaderValue(name);
-  }
-
-  @Override
-  public Map<String, List<String>> getRequestHeaders() {
-    ODataRequest request = (ODataRequest) parameterTable.get(ODATA_REQUEST);
-    return request.getRequestHeaders();
-  }
-
-  @Override
-  public List<Locale> getAcceptableLanguages() {
-    return Collections.unmodifiableList(acceptableLanguages);
-  }
-
-  public void setAcceptableLanguages(final List<Locale> acceptableLanguages) {
-    this.acceptableLanguages = acceptableLanguages;
-
-    if (this.acceptableLanguages.isEmpty()) {
-      final Locale wildcard = new Locale("*");
-      this.acceptableLanguages.add(wildcard);
-    }
-  }
-
-  public void setHttpMethod(final String httpMethod) {
-    setParameter(HTTP_METHOD, httpMethod);
-  }
-
-  @Override
-  public String getHttpMethod() {
-    return (String) getParameter(HTTP_METHOD);
-  }
-
-  public void setRequest(final ODataRequest request) {
-    setParameter(ODATA_REQUEST, request);
-  }
-
-  private boolean checkDebugMode(final Map<String, String> queryParameters) {
-    if (getQueryDebugValue(queryParameters) == null) {
-      return false;
-    } else {
-      final ODataDebugCallback callback = getServiceFactory().getCallback(ODataDebugCallback.class);
-      return callback != null && callback.isDebugEnabled();
-    }
-  }
-
-  private static String getQueryDebugValue(final Map<String, String> queryParameters) {
-    final String debugValue = queryParameters.get(ODataDebugResponseWrapper.ODATA_DEBUG_QUERY_PARAMETER);
-    return ODataDebugResponseWrapper.ODATA_DEBUG_JSON.equals(debugValue) ?
-        debugValue : null;
-  }
-
-  public void setBatchParentContext(final ODataContext ctx) {
-    setParameter(ODATA_BATCH_PARENT_CONTEXT, ctx);
-  }
-
-  @Override
-  public ODataContext getBatchParentContext() {
-    return (ODataContext) parameterTable.get(ODATA_BATCH_PARENT_CONTEXT);
-  }
-
-  @Override
-  public boolean isInBatchMode() {
-    return parameterTable.containsKey(ODATA_BATCH_PARENT_CONTEXT);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataExceptionWrapper.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataExceptionWrapper.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataExceptionWrapper.java
deleted file mode 100644
index 4d4fad8..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataExceptionWrapper.java
+++ /dev/null
@@ -1,354 +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.odata2.core;
-
-import java.net.URI;
-import java.text.ParseException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.olingo.odata2.api.ODataServiceFactory;
-import org.apache.olingo.odata2.api.batch.BatchException;
-import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
-import org.apache.olingo.odata2.api.ep.EntityProvider;
-import org.apache.olingo.odata2.api.ep.EntityProviderException;
-import org.apache.olingo.odata2.api.exception.MessageReference;
-import org.apache.olingo.odata2.api.exception.ODataApplicationException;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.exception.ODataHttpException;
-import org.apache.olingo.odata2.api.exception.ODataMessageException;
-import org.apache.olingo.odata2.api.processor.ODataContext;
-import org.apache.olingo.odata2.api.processor.ODataErrorCallback;
-import org.apache.olingo.odata2.api.processor.ODataErrorContext;
-import org.apache.olingo.odata2.api.processor.ODataResponse;
-import org.apache.olingo.odata2.core.commons.ContentType;
-import org.apache.olingo.odata2.core.ep.ProviderFacadeImpl;
-import org.apache.olingo.odata2.core.exception.MessageService;
-import org.apache.olingo.odata2.core.exception.MessageService.Message;
-import org.apache.olingo.odata2.core.exception.ODataRuntimeException;
-
-/**
- *  
- */
-public class ODataExceptionWrapper {
-
-  private static final String DOLLAR_FORMAT = "$format";
-  private static final String DOLLAR_FORMAT_JSON = "json";
-  private static final Locale DEFAULT_RESPONSE_LOCALE = Locale.ENGLISH;
-
-  private final String contentType;
-  private final Locale messageLocale;
-  private final Map<String, List<String>> httpRequestHeaders;
-  private final ODataErrorCallback callback;
-  private final ODataErrorContext errorContext = new ODataErrorContext();
-  private final URI requestUri;
-
-  public ODataExceptionWrapper(final ODataContext context, final Map<String, String> queryParameters,
-      final List<String> acceptHeaderContentTypes) {
-    contentType = getContentType(queryParameters, acceptHeaderContentTypes).toContentTypeString();
-    messageLocale = MessageService.getSupportedLocale(getLanguages(context), DEFAULT_RESPONSE_LOCALE);
-    httpRequestHeaders = context.getRequestHeaders();
-    try {
-      requestUri = context.getPathInfo().getRequestUri();
-      errorContext.setPathInfo(context.getPathInfo());
-      callback = getErrorHandlerCallbackFromContext(context);
-    } catch (Exception e) {
-      throw new ODataRuntimeException("Exception occurred", e);
-    }
-  }
-
-  public ODataExceptionWrapper(final UriInfo uriInfo, final HttpHeaders httpHeaders, final ServletConfig servletConfig,
-      final HttpServletRequest servletRequest) {
-    contentType = getContentType(uriInfo, httpHeaders).toContentTypeString();
-    messageLocale = MessageService.getSupportedLocale(getLanguages(httpHeaders), DEFAULT_RESPONSE_LOCALE);
-    httpRequestHeaders = httpHeaders.getRequestHeaders();
-    requestUri = uriInfo.getRequestUri();
-    try {
-      callback = getErrorHandlerCallbackFromServletConfig(servletConfig, servletRequest);
-    } catch (Exception e) {
-      throw new ODataRuntimeException("Exception occurred", e);
-    }
-  }
-
-  public ODataResponse wrapInExceptionResponse(final Exception exception) {
-    try {
-      final Exception toHandleException = extractException(exception);
-      fillErrorContext(toHandleException);
-      if (toHandleException instanceof ODataApplicationException) {
-        enhanceContextWithApplicationException((ODataApplicationException) toHandleException);
-      } else if (toHandleException instanceof ODataMessageException) {
-        enhanceContextWithMessageException((ODataMessageException) toHandleException);
-      }
-
-      ODataResponse oDataResponse;
-      if (callback != null) {
-        oDataResponse = handleErrorCallback(callback);
-      } else {
-        oDataResponse = EntityProvider.writeErrorDocument(errorContext);
-      }
-      if (!oDataResponse.containsHeader(org.apache.olingo.odata2.api.commons.HttpHeaders.CONTENT_TYPE)) {
-        oDataResponse = ODataResponse.fromResponse(oDataResponse).contentHeader(contentType).build();
-      }
-      return oDataResponse;
-    } catch (Exception e) {
-      ODataResponse response = ODataResponse.entity("Exception during error handling occured!")
-          .contentHeader(ContentType.TEXT_PLAIN.toContentTypeString())
-          .status(HttpStatusCodes.INTERNAL_SERVER_ERROR).build();
-      return response;
-    }
-  }
-
-  private ODataResponse handleErrorCallback(final ODataErrorCallback callback) throws EntityProviderException {
-    ODataResponse oDataResponse;
-    try {
-      oDataResponse = callback.handleError(errorContext);
-    } catch (ODataApplicationException e) {
-      fillErrorContext(e);
-      enhanceContextWithApplicationException(e);
-      oDataResponse = new ProviderFacadeImpl().writeErrorDocument(errorContext);
-    }
-    return oDataResponse;
-  }
-
-  private void enhanceContextWithApplicationException(final ODataApplicationException toHandleException) {
-    errorContext.setHttpStatus(toHandleException.getHttpStatus());
-    errorContext.setErrorCode(toHandleException.getCode());
-  }
-
-  private void enhanceContextWithMessageException(final ODataMessageException toHandleException) {
-    errorContext.setErrorCode(toHandleException.getErrorCode());
-    MessageReference messageReference = toHandleException.getMessageReference();
-    Message localizedMessage = messageReference == null ? null : extractEntity(messageReference);
-    if (localizedMessage != null) {
-      errorContext.setMessage(localizedMessage.getText());
-      errorContext.setLocale(localizedMessage.getLocale());
-    }
-    if (toHandleException instanceof ODataHttpException) {
-      errorContext.setHttpStatus(((ODataHttpException) toHandleException).getHttpStatus());
-    } else if (toHandleException instanceof EntityProviderException) {
-      errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST);
-    } else if (toHandleException instanceof BatchException) {
-      errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST);
-    }
-
-  }
-
-  /**
-   * Fill current error context ({@link #errorContext}) with values from given {@link Exception} parameter.
-   * 
-   * @param exception exception with values to be set on error context
-   */
-  private void fillErrorContext(final Exception exception) {
-    errorContext.setContentType(contentType);
-    errorContext.setException(exception);
-    errorContext.setHttpStatus(HttpStatusCodes.INTERNAL_SERVER_ERROR);
-    errorContext.setErrorCode(null);
-    errorContext.setMessage(exception.getMessage());
-    errorContext.setLocale(DEFAULT_RESPONSE_LOCALE);
-    errorContext.setRequestUri(requestUri);
-
-    if (httpRequestHeaders != null) {
-      for (Entry<String, List<String>> entry : httpRequestHeaders.entrySet()) {
-        errorContext.putRequestHeader(entry.getKey(), entry.getValue());
-      }
-    }
-  }
-
-  private Exception extractException(final Exception exception) {
-    if (exception instanceof ODataException) {
-      ODataException odataException = (ODataException) exception;
-      if (odataException.isCausedByApplicationException()) {
-        return odataException.getApplicationExceptionCause();
-      } else if (odataException.isCausedByHttpException()) {
-        return odataException.getHttpExceptionCause();
-      } else if (odataException.isCausedByMessageException()) {
-        return odataException.getMessageExceptionCause();
-      }
-    }
-    return exception;
-  }
-
-  private Message extractEntity(final MessageReference context) {
-    return MessageService.getMessage(messageLocale, context);
-  }
-
-  private List<Locale> getLanguages(final ODataContext context) {
-    try {
-      if (context.getAcceptableLanguages().isEmpty()) {
-        return Arrays.asList(DEFAULT_RESPONSE_LOCALE);
-      }
-      return context.getAcceptableLanguages();
-    } catch (WebApplicationException e) {
-      if (e.getCause() != null && e.getCause().getClass() == ParseException.class) {
-        // invalid accept-language string in http header
-        // compensate exception with using default locale
-        return Arrays.asList(DEFAULT_RESPONSE_LOCALE);
-      }
-      // not able to compensate exception -> re-throw
-      throw e;
-    }
-  }
-
-  private List<Locale> getLanguages(final HttpHeaders httpHeaders) {
-    try {
-      if (httpHeaders.getAcceptableLanguages().isEmpty()) {
-        return Arrays.asList(DEFAULT_RESPONSE_LOCALE);
-      }
-      return httpHeaders.getAcceptableLanguages();
-    } catch (WebApplicationException e) {
-      if (e.getCause() != null && e.getCause().getClass() == ParseException.class) {
-        // invalid accept-language string in http header
-        // compensate exception with using default locale
-        return Arrays.asList(DEFAULT_RESPONSE_LOCALE);
-      }
-      // not able to compensate exception -> re-throw
-      throw e;
-    }
-  }
-
-  private ContentType getContentType(final Map<String, String> queryParameters,
-      final List<String> acceptHeaderContentTypes) {
-    ContentType contentType = getContentTypeByUriInfo(queryParameters);
-    if (contentType == null) {
-      contentType = getContentTypeByAcceptHeader(acceptHeaderContentTypes);
-    }
-    return contentType;
-  }
-
-  private ContentType getContentTypeByUriInfo(final Map<String, String> queryParameters) {
-    ContentType contentType = null;
-    if (queryParameters != null) {
-      if (queryParameters.containsKey(DOLLAR_FORMAT)) {
-        String contentTypeString = queryParameters.get(DOLLAR_FORMAT);
-        if (DOLLAR_FORMAT_JSON.equals(contentTypeString)) {
-          contentType = ContentType.APPLICATION_JSON;
-        } else {
-          // Any format mentioned in the $format parameter other than json results in an application/xml content type
-          // for error messages
-          // due to the OData V2 Specification
-          contentType = ContentType.APPLICATION_XML;
-        }
-      }
-    }
-    return contentType;
-  }
-
-  private ContentType getContentTypeByAcceptHeader(final List<String> acceptHeaderContentTypes) {
-    for (String acceptContentType : acceptHeaderContentTypes) {
-      if (ContentType.isParseable(acceptContentType)) {
-        ContentType convertedContentType = ContentType.create(acceptContentType);
-        if (convertedContentType.isWildcard()
-            || ContentType.APPLICATION_XML.equals(convertedContentType)
-            || ContentType.APPLICATION_XML_CS_UTF_8.equals(convertedContentType)
-            || ContentType.APPLICATION_ATOM_XML.equals(convertedContentType)
-            || ContentType.APPLICATION_ATOM_XML_CS_UTF_8.equals(convertedContentType)) {
-          return ContentType.APPLICATION_XML;
-        } else if (ContentType.APPLICATION_JSON.equals(convertedContentType)
-            || ContentType.APPLICATION_JSON_CS_UTF_8.equals(convertedContentType)) {
-          return ContentType.APPLICATION_JSON;
-        }
-      }
-    }
-    return ContentType.APPLICATION_XML;
-  }
-
-  private ContentType getContentType(final UriInfo uriInfo, final HttpHeaders httpHeaders) {
-    ContentType contentType = getContentTypeByUriInfo(uriInfo);
-    if (contentType == null) {
-      contentType = getContentTypeByAcceptHeader(httpHeaders);
-    }
-    return contentType;
-  }
-
-  private ContentType getContentTypeByUriInfo(final UriInfo uriInfo) {
-    ContentType contentType = null;
-    if (uriInfo != null && uriInfo.getQueryParameters() != null) {
-      MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();
-      if (queryParameters.containsKey(DOLLAR_FORMAT)) {
-        String contentTypeString = queryParameters.getFirst(DOLLAR_FORMAT);
-        if (DOLLAR_FORMAT_JSON.equals(contentTypeString)) {
-          contentType = ContentType.APPLICATION_JSON;
-        } else {
-          // Any format mentioned in the $format parameter other than json results in an application/xml content type
-          // for error messages due to the OData V2 Specification.
-          contentType = ContentType.APPLICATION_XML;
-        }
-      }
-    }
-    return contentType;
-  }
-
-  private ContentType getContentTypeByAcceptHeader(final HttpHeaders httpHeaders) {
-    for (MediaType type : httpHeaders.getAcceptableMediaTypes()) {
-      if (ContentType.isParseable(type.toString())) {
-        ContentType convertedContentType = ContentType.create(type.toString());
-        if (convertedContentType.isWildcard()
-            || ContentType.APPLICATION_XML.equals(convertedContentType)
-            || ContentType.APPLICATION_XML_CS_UTF_8.equals(convertedContentType)
-            || ContentType.APPLICATION_ATOM_XML.equals(convertedContentType)
-            || ContentType.APPLICATION_ATOM_XML_CS_UTF_8.equals(convertedContentType)) {
-          return ContentType.APPLICATION_XML;
-        } else if (ContentType.APPLICATION_JSON.equals(convertedContentType)
-            || ContentType.APPLICATION_JSON_CS_UTF_8.equals(convertedContentType)) {
-          return ContentType.APPLICATION_JSON;
-        }
-      }
-    }
-    return ContentType.APPLICATION_XML;
-  }
-
-  private ODataErrorCallback getErrorHandlerCallbackFromContext(final ODataContext context)
-      throws ClassNotFoundException, InstantiationException, IllegalAccessException {
-    ODataErrorCallback callback = null;
-    ODataServiceFactory serviceFactory = context.getServiceFactory();
-    callback = serviceFactory.getCallback(ODataErrorCallback.class);
-    return callback;
-  }
-
-  private ODataErrorCallback getErrorHandlerCallbackFromServletConfig(final ServletConfig servletConfig,
-      final HttpServletRequest servletRequest) throws InstantiationException, IllegalAccessException,
-      ClassNotFoundException {
-    ODataErrorCallback callback = null;
-    final String factoryClassName = servletConfig.getInitParameter(ODataServiceFactory.FACTORY_LABEL);
-    if (factoryClassName != null) {
-      ClassLoader cl = (ClassLoader) servletRequest.getAttribute(ODataServiceFactory.FACTORY_CLASSLOADER_LABEL);
-      Class<?> factoryClass;
-      if (cl == null) {
-        factoryClass = Class.forName(factoryClassName);
-      } else {
-        factoryClass = Class.forName(factoryClassName, true, cl);
-      }
-      final ODataServiceFactory serviceFactory = (ODataServiceFactory) factoryClass.newInstance();
-
-      callback = serviceFactory.getCallback(ODataErrorCallback.class);
-    }
-    return callback;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataPathSegmentImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataPathSegmentImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataPathSegmentImpl.java
deleted file mode 100644
index 94de51d..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataPathSegmentImpl.java
+++ /dev/null
@@ -1,60 +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.odata2.core;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.uri.PathSegment;
-
-/**
- *  
- */
-public class ODataPathSegmentImpl implements PathSegment {
-
-  private String path;
-  private Map<String, List<String>> matrixParameter;
-
-  public ODataPathSegmentImpl(final String path, final Map<String, List<String>> matrixParameters) {
-    this.path = path;
-
-    Map<String, List<String>> unmodifiableMap = new HashMap<String, List<String>>();
-    if (matrixParameters != null) {
-      for (String key : matrixParameters.keySet()) {
-        List<String> values = Collections.unmodifiableList(matrixParameters.get(key));
-        unmodifiableMap.put(key, values);
-      }
-    }
-
-    matrixParameter = Collections.unmodifiableMap(unmodifiableMap);
-  }
-
-  @Override
-  public String getPath() {
-    return path;
-  }
-
-  @Override
-  public Map<String, List<String>> getMatrixParameters() {
-    return matrixParameter;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/57599da6/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataRequestHandler.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataRequestHandler.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataRequestHandler.java
deleted file mode 100644
index d9dc33a..0000000
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ODataRequestHandler.java
+++ /dev/null
@@ -1,486 +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.odata2.core;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.olingo.odata2.api.ODataService;
-import org.apache.olingo.odata2.api.ODataServiceFactory;
-import org.apache.olingo.odata2.api.ODataServiceVersion;
-import org.apache.olingo.odata2.api.commons.HttpHeaders;
-import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
-import org.apache.olingo.odata2.api.commons.ODataHttpHeaders;
-import org.apache.olingo.odata2.api.commons.ODataHttpMethod;
-import org.apache.olingo.odata2.api.edm.EdmException;
-import org.apache.olingo.odata2.api.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
-import org.apache.olingo.odata2.api.exception.ODataBadRequestException;
-import org.apache.olingo.odata2.api.exception.ODataException;
-import org.apache.olingo.odata2.api.exception.ODataMethodNotAllowedException;
-import org.apache.olingo.odata2.api.exception.ODataUnsupportedMediaTypeException;
-import org.apache.olingo.odata2.api.processor.ODataContext;
-import org.apache.olingo.odata2.api.processor.ODataProcessor;
-import org.apache.olingo.odata2.api.processor.ODataRequest;
-import org.apache.olingo.odata2.api.processor.ODataResponse;
-import org.apache.olingo.odata2.api.processor.ODataResponse.ODataResponseBuilder;
-import org.apache.olingo.odata2.api.processor.part.EntityLinkProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntityLinksProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntityMediaProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntityProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntitySetProcessor;
-import org.apache.olingo.odata2.api.processor.part.EntitySimplePropertyValueProcessor;
-import org.apache.olingo.odata2.api.processor.part.FunctionImportProcessor;
-import org.apache.olingo.odata2.api.processor.part.FunctionImportValueProcessor;
-import org.apache.olingo.odata2.api.uri.PathSegment;
-import org.apache.olingo.odata2.api.uri.UriInfo;
-import org.apache.olingo.odata2.api.uri.UriParser;
-import org.apache.olingo.odata2.core.commons.ContentType;
-import org.apache.olingo.odata2.core.commons.ContentType.ODataFormat;
-import org.apache.olingo.odata2.core.debug.ODataDebugResponseWrapper;
-import org.apache.olingo.odata2.core.exception.ODataRuntimeException;
-import org.apache.olingo.odata2.core.uri.UriInfoImpl;
-import org.apache.olingo.odata2.core.uri.UriParserImpl;
-import org.apache.olingo.odata2.core.uri.UriType;
-
-/**
- *  
- */
-public class ODataRequestHandler {
-
-  private final ODataServiceFactory serviceFactory;
-  private final ODataService service;
-  private final ODataContext context;
-
-  public ODataRequestHandler(final ODataServiceFactory factory, final ODataService service, 
-      final ODataContext context) {
-    serviceFactory = factory;
-    this.service = service;
-    this.context = context;
-  }
-
-  /**
-   * <p>Handles the {@link ODataRequest} in a way that it results in a corresponding {@link ODataResponse}.</p>
-   * <p>This includes delegation of URI parsing and dispatching of the request internally.
-   * Building of the {@link ODataContext} takes place outside of this method.</p>
-   * @param request the incoming request
-   * @return the corresponding result
-   */
-  public ODataResponse handle(final ODataRequest request) {
-    UriInfoImpl uriInfo = null;
-    Exception exception = null;
-    ODataResponse odataResponse;
-    final int timingHandle = context.startRuntimeMeasurement("ODataRequestHandler", "handle");
-    try {
-      UriParser uriParser = new UriParserImpl(service.getEntityDataModel());
-      Dispatcher dispatcher = new Dispatcher(serviceFactory, service);
-
-      final String serverDataServiceVersion = getServerDataServiceVersion();
-      final String requestDataServiceVersion = context.getRequestHeader(ODataHttpHeaders.DATASERVICEVERSION);
-      validateDataServiceVersion(serverDataServiceVersion, requestDataServiceVersion);
-
-      final List<PathSegment> pathSegments = context.getPathInfo().getODataSegments();
-      int timingHandle2 = context.startRuntimeMeasurement("UriParserImpl", "parse");
-      uriInfo = (UriInfoImpl) uriParser.parse(pathSegments, request.getQueryParameters());
-      context.stopRuntimeMeasurement(timingHandle2);
-
-      final ODataHttpMethod method = request.getMethod();
-      validateMethodAndUri(method, uriInfo);
-
-      if (method == ODataHttpMethod.POST || method == ODataHttpMethod.PUT || method == ODataHttpMethod.PATCH
-          || method == ODataHttpMethod.MERGE) {
-        checkRequestContentType(uriInfo, request.getContentType());
-      }
-
-      List<String> supportedContentTypes = getSupportedContentTypes(uriInfo, method);
-      ContentType acceptContentType =
-          new ContentNegotiator().doContentNegotiation(request, uriInfo, supportedContentTypes);
-
-      timingHandle2 = context.startRuntimeMeasurement("Dispatcher", "dispatch");
-      odataResponse =
-          dispatcher.dispatch(method, uriInfo, request.getBody(), request.getContentType(), acceptContentType
-              .toContentTypeString());
-      context.stopRuntimeMeasurement(timingHandle2);
-
-      ODataResponseBuilder extendedResponse = ODataResponse.fromResponse(odataResponse);
-      final UriType uriType = uriInfo.getUriType();
-      final String location =
-          (method == ODataHttpMethod.POST && (uriType == UriType.URI1 || uriType == UriType.URI6B)) ? odataResponse
-              .getIdLiteral() : null;
-      final HttpStatusCodes s = getStatusCode(odataResponse, method, uriType);
-      extendedResponse = extendedResponse.idLiteral(location).status(s);
-
-      if (!odataResponse.containsHeader(ODataHttpHeaders.DATASERVICEVERSION)) {
-        extendedResponse = extendedResponse.header(ODataHttpHeaders.DATASERVICEVERSION, serverDataServiceVersion);
-      }
-      if (!HttpStatusCodes.NO_CONTENT.equals(s) && !odataResponse.containsHeader(HttpHeaders.CONTENT_TYPE)) {
-        extendedResponse.header(HttpHeaders.CONTENT_TYPE, acceptContentType.toContentTypeString());
-      }
-
-      odataResponse = extendedResponse.build();
-    } catch (final Exception e) {
-      exception = e;
-      odataResponse =
-          new ODataExceptionWrapper(context, request.getQueryParameters(), request.getAcceptHeaders())
-              .wrapInExceptionResponse(e);
-    }
-    context.stopRuntimeMeasurement(timingHandle);
-
-    final String debugValue = getDebugValue(context, request.getQueryParameters());
-    return debugValue == null ? odataResponse : new ODataDebugResponseWrapper(context, odataResponse, uriInfo,
-        exception, debugValue).wrapResponse();
-  }
-
-  private HttpStatusCodes getStatusCode(final ODataResponse odataResponse, final ODataHttpMethod method,
-      final UriType uriType) {
-    if (odataResponse.getStatus() == null) {
-      if (method == ODataHttpMethod.POST) {
-        if (uriType == UriType.URI9) {
-          return HttpStatusCodes.OK;
-        } else if (uriType == UriType.URI7B) {
-          return HttpStatusCodes.NO_CONTENT;
-        }
-        return HttpStatusCodes.CREATED;
-      } else if (method == ODataHttpMethod.PUT
-          || method == ODataHttpMethod.PATCH
-          || method == ODataHttpMethod.MERGE
-          || method == ODataHttpMethod.DELETE) {
-        return HttpStatusCodes.NO_CONTENT;
-      }
-      return HttpStatusCodes.OK;
-    }
-    return odataResponse.getStatus();
-  }
-
-  private String getServerDataServiceVersion() throws ODataException {
-    return service.getVersion() == null ? ODataServiceVersion.V20 : service.getVersion();
-  }
-
-  private static void validateDataServiceVersion(final String serverDataServiceVersion,
-      final String requestDataServiceVersion) throws ODataException {
-    if (requestDataServiceVersion != null) {
-      try {
-        final boolean isValid = ODataServiceVersion.validateDataServiceVersion(requestDataServiceVersion);
-        if (!isValid || ODataServiceVersion.isBiggerThan(requestDataServiceVersion, serverDataServiceVersion)) {
-          throw new ODataBadRequestException(ODataBadRequestException.VERSIONERROR.addContent(requestDataServiceVersion
-              .toString()));
-        }
-      } catch (final IllegalArgumentException e) {
-        throw new ODataBadRequestException(ODataBadRequestException.PARSEVERSIONERROR
-            .addContent(requestDataServiceVersion), e);
-      }
-    }
-  }
-
-  private static void validateMethodAndUri(final ODataHttpMethod method, final UriInfoImpl uriInfo)
-      throws ODataException {
-    validateUriMethod(method, uriInfo);
-    checkFunctionImport(method, uriInfo);
-    if (method != ODataHttpMethod.GET) {
-      checkNotGetSystemQueryOptions(method, uriInfo);
-      checkNumberOfNavigationSegments(uriInfo);
-      checkProperty(method, uriInfo);
-    }
-  }
-
-  private static void validateUriMethod(final ODataHttpMethod method, final UriInfoImpl uriInfo) throws ODataException {
-    switch (uriInfo.getUriType()) {
-    case URI0:
-    case URI8:
-    case URI15:
-    case URI16:
-    case URI50A:
-    case URI50B:
-      if (method != ODataHttpMethod.GET) {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-      break;
-
-    case URI1:
-    case URI6B:
-    case URI7B:
-      if (method != ODataHttpMethod.GET && method != ODataHttpMethod.POST) {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-      break;
-
-    case URI2:
-    case URI6A:
-    case URI7A:
-      if (method != ODataHttpMethod.GET && method != ODataHttpMethod.PUT && method != ODataHttpMethod.DELETE
-          && method != ODataHttpMethod.PATCH && method != ODataHttpMethod.MERGE) {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-      break;
-
-    case URI3:
-      if (method != ODataHttpMethod.GET && method != ODataHttpMethod.PUT && method != ODataHttpMethod.PATCH
-          && method != ODataHttpMethod.MERGE) {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-      break;
-
-    case URI4:
-    case URI5:
-      if (method != ODataHttpMethod.GET && method != ODataHttpMethod.PUT && method != ODataHttpMethod.DELETE
-          && method != ODataHttpMethod.PATCH && method != ODataHttpMethod.MERGE) {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      } else if (method == ODataHttpMethod.DELETE && !uriInfo.isValue()) {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-      break;
-
-    case URI9:
-      if (method != ODataHttpMethod.POST) {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-      break;
-
-    case URI10:
-    case URI11:
-    case URI12:
-    case URI13:
-    case URI14:
-      break;
-
-    case URI17:
-      if (method != ODataHttpMethod.GET && method != ODataHttpMethod.PUT && method != ODataHttpMethod.DELETE) {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      } else {
-        if (uriInfo.getFormat() != null) {
-//          throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-          throw new ODataBadRequestException(ODataBadRequestException.INVALID_SYNTAX);
-        }
-      }
-      break;
-
-    default:
-      throw new ODataRuntimeException("Unknown or not implemented URI type: " + uriInfo.getUriType());
-    }
-  }
-
-  private static void checkFunctionImport(final ODataHttpMethod method, final UriInfoImpl uriInfo)
-      throws ODataException {
-    if (uriInfo.getFunctionImport() != null && uriInfo.getFunctionImport().getHttpMethod() != null
-        && !uriInfo.getFunctionImport().getHttpMethod().equals(method.toString())) {
-      throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-    }
-  }
-
-  private static void checkNotGetSystemQueryOptions(final ODataHttpMethod method, final UriInfoImpl uriInfo)
-      throws ODataException {
-    switch (uriInfo.getUriType()) {
-    case URI1:
-    case URI6B:
-      if (uriInfo.getFormat() != null || uriInfo.getFilter() != null || uriInfo.getInlineCount() != null
-          || uriInfo.getOrderBy() != null || uriInfo.getSkipToken() != null || uriInfo.getSkip() != null
-          || uriInfo.getTop() != null || !uriInfo.getExpand().isEmpty() || !uriInfo.getSelect().isEmpty()) {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-      break;
-
-    case URI2:
-      if (uriInfo.getFormat() != null || !uriInfo.getExpand().isEmpty() || !uriInfo.getSelect().isEmpty()) {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-      if (method == ODataHttpMethod.DELETE) {
-        if (uriInfo.getFilter() != null) {
-          throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-        }
-      }
-      break;
-
-    case URI3:
-      if (uriInfo.getFormat() != null) {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-      break;
-
-    case URI4:
-    case URI5:
-      if (method == ODataHttpMethod.PUT || method == ODataHttpMethod.PATCH || method == ODataHttpMethod.MERGE) {
-        if (!uriInfo.isValue() && uriInfo.getFormat() != null) {
-          throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-        }
-      }
-      break;
-
-    case URI7A:
-      if (uriInfo.getFormat() != null || uriInfo.getFilter() != null) {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-      break;
-
-    case URI7B:
-      if (uriInfo.getFormat() != null || uriInfo.getFilter() != null || uriInfo.getInlineCount() != null
-          || uriInfo.getOrderBy() != null || uriInfo.getSkipToken() != null || uriInfo.getSkip() != null
-          || uriInfo.getTop() != null) {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-      break;
-
-    case URI17:
-      if (uriInfo.getFormat() != null || uriInfo.getFilter() != null) {
-        throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-      }
-      break;
-
-    default:
-      break;
-    }
-  }
-
-  private static void checkNumberOfNavigationSegments(final UriInfoImpl uriInfo) throws ODataException {
-    switch (uriInfo.getUriType()) {
-    case URI1:
-    case URI6B:
-    case URI7A:
-    case URI7B:
-      if (uriInfo.getNavigationSegments().size() > 1) {
-        throw new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED);
-      }
-      break;
-
-    case URI3:
-    case URI4:
-    case URI5:
-    case URI17:
-      if (!uriInfo.getNavigationSegments().isEmpty()) {
-        throw new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED);
-      }
-      break;
-
-    default:
-      break;
-    }
-  }
-
-  private static void checkProperty(final ODataHttpMethod method, final UriInfoImpl uriInfo) throws ODataException {
-    if ((uriInfo.getUriType() == UriType.URI4 || uriInfo.getUriType() == UriType.URI5)
-        && (isPropertyKey(uriInfo) || method == ODataHttpMethod.DELETE && !isPropertyNullable(getProperty(uriInfo)))) {
-      throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
-    }
-  }
-
-  private static EdmProperty getProperty(final UriInfo uriInfo) {
-    final List<EdmProperty> propertyPath = uriInfo.getPropertyPath();
-    return propertyPath == null || propertyPath.isEmpty() ? null : propertyPath.get(propertyPath.size() - 1);
-  }
-
-  private static boolean isPropertyKey(final UriInfo uriInfo) throws EdmException {
-    return uriInfo.getTargetEntitySet().getEntityType().getKeyProperties().contains(getProperty(uriInfo));
-  }
-
-  private static boolean isPropertyNullable(final EdmProperty property) throws EdmException {
-    return property.getFacets() == null || property.getFacets().isNullable();
-  }
-
-  /**
-   * <p>Checks if <code>content type</code> is a valid request content type for the given {@link UriInfoImpl}.</p>
-   * <p>If the combination of <code>content type</code> and {@link UriInfoImpl} is not valid, an
-   * {@link ODataUnsupportedMediaTypeException} is thrown.</p>
-   * @param uriInfo information about request URI
-   * @param contentType request content type
-   * @throws ODataException in the case of an error during {@link UriInfoImpl} access;
-   * if the combination of <code>content type</code> and {@link UriInfoImpl} is invalid, as
-   * {@link ODataUnsupportedMediaTypeException}
-   */
-  private void checkRequestContentType(final UriInfoImpl uriInfo, final String contentType) throws ODataException {
-    Class<? extends ODataProcessor> processorFeature = Dispatcher.mapUriTypeToProcessorFeature(uriInfo);
-
-    // Don't check the request content type for function imports
-    // because the request body is not used at all.
-    if (processorFeature == FunctionImportProcessor.class || processorFeature == FunctionImportValueProcessor.class) {
-      return;
-    }
-
-    // Adjust processor feature.
-    if (processorFeature == EntitySetProcessor.class) {
-      processorFeature = uriInfo.getTargetEntitySet().getEntityType().hasStream() ? EntityMediaProcessor.class : 
-          EntityProcessor.class; // The request must contain a single entity!
-    } else if (processorFeature == EntityLinksProcessor.class) {
-      processorFeature = EntityLinkProcessor.class; // The request must contain a single link!
-    }
-
-    final ContentType parsedContentType = ContentType.parse(contentType);
-    if (parsedContentType == null || parsedContentType.hasWildcard()) {
-      throw new ODataUnsupportedMediaTypeException(ODataUnsupportedMediaTypeException.NOT_SUPPORTED
-          .addContent(parsedContentType));
-    }
-
-    // Get list of supported content types based on processor feature.
-    final List<ContentType> supportedContentTypes =
-        processorFeature == EntitySimplePropertyValueProcessor.class ? getSupportedContentTypes(getProperty(uriInfo))
-            : getSupportedContentTypes(processorFeature);
-
-    if (!hasMatchingContentType(parsedContentType, supportedContentTypes)) {
-      throw new ODataUnsupportedMediaTypeException(ODataUnsupportedMediaTypeException.NOT_SUPPORTED
-          .addContent(parsedContentType));
-    }
-  }
-
-  /**
-   * Checks if the given list of {@link ContentType}s contains a matching {@link ContentType} for the given
-   * <code>contentType</code> parameter.
-   * @param contentType for which a matching content type is searched
-   * @param allowedContentTypes list against which is checked for possible matching {@link ContentType}s
-   * @return <code>true</code> if a matching content type is in given list, otherwise <code>false</code>
-   */
-  private static boolean hasMatchingContentType(final ContentType contentType,
-      final List<ContentType> allowedContentTypes) {
-    final ContentType requested = contentType.receiveWithCharsetParameter(ContentNegotiator.DEFAULT_CHARSET);
-    if (requested.getODataFormat() == ODataFormat.CUSTOM || requested.getODataFormat() == ODataFormat.MIME) {
-      return requested.hasCompatible(allowedContentTypes);
-    }
-    return requested.hasMatch(allowedContentTypes);
-  }
-
-  private static List<ContentType> getSupportedContentTypes(final EdmProperty property) throws EdmException {
-    return property.getType() == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance() ? Arrays.asList(property
-        .getMimeType() == null ? ContentType.WILDCARD : ContentType.create(property.getMimeType())) : Arrays.asList(
-        ContentType.TEXT_PLAIN, ContentType.TEXT_PLAIN_CS_UTF_8);
-  }
-
-  private List<String> getSupportedContentTypes(final UriInfoImpl uriInfo, final ODataHttpMethod method)
-      throws ODataException {
-    Class<? extends ODataProcessor> processorFeature = Dispatcher.mapUriTypeToProcessorFeature(uriInfo);
-    if (ODataHttpMethod.POST.equals(method)) {
-      UriType uriType = uriInfo.getUriType();
-      if (uriType == UriType.URI1 || uriType == UriType.URI6B) {
-        processorFeature = EntityProcessor.class;
-      }
-    }
-    return service.getSupportedContentTypes(processorFeature);
-  }
-
-  private List<ContentType> getSupportedContentTypes(final Class<? extends ODataProcessor> processorFeature)
-      throws ODataException {
-    return ContentType.createAsCustom(service.getSupportedContentTypes(processorFeature));
-  }
-
-  private static String getDebugValue(final ODataContext context, final Map<String, String> queryParameters) {
-    return context.isInDebugMode() ? getQueryDebugValue(queryParameters) : null;
-  }
-
-  private static String getQueryDebugValue(final Map<String, String> queryParameters) {
-    final String debugValue = queryParameters.get(ODataDebugResponseWrapper.ODATA_DEBUG_QUERY_PARAMETER);
-    return ODataDebugResponseWrapper.ODATA_DEBUG_JSON.equals(debugValue) ? debugValue : null;
-  }
-}
\ No newline at end of file