You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/10/21 10:09:57 UTC
[5/7] olingo-odata4 git commit: [OLINGO-713] Added Media Entities
tutorial
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16f5c55d/samples/tutorials/p10_media/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p10_media/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java b/samples/tutorials/p10_media/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
new file mode 100644
index 0000000..8766b8d
--- /dev/null
+++ b/samples/tutorials/p10_media/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
@@ -0,0 +1,146 @@
+/*
+ * 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 myservice.mynamespace.service;
+
+import java.util.List;
+import java.util.Locale;
+
+import myservice.mynamespace.data.Storage;
+
+import org.apache.olingo.commons.api.data.ContextURL;
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.format.ContentType;
+import org.apache.olingo.commons.api.http.HttpHeader;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.ODataRequest;
+import org.apache.olingo.server.api.ODataResponse;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.deserializer.DeserializerException;
+import org.apache.olingo.server.api.processor.PrimitiveProcessor;
+import org.apache.olingo.server.api.serializer.ODataSerializer;
+import org.apache.olingo.server.api.serializer.PrimitiveSerializerOptions;
+import org.apache.olingo.server.api.serializer.SerializerException;
+import org.apache.olingo.server.api.serializer.SerializerResult;
+import org.apache.olingo.server.api.uri.UriInfo;
+import org.apache.olingo.server.api.uri.UriParameter;
+import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceEntitySet;
+import org.apache.olingo.server.api.uri.UriResourceProperty;
+
+public class DemoPrimitiveProcessor implements PrimitiveProcessor {
+
+ private OData odata;
+ private Storage storage;
+ private ServiceMetadata serviceMetadata;
+
+ public DemoPrimitiveProcessor(Storage storage) {
+ this.storage = storage;
+ }
+
+ public void init(OData odata, ServiceMetadata serviceMetadata) {
+ this.odata = odata;
+ this.serviceMetadata = serviceMetadata;
+ }
+
+ /*
+ * In our example, the URL would be: http://localhost:8080/DemoService/DemoService.svc/Products(1)/Name
+ * and the response:
+ * {
+ * @odata.context: "$metadata#Products/Name",
+ * value: "Notebook Basic 15"
+ * }
+ * */
+ public void readPrimitive(ODataRequest request, ODataResponse response,
+ UriInfo uriInfo, ContentType responseFormat)
+ throws ODataApplicationException, SerializerException {
+
+ // 1. Retrieve info from URI
+ // 1.1. retrieve the info about the requested entity set
+ List<UriResource> resourceParts = uriInfo.getUriResourceParts();
+ // Note: only in our example we can rely that the first segment is the EntitySet
+ UriResourceEntitySet uriEntityset = (UriResourceEntitySet) resourceParts.get(0);
+ EdmEntitySet edmEntitySet = uriEntityset.getEntitySet();
+ // the key for the entity
+ List<UriParameter> keyPredicates = uriEntityset.getKeyPredicates();
+
+ // 1.2. retrieve the requested (Edm) property
+ UriResourceProperty uriProperty = (UriResourceProperty)resourceParts.get(resourceParts.size() -1); // the last segment is the Property
+ EdmProperty edmProperty = uriProperty.getProperty();
+ String edmPropertyName = edmProperty.getName();
+ // in our example, we know we have only primitive types in our model
+ EdmPrimitiveType edmPropertyType = (EdmPrimitiveType) edmProperty.getType();
+
+
+ // 2. retrieve data from backend
+ // 2.1. retrieve the entity data, for which the property has to be read
+ Entity entity = storage.readEntityData(edmEntitySet, keyPredicates);
+ if (entity == null) { // Bad request
+ throw new ODataApplicationException("Entity not found",
+ HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+ }
+
+ // 2.2. retrieve the property data from the entity
+ Property property = entity.getProperty(edmPropertyName);
+ if (property == null) {
+ throw new ODataApplicationException("Property not found",
+ HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+ }
+
+ // 3. serialize
+ Object value = property.getValue();
+ if (value != null) {
+ // 3.1. configure the serializer
+ ODataSerializer serializer = odata.createSerializer(responseFormat);
+
+ ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).navOrPropertyPath(edmPropertyName).build();
+ PrimitiveSerializerOptions options = PrimitiveSerializerOptions.with().contextURL(contextUrl).build();
+ // 3.2. serialize
+ SerializerResult result = serializer.primitive(serviceMetadata, edmPropertyType, property, options);
+
+ //4. configure the response object
+ response.setContent(result.getContent());
+ response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+ response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+ }else{
+ // in case there's no value for the property, we can skip the serialization
+ response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+ }
+ }
+
+ /*
+ * These processor methods are not handled in this tutorial
+ *
+ * */
+ public void updatePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo,
+ ContentType requestFormat, ContentType responseFormat)
+ throws ODataApplicationException, DeserializerException, SerializerException {
+ throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+ }
+
+ public void deletePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo)
+ throws ODataApplicationException {
+ throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16f5c55d/samples/tutorials/p10_media/src/main/java/myservice/mynamespace/util/Util.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p10_media/src/main/java/myservice/mynamespace/util/Util.java b/samples/tutorials/p10_media/src/main/java/myservice/mynamespace/util/Util.java
new file mode 100644
index 0000000..97e8eff
--- /dev/null
+++ b/samples/tutorials/p10_media/src/main/java/myservice/mynamespace/util/Util.java
@@ -0,0 +1,161 @@
+/*
+ * 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 myservice.mynamespace.util;
+
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.olingo.commons.api.data.Entity;
+import org.apache.olingo.commons.api.data.EntityCollection;
+import org.apache.olingo.commons.api.edm.EdmBindingTarget;
+import org.apache.olingo.commons.api.edm.EdmEntitySet;
+import org.apache.olingo.commons.api.edm.EdmEntityType;
+import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmProperty;
+import org.apache.olingo.commons.api.edm.EdmType;
+import org.apache.olingo.commons.api.http.HttpStatusCode;
+import org.apache.olingo.server.api.ODataApplicationException;
+import org.apache.olingo.server.api.uri.UriInfoResource;
+import org.apache.olingo.server.api.uri.UriParameter;
+import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceEntitySet;
+
+public class Util {
+
+ public static EdmEntitySet getEdmEntitySet(UriInfoResource uriInfo) throws ODataApplicationException {
+
+ List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+ // To get the entity set we have to interpret all URI segments
+ if (!(resourcePaths.get(0) instanceof UriResourceEntitySet)) {
+ // Here we should interpret the whole URI but in this example we do not support navigation so we throw an
+ // exception
+ throw new ODataApplicationException("Invalid resource type for first segment.", HttpStatusCode.NOT_IMPLEMENTED
+ .getStatusCode(), Locale.ENGLISH);
+ }
+
+ UriResourceEntitySet uriResource = (UriResourceEntitySet) resourcePaths.get(0);
+
+ return uriResource.getEntitySet();
+ }
+
+ public static Entity findEntity(EdmEntityType edmEntityType, EntityCollection entitySet,
+ List<UriParameter> keyParams) throws ODataApplicationException {
+
+ List<Entity> entityList = entitySet.getEntities();
+
+ // loop over all entities in order to find that one that matches
+ // all keys in request e.g. contacts(ContactID=1, CompanyID=1)
+ for (Entity entity : entityList) {
+ boolean foundEntity = entityMatchesAllKeys(edmEntityType, entity, keyParams);
+ if (foundEntity) {
+ return entity;
+ }
+ }
+
+ return null;
+ }
+
+ public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams)
+ throws ODataApplicationException {
+
+ // loop over all keys
+ for (final UriParameter key : keyParams) {
+ // key
+ String keyName = key.getName();
+ String keyText = key.getText();
+
+ // Edm: we need this info for the comparison below
+ EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName);
+ Boolean isNullable = edmKeyProperty.isNullable();
+ Integer maxLength = edmKeyProperty.getMaxLength();
+ Integer precision = edmKeyProperty.getPrecision();
+ Boolean isUnicode = edmKeyProperty.isUnicode();
+ Integer scale = edmKeyProperty.getScale();
+ // get the EdmType in order to compare
+ EdmType edmType = edmKeyProperty.getType();
+ EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType;
+
+ // Runtime data: the value of the current entity
+ // don't need to check for null, this is done in olingo library
+ Object valueObject = entity.getProperty(keyName).getValue();
+
+ // now need to compare the valueObject with the keyText String
+ // this is done using the type.valueToString //
+ String valueAsString = null;
+ try {
+ valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode);
+ } catch (EdmPrimitiveTypeException e) {
+ throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR
+ .getStatusCode(), Locale.ENGLISH, e);
+ }
+
+ if (valueAsString == null) {
+ return false;
+ }
+
+ boolean matches = valueAsString.equals(keyText);
+ if (!matches) {
+ // if any of the key properties is not found in the entity, we don't need to search further
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Example:
+ * For the following navigation: DemoService.svc/Categories(1)/Products
+ * we need the EdmEntitySet for the navigation property "Products"
+ *
+ * This is defined as follows in the metadata:
+ * <code>
+ *
+ * <EntitySet Name="Categories" EntityType="OData.Demo.Category">
+ * <NavigationPropertyBinding Path="Products" Target="Products"/>
+ * </EntitySet>
+ * </code>
+ * The "Target" attribute specifies the target EntitySet
+ * Therefore we need the startEntitySet "Categories" in order to retrieve the target EntitySet "Products"
+ */
+ public static EdmEntitySet getNavigationTargetEntitySet(EdmEntitySet startEdmEntitySet,
+ EdmNavigationProperty edmNavigationProperty)
+ throws ODataApplicationException {
+
+ EdmEntitySet navigationTargetEntitySet = null;
+
+ String navPropName = edmNavigationProperty.getName();
+ EdmBindingTarget edmBindingTarget = startEdmEntitySet.getRelatedBindingTarget(navPropName);
+ if (edmBindingTarget == null) {
+ throw new ODataApplicationException("Not supported.",
+ HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+ }
+
+ if (edmBindingTarget instanceof EdmEntitySet) {
+ navigationTargetEntitySet = (EdmEntitySet) edmBindingTarget;
+ } else {
+ throw new ODataApplicationException("Not supported.",
+ HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+ }
+
+ return navigationTargetEntitySet;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16f5c55d/samples/tutorials/p10_media/src/main/java/myservice/mynamespace/web/DemoServlet.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p10_media/src/main/java/myservice/mynamespace/web/DemoServlet.java b/samples/tutorials/p10_media/src/main/java/myservice/mynamespace/web/DemoServlet.java
new file mode 100644
index 0000000..3040f0e
--- /dev/null
+++ b/samples/tutorials/p10_media/src/main/java/myservice/mynamespace/web/DemoServlet.java
@@ -0,0 +1,73 @@
+/*
+ * 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 myservice.mynamespace.web;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.olingo.server.api.OData;
+import org.apache.olingo.server.api.ODataHttpHandler;
+import org.apache.olingo.server.api.ServiceMetadata;
+import org.apache.olingo.server.api.edmx.EdmxReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import myservice.mynamespace.data.Storage;
+import myservice.mynamespace.service.DemoEdmProvider;
+import myservice.mynamespace.service.DemoEntityCollectionProcessor;
+import myservice.mynamespace.service.DemoEntityProcessor;
+import myservice.mynamespace.service.DemoPrimitiveProcessor;
+
+public class DemoServlet extends HttpServlet {
+
+ private static final long serialVersionUID = 1L;
+ private static final Logger LOG = LoggerFactory.getLogger(DemoServlet.class);
+
+ @Override
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ try {
+ HttpSession session = req.getSession(true);
+ Storage storage = (Storage) session.getAttribute(Storage.class.getName());
+ if (storage == null) {
+ storage = new Storage();
+ session.setAttribute(Storage.class.getName(), storage);
+ }
+
+ // create odata handler and configure it with EdmProvider and Processor
+ OData odata = OData.newInstance();
+ ServiceMetadata edm = odata.createServiceMetadata(new DemoEdmProvider(), new ArrayList<EdmxReference>());
+ ODataHttpHandler handler = odata.createHandler(edm);
+ handler.register(new DemoEntityCollectionProcessor(storage));
+ handler.register(new DemoEntityProcessor(storage));
+ handler.register(new DemoPrimitiveProcessor(storage));
+
+ // let the handler do the work
+ handler.process(req, resp);
+ } catch (RuntimeException e) {
+ LOG.error("Server Error occurred in ExampleServlet", e);
+ throw new ServletException(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16f5c55d/samples/tutorials/p10_media/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/samples/tutorials/p10_media/src/main/webapp/WEB-INF/web.xml b/samples/tutorials/p10_media/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..21de52a
--- /dev/null
+++ b/samples/tutorials/p10_media/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ id="WebApp_ID" version="2.5">
+
+ <!-- Register the HttpServlet implementation -->
+ <servlet>
+ <servlet-name>DemoServlet</servlet-name>
+ <servlet-class>myservice.mynamespace.web.DemoServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <!--
+ Our OData service can be invoked at
+ http://localhost:8080/DemoService/DemoService.svc
+ -->
+ <servlet-mapping>
+ <servlet-name>DemoServlet</servlet-name>
+ <url-pattern>/DemoService.svc/*</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16f5c55d/samples/tutorials/p10_media/src/main/webapp/index.jsp
----------------------------------------------------------------------
diff --git a/samples/tutorials/p10_media/src/main/webapp/index.jsp b/samples/tutorials/p10_media/src/main/webapp/index.jsp
new file mode 100644
index 0000000..7ffb4ba
--- /dev/null
+++ b/samples/tutorials/p10_media/src/main/webapp/index.jsp
@@ -0,0 +1,26 @@
+<!--
+
+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.
+
+-->
+<html>
+<body>
+<h2>Hello World!</h2>
+<a href="DemoService.svc/">OData Olingo V4 Demo Service</a>
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16f5c55d/samples/tutorials/p9_action/src/main/java/myservice/mynamespace/data/Storage.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p9_action/src/main/java/myservice/mynamespace/data/Storage.java b/samples/tutorials/p9_action/src/main/java/myservice/mynamespace/data/Storage.java
index 262a0f9..12b373f 100644
--- a/samples/tutorials/p9_action/src/main/java/myservice/mynamespace/data/Storage.java
+++ b/samples/tutorials/p9_action/src/main/java/myservice/mynamespace/data/Storage.java
@@ -143,9 +143,9 @@ public class Storage {
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
- if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
+ if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
return getEntity(edmEntityType, keyParams, productList);
- } else if(edmEntityType.getName().equals(DemoEdmProvider.ET_CATEGORY_NAME)) {
+ } else if(edmEntitySet.getName().equals(DemoEdmProvider.ES_CATEGORIES_NAME)) {
return getEntity(edmEntityType, keyParams, categoryList);
}
@@ -156,9 +156,9 @@ public class Storage {
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
- if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
+ if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
return createEntity(edmEntityType, entityToCreate, productList);
- } else if(edmEntityType.getName().equals(DemoEdmProvider.ET_CATEGORY_NAME)) {
+ } else if(edmEntitySet.getName().equals(DemoEdmProvider.ES_CATEGORIES_NAME)) {
return createEntity(edmEntityType, entityToCreate, categoryList);
}
@@ -173,9 +173,9 @@ public class Storage {
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
- if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
+ if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
updateEntity(edmEntityType, keyParams, updateEntity, httpMethod, productList);
- } else if(edmEntityType.getName().equals(DemoEdmProvider.ET_CATEGORY_NAME)) {
+ } else if(edmEntitySet.getName().equals(DemoEdmProvider.ES_CATEGORIES_NAME)) {
updateEntity(edmEntityType, keyParams, updateEntity, httpMethod, categoryList);
}
}
@@ -185,9 +185,9 @@ public class Storage {
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
- if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
+ if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
deleteEntity(edmEntityType, keyParams, productList);
- } else if(edmEntityType.getName().equals(DemoEdmProvider.ET_CATEGORY_NAME)) {
+ } else if(edmEntitySet.getName().equals(DemoEdmProvider.ES_CATEGORIES_NAME)) {
deleteEntity(edmEntityType, keyParams, categoryList);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16f5c55d/samples/tutorials/p9_action_preparation/src/main/java/myservice/mynamespace/data/Storage.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p9_action_preparation/src/main/java/myservice/mynamespace/data/Storage.java b/samples/tutorials/p9_action_preparation/src/main/java/myservice/mynamespace/data/Storage.java
index d75a7d2..c4bdee0 100644
--- a/samples/tutorials/p9_action_preparation/src/main/java/myservice/mynamespace/data/Storage.java
+++ b/samples/tutorials/p9_action_preparation/src/main/java/myservice/mynamespace/data/Storage.java
@@ -73,9 +73,9 @@ public class Storage {
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
- if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
+ if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
return getEntity(edmEntityType, keyParams, productList);
- } else if(edmEntityType.getName().equals(DemoEdmProvider.ET_CATEGORY_NAME)) {
+ } else if(edmEntitySet.getName().equals(DemoEdmProvider.ES_CATEGORIES_NAME)) {
return getEntity(edmEntityType, keyParams, categoryList);
}
@@ -86,9 +86,9 @@ public class Storage {
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
- if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
+ if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
return createEntity(edmEntityType, entityToCreate, productList);
- } else if(edmEntityType.getName().equals(DemoEdmProvider.ET_CATEGORY_NAME)) {
+ } else if(edmEntitySet.getName().equals(DemoEdmProvider.ES_CATEGORIES_NAME)) {
return createEntity(edmEntityType, entityToCreate, categoryList);
}
@@ -103,9 +103,9 @@ public class Storage {
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
- if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
+ if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
updateEntity(edmEntityType, keyParams, updateEntity, httpMethod, productList);
- } else if(edmEntityType.getName().equals(DemoEdmProvider.ET_CATEGORY_NAME)) {
+ } else if(edmEntitySet.getName().equals(DemoEdmProvider.ES_CATEGORIES_NAME)) {
updateEntity(edmEntityType, keyParams, updateEntity, httpMethod, categoryList);
}
}
@@ -115,9 +115,9 @@ public class Storage {
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
- if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
+ if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
deleteEntity(edmEntityType, keyParams, productList);
- } else if(edmEntityType.getName().equals(DemoEdmProvider.ET_CATEGORY_NAME)) {
+ } else if(edmEntitySet.getName().equals(DemoEdmProvider.ES_CATEGORIES_NAME)) {
deleteEntity(edmEntityType, keyParams, categoryList);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/16f5c55d/samples/tutorials/pom.xml
----------------------------------------------------------------------
diff --git a/samples/tutorials/pom.xml b/samples/tutorials/pom.xml
index 1a21e5f..792bcea 100644
--- a/samples/tutorials/pom.xml
+++ b/samples/tutorials/pom.xml
@@ -46,6 +46,7 @@
<module>p8_queryoptions-f</module>
<module>p9_action</module>
<module>p9_action_preparation</module>
+ <module>p10_media</module>
</modules>
<build>