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 2016/01/18 13:35:03 UTC
[2/3] olingo-odata4 git commit: [OLINGO-834] clean-up exceptions
[OLINGO-834] clean-up exceptions
Signed-off-by: Christian Amend <ch...@sap.com>
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/6837fd76
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/6837fd76
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/6837fd76
Branch: refs/heads/master
Commit: 6837fd765152a23dc208546d32188e6cc34c3858
Parents: b881e9c
Author: Klaus Straubinger <kl...@sap.com>
Authored: Wed Jan 13 16:15:44 2016 +0100
Committer: Christian Amend <ch...@sap.com>
Committed: Mon Jan 18 13:30:11 2016 +0100
----------------------------------------------------------------------
.../core/uri/parser/ExpressionParser.java | 20 +++++++++----------
.../uri/parser/UriParserSemanticException.java | 21 +-------------------
.../uri/validator/UriValidationException.java | 2 --
.../server-core-exceptions-i18n.properties | 15 --------------
4 files changed, 11 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6837fd76/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpressionParser.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpressionParser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpressionParser.java
index 6fa415f..ef7d6da 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpressionParser.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpressionParser.java
@@ -560,9 +560,10 @@ public class ExpressionParser {
}
break;
- default:
- throw new UriParserSemanticException("Unkown method '" + methodKind.name() + "'",
- UriParserSemanticException.MessageKeys.NOT_IMPLEMENTED, methodKind.name()); // TODO: better message
+ // Can have one or two parameters. These methods are handled elsewhere.
+ case CAST:
+ case ISOF:
+ break;
}
ParserHelper.requireNext(tokenizer, TokenKind.CLOSE);
return parameters;
@@ -1108,11 +1109,10 @@ public class ExpressionParser {
private void checkType(final Expression expression, final EdmPrimitiveTypeKind... kinds) throws UriParserException {
final EdmType type = getType(expression);
if (!isType(type, kinds)) {
- throw new UriParserSemanticException("Incompatible type.",
- UriParserSemanticException.MessageKeys.UNKNOWN_TYPE, // TODO: better message
- type == null ?
- "" :
- type.getFullQualifiedName().getFullQualifiedNameAsString());
+ throw new UriParserSemanticException("Incompatible types.",
+ UriParserSemanticException.MessageKeys.TYPES_NOT_COMPATIBLE,
+ type == null ? "" : type.getFullQualifiedName().getFullQualifiedNameAsString(),
+ Arrays.deepToString(kinds));
}
}
@@ -1166,8 +1166,8 @@ public class ExpressionParser {
return new EnumerationImpl(enumType,
Arrays.asList(enumType.fromUriLiteral(primitiveValueLiteral).split(",")));
} catch (final EdmPrimitiveTypeException e) {
- // TODO: Better error message.
- throw new UriParserSemanticException("Wrong enumeration value.", e,
+ // This part should not be reached, so a general error message key can be re-used.
+ throw new UriParserSemanticException("Wrong enumeration value '" + primitiveValueLiteral + "'.", e,
UriParserSemanticException.MessageKeys.UNKNOWN_PART, primitiveValueLiteral);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6837fd76/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 8f5aa67..423c875 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
@@ -27,8 +27,6 @@ public class UriParserSemanticException extends UriParserException {
/** parameters: function-import name, function parameters */
FUNCTION_NOT_FOUND,
/** parameter: resource part */
- RESOURCE_PART_ONLY_FOR_TYPED_PARTS,
- /** parameter: resource part */
RESOURCE_PART_MUST_BE_PRECEDED_BY_STRUCTURAL_TYPE,
/** parameter: property name */
PROPERTY_AFTER_COLLECTION,
@@ -36,54 +34,37 @@ public class UriParserSemanticException extends UriParserException {
PROPERTY_NOT_IN_TYPE,
/** parameters: type name, property name */
EXPRESSION_PROPERTY_NOT_IN_TYPE,
- /** parameter: property name */
- UNKNOWN_PROPERTY_TYPE,
/** parameter: type filter */
INCOMPATIBLE_TYPE_FILTER,
/** parameters: previous type filter, last type filter */
TYPE_FILTER_NOT_CHAINABLE,
/** parameter: type filter */
PREVIOUS_PART_NOT_TYPED,
- /** parameter: type */
- FUNCTION_PARAMETERS_EXPECTED,
/** parameter: resource part */
UNKNOWN_PART,
/** parameter: type */
UNKNOWN_TYPE,
/** parameter: expression */
ONLY_FOR_TYPED_PARTS,
- /** parameter: entity type name */
- UNKNOWN_ENTITY_TYPE,
/** parameter: expression */
ONLY_FOR_COLLECTIONS,
/** parameter: expression */
ONLY_FOR_ENTITY_TYPES,
/** parameter: expression */
ONLY_FOR_STRUCTURAL_TYPES,
- /** parameter: expression */
- ONLY_FOR_TYPED_PROPERTIES,
/** parameter: value */
INVALID_KEY_VALUE,
- PARAMETERS_LIST_ONLY_FOR_TYPED_PARTS,
/** parameters: expected number, actual number */
WRONG_NUMBER_OF_KEY_PROPERTIES,
- NOT_ENOUGH_REFERENTIAL_CONSTRAINTS,
KEY_NOT_ALLOWED,
- RESOURCE_PATH_NOT_TYPED,
- ONLY_SIMPLE_AND_COMPLEX_PROPERTIES_IN_SELECT,
- COMPLEX_PROPERTY_OF_ENTITY_TYPE_EXPECTED,
- NOT_FOR_ENTITY_TYPE,
- PREVIOUS_PART_TYPED,
/** parameter: resource_name */
RESOURCE_NOT_FOUND,
/** parameter: not implemented part */
NOT_IMPLEMENTED,
- /** parameter: namespace **/
+ /** parameter: namespace */
NAMESPACE_NOT_ALLOWED_AT_FIRST_ELEMENT,
/** parameter: complex parameter value */
COMPLEX_PARAMETER_IN_RESOURCE_PATH,
- /** parameter: function import name */
- FUNCTION_IMPORT_NOT_ALLOWED,
/** parameters: left type, right type */
TYPES_NOT_COMPATIBLE;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6837fd76/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 2d8f842..1656150 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
@@ -49,8 +49,6 @@ public class UriValidationException extends ODataLibraryException {
DOUBLE_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 */
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/6837fd76/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties b/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties
index e178fed..6bbad3b 100644
--- a/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties
+++ b/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties
@@ -50,41 +50,27 @@ SearchTokenizerException.NOT_FINISHED_QUERY=Search query end in an invalid state
SearchTokenizerException.INVALID_TOKEN_STATE=Token '%1$s' is in an invalid state.
SearchTokenizerException.ALREADY_FINISHED=Token '%1$s' is already in finished state.
-
UriParserSemanticException.FUNCTION_NOT_FOUND=The function import '%1$s' has no function with parameters '%2$s'.
-UriParserSemanticException.RESOURCE_PART_ONLY_FOR_TYPED_PARTS='%1$s' is only allowed for typed parts.
UriParserSemanticException.RESOURCE_PART_MUST_BE_PRECEDED_BY_STRUCTURAL_TYPE=The resource part '%1$s' must be preceded by a structural type.
UriParserSemanticException.PROPERTY_AFTER_COLLECTION=The property '%1$s' must not follow a collection.
UriParserSemanticException.PROPERTY_NOT_IN_TYPE=The type '%1$s' has no property '%2$s'.
UriParserSemanticException.EXPRESSION_PROPERTY_NOT_IN_TYPE=The property '%2$s', used in a query expression, is not defined in type '%1$s'.
-UriParserSemanticException.UNKNOWN_PROPERTY_TYPE=The type of the property '%1$s' is unknown.
UriParserSemanticException.INCOMPATIBLE_TYPE_FILTER=The type filter '%1$s' is incompatible.
UriParserSemanticException.TYPE_FILTER_NOT_CHAINABLE=The type filter '%2$s' can not be chained with '%1$s'.
UriParserSemanticException.PREVIOUS_PART_NOT_TYPED=The previous part of the type filter '%1$s' is not typed.
-UriParserSemanticException.FUNCTION_PARAMETERS_EXPECTED=Function parameters expected for type '%1$s'.
UriParserSemanticException.UNKNOWN_PART=The part '%1$s' is not defined.
UriParserSemanticException.ONLY_FOR_TYPED_PARTS='%1$s' is only allowed for typed parts.
-UriParserSemanticException.UNKNOWN_ENTITY_TYPE=The entity type '%1$s' is not defined.
UriParserSemanticException.UNKNOWN_TYPE=The type of the type cast '%1$s' is not defined.
UriParserSemanticException.ONLY_FOR_COLLECTIONS='%1$s' is only allowed for collections.
UriParserSemanticException.ONLY_FOR_ENTITY_TYPES='%1$s' is only allowed for entity types.
UriParserSemanticException.ONLY_FOR_STRUCTURAL_TYPES='%1$s' is only allowed for structural types.
-UriParserSemanticException.ONLY_FOR_TYPED_PROPERTIES='%1$s' is only allowed for typed properties.
UriParserSemanticException.INVALID_KEY_VALUE=The key value '%1$s' is invalid.
-UriParserSemanticException.PARAMETERS_LIST_ONLY_FOR_TYPED_PARTS=A list of parameters is only allowed for typed parts.
UriParserSemanticException.WRONG_NUMBER_OF_KEY_PROPERTIES=There are %2$s key properties instead of the expected %1$s.
-UriParserSemanticException.NOT_ENOUGH_REFERENTIAL_CONSTRAINTS=There are not enough referential constraints.
UriParserSemanticException.KEY_NOT_ALLOWED=A key is not allowed.
-UriParserSemanticException.RESOURCE_PATH_NOT_TYPED=The resource path is not typed.
-UriParserSemanticException.ONLY_SIMPLE_AND_COMPLEX_PROPERTIES_IN_SELECT=Only simple and complex properties are allowed in selection.
-UriParserSemanticException.COMPLEX_PROPERTY_OF_ENTITY_TYPE_EXPECTED=A complex property of an entity type is expected.
-UriParserSemanticException.NOT_FOR_ENTITY_TYPE=Not allowed for entity type.
-UriParserSemanticException.PREVIOUS_PART_TYPED=The previous part is typed.
UriParserSemanticException.RESOURCE_NOT_FOUND=Cannot find EntitySet, Singleton, ActionImport or FunctionImport with name '%1$s'.
UriParserSemanticException.NOT_IMPLEMENTED='%1$s' is not implemented!
UriParserSemanticException.NAMESPACE_NOT_ALLOWED_AT_FIRST_ELEMENT=Namespace is not allowed for Entity Sets, Singletons, Action Imports and Function Imports; found '%1$s'.
UriParserSemanticException.COMPLEX_PARAMETER_IN_RESOURCE_PATH=Complex parameters must not appear in resource path segments; found: '%1$s'.
-UriParserSemanticException.FUNCTION_IMPORT_NOT_ALLOWED=Function Imports are not allowed in $filter or $orderby. Found: '%1$s'.
UriParserSemanticException.TYPES_NOT_COMPATIBLE=The types '%1$s' and '%2$s' are not compatible.
UriValidationException.UNSUPPORTED_QUERY_OPTION=The query option '%1$s' is not supported.
@@ -99,7 +85,6 @@ UriValidationException.SYSTEM_QUERY_OPTION_NOT_ALLOWED_FOR_HTTP_METHOD=The syste
UriValidationException.INVALID_KEY_PROPERTY=The key property '%1$s' is invalid.
UriValidationException.DOUBLE_KEY_PROPERTY=The key property '%1$s' has been specified twice.
UriValidationException.LAST_SEGMENT_NOT_TYPED=The last segment '%1$s' is not typed.
-UriValidationException.SECOND_LAST_SEGMENT_NOT_TYPED=The second last segment '%1$s' is not typed.
UriValidationException.UNALLOWED_KIND_BEFORE_VALUE=The kind '%1$s' is not allowed before '$value'.
UriValidationException.UNALLOWED_KIND_BEFORE_COUNT=The kind '%1$s' is not allowed before '$count'.
UriValidationException.UNALLOWED_RESOURCE_PATH=The resource part '%1$s' is not allowed.