Java Code Examples for org.apache.olingo.commons.api.http.HttpMethod#equals()
The following examples show how to use
org.apache.olingo.commons.api.http.HttpMethod#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Storage.java From syndesis with Apache License 2.0 | 5 votes |
private void updateProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams, Entity entity, HttpMethod httpMethod) throws ODataApplicationException { Entity productEntity = getProduct(edmEntityType, keyParams); if (productEntity == null) { throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH); } // loop over all properties and replace the values with the values of the given payload // Note: ignoring ComplexType, as we don't have it in our odata model List<Property> existingProperties = productEntity.getProperties(); for (Property existingProp : existingProperties) { String propName = existingProp.getName(); // ignore the key properties, they aren't updateable if (isKey(edmEntityType, propName)) { continue; } Property updateProperty = entity.getProperty(propName); // the request payload might not consider ALL properties, so it can be null if (updateProperty == null) { // if a property has NOT been added to the request payload // depending on the HttpMethod, our behavior is different if (httpMethod.equals(HttpMethod.PATCH)) { // as of the OData spec, in case of PATCH, the existing property is not touched continue; // do nothing } else if (httpMethod.equals(HttpMethod.PUT)) { // as of the OData spec, in case of PUT, the existing property is set to null (or to default value) existingProp.setValue(existingProp.getValueType(), null); continue; } } // change the value of the properties existingProp.setValue(existingProp.getValueType(), updateProperty.getValue()); } }
Example 2
Source File: ServiceRequest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
public static boolean assertHttpMethod(HttpMethod issued, HttpMethod[] allowedMethods, ODataResponse response) throws ODataHandlerException { boolean allowed = false; for (HttpMethod method :allowedMethods) { if (issued.equals(method)) { allowed = true; } } if (!allowed) { return methodNotAllowed(response, issued, null, allowedMethods); } return true; }
Example 3
Source File: ServiceRequest.java From olingo-odata4 with Apache License 2.0 | 5 votes |
public boolean assertHttpMethod(ODataResponse response) throws ODataHandlerException { boolean allowed = false; HttpMethod issued = this.request.getMethod(); for (HttpMethod method :allowedMethods()) { if (issued.equals(method)) { allowed = true; } } if (!allowed) { return methodNotAllowed(response, issued, null, allowedMethods()); } return true; }
Example 4
Source File: Storage.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private void updateProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams, Entity entity, HttpMethod httpMethod) throws ODataApplicationException { Entity productEntity = getProduct(edmEntityType, keyParams); if (productEntity == null) { throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH); } // loop over all properties and replace the values with the values of the given payload // Note: ignoring ComplexType, as we don't have it in our odata model List<Property> existingProperties = productEntity.getProperties(); for (Property existingProp : existingProperties) { String propName = existingProp.getName(); // ignore the key properties, they aren't updateable if (isKey(edmEntityType, propName)) { continue; } Property updateProperty = entity.getProperty(propName); // the request payload might not consider ALL properties, so it can be null if (updateProperty == null) { // if a property has NOT been added to the request payload // depending on the HttpMethod, our behavior is different if (httpMethod.equals(HttpMethod.PATCH)) { // as of the OData spec, in case of PATCH, the existing property is not touched continue; // do nothing } else if (httpMethod.equals(HttpMethod.PUT)) { // as of the OData spec, in case of PUT, the existing property is set to null (or to default value) existingProp.setValue(existingProp.getValueType(), null); continue; } } // change the value of the properties existingProp.setValue(existingProp.getValueType(), updateProperty.getValue()); } }
Example 5
Source File: Storage.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private void updateProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams, Entity entity, HttpMethod httpMethod) throws ODataApplicationException { Entity productEntity = getProduct(edmEntityType, keyParams); if (productEntity == null) { throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH); } // loop over all properties and replace the values with the values of the given payload // Note: ignoring ComplexType, as we don't have it in our odata model List<Property> existingProperties = productEntity.getProperties(); for (Property existingProp : existingProperties) { String propName = existingProp.getName(); // ignore the key properties, they aren't updateable if (isKey(edmEntityType, propName)) { continue; } Property updateProperty = entity.getProperty(propName); // the request payload might not consider ALL properties, so it can be null if (updateProperty == null) { // if a property has NOT been added to the request payload // depending on the HttpMethod, our behavior is different if (httpMethod.equals(HttpMethod.PATCH)) { // as of the OData spec, in case of PATCH, the existing property is not touched continue; // do nothing } else if (httpMethod.equals(HttpMethod.PUT)) { // as of the OData spec, in case of PUT, the existing property is set to null (or to default value) existingProp.setValue(existingProp.getValueType(), null); continue; } } // change the value of the properties existingProp.setValue(existingProp.getValueType(), updateProperty.getValue()); } }