http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceEntitySetImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceEntitySetImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceEntitySetImpl.java deleted file mode 100644 index bf6d47b..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceEntitySetImpl.java +++ /dev/null @@ -1,66 +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.core.uri; - -import org.apache.olingo.commons.api.edm.EdmEntitySet; -import org.apache.olingo.commons.api.edm.EdmEntityType; -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.server.api.uri.UriResourceEntitySet; -import org.apache.olingo.server.api.uri.UriResourceKind; - -public class UriResourceEntitySetImpl extends UriResourceWithKeysImpl implements UriResourceEntitySet { - protected EdmEntitySet edmEntitySet = null; - - public UriResourceEntitySetImpl() { - super(UriResourceKind.entitySet); - } - - @Override - public EdmEntitySet getEntitySet() { - return edmEntitySet; - } - - public UriResourceEntitySetImpl setEntitSet(final EdmEntitySet edmES) { - edmEntitySet = edmES; - return this; - } - - @Override - public EdmEntityType getEntityType() { - return edmEntitySet.getEntityType(); - } - - @Override - public EdmType getType() { - return edmEntitySet.getEntityType(); - } - - @Override - public boolean isCollection() { - if (keyPredicates == null) { - return true; - } - return false; - } - - @Override - public String toString() { - return edmEntitySet.getName(); - } -}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceFunctionImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceFunctionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceFunctionImpl.java deleted file mode 100644 index 8daa810..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceFunctionImpl.java +++ /dev/null @@ -1,111 +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.core.uri; - -import org.apache.olingo.commons.api.edm.EdmFunction; -import org.apache.olingo.commons.api.edm.EdmFunctionImport; -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.server.api.uri.UriParameter; -import org.apache.olingo.server.api.uri.UriResourceFunction; -import org.apache.olingo.server.api.uri.UriResourceKind; - -import java.util.ArrayList; -import java.util.List; - -/** - * Covers Function imports and BoundFunction in URI - */ -public class UriResourceFunctionImpl extends UriResourceWithKeysImpl implements UriResourceFunction { - - protected List<UriParameterImpl> parameters; - protected EdmFunction function; - protected EdmFunctionImport functionImport; - private boolean isParameterListFilled = false; - - public UriResourceFunctionImpl() { - super(UriResourceKind.function); - } - - @Override - public List<UriParameter> getParameters() { - List<UriParameter> retList = new ArrayList<UriParameter>(); - for (UriParameterImpl item : parameters) { - retList.add(item); - } - return retList; - } - - public UriResourceFunctionImpl setParameters(final List<UriParameterImpl> parameters) { - isParameterListFilled = true; - this.parameters = parameters; - return this; - } - - @Override - public EdmFunction getFunction() { - return function; - } - - public UriResourceFunctionImpl setFunction(final EdmFunction function) { - this.function = function; - return this; - } - - @Override - public EdmFunctionImport getFunctionImport() { - return functionImport; - } - - public UriResourceFunctionImpl setFunctionImport(final EdmFunctionImport edmFI, - final List<UriParameterImpl> parameters) { - functionImport = edmFI; - - setParameters(parameters); - - return this; - } - - @Override - public EdmType getType() { - return function.getReturnType().getType(); - } - - @Override - public boolean isCollection() { - if (keyPredicates != null) { - return false; - } - return function.getReturnType().isCollection(); - } - - @Override - public String toString() { - if (functionImport != null) { - return functionImport.getName(); - } else if (function != null) { - return function.getName(); - } - return ""; - } - - public boolean isParameterListFilled() { - return isParameterListFilled; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceImpl.java deleted file mode 100644 index 9fbcbd0..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceImpl.java +++ /dev/null @@ -1,39 +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.core.uri; - -import org.apache.olingo.server.api.uri.UriResource; -import org.apache.olingo.server.api.uri.UriResourceKind; - -/** - * Covers Functionimports and BoundFunction in URI - */ -public abstract class UriResourceImpl implements UriResource { - protected UriResourceKind kind; - - public UriResourceImpl(final UriResourceKind kind) { - this.kind = kind; - } - - @Override - public UriResourceKind getKind() { - return kind; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceItImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceItImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceItImpl.java deleted file mode 100644 index b28ddf8..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceItImpl.java +++ /dev/null @@ -1,65 +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.core.uri; - -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.server.api.uri.UriResourceIt; -import org.apache.olingo.server.api.uri.UriResourceKind; - -/** - * Covers Functionimports and BoundFunction in URI - */ -public class UriResourceItImpl extends UriResourceWithKeysImpl implements UriResourceIt { - - private EdmType type; - private boolean isCollection; - - public UriResourceItImpl() { - super(UriResourceKind.it); - } - - @Override - public EdmType getType() { - return type; - } - - public UriResourceItImpl setType(final EdmType type) { - this.type = type; - return this; - } - - @Override - public boolean isCollection() { - if (keyPredicates != null) { - return false; - } - return isCollection; - } - - public UriResourceItImpl setCollection(final boolean isCollection) { - this.isCollection = isCollection; - return this; - } - - @Override - public String toString() { - return "$it"; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAllImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAllImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAllImpl.java deleted file mode 100644 index caa8b6c..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAllImpl.java +++ /dev/null @@ -1,81 +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.core.uri; - -import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; -import org.apache.olingo.commons.api.edm.EdmProperty; -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; -import org.apache.olingo.server.api.uri.UriResourceKind; -import org.apache.olingo.server.api.uri.UriResourceLambdaAll; -import org.apache.olingo.server.api.uri.queryoption.expression.Expression; -import org.apache.olingo.server.core.uri.queryoption.expression.ExpressionImpl; - -public class UriResourceLambdaAllImpl extends UriResourceTypedImpl implements UriResourceLambdaAll { - - protected EdmProperty property; - - private String lambdaVariable; - - private ExpressionImpl expression; - - public UriResourceLambdaAllImpl() { - super(UriResourceKind.lambdaAll); - } - - @Override - public EdmType getType() { - return EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean); - } - - @Override - public boolean isCollection() { - return false; - } - - @Override - public String getLambdaVariable() { - return lambdaVariable; - } - - public UriResourceLambdaAllImpl setLamdaVariable(final String lambdaVariable) { - this.lambdaVariable = lambdaVariable; - return this; - } - - ; - - @Override - public Expression getExpression() { - return expression; - } - - public UriResourceLambdaAllImpl setExpression(final ExpressionImpl expression) { - this.expression = expression; - return this; - } - - ; - - @Override - public String toString() { - return "all"; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java deleted file mode 100644 index 75e44a8..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java +++ /dev/null @@ -1,78 +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.core.uri; - -import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; -import org.apache.olingo.commons.api.edm.EdmProperty; -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; -import org.apache.olingo.server.api.uri.UriResourceKind; -import org.apache.olingo.server.api.uri.UriResourceLambdaAny; -import org.apache.olingo.server.api.uri.queryoption.expression.Expression; -import org.apache.olingo.server.core.uri.queryoption.expression.ExpressionImpl; - -public class UriResourceLambdaAnyImpl extends UriResourceTypedImpl implements UriResourceLambdaAny { - - protected EdmProperty property; - - private String lambdaVariable; - - private ExpressionImpl expression; - - public UriResourceLambdaAnyImpl() { - super(UriResourceKind.lambdaAny); - } - - @Override - public EdmType getType() { - return EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean); - } - - @Override - public boolean isCollection() { - return false; - } - - @Override - public String getLamdaVariable() { - return lambdaVariable; - } - - public UriResourceLambdaAnyImpl setLamdaVariable(final String lambdaVariable) { - this.lambdaVariable = lambdaVariable; - return this; - } - - ; - - @Override - public Expression getExpression() { - return expression; - } - - public UriResourceLambdaAnyImpl setExpression(final ExpressionImpl expression) { - this.expression = expression; - return this; - } - - @Override - public String toString() { - return "any"; - }; -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaVarImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaVarImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaVarImpl.java deleted file mode 100644 index f71fe04..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaVarImpl.java +++ /dev/null @@ -1,70 +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.core.uri; - -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.server.api.uri.UriResourceKind; -import org.apache.olingo.server.api.uri.UriResourceLambdaVariable; - -public class UriResourceLambdaVarImpl extends UriResourceTypedImpl implements UriResourceLambdaVariable { - - private EdmType type; - private boolean isCollection; - private String variableText; - - public UriResourceLambdaVarImpl() { - super(UriResourceKind.lambdaVariable); - } - - @Override - public String getVariableName() { - return variableText; - } - - public UriResourceLambdaVarImpl setVariableText(final String variableText) { - this.variableText = variableText; - return this; - } - - @Override - public EdmType getType() { - return type; - } - - public UriResourceLambdaVarImpl setType(final EdmType type) { - this.type = type; - return this; - - } - - @Override - public boolean isCollection() { - return isCollection; - } - - public UriResourceLambdaVarImpl setCollection(final boolean isCollection) { - this.isCollection = isCollection; - return this; - } - - @Override - public String toString() { - return variableText; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceNavigationPropertyImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceNavigationPropertyImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceNavigationPropertyImpl.java deleted file mode 100644 index 3da7aef..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceNavigationPropertyImpl.java +++ /dev/null @@ -1,63 +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.core.uri; - -import org.apache.olingo.commons.api.edm.EdmNavigationProperty; -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.server.api.uri.UriResourceKind; -import org.apache.olingo.server.api.uri.UriResourceNavigation; - -public class UriResourceNavigationPropertyImpl extends UriResourceWithKeysImpl implements UriResourceNavigation { - - protected EdmNavigationProperty navigationProperty; - - public UriResourceNavigationPropertyImpl() { - super(UriResourceKind.navigationProperty); - } - - @Override - public EdmNavigationProperty getProperty() { - return navigationProperty; - } - - public UriResourceNavigationPropertyImpl setNavigationProperty(final EdmNavigationProperty property) { - navigationProperty = property; - return this; - - } - - @Override - public EdmType getType() { - return navigationProperty.getType(); - } - - @Override - public boolean isCollection() { - if (keyPredicates != null) { - return false; - } - return navigationProperty.isCollection(); - } - - @Override - public String toString() { - return navigationProperty.getName(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourcePrimitivePropertyImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourcePrimitivePropertyImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourcePrimitivePropertyImpl.java deleted file mode 100644 index d599b9b..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourcePrimitivePropertyImpl.java +++ /dev/null @@ -1,59 +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.core.uri; - -import org.apache.olingo.commons.api.edm.EdmProperty; -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.server.api.uri.UriResourceKind; -import org.apache.olingo.server.api.uri.UriResourcePrimitiveProperty; - -public class UriResourcePrimitivePropertyImpl extends UriResourceTypedImpl implements UriResourcePrimitiveProperty { - - EdmProperty property; - - public UriResourcePrimitivePropertyImpl() { - super(UriResourceKind.primitiveProperty); - } - - @Override - public EdmProperty getProperty() { - return property; - } - - public UriResourcePrimitivePropertyImpl setProperty(final EdmProperty property) { - this.property = property; - return this; - } - - @Override - public EdmType getType() { - return property.getType(); - } - - @Override - public boolean isCollection() { - return property.isCollection(); - } - - @Override - public String toString() { - return property.getName(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceRefImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceRefImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceRefImpl.java deleted file mode 100644 index a0cdc3e..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceRefImpl.java +++ /dev/null @@ -1,36 +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.core.uri; - -import org.apache.olingo.server.api.uri.UriResourceKind; -import org.apache.olingo.server.api.uri.UriResourceRef; - -public class UriResourceRefImpl extends UriResourceImpl implements UriResourceRef { - - public UriResourceRefImpl() { - super(UriResourceKind.ref); - - } - - @Override - public String toString() { - return "$ref"; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceRootImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceRootImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceRootImpl.java deleted file mode 100644 index 0db0a01..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceRootImpl.java +++ /dev/null @@ -1,62 +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.core.uri; - -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.server.api.uri.UriResourceKind; -import org.apache.olingo.server.api.uri.UriResourceRoot; - -public class UriResourceRootImpl extends UriResourceWithKeysImpl implements UriResourceRoot { - - private EdmType type; - private boolean isCollection; - - public UriResourceRootImpl() { - super(UriResourceKind.root); - } - - @Override - public EdmType getType() { - return type; - } - - public UriResourceRootImpl setType(final EdmType type) { - this.type = type; - return this; - } - - @Override - public boolean isCollection() { - if (keyPredicates != null) { - return false; - } - return isCollection; - } - - public UriResourceRootImpl setCollection(final boolean isCollection) { - this.isCollection = isCollection; - return this; - } - - @Override - public String toString() { - return "$root"; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceSingletonImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceSingletonImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceSingletonImpl.java deleted file mode 100644 index cc9c606..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceSingletonImpl.java +++ /dev/null @@ -1,71 +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.core.uri; - -import org.apache.olingo.commons.api.edm.EdmEntityType; -import org.apache.olingo.commons.api.edm.EdmSingleton; -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.server.api.uri.UriResourceKind; -import org.apache.olingo.server.api.uri.UriResourceSingleton; - -public class UriResourceSingletonImpl extends UriResourceTypedImpl implements UriResourceSingleton { - - private EdmSingleton singleton; - - public UriResourceSingletonImpl() { - super(UriResourceKind.singleton); - } - - @Override - public EdmSingleton getSingleton() { - return singleton; - } - - public UriResourceSingletonImpl setSingleton(final EdmSingleton singleton) { - - this.singleton = singleton; - return this; - } - - @Override - public EdmEntityType getEntityTypeFilter() { - return (EdmEntityType) typeFilter; - } - - @Override - public EdmType getType() { - return singleton.getEntityType(); - } - - @Override - public EdmEntityType getEntityType() { - return singleton.getEntityType(); - } - - @Override - public boolean isCollection() { - return false; - } - - @Override - public String toString() { - return singleton.getName(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceStartingTypeFilterImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceStartingTypeFilterImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceStartingTypeFilterImpl.java deleted file mode 100644 index 152f44c..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceStartingTypeFilterImpl.java +++ /dev/null @@ -1,66 +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.core.uri; - -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.server.api.uri.UriResourceKind; - -public class UriResourceStartingTypeFilterImpl extends UriResourceWithKeysImpl { - - private EdmType type; - private boolean isCollection; - - public UriResourceStartingTypeFilterImpl() { - super(null); - } - - @Override - public UriResourceKind getKind() { - return kind; - } - - @Override - public EdmType getType() { - return type; - } - - public UriResourceStartingTypeFilterImpl setType(final EdmType type) { - this.type = type; - return this; - } - - @Override - public boolean isCollection() { - if (keyPredicates != null) { - return false; - } - return isCollection; - } - - public UriResourceStartingTypeFilterImpl setCollection(final boolean isCollection) { - this.isCollection = isCollection; - return this; - } - - @Override - public String toString() { - return type.getNamespace() + "." + type.getName(); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceTypedImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceTypedImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceTypedImpl.java deleted file mode 100644 index d5f01ea..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceTypedImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.server.core.uri; - -import org.apache.olingo.commons.api.edm.EdmStructuredType; -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.server.api.uri.UriResourceKind; -import org.apache.olingo.server.api.uri.UriResourcePartTyped; - -public abstract class UriResourceTypedImpl extends UriResourceImpl implements UriResourcePartTyped { - - protected EdmType typeFilter = null; - - public UriResourceTypedImpl(final UriResourceKind kind) { - super(kind); - } - - public EdmType getTypeFilter() { - return typeFilter; - } - - public UriResourceTypedImpl setTypeFilter(final EdmStructuredType typeFilter) { - this.typeFilter = typeFilter; - return this; - } - - @Override - public String toString(final boolean includeFilters) { - if (includeFilters) { - if (typeFilter != null) { - return toString() + "/" + getFQN(typeFilter).toString(); - } else { - return toString(); - } - } - return toString(); - } - - private FullQualifiedName getFQN(final EdmType type) { - return new FullQualifiedName(type.getNamespace(), type.getName()); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceValueImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceValueImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceValueImpl.java deleted file mode 100644 index 7611ecb..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceValueImpl.java +++ /dev/null @@ -1,36 +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.core.uri; - -import org.apache.olingo.server.api.uri.UriResourceKind; -import org.apache.olingo.server.api.uri.UriResourceValue; - -public class UriResourceValueImpl extends UriResourceImpl implements UriResourceValue { - - public UriResourceValueImpl() { - super(UriResourceKind.value); - - } - - @Override - public String toString() { - return "$value"; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceWithKeysImpl.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceWithKeysImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceWithKeysImpl.java deleted file mode 100644 index 19d3639..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceWithKeysImpl.java +++ /dev/null @@ -1,101 +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.core.uri; - -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.server.api.uri.UriParameter; -import org.apache.olingo.server.api.uri.UriResourceKind; -import org.apache.olingo.server.api.uri.UriResourcePartTyped; - -import java.util.ArrayList; -import java.util.List; - -public abstract class UriResourceWithKeysImpl extends UriResourceImpl implements UriResourcePartTyped { - - protected EdmType collectionTypeFilter = null; - protected List<UriParameterImpl> keyPredicates = null; - protected EdmType entryTypeFilter = null; - - public UriResourceWithKeysImpl(final UriResourceKind kind) { - super(kind); - } - - public EdmType getTypeFilterOnCollection() { - return collectionTypeFilter; - } - - public EdmType getTypeFilterOnEntry() { - return entryTypeFilter; - } - - public List<UriParameter> getKeyPredicates() { - List<UriParameter> retList = new ArrayList<UriParameter>(); - if (keyPredicates != null) { - for (UriParameterImpl item : keyPredicates) { - retList.add(item); - } - } - return retList; - } - - public UriResourceWithKeysImpl setKeyPredicates(final List<UriParameterImpl> list) { - keyPredicates = list; - return this; - } - - public UriResourceWithKeysImpl setEntryTypeFilter(final EdmType entryTypeFilter) { - this.entryTypeFilter = entryTypeFilter; - return this; - } - - public UriResourceWithKeysImpl setCollectionTypeFilter(final EdmType collectionTypeFilter) { - this.collectionTypeFilter = collectionTypeFilter; - return this; - } - - @Override - public String toString(final boolean includeFilters) { - - if (includeFilters == true) { - String tmp = ""; - if (collectionTypeFilter != null) { - tmp += getFQN(collectionTypeFilter).toString(); - } - - if (entryTypeFilter != null) { - if (tmp.length() == 0) { - tmp = getFQN(entryTypeFilter).toString(); - } else { - tmp += "/()" + getFQN(entryTypeFilter).toString(); - } - } - if (tmp.length() != 0) { - return toString() + "/" + tmp; - } - } - - return toString(); - } - - private FullQualifiedName getFQN(final EdmType type) { - return new FullQualifiedName(type.getNamespace(), type.getName()); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/CheckFullContextListener.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/CheckFullContextListener.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/CheckFullContextListener.java deleted file mode 100644 index 2b529bd..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/CheckFullContextListener.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ******************************************************************************/ -package org.apache.olingo.server.core.uri.parser; - -import org.antlr.v4.runtime.DiagnosticErrorListener; -import org.antlr.v4.runtime.Parser; -import org.antlr.v4.runtime.RecognitionException; -import org.antlr.v4.runtime.Recognizer; -import org.antlr.v4.runtime.atn.ATNConfigSet; -import org.antlr.v4.runtime.dfa.DFA; - -import java.util.BitSet; - -class CheckFullContextListener extends DiagnosticErrorListener { - - @Override - public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line, - final int charPositionInLine, - final String msg, final RecognitionException e) { - // System.err.println("syntaxError detected"); - } - - @Override - public void reportAmbiguity(final Parser recognizer, final DFA dfa, final int startIndex, final int stopIndex, - final boolean exact, - final BitSet ambigAlts, final ATNConfigSet configs) { - // System.err.println("reportAmbiguity detected"); - } - - @Override - public void reportAttemptingFullContext(final Parser recognizer, final DFA dfa, final int startIndex, - final int stopIndex, - final BitSet conflictingAlts, final ATNConfigSet configs) { - // System.err.println("reportAttemptingFullContext detected"); - } - - @Override - public void reportContextSensitivity(final Parser recognizer, final DFA dfa, final int startIndex, - final int stopIndex, final int prediction, - final ATNConfigSet configs) { - // System.err.println("reportContextSensitivity detected"); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/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 deleted file mode 100644 index a22933f..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java +++ /dev/null @@ -1,487 +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.core.uri.parser; - -import org.antlr.v4.runtime.ANTLRInputStream; -import org.antlr.v4.runtime.BailErrorStrategy; -import org.antlr.v4.runtime.CommonTokenStream; -import org.antlr.v4.runtime.Lexer; -import org.antlr.v4.runtime.ParserRuleContext; -import org.antlr.v4.runtime.RecognitionException; -import org.antlr.v4.runtime.Token; -import org.antlr.v4.runtime.atn.PredictionMode; -import org.antlr.v4.runtime.misc.ParseCancellationException; -import org.apache.olingo.commons.api.ODataRuntimeException; -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.format.ODataFormat; -import org.apache.olingo.server.api.uri.UriInfo; -import org.apache.olingo.server.api.uri.UriInfoKind; -import org.apache.olingo.server.api.uri.UriResource; -import org.apache.olingo.server.api.uri.UriResourcePartTyped; -import org.apache.olingo.server.api.uri.queryoption.SystemQueryOption; -import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind; -import org.apache.olingo.server.core.uri.UriInfoImpl; -import org.apache.olingo.server.core.uri.antlr.UriLexer; -import org.apache.olingo.server.core.uri.antlr.UriParserParser; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.AllEOFContext; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.BatchEOFContext; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.CrossjoinEOFContext; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.EntityEOFContext; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.ExpandItemsEOFContext; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.FilterExpressionEOFContext; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.MetadataEOFContext; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.OrderByEOFContext; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.PathSegmentEOFContext; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.SelectEOFContext; -import org.apache.olingo.server.core.uri.queryoption.CountOptionImpl; -import org.apache.olingo.server.core.uri.queryoption.CustomQueryOptionImpl; -import org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl; -import org.apache.olingo.server.core.uri.queryoption.FilterOptionImpl; -import org.apache.olingo.server.core.uri.queryoption.FormatOptionImpl; -import org.apache.olingo.server.core.uri.queryoption.IdOptionImpl; -import org.apache.olingo.server.core.uri.queryoption.OrderByOptionImpl; -import org.apache.olingo.server.core.uri.queryoption.SelectOptionImpl; -import org.apache.olingo.server.core.uri.queryoption.SkipOptionImpl; -import org.apache.olingo.server.core.uri.queryoption.SkipTokenOptionImpl; -import org.apache.olingo.server.core.uri.queryoption.TopOptionImpl; - -import java.util.ArrayList; -import java.util.List; - -public class Parser { - int logLevel = 0; - - private enum ParserEntryRules { - All, Batch, CrossJoin, Entity, ExpandItems, FilterExpression, Metadata, PathSegment, Orderby, Select - }; - - public Parser setLogLevel(final int logLevel) { - this.logLevel = logLevel; - return this; - } - - public UriInfo parseUri(final String path, final String query, final String fragment, final Edm edm) - throws UriParserException { - - UriContext context = new UriContext(); - UriParseTreeVisitor uriParseTreeVisitor = new UriParseTreeVisitor(edm, context); - - try { - final RawUri uri = UriDecoder.decodeUri(path, query, fragment, 0); // -> 0 segments are before the service url - - // first, read the decoded path segments - final String firstSegment = uri.pathSegmentListDecoded.isEmpty() ? "" : uri.pathSegmentListDecoded.get(0); - - if (firstSegment.isEmpty()) { - ensureLastSegment(firstSegment, 0, uri.pathSegmentListDecoded.size()); - context.contextUriInfo = new UriInfoImpl().setKind(UriInfoKind.service); - } else if (firstSegment.startsWith("$batch")) { - ensureLastSegment(firstSegment, 1, uri.pathSegmentListDecoded.size()); - BatchEOFContext ctxBatchEOF = - (BatchEOFContext) parseRule(uri.pathSegmentListDecoded.get(0), ParserEntryRules.Batch); - - uriParseTreeVisitor.visitBatchEOF(ctxBatchEOF); - } else if (firstSegment.startsWith("$metadata")) { - ensureLastSegment(firstSegment, 1, uri.pathSegmentListDecoded.size()); - MetadataEOFContext ctxMetadataEOF = - (MetadataEOFContext) parseRule(uri.pathSegmentListDecoded.get(0), ParserEntryRules.Metadata); - - uriParseTreeVisitor.visitMetadataEOF(ctxMetadataEOF); - - context.contextUriInfo.setFragment(uri.fragment); - } else if (firstSegment.startsWith("$entity")) { - - context.contextUriInfo = new UriInfoImpl().setKind(UriInfoKind.entityId); - if (uri.pathSegmentListDecoded.size() > 1) { - final String typeCastSegment = uri.pathSegmentListDecoded.get(1); - ensureLastSegment(typeCastSegment, 2, uri.pathSegmentListDecoded.size()); - EntityEOFContext ctxEntityEOF = - (EntityEOFContext) parseRule(typeCastSegment, ParserEntryRules.Entity); - uriParseTreeVisitor.visitEntityEOF(ctxEntityEOF); - } - - } else if (firstSegment.startsWith("$all")) { - ensureLastSegment(firstSegment, 1, uri.pathSegmentListDecoded.size()); - AllEOFContext ctxResourcePathEOF = - (AllEOFContext) parseRule(uri.pathSegmentListDecoded.get(0), ParserEntryRules.All); - - uriParseTreeVisitor.visitAllEOF(ctxResourcePathEOF); - } else if (firstSegment.startsWith("$crossjoin")) { - ensureLastSegment(firstSegment, 1, uri.pathSegmentListDecoded.size()); - CrossjoinEOFContext ctxResourcePathEOF = - (CrossjoinEOFContext) parseRule(uri.pathSegmentListDecoded.get(0), ParserEntryRules.CrossJoin); - - uriParseTreeVisitor.visitCrossjoinEOF(ctxResourcePathEOF); - } else { - List<PathSegmentEOFContext> ctxPathSegments = new ArrayList<PathSegmentEOFContext>(); - for (String pathSegment : uri.pathSegmentListDecoded) { - PathSegmentEOFContext ctxPathSegment = - (PathSegmentEOFContext) parseRule(pathSegment, ParserEntryRules.PathSegment); - ctxPathSegments.add(ctxPathSegment); - } - - context.contextUriInfo = new UriInfoImpl().setKind(UriInfoKind.resource); - - for (PathSegmentEOFContext ctxPathSegment : ctxPathSegments) { - // add checks for batch, entity, metadata, all, crossjoin - uriParseTreeVisitor.visitPathSegmentEOF(ctxPathSegment); - } - - UriResource lastSegment = context.contextUriInfo.getLastResourcePart(); - if (lastSegment instanceof UriResourcePartTyped) { - UriResourcePartTyped typed = (UriResourcePartTyped) lastSegment; - - UriParseTreeVisitor.TypeInformation myType = uriParseTreeVisitor.getTypeInformation(typed); - UriParseTreeVisitor.TypeInformation typeInfo = - uriParseTreeVisitor.new TypeInformation(myType.type, typed.isCollection()); - context.contextTypes.push(typeInfo); - } - } - - // second, read the system query options and the custom query options - for (RawUri.QueryOption option : uri.queryOptionListDecoded) { - if (option.name.startsWith("$")) { - SystemQueryOption systemOption = null; - if (option.name.equals(SystemQueryOptionKind.FILTER.toString())) { - FilterExpressionEOFContext ctxFilterExpression = - (FilterExpressionEOFContext) parseRule(option.value, ParserEntryRules.FilterExpression); - - FilterOptionImpl filterOption = - (FilterOptionImpl) uriParseTreeVisitor.visitFilterExpressionEOF(ctxFilterExpression); - - systemOption = filterOption; - - } else if (option.name.equals(SystemQueryOptionKind.FORMAT.toString())) { - FormatOptionImpl formatOption = new FormatOptionImpl(); - formatOption.setName(option.name); - formatOption.setText(option.value); - if (option.value.equalsIgnoreCase(ODataFormat.JSON.name()) - || option.value.equalsIgnoreCase(ODataFormat.XML.name()) - || option.value.equalsIgnoreCase(ODataFormat.ATOM.name()) - || isFormatSyntaxValid(option.value)) { - formatOption.setFormat(option.value); - } else { - throw new UriParserSyntaxException("Illegal value of $format option!", - UriParserSyntaxException.MessageKeys.WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION_FORMAT, option.value); - } - systemOption = formatOption; - - } else if (option.name.equals(SystemQueryOptionKind.EXPAND.toString())) { - ExpandItemsEOFContext ctxExpandItems = - (ExpandItemsEOFContext) parseRule(option.value, ParserEntryRules.ExpandItems); - - ExpandOptionImpl expandOption = - (ExpandOptionImpl) uriParseTreeVisitor.visitExpandItemsEOF(ctxExpandItems); - - systemOption = expandOption; - - } else if (option.name.equals(SystemQueryOptionKind.ID.toString())) { - IdOptionImpl idOption = new IdOptionImpl(); - idOption.setName(option.name); - idOption.setText(option.value); - idOption.setValue(option.value); - systemOption = idOption; - } else if (option.name.equals(SystemQueryOptionKind.LEVELS.toString())) { - throw new UriParserSyntaxException("System query option '$levels' is allowed only inside '$expand'!", - UriParserSyntaxException.MessageKeys.SYSTEM_QUERY_OPTION_LEVELS_NOT_ALLOWED_HERE); - } else if (option.name.equals(SystemQueryOptionKind.ORDERBY.toString())) { - OrderByEOFContext ctxOrderByExpression = - (OrderByEOFContext) parseRule(option.value, ParserEntryRules.Orderby); - - OrderByOptionImpl orderByOption = - (OrderByOptionImpl) uriParseTreeVisitor.visitOrderByEOF(ctxOrderByExpression); - - systemOption = orderByOption; - } else if (option.name.equals(SystemQueryOptionKind.SEARCH.toString())) { - throw new RuntimeException("System query option '$search' not implemented!"); - } else if (option.name.equals(SystemQueryOptionKind.SELECT.toString())) { - SelectEOFContext ctxSelectEOF = - (SelectEOFContext) parseRule(option.value, ParserEntryRules.Select); - - SelectOptionImpl selectOption = - (SelectOptionImpl) uriParseTreeVisitor.visitSelectEOF(ctxSelectEOF); - - systemOption = selectOption; - } else if (option.name.equals(SystemQueryOptionKind.SKIP.toString())) { - SkipOptionImpl skipOption = new SkipOptionImpl(); - skipOption.setName(option.name); - skipOption.setText(option.value); - try { - skipOption.setValue(Integer.parseInt(option.value)); - } catch (final NumberFormatException e) { - throw new UriParserSyntaxException("Illegal value of $skip option!", e, - UriParserSyntaxException.MessageKeys.WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION, - option.name, option.value); - } - systemOption = skipOption; - } else if (option.name.equals(SystemQueryOptionKind.SKIPTOKEN.toString())) { - SkipTokenOptionImpl skipTokenOption = new SkipTokenOptionImpl(); - skipTokenOption.setName(option.name); - skipTokenOption.setText(option.value); - skipTokenOption.setValue(option.value); - systemOption = skipTokenOption; - } else if (option.name.equals(SystemQueryOptionKind.TOP.toString())) { - TopOptionImpl topOption = new TopOptionImpl(); - topOption.setName(option.name); - topOption.setText(option.value); - try { - topOption.setValue(Integer.parseInt(option.value)); - } catch (final NumberFormatException e) { - throw new UriParserSyntaxException("Illegal value of $top option!", e, - UriParserSyntaxException.MessageKeys.WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION, - option.name, option.value); - } - systemOption = topOption; - } else if (option.name.equals(SystemQueryOptionKind.COUNT.toString())) { - CountOptionImpl inlineCountOption = new CountOptionImpl(); - inlineCountOption.setName(option.name); - inlineCountOption.setText(option.value); - if (option.value.equals("true") || option.value.equals("false")) { - inlineCountOption.setValue(Boolean.parseBoolean(option.value)); - } else { - throw new UriParserSyntaxException("Illegal value of $count option!", - UriParserSyntaxException.MessageKeys.WRONG_VALUE_FOR_SYSTEM_QUERY_OPTION, - option.name, option.value); - } - systemOption = inlineCountOption; - } else { - throw new UriParserSyntaxException("Unknown system query option!", - UriParserSyntaxException.MessageKeys.UNKNOWN_SYSTEM_QUERY_OPTION, option.name); - } - try { - context.contextUriInfo.setSystemQueryOption(systemOption); - } catch (final ODataRuntimeException e) { - throw new UriParserSyntaxException("Double system query option!", e, - UriParserSyntaxException.MessageKeys.DOUBLE_SYSTEM_QUERY_OPTION, option.name); - } - } else { - CustomQueryOptionImpl customOption = new CustomQueryOptionImpl(); - customOption.setName(option.name); - customOption.setText(option.value); - context.contextUriInfo.addCustomQueryOption(customOption); - } - } - - return context.contextUriInfo; - } catch (ParseCancellationException e) { - throw e.getCause() instanceof UriParserException ? - (UriParserException) e.getCause() : - new UriParserSyntaxException("Syntax error", e, UriParserSyntaxException.MessageKeys.SYNTAX); - } - } - - private void ensureLastSegment(final String segment, final int pos, final int size) - throws UriParserSyntaxException { - if (pos < size) { - throw new UriParserSyntaxException(segment + " must be the last segment.", - UriParserSyntaxException.MessageKeys.MUST_BE_LAST_SEGMENT, segment); - } - } - - private boolean isFormatSyntaxValid(final String value) { - final int index = value.indexOf('/'); - return index > 0 && index < value.length() - 1 && index == value.lastIndexOf('/'); - } - - private ParserRuleContext parseRule(final String input, final ParserEntryRules entryPoint) - throws UriParserSyntaxException { - UriParserParser parser = null; - UriLexer lexer = null; - ParserRuleContext ret = null; - - // Use 2 stage approach to improve performance - // see https://github.com/antlr/antlr4/issues/192 - - // stage = 1 - try { - - // create parser - if (logLevel > 0) { - lexer = new UriLexer(new ANTLRInputStream(input)); - showTokens(input, lexer.getAllTokens()); - } - - lexer = new UriLexer(new ANTLRInputStream(input)); - parser = new UriParserParser(new CommonTokenStream(lexer)); - - // Set error strategy - addStage1ErrorStategy(parser); - - // Set error collector - addStage1ErrorListener(parser); - - // user the faster LL parsing - parser.getInterpreter().setPredictionMode(PredictionMode.SLL); - - // parse - switch (entryPoint) { - case All: - ret = parser.allEOF(); - break; - case Batch: - ret = parser.batchEOF(); - break; - case CrossJoin: - ret = parser.crossjoinEOF(); - break; - case Metadata: - ret = parser.metadataEOF(); - break; - case PathSegment: - ret = parser.pathSegmentEOF(); - break; - case FilterExpression: - lexer.mode(Lexer.DEFAULT_MODE); - ret = parser.filterExpressionEOF(); - break; - case Orderby: - lexer.mode(Lexer.DEFAULT_MODE); - ret = parser.orderByEOF(); - break; - case ExpandItems: - lexer.mode(Lexer.DEFAULT_MODE); - ret = parser.expandItemsEOF(); - break; - case Entity: - ret = parser.entityEOF(); - break; - case Select: - ret = parser.selectEOF(); - break; - default: - break; - - } - - } catch (ParseCancellationException hardException) { - // stage = 2 - try { - - // create parser - lexer = new UriLexer(new ANTLRInputStream(input)); - parser = new UriParserParser(new CommonTokenStream(lexer)); - - // Set error strategy - addStage2ErrorStategy(parser); - - // Set error collector - addStage2ErrorListener(parser); - - // Use the slower SLL parsing - parser.getInterpreter().setPredictionMode(PredictionMode.LL); - - // parse - switch (entryPoint) { - case All: - ret = parser.allEOF(); - break; - case Batch: - ret = parser.batchEOF(); - break; - case CrossJoin: - ret = parser.crossjoinEOF(); - break; - case Metadata: - ret = parser.metadataEOF(); - break; - case PathSegment: - ret = parser.pathSegmentEOF(); - break; - case FilterExpression: - lexer.mode(Lexer.DEFAULT_MODE); - ret = parser.filterExpressionEOF(); - break; - case Orderby: - lexer.mode(Lexer.DEFAULT_MODE); - ret = parser.orderByEOF(); - break; - case ExpandItems: - lexer.mode(Lexer.DEFAULT_MODE); - ret = parser.expandItemsEOF(); - break; - case Entity: - ret = parser.entityEOF(); - break; - case Select: - ret = parser.selectEOF(); - break; - default: - break; - } - - } catch (final RecognitionException weakException) { - throw new UriParserSyntaxException("Error in syntax", weakException, - UriParserSyntaxException.MessageKeys.SYNTAX); - - // exceptionOnStage = 2; - } - } catch (final RecognitionException hardException) { - throw new UriParserSyntaxException("Error in syntax", hardException, - UriParserSyntaxException.MessageKeys.SYNTAX); - } - - return ret; - } - - protected void addStage1ErrorStategy(final UriParserParser parser) { - // Throw exception at first syntax error - parser.setErrorHandler(new BailErrorStrategy()); - - } - - protected void addStage2ErrorStategy(final UriParserParser parser) { - // Throw exception at first syntax error - parser.setErrorHandler(new BailErrorStrategy()); - } - - protected void addStage1ErrorListener(final UriParserParser parser) { - // No error logging to System.out or System.err, only exceptions used (depending on ErrorStrategy) - parser.removeErrorListeners(); - parser.addErrorListener(new CheckFullContextListener()); - - } - - protected void addStage2ErrorListener(final UriParserParser parser) { - // No error logging to System.out or System.err, only exceptions used (depending on ErrorStrategy) - parser.removeErrorListeners(); - } - - public void showTokens(final String input, final List<? extends Token> list) { - boolean first = true; - System.out.println("input: " + input); - String nL = "\n"; - String out = "[" + nL; - for (Token token : list) { - if (!first) { - out += ","; - first = false; - } - int index = token.getType(); - if (index != -1) { - out += "\"" + token.getText() + "\"" + " " + UriLexer.tokenNames[index] + nL; - } else { - out += "\"" + token.getText() + "\"" + " " + index + nL; - } - } - out += ']'; - System.out.println("tokens: " + out); - return; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/RawUri.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/RawUri.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/RawUri.java deleted file mode 100644 index 42e0a0f..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/RawUri.java +++ /dev/null @@ -1,46 +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.core.uri.parser; - -import java.util.List; - -public class RawUri { - public String uri; - public String scheme; - public String authority; - public String path; - public String queryOptionString; - public String fragment; - public List<QueryOption> queryOptionList; - public List<QueryOption> queryOptionListDecoded; - - public List<String> pathSegmentList; - public List<String> pathSegmentListDecoded; - - public static class QueryOption { - public String name; - public String value; - - QueryOption(final String name, final String value) { - this.name = name; - this.value = value; - } - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriContext.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriContext.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriContext.java deleted file mode 100644 index b99433d..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriContext.java +++ /dev/null @@ -1,97 +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.core.uri.parser; - -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.server.core.uri.UriInfoImpl; -import org.apache.olingo.server.core.uri.parser.UriParseTreeVisitor.TypeInformation; -import org.apache.olingo.server.core.uri.queryoption.ExpandItemImpl; -import org.apache.olingo.server.core.uri.queryoption.SelectItemImpl; - -import java.util.Stack; - -/** - * UriContext object used for holding information for URI parsing. - * - */ -public class UriContext { - - public static class LambdaVariables { - public boolean isCollection; - public String name; - public EdmType type; - } - - /** - * Hold all currently allowed lambda variables - * As lambda functions can be nested there may be more than one allowed lambda variables at a time while parsing a - * $filter or $orderby expressions. - */ - public Stack<LambdaVariables> allowedLambdaVariables; - /** - * Used to stack type information for nested $expand, $filter query options and other cases. - */ - public Stack<TypeInformation> contextTypes; - - // CHECKSTYLE:OFF (Maven checkstyle) - /** - * Set within method - * {@link org.apache.olingo.server.core.uri.antlr.UriParserBaseVisitor#visitExpandItem( - * org.apache.olingo.server.core.uri.antlr.UriParserParser.ExpandItemContext ctx)} - * and {@link - * org.apache.olingo.server.core.uri.antlr.UriParserBaseVisitor#visitExpandPathExtension( - * org.apache.olingo.server.core.uri.antlr.UriParserParser.ExpandPathExtensionContext ctx)} to allow nodes - * deeper in the expand tree at - * {@link org.apache.olingo.server.core.uri.antlr.UriParserBaseVisitor#visitExpandPathExtension( - * org.apache.olingo.server.core.uri.antlr.UriParserParser.ExpandPathExtensionContext ctx)} - * appending path - * segments to the currently processed {@link ExpandItemImpl}. - */ - public ExpandItemImpl contextExpandItemPath; - // CHECKSTYLE:ON (Maven checkstyle) - - /** - * Set within method - * {@link org.apache.olingo.server.core.uri.antlr.UriParserBaseVisitor#visitSelectItem( - * org.apache.olingo.server.core.uri.antlr.UriParserParser.SelectItemContext ctx)} to allow - * nodes - * deeper in the expand tree at - * {@link org.apache.olingo.server.core.uri.antlr.UriParserBaseVisitor#visitSelectSegment( - * org.apache.olingo.server.core.uri.antlr.UriParserParser.SelectSegmentContext ctx)} - * appending path segments to the - * currently processed {@link SelectItemImpl}. - */ - public SelectItemImpl contextSelectItem; - /** - * Stores the currently processed UriInfo objects. There is one URI Info object for the resource path - * and one for each new first member access within $filter and $orderBy options. - */ - public UriInfoImpl contextUriInfo; - public boolean contextReadingFunctionParameters; - - public UriContext() { - - contextExpandItemPath = null; - contextReadingFunctionParameters = false; - contextSelectItem = null; - contextTypes = new Stack<UriParseTreeVisitor.TypeInformation>(); - allowedLambdaVariables = new Stack<UriContext.LambdaVariables>(); - - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java deleted file mode 100644 index 8585edb..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java +++ /dev/null @@ -1,120 +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.core.uri.parser; - -import org.apache.olingo.commons.core.Decoder; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -public class UriDecoder { - - public static RawUri decodeUri(final String path, final String query, final String fragment, - final int skipSegments) throws UriParserSyntaxException { - RawUri rawUri = new RawUri(); - - rawUri.path = path; - rawUri.queryOptionString = query; - rawUri.fragment = fragment; - - rawUri.pathSegmentList = splitPath(path, skipSegments); - rawUri.queryOptionList = splitOptions(query); - decode(rawUri); - - return rawUri; - } - - private static void decode(RawUri rawUri) throws UriParserSyntaxException { - rawUri.pathSegmentListDecoded = new ArrayList<String>(); - for (String segment : rawUri.pathSegmentList) { - rawUri.pathSegmentListDecoded.add(decode(segment)); - } - - rawUri.queryOptionListDecoded = new ArrayList<RawUri.QueryOption>(); - for (RawUri.QueryOption optionPair : rawUri.queryOptionList) { - rawUri.queryOptionListDecoded.add(new RawUri.QueryOption( - decode(optionPair.name), - decode(optionPair.value))); - } - } - - private static List<RawUri.QueryOption> splitOptions(final String queryOptionString) { - if (queryOptionString == null) { - return Collections.<RawUri.QueryOption> emptyList(); - } - - List<RawUri.QueryOption> queryOptionList = new ArrayList<RawUri.QueryOption>(); - for (String option : split(queryOptionString, '&')) { - if (option.length() != 0) { - final List<String> pair = splitFirst(option, '='); - queryOptionList.add(new RawUri.QueryOption(pair.get(0), pair.get(1))); - } - } - return queryOptionList; - } - - private static List<String> splitFirst(final String input, final char c) { - int pos = input.indexOf(c, 0); - if (pos >= 0) { - return Arrays.asList(input.substring(0, pos), input.substring(pos + 1)); - } else { - return Arrays.asList(input, ""); - } - } - - private static List<String> splitPath(final String path, int skipSegments) { - List<String> list = split(path, '/'); - - // Empty path segments of the resource path are removed. - while (list.remove("")) { - // this place intentionally left blank - ; - } - - return skipSegments > 0 ? list.subList(skipSegments, list.size()) : list; - } - - public static List<String> split(final String input, final char c) { - - List<String> list = new LinkedList<String>(); - - int start = 0; - int end = -1; - - while ((end = input.indexOf(c, start)) >= 0) { - list.add(input.substring(start, end)); - start = end + 1; - } - - list.add(input.substring(start)); - - return list; - } - - public static String decode(final String encoded) throws UriParserSyntaxException { - try { - return Decoder.decode(encoded); - } catch (final IllegalArgumentException e) { - throw new UriParserSyntaxException("Wrong percent encoding!", e, UriParserSyntaxException.MessageKeys.SYNTAX); - } - } -}
