You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2014/08/06 17:16:15 UTC

[1/2] git commit: [OLINGO-350] Status code handling and refactoring

Repository: olingo-odata4
Updated Branches:
  refs/heads/master 34f082560 -> d19afa013


[OLINGO-350] Status code handling and refactoring


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

Branch: refs/heads/master
Commit: 5c0b34a92d67f7f4f3846a1bdd2ad76e70cd0f6b
Parents: 34f0825
Author: Christian Amend <ch...@apache.org>
Authored: Fri Aug 1 16:20:55 2014 +0200
Committer: Christian Amend <ch...@apache.org>
Committed: Wed Aug 6 17:10:15 2014 +0200

----------------------------------------------------------------------
 .../server/api/ODataTranslatedException.java    |   6 -
 .../api/processor/CollectionProcessor.java      |  40 -------
 .../server/api/processor/DefaultProcessor.java  |   4 +-
 .../processor/EntityCollectionProcessor.java    |  40 +++++++
 .../src/main/resources/i18n.properties          |   7 +-
 .../olingo/server/core/ContentNegotiator.java   |  35 +++---
 .../server/core/ContentNegotiatorException.java |  45 +++++++
 .../apache/olingo/server/core/ODataHandler.java | 120 +++++++++++--------
 .../server/core/ContentNegotiatorTest.java      |  41 +++----
 .../server/core/ODataHttpHandlerImplTest.java   |   6 -
 .../tecsvc/processor/TechnicalProcessor.java    |   4 +-
 .../olingo/server/core/ODataHandlerTest.java    |  49 ++++++++
 12 files changed, 249 insertions(+), 148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5c0b34a9/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataTranslatedException.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataTranslatedException.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataTranslatedException.java
index b703f93..1dbb810 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataTranslatedException.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataTranslatedException.java
@@ -45,12 +45,6 @@ public class ODataTranslatedException extends ODataException {
     PROCESSOR_NOT_IMPLEMENTED,
     FUNCTIONALITY_NOT_IMPLEMENTED,
     ODATA_VERSION_NOT_SUPPORTED,
-    /** parameters: HTTP header name, HTTP header value */
-    WRONG_CHARSET_IN_HEADER,
-    /** parameter: list of content-type ranges */
-    UNSUPPORTED_CONTENT_TYPES,
-    /** parameter: content type */
-    UNSUPPORTED_CONTENT_TYPE
   }
 
   private MessageKey messageKey;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5c0b34a9/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CollectionProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CollectionProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CollectionProcessor.java
deleted file mode 100644
index d61734c..0000000
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/CollectionProcessor.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.server.api.processor;
-
-import org.apache.olingo.commons.api.format.ContentType;
-import org.apache.olingo.server.api.ODataRequest;
-import org.apache.olingo.server.api.ODataResponse;
-import org.apache.olingo.server.api.uri.UriInfo;
-
-/**
- * Processor interface for handling collections of entities (collections, EntitySets or feeds).
- */
-public interface CollectionProcessor extends Processor {
-
-  /**
-   * Read entities data from persistency and puts serialized content and status into the response.
-   *  @param request - OData request object containing raw http information.
-   *  @param response - OData response object for collecting response data
-   *  @param uriInfo - information of a parsed OData uri
-   *  @param requestedContentType - requested content type after content negotiation
-   */
-  void readCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestedContentType);
-
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5c0b34a9/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
index 028bf6b..359136b 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java
@@ -87,7 +87,9 @@ public class DefaultProcessor implements MetadataProcessor, ServiceDocumentProce
     } catch (Exception e) {
       // This should never happen but to be sure we have this catch here to prevent sending a stacktrace to a client.
       String responseContent =
-          "An unexpected exception occoured during error processing with message: \"" + e.getMessage() + "\"";
+          "{\"error\":{\"code\":null,\"message\":\"An unexpected exception occoured during " +
+              "error processing with message: "
+              + e.getMessage() + "\"}}";
       response.setContent(new ByteArrayInputStream(responseContent.getBytes()));
       response.setStatusCode(HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode());
       response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.APPLICATION_JSON.toContentTypeString());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5c0b34a9/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityCollectionProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityCollectionProcessor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityCollectionProcessor.java
new file mode 100644
index 0000000..0e58c96
--- /dev/null
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/EntityCollectionProcessor.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.api.processor;
+
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.server.api.ODataRequest;
+import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.uri.UriInfo;
+
+/**
+ * Processor interface for handling collections of entities (collections, EntitySets or feeds).
+ */
+public interface EntityCollectionProcessor extends Processor {
+
+  /**
+   * Read entities data from persistency and puts serialized content and status into the response.
+   *  @param request - OData request object containing raw http information.
+   *  @param response - OData response object for collecting response data
+   *  @param uriInfo - information of a parsed OData uri
+   *  @param requestedContentType - requested content type after content negotiation
+   */
+  void readCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestedContentType);
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5c0b34a9/lib/server-api/src/main/resources/i18n.properties
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/resources/i18n.properties b/lib/server-api/src/main/resources/i18n.properties
index 3efb829..7a7fbe9 100644
--- a/lib/server-api/src/main/resources/i18n.properties
+++ b/lib/server-api/src/main/resources/i18n.properties
@@ -23,9 +23,10 @@ ODataTranslatedException.HTTP_METHOD_NOT_IMPLEMENTED=Invalid HTTP method given:
 ODataTranslatedException.PROCESSOR_NOT_IMPLEMENTED=No processor for interface '%1$s' registered.
 ODataTranslatedException.FUNCTIONALITY_NOT_IMPLEMENTED=The requested functionality has not been implemented (yet).
 ODataTranslatedException.ODATA_VERSION_NOT_SUPPORTED=OData version '%1$s' is not supported.
-ODataTranslatedException.WRONG_CHARSET_IN_HEADER=The HTTP header '%1$s' with value '%2$s' contains an invalid character-set specification.
-ODataTranslatedException.UNSUPPORTED_CONTENT_TYPES=The content-type range '%1$s' is not supported.
-ODataTranslatedException.UNSUPPORTED_CONTENT_TYPE=The content type '%1$s' is not supported.
+ContentNegotiatorException.WRONG_CHARSET_IN_HEADER=The HTTP header '%1$s' with value '%2$s' contains an invalid character-set specification.
+ContentNegotiatorException.UNSUPPORTED_CONTENT_TYPES=The content-type range '%1$s' is not supported.
+ContentNegotiatorException.UNSUPPORTED_CONTENT_TYPE=The content type '%1$s' is not supported.
+ContentNegotiatorException.UNSUPPORTED_FORMAT_OPTION=The $format option '%1$s' is not supported.
 
 ODataSerializerException.NOT_IMPLEMENTED=The requested serialization method has not been implemented yet.
 ODataSerializerException.UNSUPPORTED_FORMAT=The format '%1$s' is not supported.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5c0b34a9/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java
index 2bdadd8..e762464 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java
@@ -18,28 +18,23 @@
  */
 package org.apache.olingo.server.core;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.AcceptType;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.server.api.ODataRequest;
