You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by fm...@apache.org on 2013/07/26 13:22:36 UTC
[31/51] [partial] initial commit
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/Schema.java
----------------------------------------------------------------------
diff --git a/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/Schema.java b/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/Schema.java
new file mode 100644
index 0000000..9a62330
--- /dev/null
+++ b/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/Schema.java
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.api.edm.provider;
+
+import java.util.List;
+
+/**
+ * Objects of this class represent a schema
+ * @author SAP AG
+ */
+public class Schema {
+
+ private String namespace;
+ private String alias;
+ private List<Using> usings;
+ private List<EntityType> entityTypes;
+ private List<ComplexType> complexTypes;
+ private List<Association> associations;
+ private List<EntityContainer> entityContainers;
+ private List<AnnotationAttribute> annotationAttributes;
+ private List<AnnotationElement> annotationElements;
+
+ /**
+ * Sets the namespace for this {@link Schema}
+ * @param namespace
+ * @return {@link Schema} for method chaining
+ */
+ public Schema setNamespace(final String namespace) {
+ this.namespace = namespace;
+ return this;
+ }
+
+ /**
+ * Sets the alias for this {@link Schema}
+ * @param alias
+ * @return {@link Schema} for method chaining
+ */
+ public Schema setAlias(final String alias) {
+ this.alias = alias;
+ return this;
+ }
+
+ /**
+ * Sets the {@link Using} for this {@link Schema}
+ * @param usings
+ * @return {@link Schema} for method chaining
+ */
+ public Schema setUsings(final List<Using> usings) {
+ this.usings = usings;
+ return this;
+ }
+
+ /**
+ * Sets the {@link EntityType}s for this {@link Schema}
+ * @param entityTypes
+ * @return {@link Schema} for method chaining
+ */
+ public Schema setEntityTypes(final List<EntityType> entityTypes) {
+ this.entityTypes = entityTypes;
+ return this;
+ }
+
+ /**
+ * Sets the {@link ComplexType}s for this {@link Schema}
+ * @param complexTypes
+ * @return {@link Schema} for method chaining
+ */
+ public Schema setComplexTypes(final List<ComplexType> complexTypes) {
+ this.complexTypes = complexTypes;
+ return this;
+ }
+
+ /**
+ * Sets the {@link Association}s for this {@link Schema}
+ * @param associations
+ * @return {@link Schema} for method chaining
+ */
+ public Schema setAssociations(final List<Association> associations) {
+ this.associations = associations;
+ return this;
+ }
+
+ /**
+ * Sets the {@link EntityContainer}s for this {@link Schema}
+ * @param entityContainers
+ * @return {@link Schema} for method chaining
+ */
+ public Schema setEntityContainers(final List<EntityContainer> entityContainers) {
+ this.entityContainers = entityContainers;
+ return this;
+ }
+
+ /**
+ * Sets the List of {@link AnnotationAttribute} for this {@link Schema}
+ * @param annotationAttributes
+ * @return {@link Schema} for method chaining
+ */
+ public Schema setAnnotationAttributes(final List<AnnotationAttribute> annotationAttributes) {
+ this.annotationAttributes = annotationAttributes;
+ return this;
+ }
+
+ /**
+ * Sets the List of {@link AnnotationElement} for this {@link Schema}
+ * @param annotationElements
+ * @return {@link Schema} for method chaining
+ */
+ public Schema setAnnotationElements(final List<AnnotationElement> annotationElements) {
+ this.annotationElements = annotationElements;
+ return this;
+ }
+
+ /**
+ * @return <b>String</b> namespace of this {@link Schema}
+ */
+ public String getNamespace() {
+ return namespace;
+ }
+
+ /**
+ * @return <b>String</b> alias of this {@link Schema}
+ */
+ public String getAlias() {
+ return alias;
+ }
+
+ /**
+ * @return List<{@link Using}> of this {@link Schema}
+ */
+ public List<Using> getUsings() {
+ return usings;
+ }
+
+ /**
+ * @return List<{@link EntityType}> of this {@link Schema}
+ */
+ public List<EntityType> getEntityTypes() {
+ return entityTypes;
+ }
+
+ /**
+ * @return List<{@link ComplexType}> of this {@link Schema}
+ */
+ public List<ComplexType> getComplexTypes() {
+ return complexTypes;
+ }
+
+ /**
+ * @return List<{@link Association}> of this {@link Schema}
+ */
+ public List<Association> getAssociations() {
+ return associations;
+ }
+
+ /**
+ * @return List<{@link EntityContainer}> of this {@link Schema}
+ */
+ public List<EntityContainer> getEntityContainers() {
+ return entityContainers;
+ }
+
+ /**
+ * @return List of {@link AnnotationAttribute} annotation attributes
+ */
+ public List<AnnotationAttribute> getAnnotationAttributes() {
+ return annotationAttributes;
+ }
+
+ /**
+ * @return List of {@link AnnotationElement} annotation elements
+ */
+ public List<AnnotationElement> getAnnotationElements() {
+ return annotationElements;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/SimpleProperty.java
----------------------------------------------------------------------
diff --git a/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/SimpleProperty.java b/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/SimpleProperty.java
new file mode 100644
index 0000000..0cfb01f
--- /dev/null
+++ b/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/SimpleProperty.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.api.edm.provider;
+
+import java.util.List;
+
+import org.apache.olingo.odata2.api.edm.EdmFacets;
+import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+
+/**
+ * Objects of this class represent a simple property.
+ * @author SAP AG
+ */
+public class SimpleProperty extends Property {
+
+ private EdmSimpleTypeKind type;
+
+ /**
+ * @return {@link EdmSimpleTypeKind} of this property
+ */
+ public EdmSimpleTypeKind getType() {
+ return type;
+ }
+
+ /**
+ * Sets the {@link EdmSimpleTypeKind} for this {@link Property}.
+ * @param type
+ * @return {@link Property} for method chaining
+ */
+ public SimpleProperty setType(final EdmSimpleTypeKind type) {
+ this.type = type;
+ return this;
+ }
+
+ @Override
+ public SimpleProperty setName(final String name) {
+ super.setName(name);
+ return this;
+ }
+
+ @Override
+ public SimpleProperty setFacets(final EdmFacets facets) {
+ super.setFacets(facets);
+ return this;
+ }
+
+ @Override
+ public SimpleProperty setCustomizableFeedMappings(final CustomizableFeedMappings customizableFeedMappings) {
+ super.setCustomizableFeedMappings(customizableFeedMappings);
+ return this;
+ }
+
+ @Override
+ public SimpleProperty setMimeType(final String mimeType) {
+ super.setMimeType(mimeType);
+ return this;
+ }
+
+ @Override
+ public SimpleProperty setMapping(final Mapping mapping) {
+ super.setMapping(mapping);
+ return this;
+ }
+
+ @Override
+ public SimpleProperty setDocumentation(final Documentation documentation) {
+ super.setDocumentation(documentation);
+ return this;
+ }
+
+ @Override
+ public SimpleProperty setAnnotationAttributes(final List<AnnotationAttribute> annotationAttributes) {
+ super.setAnnotationAttributes(annotationAttributes);
+ return this;
+ }
+
+ @Override
+ public SimpleProperty setAnnotationElements(final List<AnnotationElement> annotationElements) {
+ super.setAnnotationElements(annotationElements);
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/Using.java
----------------------------------------------------------------------
diff --git a/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/Using.java b/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/Using.java
new file mode 100644
index 0000000..fbf908f
--- /dev/null
+++ b/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/Using.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.api.edm.provider;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author SAP AG
+ */
+public class Using {
+
+ private String namespace;
+ private String alias;
+ private Documentation documentation;
+ private List<AnnotationAttribute> annotationAttributes;
+ private List<AnnotationElement> annotationElements;
+
+ /**
+ * Sets the namespace for this {@link Using}
+ * @param namespace
+ * @return {@link Using} for method chaining
+ */
+ public Using setNamespace(final String namespace) {
+ this.namespace = namespace;
+ return this;
+ }
+
+ /**
+ * Sets the alias for this {@link Using}
+ * @param alias
+ * @return {@link Using} for method chaining
+ */
+ public Using setAlias(final String alias) {
+ this.alias = alias;
+ return this;
+ }
+
+ /**
+ * Sets the {@link Documentation} for this {@link Using}
+ * @param documentation
+ * @return {@link Using} for method chaining
+ */
+ public Using setDocumentation(final Documentation documentation) {
+ this.documentation = documentation;
+ return this;
+ }
+
+ /**
+ * Sets the collection of {@link AnnotationAttribute} for this {@link Using}
+ * @param annotationAttributes
+ * @return {@link Using} for method chaining
+ */
+ public Using setAnnotationAttributes(final List<AnnotationAttribute> annotationAttributes) {
+ this.annotationAttributes = annotationAttributes;
+ return this;
+ }
+
+ /**
+ * Sets the collection of {@link AnnotationElement} for this {@link Using}
+ * @param annotationElements
+ * @return {@link Using} for method chaining
+ */
+ public Using setAnnotationElements(final List<AnnotationElement> annotationElements) {
+ this.annotationElements = annotationElements;
+ return this;
+ }
+
+ /**
+ * @return <b>String</b> namespace
+ */
+ public String getNamespace() {
+ return namespace;
+ }
+
+ /**
+ * @return <b>String</b> alias
+ */
+ public String getAlias() {
+ return alias;
+ }
+
+ /**
+ * @return {@link Documentation} documentation
+ */
+ public Documentation getDocumentation() {
+ return documentation;
+ }
+
+ /**
+ * @return collection of {@link AnnotationAttribute} annotation attributes
+ */
+ public Collection<AnnotationAttribute> getAnnotationAttributes() {
+ return annotationAttributes;
+ }
+
+ /**
+ * @return collection of {@link AnnotationElement} annotation elements
+ */
+ public Collection<AnnotationElement> getAnnotationElements() {
+ return annotationElements;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/package-info.java
----------------------------------------------------------------------
diff --git a/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/package-info.java b/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/package-info.java
new file mode 100644
index 0000000..3e4324c
--- /dev/null
+++ b/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/package-info.java
@@ -0,0 +1,287 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+/**
+ * Entity Data Model Provider API
+ * <p>Classes in this package are used to provide an EDM to the library as well as to the application. To do this the class {@link org.apache.olingo.odata2.api.edm.provider.EdmProvider} has to be implemented.</p>
+ * <p>Inside the OData library we are using a lazy loading concept which means the EdmProvider is only called for an element if it is needed. See some sample coding for an EdmProvider below</p>
+ * <p>public class Provider extends EdmProvider {
+ <p>public static final String NAMESPACE_1 = "RefScenario";
+ <br/>public static final String NAMESPACE_2 = "RefScenario2";
+ <br/>private static final FullQualifiedName ENTITY_TYPE_1_1 = new FullQualifiedName(NAMESPACE_1, "Employee");
+ <br/>private static final FullQualifiedName ENTITY_TYPE_1_BASE = new FullQualifiedName(NAMESPACE_1, "Base");
+ <br/>private static final FullQualifiedName ENTITY_TYPE_1_4 = new FullQualifiedName(NAMESPACE_1, "Manager");
+ <br/>private static final FullQualifiedName ENTITY_TYPE_2_1 = new FullQualifiedName(NAMESPACE_2, "Photo");
+ <br/>private static final FullQualifiedName COMPLEX_TYPE_1 = new FullQualifiedName(NAMESPACE_1, "c_Location");
+ <br/>private static final FullQualifiedName COMPLEX_TYPE_2 = new FullQualifiedName(NAMESPACE_1, "c_City");
+ <br/>private static final FullQualifiedName ASSOCIATION_1_1 = new FullQualifiedName(NAMESPACE_1, "ManagerEmployees");
+ <br/>private static final String ROLE_1_1 = "r_Employees";
+ <br/>private static final String ROLE_1_4 = "r_Manager";
+ <br/>private static final String ENTITY_CONTAINER_1 = "Container1";
+ <br/>private static final String ENTITY_CONTAINER_2 = "Container2";
+ <br/>private static final String ENTITY_SET_1_1 = "Employees";
+ <br/>private static final String ENTITY_SET_1_4 = "Managers";
+ <br/>private static final String ENTITY_SET_2_1 = "Photos";
+ <br/>private static final String FUNCTION_IMPORT_1 = "EmployeeSearch";
+ <br/>private static final String FUNCTION_IMPORT_2 = "AllLocations";
+ </p>
+ <p>public List<Schema> getSchemas() throws ODataException {
+ <p>List<Schema> schemas = new ArrayList<Schema>();
+ <br/>Schema schema = new Schema();
+ <br/>schema.setNamespace(NAMESPACE_1);
+
+ <br/>List<EntityType> entityTypes = new ArrayList<EntityType>();
+ <br/>entityTypes.add(getEntityType(ENTITY_TYPE_1_1));
+ <br/>entityTypes.add(getEntityType(ENTITY_TYPE_1_4));
+ <br/>entityTypes.add(getEntityType(ENTITY_TYPE_1_BASE));
+ <br/>schema.setEntityTypes(entityTypes);
+
+ <br/>List<ComplexType> complexTypes = new ArrayList<ComplexType>();
+ <br/>complexTypes.add(getComplexType(COMPLEX_TYPE_1));
+ <br/>complexTypes.add(getComplexType(COMPLEX_TYPE_2));
+ <br/>schema.setComplexTypes(complexTypes);
+
+ <br/>List<Association> associations = new ArrayList<Association>();
+ <br/>associations.add(getAssociation(ASSOCIATION_1_1));
+ <br/>schema.setAssociations(associations);
+
+ <br/>EntityContainer entityContainer = new EntityContainer();
+ <br/>entityContainer.setName(ENTITY_CONTAINER_1).setDefaultEntityContainer(true);
+
+ <br/>List<EntitySet> entitySets = new ArrayList<EntitySet>();
+ <br/>entitySets.add(getEntitySet(ENTITY_CONTAINER_1, ENTITY_SET_1_1));
+ <br/>entitySets.add(getEntitySet(ENTITY_CONTAINER_1, ENTITY_SET_1_4));
+ <br/>entityContainer.setEntitySets(entitySets);
+
+ <br/>List<AssociationSet> associationSets = new ArrayList<AssociationSet>();
+ <br/>associationSets.add(getAssociationSet(ENTITY_CONTAINER_1, ASSOCIATION_1_1, ENTITY_SET_1_4, ROLE_1_4));
+ <br/>entityContainer.setAssociationSets(associationSets);
+
+ <br/>List<FunctionImport> functionImports = new ArrayList<FunctionImport>();
+ <br/>functionImports.add(getFunctionImport(ENTITY_CONTAINER_1, FUNCTION_IMPORT_1));
+ <br/>functionImports.add(getFunctionImport(ENTITY_CONTAINER_1, FUNCTION_IMPORT_2));
+ <br/>entityContainer.setFunctionImports(functionImports);
+
+ <br/>schema.setEntityContainers(Arrays.asList(entityContainer));
+
+ <br/>schemas.add(schema);
+ </p>
+ <p>schema = new Schema();
+ <br/>schema.setNamespace(NAMESPACE_2);
+
+ <br/>schema.setEntityTypes(Arrays.asList(getEntityType(ENTITY_TYPE_2_1)));
+
+ <br/>entityContainer = new EntityContainer();
+ <br/>entityContainer.setName(ENTITY_CONTAINER_2);
+ <br/>entityContainer.setEntitySets(Arrays.asList(getEntitySet(ENTITY_CONTAINER_2, ENTITY_SET_2_1)));
+ <br/>schema.setEntityContainers(Arrays.asList(entityContainer));
+
+ <br/>schemas.add(schema);
+</p>
+ <p>return schemas;</p>
+ }
+
+ <p>public EntityType getEntityType(FullQualifiedName edmFQName) throws ODataException {
+ <p>if (NAMESPACE_1.equals(edmFQName.getNamespace())) {
+ <br/>if (ENTITY_TYPE_1_1.getName().equals(edmFQName.getName())) {
+ <br/>List<Property> properties = new ArrayList<Property>();
+ <br/>properties.add(new SimpleProperty().setName("EmployeeId").setType(EdmSimpleTypeKind.String)
+ .setFacets(new Facets().setNullable(false))
+ .setMapping(new Mapping().setInternalName("getId")));
+ <br/>properties.add(new SimpleProperty().setName("EmployeeName").setType(EdmSimpleTypeKind.String)
+ .setCustomizableFeedMappings(new CustomizableFeedMappings()
+ .setFcTargetPath(EdmTargetPath.SYNDICATION_TITLE)));
+ <br/>properties.add(new SimpleProperty().setName("ManagerId").setType(EdmSimpleTypeKind.String)
+ .setMapping(new Mapping().setInternalName("getManager.getId")));
+ <br/>properties.add(new SimpleProperty().setName("RoomId").setType(EdmSimpleTypeKind.String)
+ .setMapping(new Mapping().setInternalName("getRoom.getId")));
+ <br/>properties.add(new SimpleProperty().setName("TeamId").setType(EdmSimpleTypeKind.String)
+ .setFacets(new Facets().setMaxLength(2))
+ .setMapping(new Mapping().setInternalName("getTeam.getId")));
+ <br/>properties.add(new ComplexProperty().setName("Location").setType(COMPLEX_TYPE_1)
+ .setFacets(new Facets().setNullable(false)));
+ <br/>properties.add(new SimpleProperty().setName("Age").setType(EdmSimpleTypeKind.Int16));
+ <br/>properties.add(new SimpleProperty().setName("EntryDate").setType(EdmSimpleTypeKind.DateTime)
+ .setFacets(new Facets().setNullable(true))
+ .setCustomizableFeedMappings(new CustomizableFeedMappings()
+ .setFcTargetPath(EdmTargetPath.SYNDICATION_UPDATED)));
+ <br/>properties.add(new SimpleProperty().setName("ImageUrl").setType(EdmSimpleTypeKind.String)
+ .setMapping(new Mapping().setInternalName("getImageUri")));
+ <br/>List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
+ <br/>navigationProperties.add(new NavigationProperty().setName("ne_Manager")
+ .setRelationship(ASSOCIATION_1_1).setFromRole(ROLE_1_1).setToRole(ROLE_1_4));
+
+ <br/>return new EntityType().setName(ENTITY_TYPE_1_1.getName())
+ .setProperties(properties)
+ .setHasStream(true)
+ .setKey(getKey("EmployeeId"))
+ .setNavigationProperties(navigationProperties)
+ .setMapping(new Mapping().setMimeType("getImageType"));
+
+ <p>} else if (ENTITY_TYPE_1_BASE.getName().equals(edmFQName.getName())) {
+ <br/>List<Property> properties = new ArrayList<Property>();
+ <br/>properties.add(new SimpleProperty().setName("Id").setType(EdmSimpleTypeKind.String)
+ .setFacets(new Facets().setNullable(false).setDefaultValue("1")));
+ <br/>properties.add(new SimpleProperty().setName("Name").setType(EdmSimpleTypeKind.String)
+ .setCustomizableFeedMappings(new CustomizableFeedMappings()
+ .setFcTargetPath(EdmTargetPath.SYNDICATION_TITLE)));
+
+ <br/>return new EntityType().setName(ENTITY_TYPE_1_BASE.getName())
+ .setAbstract(true)
+ .setProperties(properties)
+ .setKey(getKey("Id"));
+
+ <p>} else if (ENTITY_TYPE_1_4.getName().equals(edmFQName.getName())) {
+ <br/>List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
+ <br/>navigationProperties.add(new NavigationProperty().setName("nm_Employees")
+ .setRelationship(ASSOCIATION_1_1).setFromRole(ROLE_1_4).setToRole(ROLE_1_1));
+
+ <br/>return new EntityType().setName(ENTITY_TYPE_1_4.getName())
+ .setBaseType(ENTITY_TYPE_1_1)
+ .setHasStream(true)
+ .setNavigationProperties(navigationProperties)
+ .setMapping(new Mapping().setMimeType("getImageType"));
+
+ <p>} else if (NAMESPACE_2.equals(edmFQName.getNamespace())) {
+ <br/>if (ENTITY_TYPE_2_1.getName().equals(edmFQName.getName())) {
+ <br/>List<Property> properties = new ArrayList<Property>();
+ <br/>properties.add(new SimpleProperty().setName("Id").setType(EdmSimpleTypeKind.Int32)
+ .setFacets(new Facets().setNullable(false).setConcurrencyMode(EdmConcurrencyMode.Fixed)));
+ <br/>properties.add(new SimpleProperty().setName("Name").setType(EdmSimpleTypeKind.String)
+ .setCustomizableFeedMappings(new CustomizableFeedMappings()
+ .setFcTargetPath(EdmTargetPath.SYNDICATION_TITLE)));
+ <br/>properties.add(new SimpleProperty().setName("Type").setType(EdmSimpleTypeKind.String)
+ .setFacets(new Facets().setNullable(false)));
+ <br/>properties.add(new SimpleProperty().setName("ImageUrl").setType(EdmSimpleTypeKind.String)
+ .setCustomizableFeedMappings(new CustomizableFeedMappings()
+ .setFcTargetPath(EdmTargetPath.SYNDICATION_AUTHORURI))
+ .setMapping(new Mapping().setInternalName("getImageUri")));
+ <br/>properties.add(new SimpleProperty().setName("Image").setType(EdmSimpleTypeKind.Binary)
+ .setMapping(new Mapping().setMimeType("getImageType")));
+ <br/>properties.add(new SimpleProperty().setName("BinaryData").setType(EdmSimpleTypeKind.Binary)
+ .setFacets(new Facets().setNullable(true))
+ .setMimeType("image/jpeg"));
+ <br/>properties.add(new SimpleProperty().setName("Содержание").setType(EdmSimpleTypeKind.String)
+ .setFacets(new Facets().setNullable(true))
+ .setCustomizableFeedMappings(new CustomizableFeedMappings()
+ .setFcKeepInContent(false)
+ .setFcNsPrefix("ру") // CYRILLIC SMALL LETTER ER + CYRILLIC SMALL LETTER U
+ .setFcNsUri("http://localhost")
+ .setFcTargetPath("Содержание"))
+ .setMapping(new Mapping().setInternalName("getContent")));
+
+ <br/>return new EntityType().setName(ENTITY_TYPE_2_1.getName())
+ .setProperties(properties)
+ .setHasStream(true)
+ .setKey(getKey("Id", "Type"))
+ .setMapping(new Mapping().setMimeType("getType"));
+ }
+ }
+ }
+ <p>return null;
+ }
+
+ <p>public ComplexType getComplexType(FullQualifiedName edmFQName) throws ODataException {
+ <br/>if (NAMESPACE_1.equals(edmFQName.getNamespace()))
+ <br/>if (COMPLEX_TYPE_1.getName().equals(edmFQName.getName())) {
+ <br/>List<Property> properties = new ArrayList<Property>();
+ <br/>properties.add(new ComplexProperty().setName("City").setType(COMPLEX_TYPE_2));
+ <br/>properties.add(new SimpleProperty().setName("Country").setType(EdmSimpleTypeKind.String));
+ <br/>return new ComplexType().setName(COMPLEX_TYPE_1.getName()).setProperties(properties);
+
+ } <br/>else if (COMPLEX_TYPE_2.getName().equals(edmFQName.getName())) {
+ <br/>List<Property> properties = new ArrayList<Property>();
+ <br/>properties.add(new SimpleProperty().setName("PostalCode").setType(EdmSimpleTypeKind.String));
+ <br/>properties.add(new SimpleProperty().setName("CityName").setType(EdmSimpleTypeKind.String));
+ <br/>return new ComplexType().setName(COMPLEX_TYPE_2.getName()).setProperties(properties);
+ }
+
+ <br/>return null;
+ }
+
+ <p>public Association getAssociation(FullQualifiedName edmFQName) throws ODataException {
+ <br/>if (NAMESPACE_1.equals(edmFQName.getNamespace())) {
+ <br/>if (ASSOCIATION_1_1.getName().equals(edmFQName.getName())) {
+ <br/>return new Association().setName(ASSOCIATION_1_1.getName())
+ .setEnd1(new AssociationEnd().setType(ENTITY_TYPE_1_1).setRole(ROLE_1_1).setMultiplicity(EdmMultiplicity.MANY))
+ .setEnd2(new AssociationEnd().setType(ENTITY_TYPE_1_4).setRole(ROLE_1_4).setMultiplicity(EdmMultiplicity.ONE));
+ }
+ }
+ <br/>return null;
+ }
+
+ <p>public EntityContainerInfo getEntityContainerInfo(String name) throws ODataException {
+ <br/>if (name == null || ENTITY_CONTAINER_1.equals(name)) {
+ <br/>return new EntityContainerInfo().setName(ENTITY_CONTAINER_1).setDefaultEntityContainer(true);
+ } <br/>else if (ENTITY_CONTAINER_2.equals(name)) {
+ <br/>return new EntityContainerInfo().setName(name).setDefaultEntityContainer(false);
+ }
+ <br/>return null;
+ }
+
+ <p>public EntitySet getEntitySet(String entityContainer, String name) throws ODataException {
+ <br/>if (ENTITY_CONTAINER_1.equals(entityContainer)) {
+ <br/>if (ENTITY_SET_1_1.equals(name)) {
+ <br/>return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_1_1);
+ }
+ } <br/>else if (ENTITY_CONTAINER_2.equals(entityContainer)) {
+ <br/>if (ENTITY_SET_2_1.equals(name)) {
+ <br/>return new EntitySet().setName(name).setEntityType(ENTITY_TYPE_2_1);
+ }
+ }
+ <br/>return null;
+ }
+
+ <p>public FunctionImport getFunctionImport(String entityContainer, String name) throws ODataException {
+ <br/>if (ENTITY_CONTAINER_1.equals(entityContainer)) {
+ <br/>if (FUNCTION_IMPORT_1.equals(name)) {
+ <br/>List<FunctionImportParameter> parameters = new ArrayList<FunctionImportParameter>();
+ <br/>parameters.add(new FunctionImportParameter().setName("q").setType(EdmSimpleTypeKind.String)
+ .setFacets(new Facets().setNullable(true)));
+ <br/>return new FunctionImport().setName(name)
+ .setReturnType(new ReturnType().setTypeName(ENTITY_TYPE_1_1).setMultiplicity(EdmMultiplicity.MANY))
+ .setEntitySet(ENTITY_SET_1_1)
+ .setHttpMethod("GET")
+ .setParameters(parameters);
+
+ } <br/>else if (FUNCTION_IMPORT_2.equals(name)) {
+ <br/>return new FunctionImport().setName(name)
+ .setReturnType(new ReturnType().setTypeName(COMPLEX_TYPE_1).setMultiplicity(EdmMultiplicity.MANY))
+ .setHttpMethod("GET");
+
+ }
+ }
+
+ <br/>return null;
+ }
+
+ <p>public AssociationSet getAssociationSet(String entityContainer, FullQualifiedName association, String sourceEntitySetName, String sourceEntitySetRole) throws ODataException {
+ <br/>if (ENTITY_CONTAINER_1.equals(entityContainer))
+ <br/>if (ASSOCIATION_1_1.equals(association))
+ <br/>return new AssociationSet().setName(ASSOCIATION_1_1.getName())
+ .setAssociation(ASSOCIATION_1_1)
+ .setEnd1(new AssociationSetEnd().setRole(ROLE_1_4).setEntitySet(ENTITY_SET_1_4))
+ .setEnd2(new AssociationSetEnd().setRole(ROLE_1_1).setEntitySet(ENTITY_SET_1_1));
+
+ <br/>return null;
+ }
+}
+</p>
+ */
+package org.apache.olingo.odata2.api.edm.provider;
+
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProvider.java
----------------------------------------------------------------------
diff --git a/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProvider.java b/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProvider.java
new file mode 100644
index 0000000..724c967
--- /dev/null
+++ b/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProvider.java
@@ -0,0 +1,698 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.api.ep;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.olingo.odata2.api.batch.BatchException;
+import org.apache.olingo.odata2.api.batch.BatchPart;
+import org.apache.olingo.odata2.api.batch.BatchResponsePart;
+import org.apache.olingo.odata2.api.edm.Edm;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmFunctionImport;
+import org.apache.olingo.odata2.api.edm.EdmProperty;
+import org.apache.olingo.odata2.api.edm.provider.Schema;
+import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
+import org.apache.olingo.odata2.api.ep.feed.ODataFeed;
+import org.apache.olingo.odata2.api.processor.ODataErrorContext;
+import org.apache.olingo.odata2.api.processor.ODataResponse;
+import org.apache.olingo.odata2.api.rt.RuntimeDelegate;
+import org.apache.olingo.odata2.api.servicedocument.ServiceDocument;
+
+/**
+ * <p>Entity Provider</p>
+ * <p>An {@link EntityProvider} provides all necessary <b>read</b> and <b>write</b>
+ * methods for accessing the entities defined in an <code>Entity Data Model</code>.
+ * Therefore this library provides (in its <code>core</code> packages) as convenience
+ * basic entity providers for accessing entities in the <b>XML</b> and <b>JSON</b>
+ * formats.</p>
+ * @author SAP AG
+ */
+public final class EntityProvider {
+
+ /**
+ * (Internal) interface for all {@link EntityProvider} necessary <b>read</b> and <b>write</b> methods for accessing
+ * entities defined in an <code>Entity Data Model</code>.
+ * <p>
+ * This interface is declared as inner interface (class) because the {@link EntityProvider} provides a convenience
+ * access (and basic implementation for <b>XML</b> and <b>JSON</b> format) to all interface methods.
+ * <br/>
+ * Hence, it is <b>not recommended</b> to implement this interface (it is possible to implement it and to provide an
+ * own {@link EntityProvider} for support of additional formats but it is recommended to
+ * handle additional formats directly within an <code>ODataProcessor</code>).
+ */
+ public interface EntityProviderInterface {
+
+ /**
+ * Write metadata document in XML format for the given schemas and the provided predefined
+ * namespaces at the EDMX element. PredefinedNamespaces is of type
+ * Map{@literal <}prefix,namespace{@literal >} and may be null or an empty Map.
+ *
+ * @param schemas all XML schemas which will be written
+ * @param predefinedNamespaces type of Map{@literal <}prefix,namespace{@literal >} and may be null or an empty Map
+ * @return resulting {@link ODataResponse} with written metadata content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ ODataResponse writeMetadata(List<Schema> schemas, Map<String, String> predefinedNamespaces) throws EntityProviderException;
+
+ /**
+ * Write service document based on given {@link Edm} and <code>service root</code> as
+ * given content type.
+ *
+ * @param contentType format in which service document should be written
+ * @param edm entity data model to be written
+ * @param serviceRoot service root for the written service document
+ * @return resulting {@link ODataResponse} with written service document content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ ODataResponse writeServiceDocument(String contentType, Edm edm, String serviceRoot) throws EntityProviderException;
+
+ /**
+ * Write property as content type <code>application/octet-stream</code> or <code>text/plain</code>.
+ *
+ * @param edmProperty entity data model for to be written property
+ * @param value property which will be written
+ * @return resulting {@link ODataResponse} with written property value content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ ODataResponse writePropertyValue(EdmProperty edmProperty, Object value) throws EntityProviderException;
+
+ /**
+ * Write text value as content type <code>text/plain</code>.
+ *
+ * @param value text value which will be written
+ * @return resulting {@link ODataResponse} with written text/plain content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ ODataResponse writeText(String value) throws EntityProviderException;
+
+ /**
+ * Write binary content with content type header set to given <code>mime type</code> parameter.
+ *
+ * @param mimeType mime type which is written and used as content type header information.
+ * @param data which is written to {@link ODataResponse}.
+ * @return response object resulting {@link ODataResponse} with written binary content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ ODataResponse writeBinary(String mimeType, byte[] data) throws EntityProviderException;
+
+ /**
+ * Write given <code>data</code> (which is given in form of a {@link List} with a {@link Map} for each entity. Such a {@link Map}
+ * contains all properties [as <code>property name</code> to <code>property value</code> mapping] for the entry) in the specified
+ * format (given as <code>contentType</code>) based on given <code>entity data model for an entity set</code> (given as {@link EdmEntitySet})
+ * and <code>properties</code> for this entity provider (given as {@link EntityProviderWriteProperties}).
+ *
+ * @param contentType format in which the feed should be written
+ * @param entitySet entity data model for given entity data set
+ * @param data set of entries in form of a {@link List} with a {@link Map} for each entity (such a {@link Map}
+ * contains all properties [as <code>property name</code> to <code>property value</code> mapping).
+ * @param properties additional properties necessary for writing of data
+ * @return resulting {@link ODataResponse} with written feed content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ ODataResponse writeFeed(String contentType, EdmEntitySet entitySet, List<Map<String, Object>> data, EntityProviderWriteProperties properties) throws EntityProviderException;
+
+ /**
+ * Write given <code>data</code> (which is given in form of a {@link Map} for which contains all properties
+ * as <code>property name</code> to <code>property value</code> mapping) for the entry in the specified
+ * format (given as <code>contentType</code>) based on <code>entity data model for an entity set</code> (given as {@link EdmEntitySet})
+ * and <code>properties</code> for this entity provider (given as {@link EntityProviderWriteProperties}).
+ *
+ * @param contentType format in which the entry should be written
+ * @param entitySet entity data model for given entity data set
+ * @param data which contains all properties as <code>property name</code> to <code>property value</code> mapping for the entry
+ * @param properties additional properties necessary for writing of data
+ * @return resulting {@link ODataResponse} with written entry content
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ ODataResponse writeEntry(String contentType, EdmEntitySet entitySet, Map<String, Object> data, EntityProviderWriteProperties properties) throws EntityProviderException;
+
+ /**
+ * Write given <code>value</code> (which is given in form of an {@link Object}) for the property in the specified
+ * format (given as <code>contentType</code>) based on given <code>entity data model for an entity property</code>
+ * (given as {@link EdmProperty}).
+ *
+ * @param contentType format in which the property should be written
+ * @param edmProperty entity data model for given property
+ * @param value data which is written
+ * @return resulting {@link ODataResponse} with written property content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ ODataResponse writeProperty(String contentType, EdmProperty edmProperty, Object value) throws EntityProviderException;
+
+ /**
+ * Write <b>link</b> for key property based on <code>entity data model for an entity set</code> (given as {@link EdmEntitySet})
+ * in the specified format (given as <code>contentType</code>).
+ * The necessary key property values must be provided within the <code>data</code> (in the form of <code>property name</code>
+ * to <code>property value</code> mapping) and <code>properties</code> for this entity provider must be set
+ * (given as {@link EntityProviderWriteProperties}).
+ *
+ * @param contentType format in which the entry should be written
+ * @param entitySet entity data model for given entity data set
+ * @param data which contains all key properties as <code>property name</code> to <code>property value</code> mapping for the entry
+ * @param properties additional properties necessary for writing of data
+ * @return resulting {@link ODataResponse} with written link content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ ODataResponse writeLink(String contentType, EdmEntitySet entitySet, Map<String, Object> data, EntityProviderWriteProperties properties) throws EntityProviderException;
+
+ /**
+ * Write all <b>links</b> for key property based on <code>entity data model for an entity set</code> (given as {@link EdmEntitySet})
+ * in the specified format (given as <code>contentType</code>) for a set of entries.
+ * The necessary key property values must be provided within the <code>data</code> (in form of a {@link List} with a {@link Map}
+ * for each entry. Such a {@link Map} contains all key properties [as <code>property name</code> to
+ * <code>property value</code> mapping] for the entry) and <code>properties</code> for this entity provider must be set
+ * (given as {@link EntityProviderWriteProperties}).
+ *
+ * @param contentType format in which the entry should be written
+ * @param entitySet entity data model for given entity data set
+ * @param data set of entries in form of a {@link List} with a {@link Map} for each entry (such a {@link Map}
+ * contains all key properties [as <code>property name</code> to <code>property value</code> mapping).
+ * @param properties additional properties necessary for writing of data
+ * @return resulting {@link ODataResponse} with written links content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ ODataResponse writeLinks(String contentType, EdmEntitySet entitySet, List<Map<String, Object>> data, EntityProviderWriteProperties properties) throws EntityProviderException;
+
+ /**
+ * Write <code>data</code> result (given as {@link Object}) of function import based on <code>return type</code>
+ * of {@link EdmFunctionImport} in specified format (given as <code>contentType</code>). Additional <code>properties</code>
+ * for this entity provider must be set (given as {@link EntityProviderWriteProperties}).
+ *
+ * @param contentType format in which the entry should be written
+ * @param functionImport entity data model for executed function import
+ * @param data result of function import
+ * @param properties additional properties necessary for writing of data
+ * @return resulting {@link ODataResponse} with written function import result content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ ODataResponse writeFunctionImport(String contentType, EdmFunctionImport functionImport, Object data, EntityProviderWriteProperties properties) throws EntityProviderException;
+
+ /**
+ * Read (de-serialize) a data feed from <code>content</code> (as {@link InputStream}) in specified format (given as <code>contentType</code>)
+ * based on <code>entity data model</code> (given as {@link EdmEntitySet}) and provide this data as {@link ODataEntry}.
+ *
+ * @param contentType format of content in the given input stream.
+ * @param entitySet entity data model for entity set to be read
+ * @param content feed data in form of an {@link InputStream} which contains the data in specified format
+ * @param properties additional properties necessary for reading content from {@link InputStream} into {@link Map}.
+ * @return an {@link ODataFeed} object
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ ODataFeed readFeed(String contentType, EdmEntitySet entitySet, InputStream content, EntityProviderReadProperties properties) throws EntityProviderException;
+
+ /**
+ * Read (de-serialize) data from <code>content</code> (as {@link InputStream}) in specified format (given as <code>contentType</code>)
+ * based on <code>entity data model</code> (given as {@link EdmEntitySet}) and provide this data as {@link ODataEntry}.
+ *
+ * @param contentType format of content in the given input stream.
+ * @param entitySet entity data model for entity set to be read
+ * @param content data in form of an {@link InputStream} which contains the data in specified format
+ * @param properties additional properties necessary for reading content from {@link InputStream} into {@link Map}.
+ * @return entry as {@link ODataEntry}
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ ODataEntry readEntry(String contentType, EdmEntitySet entitySet, InputStream content, EntityProviderReadProperties properties) throws EntityProviderException;
+
+ /**
+ * Read (de-serialize) properties from <code>content</code> (as {@link InputStream}) in specified format (given as <code>contentType</code>)
+ * based on <code>entity data model</code> (given as {@link EdmProperty}) and provide this data as {@link Map} which contains
+ * the read data in form of <code>property name</code> to <code>property value</code> mapping.
+ *
+ * @param contentType format of content in the given input stream.
+ * @param edmProperty entity data model for entity property to be read
+ * @param content data in form of an {@link InputStream} which contains the data in specified format
+ * @param properties additional properties necessary for reading content from {@link InputStream} into {@link Map}.
+ * @return property as name and value in a map
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ Map<String, Object> readProperty(String contentType, EdmProperty edmProperty, InputStream content, EntityProviderReadProperties properties) throws EntityProviderException;
+
+ /**
+ * Read (de-serialize) a property value from <code>content</code> (as {@link InputStream}) in format <code>text/plain</code>
+ * based on <code>entity data model</code> (given as {@link EdmProperty}) and provide this data as {@link Object}.
+ *
+ * @param edmProperty entity data model for entity property to be read
+ * @param content data in form of an {@link InputStream} which contains the data in format <code>text/plain</code>
+ * @param typeMapping defines the mapping for this <code>edm property</code> to a <code>java class</code> which should be used
+ * during read of the content. If according <code>edm property</code> can not be read
+ * into given <code>java class</code> an {@link EntityProviderException} is thrown.
+ * Supported mappings are documented in {@link org.apache.olingo.odata2.api.edm.EdmSimpleType}.
+ * @return property value as object
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ Object readPropertyValue(EdmProperty edmProperty, InputStream content, Class<?> typeMapping) throws EntityProviderException;
+
+ /**
+ * Read (de-serialize) a link from <code>content</code> (as {@link InputStream}) in specified format (given as <code>contentType</code>)
+ * based on <code>entity data model</code> (given as {@link EdmEntitySet}) and provide the link as {@link String}.
+ *
+ * @param contentType format of content in the given input stream.
+ * @param entitySet entity data model for entity property to be read
+ * @param content data in form of an {@link InputStream} which contains the data in specified format
+ * @return link as string
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ String readLink(String contentType, EdmEntitySet entitySet, InputStream content) throws EntityProviderException;
+
+ /**
+ * Read (de-serialize) all links from <code>content</code> (as {@link InputStream})
+ * in specified format (given as <code>contentType</code>) based on <code>entity data model</code>
+ * (given as {@link EdmEntitySet}) and provide the link as List of Strings.
+ *
+ * @param contentType format of content in the given input stream.
+ * @param entitySet entity data model for entity property to be read
+ * @param content data in form of an {@link InputStream} which contains the data in specified format
+ * @return links as List of Strings
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ List<String> readLinks(String contentType, EdmEntitySet entitySet, InputStream content) throws EntityProviderException;
+
+ /**
+ * Read (de-serialize) data from metadata <code>inputStream</code> (as {@link InputStream}) and provide Edm as {@link Edm}
+ *
+ * @param inputStream the given input stream
+ * @param validate has to be true if metadata should be validated
+ * @return Edm as {@link Edm}
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ Edm readMetadata(InputStream inputStream, boolean validate) throws EntityProviderException;
+
+ /**
+ * Read (de-serialize) binary data from <code>content</code> (as {@link InputStream}) and provide it as <code>byte[]</code>.
+ *
+ * @param content data in form of an {@link InputStream} which contains the binary data
+ * @return binary data as bytes
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ byte[] readBinary(InputStream content) throws EntityProviderException;
+
+ /**
+ * <p>Serializes an error message according to the OData standard.</p>
+ * @param context contains error details see {@link ODataErrorContext}
+ * @return an {@link ODataResponse} containing the serialized error message
+ */
+ ODataResponse writeErrorDocument(ODataErrorContext context);
+
+ /**
+ * Read (de-serialize) data from service document <code>inputStream</code> (as {@link InputStream}) and provide ServiceDocument as {@link ServiceDocument}
+ *
+ * @param serviceDocument the given input stream
+ * @param contentType format of content in the given input stream
+ * @return ServiceDocument as {@link ServiceDocument}
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ ServiceDocument readServiceDocument(InputStream serviceDocument, String contentType) throws EntityProviderException;
+
+ /**
+ * Parse Batch Request body <code>inputStream</code> (as {@link InputStream}) and provide a list of Batch Parts as {@link BatchPart}
+ *
+ * @param contentType format of content in the given input stream
+ * @param content request body
+ * @param properties additional properties necessary for parsing. Must not be null.
+ * @return list of {@link BatchPart}
+ * @throws BatchException if parsing fails
+ */
+ List<BatchPart> parseBatchRequest(String contentType, InputStream content, EntityProviderBatchProperties properties) throws BatchException;
+
+ /**
+ * Write responses of Batch Response Parts in Batch Response as {@link ODataResponse}.
+ * Batch Response body matches one-to-one with the corresponding Batch Request body
+ *
+ * @param batchResponseParts a list of {@link BatchResponsePart}
+ * @return Batch Response as {@link ODataResponse}
+ * @throws BatchException
+ */
+ ODataResponse writeBatchResponse(List<BatchResponsePart> batchResponseParts) throws BatchException;
+ }
+
+ /**
+ * Create an instance for the {@link EntityProviderInterface} over the {@link RuntimeDelegate}.
+ *
+ * @return instance of {@link EntityProviderInterface}
+ */
+ private static EntityProviderInterface createEntityProvider() {
+ return RuntimeDelegate.createEntityProvider();
+ }
+
+ /**
+ * <p>Serializes an error message according to the OData standard.</p>
+ * An exception is not thrown because this method is used in exception handling.</p>
+ * @param context contains error details see {@link ODataErrorContext}
+ * @return an {@link ODataResponse} containing the serialized error message
+ */
+ public static ODataResponse writeErrorDocument(final ODataErrorContext context) {
+ return createEntityProvider().writeErrorDocument(context);
+ }
+
+ /**
+ * Write metadata document in XML format for the given schemas and the provided predefined
+ * namespaces at the EDMX element. PredefinedNamespaces is of type
+ * Map{@literal <}prefix,namespace{@literal >} and may be null or an empty Map.
+ *
+ * @param schemas all XML schemas which will be written
+ * @param predefinedNamespaces type of Map{@literal <}prefix,namespace{@literal >} and may be null or an empty Map
+ * @return resulting {@link ODataResponse} with written metadata content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ public static ODataResponse writeMetadata(final List<Schema> schemas, final Map<String, String> predefinedNamespaces) throws EntityProviderException {
+ return createEntityProvider().writeMetadata(schemas, predefinedNamespaces);
+ }
+
+ /**
+ * Write service document based on given {@link Edm} and <code>service root</code> as
+ * given content type.
+ *
+ * @param contentType format in which service document should be written
+ * @param edm entity data model to be written
+ * @param serviceRoot service root for the written service document
+ * @return resulting {@link ODataResponse} with written service document content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ public static ODataResponse writeServiceDocument(final String contentType, final Edm edm, final String serviceRoot) throws EntityProviderException {
+ return createEntityProvider().writeServiceDocument(contentType, edm, serviceRoot);
+ }
+
+ /**
+ * Write property as content type <code>application/octet-stream</code> or <code>text/plain</code>.
+ *
+ * @param edmProperty entity data model for to be written property
+ * @param value property which will be written
+ * @return resulting {@link ODataResponse} with written property value content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ public static ODataResponse writePropertyValue(final EdmProperty edmProperty, final Object value) throws EntityProviderException {
+ return createEntityProvider().writePropertyValue(edmProperty, value);
+ }
+
+ /**
+ * Write text value as content type <code>text/plain</code>.
+ *
+ * @param value text value which will be written
+ * @return resulting {@link ODataResponse} with written text/plain content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ public static ODataResponse writeText(final String value) throws EntityProviderException {
+ return createEntityProvider().writeText(value);
+ }
+
+ /**
+ * Write binary content with content type header set to given <code>mime type</code> parameter.
+ *
+ * @param mimeType mime type which is written and used as content type header information.
+ * @param data which is written to {@link ODataResponse}.
+ * @return response object resulting {@link ODataResponse} with written binary content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ public static ODataResponse writeBinary(final String mimeType, final byte[] data) throws EntityProviderException {
+ return createEntityProvider().writeBinary(mimeType, data);
+ }
+
+ /**
+ * Write given <code>data</code> (which is given in form of a {@link List} with a {@link Map} for each entity. Such a {@link Map}
+ * contains all properties [as <code>property name</code> to <code>property value</code> mapping] for the entry) in the specified
+ * format (given as <code>contentType</code>) based on given <code>entity data model for an entity set</code> (given as {@link EdmEntitySet})
+ * and <code>properties</code> for this entity provider (given as {@link EntityProviderWriteProperties}).
+ *
+ * @param contentType format in which the feed should be written
+ * @param entitySet entity data model for given entity data set
+ * @param data set of entries in form of a {@link List} with a {@link Map} for each entity (such a {@link Map}
+ * contains all properties [as <code>property name</code> to <code>property value</code> mapping).
+ * @param properties additional properties necessary for writing of data
+ * @return resulting {@link ODataResponse} with written feed content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ public static ODataResponse writeFeed(final String contentType, final EdmEntitySet entitySet, final List<Map<String, Object>> data, final EntityProviderWriteProperties properties) throws EntityProviderException {
+ return createEntityProvider().writeFeed(contentType, entitySet, data, properties);
+ }
+
+ /**
+ * Write given <code>data</code> (which is given in form of a {@link Map} for which contains all properties
+ * as <code>property name</code> to <code>property value</code> mapping) for the entry in the specified
+ * format (given as <code>contentType</code>) based on <code>entity data model for an entity set</code> (given as {@link EdmEntitySet})
+ * and <code>properties</code> for this entity provider (given as {@link EntityProviderWriteProperties}).
+ *
+ * @param contentType format in which the entry should be written
+ * @param entitySet entity data model for given entity data set
+ * @param data which contains all properties as <code>property name</code> to <code>property value</code> mapping for the entry
+ * @param properties additional properties necessary for writing of data
+ * @return resulting {@link ODataResponse} with written entry content
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ public static ODataResponse writeEntry(final String contentType, final EdmEntitySet entitySet, final Map<String, Object> data, final EntityProviderWriteProperties properties) throws EntityProviderException {
+ return createEntityProvider().writeEntry(contentType, entitySet, data, properties);
+ }
+
+ /**
+ * Write given <code>value</code> (which is given in form of an {@link Object}) for the property in the specified
+ * format (given as <code>contentType</code>) based on given <code>entity data model for an entity property</code>
+ * (given as {@link EdmProperty}).
+ *
+ * @param contentType format in which the property should be written
+ * @param edmProperty entity data model for given property
+ * @param value data which is written
+ * @return resulting {@link ODataResponse} with written property content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ public static ODataResponse writeProperty(final String contentType, final EdmProperty edmProperty, final Object value) throws EntityProviderException {
+ return createEntityProvider().writeProperty(contentType, edmProperty, value);
+ }
+
+ /**
+ * Write <b>link</b> for key property based on <code>entity data model for an entity set</code> (given as {@link EdmEntitySet})
+ * in the specified format (given as <code>contentType</code>).
+ * The necessary key property values must be provided within the <code>data</code> (in the form of <code>property name</code>
+ * to <code>property value</code> mapping) and <code>properties</code> for this entity provider must be set
+ * (given as {@link EntityProviderWriteProperties}).
+ *
+ * @param contentType format in which the entry should be written
+ * @param entitySet entity data model for given entity data set
+ * @param data which contains all key properties as <code>property name</code> to <code>property value</code> mapping for the entry
+ * @param properties additional properties necessary for writing of data
+ * @return resulting {@link ODataResponse} with written link content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ public static ODataResponse writeLink(final String contentType, final EdmEntitySet entitySet, final Map<String, Object> data, final EntityProviderWriteProperties properties) throws EntityProviderException {
+ return createEntityProvider().writeLink(contentType, entitySet, data, properties);
+ }
+
+ /**
+ * Write all <b>links</b> for key property based on <code>entity data model for an entity set</code> (given as {@link EdmEntitySet})
+ * in the specified format (given as <code>contentType</code>) for a set of entries.
+ * The necessary key property values must be provided within the <code>data</code> (in form of a {@link List} with a {@link Map}
+ * for each entry. Such a {@link Map} contains all key properties [as <code>property name</code> to
+ * <code>property value</code> mapping] for the entry) and <code>properties</code> for this entity provider must be set
+ * (given as {@link EntityProviderWriteProperties}).
+ *
+ * @param contentType format in which the entry should be written
+ * @param entitySet entity data model for given entity data set
+ * @param data set of entries in form of a {@link List} with a {@link Map} for each entry (such a {@link Map}
+ * contains all key properties [as <code>property name</code> to <code>property value</code> mapping).
+ * @param properties additional properties necessary for writing of data
+ * @return resulting {@link ODataResponse} with written links content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ public static ODataResponse writeLinks(final String contentType, final EdmEntitySet entitySet, final List<Map<String, Object>> data, final EntityProviderWriteProperties properties) throws EntityProviderException {
+ return createEntityProvider().writeLinks(contentType, entitySet, data, properties);
+ }
+
+ /**
+ * Write <code>data</code> result (given as {@link Object}) of function import based on <code>return type</code>
+ * of {@link EdmFunctionImport} in specified format (given as <code>contentType</code>). Additional <code>properties</code>
+ * for this entity provider must be set (given as {@link EntityProviderWriteProperties}).
+ *
+ * @param contentType format in which the entry should be written
+ * @param functionImport entity data model for executed function import
+ * @param data result of function import
+ * @param properties additional properties necessary for writing of data
+ * @return resulting {@link ODataResponse} with written function import result content.
+ * @throws EntityProviderException if writing of data (serialization) fails
+ */
+ public static ODataResponse writeFunctionImport(final String contentType, final EdmFunctionImport functionImport, final Object data, final EntityProviderWriteProperties properties) throws EntityProviderException {
+ return createEntityProvider().writeFunctionImport(contentType, functionImport, data, properties);
+ }
+
+ /**
+ * Read (de-serialize) a data feed from <code>content</code> (as {@link InputStream}) in specified format (given as <code>contentType</code>)
+ * based on <code>entity data model</code> (given as {@link EdmEntitySet}) and provide this data as {@link ODataEntry}.
+ *
+ * @param contentType format of content in the given input stream.
+ * @param entitySet entity data model for entity set to be read
+ * @param content feed data in form of an {@link InputStream} which contains the data in specified format
+ * @param properties additional properties necessary for reading content from {@link InputStream} into {@link Map}. Must not be null.
+ * @return an {@link ODataFeed} object
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ public static ODataFeed readFeed(final String contentType, final EdmEntitySet entitySet, final InputStream content, final EntityProviderReadProperties properties) throws EntityProviderException {
+ return createEntityProvider().readFeed(contentType, entitySet, content, properties);
+ }
+
+ /**
+ * Read (de-serialize) data from <code>content</code> (as {@link InputStream}) in specified format (given as <code>contentType</code>)
+ * based on <code>entity data model</code> (given as {@link EdmEntitySet}) and provide this data as {@link ODataEntry}.
+ *
+ * @param contentType format of content in the given input stream.
+ * @param entitySet entity data model for entity set to be read
+ * @param content data in form of an {@link InputStream} which contains the data in specified format
+ * @param properties additional properties necessary for reading content from {@link InputStream} into {@link Map}. Must not be null.
+ * @return entry as {@link ODataEntry}
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ public static ODataEntry readEntry(final String contentType, final EdmEntitySet entitySet, final InputStream content, final EntityProviderReadProperties properties) throws EntityProviderException {
+ return createEntityProvider().readEntry(contentType, entitySet, content, properties);
+ }
+
+ /**
+ * Read (de-serialize) properties from <code>content</code> (as {@link InputStream}) in specified format (given as <code>contentType</code>)
+ * based on <code>entity data model</code> (given as {@link EdmProperty}) and provide this data as {@link Map} which contains
+ * the read data in form of <code>property name</code> to <code>property value</code> mapping.
+ *
+ * @param contentType format of content in the given input stream.
+ * @param edmProperty entity data model for entity property to be read
+ * @param content data in form of an {@link InputStream} which contains the data in specified format
+ * @param properties additional properties necessary for reading content from {@link InputStream} into {@link Map}. Must not be null.
+ * @return property as name and value in a map
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ public static Map<String, Object> readProperty(final String contentType, final EdmProperty edmProperty, final InputStream content, final EntityProviderReadProperties properties) throws EntityProviderException {
+ return createEntityProvider().readProperty(contentType, edmProperty, content, properties);
+ }
+
+ /**
+ * Read (de-serialize) a property value from <code>content</code> (as {@link InputStream}) in format <code>text/plain</code>
+ * based on <code>entity data model</code> (given as {@link EdmProperty}) and provide this data as {@link Object}.
+ *
+ * @param edmProperty entity data model for entity property to be read
+ * @param content data in form of an {@link InputStream} which contains the data in format <code>text/plain</code>
+ * @return property value as object
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ public static Object readPropertyValue(final EdmProperty edmProperty, final InputStream content) throws EntityProviderException {
+ return createEntityProvider().readPropertyValue(edmProperty, content, null);
+ }
+
+ /**
+ * Read (de-serialize) a property value from <code>content</code> (as {@link InputStream}) in format <code>text/plain</code>
+ * based on <code>entity data model</code> (given as {@link EdmProperty}) and provide this data as {@link Object}.
+ *
+ * @param edmProperty entity data model for entity property to be read
+ * @param content data in form of an {@link InputStream} which contains the data in format <code>text/plain</code>
+ * @param typeMapping defines the mapping for this <code>edm property</code> to a <code>java class</code> which should be used
+ * during read of the content. If according <code>edm property</code> can not be read
+ * into given <code>java class</code> an {@link EntityProviderException} is thrown.
+ * Supported mappings are documented in {@link org.apache.olingo.odata2.api.edm.EdmSimpleType}.
+ * @return property value as object
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ public static Object readPropertyValue(final EdmProperty edmProperty, final InputStream content, final Class<?> typeMapping) throws EntityProviderException {
+ return createEntityProvider().readPropertyValue(edmProperty, content, typeMapping);
+ }
+
+ /**
+ * Read (de-serialize) a link from <code>content</code> (as {@link InputStream}) in specified format (given as <code>contentType</code>)
+ * based on <code>entity data model</code> (given as {@link EdmEntitySet}) and provide the link as {@link String}.
+ *
+ * @param contentType format of content in the given input stream.
+ * @param entitySet entity data model for entity property to be read
+ * @param content data in form of an {@link InputStream} which contains the data in specified format
+ * @return link as string
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ public static String readLink(final String contentType, final EdmEntitySet entitySet, final InputStream content) throws EntityProviderException {
+ return createEntityProvider().readLink(contentType, entitySet, content);
+ }
+
+ /**
+ * Read (de-serialize) a link collection from <code>content</code> (as {@link InputStream})
+ * in specified format (given as <code>contentType</code>) based on <code>entity data model</code>
+ * (given as {@link EdmEntitySet}) and provide the links as List of Strings.
+ *
+ * @param contentType format of content in the given input stream.
+ * @param entitySet entity data model for entity property to be read
+ * @param content data in form of an {@link InputStream} which contains the data in specified format
+ * @return links as List of Strings
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ public static List<String> readLinks(final String contentType, final EdmEntitySet entitySet, final InputStream content) throws EntityProviderException {
+ return createEntityProvider().readLinks(contentType, entitySet, content);
+ }
+
+ /**
+ * Read (de-serialize) binary data from <code>content</code> (as {@link InputStream}) and provide it as <code>byte[]</code>.
+ *
+ * @param content data in form of an {@link InputStream} which contains the binary data
+ * @return binary data as bytes
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ public static byte[] readBinary(final InputStream content) throws EntityProviderException {
+ return createEntityProvider().readBinary(content);
+ }
+
+ /**
+ * Read (de-serialize) data from metadata <code>inputStream</code> (as {@link InputStream}) and provide Edm as {@link Edm}
+ *
+ * @param metadataXml a metadata xml input stream (means the metadata document)
+ * @param validate has to be true if metadata should be validated
+ * @return Edm as {@link Edm}
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ public static Edm readMetadata(final InputStream metadataXml, final boolean validate) throws EntityProviderException {
+ return createEntityProvider().readMetadata(metadataXml, validate);
+ }
+
+ /**
+ * Read (de-serialize) data from service document <code>inputStream</code> (as {@link InputStream}) and provide ServiceDocument as {@link ServiceDocument}
+ *
+ * @param serviceDocument the given input stream
+ * @param contentType format of content in the given input stream
+ * @return ServiceDocument as {@link ServiceDocument}
+ * @throws EntityProviderException if reading of data (de-serialization) fails
+ */
+ public static ServiceDocument readServiceDocument(final InputStream serviceDocument, final String contentType) throws EntityProviderException {
+ return createEntityProvider().readServiceDocument(serviceDocument, contentType);
+ }
+
+ /**
+ * Parse Batch Request body <code>inputStream</code> (as {@link InputStream}) and provide a list of Batch Parts as {@link BatchPart}
+ *
+ * @param contentType format of content in the given input stream
+ * @param content request body
+ * @param properties additional properties necessary for parsing. Must not be null.
+ * @return list of {@link BatchPart}
+ * @throws BatchException if parsing fails
+ */
+ public static List<BatchPart> parseBatchRequest(final String contentType, final InputStream content, final EntityProviderBatchProperties properties) throws BatchException {
+ return createEntityProvider().parseBatchRequest(contentType, content, properties);
+ }
+
+ /**
+ * Write responses of Batch Response Parts in Batch Response as {@link ODataResponse}.
+ * Batch Response body matches one-to-one with the corresponding Batch Request body
+ *
+ * @param batchResponseParts a list of {@link BatchResponsePart}
+ * @return Batch Response as {@link ODataResponse}
+ * @throws BatchException
+ */
+ public static ODataResponse writeBatchResponse(final List<BatchResponsePart> batchResponseParts) throws BatchException {
+ return createEntityProvider().writeBatchResponse(batchResponseParts);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderBatchProperties.java
----------------------------------------------------------------------
diff --git a/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderBatchProperties.java b/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderBatchProperties.java
new file mode 100644
index 0000000..ad60c86
--- /dev/null
+++ b/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderBatchProperties.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.api.ep;
+
+import org.apache.olingo.odata2.api.uri.PathInfo;
+
+/**
+ * The {@link EntityProviderBatchProperties} contains necessary informations to parse a Batch Request body.
+ *
+ * @author SAP AG
+ */
+public class EntityProviderBatchProperties {
+ /**
+ * PathInfo contains service root and preceding segments which should be used for URI parsing of a single request
+ */
+ private PathInfo pathInfo;
+
+ public static EntityProviderBatchPropertiesBuilder init() {
+ return new EntityProviderBatchPropertiesBuilder();
+ }
+
+ public PathInfo getPathInfo() {
+ return pathInfo;
+ }
+
+ public static class EntityProviderBatchPropertiesBuilder {
+ private final EntityProviderBatchProperties properties = new EntityProviderBatchProperties();
+
+ public EntityProviderBatchPropertiesBuilder() {}
+
+ public EntityProviderBatchPropertiesBuilder(final EntityProviderBatchProperties propertiesFrom) {
+ properties.pathInfo = propertiesFrom.pathInfo;
+ }
+
+ public EntityProviderBatchPropertiesBuilder pathInfo(final PathInfo pathInfo) {
+ properties.pathInfo = pathInfo;
+ return this;
+ }
+
+ public EntityProviderBatchProperties build() {
+ return properties;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/ff2b0a0e/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderException.java
----------------------------------------------------------------------
diff --git a/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderException.java b/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderException.java
new file mode 100644
index 0000000..00970da
--- /dev/null
+++ b/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderException.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.api.ep;
+
+import org.apache.olingo.odata2.api.exception.MessageReference;
+import org.apache.olingo.odata2.api.exception.ODataMessageException;
+
+/**
+ * An {@link EntityProviderException} is the base exception for all <code>EntityProvider</code> related exceptions.
+ * It extends the {@link ODataMessageException} and provides several {@link MessageReference} for specification of
+ * the thrown exception.
+ */
+public class EntityProviderException extends ODataMessageException {
+
+ private static final long serialVersionUID = 1L;
+
+ /** INVALID_STATE requires no content value */
+ public static final MessageReference COMMON = createMessageReference(EntityProviderException.class, "COMMON");
+ /** EXCEPTION_OCCURRED requires 1 content value ('exception name') */
+ public static final MessageReference EXCEPTION_OCCURRED = createMessageReference(EntityProviderException.class, "EXCEPTION_OCCURRED");
+ /** INVALIDMAPPING requires 1 content value ('propertyName') */
+ public static final MessageReference INVALID_MAPPING = createMessageReference(EntityProviderException.class, "INVALID_MAPPING");
+ /** INVALID_ENTITYTYPE requires 2 content values ('supplied entity type' and 'content entity type') */
+ public static final MessageReference INVALID_ENTITYTYPE = createMessageReference(EntityProviderException.class, "INVALID_ENTITYTYPE");
+ /** INVALID_COMPLEX_TYPE requires 2 content values ('supplied complex type' and 'content complex type') */
+ public static final MessageReference INVALID_COMPLEX_TYPE = createMessageReference(EntityProviderException.class, "INVALID_COMPLEX_TYPE");
+ /** INVALID_CONTENT requires 2 content values ('invalid tag' and 'parent tag') */
+ public static final MessageReference INVALID_CONTENT = createMessageReference(EntityProviderException.class, "INVALID_CONTENT");
+ /** INVALID_PROPERTY_VALUE requires 1 content value ('invalid value') */
+ public static final MessageReference INVALID_PROPERTY_VALUE = createMessageReference(EntityProviderException.class, "INVALID_PROPERTY_VALUE");
+ /** MISSING_PROPERTY requires 1 content value ('invalid value') */
+ public static final MessageReference MISSING_PROPERTY = createMessageReference(EntityProviderException.class, "MISSING_PROPERTY");
+ /** INVALID_PARENT_TAG requires 2 content values ('missing attribute name' and 'tag name') */
+ public static final MessageReference MISSING_ATTRIBUTE = createMessageReference(EntityProviderException.class, "MISSING_ATTRIBUTE");
+ public static final MessageReference UNSUPPORTED_PROPERTY_TYPE = createMessageReference(EntityProviderException.class, "UNSUPPORTED_PROPERTY_TYPE");
+ public static final MessageReference INLINECOUNT_INVALID = createMessageReference(EntityProviderException.class, "INLINECOUNT_INVALID");
+ /** INVALID_STATE requires 1 content value ('message') */
+ public static final MessageReference INVALID_STATE = createMessageReference(EntityProviderException.class, "INVALID_STATE");
+ /** INVALID_INLINE_CONTENT requires 1 content value ('invalid inline message') */
+ public static final MessageReference INVALID_INLINE_CONTENT = createMessageReference(EntityProviderException.class, "INVALID_INLINE_CONTENT");
+ /** INVALID_PROPERTY requires 1 content value ('invalid property name') */
+ public static final MessageReference INVALID_PROPERTY = createMessageReference(EntityProviderException.class, "INVALID_PROPERTY");
+ /** ILLEGAL_ARGUMENT requires 1 content value ('message') */
+ public static final MessageReference ILLEGAL_ARGUMENT = createMessageReference(EntityProviderException.class, "ILLEGAL_ARGUMENT");
+ /** INVALID_NAMESPACE requires 1 content value ('invalid tag/namespace') */
+ public static final MessageReference INVALID_NAMESPACE = createMessageReference(EntityProviderException.class, "INVALID_NAMESPACE");
+ /** INVALID_PARENT_TAG requires 2 content values ('expected parent tag' and 'found parent tag') */
+ public static final MessageReference INVALID_PARENT_TAG = createMessageReference(EntityProviderException.class, "INVALID_PARENT_TAG");
+ public static final MessageReference EXPANDNOTSUPPORTED = createMessageReference(EntityProviderException.class, "EXPANDNOTSUPPORTED");
+ /** DOUBLE_PROPERTY requires 1 content value ('double tag/property') */
+ public static final MessageReference DOUBLE_PROPERTY = createMessageReference(EntityProviderException.class, "DOUBLE_PROPERTY");
+ /** NOT_SET_CHARACTER_ENCODING requires no content value */
+ public static final MessageReference NOT_SET_CHARACTER_ENCODING = createMessageReference(EntityProviderException.class, "NOT_SET_CHARACTER_ENCODING");
+ /** UNSUPPORTED_CHARACTER_ENCODING requires 1 content value ('found but unsupported character encoding') */
+ public static final MessageReference UNSUPPORTED_CHARACTER_ENCODING = createMessageReference(EntityProviderException.class, "UNSUPPORTED_CHARACTER_ENCODING");
+ /** MEDIA_DATA_NOT_INITIAL requires no content value */
+ public static final MessageReference MEDIA_DATA_NOT_INITIAL = createMessageReference(EntityProviderException.class, "MEDIA_DATA_NOT_INITIAL");
+ /** END_DOCUMENT_EXPECTED requires 1 content value ('actual token') */
+ public static final MessageReference END_DOCUMENT_EXPECTED = createMessageReference(EntityProviderException.class, "END_DOCUMENT_EXPECTED");
+ /** MISSING_RESULTS_ARRAY requires no content value */
+ public static final MessageReference MISSING_RESULTS_ARRAY = createMessageReference(EntityProviderException.class, "MISSING_RESULTS_ARRAY");
+
+ public EntityProviderException(final MessageReference messageReference) {
+ super(messageReference);
+ }
+
+ public EntityProviderException(final MessageReference messageReference, final Throwable cause) {
+ super(messageReference, cause);
+ }
+
+ public EntityProviderException(final MessageReference messageReference, final String errorCode) {
+ super(messageReference, errorCode);
+ }
+
+ public EntityProviderException(final MessageReference messageReference, final Throwable cause, final String errorCode) {
+ super(messageReference, cause, errorCode);
+ }
+}