-import org.apache.olingo.server.api.ODataTranslatedException;
 import org.apache.olingo.server.api.processor.CustomContentTypeSupportProcessor;
 import org.apache.olingo.server.api.processor.FormatContentTypeMapping;
 import org.apache.olingo.server.api.processor.MetadataProcessor;
 import org.apache.olingo.server.api.processor.Processor;
 import org.apache.olingo.server.api.uri.queryoption.FormatOption;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
 
 public class ContentNegotiator {
 
-  private final static Logger LOG = LoggerFactory.getLogger(ContentNegotiator.class);
-
   private ContentNegotiator() {}
 
   private static List<FormatContentTypeMapping>
@@ -71,7 +66,7 @@ public class ContentNegotiator {
   }
 
   public static ContentType doContentNegotiation(final FormatOption formatOption, final ODataRequest request,
-      final Processor processor, final Class<? extends Processor> processorClass) throws ODataTranslatedException {
+      final Processor processor, final Class<? extends Processor> processorClass) throws ContentNegotiatorException {
     ContentType requestedContentType = null;
 
     List<FormatContentTypeMapping> supportedContentTypes = getSupportedContentTypes(processor, processorClass);
@@ -81,7 +76,6 @@ public class ContentNegotiator {
     boolean supported = false;
 
     if (formatOption != null) {
-
       if ("json".equalsIgnoreCase(formatOption.getText().trim())) {
         requestedContentType = ODataFormat.JSON.getContentType(ODataServiceVersion.V40);
         for (FormatContentTypeMapping entry : supportedContentTypes) {
@@ -107,6 +101,10 @@ public class ContentNegotiator {
           }
         }
       }
+      if (!supported) {
+        throw new ContentNegotiatorException("Unsupported $format = " + formatOption.getText(),
+            ContentNegotiatorException.MessageKeys.UNSUPPORTED_FORMAT_OPTION, formatOption.getText());
+      }
     } else if (acceptHeaderValue != null) {
       List<AcceptType> acceptedContentTypes = AcceptType.create(acceptHeaderValue);
 
@@ -119,8 +117,8 @@ public class ContentNegotiator {
             if ("utf8".equalsIgnoreCase(value) || "utf-8".equalsIgnoreCase(value)) {
               ct = ContentType.create(ct, ContentType.PARAMETER_CHARSET_UTF8);
             } else {
-              throw new ODataTranslatedException("charset in accept header not supported: " + acceptHeaderValue,
-                  ODataTranslatedException.MessageKeys.WRONG_CHARSET_IN_HEADER, HttpHeader.ACCEPT, acceptHeaderValue);
+              throw new ContentNegotiatorException("charset in accept header not supported: " + acceptHeaderValue,
+                  ContentNegotiatorException.MessageKeys.WRONG_CHARSET_IN_HEADER, HttpHeader.ACCEPT, acceptHeaderValue);
             }
           }
 
@@ -135,13 +133,12 @@ public class ContentNegotiator {
         }
       }
 
-      if (requestedContentType == null) {
-        throw new ODataTranslatedException(
+      if (!supported) {
+        throw new ContentNegotiatorException(
             "unsupported accept content type: " + acceptedContentTypes + " != " + supportedContentTypes,
-            ODataTranslatedException.MessageKeys.UNSUPPORTED_CONTENT_TYPES, acceptedContentTypes.toString());
+            ContentNegotiatorException.MessageKeys.UNSUPPORTED_CONTENT_TYPES, acceptedContentTypes.toString());
       }
     } else {
-
       if (processorClass == MetadataProcessor.class) {
         requestedContentType = ContentType.APPLICATION_XML;
       } else {
@@ -157,13 +154,11 @@ public class ContentNegotiator {
     }
 
     if (!supported) {
-      throw new ODataTranslatedException(
+      throw new ContentNegotiatorException(
           "unsupported accept content type: " + requestedContentType + " != " + supportedContentTypes,
-          ODataTranslatedException.MessageKeys.UNSUPPORTED_CONTENT_TYPE, requestedContentType.toContentTypeString());
+          ContentNegotiatorException.MessageKeys.UNSUPPORTED_CONTENT_TYPE, requestedContentType.toContentTypeString());
     }
 
-    LOG.debug("requested content type: " + requestedContentType);
-
     return requestedContentType;
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5c0b34a9/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiatorException.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiatorException.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiatorException.java
new file mode 100644
index 0000000..6e0d823
--- /dev/null
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiatorException.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.server.core;
+
+import org.apache.olingo.server.api.ODataTranslatedException;
+
+public class ContentNegotiatorException extends ODataTranslatedException {
+  private static final long serialVersionUID = -8112658467394158700L;
+
+  public static enum MessageKeys implements MessageKey {
+    /** parameters: HTTP header name, HTTP header value */
+    WRONG_CHARSET_IN_HEADER,
+    /** parameter: list of content-type ranges */
+    UNSUPPORTED_CONTENT_TYPES,
+    /** parameter: content type */
+    UNSUPPORTED_CONTENT_TYPE,
+    /** parameter: format string */
+    UNSUPPORTED_FORMAT_OPTION
+  }
+
+  public ContentNegotiatorException(String developmentMessage, MessageKey messageKey, String... parameters) {
+    super(developmentMessage, messageKey, parameters);
+  }
+
+  public ContentNegotiatorException(String developmentMessage, Throwable cause, MessageKey messageKey,
+      String... parameters) {
+    super(developmentMessage, cause, messageKey, parameters);
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5c0b34a9/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
index 9c6bf3e..f364a22 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
@@ -22,7 +22,6 @@ import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 
-import org.apache.olingo.commons.api.ODataRuntimeException;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ContentType;
@@ -36,7 +35,7 @@ import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.ODataServerError;
 import org.apache.olingo.server.api.ODataTranslatedException;
-import org.apache.olingo.server.api.processor.CollectionProcessor;
+import org.apache.olingo.server.api.processor.EntityCollectionProcessor;
 import org.apache.olingo.server.api.processor.DefaultProcessor;
 import org.apache.olingo.server.api.processor.EntityProcessor;
 import org.apache.olingo.server.api.processor.ExceptionProcessor;
@@ -48,6 +47,8 @@ import org.apache.olingo.server.api.uri.UriResource;
 import org.apache.olingo.server.api.uri.UriResourceNavigation;
 import org.apache.olingo.server.api.uri.UriResourcePartTyped;
 import org.apache.olingo.server.core.uri.parser.Parser;
+import org.apache.olingo.server.core.uri.parser.UriParserException;
+import org.apache.olingo.server.core.uri.validator.UriValidationException;
 import org.apache.olingo.server.core.uri.validator.UriValidator;
 
 public class ODataHandler {
@@ -69,46 +70,17 @@ public class ODataHandler {
     ContentType requestedContentType = null;
     ODataResponse response = new ODataResponse();
     try {
-      validateODataVersion(request, response);
 
-      Parser parser = new Parser();
-      String odUri =
-          request.getRawODataPath() + (request.getRawQueryPath() == null ? "" : "?" + request.getRawQueryPath());
-      UriInfo uriInfo = parser.parseUri(odUri, edm);
+      processInternal(request, requestedContentType, response);
 
-      UriValidator validator = new UriValidator();
-      validator.validate(uriInfo, request.getMethod());
+    } catch (UriParserException e) {
 
-      switch (uriInfo.getKind()) {
-      case metadata:
-        MetadataProcessor mp = selectProcessor(MetadataProcessor.class, response);
-
-        requestedContentType =
-            ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, mp, MetadataProcessor.class);
-
-        mp.readMetadata(request, response, uriInfo, requestedContentType);
-        break;
-      case service:
-        if ("".equals(request.getRawODataPath())) {
-          RedirectProcessor rdp = selectProcessor(RedirectProcessor.class, response);
-          rdp.redirect(request, response);
-        } else {
-          ServiceDocumentProcessor sdp = selectProcessor(ServiceDocumentProcessor.class, response);
-
-          requestedContentType =
-              ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, sdp,
-                  ServiceDocumentProcessor.class);
-
-          sdp.readServiceDocument(request, response, uriInfo, requestedContentType);
-        }
-        break;
-      case resource:
-        handleResourceDispatching(request, response, uriInfo);
-        break;
-      default:
-        throw new ODataTranslatedException("not implemented",
-            ODataTranslatedException.MessageKeys.FUNCTIONALITY_NOT_IMPLEMENTED);
-      }
+    } catch (ContentNegotiatorException e) {
+      Locale requestedLocale = null;
+      ODataServerError serverError =
+          ODataExceptionHelper.createServerErrorObject(e, HttpStatusCode.NOT_ACCEPTABLE.getStatusCode(),
+              requestedLocale);
+      handleException(request, response, serverError, requestedContentType);
     } catch (ODataTranslatedException e) {
       Locale requestedLocale = null;
       ODataServerError serverError =
@@ -124,6 +96,53 @@ public class ODataHandler {
     return response;
   }
 
+  private void processInternal(final ODataRequest request, ContentType requestedContentType,
+      final ODataResponse response)
+      throws ODataTranslatedException, UriParserException, UriValidationException, ContentNegotiatorException,
+      ODataApplicationException {
+    validateODataVersion(request, response);
+
+    Parser parser = new Parser();
+    String odUri =
+        request.getRawODataPath() + (request.getRawQueryPath() == null ? "" : "?" + request.getRawQueryPath());
+    UriInfo uriInfo = parser.parseUri(odUri, edm);
+
+    UriValidator validator = new UriValidator();
+    validator.validate(uriInfo, request.getMethod());
+
+    switch (uriInfo.getKind()) {
+    case metadata:
+      MetadataProcessor mp = selectProcessor(MetadataProcessor.class, response);
+
+      requestedContentType =
+          ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, mp, MetadataProcessor.class);
+
+      mp.readMetadata(request, response, uriInfo, requestedContentType);
+      break;
+    case service:
+      if ("".equals(request.getRawODataPath())) {
+        RedirectProcessor rdp = selectProcessor(RedirectProcessor.class, response);
+        rdp.redirect(request, response);
+      } else {
+        ServiceDocumentProcessor sdp = selectProcessor(ServiceDocumentProcessor.class, response);
+
+        requestedContentType =
+            ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, sdp,
+                ServiceDocumentProcessor.class);
+
+        sdp.readServiceDocument(request, response, uriInfo, requestedContentType);
+      }
+      break;
+    case resource:
+      handleResourceDispatching(request, response, uriInfo);
+      break;
+    default:
+      response.setStatusCode(HttpStatusCode.NOT_IMPLEMENTED.getStatusCode());
+      throw new ODataTranslatedException("not implemented",
+          ODataTranslatedException.MessageKeys.FUNCTIONALITY_NOT_IMPLEMENTED);
+    }
+  }
+
   private void handleException(ODataRequest request, ODataResponse response, ODataServerError serverError,
       ContentType requestedContentType) {
     ExceptionProcessor exceptionProcessor;
@@ -132,10 +151,10 @@ public class ODataHandler {
     } catch (ODataTranslatedException e) {
       exceptionProcessor = new DefaultProcessor();
     }
-      if (requestedContentType == null) {
-        requestedContentType = ODataFormat.JSON.getContentType(ODataServiceVersion.V40);
-      }
-      exceptionProcessor.processException(request, response, serverError, requestedContentType);
+    if (requestedContentType == null) {
+      requestedContentType = ODataFormat.JSON.getContentType(ODataServiceVersion.V40);
+    }
+    exceptionProcessor.processException(request, response, serverError, requestedContentType);
   }
 
   private void handleResourceDispatching(final ODataRequest request, final ODataResponse response,
@@ -148,13 +167,15 @@ public class ODataHandler {
     case entitySet:
       if (((UriResourcePartTyped) lastPathSegment).isCollection()) {
         if (request.getMethod().equals(HttpMethod.GET)) {
-          CollectionProcessor cp = selectProcessor(CollectionProcessor.class, response);
+          EntityCollectionProcessor cp = selectProcessor(EntityCollectionProcessor.class, response);
 
           requestedContentType =
-              ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, cp, CollectionProcessor.class);
+              ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, cp,
+                  EntityCollectionProcessor.class);
 
           cp.readCollection(request, response, uriInfo, requestedContentType);
         } else {
+          response.setStatusCode(HttpStatusCode.NOT_IMPLEMENTED.getStatusCode());
           throw new ODataTranslatedException("not implemented",
               ODataTranslatedException.MessageKeys.FUNCTIONALITY_NOT_IMPLEMENTED);
         }
@@ -167,6 +188,7 @@ public class ODataHandler {
 
           ep.readEntity(request, response, uriInfo, requestedContentType);
         } else {
+          response.setStatusCode(HttpStatusCode.NOT_IMPLEMENTED.getStatusCode());
           throw new ODataTranslatedException("not implemented",
               ODataTranslatedException.MessageKeys.FUNCTIONALITY_NOT_IMPLEMENTED);
         }
@@ -175,13 +197,15 @@ public class ODataHandler {
     case navigationProperty:
       if (((UriResourceNavigation) lastPathSegment).isCollection()) {
         if (request.getMethod().equals(HttpMethod.GET)) {
-          CollectionProcessor cp = selectProcessor(CollectionProcessor.class, response);
+          EntityCollectionProcessor cp = selectProcessor(EntityCollectionProcessor.class, response);
 
           requestedContentType =
-              ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, cp, CollectionProcessor.class);
+              ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(), request, cp,
+                  EntityCollectionProcessor.class);
 
           cp.readCollection(request, response, uriInfo, requestedContentType);
         } else {
+          response.setStatusCode(HttpStatusCode.NOT_IMPLEMENTED.getStatusCode());
           throw new ODataTranslatedException("not implemented",
               ODataTranslatedException.MessageKeys.FUNCTIONALITY_NOT_IMPLEMENTED);
         }
@@ -194,12 +218,14 @@ public class ODataHandler {
 
           ep.readEntity(request, response, uriInfo, requestedContentType);
         } else {
+          response.setStatusCode(HttpStatusCode.NOT_IMPLEMENTED.getStatusCode());
           throw new ODataTranslatedException("not implemented",
               ODataTranslatedException.MessageKeys.FUNCTIONALITY_NOT_IMPLEMENTED);
         }
       }
       break;
     default:
+      response.setStatusCode(HttpStatusCode.NOT_IMPLEMENTED.getStatusCode());
       throw new ODataTranslatedException("not implemented",
           ODataTranslatedException.MessageKeys.FUNCTIONALITY_NOT_IMPLEMENTED);
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5c0b34a9/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
index ca78ba0..f858aa0 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/ContentNegotiatorTest.java
@@ -18,6 +18,17 @@
  */
 package org.apache.olingo.server.core;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.http.HttpHeader;
@@ -25,8 +36,7 @@ import org.apache.olingo.commons.api.http.HttpMethod;
 import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
-import org.apache.olingo.server.api.ODataTranslatedException;
-import org.apache.olingo.server.api.processor.CollectionProcessor;
+import org.apache.olingo.server.api.processor.EntityCollectionProcessor;
 import org.apache.olingo.server.api.processor.CustomContentTypeSupportProcessor;
 import org.apache.olingo.server.api.processor.FormatContentTypeMapping;
 import org.apache.olingo.server.api.processor.MetadataProcessor;
@@ -35,19 +45,6 @@ import org.apache.olingo.server.api.processor.ServiceDocumentProcessor;
 import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.api.uri.queryoption.FormatOption;
 import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 public class ContentNegotiatorTest {
 
@@ -103,8 +100,6 @@ public class ContentNegotiatorTest {
   //CHECKSTYLE:ON
   //@formatter:on
 
-  private final static Logger LOG = LoggerFactory.getLogger(ContentNegotiatorTest.class);
-
   @Test
   public void testServiceDocumentSingleCase() throws Exception {
     String[] useCase = { ACCEPT_CASE_MIN_UTF8, null, ACCEPT_CASE_MIN_UTF8, null, null };
@@ -139,17 +134,17 @@ public class ContentNegotiatorTest {
       try {
         testContentNegotiation(useCase, MetadataProcessor.class);
         fail("Exeption expected!");
-      } catch (Exception e) {
+      } catch (ContentNegotiatorException e) {
 
+      }catch (Exception e) {
+        e.printStackTrace();
+        fail("Wrong Exception: " + e.getClass().getName());
       }
     }
   }
 
   public void testContentNegotiation(final String[] useCase, final Class<? extends Processor> processorClass)
-      throws ODataTranslatedException {
-
-    LOG.debug(Arrays.asList(useCase).toString());
-
+      throws Exception {
     ODataRequest request = new ODataRequest();
     request.setMethod(HttpMethod.GET);
     request.setRawODataPath("/" + (useCase[1] == null ? "" : "?$format=" + useCase[1]));
@@ -194,7 +189,7 @@ public class ContentNegotiatorTest {
   }
 
   private class ProcessorStub implements ServiceDocumentProcessor, MetadataProcessor,
-      CollectionProcessor,
+      EntityCollectionProcessor,
       CustomContentTypeSupportProcessor {
 
     List<FormatContentTypeMapping> customMapping;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5c0b34a9/lib/server-core/src/test/java/org/apache/olingo/server/core/ODataHttpHandlerImplTest.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/ODataHttpHandlerImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/ODataHttpHandlerImplTest.java
index 03fc0ea..a81af68 100644
--- a/lib/server-core/src/test/java/org/apache/olingo/server/core/ODataHttpHandlerImplTest.java
+++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/ODataHttpHandlerImplTest.java
@@ -29,13 +29,9 @@ import org.apache.olingo.commons.api.http.HttpMethod;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataTranslatedException;
 import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class ODataHttpHandlerImplTest {
 
-  private final Logger LOG = LoggerFactory.getLogger(ODataHttpHandlerImplTest.class);
-
   @Test
   public void extractMethod() throws Exception {
     String[][] mm = {
@@ -149,8 +145,6 @@ public class ODataHttpHandlerImplTest {
       String requestUri = p[1] + p[2] + p[3] + p[4];
       String queryString = p[5].isEmpty() ? null : p[5];
 
-      LOG.debug(requestUrl + (queryString == null ? "" : "?" + queryString));
-
       when(hr.getRequestURL()).thenReturn(new StringBuffer(requestUrl));
       when(hr.getRequestURI()).thenReturn(requestUri);
       when(hr.getQueryString()).thenReturn(queryString);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5c0b34a9/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
index d079dd0..3ea7b1e 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/TechnicalProcessor.java
@@ -31,7 +31,7 @@ import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.ODataTranslatedException;
-import org.apache.olingo.server.api.processor.CollectionProcessor;
+import org.apache.olingo.server.api.processor.EntityCollectionProcessor;
 import org.apache.olingo.server.api.processor.EntityProcessor;
 import org.apache.olingo.server.api.serializer.ODataSerializer;
 import org.apache.olingo.server.api.uri.UriInfo;
@@ -42,7 +42,7 @@ import org.apache.olingo.server.tecsvc.data.DataProvider;
 
 import java.util.List;
 
-public class TechnicalProcessor implements CollectionProcessor, EntityProcessor {
+public class TechnicalProcessor implements EntityCollectionProcessor, EntityProcessor {
 
   private OData odata;
   private Edm edm;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5c0b34a9/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
index efd0e65..5eaff89 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
@@ -21,22 +21,28 @@ package org.apache.olingo.server.core;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 
 import java.util.Arrays;
+import java.util.Locale;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.http.HttpContentType;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.commons.api.http.HttpMethod;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.processor.MetadataProcessor;
 import org.apache.olingo.server.api.processor.ServiceDocumentProcessor;
+import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
 import org.junit.Before;
 import org.junit.Test;
@@ -187,4 +193,47 @@ public class ODataHandlerTest {
     assertEquals(400, response.getStatusCode());
   }
 
+  @Test
+  public void testContentNegotiationSupported() {
+    ODataRequest request = new ODataRequest();
+
+    request.setMethod(HttpMethod.GET);
+    request.setRawODataPath("$metadata");
+    request.setRawQueryPath("$format=xml");
+
+    ODataResponse response = handler.process(request);
+    assertNotNull(response);
+    assertEquals(200, response.getStatusCode());
+  }
+
+  @Test
+  public void testContentNegotiationNotSupported() {
+    ODataRequest request = new ODataRequest();
+
+    request.setMethod(HttpMethod.GET);
+    request.setRawODataPath("$metadata");
+    request.setRawQueryPath("$format=notSupported");
+
+    ODataResponse response = handler.process(request);
+    assertNotNull(response);
+    assertEquals(406, response.getStatusCode());
+  }
+
+  @Test
+  public void testWithApplicationExceptionInProcessor() throws Exception {
+    ODataRequest request = new ODataRequest();
+
+    request.setMethod(HttpMethod.GET);
+    request.setRawODataPath("$metadata");
+
+    MetadataProcessor metadataProcessor = mock(MetadataProcessor.class);
+    doThrow(new ODataApplicationException("msg", 412, Locale.ENGLISH)).when(metadataProcessor).readMetadata(
+        any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class));
+
+    handler.register(metadataProcessor);
+
+    ODataResponse response = handler.process(request);
+    assertNotNull(response);
+    assertEquals(412, response.getStatusCode());
+  }
 }


[2/2] git commit: [OLINGO-348] Make Uri Parser exception translatable

Posted by ch...@apache.org.
[OLINGO-348] Make Uri Parser exception translatable


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

Branch: refs/heads/master
Commit: d19afa013bfe819234f981039b613ca8210a591a
Parents: 5c0b34a
Author: Christian Amend <ch...@apache.org>
Authored: Wed Aug 6 17:09:29 2014 +0200
Committer: Christian Amend <ch...@apache.org>
Committed: Wed Aug 6 17:10:16 2014 +0200

----------------------------------------------------------------------
 .../core/edm/primitivetype/EdmDecimal.java      |   3 +-
 .../edm/primitivetype/EdmTimeOfDayTest.java     |   6 +
 .../olingo/server/api/uri/UriInfoResource.java  |   6 +
 .../apache/olingo/server/core/ODataHandler.java |   2 +-
 .../olingo/server/core/uri/UriInfoImpl.java     |   9 ++
 .../olingo/server/core/uri/parser/Parser.java   |  13 +-
 .../core/uri/parser/UriParseTreeVisitor.java    | 132 ++++++++++++-------
 .../core/uri/parser/UriParserException.java     |  20 +--
 .../uri/parser/UriParserSemanticException.java  |  16 ++-
 .../uri/parser/UriParserSyntaxException.java    |  19 +--
 .../uri/validator/UriValidationException.java   |  42 +++++-
 .../server/core/uri/validator/UriValidator.java |  70 +++++++---
 .../olingo/server/core/ODataHandlerTest.java    |  73 +++++++++-
 .../olingo/server/core/uri/UriInfoImplTest.java |  30 ++---
 .../core/uri/antlr/TestFullResourcePath.java    |  24 ++--
 .../core/uri/antlr/TestUriParserImpl.java       |   8 +-
 .../core/uri/testutil/ResourceValidator.java    |   6 +
 .../core/uri/testutil/TestUriValidator.java     |   8 ++
 .../core/uri/validator/UriValidatorTest.java    |   6 +
 19 files changed, 353 insertions(+), 140 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimal.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimal.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimal.java
index 66b0d70..f67caf9 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimal.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimal.java
@@ -68,7 +68,8 @@ public final class EdmDecimal extends SingletonPrimitiveType {
   }
 
   private static boolean validateLiteral(final String value) {
-    return PATTERN.matcher(value).matches();
+    boolean valid = PATTERN.matcher(value).matches();
+    return valid;
   }
 
   private static final boolean validatePrecisionAndScale(final String value, final Integer precision,

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDayTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDayTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDayTest.java
index 297fd82..917814d 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDayTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDayTest.java
@@ -90,4 +90,10 @@ public class EdmTimeOfDayTest extends PrimitiveTypeBaseTest {
 
     expectTypeErrorInValueOfString(instance, "11:12:13");
   }
+
+  @Test
+  public void tests() throws Exception {
+    instance.validate("12:34:55", null, null, null, null, null);
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoResource.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoResource.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoResource.java
index f663c2f..7a62c36 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoResource.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoResource.java
@@ -115,4 +115,10 @@ public interface UriInfoResource {
    */
   List<UriResource> getUriResourceParts();
 
+  /**
+   * @param alias
+   * @return the value for the given alias or null if no value is defined
+   */
+  String getValueForAlias(String alias);
+
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
index f364a22..3b9f068 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHandler.java
@@ -74,7 +74,7 @@ public class ODataHandler {
       processInternal(request, requestedContentType, response);
 
     } catch (UriParserException e) {
-
+      e.printStackTrace();
     } catch (ContentNegotiatorException e) {
       Locale requestedLocale = null;
       ODataServerError serverError =

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java
index ee855eb..2b4b266 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java
@@ -62,6 +62,7 @@ public class UriInfoImpl implements UriInfo {
   private EdmEntityType entityTypeCast; // for $entity
 
   private List<CustomQueryOptionImpl> customQueryOptions = new ArrayList<CustomQueryOptionImpl>();
+  private HashMap<String, String> aliasToValue = new HashMap<String, String>();
 
   HashMap<SystemQueryOptionKind, SystemQueryOption> systemQueryOptions =
       new HashMap<SystemQueryOptionKind, SystemQueryOption>();
@@ -135,6 +136,11 @@ public class UriInfoImpl implements UriInfo {
   }
 
   @Override
+  public String getValueForAlias(String alias) {
+    return aliasToValue.get(alias);
+  }
+
+  @Override
   public EdmEntityType getEntityTypeCast() {
     return entityTypeCast;
   }
@@ -228,6 +234,9 @@ public class UriInfoImpl implements UriInfo {
 
   public void addCustomQueryOption(final QueryOptionImpl item) {
     customQueryOptions.add((CustomQueryOptionImpl) item);
+    if (item.getName().startsWith("@")) {
+      aliasToValue.put(item.getName(), item.getText());
+    }
   }
 
   public UriInfoImpl setSystemQueryOption(final SystemQueryOptionImpl systemOption) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
index 535359f..1136811 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
@@ -221,7 +221,8 @@ public class Parser {
             try {
               inlineCountOption.setValue(Integer.parseInt(option.value));
             } catch (final NumberFormatException e) {
-              throw new UriParserSemanticException("Illegal value of $skip option!", e);
+              throw new UriParserSemanticException("Illegal value of $skip option!", e,
+                  UriParserSemanticException.MessageKeys.TEST);
             }
             context.contextUriInfo.setSystemQueryOption(inlineCountOption);
           } else if (option.name.equals("$skiptoken")) {
@@ -237,7 +238,8 @@ public class Parser {
             try {
               inlineCountOption.setValue(Integer.parseInt(option.value));
             } catch (final NumberFormatException e) {
-              throw new UriParserSemanticException("Illegal value of $top option!", e);
+              throw new UriParserSemanticException("Illegal value of $top option!", e,
+                  UriParserSemanticException.MessageKeys.TEST);
             }
             context.contextUriInfo.setSystemQueryOption(inlineCountOption);
           } else if (option.name.equals("$count")) {
@@ -248,7 +250,8 @@ public class Parser {
             if (option.value.equals("true") || option.value.equals("false")) {
               inlineCountOption.setValue(Boolean.parseBoolean(option.value));
             } else {
-              throw new UriParserSemanticException("Illegal value of $count option!");
+              throw new UriParserSemanticException("Illegal value of $count option!",
+                  UriParserSemanticException.MessageKeys.TEST);
             }
             context.contextUriInfo.setSystemQueryOption(inlineCountOption);
           }
@@ -396,12 +399,12 @@ public class Parser {
         }
 
       } catch (Exception weakException) {
-        throw new UriParserSyntaxException("Error in syntax", weakException);
+        throw new UriParserSyntaxException("Error in syntax", weakException, UriParserSyntaxException.MessageKeys.TEST);
 
         // exceptionOnStage = 2;
       }
     } catch (Exception hardException) {
-      throw new UriParserSyntaxException("Error in syntax", hardException);
+      throw new UriParserSyntaxException("Error in syntax", hardException, UriParserSyntaxException.MessageKeys.TEST);
     }
 
     return ret;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
index ea24268..13900d6 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java
@@ -343,7 +343,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
             tmp += (tmp.length() != 0 ? "," : "") + name;
           }
           throw wrap(new UriParserSemanticException("Function of functionimport '" + edmFunctionImport.getName()
-              + "' with parameters [" + tmp + "] not found"));
+              + "' with parameters [" + tmp + "] not found", UriParserSemanticException.MessageKeys.TEST));
         }
 
         uriResource.setFunction(edmFunctionImport.getUnboundFunction(names));
@@ -358,7 +358,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
     if (lastResourcePart == null) {
       if (context.contextTypes.size() == 0) {
         throw wrap(new UriParserSemanticException("Resource part '" + odi + "' can only applied on typed "
-            + "resource parts"));
+            + "resource parts", UriParserSemanticException.MessageKeys.TEST));
       }
       source = context.contextTypes.peek();
     } else {
@@ -366,7 +366,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
 
       if (source.type == null) {
         throw wrap(new UriParserSemanticException("Resource part '" + odi + "' can only applied on typed "
-            + "resource parts"));
+            + "resource parts", UriParserSemanticException.MessageKeys.TEST));
       }
     }
 
@@ -385,7 +385,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
 
       if (!(source.type instanceof EdmStructuredType)) {
         throw wrap(new UriParserSemanticException("Can not parse'" + odi
-            + "'Previous path segment not a structural type."));
+            + "'Previous path segment not a structural type.", UriParserSemanticException.MessageKeys.TEST));
       }
 
       EdmStructuredType structType = (EdmStructuredType) source.type;
@@ -393,7 +393,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
       EdmElement property = structType.getProperty(odi);
       if (property == null) {
         throw wrap(new UriParserSemanticException("Property '" + odi + "' not found in type '"
-            + structType.getNamespace() + "." + structType.getName() + "'"));
+            + structType.getNamespace() + "." + structType.getName() + "'", 
+            UriParserSemanticException.MessageKeys.TEST));
       }
 
       if (property instanceof EdmProperty) {
@@ -417,7 +418,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
         context.contextUriInfo.addResourcePart(navigationResource);
         return null;
       } else {
-        throw wrap(new UriParserSemanticException("Unkown type for property '" + property + "'"));
+        throw wrap(new UriParserSemanticException("Unkown type for property '" + property + "'",
+            UriParserSemanticException.MessageKeys.TEST));
       }
 
     } else { // with namespace
@@ -432,7 +434,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
           // is entity type cast
           if (!(filterEntityType.compatibleTo(source.type))) {
             throw wrap(new UriParserSemanticException(
-                "Entity typefilter not compatible to previous path segment: " + fullFilterName.toString()));
+                "Entity typefilter not compatible to previous path segment: " + fullFilterName.toString(),
+                UriParserSemanticException.MessageKeys.TEST));
           }
 
           if (lastResourcePart == null) {
@@ -457,7 +460,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
                 if (lastPartWithKeys.getTypeFilterOnEntry() != null) {
                   throw wrap(new UriParserSemanticException("Entry typefilters are not chainable, used '"
                       + getName(filterEntityType) + "' behind '"
-                      + getName(lastPartWithKeys.getTypeFilterOnEntry()) + "'"));
+                      + getName(lastPartWithKeys.getTypeFilterOnEntry()) + "'",
+                      UriParserSemanticException.MessageKeys.TEST));
                 }
                 lastPartWithKeys.setEntryTypeFilter(filterEntityType);
                 return null;
@@ -465,7 +469,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
                 if (lastPartWithKeys.getTypeFilterOnCollection() != null) {
                   throw wrap(new UriParserSemanticException("Collection typefilters are not chainable, used '"
                       + getName(filterEntityType) + "' behind '"
-                      + getName(lastPartWithKeys.getTypeFilterOnCollection()) + "'"));
+                      + getName(lastPartWithKeys.getTypeFilterOnCollection()) + "'",
+                      UriParserSemanticException.MessageKeys.TEST));
                 }
                 lastPartWithKeys.setCollectionTypeFilter(filterEntityType);
                 return null;
@@ -475,14 +480,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
               if (lastPartTyped.getTypeFilter() != null) {
                 throw wrap(new UriParserSemanticException("Typefilters are not chainable, used '"
                     + getName(filterEntityType) + "' behind '"
-                    + getName(lastPartTyped.getTypeFilter()) + "'"));
+                    + getName(lastPartTyped.getTypeFilter()) + "'", UriParserSemanticException.MessageKeys.TEST));
               }
 
               lastPartTyped.setTypeFilter(filterEntityType);
               return null;
             } else {
               throw wrap(new UriParserSemanticException("Path segment before '" + getName(filterEntityType)
-                  + "' not typed"));
+                  + "' not typed", UriParserSemanticException.MessageKeys.TEST));
             }
           }
         }
@@ -497,7 +502,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
           if (!(filterComplexType.compatibleTo(source.type))) {
             throw wrap(new UriParserSemanticException(
                 "Complex typefilter '" + getName(source.type) + "'not compatible type of previous path segment '"
-                    + getName(filterComplexType) + "'"));
+                    + getName(filterComplexType) + "'", UriParserSemanticException.MessageKeys.TEST));
           }
 
           // is simple complex type cast
@@ -523,7 +528,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
                 if (lastPartWithKeys.getTypeFilterOnEntry() != null) {
                   throw wrap(new UriParserSemanticException("Entry typefilters are not chainable, used '"
                       + getName(filterComplexType) + "' behind '"
-                      + getName(lastPartWithKeys.getTypeFilterOnEntry()) + "'"));
+                      + getName(lastPartWithKeys.getTypeFilterOnEntry()) + "'",
+                      UriParserSemanticException.MessageKeys.TEST));
                 }
                 lastPartWithKeys.setEntryTypeFilter(filterComplexType);
                 return null;
@@ -531,7 +537,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
                 if (lastPartWithKeys.getTypeFilterOnCollection() != null) {
                   throw wrap(new UriParserSemanticException("Collection typefilters are not chainable, used '"
                       + getName(filterComplexType) + "' behind '"
-                      + getName(lastPartWithKeys.getTypeFilterOnCollection()) + "'"));
+                      + getName(lastPartWithKeys.getTypeFilterOnCollection()) + "'",
+                      UriParserSemanticException.MessageKeys.TEST));
                 }
                 lastPartWithKeys.setCollectionTypeFilter(filterComplexType);
                 return null;
@@ -542,14 +549,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
               if (lastPartTyped.getTypeFilter() != null) {
                 throw wrap(new UriParserSemanticException("Typefilters are not chainable, used '"
                     + getName(filterComplexType) + "' behind '"
-                    + getName(lastPartTyped.getTypeFilter()) + "'"));
+                    + getName(lastPartTyped.getTypeFilter()) + "'", UriParserSemanticException.MessageKeys.TEST));
               }
 
               lastPartTyped.setTypeFilter(filterComplexType);
               return null;
             } else {
               throw wrap(new UriParserSemanticException("Path segment before '" + getName(filterComplexType)
-                  + "' not typed"));
+                  + "' not typed", UriParserSemanticException.MessageKeys.TEST));
             }
           }
         }
@@ -569,7 +576,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
       // do a check for bound functions (which requires a parameter list)
       if (ctx.vlNVO.size() == 0) {
         throw wrap(new UriParserSemanticException("Expected function parameters for '" + fullBindingTypeName.toString()
-            + "'"));
+            + "'", UriParserSemanticException.MessageKeys.TEST));
       }
 
       context.contextReadingFunctionParameters = true;
@@ -610,7 +617,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
         return null;
       }
 
-      throw wrap(new UriParserSemanticException("Unknown resource path segment:" + fullFilterName.toString()));
+      throw wrap(new UriParserSemanticException("Unknown resource path segment:" + fullFilterName.toString(),
+          UriParserSemanticException.MessageKeys.TEST));
     }
   }
 
@@ -631,7 +639,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
 
     UriResource obj = context.contextUriInfo.getLastResourcePart();
     if (!(obj instanceof UriResourcePartTyped)) {
-      throw wrap(new UriParserSemanticException("any only allowed on typed path segments"));
+      throw wrap(new UriParserSemanticException("any only allowed on typed path segments",
+          UriParserSemanticException.MessageKeys.TEST));
     }
 
     UriContext.LambdaVariables var = new UriContext.LambdaVariables();
@@ -770,7 +779,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
 
     EdmEntityType type = edm.getEntityType(fullName);
     if (type == null) {
-      throw wrap(new UriParserSemanticException("Expected EntityTypeName"));
+      throw wrap(new UriParserSemanticException("Expected EntityTypeName",
+          UriParserSemanticException.MessageKeys.TEST));
     }
     context.contextUriInfo.setEntityTypeCast(type);
 
@@ -855,7 +865,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
     if (ctx.vLV != null) {
       UriResourceImpl lastResourcePart = (UriResourceImpl) context.contextUriInfo.getLastResourcePart();
       if (!(lastResourcePart instanceof UriResourcePartTyped)) {
-        throw wrap(new UriParserSemanticException("any only allowed on typed path segments"));
+        throw wrap(new UriParserSemanticException("any only allowed on typed path segments",
+            UriParserSemanticException.MessageKeys.TEST));
       }
 
       UriContext.LambdaVariables var = new UriContext.LambdaVariables();
@@ -957,11 +968,13 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
         if (!((UriResourcePartTyped) pathInfo).isCollection()) {
           context.contextUriInfo.addResourcePart(new UriResourceValueImpl());
         } else {
-          throw wrap(new UriParserSemanticException("$value only allowed on typed path segments"));
+          throw wrap(new UriParserSemanticException("$value only allowed on typed path segments",
+              UriParserSemanticException.MessageKeys.TEST));
         }
         return null;
       } else {
-        throw wrap(new UriParserSemanticException("$value only allowed on typed path segments"));
+        throw wrap(new UriParserSemanticException("$value only allowed on typed path segments",
+            UriParserSemanticException.MessageKeys.TEST));
       }
 
     } else if (ctx.vC != null) {
@@ -969,10 +982,12 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
         if (((UriResourcePartTyped) pathInfo).isCollection()) {
           context.contextUriInfo.addResourcePart(new UriResourceCountImpl());
         } else {
-          throw wrap(new UriParserSemanticException("$count only allowed on collection properties"));
+          throw wrap(new UriParserSemanticException("$count only allowed on collection properties",
+              UriParserSemanticException.MessageKeys.TEST));
         }
       } else {
-        throw wrap(new UriParserSemanticException("$count only allowed on typed properties"));
+        throw wrap(new UriParserSemanticException("$count only allowed on typed properties",
+            UriParserSemanticException.MessageKeys.TEST));
       }
     } else if (ctx.vR != null) {
       if (pathInfo instanceof UriResourcePartTyped) {
@@ -980,10 +995,12 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
         if (type instanceof EdmEntityType) {
           context.contextUriInfo.addResourcePart(new UriResourceRefImpl());
         } else {
-          throw wrap(new UriParserSemanticException("$ref only allowed on endity types"));
+          throw wrap(new UriParserSemanticException("$ref only allowed on endity types",
+              UriParserSemanticException.MessageKeys.TEST));
         }
       } else {
-        throw wrap(new UriParserSemanticException("$ref only allowed on typed properties"));
+        throw wrap(new UriParserSemanticException("$ref only allowed on typed properties",
+            UriParserSemanticException.MessageKeys.TEST));
       }
 
     } else if (ctx.vAll != null) {
@@ -1393,13 +1410,15 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
       try {
         expression = (ExpressionImpl) ctx.vVO.accept(this);
       } catch (Exception ex) {
-        throw wrap(new UriParserSemanticException("Invalid key value: " + valueText));
+        throw wrap(new UriParserSemanticException("Invalid key value: " + valueText,
+            UriParserSemanticException.MessageKeys.TEST));
       }
 
       // get type of last resource part
       UriResource last = context.contextUriInfo.getLastResourcePart();
       if (!(last instanceof UriResourcePartTyped)) {
-        throw wrap(new UriParserSemanticException("Paramterslist on untyped resource path segement not allowed"));
+        throw wrap(new UriParserSemanticException("Paramterslist on untyped resource path segement not allowed",
+            UriParserSemanticException.MessageKeys.TEST));
       }
       EdmEntityType lastType = (EdmEntityType) ((UriResourcePartTyped) last).getType();
 
@@ -1420,14 +1439,16 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
       // key.
       // for using referential constrains the last resource part must be a navigation property
       if (!(context.contextUriInfo.getLastResourcePart() instanceof UriResourceNavigationPropertyImpl)) {
-        throw wrap(new UriParserSemanticException("Not enougth keyproperties defined"));
+        throw wrap(new UriParserSemanticException("Not enougth keyproperties defined",
+            UriParserSemanticException.MessageKeys.TEST));
       }
       UriResourceNavigationPropertyImpl lastNav = (UriResourceNavigationPropertyImpl) last;
 
       // get the partner of the navigation property
       EdmNavigationProperty partner = lastNav.getProperty().getPartner();
       if (partner == null) {
-        throw wrap(new UriParserSemanticException("Not enougth keyproperties defined"));
+        throw wrap(new UriParserSemanticException("Not enougth keyproperties defined",
+            UriParserSemanticException.MessageKeys.TEST));
       }
 
       // create the keylist
@@ -1445,7 +1466,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
             missedKey = item;
           } else {
             // two of more keys are missing
-            throw wrap(new UriParserSemanticException("Not enougth referntial contrains defined"));
+            throw wrap(new UriParserSemanticException("Not enougth referntial contrains defined",
+                UriParserSemanticException.MessageKeys.TEST));
           }
         }
       }
@@ -1479,7 +1501,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
 
       // get type of last resource part
       if (!(last instanceof UriResourcePartTyped)) {
-        throw wrap(new UriParserSemanticException("Parameterslist on untyped resource path segement not allowed"));
+        throw wrap(new UriParserSemanticException("Parameterslist on untyped resource path segement not allowed",
+            UriParserSemanticException.MessageKeys.TEST));
       }
       EdmEntityType lastType = (EdmEntityType) ((UriResourcePartTyped) last).getType();
 
@@ -1494,14 +1517,16 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
       // if not, check if the missing key predicates can be satisfied with help of the defined referential constrains
       // for using referential constrains the last resource part must be a navigation property
       if (!(context.contextUriInfo.getLastResourcePart() instanceof UriResourceNavigationPropertyImpl)) {
-        throw wrap(new UriParserSemanticException("Not enougth keyproperties defined"));
+        throw wrap(new UriParserSemanticException("Not enougth keyproperties defined",
+            UriParserSemanticException.MessageKeys.TEST));
       }
       UriResourceNavigationPropertyImpl lastNav = (UriResourceNavigationPropertyImpl) last;
 
       // get the partner of the navigation property
       EdmNavigationProperty partner = lastNav.getProperty().getPartner();
       if (partner == null) {
-        throw wrap(new UriParserSemanticException("Not enougth keyproperties defined"));
+        throw wrap(new UriParserSemanticException("Not enougth keyproperties defined",
+            UriParserSemanticException.MessageKeys.TEST));
       }
 
       // fill missing keys from referential constrains
@@ -1528,7 +1553,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
         return list;
       }
 
-      throw wrap(new UriParserSemanticException("Not enougth keyproperties defined"));
+      throw wrap(new UriParserSemanticException("Not enougth keyproperties defined",
+          UriParserSemanticException.MessageKeys.TEST));
     }
     return new ArrayList<String>();
   }
@@ -1542,7 +1568,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
       uriParameter.setText(ctx.vCOM.getText());
       uriParameter.setExpression((ExpressionImpl) ctx.vCOM.accept(this));
     } else {
-      uriParameter.setAlias(ctx.vALI.getText());
+      uriParameter.setAlias("@" + ctx.vALI.getText());
     }
 
     return uriParameter;
@@ -1631,7 +1657,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
         ((UriResourceWithKeysImpl) pathInfoSegment)
             .setKeyPredicates(list);
       } else {
-        throw wrap(new UriParserSemanticException("Key properties not allowed"));
+        throw wrap(new UriParserSemanticException("Key properties not allowed",
+            UriParserSemanticException.MessageKeys.TEST));
         // throw UriSemanticError.addKrepredicatesNotAllowed();
       }
     }
@@ -1698,7 +1725,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
     UriResource lastResource = context.contextUriInfo.getLastResourcePart();
 
     if (!(lastResource instanceof UriResourcePartTyped)) {
-      throw wrap(new UriParserSemanticException("Resource path not typed"));
+      throw wrap(new UriParserSemanticException("Resource path not typed",
+          UriParserSemanticException.MessageKeys.TEST));
     }
 
     UriResourcePartTyped lastType = (UriResourcePartTyped) lastResource;
@@ -1803,18 +1831,21 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
 
         prevType = getTypeInformation(last).type;
         if (prevType == null) {
-          throw wrap(new UriParserSemanticException("prev segement not typed"));
+          throw wrap(new UriParserSemanticException("prev segement not typed",
+              UriParserSemanticException.MessageKeys.TEST));
         }
       }
 
       if (!(prevType instanceof EdmStructuredType)) {
-        throw wrap(new UriParserSemanticException("Previous select item is not a structural type"));
+        throw wrap(new UriParserSemanticException("Previous select item is not a structural type",
+            UriParserSemanticException.MessageKeys.TEST));
       }
 
       EdmStructuredType structType = (EdmStructuredType) prevType;
       EdmElement element = structType.getProperty(odi);
       if (element == null) {
-        throw wrap(new UriParserSemanticException("Previous select item has not property: " + odi));
+        throw wrap(new UriParserSemanticException("Previous select item has not property: " + odi,
+            UriParserSemanticException.MessageKeys.TEST));
       }
 
       // create new segment
@@ -1864,7 +1895,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
           return this;
         }
       } else {
-        throw wrap(new UriParserSemanticException("Only Simple and Complex properties within select allowed"));
+        throw wrap(new UriParserSemanticException("Only Simple and Complex properties within select allowed",
+            UriParserSemanticException.MessageKeys.TEST));
       }
     } else {
       String namespace = ctx.vNS.getText();
@@ -1916,14 +1948,16 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
             }
           }
         } else {
-          throw wrap(new UriParserSemanticException("prev segement must be comlex of entity type"));
+          throw wrap(new UriParserSemanticException("prev segement must be comlex of entity type",
+              UriParserSemanticException.MessageKeys.TEST));
         }
 
       } else {
         UriInfoImpl uriInfo = (UriInfoImpl) context.contextSelectItem.getResourcePath();
         UriResource last = uriInfo.getLastResourcePart();
         if (!(last instanceof UriResourceTypedImpl)) {
-          throw wrap(new UriParserSemanticException("prev segement typed"));
+          throw wrap(new UriParserSemanticException("prev segement typed",
+              UriParserSemanticException.MessageKeys.TEST));
         }
         EdmType prevType = getTypeInformation(last).type;
 
@@ -1939,7 +1973,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
             }
           }
         } else if (prevType instanceof EdmEntityType) {
-          throw wrap(new UriParserSemanticException("Error"));
+          throw wrap(new UriParserSemanticException("Error", UriParserSemanticException.MessageKeys.TEST));
           /*
            * EdmEntityType et = edm.getEntityType(fullName);
            * if (et != null) {
@@ -1953,7 +1987,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
            * }
            */
         } else {
-          throw wrap(new UriParserSemanticException("prev segement must be comlex of entity type"));
+          throw wrap(new UriParserSemanticException("prev segement must be comlex of entity type",
+              UriParserSemanticException.MessageKeys.TEST));
         }
       }
 
@@ -1964,7 +1999,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
         UriInfoImpl uriInfo = (UriInfoImpl) context.contextSelectItem.getResourcePath();
         UriResource last = uriInfo.getLastResourcePart();
         if (!(last instanceof UriResourceTypedImpl)) {
-          throw wrap(new UriParserSemanticException("prev segement typed"));
+          throw wrap(new UriParserSemanticException("prev segement typed",
+              UriParserSemanticException.MessageKeys.TEST));
         }
         prevType = getTypeInformation(last).type;
       }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserException.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserException.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserException.java
index adb5d01..faa3c63 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserException.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserException.java
@@ -18,18 +18,18 @@
  */
 package org.apache.olingo.server.core.uri.parser;
 
-public class UriParserException extends Exception {
-  /**
-   * 
-   */
-  private static final long serialVersionUID = 1L;
+import org.apache.olingo.server.api.ODataTranslatedException;
 
-  public UriParserException(final String message, final Throwable cause) {
-    super(message, cause);
-  }
+public class UriParserException extends ODataTranslatedException {
+
+  private static final long serialVersionUID = -6438700016830955949L;
 
-  public UriParserException(final String message) {
-    super(message, null);
+  public UriParserException(String developmentMessage, MessageKey messageKey, String... parameters) {
+    super(developmentMessage, messageKey, parameters);
   }
 
+  public UriParserException(String developmentMessage, Throwable cause, MessageKey messageKey,
+      String... parameters) {
+    super(developmentMessage, cause, messageKey, parameters);
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSemanticException.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSemanticException.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSemanticException.java
index 1dd952b..41d178f 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSemanticException.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSemanticException.java
@@ -20,14 +20,18 @@ package org.apache.olingo.server.core.uri.parser;
 
 public class UriParserSemanticException extends UriParserException {
 
-  private static final long serialVersionUID = 1L;
-
-  public UriParserSemanticException(final String message, final Throwable cause) {
-    super(message, cause);
+  private static final long serialVersionUID = 3850285860949809622L;
+  
+  public static enum MessageKeys implements MessageKey {
+    TEST
   }
 
-  public UriParserSemanticException(final String message) {
-    super(message, null);
+  public UriParserSemanticException(String developmentMessage, MessageKey messageKey, String... parameters) {
+    super(developmentMessage, messageKey, parameters);
   }
 
+  public UriParserSemanticException(String developmentMessage, Throwable cause, MessageKey messageKey,
+      String... parameters) {
+    super(developmentMessage, cause, messageKey, parameters);
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSyntaxException.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSyntaxException.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSyntaxException.java
index da7f62c..a7dfdd9 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSyntaxException.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSyntaxException.java
@@ -20,17 +20,18 @@ package org.apache.olingo.server.core.uri.parser;
 
 public class UriParserSyntaxException extends UriParserException {
 
-  /**
-   * 
-   */
-  private static final long serialVersionUID = 1L;
+  private static final long serialVersionUID = 5887744747812478226L;
 
-  public UriParserSyntaxException(final String message, final Throwable cause) {
-    super(message, cause);
+  public static enum MessageKeys implements MessageKey {
+    TEST
   }
-
-  public UriParserSyntaxException(final String message) {
-    super(message, null);
+  
+  public UriParserSyntaxException(String developmentMessage, MessageKey messageKey, String... parameters) {
+    super(developmentMessage, messageKey, parameters);
   }
 
+  public UriParserSyntaxException(String developmentMessage, Throwable cause, MessageKey messageKey,
+      String... parameters) {
+    super(developmentMessage, cause, messageKey, parameters);
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidationException.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidationException.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidationException.java
index 2584932..f175483 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidationException.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidationException.java
@@ -18,17 +18,47 @@
  */
 package org.apache.olingo.server.core.uri.validator;
 
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.server.api.ODataTranslatedException;
 
-public class UriValidationException extends Exception {
+public class UriValidationException extends ODataTranslatedException {
 
   private static final long serialVersionUID = -3179078078053564742L;
 
-  public UriValidationException(final String msg) {
-    super(msg);
+  public static enum MessageKeys implements MessageKey {
+    /** parameter: unsupported query option */
+    UNSUPPORTED_QUERY_OPTION,
+    /** parameter: unsupported uri kind */
+    UNSUPPORTED_URI_KIND,
+    /** parameter: unsupported uri resource kind */
+    UNSUPPORTED_URI_RESOURCE_KIND,
+    /** parameter: unsupported function return type */
+    UNSUPPORTED_FUNCTION_RETURN_TYPE,
+    /** parameter: unsupported action return type */
+    UNSUPPORTED_ACTION_RETURN_TYPE,
+    /** parameter: unsupported http method */
+    UNSUPPORTED_HTTP_METHOD,
+    /** parameter: system query option */
+    SYSTEM_QUERY_OPTION_NOT_ALLOWED,
+    /** parameters: system query option, http method */
+    SYSTEM_QUERY_OPTION_NOT_ALLOWED_FOR_HTTP_METHOD,
+    /** parameter: invalid key property */
+    INVALID_KEY_PROPERTY,
+    /** parameter: untyped segment name */
+    LAST_SEGMENT_NOT_TYPED,
+    /** parameter: untyped segment name */
+    SECOND_LAST_SEGMENT_NOT_TYPED,
+    /** parameter: unallowed kind before $value */
+    UNALLOWED_KIND_BEFORE_VALUE,
+    /** parameter: unallowed kind before $count */
+    UNALLOWED_KIND_BEFORE_COUNT,
+  }
+  
+  public UriValidationException(String developmentMessage, MessageKey messageKey, String... parameters) {
+    super(developmentMessage, messageKey, parameters);
   }
 
-  public UriValidationException(final EdmPrimitiveTypeException e) {
-    super(e);
+  public UriValidationException(String developmentMessage, Throwable cause, MessageKey messageKey,
+      String... parameters) {
+    super(developmentMessage, cause, messageKey, parameters);
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
index f547c48..0cbabbc 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java
@@ -41,6 +41,7 @@ import org.apache.olingo.server.api.uri.UriResourceKind;
 import org.apache.olingo.server.api.uri.UriResourceNavigation;
 import org.apache.olingo.server.api.uri.UriResourcePartTyped;
 import org.apache.olingo.server.api.uri.UriResourceSingleton;
+import org.apache.olingo.server.api.uri.queryoption.CustomQueryOption;
 import org.apache.olingo.server.api.uri.queryoption.SystemQueryOption;
 import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
 
@@ -219,7 +220,8 @@ public class UriValidator {
       idx = ColumnIndex.top;
       break;
     default:
-      throw new UriValidationException("Unsupported option: " + queryOptionKind);
+      throw new UriValidationException("Unsupported option: " + queryOptionKind.toString(),
+          UriValidationException.MessageKeys.UNSUPPORTED_QUERY_OPTION, queryOptionKind.toString());
     }
 
     return idx;
@@ -251,7 +253,8 @@ public class UriValidator {
       idx = RowIndexForUriType.service;
       break;
     default:
-      throw new UriValidationException("Unsupported uriInfo kind: " + uriInfo.getKind());
+      throw new UriValidationException("Unsupported uriInfo kind: " + uriInfo.getKind(),
+          UriValidationException.MessageKeys.UNSUPPORTED_URI_KIND, uriInfo.getKind().toString());
     }
 
     return idx;
@@ -300,7 +303,8 @@ public class UriValidator {
       idx = rowIndexForValue(uriInfo);
       break;
     default:
-      throw new UriValidationException("Unsupported uriResource kind: " + lastPathSegment.getKind());
+      throw new UriValidationException("Unsupported uriResource kind: " + lastPathSegment.getKind(),
+          UriValidationException.MessageKeys.UNSUPPORTED_URI_RESOURCE_KIND, lastPathSegment.getKind().toString());
     }
 
     return idx;
@@ -367,7 +371,8 @@ public class UriValidator {
       break;
     default:
       throw new UriValidationException("Unexpected kind in path segment before $value: "
-          + secondLastPathSegment.getKind());
+          + secondLastPathSegment.getKind(), UriValidationException.MessageKeys.UNALLOWED_KIND_BEFORE_VALUE,
+          secondLastPathSegment.toString());
     }
     return idx;
   }
@@ -388,7 +393,8 @@ public class UriValidator {
       idx = isCollection ? RowIndexForUriType.propertyPrimitiveCollection : RowIndexForUriType.propertyPrimitive;
       break;
     default:
-      throw new UriValidationException("Unsupported function return type: " + functionReturnTypeKind);
+      throw new UriValidationException("Unsupported function return type: " + functionReturnTypeKind,
+          UriValidationException.MessageKeys.UNSUPPORTED_FUNCTION_RETURN_TYPE, functionReturnTypeKind.toString());
     }
     return idx;
   }
@@ -405,7 +411,8 @@ public class UriValidator {
               : RowIndexForUriType.reference;
     } else {
       throw new UriValidationException("secondLastPathSegment not a class of UriResourcePartTyped: "
-          + lastPathSegment.getClass());
+          + lastPathSegment.getClass(), UriValidationException.MessageKeys.LAST_SEGMENT_NOT_TYPED, lastPathSegment
+          .toString());
     }
 
     return idx;
@@ -420,7 +427,8 @@ public class UriValidator {
               : RowIndexForUriType.propertyPrimitive;
     } else {
       throw new UriValidationException("lastPathSegment not a class of UriResourcePartTyped: "
-          + lastPathSegment.getClass());
+          + lastPathSegment.getClass(), UriValidationException.MessageKeys.LAST_SEGMENT_NOT_TYPED, lastPathSegment
+          .toString());
     }
     return idx;
   }
@@ -444,7 +452,9 @@ public class UriValidator {
       idx = rt.isCollection() ? RowIndexForUriType.propertyComplexCollection : RowIndexForUriType.propertyComplex;
       break;
     default:
-      throw new UriValidationException("Unsupported function return type: " + rt.getType().getKind());
+      throw new UriValidationException("Unsupported function return type: " + rt.getType().getKind(),
+          UriValidationException.MessageKeys.UNSUPPORTED_FUNCTION_RETURN_TYPE,
+          rt.getType().getKind().toString());
     }
 
     return idx;
@@ -458,7 +468,8 @@ public class UriValidator {
               : RowIndexForUriType.entity;
     } else {
       throw new UriValidationException("lastPathSegment not a class of UriResourcePartTyped: "
-          + lastPathSegment.getClass());
+          + lastPathSegment.getClass(), UriValidationException.MessageKeys.LAST_SEGMENT_NOT_TYPED, lastPathSegment
+          .toString());
     }
     return idx;
   }
@@ -472,7 +483,8 @@ public class UriValidator {
               : RowIndexForUriType.propertyComplex;
     } else {
       throw new UriValidationException("lastPathSegment not a class of UriResourcePartTyped: "
-          + lastPathSegment.getClass());
+          + lastPathSegment.getClass(), UriValidationException.MessageKeys.LAST_SEGMENT_NOT_TYPED, lastPathSegment
+          .toString());
     }
     return idx;
   }
@@ -496,7 +508,8 @@ public class UriValidator {
       idx = rt.isCollection() ? RowIndexForUriType.propertyComplexCollection : RowIndexForUriType.propertyComplex;
       break;
     default:
-      throw new UriValidationException("Unsupported action return type: " + rt.getType().getKind());
+      throw new UriValidationException("Unsupported action return type: " + rt.getType().getKind(),
+          UriValidationException.MessageKeys.UNSUPPORTED_ACTION_RETURN_TYPE, rt.getType().getKind().toString());
     }
 
     return idx;
@@ -535,7 +548,8 @@ public class UriValidator {
       idx = determineReturnType(functionReturnTypeKind, isCollection);
       break;
     default:
-      throw new UriValidationException("Illegal path part kind: " + secondLastPathSegment.getKind());
+      throw new UriValidationException("Illegal path part kind before $count: " + secondLastPathSegment.getKind(),
+          UriValidationException.MessageKeys.UNALLOWED_KIND_BEFORE_COUNT, secondLastPathSegment.toString());
     }
 
     return idx;
@@ -548,7 +562,8 @@ public class UriValidator {
       ColumnIndex col = colIndex(option.getKind());
 
       if (!decisionMatrix[row.getIndex()][col.getIndex()]) {
-        throw new UriValidationException("System query option not allowed: " + option.getName());
+        throw new UriValidationException("System query option not allowed: " + option.getName(),
+            UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED, option.getName());
       }
     }
 
@@ -561,7 +576,8 @@ public class UriValidator {
       ColumnIndex col = colIndex(option.getKind());
       if (!decisionMatrixForHttpMethod[row.getIndex()][col.getIndex()]) {
         throw new UriValidationException("System query option " + option.getName() + " not allowed for method "
-            + httpMethod);
+            + httpMethod, UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED_FOR_HTTP_METHOD, option
+            .getName(), httpMethod.toString());
       }
     }
 
@@ -590,7 +606,8 @@ public class UriValidator {
       idx = RowIndexForHttpMethod.MERGE;
       break;
     default:
-      throw new UriValidationException("HTTP method not supported: " + httpMethod);
+      throw new UriValidationException("HTTP method not supported: " + httpMethod,
+          UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD, httpMethod.toString());
     }
 
     return idx;
@@ -619,26 +636,39 @@ public class UriValidator {
 
             for (UriParameter keyPredicate : keyPredicates) {
               String name = keyPredicate.getName();
+              String alias = keyPredicate.getAlias();
               String value = keyPredicate.getText();
+              if (alias != null) {
+                value = uriInfo.getValueForAlias(alias);
+              }
               EdmKeyPropertyRef edmKey = edmKeys.get(name);
 
               if (edmKey == null) {
-                throw new UriValidationException("Unknown key property: " + name);
+                throw new UriValidationException("Unknown key property: " + name,
+                    UriValidationException.MessageKeys.INVALID_KEY_PROPERTY, name);
               }
 
               EdmType edmType = edmKey.getProperty().getType();
               EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType;
 
               String edmLiteral = edmPrimitiveType.fromUriLiteral(value);
-              edmPrimitiveType.validate(edmLiteral, edmKey.getProperty().isNullable(), edmKey.getProperty()
-                  .getMaxLength(), edmKey.getProperty().getPrecision(), edmKey.getProperty().getScale(), edmKey
-                  .getProperty().isUnicode());
+              boolean isValid =
+                  edmPrimitiveType.validate(edmLiteral, edmKey.getProperty().isNullable(), edmKey.getProperty()
+                      .getMaxLength(), edmKey.getProperty().getPrecision(), edmKey.getProperty().getScale(), edmKey
+                      .getProperty().isUnicode());
+              if (!isValid) {
+                // TODO: Check exception here
+                throw new UriValidationException("PrimitiveTypeException",
+                    UriValidationException.MessageKeys.INVALID_KEY_PROPERTY);
+              }
             }
           }
         }
       }
     } catch (EdmPrimitiveTypeException e) {
-      throw new UriValidationException(e);
+      // TODO: Check exception here
+      throw new UriValidationException("PrimitiveTypeException", e,
+          UriValidationException.MessageKeys.INVALID_KEY_PROPERTY);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
index 5eaff89..7e55ab8 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/ODataHandlerTest.java
@@ -29,7 +29,9 @@ import java.util.Arrays;
 import java.util.Locale;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.olingo.commons.api.ODataException;
 import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.api.format.ContentType;
 import org.apache.olingo.commons.api.http.HttpContentType;
@@ -40,11 +42,14 @@ import org.apache.olingo.server.api.OData;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.ODataRequest;
 import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.edm.provider.EdmProvider;
+import org.apache.olingo.server.api.edm.provider.EntitySet;
 import org.apache.olingo.server.api.processor.MetadataProcessor;
 import org.apache.olingo.server.api.processor.ServiceDocumentProcessor;
 import org.apache.olingo.server.api.uri.UriInfo;
 import org.apache.olingo.server.tecsvc.provider.EdmTechProvider;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class ODataHandlerTest {
@@ -220,6 +225,18 @@ public class ODataHandlerTest {
   }
 
   @Test
+  public void testUnregisteredProcessor() {
+    ODataRequest request = new ODataRequest();
+
+    request.setMethod(HttpMethod.GET);
+    request.setRawODataPath("ESAllPrim");
+
+    ODataResponse response = handler.process(request);
+    assertNotNull(response);
+    assertEquals(501, response.getStatusCode());
+  }
+
+  @Test
   public void testWithApplicationExceptionInProcessor() throws Exception {
     ODataRequest request = new ODataRequest();
 
@@ -227,13 +244,65 @@ public class ODataHandlerTest {
     request.setRawODataPath("$metadata");
 
     MetadataProcessor metadataProcessor = mock(MetadataProcessor.class);
-    doThrow(new ODataApplicationException("msg", 412, Locale.ENGLISH)).when(metadataProcessor).readMetadata(
+    doThrow(new ODataApplicationException("msg", 425, Locale.ENGLISH)).when(metadataProcessor).readMetadata(
         any(ODataRequest.class), any(ODataResponse.class), any(UriInfo.class), any(ContentType.class));
 
     handler.register(metadataProcessor);
 
     ODataResponse response = handler.process(request);
     assertNotNull(response);
-    assertEquals(412, response.getStatusCode());
+    assertEquals(425, response.getStatusCode());
+  }
+  
+  //TODO: Use this test
+  @Ignore
+  @Test
+  public void testUriParserExceptionResultsInRightResponseNotFound() throws Exception {
+    ODataRequest request = new ODataRequest();
+
+    request.setMethod(HttpMethod.GET);
+    request.setRawODataPath("NotFound");
+
+    ODataResponse response = handler.process(request);
+    assertNotNull(response);
+    assertEquals(404, response.getStatusCode());
+  }
+  
+  //TODO: Use this test
+  @Ignore
+  @Test
+  public void testUriParserExceptionResultsInRightResponseBadRequest() throws Exception {
+    ODataRequest request = new ODataRequest();
+
+    request.setMethod(HttpMethod.GET);
+    request.setRawODataPath("ESAllPrim()");
+
+    ODataResponse response = handler.process(request);
+    assertNotNull(response);
+    assertEquals(404, response.getStatusCode());
+  }
+  
+  @Test
+  public void testUriParserExceptionResultsInRightResponseEdmCause() throws Exception {
+    ODataRequest request = new ODataRequest();
+
+    request.setMethod(HttpMethod.GET);
+    request.setRawODataPath("EdmException");
+
+    OData odata = OData.newInstance();
+    Edm edm = odata.createEdm(new EdmProvider() {
+      public EntitySet getEntitySet(final FullQualifiedName entityContainer, final String entitySetName)
+          throws ODataException {
+        throw new ODataException("msg");
+      }
+    });
+
+    ODataHandler localHandler = new ODataHandler(odata, edm);
+    
+    ODataResponse response = localHandler.process(request);
+    assertNotNull(response);
+    assertEquals(500, response.getStatusCode());
+    // TODO: Check for message in case of EdmException
+    // System.out.println(IOUtils.toString(response.getContent()));
   }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java
index d5adc79..91b58c0 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/UriInfoImplTest.java
@@ -148,21 +148,21 @@ public class UriInfoImplTest {
 
     QueryOptionImpl queryOption = new QueryOptionImpl();
 
-    queryOptions.add(expand);
-    queryOptions.add(filter);
-    queryOptions.add(format);
-    queryOptions.add(id);
-    queryOptions.add(inlinecount);
-    queryOptions.add(orderby);
-    queryOptions.add(search);
-    queryOptions.add(select);
-    queryOptions.add(skip);
-    queryOptions.add(skipToken);
-    queryOptions.add(top);
-    queryOptions.add(customOption0);
-    queryOptions.add(customOption1);
-    queryOptions.add(levels);// not stored
-    queryOptions.add(queryOption);// not stored
+    queryOptions.add(expand.setName(""));
+    queryOptions.add(filter.setName(""));
+    queryOptions.add(format.setName(""));
+    queryOptions.add(id.setName(""));
+    queryOptions.add(inlinecount.setName(""));
+    queryOptions.add(orderby.setName(""));
+    queryOptions.add(search.setName(""));
+    queryOptions.add(select.setName(""));
+    queryOptions.add(skip.setName(""));
+    queryOptions.add(skipToken.setName(""));
+    queryOptions.add(top.setName(""));
+    queryOptions.add(customOption0.setName(""));
+    queryOptions.add(customOption1.setName(""));
+    queryOptions.add(levels.setName(""));// not stored
+    queryOptions.add(queryOption.setName(""));// not stored
     uriInfo.setQueryOptions(queryOptions);
 
     assertEquals(expand, uriInfo.getExpandOption());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
index a6f33ec..37da223 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
@@ -1067,21 +1067,18 @@ public class TestFullResourcePath {
         .isKeyPredicate(2, "KeyAlias2", "'3'")
         .isKeyPredicate(3, "KeyAlias3", "'4'");
 
-    testUri.run("ESCollAllPrim(null)")
-        .isKind(UriInfoKind.resource).goPath()
-        .first()
-        .isEntitySet("ESCollAllPrim");
+    testUri.runEx("ESCollAllPrim(null)").isExValidation("");
   }
 
   @Test
   public void runEsNameParaKeys() throws Exception {
     testUri.run(encode("ESAllKey(PropertyString='O''Neil',PropertyBoolean=true,PropertyByte=255,"
         + "PropertySByte=-128,PropertyInt16=-32768,PropertyInt32=-2147483648,"
-        + "PropertyInt64=-9223372036854775808,PropertyDecimal=0.1,PropertyDate=2013-09-25,"
+        + "PropertyInt64=-9223372036854775808,PropertyDecimal=1,PropertyDate=2013-09-25,"
         + "PropertyDateTimeOffset=2002-10-10T12:00:00-05:00,"
-        + "PropertyDuration=duration'P10DT5H34M21.123456789012S',"
+        + "PropertyDuration=duration'P50903316DT2H25M4S',"
         + "PropertyGuid=12345678-1234-1234-1234-123456789012,"
-        + "PropertyTimeOfDay=12:34:55.123456789012)"))
+        + "PropertyTimeOfDay=12:34:55)"))
         .isKind(UriInfoKind.resource).goPath()
         .first()
         .isEntitySet("ESAllKey")
@@ -1092,12 +1089,12 @@ public class TestFullResourcePath {
         .isKeyPredicate(4, "PropertyInt16", "-32768")
         .isKeyPredicate(5, "PropertyInt32", "-2147483648")
         .isKeyPredicate(6, "PropertyInt64", "-9223372036854775808")
-        .isKeyPredicate(7, "PropertyDecimal", "0.1")
+        .isKeyPredicate(7, "PropertyDecimal", "1")
         .isKeyPredicate(8, "PropertyDate", "2013-09-25")
         .isKeyPredicate(9, "PropertyDateTimeOffset", "2002-10-10T12:00:00-05:00")
-        .isKeyPredicate(10, "PropertyDuration", "duration'P10DT5H34M21.123456789012S'")
+        .isKeyPredicate(10, "PropertyDuration", "duration'P50903316DT2H25M4S'")
         .isKeyPredicate(11, "PropertyGuid", "12345678-1234-1234-1234-123456789012")
-        .isKeyPredicate(12, "PropertyTimeOfDay", "12:34:55.123456789012");
+        .isKeyPredicate(12, "PropertyTimeOfDay", "12:34:55");
   }
 
   @Test
@@ -3321,7 +3318,7 @@ public class TestFullResourcePath {
         .goPath()
         .first()
         .isFunction("UFCRTETTwoKeyNavParamCTTwoPrim")
-        .isParameterAlias(0, "ParameterCTTwoPrim", "ParamAlias");
+        .isParameterAlias(0, "ParameterCTTwoPrim", "@ParamAlias");
 
     testFilter.runOnETTwoKeyNav("PropertyComp"
         + "/com.sap.odata.test1.BFCCTPrimCompRTESTwoKeyNavParam"
@@ -3446,7 +3443,7 @@ public class TestFullResourcePath {
         .root().left().goPath()
         .first()
         .isFunction("UFCRTETTwoKeyNavParam")
-        .isParameterAlias(0, "ParameterInt16", "Param1Alias")
+        .isParameterAlias(0, "ParameterInt16", "@Param1Alias")
         .n()
         .isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false);
 
@@ -5091,7 +5088,8 @@ public class TestFullResourcePath {
   public void testAlias() throws Exception {
     testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString=@A)?@A='2'").goPath()
         .isKeyPredicate(0, "PropertyInt16", "1")
-        .isKeyPredicateAlias(1, "PropertyString", "A")
+        .isKeyPredicateAlias(1, "PropertyString", "@A")
+        .isInAliasToValueMap("@A", "'2'")
         .goUpUriValidator()
         .isCustomParameter(0, "@A", "'2'");
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
index 299af41..bd91666 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestUriParserImpl.java
@@ -47,14 +47,14 @@ public class TestUriParserImpl {
   private final String PropertyDate = "PropertyDate=2013-09-25";
   private final String PropertyDateTimeOffset = "PropertyDateTimeOffset=2002-10-10T12:00:00-05:00";
   private final String PropertyDecimal = "PropertyDecimal=12";
-  private final String PropertyDuration = "PropertyDuration=duration'P10DT5H34M21.123456789012S'";
+  private final String PropertyDuration = "PropertyDuration=duration'P50903316DT2H25M4S'";
   private final String PropertyGuid = "PropertyGuid=12345678-1234-1234-1234-123456789012";
   private final String PropertyInt16 = "PropertyInt16=1";
   private final String PropertyInt32 = "PropertyInt32=12";
   private final String PropertyInt64 = "PropertyInt64=64";
   private final String PropertySByte = "PropertySByte=1";
   private final String PropertyString = "PropertyString='ABC'";
-  private final String PropertyTimeOfDay = "PropertyTimeOfDay=12:34:55.123456789012";
+  private final String PropertyTimeOfDay = "PropertyTimeOfDay=12:34:55";
 
   private final String allKeys = PropertyString + "," + PropertyInt16 + "," + PropertyBoolean + "," + PropertyByte
       + "," + PropertySByte + "," + PropertyInt32 + "," + PropertyInt64 + "," + PropertyDecimal + "," + PropertyDate
@@ -358,9 +358,9 @@ public class TestUriParserImpl {
         .isKeyPredicate(7, "PropertyDecimal", "12")
         .isKeyPredicate(8, "PropertyDate", "2013-09-25")
         .isKeyPredicate(9, "PropertyDateTimeOffset", "2002-10-10T12:00:00-05:00")
-        .isKeyPredicate(10, "PropertyDuration", "duration'P10DT5H34M21.123456789012S'")
+        .isKeyPredicate(10, "PropertyDuration", "duration'P50903316DT2H25M4S'")
         .isKeyPredicate(11, "PropertyGuid", "12345678-1234-1234-1234-123456789012")
-        .isKeyPredicate(12, "PropertyTimeOfDay", "12:34:55.123456789012");
+        .isKeyPredicate(12, "PropertyTimeOfDay", "12:34:55");
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
index 4502ca6..0332c73 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java
@@ -597,4 +597,10 @@ public class ResourceValidator implements TestValidator {
     return this;
   }
 
+  public ResourceValidator isInAliasToValueMap(String alias, String value) {
+    String valueForAlias = uriInfo.getValueForAlias(alias);
+    assertEquals(value, valueForAlias);
+    return this;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
index 022954b..300c8fc 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java
@@ -71,9 +71,12 @@ public class TestUriValidator implements TestValidator {
     uriInfo = null;
     try {
       uriInfo = (UriInfoImpl) parser.parseUri(uri, edm);
+      new UriValidator().validate(uriInfo, HttpMethod.GET);
       fail("Exception expected");
     } catch (UriParserException e) {
       exception = e;
+    } catch (UriValidationException e) {
+      exception = e;
     }
 
     return this;
@@ -252,4 +255,9 @@ public class TestUriValidator implements TestValidator {
     return this;
   }
 
+  public TestUriValidator isExValidation(String string) {
+    assertEquals(UriValidationException.class, exception.getClass());
+    return this;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/d19afa01/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
index cdb8bc9..3b8ccb9 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/validator/UriValidatorTest.java
@@ -331,6 +331,12 @@ public class UriValidatorTest {
     parseAndValidate(uri, HttpMethod.GET);
   }
 
+  @Test(expected = UriValidationException.class)
+  public void validateKeyPredicatesWrongValueTypeForValidateMethod() throws Exception {
+    String uri = "ESTwoKeyNav(PropertyInt16='abc', PropertyString='abc')";
+    parseAndValidate(uri, HttpMethod.GET);
+  }
+  
   @Test
   public void checkValidSystemQueryOption() throws Exception {
     String[] uris = constructUri(urisWithValidSystemQueryOptions);