diff --git a/ext/client-proxy-android/pom.xml b/ext/client-proxy-android/pom.xml new file mode 100644 index 000000000..b8c8027e4 --- /dev/null +++ b/ext/client-proxy-android/pom.xml @@ -0,0 +1,96 @@ + + + + 4.0.0 + + olingo-client-proxy-android + jar + ${project.artifactId} + + + org.apache.olingo + olingo-ext + 0.1.0-SNAPSHOT + .. + + + + + org.apache.olingo + olingo-client-proxy + ${project.version} + true + + + + + + + org.sonatype.plugins + jarjar-maven-plugin + true + + + package + + jarjar + + + + org.apache.olingo:olingo-client-proxy-android + org.apache.olingo:olingo-client-proxy + org.apache.olingo:olingo-client-core-android + org.apache.olingo:olingo-client-core + org.apache.olingo:olingo-client-api + org.apache.olingo:olingo-commons-api + org.apache.commons:commons-lang3 + org.slf4j:slf4j-api + commons-io:commons-io + commons-beanutils:commons-beanutils + org.apache.httpcomponents:httpclient + org.apache.httpcomponents:httpcore + commons-logging:commons-logging + org.apache.olingo:olingo-commons-core + commons-codec:commons-codec + com.fasterxml.jackson.core:jackson-core + com.fasterxml.jackson.core:jackson-databind + com.fasterxml.jackson.core:jackson-annotations + com.fasterxml.jackson.dataformat:jackson-dataformat-xml + com.fasterxml.jackson.module:jackson-module-jaxb-annotations + org.codehaus.woodstox:stax2-api + javax.xml.stream:stax-api + com.fasterxml:aalto-xml + + + + javax.xml.stream.** + org.apache.olingo.javax.xml.stream.@1 + + + + + + + + + diff --git a/ext/client-proxy/pom.xml b/ext/client-proxy/pom.xml index 827e7e9b1..bda3379d4 100644 --- a/ext/client-proxy/pom.xml +++ b/ext/client-proxy/pom.xml @@ -51,7 +51,7 @@ commons-beanutils - commons-beanutils-core + commons-beanutils commons-logging diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractAnnotatable.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Annotatable.java similarity index 95% rename from ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractAnnotatable.java rename to ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Annotatable.java index b0a1f4ff3..08af72be5 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/AbstractAnnotatable.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/Annotatable.java @@ -21,7 +21,7 @@ package org.apache.olingo.ext.proxy.api; import java.io.Serializable; import java.util.Collection; -public interface AbstractAnnotatable extends Serializable { +public interface Annotatable extends Serializable { void addAnnotation(Class term, Object value); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v4/BatchStreamManager.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/AnnotationsForNavigationProperty.java similarity index 63% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v4/BatchStreamManager.java rename to ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/AnnotationsForNavigationProperty.java index 8caaf7a4d..ac57ee935 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v4/BatchStreamManager.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/AnnotationsForNavigationProperty.java @@ -16,19 +16,19 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.api.communication.request.batch.v4; +package org.apache.olingo.ext.proxy.api.annotations; -/** - * Batch request payload management. - */ -public interface BatchStreamManager - extends org.apache.olingo.client.api.communication.request.batch.BatchStreamManager { +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface AnnotationsForNavigationProperty { + + String name(); + + String type(); - /** - * Gets an outside update batch item instance. An outside update item can be submitted embedded into a batch request - * only. - * - * @return ODataOutsideUpdate instance. - */ - ODataOutsideUpdate addOutsideUpdate(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v3/BatchStreamManager.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/AnnotationsForProperty.java similarity index 69% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v3/BatchStreamManager.java rename to ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/AnnotationsForProperty.java index 0dd5bfbe1..1e317b2d4 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v3/BatchStreamManager.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/annotations/AnnotationsForProperty.java @@ -16,11 +16,19 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.api.communication.request.batch.v3; +package org.apache.olingo.ext.proxy.api.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface AnnotationsForProperty { + + String name(); + + String type(); -/** - * Batch request payload management. - */ -public interface BatchStreamManager - extends org.apache.olingo.client.api.communication.request.batch.BatchStreamManager { } diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java index 2ce424a17..09b443b5a 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractInvocationHandler.java @@ -35,12 +35,17 @@ import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.olingo.client.api.CommonEdmEnabledODataClient; +import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent; +import org.apache.olingo.client.api.http.HttpMethod; import org.apache.olingo.commons.api.domain.CommonODataEntity; import org.apache.olingo.commons.api.domain.CommonODataEntitySet; import org.apache.olingo.commons.api.domain.CommonODataProperty; import org.apache.olingo.commons.api.domain.ODataInvokeResult; import org.apache.olingo.commons.api.domain.ODataValue; +import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmOperation; +import org.apache.olingo.commons.api.edm.EdmReturnType; +import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; import org.apache.olingo.commons.core.edm.EdmTypeInfo; import org.apache.olingo.ext.proxy.EntityContainerFactory; import org.apache.olingo.ext.proxy.api.OperationType; @@ -156,6 +161,25 @@ abstract class AbstractInvocationHandler implements InvocationHandler { handler); } + @SuppressWarnings("unchecked") + private Class getResultReference(final EdmReturnType returnType) { + Class result; + + if (returnType == null) { + result = (Class) ODataNoContent.class; + } else { + if (returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) { + result = (Class) CommonODataEntitySet.class; + } else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) { + result = (Class) CommonODataEntity.class; + } else { + result = (Class) CommonODataProperty.class; + } + } + + return result; + } + protected Object invokeOperation( final Operation annotation, final Method method, @@ -193,7 +217,11 @@ abstract class AbstractInvocationHandler implements InvocationHandler { // 3. invoke final ODataInvokeResult result = client.getInvokeRequestFactory().getInvokeRequest( - target, edmOperation, parameterValues).execute().getBody(); + edmOperation instanceof EdmFunction ? HttpMethod.GET : HttpMethod.POST, + target, + getResultReference(edmOperation.getReturnType()), + parameterValues). + execute().getBody(); // 4. process invoke result if (StringUtils.isBlank(annotation.returnType())) { diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java index 3a858951a..5f04408e6 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java @@ -26,6 +26,8 @@ import java.lang.reflect.Type; import java.net.URI; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import org.apache.commons.lang3.ArrayUtils; import org.apache.olingo.client.api.CommonEdmEnabledODataClient; import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest; @@ -66,6 +68,12 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca protected Object internal; + private final Map propAnnotatableHandlers = + new HashMap(); + + private final Map navPropAnnotatableHandlers = + new HashMap(); + protected AbstractStructuredInvocationHandler( final CommonEdmEnabledODataClient client, final Class typeRef, @@ -91,6 +99,10 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca this.entityHandler = entityHandler == this ? null : entityHandler; } + public Object getInternal() { + return internal; + } + public EntityInvocationHandler getEntityHandler() { return entityHandler == null ? this instanceof EntityInvocationHandler @@ -126,6 +138,13 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca Thread.currentThread().getContextClassLoader(), new Class[] {returnType}, ComplexFactoryInvocationHandler.getInstance(getEntityHandler(), this)); + } else if ("annotations".equals(method.getName()) && ArrayUtils.isEmpty(args)) { + final Class returnType = method.getReturnType(); + + return Proxy.newProxyInstance( + Thread.currentThread().getContextClassLoader(), + new Class[] {returnType}, + AnnotatationsInvocationHandler.getInstance(getEntityHandler(), this)); } else if (method.getName().startsWith("get")) { // Assumption: for each getter will always exist a setter and viceversa. // get method annotation and check if it exists as expected @@ -222,7 +241,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca null, ((ODataInlineEntity) link).getEntity(), property.targetContainer(), - client.getURIBuilder(serviceRoot).appendEntitySetSegment(property.targetEntitySet()).build(), + client.newURIBuilder(serviceRoot).appendEntitySetSegment(property.targetEntitySet()).build(), type, false); } else if (link instanceof ODataInlineEntitySet) { @@ -259,7 +278,7 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca uri, res.getBody(), property.targetContainer(), - client.getURIBuilder(serviceRoot).appendEntitySetSegment(property.targetEntitySet()).build(), + client.newURIBuilder(serviceRoot).appendEntitySetSegment(property.targetEntitySet()).build(), type, res.getETag(), true); @@ -269,18 +288,6 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca return navPropValue; } - protected abstract Object getPropertyValue(final String name, final Type type); - - public void addAdditionalProperty(final String name, final Object value) { - addPropertyChanges(name, value); - attach(AttachedEntityStatus.CHANGED); - } - - public void removeAdditionalProperty(final String name) { - removePropertyChanges(name); - attach(AttachedEntityStatus.CHANGED); - } - public Object getAdditionalProperty(final String name) { return getPropertyValue(name, null); } @@ -316,13 +323,31 @@ public abstract class AbstractStructuredInvocationHandler extends AbstractInvoca addLinkChanges(property, value); } + public Map getPropAnnotatableHandlers() { + return propAnnotatableHandlers; + } + + public void putPropAnnotatableHandler(final String propName, final AnnotatableInvocationHandler handler) { + propAnnotatableHandlers.put(propName, handler); + } + + public Map getNavPropAnnotatableHandlers() { + return navPropAnnotatableHandlers; + } + + public void putNavPropAnnotatableHandler(final String navPropName, final AnnotatableInvocationHandler handler) { + navPropAnnotatableHandlers.put(navPropName, handler); + } + protected abstract void setPropertyValue(final Property property, final Object value); - protected abstract void addPropertyChanges(final String name, final Object value); - - protected abstract void removePropertyChanges(final String name); - protected abstract void addLinkChanges(final NavigationProperty navProp, final Object value); + protected abstract Object getPropertyValue(final String name, final Type type); + + public abstract void addAdditionalProperty(final String name, final Object value); + + public abstract void removeAdditionalProperty(final String name); + public abstract boolean isChanged(); } diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java new file mode 100644 index 000000000..c0a4e539c --- /dev/null +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatableInvocationHandler.java @@ -0,0 +1,180 @@ +/* + * 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.ext.proxy.commons; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.olingo.client.api.CommonEdmEnabledODataClient; +import org.apache.olingo.commons.api.domain.v4.ODataAnnotation; +import org.apache.olingo.commons.api.domain.v4.ODataEntity; +import org.apache.olingo.commons.api.domain.v4.ODataLinkedComplexValue; +import org.apache.olingo.ext.proxy.api.AbstractTerm; +import org.apache.olingo.ext.proxy.api.Annotatable; +import org.apache.olingo.ext.proxy.api.annotations.Namespace; +import org.apache.olingo.ext.proxy.api.annotations.Term; +import org.apache.olingo.ext.proxy.context.AttachedEntityStatus; +import org.apache.olingo.ext.proxy.utils.CoreUtils; + +public class AnnotatableInvocationHandler extends AbstractInvocationHandler implements Annotatable { + + private static final long serialVersionUID = 3111228269617223332L; + + private final String propName; + + private final String navPropName; + + private final EntityInvocationHandler entityHandler; + + private final AbstractStructuredInvocationHandler targetHandler; + + private final Map, Object> annotations = + new HashMap, Object>(); + + public AnnotatableInvocationHandler( + final CommonEdmEnabledODataClient client, + final EntityContainerInvocationHandler containerHandler, + final String propName, + final String navPropName, + final EntityInvocationHandler entityHandler, + final AbstractStructuredInvocationHandler targetHandler) { + + super(client, containerHandler); + + this.propName = propName; + this.navPropName = navPropName; + this.entityHandler = entityHandler; + this.targetHandler = targetHandler; + } + + @Override + public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { + return invokeSelfMethod(method, args); + } + + public Map, Object> getAnnotations() { + return annotations; + } + + private List internalAnnotations() { + List result = Collections.emptyList(); + + if (entityHandler.getEntity() instanceof ODataEntity) { + if (targetHandler.getInternal() instanceof ODataEntity) { + result = propName == null + ? ((org.apache.olingo.commons.api.domain.v4.ODataLink) ((ODataEntity) targetHandler.getInternal()). + getNavigationLink(navPropName)).getAnnotations() + : ((ODataEntity) targetHandler.getInternal()).getProperty(propName).getAnnotations(); + } else if (targetHandler.getInternal() instanceof ODataLinkedComplexValue) { + result = propName == null + ? ((org.apache.olingo.commons.api.domain.v4.ODataLink) ((ODataLinkedComplexValue) targetHandler. + getInternal()).getNavigationLink(navPropName)).getAnnotations() + : ((ODataLinkedComplexValue) targetHandler.getInternal()).get(propName).getAnnotations(); + } + } + + return result; + } + + @Override + public void addAnnotation(final Class term, final Object value) { + this.annotations.put(term, value); + + if (value != null) { + Collection coll; + if (Collection.class.isAssignableFrom(value.getClass())) { + coll = Collection.class.cast(value); + } else { + coll = Collections.singleton(value); + } + + for (Object item : coll) { + if (item instanceof Proxy) { + final InvocationHandler handler = Proxy.getInvocationHandler(item); + if ((handler instanceof ComplexInvocationHandler) + && ((ComplexInvocationHandler) handler).getEntityHandler() == null) { + ((ComplexInvocationHandler) handler).setEntityHandler(entityHandler); + } + } + } + } + + entityHandler.attach(AttachedEntityStatus.CHANGED); + if (navPropName == null) { + targetHandler.putPropAnnotatableHandler(propName, this); + } else { + targetHandler.putNavPropAnnotatableHandler(navPropName, this); + } + } + + @Override + public void removeAnnotation(final Class term) { + this.annotations.remove(term); + + entityHandler.attach(AttachedEntityStatus.CHANGED); + if (navPropName == null) { + targetHandler.putPropAnnotatableHandler(propName, this); + } else { + targetHandler.putNavPropAnnotatableHandler(navPropName, this); + } + } + + @Override + public Object getAnnotation(final Class term) { + Object res = null; + + if (annotations.containsKey(term)) { + res = annotations.get(term); + } else if (entityHandler.getEntity() instanceof ODataEntity) { + try { + final Term termAnn = term.getAnnotation(Term.class); + final Namespace namespaceAnn = term.getAnnotation(Namespace.class); + ODataAnnotation annotation = null; + for (ODataAnnotation _annotation : internalAnnotations()) { + if ((namespaceAnn.value() + "." + termAnn.name()).equals(_annotation.getTerm())) { + annotation = _annotation; + } + } + res = annotation == null || annotation.hasNullValue() + ? null + : CoreUtils.getObjectFromODataValue( + client, annotation.getValue(), null, targetHandler.getEntityHandler()); + if (res != null) { + annotations.put(term, res); + } + } catch (Exception e) { + throw new IllegalArgumentException("Error getting annotation for term '" + term.getName() + "'", e); + } + } + + return res; + } + + @Override + public Collection> getAnnotationTerms() { + return entityHandler.getEntity() instanceof ODataEntity + ? CoreUtils.getAnnotationTerms(internalAnnotations()) + : Collections.>emptyList(); + } +} diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatationsInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatationsInvocationHandler.java new file mode 100644 index 000000000..d9ef3eaf5 --- /dev/null +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AnnotatationsInvocationHandler.java @@ -0,0 +1,91 @@ +/* + * 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.ext.proxy.commons; + +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import org.apache.olingo.client.api.CommonEdmEnabledODataClient; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.utils.ClassUtils; + +public class AnnotatationsInvocationHandler extends AbstractInvocationHandler { + + private static final long serialVersionUID = -1993362719908718985L; + + private final EntityInvocationHandler entityHandler; + + private final AbstractStructuredInvocationHandler targetHandler; + + static AnnotatationsInvocationHandler getInstance( + final EntityInvocationHandler entityHandler, + final AbstractStructuredInvocationHandler targetHandler) { + + return new AnnotatationsInvocationHandler( + entityHandler == null ? null : entityHandler.containerHandler.client, + targetHandler == null + ? entityHandler == null ? null : entityHandler.containerHandler : targetHandler.containerHandler, + entityHandler, + targetHandler); + } + + private AnnotatationsInvocationHandler( + final CommonEdmEnabledODataClient client, + final EntityContainerInvocationHandler containerHandler, + final EntityInvocationHandler entityHandler, + final AbstractStructuredInvocationHandler targetHandler) { + + super(client, containerHandler); + this.targetHandler = targetHandler; + this.entityHandler = entityHandler; + } + + @Override + public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { + if (isSelfMethod(method, args)) { + return invokeSelfMethod(method, args); + } else if (method.getName().startsWith("get") && method.getName().endsWith("Annotations")) { + final Method getter = proxy.getClass().getInterfaces()[0].getMethod(method.getName()); + + String propName = null; + String navPropName = null; + + final AnnotationsForProperty annForProp = ClassUtils.getAnnotation(AnnotationsForProperty.class, getter); + if (annForProp == null) { + final AnnotationsForNavigationProperty annForNavProp = + ClassUtils.getAnnotation(AnnotationsForNavigationProperty.class, getter); + if (annForNavProp == null) { + throw new UnsupportedOperationException("Unsupported method " + method.getName()); + } + + navPropName = annForNavProp.name(); + } else { + propName = annForProp.name(); + } + + return Proxy.newProxyInstance( + Thread.currentThread().getContextClassLoader(), + new Class[] {method.getReturnType()}, + new AnnotatableInvocationHandler( + client, containerHandler, propName, navPropName, entityHandler, targetHandler)); + } else { + throw new NoSuchMethodException(method.getName()); + } + } +} diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexFactoryInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexFactoryInvocationHandler.java index 74ea4655b..2429a0279 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexFactoryInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexFactoryInvocationHandler.java @@ -45,6 +45,7 @@ class ComplexFactoryInvocationHandler extends AbstractInvocationHandler implemen static ComplexFactoryInvocationHandler getInstance( final EntityInvocationHandler entityHandler, final AbstractStructuredInvocationHandler targetHandler) { + return new ComplexFactoryInvocationHandler( entityHandler == null ? null : entityHandler.containerHandler.client, targetHandler == null diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java index e3743fe88..a207e68a8 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ComplexInvocationHandler.java @@ -131,13 +131,21 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle } @Override - @SuppressWarnings("unchecked") protected void setPropertyValue(final Property property, final Object value) { final FullQualifiedName fqn = new FullQualifiedName(ClassUtils.getNamespace(typeRef), typeRef.getAnnotation(ComplexType.class).name()); final EdmElement edmProperty = client.getCachedEdm().getComplexType(fqn).getProperty(property.name()); + final EdmTypeInfo type = new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()).setTypeExpression( + edmProperty.isCollection() ? "Collection(" + property.type() + ")" : property.type()).build(); + + setPropertyValue(property.name(), type, value); + } + + @SuppressWarnings("unchecked") + private void setPropertyValue(final String name, final EdmTypeInfo type, final Object value) { + final Object toBeAdded; if (value == null) { @@ -145,7 +153,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle } else if (Collection.class.isAssignableFrom(value.getClass())) { toBeAdded = new ArrayList(); for (Object obj : (Collection) value) { - ((Collection) toBeAdded).add(obj instanceof Proxy ? Proxy.getInvocationHandler(obj) : obj); + Collection.class.cast(toBeAdded).add(obj instanceof Proxy ? Proxy.getInvocationHandler(obj) : obj); } } else if (value instanceof Proxy) { toBeAdded = Proxy.getInvocationHandler(value); @@ -153,10 +161,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle toBeAdded = value; } - final EdmTypeInfo type = new EdmTypeInfo.Builder().setEdm(client.getCachedEdm()).setTypeExpression( - edmProperty.isCollection() ? "Collection(" + property.type() + ")" : property.type()).build(); - - client.getBinder().add(getComplex(), CoreUtils.getODataProperty(client, property.name(), type, toBeAdded)); + client.getBinder().add(getComplex(), CoreUtils.getODataProperty(client, name, type, toBeAdded)); if (getEntityHandler() != null && !entityContext.isAttached(getEntityHandler())) { entityContext.attach(getEntityHandler(), AttachedEntityStatus.CHANGED); @@ -173,13 +178,18 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle } @Override - protected void addPropertyChanges(final String name, final Object value) { - // do nothing .... + public void addAdditionalProperty(final String name, final Object value) { + setPropertyValue(name, null, value); + attach(AttachedEntityStatus.CHANGED); } @Override - protected void removePropertyChanges(final String name) { - // do nothing .... + public void removeAdditionalProperty(final String name) { + final CommonODataProperty property = getComplex().get(name); + if(property !=null && !property.hasNullValue()){ + setPropertyValue(name, null, null); + attach(AttachedEntityStatus.CHANGED); + } } @Override diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java index a5aa6b318..1a6e6d9fa 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ContainerImpl.java @@ -34,7 +34,7 @@ import org.apache.olingo.client.api.CommonEdmEnabledODataClient; import org.apache.olingo.client.api.communication.header.ODataPreferences; import org.apache.olingo.client.api.communication.request.ODataRequest; import org.apache.olingo.client.api.communication.request.ODataStreamedRequest; -import org.apache.olingo.client.api.communication.request.batch.BatchStreamManager; +import org.apache.olingo.client.api.communication.request.batch.BatchManager; import org.apache.olingo.client.api.communication.request.batch.CommonODataBatchRequest; import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem; import org.apache.olingo.client.api.communication.request.batch.ODataChangeset; @@ -90,7 +90,7 @@ class ContainerImpl implements Container { final CommonODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(client.getServiceRoot()); ((ODataRequest) request).setAccept(client.getConfiguration().getDefaultBatchAcceptFormat()); - final BatchStreamManager streamManager = (BatchStreamManager) ((ODataStreamedRequest) request).execute(); + final BatchManager streamManager = (BatchManager) ((ODataStreamedRequest) request).payloadManager(); final ODataChangeset changeset = streamManager.addChangeset(); @@ -113,8 +113,9 @@ class ContainerImpl implements Container { final ODataBatchResponse response = streamManager.getResponse(); - if ((client.getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0 && response.getStatusCode() != 202) - || (client.getServiceVersion().compareTo(ODataServiceVersion.V30) > 0 && response.getStatusCode() != 200)) { + // This should be 202 for service version <= 3.0 and 200 for service version >= 4.0 but it seems that + // many service implementations are not fully compliant with this respect. + if (response.getStatusCode() != 202 && response.getStatusCode() != 200) { throw new IllegalStateException("Operation failed"); } @@ -200,7 +201,7 @@ class ContainerImpl implements Container { LOG.debug("Update media entity '{}'", uri); final ODataMediaEntityUpdateRequest req = - client.getStreamedRequestFactory().getMediaEntityUpdateRequest(uri, input); + client.getCUDRequestFactory().getMediaEntityUpdateRequest(uri, input); req.setContentType(StringUtils.isBlank(handler.getEntity().getMediaContentType()) ? ODataMediaFormat.WILDCARD.toString() @@ -221,7 +222,7 @@ class ContainerImpl implements Container { LOG.debug("Update media entity '{}'", uri); - final ODataStreamUpdateRequest req = client.getStreamedRequestFactory().getStreamUpdateRequest(uri, input); + final ODataStreamUpdateRequest req = client.getCUDRequestFactory().getStreamUpdateRequest(uri, input); if (StringUtils.isNotBlank(handler.getETag())) { req.setIfMatch(handler.getETag()); @@ -321,6 +322,11 @@ class ContainerImpl implements Container { if (entity instanceof ODataEntity) { ((ODataEntity) entity).getAnnotations().clear(); CoreUtils.addAnnotations(client, handler.getAnnotations(), (ODataEntity) entity); + + for (Map.Entry entry : handler.getPropAnnotatableHandlers().entrySet()) { + CoreUtils.addAnnotations(client, + entry.getValue().getAnnotations(), ((ODataEntity) entity).getProperty(entry.getKey())); + } } } @@ -376,6 +382,16 @@ class ContainerImpl implements Container { } } + if (entity instanceof ODataEntity) { + for (Map.Entry entry + : handler.getNavPropAnnotatableHandlers().entrySet()) { + + CoreUtils.addAnnotations(client, + entry.getValue().getAnnotations(), + (org.apache.olingo.commons.api.domain.v4.ODataLink) entity.getNavigationLink(entry.getKey())); + } + } + // insert into the batch LOG.debug("{}: Insert '{}' into the batch", pos, handler); final AttachedEntityStatus processedStatus = batch(handler, entity, changeset); diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java index 529c5eb61..2d9065a22 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityInvocationHandler.java @@ -44,6 +44,7 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntity; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.format.ODataMediaFormat; import org.apache.olingo.ext.proxy.api.AbstractTerm; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; @@ -53,7 +54,7 @@ import org.apache.olingo.ext.proxy.context.AttachedEntityStatus; import org.apache.olingo.ext.proxy.context.EntityUUID; import org.apache.olingo.ext.proxy.utils.CoreUtils; -public class EntityInvocationHandler extends AbstractStructuredInvocationHandler { +public class EntityInvocationHandler extends AbstractStructuredInvocationHandler implements Annotatable { private static final long serialVersionUID = 2629912294765040037L; @@ -180,6 +181,12 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler return propertyChanges; } + @Override + public void addAdditionalProperty(final String name, final Object value) { + propertyChanges.put(name, value); + attach(AttachedEntityStatus.CHANGED); + } + public Map getLinkChanges() { return linkChanges; } @@ -257,7 +264,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler if (EdmPrimitiveTypeKind.Stream.getFullQualifiedName().toString().equalsIgnoreCase(property.type())) { setStreamedProperty(property, (InputStream) value); } else { - addPropertyChanges(property.name(), value); + propertyChanges.put(property.name(), value); if (value != null) { Collection coll; @@ -316,7 +323,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler final String contentType = StringUtils.isBlank(getEntity().getMediaContentType()) ? "*/*" : getEntity().getMediaContentType(); - final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(contentSource); + final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(contentSource); retrieveReq.setFormat(ODataMediaFormat.fromFormat(contentType)); this.stream = retrieveReq.execute().getBody(); @@ -326,7 +333,6 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler } public Object getStreamedProperty(final String name) { - InputStream res = streamedPropertyChanges.get(name); try { @@ -374,13 +380,9 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler } @Override - protected void addPropertyChanges(final String name, final Object value) { - propertyChanges.put(name, value); - } - - @Override - protected void removePropertyChanges(final String name) { + public void removeAdditionalProperty(final String name) { propertyChanges.remove(name); + attach(AttachedEntityStatus.CHANGED); } protected void cacheProperty(final String name, final Object value) { @@ -400,6 +402,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler updateLinksTag(checkpoint); } + @Override public void addAnnotation(final Class term, final Object value) { this.annotations.put(term, value); @@ -425,10 +428,13 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler attach(AttachedEntityStatus.CHANGED); } + @Override public void removeAnnotation(final Class term) { this.annotations.remove(term); + attach(AttachedEntityStatus.CHANGED); } + @Override public Object getAnnotation(final Class term) { Object res = null; @@ -458,6 +464,7 @@ public class EntityInvocationHandler extends AbstractStructuredInvocationHandler return res; } + @Override public Collection> getAnnotationTerms() { return getEntity() instanceof ODataEntity ? CoreUtils.getAnnotationTerms(((ODataEntity) getEntity()).getAnnotations()) diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java index 4f4e45ab8..7aa8c22d5 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntitySetInvocationHandler.java @@ -90,8 +90,7 @@ class EntitySetInvocationHandler< static EntitySetInvocationHandler getInstance( final Class ref, final EntityContainerInvocationHandler containerHandler, final String entitySetName) { - final CommonURIBuilder uriBuilder = containerHandler.getClient(). - getURIBuilder(containerHandler.getFactory().getServiceRoot()); + final CommonURIBuilder uriBuilder = containerHandler.getClient().newURIBuilder(); final StringBuilder entitySetSegment = new StringBuilder(); if (!containerHandler.isDefaultEntityContainer()) { @@ -184,7 +183,7 @@ class EntitySetInvocationHandler< @Override public Long count() { final ODataValueRequest req = client.getRetrieveRequestFactory(). - getValueRequest(client.getURIBuilder(this.uri.toASCIIString()).count().build()); + getValueRequest(client.newURIBuilder(this.uri.toASCIIString()).count().build()); req.setFormat(ODataValueFormat.TEXT); return Long.valueOf(req.execute().getBody().asPrimitive().toString()); } @@ -247,7 +246,7 @@ class EntitySetInvocationHandler< // not yet attached: search against the service try { LOG.debug("Search for '{}({})' into the service", typeRef.getSimpleName(), key); - final CommonURIBuilder uriBuilder = client.getURIBuilder(this.uri.toASCIIString()); + final CommonURIBuilder uriBuilder = client.newURIBuilder(this.uri.toASCIIString()); if (key.getClass().getAnnotation(CompoundKey.class) == null) { LOG.debug("Append key segment '{}'", key); @@ -376,7 +375,7 @@ class EntitySetInvocationHandler< final Class ref = (Class) ClassUtils.extractTypeArg(collTypeRef); final Class oref = (Class) ClassUtils.extractTypeArg(this.collTypeRef); - final CommonURIBuilder uriBuilder = client.getURIBuilder(this.uri.toASCIIString()); + final CommonURIBuilder uriBuilder = client.newURIBuilder(this.uri.toASCIIString()); final URI entitySetURI; if (oref.equals(ref)) { @@ -463,6 +462,6 @@ class EntitySetInvocationHandler< @Override public EntitySetIterator iterator() { - return new EntitySetIterator(client.getURIBuilder(this.uri.toASCIIString()).build(), this); + return new EntitySetIterator(client.newURIBuilder(this.uri.toASCIIString()).build(), this); } } diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FilterImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FilterImpl.java index 4299ddeaf..42ce64611 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FilterImpl.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/FilterImpl.java @@ -150,7 +150,7 @@ public class FilterImpl uriBuilder = client.getURIBuilder(this.baseURI.toASCIIString()). + final CommonURIBuilder uriBuilder = client.newURIBuilder(this.baseURI.toASCIIString()). appendDerivedEntityTypeSegment(new FullQualifiedName( ClassUtils.getNamespace(typeRef), ClassUtils.getEntityTypeName(typeRef)).toString()); diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java index 69e1f9baf..d28a319d9 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java @@ -28,7 +28,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.apache.olingo.client.api.uri.CommonURIBuilder; -import org.apache.olingo.client.core.uri.URIUtils; import org.apache.olingo.commons.api.domain.CommonODataEntity; import org.apache.olingo.commons.api.domain.ODataOperation; import org.apache.olingo.commons.api.edm.EdmEntityContainer; @@ -41,7 +40,7 @@ import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; import org.apache.olingo.ext.proxy.utils.ClassUtils; -class OperationInvocationHandler extends AbstractInvocationHandler implements OperationExecutor { +final class OperationInvocationHandler extends AbstractInvocationHandler implements OperationExecutor { private static final long serialVersionUID = 2629912294765040027L; @@ -154,8 +153,8 @@ class OperationInvocationHandler extends AbstractInvocationHandler implements Op edmOperation = container.getActionImport(operation.name()).getUnboundAction(); } - final CommonURIBuilder uriBuilder = getClient().getURIBuilder(this.serviceRoot). - appendOperationCallSegment(URIUtils.operationImportURISegment(container, edmOperation.getName())); + final CommonURIBuilder uriBuilder = getClient().newURIBuilder(this.serviceRoot). + appendOperationCallSegment(edmOperation.getName()); return new AbstractMap.SimpleEntry(uriBuilder.build(), edmOperation); } diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SearchImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SearchImpl.java index 73a058502..fb65c6eac 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SearchImpl.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/SearchImpl.java @@ -75,7 +75,7 @@ public class SearchImpl { * @return true if is attached; false otherwise. */ public boolean isAttached(final EntityInvocationHandler entity) { - return allAttachedEntities.containsKey(entity) + return entity == null // avoid attach for null entities (coming from complexes created from container ...) + || allAttachedEntities.containsKey(entity) || (entity.getUUID().getKey() != null && searchableEntities.containsKey(entity.getUUID())); } diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java index 5fbdc69ef..b32e80ee4 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/utils/CoreUtils.java @@ -43,6 +43,7 @@ import org.apache.olingo.commons.api.domain.CommonODataProperty; import org.apache.olingo.commons.api.domain.ODataLink; import org.apache.olingo.commons.api.domain.ODataPrimitiveValue; import org.apache.olingo.commons.api.domain.ODataValue; +import org.apache.olingo.commons.api.domain.v4.ODataAnnotatable; import org.apache.olingo.commons.api.domain.v4.ODataAnnotation; import org.apache.olingo.commons.api.domain.v4.ODataEntity; import org.apache.olingo.commons.api.domain.v4.ODataEnumValue; @@ -312,7 +313,7 @@ public final class CoreUtils { public static void addAnnotations( final CommonEdmEnabledODataClient client, final Map, Object> annotations, - final ODataEntity entity) { + final ODataAnnotatable annotatable) { for (Map.Entry, Object> entry : annotations.entrySet()) { final Namespace nsAnn = entry.getKey().getAnnotation(Namespace.class); @@ -322,7 +323,7 @@ public final class CoreUtils { if (term == null) { LOG.error("Could not find term for class {}", entry.getKey().getName()); } else { - entity.getAnnotations().add(getODataAnnotation( + annotatable.getAnnotations().add(getODataAnnotation( client, term.getFullQualifiedName().toString(), term.getType(), entry.getValue())); } } diff --git a/ext/pojogen-maven-plugin/src/main/resources/complexType.vm b/ext/pojogen-maven-plugin/src/main/resources/complexType.vm index ba03282bc..d7acbffb2 100644 --- a/ext/pojogen-maven-plugin/src/main/resources/complexType.vm +++ b/ext/pojogen-maven-plugin/src/main/resources/complexType.vm @@ -18,10 +18,14 @@ *# package ${package}; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.ComplexType; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; +import org.apache.olingo.ext.proxy.api.AbstractOpenType; +import org.apache.olingo.ext.proxy.api.Annotatable; #foreach($ns in $namespaces) import ${basePackage}.${ns}.*; import ${basePackage}.${ns}.types.*; diff --git a/ext/pojogen-maven-plugin/src/main/resources/entityType.vm b/ext/pojogen-maven-plugin/src/main/resources/entityType.vm index e66f936b4..5c54e5f1e 100644 --- a/ext/pojogen-maven-plugin/src/main/resources/entityType.vm +++ b/ext/pojogen-maven-plugin/src/main/resources/entityType.vm @@ -20,6 +20,8 @@ package ${package}; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -28,7 +30,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -63,7 +65,7 @@ import javax.xml.datatype.Duration; isAbstract = $entityType.Abstract#if($entityType.getBaseType()), baseType = "$entityType.getBaseType().getFullQualifiedName().toString()"#end) public interface $utility.capitalize($entityType.Name) - extends AbstractAnnotatable,#if( $entityType.getBaseType() )$utility.getJavaType($entityType.getBaseType())#{elseif}( $entityType.isOpenType() )AbstractOpenType#{else}Serializable#end { + extends Annotatable,#if( $entityType.getBaseType() )$utility.getJavaType($entityType.getBaseType())#{elseif}( $entityType.isOpenType() )AbstractOpenType#{else}Serializable#end { #set( $keys = [] ) #foreach($key in $entityType.KeyPropertyRefs) @@ -198,5 +200,31 @@ public interface $utility.capitalize($entityType.Name) #end } -#end +#end + + #if( $entityType.baseType ) + @Override + #end + Annotations annotations(); + + interface Annotations #if( $entityType.baseType ) + extends ${utility.getJavaType($entityType.getBaseType())}.Annotations#end{ + + #foreach($propertyName in $entityType.PropertyNames) + #set($property = $entityType.getProperty($propertyName)) + @AnnotationsForProperty(name = "$property.Name", + type = "$property.Type.FullQualifiedName.toString()") + Annotatable get$utility.capitalize($property.Name)Annotations(); + + #end + + #foreach($propertyName in $entityType.NavigationPropertyNames) + #set($property = $entityType.getNavigationProperty($propertyName)) + #set($type = $utility.getNavigationType($property)) + + @AnnotationsForNavigationProperty(name = "$property.Name", + type = "$type") + Annotatable get$utility.capitalize($property.Name)Annotations(); + #end + } } diff --git a/ext/pojogen-maven-plugin/src/main/resources/v40/complexType.vm b/ext/pojogen-maven-plugin/src/main/resources/v40/complexType.vm index b76717ff4..caba995df 100644 --- a/ext/pojogen-maven-plugin/src/main/resources/v40/complexType.vm +++ b/ext/pojogen-maven-plugin/src/main/resources/v40/complexType.vm @@ -22,7 +22,7 @@ isAbstract = $complexType.Abstract#if($complexType.getBaseType()), baseType = "$complexType.getBaseType().getFullQualifiedName().toString()"#end) public interface $utility.capitalize($complexType.Name) - extends #if($complexType.getBaseType())$utility.getJavaType($complexType.getBaseType().getFullQualifiedName().toString())#{else}Serializable#end { + extends #if($complexType.getBaseType())$utility.getJavaType($complexType.getBaseType().getFullQualifiedName().toString()),#{end}#if( $complexType.isOpenType() )AbstractOpenType,#{end}Serializable { #set( $complexProps = [] ) #foreach($propertyName in $complexType.PropertyNames) @@ -81,3 +81,29 @@ public interface $utility.capitalize($complexType.Name) #end } #end + + #if( $complexType.baseType ) + @Override + #end + Annotations annotations(); + + interface Annotations #if( $complexType.baseType ) + extends ${utility.getJavaType($complexType.getBaseType())}.Annotations#end{ + + #foreach($propertyName in $complexType.PropertyNames) + #set($property = $complexType.getProperty($propertyName)) + @AnnotationsForProperty(name = "$property.Name", + type = "$property.Type.FullQualifiedName.toString()") + Annotatable get$utility.capitalize($property.Name)Annotations(); + + #end + + #foreach($propertyName in $complexType.NavigationPropertyNames) + #set($property = $complexType.getNavigationProperty($propertyName)) + #set($type = $utility.getNavigationType($property)) + + @AnnotationsForNavigationProperty(name = "$property.Name", + type = "$type") + Annotatable get$utility.capitalize($property.Name)Annotations(); + #end + } diff --git a/ext/pom.xml b/ext/pom.xml index c2667ae07..991a936a4 100644 --- a/ext/pom.xml +++ b/ext/pom.xml @@ -39,5 +39,6 @@ client-core-android pojogen-maven-plugin client-proxy + client-proxy-android diff --git a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java index 4ccea548b..e8c0be585 100644 --- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java +++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java @@ -188,7 +188,7 @@ public abstract class AbstractServices { protected Response getMetadata(final String filename) { try { - return xml.createResponse(null, FSManager.instance(version).readFile(filename, Accept.XML), null, Accept.XML); + return xml.createResponse(null, FSManager.instance(version).readRes(filename, Accept.XML), null, Accept.XML); } catch (Exception e) { return xml.createFaultResponse(Accept.XML.toString(version), e); } @@ -1306,10 +1306,9 @@ public abstract class AbstractServices { @PathParam("entityId") String entityId) { try { - final String basePath = - entitySetName + File.separatorChar + Commons.getEntityKey(entityId) + File.separatorChar; + final String basePath = entitySetName + File.separatorChar + Commons.getEntityKey(entityId); - FSManager.instance(version).deleteFile(basePath + Constants.get(version, ConstantKey.ENTITY)); + FSManager.instance(version).deleteEntity(basePath); return xml.createResponse(null, null, null, null, Response.Status.NO_CONTENT); } catch (Exception e) { diff --git a/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java b/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java index 79a8d0301..a457efb4e 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java +++ b/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java @@ -51,7 +51,7 @@ import org.springframework.stereotype.Service; public class V3ActionOverloading extends V3Services { public V3ActionOverloading() throws Exception { - super(new Metadata(FSManager.instance(ODataServiceVersion.V30).readFile( + super(new Metadata(FSManager.instance(ODataServiceVersion.V30).readRes( "actionOverloading" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V30, ConstantKey.METADATA)), Accept.XML), ODataServiceVersion.V30)); } diff --git a/fit/src/main/java/org/apache/olingo/fit/V3OpenType.java b/fit/src/main/java/org/apache/olingo/fit/V3OpenType.java index c112b9976..23d644b37 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V3OpenType.java +++ b/fit/src/main/java/org/apache/olingo/fit/V3OpenType.java @@ -55,7 +55,7 @@ public class V3OpenType extends V3Services { public V3OpenType() throws Exception { super(new Metadata(FSManager.instance(ODataServiceVersion.V30). - readFile("openType" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V30, ConstantKey.METADATA)), + readRes("openType" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V30, ConstantKey.METADATA)), Accept.XML), ODataServiceVersion.V30)); } diff --git a/fit/src/main/java/org/apache/olingo/fit/V3PrimitiveKeys.java b/fit/src/main/java/org/apache/olingo/fit/V3PrimitiveKeys.java index 3b159af58..d235bc08a 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V3PrimitiveKeys.java +++ b/fit/src/main/java/org/apache/olingo/fit/V3PrimitiveKeys.java @@ -47,7 +47,7 @@ public class V3PrimitiveKeys extends V3Services { public Response getMetadata() { try { return xml.createResponse( - null, FSManager.instance(version).readFile("primitiveKeysMetadata", Accept.XML), null, Accept.XML); + null, FSManager.instance(version).readRes("primitiveKeysMetadata", Accept.XML), null, Accept.XML); } catch (Exception e) { return xml.createFaultResponse(Accept.XML.toString(version), e); } diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Demo.java b/fit/src/main/java/org/apache/olingo/fit/V4Demo.java index 89449624c..c308a0823 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V4Demo.java +++ b/fit/src/main/java/org/apache/olingo/fit/V4Demo.java @@ -52,7 +52,7 @@ public class V4Demo extends V4Services { public V4Demo() throws Exception { super(new Metadata(FSManager.instance(ODataServiceVersion.V40). - readFile("demo" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA)), + readRes("demo" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA)), Accept.XML), ODataServiceVersion.V40)); } diff --git a/fit/src/main/java/org/apache/olingo/fit/V4OpenType.java b/fit/src/main/java/org/apache/olingo/fit/V4OpenType.java index fd290392a..b76293af0 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V4OpenType.java +++ b/fit/src/main/java/org/apache/olingo/fit/V4OpenType.java @@ -51,7 +51,7 @@ public class V4OpenType extends V4Services { public V4OpenType() throws Exception { super(new Metadata(FSManager.instance(ODataServiceVersion.V40). - readFile("openType" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA)), + readRes("openType" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA)), Accept.XML), ODataServiceVersion.V40)); } diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Services.java b/fit/src/main/java/org/apache/olingo/fit/V4Services.java index 9487d1e96..db88da0fa 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V4Services.java +++ b/fit/src/main/java/org/apache/olingo/fit/V4Services.java @@ -293,7 +293,7 @@ public class V4Services extends AbstractServices { addChangesetItemIntro(chbos, lastContebtID, cboundary); res = bodyPartRequest(new MimeBodyPart(part.getInputStream()), references); - if (res==null || res.getStatus() >= 400) { + if (res == null || res.getStatus() >= 400) { throw new Exception("Failure processing changeset"); } @@ -457,7 +457,7 @@ public class V4Services extends AbstractServices { } @GET - @Path("/Company/Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount") + @Path("/Company/Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount{paren:[\\(\\)]*}") public Response functionGetEmployeesCount( @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept, @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) { @@ -488,7 +488,7 @@ public class V4Services extends AbstractServices { } @POST - @Path("/Company/Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue") + @Path("/Company/Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue{paren:[\\(\\)]*}") public Response actionIncreaseRevenue( @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept, @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType, @@ -562,7 +562,7 @@ public class V4Services extends AbstractServices { } @POST - @Path("/Products({entityId})/Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight") + @Path("/Products({entityId})/Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight{paren:[\\(\\)]*}") public Response actionAddAccessRight( @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept, @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType, @@ -583,11 +583,16 @@ public class V4Services extends AbstractServices { assert 1 == entry.getProperties().size(); assert entry.getProperty("accessRight") != null; - entry.getProperty("accessRight").setType("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel"); + final Property property = entry.getProperty("accessRight"); + property.setType("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel"); + + final ResWrap result = new ResWrap( + URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + property.getType()), + null, (AtomPropertyImpl) property); return xml.createResponse( null, - xml.writeProperty(acceptType, entry.getProperty("accessRight")), + xml.writeProperty(acceptType, result), null, acceptType); } catch (Exception e) { @@ -596,7 +601,7 @@ public class V4Services extends AbstractServices { } @POST - @Path("/Customers(PersonID={personId})/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress") + @Path("/Customers(PersonID={personId})/Microsoft.Test.OData.Services.ODataWCFService.ResetAddress{paren:[\\(\\)]*}") public Response actionResetAddress( @Context UriInfo uriInfo, @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept, @@ -622,7 +627,7 @@ public class V4Services extends AbstractServices { @GET @Path("/ProductDetails(ProductID={productId},ProductDetailID={productDetailId})" - + "/Microsoft.Test.OData.Services.ODataWCFService.GetRelatedProduct") + + "/Microsoft.Test.OData.Services.ODataWCFService.GetRelatedProduct{paren:[\\(\\)]*}") public Response functionGetRelatedProduct( @Context UriInfo uriInfo, @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept, @@ -634,11 +639,12 @@ public class V4Services extends AbstractServices { } @POST - @Path("/Accounts(101)/Microsoft.Test.OData.Services.ODataWCFService.RefreshDefaultPI") + @Path("/Accounts({entityId})/Microsoft.Test.OData.Services.ODataWCFService.RefreshDefaultPI{paren:[\\(\\)]*}") public Response actionRefreshDefaultPI( @Context UriInfo uriInfo, @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept, @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType, + @PathParam("entityId") String entityId, @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format, final String param) { @@ -649,23 +655,24 @@ public class V4Services extends AbstractServices { assert 1 == entry.getProperties().size(); assert entry.getProperty("newDate") != null; - return functionGetDefaultPI(accept, format); + return functionGetDefaultPI(accept, entityId, format); } catch (Exception e) { return xml.createFaultResponse(accept, e); } } @GET - @Path("/Accounts(101)/Microsoft.Test.OData.Services.ODataWCFService.GetDefaultPI") + @Path("/Accounts({entityId})/Microsoft.Test.OData.Services.ODataWCFService.GetDefaultPI{paren:[\\(\\)]*}") public Response functionGetDefaultPI( @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept, + @PathParam("entityId") String entityId, @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format) { - return getContainedEntity(accept, "101", "MyPaymentInstruments", "101901", format); + return getContainedEntity(accept, entityId, "MyPaymentInstruments", entityId+ "901", format); } @GET - @Path("/Accounts({entityId})/Microsoft.Test.OData.Services.ODataWCFService.GetAccountInfo") + @Path("/Accounts({entityId})/Microsoft.Test.OData.Services.ODataWCFService.GetAccountInfo{paren:[\\(\\)]*}") public Response functionGetAccountInfo( @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept, @PathParam("entityId") String entityId, @@ -1317,4 +1324,26 @@ public class V4Services extends AbstractServices { return xml.createFaultResponse(accept, e); } } + + @POST + @Path("/Products({productId})/Categories/$ref") + public Response createLinked( + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept, + @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format, + final String entity) { + + return xml.createResponse(null, null, null, Status.NO_CONTENT); + } + + @DELETE + @Path("/Products({productId})/Categories({categoryId})/$ref") + public Response deleteLinked( + @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) String accept, + @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) String contentType, + @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) String format, + final String entity) { + + return xml.createResponse(null, null, null, Status.NO_CONTENT); + } } diff --git a/fit/src/main/java/org/apache/olingo/fit/V4Vocabularies.java b/fit/src/main/java/org/apache/olingo/fit/V4Vocabularies.java index 8271e53d8..5d64457db 100644 --- a/fit/src/main/java/org/apache/olingo/fit/V4Vocabularies.java +++ b/fit/src/main/java/org/apache/olingo/fit/V4Vocabularies.java @@ -42,7 +42,7 @@ public class V4Vocabularies { private final XMLUtilities xml; public V4Vocabularies() throws Exception { - this.metadata = new Metadata(FSManager.instance(ODataServiceVersion.V40).readFile( + this.metadata = new Metadata(FSManager.instance(ODataServiceVersion.V40).readRes( "vocabularies-" + Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA), Accept.XML), ODataServiceVersion.V40); this.xml = new XMLUtilities(ODataServiceVersion.V40, metadata); @@ -55,7 +55,7 @@ public class V4Vocabularies { try { return xml.createResponse( null, - FSManager.instance(ODataServiceVersion.V40).readFile( + FSManager.instance(ODataServiceVersion.V40).readRes( "vocabularies-" + Constants.get(ODataServiceVersion.V40, ConstantKey.METADATA), Accept.XML), null, Accept.XML); diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/DataBinder.java b/fit/src/main/java/org/apache/olingo/fit/utils/DataBinder.java index f79b221a3..4dbd725ae 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/DataBinder.java +++ b/fit/src/main/java/org/apache/olingo/fit/utils/DataBinder.java @@ -89,6 +89,7 @@ public class DataBinder { public JSONEntityImpl toJSONEntity(final AtomEntityImpl atomEntity) { final JSONEntityImpl jsonEntity = new JSONEntityImpl(); + jsonEntity.getAnnotations().addAll(atomEntity.getAnnotations()); BeanUtils.copyProperties(atomEntity, jsonEntity, "baseURI", "properties", "links"); // This shouldn't ever happen, but... @@ -126,6 +127,7 @@ public class DataBinder { jlink.setTitle(link.getTitle()); jlink.setType(link.getType()); jlink.setRel(link.getRel()); + jlink.getAnnotations().addAll(link.getAnnotations()); if (link.getInlineEntity() instanceof AtomEntityImpl) { final Entity inlineEntity = link.getInlineEntity(); @@ -184,6 +186,7 @@ public class DataBinder { final Link alink = new LinkImpl(); alink.setHref(link.getHref()); alink.setTitle(link.getTitle()); + alink.getAnnotations().addAll(link.getAnnotations()); final NavigationProperty navPropDetails = metadata.getEntityOrComplexType(jsonEntity.getType()).getNavigationProperty(link.getTitle()); @@ -218,6 +221,7 @@ public class DataBinder { if (navProperties.containsKey(property.getName())) { final Link alink = new LinkImpl(); alink.setTitle(property.getName()); + alink.getAnnotations().addAll(property.getAnnotations()); alink.setType(navProperties.get(property.getName()).isEntitySet() ? Constants.get(version, ConstantKey.ATOM_LINK_FEED) @@ -256,22 +260,23 @@ public class DataBinder { return atomEntity; } - public JSONPropertyImpl toJSONProperty(final AtomPropertyImpl atomproperty) { - final JSONPropertyImpl jsonproperty = new JSONPropertyImpl(); - BeanUtils.copyProperties(atomproperty, jsonproperty, "value"); + public JSONPropertyImpl toJSONProperty(final AtomPropertyImpl atomProperty) { + final JSONPropertyImpl jsonProperty = new JSONPropertyImpl(); + BeanUtils.copyProperties(atomProperty, jsonProperty, "value"); + jsonProperty.getAnnotations().addAll(atomProperty.getAnnotations()); - if (atomproperty.getValue().isComplex()) { + if (atomProperty.getValue().isComplex()) { final ComplexValueImpl complex = new ComplexValueImpl(); - jsonproperty.setValue(complex); + jsonProperty.setValue(complex); - for (Property field : atomproperty.getValue().asComplex().get()) { + for (Property field : atomProperty.getValue().asComplex().get()) { complex.get().add(toJSONProperty((AtomPropertyImpl) field)); } - } else if (atomproperty.getValue().isCollection()) { + } else if (atomProperty.getValue().isCollection()) { final CollectionValueImpl collection = new CollectionValueImpl(); - jsonproperty.setValue(collection); + jsonProperty.setValue(collection); - for (Value element : atomproperty.getValue().asCollection().get()) { + for (Value element : atomProperty.getValue().asCollection().get()) { if (element.isComplex()) { final ComplexValueImpl complex = new ComplexValueImpl(); collection.get().add(complex); @@ -284,15 +289,16 @@ public class DataBinder { } } } else { - jsonproperty.setValue(atomproperty.getValue()); + jsonProperty.setValue(atomProperty.getValue()); } - return jsonproperty; + return jsonProperty; } public AtomPropertyImpl toAtomProperty(final JSONPropertyImpl jsonProperty, final String entryType) { - final AtomPropertyImpl atomproperty = new AtomPropertyImpl(); - atomproperty.setName(jsonProperty.getName()); + final AtomPropertyImpl atomProperty = new AtomPropertyImpl(); + atomProperty.setName(jsonProperty.getName()); + atomProperty.getAnnotations().addAll(jsonProperty.getAnnotations()); final EntityType entityType = entryType == null ? null @@ -304,21 +310,21 @@ public class DataBinder { || jsonProperty.getName() == null || !jsonProperty.getType().startsWith(EdmPrimitiveType.EDM_NAMESPACE))) { - atomproperty.setType(jsonProperty.getType()); + atomProperty.setType(jsonProperty.getType()); } else if (entityType != null) { - atomproperty.setType(entityType.getProperty(jsonProperty.getName()).getType()); + atomProperty.setType(entityType.getProperty(jsonProperty.getName()).getType()); } if (jsonProperty.getValue().isComplex()) { final ComplexValueImpl complex = new ComplexValueImpl(); - atomproperty.setValue(complex); + atomProperty.setValue(complex); for (Property field : jsonProperty.getValue().asComplex().get()) { - complex.get().add(toAtomProperty((JSONPropertyImpl) field, atomproperty.getType())); + complex.get().add(toAtomProperty((JSONPropertyImpl) field, atomProperty.getType())); } } else if (jsonProperty.getValue().isCollection()) { final CollectionValueImpl collection = new CollectionValueImpl(); - atomproperty.setValue(collection); + atomProperty.setValue(collection); for (Value element : jsonProperty.getValue().asCollection().get()) { if (element instanceof ComplexValueImpl) { @@ -326,16 +332,16 @@ public class DataBinder { collection.get().add(complex); for (Property field : element.asComplex().get()) { - complex.get().add(toAtomProperty((JSONPropertyImpl) field, atomproperty.getType())); + complex.get().add(toAtomProperty((JSONPropertyImpl) field, atomProperty.getType())); } } else { collection.get().add(element); } } } else { - atomproperty.setValue(jsonProperty.getValue()); + atomProperty.setValue(jsonProperty.getValue()); } - return atomproperty; + return atomProperty; } } diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java b/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java index 2599b8fe2..e529b45d1 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java +++ b/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java @@ -35,6 +35,7 @@ import org.apache.commons.vfs2.FileSelectInfo; import org.apache.commons.vfs2.FileSelector; import org.apache.commons.vfs2.FileSystemException; import org.apache.commons.vfs2.FileSystemManager; +import org.apache.commons.vfs2.FileType; import org.apache.commons.vfs2.VFS; import org.apache.olingo.commons.api.data.ResWrap; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; @@ -72,6 +73,18 @@ public class FSManager { private FSManager(final ODataServiceVersion version) throws Exception { this.version = version; fsManager = VFS.getManager(); + + final FileObject basePath = fsManager.resolveFile(RES_PREFIX + File.separatorChar + version.name()); + final String absoluteBaseFolder = basePath.getURL().getPath(); + + for (FileObject fo : find(basePath, null)) { + if (fo.getType() == FileType.FILE + && !fo.getName().getBaseName().contains("Metadata") + && !fo.getName().getBaseName().contains("metadata")) { + final String path = fo.getURL().getPath().replace(absoluteBaseFolder, "//" + version.name()); + putInMemory(fo.getContent().getInputStream(), path); + } + } } public String getAbsolutePath(final String relativePath, final Accept accept) { @@ -79,7 +92,7 @@ public class FSManager { + (accept == null ? "" : accept.getExtension()); } - public FileObject putInMemory(final InputStream is, final String path) throws IOException { + public final FileObject putInMemory(final InputStream is, final String path) throws IOException { LOG.info("Write in memory {}", path); final FileObject memObject = fsManager.resolveFile(MEM_PREFIX + path); @@ -116,9 +129,9 @@ public class FSManager { final ObjectMapper mapper = Commons.getJSONMapper(version); mapper.writeValue( writer, new JSONEntryContainer( - container.getContextURL(), - container.getMetadataETag(), - dataBinder.toJSONEntity(container.getPayload()))); + container.getContextURL(), + container.getMetadataETag(), + dataBinder.toJSONEntity(container.getPayload()))); putInMemory(new ByteArrayInputStream(content.toByteArray()), getAbsolutePath(relativePath, Accept.JSON_FULLMETA)); } catch (Exception e) { @@ -126,29 +139,27 @@ public class FSManager { } } - public InputStream readFile(final String relativePath) { - return readFile(relativePath, null); + public InputStream readRes(final String relativePath, final Accept accept) { + return readFile(relativePath, accept, RES_PREFIX); } public InputStream readFile(final String relativePath, final Accept accept) { + return readFile(relativePath, accept, MEM_PREFIX); + } + + public InputStream readFile(final String relativePath) { + return readFile(relativePath, null, MEM_PREFIX); + } + + private InputStream readFile(final String relativePath, final Accept accept, final String fs) { final String path = getAbsolutePath(relativePath, accept); - LOG.info("Read {}", path); + LOG.info("Read {}{}", fs, path); try { - FileObject fileObject = fsManager.resolveFile(MEM_PREFIX + path); + final FileObject fileObject = fsManager.resolveFile(fs + path); if (!fileObject.exists()) { LOG.warn("In-memory path '{}' not found", path); - - try { - fileObject = fsManager.resolveFile(RES_PREFIX + path); - fileObject = putInMemory(fileObject.getContent().getInputStream(), path); - } catch (FileSystemException fse) { - LOG.warn("Resource path '{}' not found", path, fse); - } - } - - if (!fileObject.exists()) { throw new NotFoundException(); } @@ -176,12 +187,33 @@ public class FSManager { } } - public FileObject resolve(final String path) throws FileSystemException { - FileObject res = fsManager.resolveFile(MEM_PREFIX + path); + public void deleteEntity(final String relativePath) { + final String path = getAbsolutePath(relativePath, null); + LOG.info("Delete {}", path); - if (!res.exists()) { - res = fsManager.resolveFile(RES_PREFIX + path); + try { + final FileObject fileObject = fsManager.resolveFile(MEM_PREFIX + path); + + if (fileObject.exists()) { + fileObject.delete(new FileSelector() { + @Override + public boolean includeFile(final FileSelectInfo fileInfo) throws Exception { + return true; + } + + @Override + public boolean traverseDescendents(final FileSelectInfo fileInfo) throws Exception { + return true; + } + }); + } + } catch (IOException ignore) { + // ignore exception } + } + + public FileObject resolve(final String path) throws FileSystemException { + final FileObject res = fsManager.resolveFile(MEM_PREFIX + path); if (!res.exists()) { throw new FileSystemException("Unresolved path " + path); @@ -190,11 +222,11 @@ public class FSManager { return res; } - public FileObject[] findByExtension(final FileObject fo, final String ext) throws FileSystemException { + public final FileObject[] find(final FileObject fo, final String ext) throws FileSystemException { return fo.findFiles(new FileSelector() { @Override public boolean includeFile(final FileSelectInfo fileInfo) throws Exception { - return fileInfo.getFile().getName().getExtension().equals(ext); + return ext == null ? true : fileInfo.getFile().getName().getExtension().equals(ext); } @Override diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java index b4f99693a..84a6cd2e6 100644 --- a/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java +++ b/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java @@ -598,7 +598,7 @@ public class XMLUtilities extends AbstractUtilities { try { final FileObject skipToken = fsManager.resolve(skipTokenDirPath); - final FileObject[] files = fsManager.findByExtension(skipToken, Accept.XML.getExtension().substring(1)); + final FileObject[] files = fsManager.find(skipToken, Accept.XML.getExtension().substring(1)); for (FileObject file : files) { count += countFeedElements(fsManager.readFile( diff --git a/fit/src/main/resources/V40/Accounts/102/entity.full.json b/fit/src/main/resources/V40/Accounts/102/entity.full.json new file mode 100644 index 000000000..1682135c5 --- /dev/null +++ b/fit/src/main/resources/V40/Accounts/102/entity.full.json @@ -0,0 +1,34 @@ +{ + "@odata.context": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#Accounts/$entity", + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.Account", + "@odata.id": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)", + "@odata.editLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)", + "AccountID": 102, + "Country": "US", + "AccountInfo": { + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.AccountInfo", + "FirstName": "Alex", + "LastName": "Green", + "MiddleName": "Hood" + }, + "MyGiftCard@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyGiftCard/$ref", + "MyGiftCard@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyGiftCard", + "MyPaymentInstruments@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments/$ref", + "MyPaymentInstruments@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments", + "ActiveSubscriptions@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/ActiveSubscriptions/$ref", + "ActiveSubscriptions@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/ActiveSubscriptions", + "AvailableSubscriptionTemplatess@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/AvailableSubscriptionTemplatess/$ref", + "AvailableSubscriptionTemplatess@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/AvailableSubscriptionTemplatess", + "#Microsoft.Test.OData.Services.ODataWCFService.RefreshDefaultPI": { + "title": "Microsoft.Test.OData.Services.ODataWCFService.RefreshDefaultPI", + "target": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/Microsoft.Test.OData.Services.ODataWCFService.RefreshDefaultPI" + }, + "#Microsoft.Test.OData.Services.ODataWCFService.GetDefaultPI": { + "title": "Microsoft.Test.OData.Services.ODataWCFService.GetDefaultPI", + "target": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/Microsoft.Test.OData.Services.ODataWCFService.GetDefaultPI" + }, + "#Microsoft.Test.OData.Services.ODataWCFService.GetAccountInfo": { + "title": "Microsoft.Test.OData.Services.ODataWCFService.GetAccountInfo", + "target": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/Microsoft.Test.OData.Services.ODataWCFService.GetAccountInfo" + } +} diff --git a/fit/src/main/resources/V40/Accounts/102/entity.xml b/fit/src/main/resources/V40/Accounts/102/entity.xml new file mode 100644 index 000000000..0b9cc630d --- /dev/null +++ b/fit/src/main/resources/V40/Accounts/102/entity.xml @@ -0,0 +1,55 @@ + + + + http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102) + + + + + + + + <updated>2014-04-14T12:45:00Z</updated> + <author> + <name/> + </author> + <m:action metadata="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#Microsoft.Test.OData.Services.ODataWCFService.RefreshDefaultPI" + title="Microsoft.Test.OData.Services.ODataWCFService.RefreshDefaultPI" + target="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/Microsoft.Test.OData.Services.ODataWCFService.RefreshDefaultPI"/> + <m:action metadata="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#Microsoft.Test.OData.Services.ODataWCFService.GetDefaultPI" + title="Microsoft.Test.OData.Services.ODataWCFService.GetDefaultPI" + target="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/Microsoft.Test.OData.Services.ODataWCFService.GetDefaultPI"/> + <m:action metadata="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#Microsoft.Test.OData.Services.ODataWCFService.GetAccountInfo" + title="Microsoft.Test.OData.Services.ODataWCFService.GetAccountInfo" + target="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/Microsoft.Test.OData.Services.ODataWCFService.GetAccountInfo"/> + <content type="application/xml"> + <m:properties> + <d:AccountID m:type="Int32">102</d:AccountID> + <d:Country>US</d:Country> + <d:AccountInfo m:type="#Microsoft.Test.OData.Services.ODataWCFService.AccountInfo"> + <d:FirstName>Alex</d:FirstName> + <d:LastName>Green</d:LastName> + <d:MiddleName>Hood</d:MiddleName> + </d:AccountInfo> + </m:properties> + </content> +</entry> diff --git a/fit/src/main/resources/V40/Accounts/102/links/MyGiftCard.full.json b/fit/src/main/resources/V40/Accounts/102/links/MyGiftCard.full.json new file mode 100644 index 000000000..cf9d18a31 --- /dev/null +++ b/fit/src/main/resources/V40/Accounts/102/links/MyGiftCard.full.json @@ -0,0 +1,15 @@ +{ + "@odata.context": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#Accounts(102)/MyGiftCard/$entity", + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.GiftCard", + "@odata.id": "Accounts(102)/MyGiftCard", + "@odata.editLink": "Accounts(102)/MyGiftCard", + "GiftCardID": 301, + "GiftCardNO": "AAA123A", + "Amount": 19.9, + "ExperationDate@odata.type": "#DateTimeOffset", + "ExperationDate": "2013-12-30T00:00:00Z", + "#Microsoft.Test.OData.Services.ODataWCFService.GetActualAmount": { + "title": "Microsoft.Test.OData.Services.ODataWCFService.GetActualAmount", + "target": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyGiftCard/Microsoft.Test.OData.Services.ODataWCFService.GetActualAmount" + } +} diff --git a/fit/src/main/resources/V40/Accounts/102/links/MyGiftCard.xml b/fit/src/main/resources/V40/Accounts/102/links/MyGiftCard.xml new file mode 100644 index 000000000..b1927b346 --- /dev/null +++ b/fit/src/main/resources/V40/Accounts/102/links/MyGiftCard.xml @@ -0,0 +1,41 @@ +<?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. + +--> +<entry xml:base="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:context="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#Accounts(102)/MyGiftCard/$entity"> + <category term="#Microsoft.Test.OData.Services.ODataWCFService.GiftCard" scheme="http://docs.oasis-open.org/odata/ns/scheme" /> + <id /> + <title /> + <updated>2014-04-23T13:48:48Z</updated> + <author> + <name /> + </author> + <m:action metadata="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#Microsoft.Test.OData.Services.ODataWCFService.GetActualAmount" + title="Microsoft.Test.OData.Services.ODataWCFService.GetActualAmount" + target="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyGiftCard/Microsoft.Test.OData.Services.ODataWCFService.GetActualAmount"/> + <content type="application/xml"> + <m:properties> + <d:GiftCardID m:type="Int32">301</d:GiftCardID> + <d:GiftCardNO>AAA123A</d:GiftCardNO> + <d:Amount m:type="Double">19.9</d:Amount> + <d:ExperationDate m:type="DateTimeOffset">2013-12-30T00:00:00Z</d:ExperationDate> + </m:properties> + </content> +</entry> diff --git a/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments(102901).full.json b/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments(102901).full.json new file mode 100644 index 000000000..70c96de06 --- /dev/null +++ b/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments(102901).full.json @@ -0,0 +1,16 @@ +{ + "@odata.context": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#Accounts(102)/MyPaymentInstruments/$entity", + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", + "@odata.id": "Accounts(102)/MyPaymentInstruments(102901)", + "@odata.editLink": "Accounts(102)/MyPaymentInstruments(102901)", + "PaymentInstrumentID": 102901, + "FriendlyName": "102 first PI", + "CreatedDate@odata.type": "#DateTimeOffset", + "CreatedDate": "2014-04-09T00:00:00Z", + "TheStoredPI@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/TheStoredPI/$ref", + "TheStoredPI@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/TheStoredPI", + "BillingStatements@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/BillingStatements/$ref", + "BillingStatements@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/BillingStatements", + "BackupStoredPI@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/BackupStoredPI/$ref", + "BackupStoredPI@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/BackupStoredPI" +} diff --git a/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments(102901).xml b/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments(102901).xml new file mode 100644 index 000000000..e51921779 --- /dev/null +++ b/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments(102901).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. + +--> +<entry xml:base="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:context="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#Accounts(102)/MyPaymentInstruments/$entity"> + <category term="#Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument" scheme="http://docs.oasis-open.org/odata/ns/scheme"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/TheStoredPI" type="application/atom+xml;type=entry" title="TheStoredPI" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/TheStoredPI"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/BillingStatements" type="application/atom+xml;type=feed" title="BillingStatements" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/BillingStatements"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/BackupStoredPI" type="application/atom+xml;type=entry" title="BackupStoredPI" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/BackupStoredPI"/> + <id/> + <title/> + <updated>2014-04-14T12:47:37Z</updated> + <author> + <name/> + </author> + <content type="application/xml"> + <m:properties> + <d:PaymentInstrumentID m:type="Int32">102901</d:PaymentInstrumentID> + <d:FriendlyName>102 first PI</d:FriendlyName> + <d:CreatedDate m:type="DateTimeOffset">2014-04-09T00:00:00Z</d:CreatedDate> + </m:properties> + </content> +</entry> diff --git a/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments(102902).full.json b/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments(102902).full.json new file mode 100644 index 000000000..d6082db2e --- /dev/null +++ b/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments(102902).full.json @@ -0,0 +1,16 @@ +{ + "@odata.context": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#Accounts(102)/MyPaymentInstruments/$entity", + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", + "@odata.id": "Accounts(102)/MyPaymentInstruments(102902)", + "@odata.editLink": "Accounts(102)/MyPaymentInstruments(102902)", + "PaymentInstrumentID": 102902, + "FriendlyName": "102 first PI", + "CreatedDate@odata.type": "#DateTimeOffset", + "CreatedDate": "2014-04-09T00:00:00Z", + "TheStoredPI@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/TheStoredPI/$ref", + "TheStoredPI@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/TheStoredPI", + "BillingStatements@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/BillingStatements/$ref", + "BillingStatements@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/BillingStatements", + "BackupStoredPI@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/BackupStoredPI/$ref", + "BackupStoredPI@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/BackupStoredPI" +} diff --git a/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments(102902).xml b/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments(102902).xml new file mode 100644 index 000000000..7a056c44b --- /dev/null +++ b/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments(102902).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. + +--> +<entry xml:base="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:context="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#Accounts(102)/MyPaymentInstruments/$entity"> + <category term="#Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument" scheme="http://docs.oasis-open.org/odata/ns/scheme"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/TheStoredPI" type="application/atom+xml;type=entry" title="TheStoredPI" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/TheStoredPI"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/BillingStatements" type="application/atom+xml;type=feed" title="BillingStatements" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/BillingStatements"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/BackupStoredPI" type="application/atom+xml;type=entry" title="BackupStoredPI" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/BackupStoredPI"/> + <id/> + <title/> + <updated>2014-04-14T12:47:37Z</updated> + <author> + <name/> + </author> + <content type="application/xml"> + <m:properties> + <d:PaymentInstrumentID m:type="Int32">102902</d:PaymentInstrumentID> + <d:FriendlyName>102 first PI</d:FriendlyName> + <d:CreatedDate m:type="DateTimeOffset">2014-04-09T00:00:00Z</d:CreatedDate> + </m:properties> + </content> +</entry> diff --git a/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments.full.json b/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments.full.json new file mode 100644 index 000000000..d056b5ead --- /dev/null +++ b/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments.full.json @@ -0,0 +1,62 @@ +{ + "@odata.context": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#Accounts(102)/MyPaymentInstruments", + "value": [{ + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", + "@odata.id": "Accounts(102)/MyPaymentInstruments(102901)", + "@odata.editLink": "Accounts(102)/MyPaymentInstruments(102901)", + "PaymentInstrumentID": 102901, + "FriendlyName": "102 first PI", + "CreatedDate@odata.type": "#DateTimeOffset", + "CreatedDate": "2014-04-09T00:00:00Z", + "TheStoredPI@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/TheStoredPI/$ref", + "TheStoredPI@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/TheStoredPI", + "BillingStatements@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/BillingStatements/$ref", + "BillingStatements@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/BillingStatements", + "BackupStoredPI@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/BackupStoredPI/$ref", + "BackupStoredPI@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/BackupStoredPI" + }, { + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI", + "@odata.id": "Accounts(102)/MyPaymentInstruments(102902)", + "@odata.editLink": "Accounts(102)/MyPaymentInstruments(102902)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI", + "PaymentInstrumentID": 102902, + "FriendlyName": "102 frist credit PI", + "CreatedDate@odata.type": "#DateTimeOffset", + "CreatedDate": "2012-11-01T00:00:00Z", + "CardNumber": "6000000000000000", + "CVV": "234", + "HolderName": "Alex", + "Balance": 100.0, + "ExperationDate@odata.type": "#DateTimeOffset", + "ExperationDate": "2022-11-01T00:00:00Z", + "TheStoredPI@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/TheStoredPI/$ref", + "TheStoredPI@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/TheStoredPI", + "BillingStatements@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/BillingStatements/$ref", + "BillingStatements@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/BillingStatements", + "BackupStoredPI@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/BackupStoredPI/$ref", + "BackupStoredPI@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/BackupStoredPI", + "CreditRecords@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/CreditRecords/$ref", + "CreditRecords@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/CreditRecords" + }, { + "@odata.type": "#Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI", + "@odata.id": "Accounts(102)/MyPaymentInstruments(102903)", + "@odata.editLink": "Accounts(102)/MyPaymentInstruments(102903)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI", + "PaymentInstrumentID": 102903, + "FriendlyName": "102 second credit PI", + "CreatedDate@odata.type": "#DateTimeOffset", + "CreatedDate": "2012-11-01T00:00:00Z", + "CardNumber": "8000000000000000", + "CVV": "012", + "HolderName": "James", + "Balance": 300.0, + "ExperationDate@odata.type": "#DateTimeOffset", + "ExperationDate": "2022-10-02T00:00:00Z", + "TheStoredPI@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102903)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/TheStoredPI/$ref", + "TheStoredPI@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102903)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/TheStoredPI", + "BillingStatements@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102903)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/BillingStatements/$ref", + "BillingStatements@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102903)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/BillingStatements", + "BackupStoredPI@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102903)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/BackupStoredPI/$ref", + "BackupStoredPI@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102903)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/BackupStoredPI", + "CreditRecords@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102903)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/CreditRecords/$ref", + "CreditRecords@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102903)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/CreditRecords" + }] +} diff --git a/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments.xml b/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments.xml new file mode 100644 index 000000000..5defbc308 --- /dev/null +++ b/fit/src/main/resources/V40/Accounts/102/links/MyPaymentInstruments.xml @@ -0,0 +1,95 @@ +<?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. + +--> +<feed xml:base="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://docs.oasis-open.org/odata/ns/data" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:context="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/$metadata#Accounts(102)/MyPaymentInstruments"> + <id>http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/MyPaymentInstruments</id> + <title/> + <updated>2014-04-14T12:45:33Z</updated> + <entry> + <category term="#Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument" scheme="http://docs.oasis-open.org/odata/ns/scheme"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/TheStoredPI" type="application/atom+xml;type=entry" title="TheStoredPI" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/TheStoredPI"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/BillingStatements" type="application/atom+xml;type=feed" title="BillingStatements" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/BillingStatements"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/BackupStoredPI" type="application/atom+xml;type=entry" title="BackupStoredPI" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102901)/BackupStoredPI"/> + <id/> + <title/> + <updated>2014-04-14T12:45:33Z</updated> + <author> + <name/> + </author> + <content type="application/xml"> + <m:properties> + <d:PaymentInstrumentID m:type="Int32">102901</d:PaymentInstrumentID> + <d:FriendlyName>102 first PI</d:FriendlyName> + <d:CreatedDate m:type="DateTimeOffset">2014-04-09T00:00:00Z</d:CreatedDate> + </m:properties> + </content> + </entry> + <entry> + <category term="#Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI" scheme="http://docs.oasis-open.org/odata/ns/scheme"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/TheStoredPI" type="application/atom+xml;type=entry" title="TheStoredPI" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/TheStoredPI"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/BillingStatements" type="application/atom+xml;type=feed" title="BillingStatements" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/BillingStatements"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/BackupStoredPI" type="application/atom+xml;type=entry" title="BackupStoredPI" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/BackupStoredPI"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/CreditRecords" type="application/atom+xml;type=feed" title="CreditRecords" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102902)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/CreditRecords"/> + <id/> + <title/> + <updated>2014-04-14T12:45:33Z</updated> + <author> + <name/> + </author> + <content type="application/xml"> + <m:properties> + <d:PaymentInstrumentID m:type="Int32">102902</d:PaymentInstrumentID> + <d:FriendlyName>102 frist credit PI</d:FriendlyName> + <d:CreatedDate m:type="DateTimeOffset">2012-11-01T00:00:00Z</d:CreatedDate> + <d:CardNumber>6000000000000000</d:CardNumber> + <d:CVV>234</d:CVV> + <d:HolderName>Alex</d:HolderName> + <d:Balance m:type="Double">100</d:Balance> + <d:ExperationDate m:type="DateTimeOffset">2022-11-01T00:00:00Z</d:ExperationDate> + </m:properties> + </content> + </entry> + <entry> + <category term="#Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI" scheme="http://docs.oasis-open.org/odata/ns/scheme"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/TheStoredPI" type="application/atom+xml;type=entry" title="TheStoredPI" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102903)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/TheStoredPI"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/BillingStatements" type="application/atom+xml;type=feed" title="BillingStatements" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102903)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/BillingStatements"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/BackupStoredPI" type="application/atom+xml;type=entry" title="BackupStoredPI" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102903)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/BackupStoredPI"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/CreditRecords" type="application/atom+xml;type=feed" title="CreditRecords" href="http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Accounts(102)/MyPaymentInstruments(102903)/Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI/CreditRecords"/> + <id/> + <title/> + <updated>2014-04-14T12:45:33Z</updated> + <author> + <name/> + </author> + <content type="application/xml"> + <m:properties> + <d:PaymentInstrumentID m:type="Int32">102903</d:PaymentInstrumentID> + <d:FriendlyName>102 second credit PI</d:FriendlyName> + <d:CreatedDate m:type="DateTimeOffset">2012-11-01T00:00:00Z</d:CreatedDate> + <d:CardNumber>8000000000000000</d:CardNumber> + <d:CVV>012</d:CVV> + <d:HolderName>James</d:HolderName> + <d:Balance m:type="Double">300</d:Balance> + <d:ExperationDate m:type="DateTimeOffset">2022-10-02T00:00:00Z</d:ExperationDate> + </m:properties> + </content> + </entry> +</feed> diff --git a/fit/src/main/resources/V40/Boss/entity.full.json b/fit/src/main/resources/V40/Boss/entity.full.json index d89b4a58c..5444c2c3e 100644 --- a/fit/src/main/resources/V40/Boss/entity.full.json +++ b/fit/src/main/resources/V40/Boss/entity.full.json @@ -6,6 +6,7 @@ "@Microsoft.Test.OData.Services.ODataWCFService.IsBoss": true, "PersonID": 2, "FirstName": "Jill", + "LastName@Microsoft.Test.OData.Services.ODataWCFService.IsBoss": false, "LastName": "Jones", "MiddleName": null, "HomeAddress": null, @@ -31,6 +32,7 @@ "TimeBetweenLastTwoOrders": "PT0.0000002S", "Parent@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Parent/$ref", "Parent@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Parent", + "Orders@Microsoft.Test.OData.Services.ODataWCFService.IsBoss": false, "Orders@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Orders/$ref", "Orders@odata.navigationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Orders", "Company@odata.associationLink": "http://localhost:${cargo.servlet.port}/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Company/$ref", diff --git a/fit/src/main/resources/V40/Boss/entity.xml b/fit/src/main/resources/V40/Boss/entity.xml index 72ccb4c62..41c2248e7 100644 --- a/fit/src/main/resources/V40/Boss/entity.xml +++ b/fit/src/main/resources/V40/Boss/entity.xml @@ -25,7 +25,9 @@ <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/Parent" title="Parent" href="http://localhost:9080/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Parent/$ref" type="application/xml"/> <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/Orders" title="Orders" href="http://localhost:9080/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Orders/$ref" type="application/xml"/> <link rel="http://docs.oasis-open.org/odata/ns/relatedlinks/Company" title="Company" href="http://localhost:9080/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Company/$ref" type="application/xml"/> - <link rel="http://docs.oasis-open.org/odata/ns/related/Parent" title="Parent" href="http://localhost:9080/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Parent" type="application/atom+xml;type=entry"/> + <link rel="http://docs.oasis-open.org/odata/ns/related/Parent" title="Parent" href="http://localhost:9080/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Parent" type="application/atom+xml;type=entry"> + <m:annotation term="Microsoft.Test.OData.Services.ODataWCFService.IsBoss" m:type="Boolean">false</m:annotation> + </link> <link rel="http://docs.oasis-open.org/odata/ns/related/Orders" title="Orders" href="http://localhost:9080/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Orders" type="application/atom+xml;type=entry"/> <link rel="http://docs.oasis-open.org/odata/ns/related/Company" title="Company" href="http://localhost:9080/stub/StaticService/V40/Static.svc/Boss/Microsoft.Test.OData.Services.ODataWCFService.Customer/Company" type="application/atom+xml;type=entry"/> <content type="application/xml"> @@ -33,6 +35,7 @@ <d:PersonID m:type="Int32">2</d:PersonID> <d:FirstName>Jill</d:FirstName> <d:LastName>Jones</d:LastName> + <m:annotation term="Microsoft.Test.OData.Services.ODataWCFService.IsBoss" target="LastName" m:type="Boolean">false</m:annotation> <d:MiddleName m:null="true"/> <d:HomeAddress m:null="true"/> <d:Home m:type="GeographyPoint"> diff --git a/fit/src/main/resources/V40/openTypeMetadata.xml b/fit/src/main/resources/V40/openTypeMetadata.xml index 3cca59047..62b2f77b4 100644 --- a/fit/src/main/resources/V40/openTypeMetadata.xml +++ b/fit/src/main/resources/V40/openTypeMetadata.xml @@ -41,6 +41,10 @@ <Property Name="Int" Type="Edm.Int32" Nullable="false"/> <Property Name="Long" Type="Edm.Int64" Nullable="false"/> </ComplexType> + <ComplexType Name="AccountInfo" OpenType="true"> + <Property Name="FirstName" Type="Edm.String" Nullable="false"/> + <Property Name="LastName" Type="Edm.String" Nullable="false"/> + </ComplexType> <EntityType Name="Row" OpenType="true"> <Key> <PropertyRef Name="Id"/> diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AbstractTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AbstractTestITCase.java index de9cdc3b8..0bf0eb58d 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AbstractTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AbstractTestITCase.java @@ -63,8 +63,6 @@ public abstract class AbstractTestITCase { protected static String testLargeModelServiceRootURL; - protected static String testAuthServiceRootURL; - protected final EntityContext entityContext = EntityContainerFactory.getContext().entityContext(); protected static EntityContainerFactory<EdmEnabledODataClient> containerFactory; @@ -79,7 +77,6 @@ public abstract class AbstractTestITCase { testActionOverloadingServiceRootURL = "http://localhost:9080/stub/StaticService/V30/ActionOverloading.svc"; testOpenTypeServiceRootURL = "http://localhost:9080/stub/StaticService/V30/OpenType.svc"; testLargeModelServiceRootURL = "http://localhost:9080/stub/StaticService/V30/Static.svc/large"; - testAuthServiceRootURL = "http://localhost:9080/stub/DefaultService.svc"; containerFactory = EntityContainerFactory.getV3(testStaticServiceRootURL); containerFactory.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM); diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AuthEntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityCreateTestITCase.java similarity index 64% rename from fit/src/test/java/org/apache/olingo/fit/proxy/v3/AuthEntityRetrieveTestITCase.java rename to fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityCreateTestITCase.java index 7a721a467..d837075be 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AuthEntityRetrieveTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityCreateTestITCase.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.fit.proxy.v3; +package org.apache.olingo.fit.proxy.v4; import static org.junit.Assert.assertNotNull; @@ -24,25 +24,27 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory; +import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.ext.proxy.EntityContainerFactory; -import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice. - DefaultContainer; +import static org.apache.olingo.fit.proxy.v4.AbstractTestITCase.containerFactory; +import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities; -public class AuthEntityRetrieveTestITCase extends EntityRetrieveTestITCase { +public class AuthEntityCreateTestITCase extends EntityCreateTestITCase { @BeforeClass public static void setupContaner() { - containerFactory = EntityContainerFactory.getV3(testAuthServiceRootURL); + containerFactory = EntityContainerFactory.getV4(testAuthServiceRootURL); + containerFactory.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM); containerFactory.getClient().getConfiguration(). setHttpClientFactory(new BasicAuthHttpClientFactory("odatajclient", "odatajclient")); - container = containerFactory.getEntityContainer(DefaultContainer.class); + container = containerFactory.getEntityContainer(InMemoryEntities.class); assertNotNull(container); } @AfterClass public static void disableBasicAuth() { - containerFactory = EntityContainerFactory.getV3(testStaticServiceRootURL); - container = containerFactory.getEntityContainer(DefaultContainer.class); + containerFactory = EntityContainerFactory.getV4(testStaticServiceRootURL); + container = containerFactory.getEntityContainer(InMemoryEntities.class); assertNotNull(container); } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityRetrieveTestITCase.java index afe4d006e..c5391d037 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityRetrieveTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AuthEntityRetrieveTestITCase.java @@ -18,8 +18,6 @@ */ package org.apache.olingo.fit.proxy.v4; -import static org.apache.olingo.fit.proxy.v4.AbstractTestITCase.testKeyAsSegmentServiceRootURL; - import org.apache.olingo.client.api.v4.EdmEnabledODataClient; import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory; @@ -32,7 +30,7 @@ public class AuthEntityRetrieveTestITCase extends EntityRetrieveTestITCase { @Override protected InMemoryEntities getContainer() { final EntityContainerFactory<EdmEnabledODataClient> ecf = - EntityContainerFactory.getV4(testKeyAsSegmentServiceRootURL); + EntityContainerFactory.getV4(testAuthServiceRootURL); ecf.getClient().getConfiguration().setKeyAsSegment(true); ecf.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM); ecf.getClient().getConfiguration(). diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityCreateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityCreateTestITCase.java index aee312773..88c4743bf 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityCreateTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/EntityCreateTestITCase.java @@ -29,6 +29,8 @@ import java.util.Calendar; import java.util.Collections; import java.util.TimeZone; import org.apache.commons.lang3.RandomUtils; +import static org.apache.olingo.fit.proxy.v4.AbstractTestITCase.container; + import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccessLevel; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Color; @@ -71,7 +73,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase { date.clear(); date.set(2011, 3, 4, 9, 0, 0); employee.setDateHired(date); - Address homeAddress = employee.factory().newHomeAddress(); + final Address homeAddress = employee.factory().newHomeAddress(); homeAddress.setCity("Pescara"); homeAddress.setPostalCode("65100"); homeAddress.setStreet("viale Gabriele D'Annunzio 256"); @@ -94,7 +96,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase { container.getPeople().delete(actual.getPersonID()); container.flush(); - actual = container.getPeople().get(id, Employee.class);; + actual = container.getPeople().get(id, Employee.class); assertNull(actual); entityContext.detachAll(); @@ -130,7 +132,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase { assertEquals(homeAddress.getCity(), actual.getHomeAddress().getCity()); assertEquals(1, actual.getOrders().size()); assertEquals(8, actual.getOrders().iterator().next().getOrderID(), 0); - + container.getCustomers().delete(actual.getPersonID()); container.flush(); diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OpenTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OpenTypeTestITCase.java index 11f7d07d5..e337521fd 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OpenTypeTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/OpenTypeTestITCase.java @@ -33,6 +33,7 @@ import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.ext.proxy.EntityContainerFactory; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.DefaultContainer; +import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.AccountInfo; import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.Color; import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.ContactDetails; import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.Row; @@ -115,6 +116,12 @@ public class OpenTypeTestITCase extends AbstractTestITCase { rowIndex.addAdditionalProperty("aContact", contact); rowIndex.addAdditionalProperty("aColor", Color.Green); + final AccountInfo ai = otcontainer.complexFactory().newAccountInfo(); + ai.setFirstName("Fabio"); + ai.setLastName("Martelli"); + ai.addAdditionalProperty("email", "fabio.martelli@tirasa.net"); + rowIndex.addAdditionalProperty("info", ai); + otcontainer.flush(); rowIndex = otcontainer.getRowIndex().get(id); @@ -127,6 +134,10 @@ public class OpenTypeTestITCase extends AbstractTestITCase { assertEquals(ContactDetails.class, rowIndex.getAdditionalProperty("aContact").getClass().getInterfaces()[0]); assertEquals(Color.class, rowIndex.getAdditionalProperty("aColor").getClass()); assertEquals(Color.Green, rowIndex.getAdditionalProperty("aColor")); + assertEquals("Fabio", AccountInfo.class.cast(rowIndex.getAdditionalProperty("info")).getFirstName()); + assertEquals("Martelli", AccountInfo.class.cast(rowIndex.getAdditionalProperty("info")).getLastName()); + assertEquals("fabio.martelli@tirasa.net", AccountInfo.class.cast(rowIndex.getAdditionalProperty("info")). + getAdditionalProperty("email")); entityContext.detachAll(); diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/SingletonTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/SingletonTestITCase.java index 946029795..ae1ef53f2 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/SingletonTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/SingletonTestITCase.java @@ -19,9 +19,10 @@ package org.apache.olingo.fit.proxy.v4; import static org.junit.Assert.assertEquals; - +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Company; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CompanyCategory; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.IsBoss; @@ -51,13 +52,26 @@ public class SingletonTestITCase extends AbstractTestITCase { public void readWithAnnotations() { final Company company = container.getCompany().get(); assertTrue(company.getAnnotationTerms().isEmpty()); - + final Person boss = container.getBoss().get(); assertEquals(2, boss.getPersonID(), 0); assertEquals(1, boss.getAnnotationTerms().size()); - final Object isBoss = boss.getAnnotation(IsBoss.class); + Object isBoss = boss.getAnnotation(IsBoss.class); assertTrue(isBoss instanceof Boolean); assertTrue((Boolean) isBoss); + + Annotatable annotations = boss.annotations().getFirstNameAnnotations(); + assertTrue(annotations.getAnnotationTerms().isEmpty()); + + annotations = boss.annotations().getLastNameAnnotations(); + isBoss = annotations.getAnnotation(IsBoss.class); + assertTrue(isBoss instanceof Boolean); + assertFalse((Boolean) isBoss); + + annotations = boss.annotations().getParentAnnotations(); + isBoss = annotations.getAnnotation(IsBoss.class); + assertTrue(isBoss instanceof Boolean); + assertFalse((Boolean) isBoss); } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/DefaultContainer.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/DefaultContainer.java index 18df189d4..f146c6bb3 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/DefaultContainer.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/DefaultContainer.java @@ -53,12 +53,10 @@ import javax.xml.datatype.Duration; public interface DefaultContainer extends Container { Row getRow(); - RowIndex getRowIndex(); - Operations operations(); public interface Operations { @@ -72,5 +70,9 @@ public interface DefaultContainer extends Container { type = "Microsoft.Test.OData.Services.OpenTypesServiceV4.ContactDetails") org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.ContactDetails newContactDetails(); + @Property(name = "AccountInfo", + type = "Microsoft.Test.OData.Services.OpenTypesServiceV4.AccountInfo") + org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.AccountInfo newAccountInfo(); + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/Row.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/Row.java index 5c970acf3..80a73a930 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/Row.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/Row.java @@ -43,7 +43,6 @@ import java.util.Calendar; import javax.xml.datatype.Duration; - @EntitySet(name = "Row") public interface Row extends AbstractEntitySet<org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.Row, UUID, org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.RowCollection> { diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/RowIndex.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/RowIndex.java index 22dee42f5..97ee5f99a 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/RowIndex.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/RowIndex.java @@ -43,7 +43,6 @@ import java.util.Calendar; import javax.xml.datatype.Duration; - @EntitySet(name = "RowIndex") public interface RowIndex extends AbstractEntitySet<org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.RowIndex, Integer, org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.RowIndexCollection> { diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/AccountInfo.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/AccountInfo.java new file mode 100644 index 000000000..651a65a8b --- /dev/null +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/AccountInfo.java @@ -0,0 +1,90 @@ +/* + * 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.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types; + +import org.apache.olingo.ext.proxy.api.annotations.Namespace; +import org.apache.olingo.ext.proxy.api.annotations.ComplexType; +import org.apache.olingo.ext.proxy.api.annotations.Property; +import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; +import org.apache.olingo.ext.proxy.api.AbstractOpenType; +import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.*; +import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.*; + +import org.apache.olingo.commons.api.edm.geo.Geospatial; +import org.apache.olingo.commons.api.edm.geo.GeospatialCollection; +import org.apache.olingo.commons.api.edm.geo.LineString; +import org.apache.olingo.commons.api.edm.geo.MultiLineString; +import org.apache.olingo.commons.api.edm.geo.MultiPoint; +import org.apache.olingo.commons.api.edm.geo.MultiPolygon; +import org.apache.olingo.commons.api.edm.geo.Point; +import org.apache.olingo.commons.api.edm.geo.Polygon; +import java.math.BigDecimal; +import java.net.URI; +import java.util.UUID; +import java.io.Serializable; +import java.util.Collection; +import java.util.Calendar; +import javax.xml.datatype.Duration; + + +@Namespace("Microsoft.Test.OData.Services.OpenTypesServiceV4") +@ComplexType(name = "AccountInfo", + isOpenType = true, + isAbstract = false) +public interface AccountInfo + extends AbstractOpenType,Serializable { + + + @Property(name = "FirstName", + type = "Edm.String", + nullable = false, + defaultValue = "", + maxLenght = Integer.MAX_VALUE, + fixedLenght = false, + precision = 0, + scale = 0, + unicode = true, + collation = "", + srid = "") + String getFirstName(); + + void setFirstName(String _firstName); + + + + @Property(name = "LastName", + type = "Edm.String", + nullable = false, + defaultValue = "", + maxLenght = Integer.MAX_VALUE, + fixedLenght = false, + precision = 0, + scale = 0, + unicode = true, + collation = "", + srid = "") + String getLastName(); + + void setLastName(String _lastName); + + + + +} diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/ContactDetails.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/ContactDetails.java index d96c8386a..4eae25407 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/ContactDetails.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/ContactDetails.java @@ -23,6 +23,7 @@ import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.ComplexType; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; +import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.*; import org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.*; @@ -64,7 +65,7 @@ public interface ContactDetails srid = "") byte[] getFirstContacted(); - void setFirstContacted(final byte[] _firstContacted); + void setFirstContacted(byte[] _firstContacted); @@ -81,7 +82,7 @@ public interface ContactDetails srid = "") Calendar getLastContacted(); - void setLastContacted(final Calendar _lastContacted); + void setLastContacted(Calendar _lastContacted); @@ -98,7 +99,7 @@ public interface ContactDetails srid = "") Calendar getContacted(); - void setContacted(final Calendar _contacted); + void setContacted(Calendar _contacted); @@ -115,7 +116,7 @@ public interface ContactDetails srid = "") UUID getGUID(); - void setGUID(final UUID _gUID); + void setGUID(UUID _gUID); @@ -132,7 +133,7 @@ public interface ContactDetails srid = "") Calendar getPreferedContactTime(); - void setPreferedContactTime(final Calendar _preferedContactTime); + void setPreferedContactTime(Calendar _preferedContactTime); @@ -149,7 +150,7 @@ public interface ContactDetails srid = "") Short getByte(); - void setByte(final Short _byte); + void setByte(Short _byte); @@ -166,7 +167,7 @@ public interface ContactDetails srid = "") Byte getSignedByte(); - void setSignedByte(final Byte _signedByte); + void setSignedByte(Byte _signedByte); @@ -183,7 +184,7 @@ public interface ContactDetails srid = "") Double getDouble(); - void setDouble(final Double _double); + void setDouble(Double _double); @@ -200,7 +201,7 @@ public interface ContactDetails srid = "") Float getSingle(); - void setSingle(final Float _single); + void setSingle(Float _single); @@ -217,7 +218,7 @@ public interface ContactDetails srid = "") Short getShort(); - void setShort(final Short _short); + void setShort(Short _short); @@ -234,7 +235,7 @@ public interface ContactDetails srid = "") Integer getInt(); - void setInt(final Integer _int); + void setInt(Integer _int); @@ -251,7 +252,7 @@ public interface ContactDetails srid = "") Long getLong(); - void setLong(final Long _long); + void setLong(Long _long); diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/IndexedRow.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/IndexedRow.java index 0ce9626ce..e7ec3e67a 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/IndexedRow.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/IndexedRow.java @@ -28,6 +28,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -59,7 +60,7 @@ import javax.xml.datatype.Duration; isAbstract = false, baseType = "Microsoft.Test.OData.Services.OpenTypesServiceV4.Row") public interface IndexedRow - extends org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.Row { + extends Annotatable,org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.Row { @Key @@ -83,7 +84,7 @@ public interface IndexedRow fcKeepInContent = false) UUID getId(); - void setId(final UUID _id); + void setId(UUID _id); diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/IndexedRowCollection.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/IndexedRowCollection.java index 40e8638f3..a4496e56f 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/IndexedRowCollection.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/IndexedRowCollection.java @@ -21,6 +21,7 @@ package org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.op import org.apache.olingo.client.api.http.HttpMethod; import org.apache.olingo.ext.proxy.api.AbstractEntityCollection; +import org.apache.olingo.ext.proxy.api.AbstractTerm; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; @@ -44,4 +45,8 @@ import java.util.Calendar; import javax.xml.datatype.Duration; public interface IndexedRowCollection extends AbstractEntityCollection<IndexedRow> { + + Object getAnnotation(Class<? extends AbstractTerm> term); + + Collection<Class<? extends AbstractTerm>> getAnnotationTerms(); } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/Row.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/Row.java index 45e33a9bb..d655cee49 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/Row.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/Row.java @@ -28,6 +28,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +59,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface Row - extends AbstractOpenType { + extends Annotatable,AbstractOpenType { @Key @@ -82,7 +83,7 @@ public interface Row fcKeepInContent = false) UUID getId(); - void setId(final UUID _id); + void setId(UUID _id); diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/RowCollection.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/RowCollection.java index 25099bdf8..087207322 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/RowCollection.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/RowCollection.java @@ -21,6 +21,7 @@ package org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.op import org.apache.olingo.client.api.http.HttpMethod; import org.apache.olingo.ext.proxy.api.AbstractEntityCollection; +import org.apache.olingo.ext.proxy.api.AbstractTerm; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; @@ -44,4 +45,8 @@ import java.util.Calendar; import javax.xml.datatype.Duration; public interface RowCollection extends AbstractEntityCollection<Row> { + + Object getAnnotation(Class<? extends AbstractTerm> term); + + Collection<Class<? extends AbstractTerm>> getAnnotationTerms(); } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/RowIndex.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/RowIndex.java index 9758eabce..213bcc7cc 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/RowIndex.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/RowIndex.java @@ -28,6 +28,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +59,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface RowIndex - extends AbstractOpenType { + extends Annotatable,AbstractOpenType { @Key @@ -82,7 +83,7 @@ public interface RowIndex fcKeepInContent = false) Integer getId(); - void setId(final Integer _id); + void setId(Integer _id); @@ -90,12 +91,12 @@ public interface RowIndex type = "Microsoft.Test.OData.Services.OpenTypesServiceV4.Row", targetSchema = "Microsoft.Test.OData.Services.OpenTypesServiceV4", targetContainer = "DefaultContainer", - targetEntitySet = "Row") + targetEntitySet = "Row", + containsTarget = false) org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.Row getRows(); - void setRows(final org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.Row _rows); - - + void setRows(org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.Row _rows); + } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/RowIndexCollection.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/RowIndexCollection.java index 3b20d0eca..eeeb329a1 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/RowIndexCollection.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/opentype/microsoft/test/odata/services/opentypesservicev4/types/RowIndexCollection.java @@ -21,6 +21,7 @@ package org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.op import org.apache.olingo.client.api.http.HttpMethod; import org.apache.olingo.ext.proxy.api.AbstractEntityCollection; +import org.apache.olingo.ext.proxy.api.AbstractTerm; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; @@ -44,4 +45,8 @@ import java.util.Calendar; import javax.xml.datatype.Duration; public interface RowIndexCollection extends AbstractEntityCollection<RowIndex> { + + Object getAnnotation(Class<? extends AbstractTerm> term); + + Collection<Class<? extends AbstractTerm>> getAnnotationTerms(); } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Account.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Account.java index 82d61078b..12402e3ab 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Account.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Account.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface Account - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -208,4 +210,39 @@ public interface Account org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccountInfo newAccountInfo(); } + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "AccountID", + type = "Edm.Int32") + Annotatable getAccountIDAnnotations(); + + @AnnotationsForProperty(name = "Country", + type = "Edm.String") + Annotatable getCountryAnnotations(); + + @AnnotationsForProperty(name = "AccountInfo", + type = "Microsoft.Test.OData.Services.ODataWCFService.AccountInfo") + Annotatable getAccountInfoAnnotations(); + + + + @AnnotationsForNavigationProperty(name = "MyGiftCard", + type = "Microsoft.Test.OData.Services.ODataWCFService.GiftCard") + Annotatable getMyGiftCardAnnotations(); + + @AnnotationsForNavigationProperty(name = "MyPaymentInstruments", + type = "Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument") + Annotatable getMyPaymentInstrumentsAnnotations(); + + @AnnotationsForNavigationProperty(name = "ActiveSubscriptions", + type = "Microsoft.Test.OData.Services.ODataWCFService.Subscription") + Annotatable getActiveSubscriptionsAnnotations(); + + @AnnotationsForNavigationProperty(name = "AvailableSubscriptionTemplatess", + type = "Microsoft.Test.OData.Services.ODataWCFService.Subscription") + Annotatable getAvailableSubscriptionTemplatessAnnotations(); + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/AccountInfo.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/AccountInfo.java index 597de706a..da20faaca 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/AccountInfo.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/AccountInfo.java @@ -18,10 +18,14 @@ */ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.ComplexType; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; +import org.apache.olingo.ext.proxy.api.AbstractOpenType; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.*; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.*; @@ -47,7 +51,7 @@ import javax.xml.datatype.Duration; isOpenType = true, isAbstract = false) public interface AccountInfo - extends Serializable { + extends AbstractOpenType,Serializable { @Property(name = "FirstName", @@ -85,4 +89,19 @@ public interface AccountInfo + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "FirstName", + type = "Edm.String") + Annotatable getFirstNameAnnotations(); + + @AnnotationsForProperty(name = "LastName", + type = "Edm.String") + Annotatable getLastNameAnnotations(); + + + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Address.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Address.java index 2a64ec378..40ce1f2b5 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Address.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Address.java @@ -18,10 +18,14 @@ */ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.ComplexType; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; +import org.apache.olingo.ext.proxy.api.AbstractOpenType; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.*; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.*; @@ -102,4 +106,23 @@ public interface Address + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "Street", + type = "Edm.String") + Annotatable getStreetAnnotations(); + + @AnnotationsForProperty(name = "City", + type = "Edm.String") + Annotatable getCityAnnotations(); + + @AnnotationsForProperty(name = "PostalCode", + type = "Edm.String") + Annotatable getPostalCodeAnnotations(); + + + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Asset.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Asset.java index ba5be3181..aad3273d0 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Asset.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Asset.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface Asset - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -134,4 +136,23 @@ public interface Asset + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "AssetID", + type = "Edm.Int32") + Annotatable getAssetIDAnnotations(); + + @AnnotationsForProperty(name = "Name", + type = "Edm.String") + Annotatable getNameAnnotations(); + + @AnnotationsForProperty(name = "Number", + type = "Edm.Int32") + Annotatable getNumberAnnotations(); + + + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Club.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Club.java index 6016e77c2..79d5c41d0 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Club.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Club.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface Club - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -111,4 +113,19 @@ public interface Club + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "ClubID", + type = "Edm.Int32") + Annotatable getClubIDAnnotations(); + + @AnnotationsForProperty(name = "Name", + type = "Edm.String") + Annotatable getNameAnnotations(); + + + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Company.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Company.java index 1b16a5a94..cc27967a8 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Company.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Company.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface Company - extends AbstractAnnotatable,AbstractOpenType { + extends Annotatable,AbstractOpenType { @Key @@ -247,4 +249,47 @@ public interface Company org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address newAddress(); } + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "CompanyID", + type = "Edm.Int32") + Annotatable getCompanyIDAnnotations(); + + @AnnotationsForProperty(name = "CompanyCategory", + type = "Microsoft.Test.OData.Services.ODataWCFService.CompanyCategory") + Annotatable getCompanyCategoryAnnotations(); + + @AnnotationsForProperty(name = "Revenue", + type = "Edm.Int64") + Annotatable getRevenueAnnotations(); + + @AnnotationsForProperty(name = "Name", + type = "Edm.String") + Annotatable getNameAnnotations(); + + @AnnotationsForProperty(name = "Address", + type = "Microsoft.Test.OData.Services.ODataWCFService.Address") + Annotatable getAddressAnnotations(); + + + + @AnnotationsForNavigationProperty(name = "Employees", + type = "Microsoft.Test.OData.Services.ODataWCFService.Employee") + Annotatable getEmployeesAnnotations(); + + @AnnotationsForNavigationProperty(name = "VipCustomer", + type = "Microsoft.Test.OData.Services.ODataWCFService.Customer") + Annotatable getVipCustomerAnnotations(); + + @AnnotationsForNavigationProperty(name = "Departments", + type = "Microsoft.Test.OData.Services.ODataWCFService.Department") + Annotatable getDepartmentsAnnotations(); + + @AnnotationsForNavigationProperty(name = "CoreDepartment", + type = "Microsoft.Test.OData.Services.ODataWCFService.Department") + Annotatable getCoreDepartmentAnnotations(); + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/CompanyAddress.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/CompanyAddress.java index 35c82e0a2..d4916dd46 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/CompanyAddress.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/CompanyAddress.java @@ -18,10 +18,14 @@ */ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.ComplexType; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; +import org.apache.olingo.ext.proxy.api.AbstractOpenType; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.*; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.*; @@ -48,7 +52,7 @@ import javax.xml.datatype.Duration; isAbstract = false, baseType = "Microsoft.Test.OData.Services.ODataWCFService.Address") public interface CompanyAddress - extends org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address { + extends org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address,Serializable { @Property(name = "Street", @@ -120,4 +124,28 @@ public interface CompanyAddress + + @Override + Annotations annotations(); + + interface Annotations extends org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address.Annotations{ + + @AnnotationsForProperty(name = "Street", + type = "Edm.String") + Annotatable getStreetAnnotations(); + + @AnnotationsForProperty(name = "City", + type = "Edm.String") + Annotatable getCityAnnotations(); + + @AnnotationsForProperty(name = "PostalCode", + type = "Edm.String") + Annotatable getPostalCodeAnnotations(); + + @AnnotationsForProperty(name = "CompanyName", + type = "Edm.String") + Annotatable getCompanyNameAnnotations(); + + + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/CreditCardPI.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/CreditCardPI.java index d005712e0..f14dc8955 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/CreditCardPI.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/CreditCardPI.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -59,7 +61,7 @@ import javax.xml.datatype.Duration; isAbstract = false, baseType = "Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument") public interface CreditCardPI - extends AbstractAnnotatable,org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PaymentInstrument { + extends Annotatable,org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PaymentInstrument { @Key @@ -290,4 +292,60 @@ public interface CreditCardPI + + @Override + Annotations annotations(); + + interface Annotations extends org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.PaymentInstrument.Annotations{ + + @AnnotationsForProperty(name = "PaymentInstrumentID", + type = "Edm.Int32") + Annotatable getPaymentInstrumentIDAnnotations(); + + @AnnotationsForProperty(name = "FriendlyName", + type = "Edm.String") + Annotatable getFriendlyNameAnnotations(); + + @AnnotationsForProperty(name = "CreatedDate", + type = "Edm.DateTimeOffset") + Annotatable getCreatedDateAnnotations(); + + @AnnotationsForProperty(name = "CardNumber", + type = "Edm.String") + Annotatable getCardNumberAnnotations(); + + @AnnotationsForProperty(name = "CVV", + type = "Edm.String") + Annotatable getCVVAnnotations(); + + @AnnotationsForProperty(name = "HolderName", + type = "Edm.String") + Annotatable getHolderNameAnnotations(); + + @AnnotationsForProperty(name = "Balance", + type = "Edm.Double") + Annotatable getBalanceAnnotations(); + + @AnnotationsForProperty(name = "ExperationDate", + type = "Edm.DateTimeOffset") + Annotatable getExperationDateAnnotations(); + + + + @AnnotationsForNavigationProperty(name = "TheStoredPI", + type = "Microsoft.Test.OData.Services.ODataWCFService.StoredPI") + Annotatable getTheStoredPIAnnotations(); + + @AnnotationsForNavigationProperty(name = "BillingStatements", + type = "Microsoft.Test.OData.Services.ODataWCFService.Statement") + Annotatable getBillingStatementsAnnotations(); + + @AnnotationsForNavigationProperty(name = "BackupStoredPI", + type = "Microsoft.Test.OData.Services.ODataWCFService.StoredPI") + Annotatable getBackupStoredPIAnnotations(); + + @AnnotationsForNavigationProperty(name = "CreditRecords", + type = "Microsoft.Test.OData.Services.ODataWCFService.CreditRecord") + Annotatable getCreditRecordsAnnotations(); + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/CreditRecord.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/CreditRecord.java index ca1c5934a..93a49c85b 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/CreditRecord.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/CreditRecord.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface CreditRecord - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -157,4 +159,27 @@ public interface CreditRecord + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "CreditRecordID", + type = "Edm.Int32") + Annotatable getCreditRecordIDAnnotations(); + + @AnnotationsForProperty(name = "IsGood", + type = "Edm.Boolean") + Annotatable getIsGoodAnnotations(); + + @AnnotationsForProperty(name = "Reason", + type = "Edm.String") + Annotatable getReasonAnnotations(); + + @AnnotationsForProperty(name = "CreatedDate", + type = "Edm.DateTimeOffset") + Annotatable getCreatedDateAnnotations(); + + + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Customer.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Customer.java index d545c8703..2ddbd7aa8 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Customer.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Customer.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -59,7 +61,7 @@ import javax.xml.datatype.Duration; isAbstract = false, baseType = "Microsoft.Test.OData.Services.ODataWCFService.Person") public interface Customer - extends AbstractAnnotatable,org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person { + extends Annotatable,org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person { @Key @@ -364,4 +366,68 @@ public interface Customer org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address newHomeAddress(); } + + @Override + Annotations annotations(); + + interface Annotations extends org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person.Annotations{ + + @AnnotationsForProperty(name = "PersonID", + type = "Edm.Int32") + Annotatable getPersonIDAnnotations(); + + @AnnotationsForProperty(name = "FirstName", + type = "Edm.String") + Annotatable getFirstNameAnnotations(); + + @AnnotationsForProperty(name = "LastName", + type = "Edm.String") + Annotatable getLastNameAnnotations(); + + @AnnotationsForProperty(name = "MiddleName", + type = "Edm.String") + Annotatable getMiddleNameAnnotations(); + + @AnnotationsForProperty(name = "HomeAddress", + type = "Microsoft.Test.OData.Services.ODataWCFService.Address") + Annotatable getHomeAddressAnnotations(); + + @AnnotationsForProperty(name = "Home", + type = "Edm.GeographyPoint") + Annotatable getHomeAnnotations(); + + @AnnotationsForProperty(name = "Numbers", + type = "Edm.String") + Annotatable getNumbersAnnotations(); + + @AnnotationsForProperty(name = "Emails", + type = "Edm.String") + Annotatable getEmailsAnnotations(); + + @AnnotationsForProperty(name = "City", + type = "Edm.String") + Annotatable getCityAnnotations(); + + @AnnotationsForProperty(name = "Birthday", + type = "Edm.DateTimeOffset") + Annotatable getBirthdayAnnotations(); + + @AnnotationsForProperty(name = "TimeBetweenLastTwoOrders", + type = "Edm.Duration") + Annotatable getTimeBetweenLastTwoOrdersAnnotations(); + + + + @AnnotationsForNavigationProperty(name = "Parent", + type = "Microsoft.Test.OData.Services.ODataWCFService.Person") + Annotatable getParentAnnotations(); + + @AnnotationsForNavigationProperty(name = "Orders", + type = "Microsoft.Test.OData.Services.ODataWCFService.Order") + Annotatable getOrdersAnnotations(); + + @AnnotationsForNavigationProperty(name = "Company", + type = "Microsoft.Test.OData.Services.ODataWCFService.Company") + Annotatable getCompanyAnnotations(); + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Department.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Department.java index 6eed1d3d4..f6a25314a 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Department.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Department.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface Department - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -144,4 +146,27 @@ public interface Department + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "DepartmentID", + type = "Edm.Int32") + Annotatable getDepartmentIDAnnotations(); + + @AnnotationsForProperty(name = "Name", + type = "Edm.String") + Annotatable getNameAnnotations(); + + @AnnotationsForProperty(name = "DepartmentNO", + type = "Edm.String") + Annotatable getDepartmentNOAnnotations(); + + + + @AnnotationsForNavigationProperty(name = "Company", + type = "Microsoft.Test.OData.Services.ODataWCFService.Company") + Annotatable getCompanyAnnotations(); + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Employee.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Employee.java index 87c1486d9..16f707481 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Employee.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Employee.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -59,7 +61,7 @@ import javax.xml.datatype.Duration; isAbstract = false, baseType = "Microsoft.Test.OData.Services.ODataWCFService.Person") public interface Employee - extends AbstractAnnotatable,org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person { + extends Annotatable,org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person { @Key @@ -331,4 +333,60 @@ public interface Employee org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address newHomeAddress(); } + + @Override + Annotations annotations(); + + interface Annotations extends org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Person.Annotations{ + + @AnnotationsForProperty(name = "PersonID", + type = "Edm.Int32") + Annotatable getPersonIDAnnotations(); + + @AnnotationsForProperty(name = "FirstName", + type = "Edm.String") + Annotatable getFirstNameAnnotations(); + + @AnnotationsForProperty(name = "LastName", + type = "Edm.String") + Annotatable getLastNameAnnotations(); + + @AnnotationsForProperty(name = "MiddleName", + type = "Edm.String") + Annotatable getMiddleNameAnnotations(); + + @AnnotationsForProperty(name = "HomeAddress", + type = "Microsoft.Test.OData.Services.ODataWCFService.Address") + Annotatable getHomeAddressAnnotations(); + + @AnnotationsForProperty(name = "Home", + type = "Edm.GeographyPoint") + Annotatable getHomeAnnotations(); + + @AnnotationsForProperty(name = "Numbers", + type = "Edm.String") + Annotatable getNumbersAnnotations(); + + @AnnotationsForProperty(name = "Emails", + type = "Edm.String") + Annotatable getEmailsAnnotations(); + + @AnnotationsForProperty(name = "DateHired", + type = "Edm.DateTimeOffset") + Annotatable getDateHiredAnnotations(); + + @AnnotationsForProperty(name = "Office", + type = "Edm.GeographyPoint") + Annotatable getOfficeAnnotations(); + + + + @AnnotationsForNavigationProperty(name = "Parent", + type = "Microsoft.Test.OData.Services.ODataWCFService.Person") + Annotatable getParentAnnotations(); + + @AnnotationsForNavigationProperty(name = "Company", + type = "Microsoft.Test.OData.Services.ODataWCFService.Company") + Annotatable getCompanyAnnotations(); + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/GiftCard.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/GiftCard.java index e4ccfe2a2..4d009814e 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/GiftCard.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/GiftCard.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface GiftCard - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -193,4 +195,31 @@ public interface GiftCard } + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "GiftCardID", + type = "Edm.Int32") + Annotatable getGiftCardIDAnnotations(); + + @AnnotationsForProperty(name = "GiftCardNO", + type = "Edm.String") + Annotatable getGiftCardNOAnnotations(); + + @AnnotationsForProperty(name = "Amount", + type = "Edm.Double") + Annotatable getAmountAnnotations(); + + @AnnotationsForProperty(name = "ExperationDate", + type = "Edm.DateTimeOffset") + Annotatable getExperationDateAnnotations(); + + @AnnotationsForProperty(name = "OwnerName", + type = "Edm.String") + Annotatable getOwnerNameAnnotations(); + + + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/HomeAddress.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/HomeAddress.java index 9327fe8ed..d67155c9b 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/HomeAddress.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/HomeAddress.java @@ -18,10 +18,14 @@ */ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.ComplexType; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; +import org.apache.olingo.ext.proxy.api.AbstractOpenType; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.*; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.*; @@ -48,7 +52,7 @@ import javax.xml.datatype.Duration; isAbstract = false, baseType = "Microsoft.Test.OData.Services.ODataWCFService.Address") public interface HomeAddress - extends org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address { + extends org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address,Serializable { @Property(name = "Street", @@ -120,4 +124,28 @@ public interface HomeAddress + + @Override + Annotations annotations(); + + interface Annotations extends org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address.Annotations{ + + @AnnotationsForProperty(name = "Street", + type = "Edm.String") + Annotatable getStreetAnnotations(); + + @AnnotationsForProperty(name = "City", + type = "Edm.String") + Annotatable getCityAnnotations(); + + @AnnotationsForProperty(name = "PostalCode", + type = "Edm.String") + Annotatable getPostalCodeAnnotations(); + + @AnnotationsForProperty(name = "FamilyName", + type = "Edm.String") + Annotatable getFamilyNameAnnotations(); + + + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/LabourUnion.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/LabourUnion.java index 699b417ec..dded85d93 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/LabourUnion.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/LabourUnion.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface LabourUnion - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -111,4 +113,19 @@ public interface LabourUnion + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "LabourUnionID", + type = "Edm.Int32") + Annotatable getLabourUnionIDAnnotations(); + + @AnnotationsForProperty(name = "Name", + type = "Edm.String") + Annotatable getNameAnnotations(); + + + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Order.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Order.java index 2d3ea17e9..f1ad3dcde 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Order.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Order.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface Order - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -187,4 +189,39 @@ public interface Order + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "OrderID", + type = "Edm.Int32") + Annotatable getOrderIDAnnotations(); + + @AnnotationsForProperty(name = "OrderDate", + type = "Edm.DateTimeOffset") + Annotatable getOrderDateAnnotations(); + + @AnnotationsForProperty(name = "ShelfLife", + type = "Edm.Duration") + Annotatable getShelfLifeAnnotations(); + + @AnnotationsForProperty(name = "OrderShelfLifes", + type = "Edm.Duration") + Annotatable getOrderShelfLifesAnnotations(); + + + + @AnnotationsForNavigationProperty(name = "LoggedInEmployee", + type = "Microsoft.Test.OData.Services.ODataWCFService.Employee") + Annotatable getLoggedInEmployeeAnnotations(); + + @AnnotationsForNavigationProperty(name = "CustomerForOrder", + type = "Microsoft.Test.OData.Services.ODataWCFService.Customer") + Annotatable getCustomerForOrderAnnotations(); + + @AnnotationsForNavigationProperty(name = "OrderDetails", + type = "Microsoft.Test.OData.Services.ODataWCFService.OrderDetail") + Annotatable getOrderDetailsAnnotations(); + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/OrderDetail.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/OrderDetail.java index f8b0ca396..865cc7215 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/OrderDetail.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/OrderDetail.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface OrderDetail - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -200,4 +202,39 @@ public interface OrderDetail + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "OrderID", + type = "Edm.Int32") + Annotatable getOrderIDAnnotations(); + + @AnnotationsForProperty(name = "ProductID", + type = "Edm.Int32") + Annotatable getProductIDAnnotations(); + + @AnnotationsForProperty(name = "OrderPlaced", + type = "Edm.DateTimeOffset") + Annotatable getOrderPlacedAnnotations(); + + @AnnotationsForProperty(name = "Quantity", + type = "Edm.Int32") + Annotatable getQuantityAnnotations(); + + @AnnotationsForProperty(name = "UnitPrice", + type = "Edm.Single") + Annotatable getUnitPriceAnnotations(); + + + + @AnnotationsForNavigationProperty(name = "ProductOrdered", + type = "Microsoft.Test.OData.Services.ODataWCFService.Product") + Annotatable getProductOrderedAnnotations(); + + @AnnotationsForNavigationProperty(name = "AssociatedOrder", + type = "Microsoft.Test.OData.Services.ODataWCFService.Order") + Annotatable getAssociatedOrderAnnotations(); + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/PaymentInstrument.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/PaymentInstrument.java index 2915a94cf..1e982b5ea 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/PaymentInstrument.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/PaymentInstrument.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface PaymentInstrument - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -164,4 +166,35 @@ public interface PaymentInstrument + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "PaymentInstrumentID", + type = "Edm.Int32") + Annotatable getPaymentInstrumentIDAnnotations(); + + @AnnotationsForProperty(name = "FriendlyName", + type = "Edm.String") + Annotatable getFriendlyNameAnnotations(); + + @AnnotationsForProperty(name = "CreatedDate", + type = "Edm.DateTimeOffset") + Annotatable getCreatedDateAnnotations(); + + + + @AnnotationsForNavigationProperty(name = "TheStoredPI", + type = "Microsoft.Test.OData.Services.ODataWCFService.StoredPI") + Annotatable getTheStoredPIAnnotations(); + + @AnnotationsForNavigationProperty(name = "BillingStatements", + type = "Microsoft.Test.OData.Services.ODataWCFService.Statement") + Annotatable getBillingStatementsAnnotations(); + + @AnnotationsForNavigationProperty(name = "BackupStoredPI", + type = "Microsoft.Test.OData.Services.ODataWCFService.StoredPI") + Annotatable getBackupStoredPIAnnotations(); + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Person.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Person.java index ec17476a3..fcd58ffee 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Person.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Person.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface Person - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -287,4 +289,47 @@ public interface Person org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address newHomeAddress(); } + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "PersonID", + type = "Edm.Int32") + Annotatable getPersonIDAnnotations(); + + @AnnotationsForProperty(name = "FirstName", + type = "Edm.String") + Annotatable getFirstNameAnnotations(); + + @AnnotationsForProperty(name = "LastName", + type = "Edm.String") + Annotatable getLastNameAnnotations(); + + @AnnotationsForProperty(name = "MiddleName", + type = "Edm.String") + Annotatable getMiddleNameAnnotations(); + + @AnnotationsForProperty(name = "HomeAddress", + type = "Microsoft.Test.OData.Services.ODataWCFService.Address") + Annotatable getHomeAddressAnnotations(); + + @AnnotationsForProperty(name = "Home", + type = "Edm.GeographyPoint") + Annotatable getHomeAnnotations(); + + @AnnotationsForProperty(name = "Numbers", + type = "Edm.String") + Annotatable getNumbersAnnotations(); + + @AnnotationsForProperty(name = "Emails", + type = "Edm.String") + Annotatable getEmailsAnnotations(); + + + + @AnnotationsForNavigationProperty(name = "Parent", + type = "Microsoft.Test.OData.Services.ODataWCFService.Person") + Annotatable getParentAnnotations(); + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Product.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Product.java index 88e84bc90..8d6032467 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Product.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Product.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface Product - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -302,4 +304,51 @@ public interface Product } + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "ProductID", + type = "Edm.Int32") + Annotatable getProductIDAnnotations(); + + @AnnotationsForProperty(name = "Name", + type = "Edm.String") + Annotatable getNameAnnotations(); + + @AnnotationsForProperty(name = "QuantityPerUnit", + type = "Edm.String") + Annotatable getQuantityPerUnitAnnotations(); + + @AnnotationsForProperty(name = "UnitPrice", + type = "Edm.Single") + Annotatable getUnitPriceAnnotations(); + + @AnnotationsForProperty(name = "QuantityInStock", + type = "Edm.Int32") + Annotatable getQuantityInStockAnnotations(); + + @AnnotationsForProperty(name = "Discontinued", + type = "Edm.Boolean") + Annotatable getDiscontinuedAnnotations(); + + @AnnotationsForProperty(name = "UserAccess", + type = "Microsoft.Test.OData.Services.ODataWCFService.AccessLevel") + Annotatable getUserAccessAnnotations(); + + @AnnotationsForProperty(name = "SkinColor", + type = "Microsoft.Test.OData.Services.ODataWCFService.Color") + Annotatable getSkinColorAnnotations(); + + @AnnotationsForProperty(name = "CoverColors", + type = "Microsoft.Test.OData.Services.ODataWCFService.Color") + Annotatable getCoverColorsAnnotations(); + + + + @AnnotationsForNavigationProperty(name = "Details", + type = "Microsoft.Test.OData.Services.ODataWCFService.ProductDetail") + Annotatable getDetailsAnnotations(); + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/ProductDetail.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/ProductDetail.java index adb1b8446..154d2c00a 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/ProductDetail.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/ProductDetail.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface ProductDetail - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -189,4 +191,35 @@ public interface ProductDetail } + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "ProductID", + type = "Edm.Int32") + Annotatable getProductIDAnnotations(); + + @AnnotationsForProperty(name = "ProductDetailID", + type = "Edm.Int32") + Annotatable getProductDetailIDAnnotations(); + + @AnnotationsForProperty(name = "ProductName", + type = "Edm.String") + Annotatable getProductNameAnnotations(); + + @AnnotationsForProperty(name = "Description", + type = "Edm.String") + Annotatable getDescriptionAnnotations(); + + + + @AnnotationsForNavigationProperty(name = "RelatedProduct", + type = "Microsoft.Test.OData.Services.ODataWCFService.Product") + Annotatable getRelatedProductAnnotations(); + + @AnnotationsForNavigationProperty(name = "Reviews", + type = "Microsoft.Test.OData.Services.ODataWCFService.ProductReview") + Annotatable getReviewsAnnotations(); + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/ProductReview.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/ProductReview.java index 5c982a787..fcee35c8b 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/ProductReview.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/ProductReview.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface ProductReview - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -203,4 +205,35 @@ public interface ProductReview + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "ProductID", + type = "Edm.Int32") + Annotatable getProductIDAnnotations(); + + @AnnotationsForProperty(name = "ProductDetailID", + type = "Edm.Int32") + Annotatable getProductDetailIDAnnotations(); + + @AnnotationsForProperty(name = "ReviewTitle", + type = "Edm.String") + Annotatable getReviewTitleAnnotations(); + + @AnnotationsForProperty(name = "RevisionID", + type = "Edm.Int32") + Annotatable getRevisionIDAnnotations(); + + @AnnotationsForProperty(name = "Comment", + type = "Edm.String") + Annotatable getCommentAnnotations(); + + @AnnotationsForProperty(name = "Author", + type = "Edm.String") + Annotatable getAuthorAnnotations(); + + + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/PublicCompany.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/PublicCompany.java index 31aa47015..d856468d3 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/PublicCompany.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/PublicCompany.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -59,7 +61,7 @@ import javax.xml.datatype.Duration; isAbstract = false, baseType = "Microsoft.Test.OData.Services.ODataWCFService.Company") public interface PublicCompany - extends AbstractAnnotatable,org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Company { + extends Annotatable,org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Company { @Key @@ -289,4 +291,64 @@ public interface PublicCompany org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Address newAddress(); } + + @Override + Annotations annotations(); + + interface Annotations extends org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Company.Annotations{ + + @AnnotationsForProperty(name = "CompanyID", + type = "Edm.Int32") + Annotatable getCompanyIDAnnotations(); + + @AnnotationsForProperty(name = "CompanyCategory", + type = "Microsoft.Test.OData.Services.ODataWCFService.CompanyCategory") + Annotatable getCompanyCategoryAnnotations(); + + @AnnotationsForProperty(name = "Revenue", + type = "Edm.Int64") + Annotatable getRevenueAnnotations(); + + @AnnotationsForProperty(name = "Name", + type = "Edm.String") + Annotatable getNameAnnotations(); + + @AnnotationsForProperty(name = "Address", + type = "Microsoft.Test.OData.Services.ODataWCFService.Address") + Annotatable getAddressAnnotations(); + + @AnnotationsForProperty(name = "StockExchange", + type = "Edm.String") + Annotatable getStockExchangeAnnotations(); + + + + @AnnotationsForNavigationProperty(name = "Employees", + type = "Microsoft.Test.OData.Services.ODataWCFService.Employee") + Annotatable getEmployeesAnnotations(); + + @AnnotationsForNavigationProperty(name = "VipCustomer", + type = "Microsoft.Test.OData.Services.ODataWCFService.Customer") + Annotatable getVipCustomerAnnotations(); + + @AnnotationsForNavigationProperty(name = "Departments", + type = "Microsoft.Test.OData.Services.ODataWCFService.Department") + Annotatable getDepartmentsAnnotations(); + + @AnnotationsForNavigationProperty(name = "CoreDepartment", + type = "Microsoft.Test.OData.Services.ODataWCFService.Department") + Annotatable getCoreDepartmentAnnotations(); + + @AnnotationsForNavigationProperty(name = "Assets", + type = "Microsoft.Test.OData.Services.ODataWCFService.Asset") + Annotatable getAssetsAnnotations(); + + @AnnotationsForNavigationProperty(name = "Club", + type = "Microsoft.Test.OData.Services.ODataWCFService.Club") + Annotatable getClubAnnotations(); + + @AnnotationsForNavigationProperty(name = "LabourUnion", + type = "Microsoft.Test.OData.Services.ODataWCFService.LabourUnion") + Annotatable getLabourUnionAnnotations(); + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Statement.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Statement.java index e12c0f16b..fb86a3868 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Statement.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Statement.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface Statement - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -157,4 +159,27 @@ public interface Statement + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "StatementID", + type = "Edm.Int32") + Annotatable getStatementIDAnnotations(); + + @AnnotationsForProperty(name = "TransactionType", + type = "Edm.String") + Annotatable getTransactionTypeAnnotations(); + + @AnnotationsForProperty(name = "TransactionDescription", + type = "Edm.String") + Annotatable getTransactionDescriptionAnnotations(); + + @AnnotationsForProperty(name = "Amount", + type = "Edm.Double") + Annotatable getAmountAnnotations(); + + + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/StoredPI.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/StoredPI.java index 0a31c18aa..bad03e481 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/StoredPI.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/StoredPI.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface StoredPI - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -157,4 +159,27 @@ public interface StoredPI + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "StoredPIID", + type = "Edm.Int32") + Annotatable getStoredPIIDAnnotations(); + + @AnnotationsForProperty(name = "PIName", + type = "Edm.String") + Annotatable getPINameAnnotations(); + + @AnnotationsForProperty(name = "PIType", + type = "Edm.String") + Annotatable getPITypeAnnotations(); + + @AnnotationsForProperty(name = "CreatedDate", + type = "Edm.DateTimeOffset") + Annotatable getCreatedDateAnnotations(); + + + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Subscription.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Subscription.java index 17dd86562..e72bdfd86 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Subscription.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/staticservice/microsoft/test/odata/services/odatawcfservice/types/Subscription.java @@ -19,6 +19,8 @@ package org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForProperty; +import org.apache.olingo.ext.proxy.api.annotations.AnnotationsForNavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Namespace; import org.apache.olingo.ext.proxy.api.annotations.EntityType; import org.apache.olingo.ext.proxy.api.annotations.Key; @@ -27,7 +29,7 @@ import org.apache.olingo.ext.proxy.api.annotations.NavigationProperty; import org.apache.olingo.ext.proxy.api.annotations.Property; import org.apache.olingo.ext.proxy.api.annotations.Operation; import org.apache.olingo.ext.proxy.api.annotations.Parameter; -import org.apache.olingo.ext.proxy.api.AbstractAnnotatable; +import org.apache.olingo.ext.proxy.api.Annotatable; import org.apache.olingo.ext.proxy.api.AbstractOpenType; import org.apache.olingo.ext.proxy.api.OperationType; import org.apache.olingo.commons.api.edm.constants.EdmContentKind; @@ -58,7 +60,7 @@ import javax.xml.datatype.Duration; hasStream = false, isAbstract = false) public interface Subscription - extends AbstractAnnotatable,Serializable { + extends Annotatable,Serializable { @Key @@ -180,4 +182,31 @@ public interface Subscription + + Annotations annotations(); + + interface Annotations { + + @AnnotationsForProperty(name = "SubscriptionID", + type = "Edm.Int32") + Annotatable getSubscriptionIDAnnotations(); + + @AnnotationsForProperty(name = "TemplateGuid", + type = "Edm.String") + Annotatable getTemplateGuidAnnotations(); + + @AnnotationsForProperty(name = "Title", + type = "Edm.String") + Annotatable getTitleAnnotations(); + + @AnnotationsForProperty(name = "Category", + type = "Edm.String") + Annotatable getCategoryAnnotations(); + + @AnnotationsForProperty(name = "CreatedDate", + type = "Edm.DateTimeOffset") + Annotatable getCreatedDateAnnotations(); + + + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/AbstractTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/AbstractTestITCase.java index fc2bbaee1..d9bf300c9 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/AbstractTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/AbstractTestITCase.java @@ -329,7 +329,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase { final ODataEntity original, final String entitySetName) { - final URIBuilder uriBuilder = getClient().getURIBuilder(serviceRootURL). + final URIBuilder uriBuilder = getClient().newURIBuilder(serviceRootURL). appendEntitySetSegment(entitySetName); debugODataEntity(original, "About to create"); @@ -356,7 +356,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase { final int actualObjectId, final Collection<String> expands) { - final URIBuilder uriBuilder = getClient().getURIBuilder(serviceRootURL). + final URIBuilder uriBuilder = getClient().newURIBuilder(serviceRootURL). appendEntitySetSegment("Customer").appendKeySegment(actualObjectId); // search expanded diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/ActionOverloadingTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/ActionOverloadingTestITCase.java index de6d62d89..d9e617b9f 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/ActionOverloadingTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/ActionOverloadingTestITCase.java @@ -19,7 +19,6 @@ package org.apache.olingo.fit.v3; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; import static org.junit.Assert.assertEquals; import java.util.LinkedHashMap; @@ -27,120 +26,69 @@ import java.util.Map; import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent; import org.apache.olingo.client.api.communication.response.ODataInvokeResponse; import org.apache.olingo.client.api.uri.v3.URIBuilder; -import org.apache.olingo.client.core.uri.URIUtils; import org.apache.olingo.commons.api.domain.ODataValue; import org.apache.olingo.commons.api.domain.v3.ODataEntity; import org.apache.olingo.commons.api.domain.v3.ODataEntitySet; import org.apache.olingo.commons.api.domain.v3.ODataProperty; -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAction; -import org.apache.olingo.commons.api.edm.EdmActionImport; -import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; -import org.apache.olingo.commons.api.edm.EdmSchema; -import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32; import org.junit.Test; public class ActionOverloadingTestITCase extends AbstractTestITCase { @Test public void retrieveProduct() throws EdmPrimitiveTypeException { - final Edm edm = getClient().getRetrieveRequestFactory(). - getMetadataRequest(testActionOverloadingServiceRootURL).execute().getBody(); - assertNotNull(edm); + final String actionImportName = "RetrieveProduct"; - final EdmEntityContainer container = edm.getSchemas().get(0).getEntityContainer(); - assertNotNull(container); + // 1. unbound + final URIBuilder builder = getClient().newURIBuilder(testActionOverloadingServiceRootURL). + appendOperationCallSegment(actionImportName); + final ODataInvokeResponse<ODataProperty> unboundRes = getClient().getInvokeRequestFactory(). + getActionInvokeRequest(builder.build(), ODataProperty.class).execute(); + assertNotNull(unboundRes); + assertEquals(200, unboundRes.getStatusCode()); + assertEquals(Integer.valueOf(-10), unboundRes.getBody().getPrimitiveValue().toCastValue(Integer.class)); - int execs = 0; - for (EdmActionImport actImp : container.getActionImports()) { - if ("RetrieveProduct".equals(actImp.getName())) { - // 1. unbound - final EdmAction unbound = actImp.getUnboundAction(); - assertNotNull(unbound); - assertEquals(EdmInt32.getInstance(), unbound.getReturnType().getType()); + // 2. bound to Product + final ODataEntity product = getClient().getRetrieveRequestFactory().getEntityRequest( + getClient().newURIBuilder(testActionOverloadingServiceRootURL). + appendEntitySetSegment("Product").appendKeySegment(-10).build()). + execute().getBody(); + assertNotNull(product); - final URIBuilder unboundBuilder = getClient().getURIBuilder(testActionOverloadingServiceRootURL). - appendOperationCallSegment(URIUtils.operationImportURISegment(container, actImp.getName())); - final ODataInvokeResponse<ODataProperty> unboundRes = getClient().getInvokeRequestFactory(). - <ODataProperty>getInvokeRequest(unboundBuilder.build(), unbound).execute(); - assertNotNull(unboundRes); - assertEquals(200, unboundRes.getStatusCode()); - assertEquals(Integer.valueOf(-10), unboundRes.getBody().getPrimitiveValue().toCastValue(Integer.class)); - execs++; + final ODataInvokeResponse<ODataProperty> productBoundRes = getClient().getInvokeRequestFactory(). + getActionInvokeRequest(product.getOperation(actionImportName).getTarget(), ODataProperty.class). + execute(); + assertNotNull(productBoundRes); + assertEquals(200, productBoundRes.getStatusCode()); + assertEquals(Integer.valueOf(-10), productBoundRes.getBody().getPrimitiveValue().toCastValue(Integer.class)); - // 2. bound to Product - final EdmAction productBound = edm.getBoundAction( - new FullQualifiedName(container.getNamespace(), actImp.getName()), - new FullQualifiedName(container.getNamespace(), "Product"), false); - assertNotNull(productBound); - assertEquals(EdmInt32.getInstance(), productBound.getReturnType().getType()); + // 3. bound to OrderLine + final Map<String, Object> key = new LinkedHashMap<String, Object>(2); + key.put("OrderId", -10); + key.put("ProductId", -10); + final ODataEntity orderLine = getClient().getRetrieveRequestFactory().getEntityRequest( + getClient().newURIBuilder(testActionOverloadingServiceRootURL). + appendEntitySetSegment("OrderLine").appendKeySegment(key).build()). + execute().getBody(); + assertNotNull(orderLine); - final ODataEntity product = getClient().getRetrieveRequestFactory().getEntityRequest( - getClient().getURIBuilder(testActionOverloadingServiceRootURL). - appendEntitySetSegment("Product").appendKeySegment(-10).build()). - execute().getBody(); - assertNotNull(product); - - final ODataInvokeResponse<ODataProperty> productBoundRes = getClient().getInvokeRequestFactory(). - <ODataProperty>getInvokeRequest(product.getOperation(actImp.getName()).getTarget(), unbound). - execute(); - assertNotNull(productBoundRes); - assertEquals(200, productBoundRes.getStatusCode()); - assertEquals(Integer.valueOf(-10), productBoundRes.getBody().getPrimitiveValue().toCastValue(Integer.class)); - execs++; - - // 3. bound to OrderLine - final EdmAction orderLineBound = edm.getBoundAction( - new FullQualifiedName(container.getNamespace(), actImp.getName()), - new FullQualifiedName(container.getNamespace(), "OrderLine"), false); - assertNotNull(orderLineBound); - assertEquals(EdmInt32.getInstance(), orderLineBound.getReturnType().getType()); - - final Map<String, Object> key = new LinkedHashMap<String, Object>(2); - key.put("OrderId", -10); - key.put("ProductId", -10); - final ODataEntity orderLine = getClient().getRetrieveRequestFactory().getEntityRequest( - getClient().getURIBuilder(testActionOverloadingServiceRootURL). - appendEntitySetSegment("OrderLine").appendKeySegment(key).build()). - execute().getBody(); - assertNotNull(orderLine); - - final ODataInvokeResponse<ODataProperty> orderLineBoundRes = getClient().getInvokeRequestFactory(). - <ODataProperty>getInvokeRequest(orderLine.getOperation(actImp.getName()).getTarget(), unbound). - execute(); - assertNotNull(orderLineBoundRes); - assertEquals(200, orderLineBoundRes.getStatusCode()); - assertEquals(Integer.valueOf(-10), orderLineBoundRes.getBody().getPrimitiveValue().toCastValue(Integer.class)); - execs++; - } - } - assertEquals(3, execs); + final ODataInvokeResponse<ODataProperty> orderLineBoundRes = getClient().getInvokeRequestFactory(). + getActionInvokeRequest(orderLine.getOperation(actionImportName).getTarget(), ODataProperty.class). + execute(); + assertNotNull(orderLineBoundRes); + assertEquals(200, orderLineBoundRes.getStatusCode()); + assertEquals(Integer.valueOf(-10), orderLineBoundRes.getBody().getPrimitiveValue().toCastValue(Integer.class)); } @Test public void increaseSalaries() { - final Edm edm = getClient().getRetrieveRequestFactory(). - getMetadataRequest(testActionOverloadingServiceRootURL).execute().getBody(); - assertNotNull(edm); - - final EdmSchema schema = edm.getSchemas().get(0); - assertNotNull(schema); - - EdmAction actImp = edm.getBoundAction( - new FullQualifiedName(schema.getNamespace(), "IncreaseSalaries"), - new FullQualifiedName(schema.getNamespace(), "Employee"), - true); + final String actionImportName = "IncreaseSalaries"; final Map<String, ODataValue> parameters = new LinkedHashMap<String, ODataValue>(1); parameters.put("n", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(5)); // 1. bound to employees - assertNotNull(actImp); - assertNull(actImp.getReturnType()); - - final URIBuilder employeeBuilder = getClient().getURIBuilder(testActionOverloadingServiceRootURL). + final URIBuilder employeeBuilder = getClient().newURIBuilder(testActionOverloadingServiceRootURL). appendEntitySetSegment("Person"). appendDerivedEntityTypeSegment("Microsoft.Test.OData.Services.AstoriaDefaultService.Employee"); final ODataEntitySet employees = getClient().getRetrieveRequestFactory().getEntitySetRequest( @@ -148,20 +96,13 @@ public class ActionOverloadingTestITCase extends AbstractTestITCase { assertNotNull(employees); final ODataInvokeResponse<ODataNoContent> employeeRes = getClient().getInvokeRequestFactory(). - <ODataNoContent>getInvokeRequest(employeeBuilder.appendOperationCallSegment(actImp.getName()).build(), - actImp, parameters).execute(); + getActionInvokeRequest(employeeBuilder.appendOperationCallSegment(actionImportName).build(), + ODataNoContent.class, parameters).execute(); assertNotNull(employeeRes); assertEquals(204, employeeRes.getStatusCode()); // 2. bound to special employees - actImp = edm.getBoundAction( - new FullQualifiedName(schema.getNamespace(), "IncreaseSalaries"), - new FullQualifiedName(schema.getNamespace(), "SpecialEmployee"), - true); - assertNotNull(actImp); - assertNull(actImp.getReturnType()); - - final URIBuilder specEmpBuilder = getClient().getURIBuilder(testActionOverloadingServiceRootURL). + final URIBuilder specEmpBuilder = getClient().newURIBuilder(testActionOverloadingServiceRootURL). appendEntitySetSegment("Person"). appendDerivedEntityTypeSegment("Microsoft.Test.OData.Services.AstoriaDefaultService.SpecialEmployee"); final ODataEntitySet specEmps = getClient().getRetrieveRequestFactory().getEntitySetRequest( @@ -169,8 +110,8 @@ public class ActionOverloadingTestITCase extends AbstractTestITCase { assertNotNull(specEmps); final ODataInvokeResponse<ODataNoContent> specEmpsRes = getClient().getInvokeRequestFactory(). - <ODataNoContent>getInvokeRequest(specEmpBuilder.appendOperationCallSegment(actImp.getName()).build(), - actImp, parameters).execute(); + getActionInvokeRequest(specEmpBuilder.appendOperationCallSegment(actionImportName).build(), + ODataNoContent.class, parameters).execute(); assertNotNull(specEmpsRes); assertEquals(204, specEmpsRes.getStatusCode()); } diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java index 5b10eb16e..d28bea2d7 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/AsyncTestITCase.java @@ -44,7 +44,7 @@ public class AsyncTestITCase extends AbstractTestITCase { @Test public void retrieveEntitySet() throws InterruptedException, ExecutionException { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Product"); final Future<ODataRetrieveResponse<ODataEntitySet>> futureRes = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()).asyncExecute(); @@ -62,7 +62,7 @@ public class AsyncTestITCase extends AbstractTestITCase { @Test public void updateEntity() throws InterruptedException, ExecutionException { - final URI uri = client.getURIBuilder(testStaticServiceRootURL). + final URI uri = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Product").appendKeySegment(-10).build(); final ODataRetrieveResponse<ODataEntity> entityRes = client.getRetrieveRequestFactory(). @@ -93,15 +93,15 @@ public class AsyncTestITCase extends AbstractTestITCase { @Test public void createMediaEntity() throws Exception { - URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car"); + URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car"); final String TO_BE_UPDATED = "async buffered stream sample"; final InputStream input = IOUtils.toInputStream(TO_BE_UPDATED); final ODataMediaEntityCreateRequest<ODataEntity> createReq = - client.getStreamedRequestFactory().getMediaEntityCreateRequest(builder.build(), input); + client.getCUDRequestFactory().getMediaEntityCreateRequest(builder.build(), input); - final MediaEntityCreateStreamManager<ODataEntity> streamManager = createReq.execute(); + final MediaEntityCreateStreamManager<ODataEntity> streamManager = createReq.payloadManager(); final Future<ODataMediaEntityCreateResponse<ODataEntity>> futureCreateRes = streamManager.getAsyncResponse(); while (!futureCreateRes.isDone()) { @@ -119,10 +119,9 @@ public class AsyncTestITCase extends AbstractTestITCase { ? created.getProperties().get(0).getPrimitiveValue().toCastValue(Integer.class) : created.getProperties().get(1).getPrimitiveValue().toCastValue(Integer.class); - builder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Car").appendKeySegment(id).appendValueSegment(); + builder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car").appendKeySegment(id); - final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build()); + final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build()); final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute(); assertEquals(200, retrieveRes.getStatusCode()); diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/BatchTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/BatchTestITCase.java index 3b7367185..18ebaad48 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/BatchTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/BatchTestITCase.java @@ -30,11 +30,10 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.apache.http.HttpResponse; import org.apache.olingo.client.api.ODataBatchConstants; -import org.apache.olingo.client.api.communication.request.ODataStreamManager; -import org.apache.olingo.client.api.communication.request.batch.BatchStreamManager; +import org.apache.olingo.client.api.communication.request.ODataPayloadManager; +import org.apache.olingo.client.api.communication.request.batch.BatchManager; import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem; import org.apache.olingo.client.api.communication.request.batch.ODataChangeset; -import org.apache.olingo.client.api.communication.request.batch.ODataRetrieve; import org.apache.olingo.client.api.communication.request.batch.v3.ODataBatchRequest; import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest; import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest; @@ -50,7 +49,7 @@ import org.apache.olingo.client.api.uri.v3.URIBuilder; import org.apache.olingo.client.core.communication.request.AbstractODataStreamManager; import org.apache.olingo.client.core.communication.request.Wrapper; import org.apache.olingo.client.core.communication.request.batch.ODataChangesetResponseItem; -import org.apache.olingo.client.core.communication.request.batch.ODataRetrieveResponseItem; +import org.apache.olingo.client.core.communication.request.batch.ODataSingleResponseItem; import org.apache.olingo.client.core.communication.request.retrieve.ODataEntityRequestImpl; import org.apache.olingo.client.core.communication.request.retrieve.ODataEntityRequestImpl.ODataEntityResponseImpl; import org.apache.olingo.client.core.uri.URIUtils; @@ -90,7 +89,7 @@ public class BatchTestITCase extends AbstractTestITCase { // create your request final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testStaticServiceRootURL); - final BatchStreamManager payload = request.execute(); + final BatchManager payload = request.payloadManager(); final ODataBatchResponse response = payload.getResponse(); assertEquals(202, response.getStatusCode()); @@ -105,13 +104,13 @@ public class BatchTestITCase extends AbstractTestITCase { // create your request final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testStaticServiceRootURL); - final BatchStreamManager payload = request.execute(); + final BatchManager payload = request.payloadManager(); final ODataChangeset changeset = payload.addChangeset(); URIBuilder targetURI; ODataEntityCreateRequest<ODataEntity> createReq; - targetURI = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customer"); + targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customer"); for (int i = 1; i <= 2; i++) { // Create Customer into the changeset createReq = client.getCUDRequestFactory().getEntityCreateRequest( @@ -121,14 +120,14 @@ public class BatchTestITCase extends AbstractTestITCase { changeset.addRequest(createReq); } - targetURI = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("WrongEntitySet"); + targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("WrongEntitySet"); createReq = client.getCUDRequestFactory().getEntityCreateRequest( targetURI.build(), getSampleCustomerProfile(105, "Sample customer", false)); createReq.setFormat(ODataPubFormat.JSON); changeset.addRequest(createReq); - targetURI = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customer"); + targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customer"); for (int i = 3; i <= 4; i++) { // Create Customer into the changeset createReq = client.getCUDRequestFactory().getEntityCreateRequest( @@ -158,12 +157,12 @@ public class BatchTestITCase extends AbstractTestITCase { public void changesetWithReference() throws EdmPrimitiveTypeException { // create your request final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testStaticServiceRootURL); - final BatchStreamManager streamManager = request.execute(); + final BatchManager streamManager = request.payloadManager(); final ODataChangeset changeset = streamManager.addChangeset(); ODataEntity customer = getSampleCustomerProfile(20, "sample customer", false); - URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customer"); + URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customer"); // add create request final ODataEntityCreateRequest<ODataEntity> createReq = @@ -178,7 +177,7 @@ public class BatchTestITCase extends AbstractTestITCase { final ODataEntity customerChanges = client.getObjectFactory().newEntity(customer.getTypeName()); customerChanges.addLink(client.getObjectFactory().newEntityNavigationLink( "Info", - client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("CustomerInfo"). + client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("CustomerInfo"). appendKeySegment(17).build())); final ODataEntityUpdateRequest<ODataEntity> updateReq = client.getCUDRequestFactory().getEntityUpdateRequest( @@ -234,7 +233,7 @@ public class BatchTestITCase extends AbstractTestITCase { public void updateLinkWithReference() throws EdmPrimitiveTypeException { // create your request final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testStaticServiceRootURL); - final BatchStreamManager streamManager = request.execute(); + final BatchManager streamManager = request.payloadManager(); final ODataChangeset changeset = streamManager.addChangeset(); @@ -245,7 +244,7 @@ public class BatchTestITCase extends AbstractTestITCase { info.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Information", client.getObjectFactory().newPrimitiveValueBuilder().buildString("Sample information about customer 30"))); - URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("CustomerInfo"); + URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("CustomerInfo"); ODataEntityCreateRequest<ODataEntity> createReq = client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), info); @@ -259,7 +258,7 @@ public class BatchTestITCase extends AbstractTestITCase { customer.getNavigationLinks().add( client.getObjectFactory().newEntityNavigationLink("Info", URI.create("$" + createRequestRef))); - uriBuilder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customer"); + uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customer"); // add create request createReq = client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), customer); @@ -290,13 +289,13 @@ public class BatchTestITCase extends AbstractTestITCase { assertEquals(201, res.getStatusCode()); assertTrue(res instanceof ODataEntityCreateResponse); - uriBuilder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customer").appendKeySegment(30); + uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customer").appendKeySegment(30); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest( URIUtils.getURI(testStaticServiceRootURL, uriBuilder.build() + "/Info")); - + final ODataEntity navigatedInfo = req.execute().getBody(); - + assertEquals(infoEntity.getProperty("CustomerInfoId").getPrimitiveValue().toCastValue(Integer.class), navigatedInfo.getProperty("CustomerInfoId").getPrimitiveValue().toCastValue(Integer.class)); } @@ -307,15 +306,13 @@ public class BatchTestITCase extends AbstractTestITCase { // create your request final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testStaticServiceRootURL); - final BatchStreamManager streamManager = request.execute(); + final BatchManager streamManager = request.payloadManager(); // ------------------------------------------- // Add retrieve item // ------------------------------------------- - ODataRetrieve retrieve = streamManager.addRetrieve(); - // prepare URI - URIBuilder targetURI = client.getURIBuilder(testStaticServiceRootURL); + URIBuilder targetURI = client.newURIBuilder(testStaticServiceRootURL); targetURI.appendEntitySetSegment("Customer").appendKeySegment(-10). expand("Logins").select("CustomerId,Logins/Username"); @@ -323,7 +320,7 @@ public class BatchTestITCase extends AbstractTestITCase { ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build()); queryReq.setFormat(ODataPubFormat.ATOM); - retrieve.setRequest(queryReq); + streamManager.addRequest(queryReq); // ------------------------------------------- // ------------------------------------------- @@ -332,7 +329,7 @@ public class BatchTestITCase extends AbstractTestITCase { final ODataChangeset changeset = streamManager.addChangeset(); // Update Product into the changeset - targetURI = client.getURIBuilder(testStaticServiceRootURL). + targetURI = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Product").appendKeySegment(-10); final URI editLink = targetURI.build(); @@ -351,7 +348,7 @@ public class BatchTestITCase extends AbstractTestITCase { changeset.addRequest(changeReq); // Create Customer into the changeset - targetURI = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customer"); + targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customer"); final ODataEntity original = getSampleCustomerProfile(1000, "Sample customer", false); final ODataEntityCreateRequest<ODataEntity> createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original); @@ -360,7 +357,7 @@ public class BatchTestITCase extends AbstractTestITCase { // Delete customer created above targetURI = - client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customer").appendKeySegment(1000); + client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customer").appendKeySegment(1000); final ODataDeleteRequest deleteReq = client.getCUDRequestFactory().getDeleteRequest(targetURI.build()); changeset.addRequest(deleteReq); // ------------------------------------------- @@ -368,16 +365,15 @@ public class BatchTestITCase extends AbstractTestITCase { // ------------------------------------------- // Add retrieve item // ------------------------------------------- - retrieve = streamManager.addRetrieve(); // prepare URI - targetURI = client.getURIBuilder(testStaticServiceRootURL). + targetURI = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Product").appendKeySegment(-10); // create new request queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build()); - retrieve.setRequest(queryReq); + streamManager.addRequest(queryReq); // ------------------------------------------- final ODataBatchResponse response = streamManager.getResponse(); @@ -387,9 +383,9 @@ public class BatchTestITCase extends AbstractTestITCase { // retrive the first item (ODataRetrieve) ODataBatchResponseItem item = iter.next(); - assertTrue(item instanceof ODataRetrieveResponseItem); + assertTrue(item instanceof ODataSingleResponseItem); - ODataRetrieveResponseItem retitem = (ODataRetrieveResponseItem) item; + ODataSingleResponseItem retitem = (ODataSingleResponseItem) item; ODataResponse res = retitem.next(); assertTrue(res instanceof ODataEntityResponseImpl); assertEquals(200, res.getStatusCode()); @@ -426,9 +422,9 @@ public class BatchTestITCase extends AbstractTestITCase { // retrive the third item (ODataRetrieve) item = iter.next(); - assertTrue(item instanceof ODataRetrieveResponseItem); + assertTrue(item instanceof ODataSingleResponseItem); - retitem = (ODataRetrieveResponseItem) item; + retitem = (ODataSingleResponseItem) item; res = retitem.next(); assertTrue(res instanceof ODataEntityResponseImpl); assertEquals(200, res.getStatusCode()); @@ -448,7 +444,7 @@ public class BatchTestITCase extends AbstractTestITCase { super(new Wrapper<Future<HttpResponse>>()); } - public ODataStreamManager<ODataBatchResponse> addObject(byte[] src) { + public ODataPayloadManager<ODataBatchResponse> addObject(byte[] src) { stream(src); return this; } @@ -499,9 +495,9 @@ public class BatchTestITCase extends AbstractTestITCase { private static class BatchStreamingThread extends Thread { - private final BatchStreamManager streaming; + private final BatchManager streaming; - public BatchStreamingThread(final BatchStreamManager streaming) { + public BatchStreamingThread(final BatchManager streaming) { this.streaming = streaming; } diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/CountTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/CountTestITCase.java index 9745ef53b..56c7902c5 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/CountTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/CountTestITCase.java @@ -31,7 +31,7 @@ public class CountTestITCase extends AbstractTestITCase { @Test public void entityCount() { - CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customer").count(); final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); @@ -45,7 +45,7 @@ public class CountTestITCase extends AbstractTestITCase { @Test public void invalidAccept() { - final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customer").count(); final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/EntityCreateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/EntityCreateTestITCase.java index db26eee49..0d9730e6e 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/EntityCreateTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/EntityCreateTestITCase.java @@ -227,7 +227,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase { final ODataEntity original = getSampleCustomerProfile(id, "Sample customer", false); final ODataEntityCreateRequest<ODataEntity> createReq = client.getCUDRequestFactory().getEntityCreateRequest( - client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer").build(), original); + client.newURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer").build(), original); createReq.setPrefer(client.newPreferences().returnNoContent()); final ODataEntityCreateResponse<ODataEntity> createRes = createReq.execute(); @@ -243,7 +243,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase { } final ODataDeleteResponse deleteRes = client.getCUDRequestFactory().getDeleteRequest( - client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer").appendKeySegment(id).build()). + client.newURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer").appendKeySegment(id).build()). execute(); assertEquals(204, deleteRes.getStatusCode()); } @@ -253,7 +253,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase { final int id = 2; final ODataEntity original = getSampleCustomerProfile(id, "Sample customer for issue 135", false); - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer"); + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer"); final ODataEntityCreateRequest<ODataEntity> createReq = client.getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), original); createReq.setFormat(ODataPubFormat.JSON_FULL_METADATA); @@ -267,7 +267,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase { fail(e.getMessage()); } finally { final ODataDeleteResponse deleteRes = client.getCUDRequestFactory().getDeleteRequest( - client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer").appendKeySegment(id). + client.newURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer").appendKeySegment(id). build()). execute(); assertEquals(204, deleteRes.getStatusCode()); @@ -294,7 +294,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase { client.getObjectFactory().newPrimitiveValueBuilder().buildInt32(id))); final ODataEntityCreateRequest<ODataEntity> createReq = client.getCUDRequestFactory().getEntityCreateRequest( - client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Order").build(), order); + client.newURIBuilder(getServiceRoot()).appendEntitySetSegment("Order").build(), order); createReq.setFormat(format); original.addLink(client.getObjectFactory().newEntitySetNavigationLink( @@ -306,7 +306,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase { // now, compare the created one with the actual one and go deeply into the associated customer info..... final ODataEntity actual = compareEntities(getServiceRoot(), format, created, id, null); - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()); + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()); uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(id).appendEntitySetSegment("Orders"); final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory(). @@ -348,7 +348,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase { // now, compare the created one with the actual one and go deeply into the associated customer info..... final ODataEntity actual = compareEntities(getServiceRoot(), format, created, id, null); - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()); + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()); uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(id).appendEntitySetSegment("Info"); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); @@ -464,7 +464,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase { client.getObjectFactory().newPrimitiveValueBuilder().buildBoolean(false))); final URIBuilder builder = - client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Message"); + client.newURIBuilder(getServiceRoot()).appendEntitySetSegment("Message"); final ODataEntityCreateRequest<ODataEntity> req = client.getCUDRequestFactory(). getEntityCreateRequest(builder.build(), message); req.setFormat(format); diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java index b6943aa0d..9314d2a76 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/EntityRetrieveTestITCase.java @@ -56,7 +56,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { } private void withInlineEntry(final ODataPubFormat format) { - final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()). + final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Customer").appendKeySegment(-10).expand("Info"); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); @@ -109,7 +109,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { } private void withInlineFeed(final ODataPubFormat format) { - final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()). + final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Customer").appendKeySegment(-10).expand("Orders"); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); @@ -148,7 +148,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { } private void rawRequest(final ODataPubFormat format) { - final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()). + final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Car").appendKeySegment(16); final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build()); @@ -180,7 +180,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { multiKey.put("FromUsername", "1"); multiKey.put("MessageId", -10); - final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()). + final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Message").appendKeySegment(multiKey); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); @@ -214,7 +214,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { private void checkForETag(final ODataPubFormat format) { final CommonURIBuilder<?> uriBuilder = - client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Product").appendKeySegment(-10); + client.newURIBuilder(getServiceRoot()).appendEntitySetSegment("Product").appendKeySegment(-10); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); @@ -231,7 +231,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { @Test(expected = IllegalArgumentException.class) public void issue99() { - final CommonURIBuilder<?> uriBuilder = client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Car"); + final CommonURIBuilder<?> uriBuilder = client.newURIBuilder(getServiceRoot()).appendEntitySetSegment("Car"); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(ODataPubFormat.JSON); @@ -242,7 +242,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { } private void geospatial(final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()). + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("AllGeoTypesSet").appendKeySegment(-10); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java index 6bcd24834..68fb07d00 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/EntitySetTestITCase.java @@ -99,7 +99,7 @@ public class EntitySetTestITCase extends AbstractTestITCase { } private void readEntitySetWithNextLink(final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()); + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()); uriBuilder.appendEntitySetSegment("Customer"); final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory(). @@ -124,7 +124,7 @@ public class EntitySetTestITCase extends AbstractTestITCase { } private void readODataEntitySetIterator(final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()); + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()); uriBuilder.appendEntitySetSegment("Customer"); final ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> req = @@ -147,7 +147,7 @@ public class EntitySetTestITCase extends AbstractTestITCase { } private void readWithInlineCount(final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()); + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()); uriBuilder.appendEntitySetSegment("Product").inlineCount(URIBuilder.InlineCount.allpages); final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build()); @@ -161,7 +161,7 @@ public class EntitySetTestITCase extends AbstractTestITCase { } private void rawRequest(final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()); + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()); uriBuilder.appendEntitySetSegment("Car"); final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build()); diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/EntityUpdateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/EntityUpdateTestITCase.java index 3e78f6026..413dae83c 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/EntityUpdateTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/EntityUpdateTestITCase.java @@ -49,7 +49,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { @Test public void mergeAsAtom() { final ODataPubFormat format = ODataPubFormat.ATOM; - final URI uri = client.getURIBuilder(getServiceRoot()). + final URI uri = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Product").appendKeySegment(-10).build(); final String etag = getETag(uri); final ODataEntity merge = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE); @@ -60,7 +60,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { @Test public void mergeAsJSON() { final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA; - final URI uri = client.getURIBuilder(getServiceRoot()). + final URI uri = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Product").appendKeySegment(-10).build(); final String etag = getETag(uri); final ODataEntity merge = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE); @@ -71,7 +71,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { @Test public void patchAsAtom() { final ODataPubFormat format = ODataPubFormat.ATOM; - final URI uri = client.getURIBuilder(getServiceRoot()). + final URI uri = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Product").appendKeySegment(-10).build(); final String etag = getETag(uri); final ODataEntity patch = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE); @@ -82,7 +82,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { @Test public void patchAsJSON() { final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA; - final URI uri = client.getURIBuilder(getServiceRoot()). + final URI uri = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Product").appendKeySegment(-10).build(); final String etag = getETag(uri); final ODataEntity patch = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE); @@ -93,7 +93,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { @Test public void replaceAsAtom() { final ODataPubFormat format = ODataPubFormat.ATOM; - final ODataEntity changes = read(format, client.getURIBuilder(getServiceRoot()). + final ODataEntity changes = read(format, client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Car").appendKeySegment(14).build()); updateEntityDescription(format, changes, UpdateType.REPLACE); } @@ -101,7 +101,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { @Test public void replaceAsJSON() { final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA; - final ODataEntity changes = read(format, client.getURIBuilder(getServiceRoot()). + final ODataEntity changes = read(format, client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Car").appendKeySegment(14).build()); updateEntityDescription(format, changes, UpdateType.REPLACE); } @@ -117,7 +117,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { } public void patchLink(final ODataPubFormat format) throws EdmPrimitiveTypeException { - final URI uri = client.getURIBuilder(getServiceRoot()). + final URI uri = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Customer").appendKeySegment(-10).build(); final ODataEntity patch = client.getObjectFactory(). @@ -127,14 +127,14 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { // --------------------------------------- // Update to CustomerInfo(12) // --------------------------------------- - URI customerInfoURI = client.getURIBuilder(getServiceRoot()). + URI customerInfoURI = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("CustomerInfo").appendKeySegment(12).build(); patch.addLink(client.getObjectFactory().newEntityNavigationLink("Info", customerInfoURI)); update(UpdateType.PATCH, patch, format, null); - customerInfoURI = client.getURIBuilder(getServiceRoot()). + customerInfoURI = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Customer").appendKeySegment(-10).appendNavigationSegment("Info").build(); ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(customerInfoURI); @@ -151,7 +151,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { // --------------------------------------- patch.getNavigationLinks().clear(); - customerInfoURI = client.getURIBuilder(getServiceRoot()). + customerInfoURI = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("CustomerInfo").appendKeySegment(11).build(); read(format, customerInfoURI); @@ -159,7 +159,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { update(UpdateType.PATCH, patch, format, null); - customerInfoURI = client.getURIBuilder(getServiceRoot()). + customerInfoURI = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Customer").appendKeySegment(-10).appendNavigationSegment("Info").build(); req = client.getRetrieveRequestFactory().getEntityRequest(customerInfoURI); @@ -178,7 +178,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { final LinkedHashMap<String, Object> multiKey = new LinkedHashMap<String, Object>(); multiKey.put("FromUsername", "1"); multiKey.put("MessageId", -10); - final ODataEntity message = read(format, client.getURIBuilder(getServiceRoot()). + final ODataEntity message = read(format, client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Message").appendKeySegment(multiKey).build()); message.getAssociationLinks().clear(); message.getNavigationLinks().clear(); @@ -222,7 +222,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { @Test public void concurrentModification() { - final URI uri = client.getURIBuilder(getServiceRoot()). + final URI uri = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Product").appendKeySegment(-10).build(); String etag = getETag(uri); final ODataEntity product = client.getObjectFactory().newEntity(TEST_PRODUCT_TYPE); diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/ErrorTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/ErrorTestITCase.java index 21fb8f859..fe8ef6104 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/ErrorTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/ErrorTestITCase.java @@ -38,12 +38,8 @@ import org.apache.olingo.client.api.uri.v3.URIBuilder; import org.apache.olingo.client.api.v3.ODataClient; import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest; import org.apache.olingo.client.core.communication.response.AbstractODataResponse; -import org.apache.olingo.client.core.uri.URIUtils; import org.apache.olingo.commons.api.domain.v3.ODataEntity; import org.apache.olingo.commons.api.domain.v3.ODataEntitySet; -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmEntityContainer; -import org.apache.olingo.commons.api.edm.EdmFunctionImport; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.format.ODataPubFormat; import org.junit.Test; @@ -88,7 +84,7 @@ public class ErrorTestITCase extends AbstractTestITCase { } private void stacktraceError(final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL); uriBuilder.appendEntitySetSegment("Customer"); final ErrorGeneratingRequest errorReq = new ErrorGeneratingRequest(HttpMethod.POST, uriBuilder.build()); @@ -115,7 +111,7 @@ public class ErrorTestITCase extends AbstractTestITCase { } private void notfoundError(final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL); uriBuilder.appendEntitySetSegment("Customer(154)"); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); @@ -143,16 +139,10 @@ public class ErrorTestITCase extends AbstractTestITCase { } private void instreamError(final ODataPubFormat format) { - final Edm metadata = - client.getRetrieveRequestFactory().getMetadataRequest(testStaticServiceRootURL).execute().getBody(); - assertNotNull(metadata); - - final EdmEntityContainer container = metadata.getSchemas().get(0).getEntityContainer(); - final EdmFunctionImport funcImp = container.getFunctionImport("InStreamErrorGetCustomer"); - final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment(URIUtils.operationImportURISegment(container, funcImp.getName())); + final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL). + appendOperationCallSegment("InStreamErrorGetCustomer"); final ODataInvokeRequest<ODataEntitySet> req = - client.getInvokeRequestFactory().getInvokeRequest(builder.build(), funcImp.getUnboundFunction(null)); + client.getInvokeRequestFactory().getFunctionInvokeRequest(builder.build(), ODataEntitySet.class); req.setFormat(format); final ODataInvokeResponse<ODataEntitySet> res = req.execute(); diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/FilterFactoryTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/FilterFactoryTestITCase.java index 2b447ad19..3f00d2c1e 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/FilterFactoryTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/FilterFactoryTestITCase.java @@ -39,7 +39,7 @@ public class FilterFactoryTestITCase extends AbstractTestITCase { } private void match(final String entitySet, final URIFilter filter, final int expected) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment(entitySet).filter(filter); final CommonODataEntitySet feed = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()). diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/FilterTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/FilterTestITCase.java index 7d3bbdb05..d14f9e4a0 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/FilterTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/FilterTestITCase.java @@ -28,7 +28,7 @@ import org.junit.Test; public class FilterTestITCase extends AbstractTestITCase { private void filterQueryTest(final String entity, final String filter, final int expected) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment(entity).filter(filter); final ODataEntitySet entitySet = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()). execute().getBody(); diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/InvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/InvokeTestITCase.java index 02edf6e8e..6b8742fa9 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/InvokeTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/InvokeTestITCase.java @@ -39,43 +39,25 @@ import org.apache.olingo.client.api.communication.response.ODataDeleteResponse; import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse; import org.apache.olingo.client.api.communication.response.ODataInvokeResponse; import org.apache.olingo.client.api.uri.v3.URIBuilder; -import org.apache.olingo.client.core.uri.URIUtils; import org.apache.olingo.commons.api.domain.ODataOperation; -import org.apache.olingo.commons.api.domain.ODataPrimitiveValue; import org.apache.olingo.commons.api.domain.ODataValue; import org.apache.olingo.commons.api.domain.v3.ODataEntity; import org.apache.olingo.commons.api.domain.v3.ODataEntitySet; import org.apache.olingo.commons.api.domain.v3.ODataProperty; -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAction; -import org.apache.olingo.commons.api.edm.EdmEntityContainer; -import org.apache.olingo.commons.api.edm.EdmFunction; -import org.apache.olingo.commons.api.edm.EdmFunctionImport; -import org.apache.olingo.commons.api.edm.EdmParameter; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.format.ODataPubFormat; -import org.apache.olingo.commons.core.edm.EdmTypeInfo; import org.junit.Test; public class InvokeTestITCase extends AbstractTestITCase { private void getWithNoParams(final ODataPubFormat format) { - final Edm edm = getClient().getRetrieveRequestFactory(). - getMetadataRequest(testStaticServiceRootURL).execute().getBody(); - assertNotNull(edm); - - final EdmEntityContainer container = edm.getSchemas().get(0).getEntityContainer(); - // 1. get primitive value property - EdmFunctionImport funcImp = container.getFunctionImport("GetPrimitiveString"); - EdmFunction func = funcImp.getUnboundFunction(null); - - URIBuilder builder = getClient().getURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment(URIUtils.operationImportURISegment(container, funcImp.getName())); + URIBuilder builder = getClient().newURIBuilder(testStaticServiceRootURL). + appendOperationCallSegment("GetPrimitiveString"); ODataInvokeRequest<ODataProperty> req = getClient().getInvokeRequestFactory(). - getInvokeRequest(builder.build(), func); + getFunctionInvokeRequest(builder.build(), ODataProperty.class); req.setFormat(format); ODataInvokeResponse<ODataProperty> res = req.execute(); assertNotNull(res); @@ -85,13 +67,10 @@ public class InvokeTestITCase extends AbstractTestITCase { assertEquals("Foo", property.getPrimitiveValue().toString()); // 2. get collection of complex type property - funcImp = container.getFunctionImport("EntityProjectionReturnsCollectionOfComplexTypes"); - func = funcImp.getUnboundFunction(null); + builder = getClient().newURIBuilder(testStaticServiceRootURL). + appendOperationCallSegment("EntityProjectionReturnsCollectionOfComplexTypes"); - builder = getClient().getURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment(URIUtils.operationImportURISegment(container, funcImp.getName())); - - req = getClient().getInvokeRequestFactory().getInvokeRequest(builder.build(), func); + req = getClient().getInvokeRequestFactory().getFunctionInvokeRequest(builder.build(), ODataProperty.class); req.setFormat(format); res = req.execute(); assertNotNull(res); @@ -114,26 +93,13 @@ public class InvokeTestITCase extends AbstractTestITCase { private void getWithParams(final ODataPubFormat format) throws EdmPrimitiveTypeException { // 1. primitive result - final Edm edm = getClient().getRetrieveRequestFactory(). - getMetadataRequest(testStaticServiceRootURL).execute().getBody(); - assertNotNull(edm); - - final EdmEntityContainer container = edm.getSchemas().get(0).getEntityContainer(); - EdmFunctionImport funcImp = container.getFunctionImport("GetArgumentPlusOne"); - - URIBuilder builder = getClient().getURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment(URIUtils.operationImportURISegment(container, funcImp.getName())); - - EdmFunction function = funcImp.getUnboundFunction(Collections.singletonList("arg1")); - EdmParameter param = function.getParameter(function.getParameterNames().get(0)); - ODataPrimitiveValue paramValue = getClient().getObjectFactory().newPrimitiveValueBuilder(). - setType(param.getType()). - setValue(154). - build(); + URIBuilder builder = getClient().newURIBuilder(testStaticServiceRootURL). + appendOperationCallSegment("GetArgumentPlusOne"); + ODataValue param = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(154); final ODataInvokeRequest<ODataProperty> primitiveReq = getClient().getInvokeRequestFactory(). - getInvokeRequest(builder.build(), function, - Collections.<String, ODataValue>singletonMap(param.getName(), paramValue)); + getFunctionInvokeRequest(builder.build(), ODataProperty.class, + Collections.<String, ODataValue>singletonMap("arg1", param)); primitiveReq.setFormat(format); final ODataInvokeResponse<ODataProperty> primitiveRes = primitiveReq.execute(); @@ -143,22 +109,13 @@ public class InvokeTestITCase extends AbstractTestITCase { assertNotNull(property); assertEquals(Integer.valueOf(155), property.getPrimitiveValue().toCastValue(Integer.class)); - // 2. feed result - funcImp = container.getFunctionImport("GetSpecificCustomer"); - - builder = getClient().getURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment(URIUtils.operationImportURISegment(container, funcImp.getName())); - - function = funcImp.getUnboundFunction(Collections.singletonList("Name")); - param = function.getParameter(function.getParameterNames().get(0)); - paramValue = getClient().getObjectFactory().newPrimitiveValueBuilder(). - setType(param.getType()). - setValue(StringUtils.EMPTY). - build(); + // 2. entity set result + builder = getClient().newURIBuilder(testStaticServiceRootURL).appendOperationCallSegment("GetSpecificCustomer"); + param = getClient().getObjectFactory().newPrimitiveValueBuilder().buildString(StringUtils.EMPTY); final ODataInvokeRequest<ODataEntitySet> feedReq = getClient().getInvokeRequestFactory(). - getInvokeRequest(builder.build(), function, - Collections.<String, ODataValue>singletonMap(param.getName(), paramValue)); + getFunctionInvokeRequest(builder.build(), ODataEntitySet.class, + Collections.<String, ODataValue>singletonMap("Name", param)); feedReq.setFormat(format); final ODataInvokeResponse<ODataEntitySet> feedRes = feedReq.execute(); @@ -199,7 +156,7 @@ public class InvokeTestITCase extends AbstractTestITCase { employee.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty( "Title", getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("CEO"))); - final URIBuilder uriBuilder = getClient().getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Person"); + final URIBuilder uriBuilder = getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Person"); final ODataEntityCreateRequest<ODataEntity> createReq = getClient().getCUDRequestFactory().getEntityCreateRequest(uriBuilder.build(), employee); @@ -213,7 +170,7 @@ public class InvokeTestITCase extends AbstractTestITCase { } private void deleteEmployee(final ODataPubFormat format, final Integer id) { - final URIBuilder uriBuilder = getClient().getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = getClient().newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Person").appendKeySegment(id); final ODataDeleteRequest deleteReq = getClient().getCUDRequestFactory().getDeleteRequest(uriBuilder.build()); @@ -233,24 +190,15 @@ public class InvokeTestITCase extends AbstractTestITCase { // 1. invoke action bound with the employee just created final ODataOperation operation = created.getOperations().get(0); - final Edm edm = getClient().getRetrieveRequestFactory(). - getMetadataRequest(testStaticServiceRootURL).execute().getBody(); - assertNotNull(edm); - - final EdmEntityContainer container = edm.getSchemas().get(0).getEntityContainer(); - final EdmAction action = edm.getBoundAction( - new FullQualifiedName(container.getNamespace(), operation.getTitle()), - created.getTypeName(), false); - final ODataInvokeRequest<ODataNoContent> req = getClient().getInvokeRequestFactory(). - getInvokeRequest(operation.getTarget(), action); + getActionInvokeRequest(operation.getTarget(), ODataNoContent.class); req.setFormat(ODataPubFormat.JSON_FULL_METADATA); final ODataInvokeResponse<ODataNoContent> res = req.execute(); assertNotNull(res); assertEquals(204, res.getStatusCode()); // 2. check that invoked action has effectively run - final URIBuilder uriBuilder = getClient().getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = getClient().newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Person").appendKeySegment(createdId); final ODataEntityRequest<ODataEntity> retrieveRes = getClient().getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); @@ -266,7 +214,7 @@ public class InvokeTestITCase extends AbstractTestITCase { @Test public void boundPostWithParams() throws EdmPrimitiveTypeException { // 1. read employees and store their current salary - final URIBuilder builder = getClient().getURIBuilder(testStaticServiceRootURL). + final URIBuilder builder = getClient().newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Person"). appendEntitySetSegment("Microsoft.Test.OData.Services.AstoriaDefaultService.Employee"); final URI employeesURI = builder.build(); @@ -281,27 +229,11 @@ public class InvokeTestITCase extends AbstractTestITCase { assertFalse(preSalaries.isEmpty()); // 2. invoke action bound, with additional parameter - final Edm edm = getClient().getRetrieveRequestFactory(). - getMetadataRequest(testStaticServiceRootURL).execute().getBody(); - assertNotNull(edm); - - final EdmEntityContainer container = edm.getSchemas().get(0).getEntityContainer(); - - final EdmTypeInfo employeesTypeInfo = new EdmTypeInfo.Builder().setEdm(edm). - setTypeExpression("Collection(Microsoft.Test.OData.Services.AstoriaDefaultService.Employee)").build(); - final EdmAction action = edm.getBoundAction( - new FullQualifiedName(container.getNamespace(), "IncreaseSalaries"), - employeesTypeInfo.getFullQualifiedName(), employeesTypeInfo.isCollection()); - - final EdmParameter param = action.getParameter(action.getParameterNames().get(1)); - final ODataPrimitiveValue paramValue = getClient().getObjectFactory().newPrimitiveValueBuilder(). - setType(param.getType()). - setValue(1). - build(); - - final ODataInvokeRequest<ODataNoContent> req = getClient().getInvokeRequestFactory().getInvokeRequest( - builder.appendOperationCallSegment(action.getName()).build(), action, - Collections.<String, ODataValue>singletonMap(param.getName(), paramValue)); + final ODataValue param = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(1); + final ODataInvokeRequest<ODataNoContent> req = getClient().getInvokeRequestFactory(). + getActionInvokeRequest( + builder.appendOperationCallSegment("IncreaseSalaries").build(), ODataNoContent.class, + Collections.<String, ODataValue>singletonMap("n", param)); final ODataInvokeResponse<ODataNoContent> res = req.execute(); assertNotNull(res); assertEquals(204, res.getStatusCode()); diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/KeyAsSegmentTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/KeyAsSegmentTestITCase.java index 7a1bebc32..30c2d99ad 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/KeyAsSegmentTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/KeyAsSegmentTestITCase.java @@ -39,7 +39,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase { } private void read(final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testKeyAsSegmentServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testKeyAsSegmentServiceRootURL). appendEntitySetSegment("Customer").appendKeySegment(-10); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); @@ -90,7 +90,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase { @Test public void replaceODataEntityAsAtom() { final ODataPubFormat format = ODataPubFormat.ATOM; - final ODataEntity changes = read(format, client.getURIBuilder(testKeyAsSegmentServiceRootURL). + final ODataEntity changes = read(format, client.newURIBuilder(testKeyAsSegmentServiceRootURL). appendEntitySetSegment("Car").appendKeySegment(14).build()); updateEntityDescription(format, changes, UpdateType.REPLACE); } @@ -98,7 +98,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase { @Test public void replaceODataEntityAsJSON() { final ODataPubFormat format = ODataPubFormat.JSON_FULL_METADATA; - final ODataEntity changes = read(format, client.getURIBuilder(testKeyAsSegmentServiceRootURL). + final ODataEntity changes = read(format, client.newURIBuilder(testKeyAsSegmentServiceRootURL). appendEntitySetSegment("Car").appendKeySegment(14).build()); updateEntityDescription(format, changes, UpdateType.REPLACE); } diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/LinkTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/LinkTestITCase.java index 5edf429e7..54b077479 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/LinkTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/LinkTestITCase.java @@ -49,7 +49,7 @@ public class LinkTestITCase extends AbstractTestITCase { } private ODataLinkCollection doRetrieveLinkURIs(final ODataFormat format, final String linkname) throws IOException { - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()). + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Customer").appendKeySegment(-10); final ODataLinkCollectionRequest req = @@ -95,7 +95,7 @@ public class LinkTestITCase extends AbstractTestITCase { final ODataLink newLink = client.getObjectFactory(). newAssociationLink(URI.create(getServiceRoot() + "/Login('3')")); - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()). + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Customer").appendKeySegment(-10).appendLinksSegment("Logins"); final ODataLinkCreateRequest req = @@ -113,7 +113,7 @@ public class LinkTestITCase extends AbstractTestITCase { assertEquals(Collections.singletonList(newLink.getLink()), after); assertEquals(204, client.getCUDRequestFactory().getDeleteRequest( - client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer"). + client.newURIBuilder(getServiceRoot()).appendEntitySetSegment("Customer"). appendKeySegment(-10).appendLinksSegment("Logins('3')").build()).execute().getStatusCode()); } @@ -135,7 +135,7 @@ public class LinkTestITCase extends AbstractTestITCase { ODataLink newLink = client.getObjectFactory(). newAssociationLink(URI.create(getServiceRoot() + "/CustomerInfo(12)")); - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()); + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()); uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(-10).appendLinksSegment("Info"); ODataLinkUpdateRequest req = diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java index 49073786c..7383c1b33 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/MediaEntityTestITCase.java @@ -47,10 +47,10 @@ public class MediaEntityTestITCase extends AbstractTestITCase { @Test public void read() throws Exception { - final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Car").appendKeySegment(12).appendValueSegment(); + final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("Car").appendKeySegment(12); - final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build()); + final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build()); retrieveReq.setFormat(ODataMediaFormat.WILDCARD); final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute(); @@ -62,10 +62,10 @@ public class MediaEntityTestITCase extends AbstractTestITCase { @Test(expected = ODataClientErrorException.class) public void readWithXmlError() throws Exception { - final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Car").appendKeySegment(12).appendValueSegment(); + final URIBuilder builder = + client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car").appendKeySegment(12); - final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build()); + final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build()); retrieveReq.setFormat(ODataMediaFormat.APPLICATION_XML); retrieveReq.execute(); @@ -73,31 +73,31 @@ public class MediaEntityTestITCase extends AbstractTestITCase { @Test(expected = ODataClientErrorException.class) public void readWithJsonError() throws Exception { - final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Car").appendKeySegment(12).appendValueSegment(); + final URIBuilder builder = + client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car").appendKeySegment(12); - final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build()); + final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build()); retrieveReq.setFormat(ODataMediaFormat.APPLICATION_JSON); retrieveReq.execute(); } private void updateMediaEntity(final ODataPubFormat format, final int id) throws Exception { - final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Car").appendKeySegment(id).appendValueSegment(); + final URIBuilder builder = + client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car").appendKeySegment(id); final String TO_BE_UPDATED = "new buffered stream sample"; final InputStream input = IOUtils.toInputStream(TO_BE_UPDATED); final ODataMediaEntityUpdateRequest<ODataEntity> updateReq = - client.getStreamedRequestFactory().getMediaEntityUpdateRequest(builder.build(), input); + client.getCUDRequestFactory().getMediaEntityUpdateRequest(builder.build(), input); updateReq.setFormat(format); - final MediaEntityUpdateStreamManager<ODataEntity> streamManager = updateReq.execute(); + final MediaEntityUpdateStreamManager<ODataEntity> streamManager = updateReq.payloadManager(); final ODataMediaEntityUpdateResponse<ODataEntity> updateRes = streamManager.getResponse(); assertEquals(204, updateRes.getStatusCode()); - final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build()); + final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build()); final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute(); assertEquals(200, retrieveRes.getStatusCode()); @@ -115,13 +115,13 @@ public class MediaEntityTestITCase extends AbstractTestITCase { } private void createMediaEntity(final ODataPubFormat format, final InputStream input) throws Exception { - final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car"); + final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car"); final ODataMediaEntityCreateRequest<ODataEntity> createReq = - client.getStreamedRequestFactory().getMediaEntityCreateRequest(builder.build(), input); + client.getCUDRequestFactory().getMediaEntityCreateRequest(builder.build(), input); createReq.setFormat(format); - final MediaEntityCreateStreamManager<ODataEntity> streamManager = createReq.execute(); + final MediaEntityCreateStreamManager<ODataEntity> streamManager = createReq.payloadManager(); final ODataMediaEntityCreateResponse<ODataEntity> createRes = streamManager.getResponse(); assertEquals(201, createRes.getStatusCode()); @@ -137,9 +137,9 @@ public class MediaEntityTestITCase extends AbstractTestITCase { } assertNotNull(id); - builder.appendKeySegment(id).appendValueSegment(); + builder.appendKeySegment(id); - final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaRequest(builder.build()); + final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory().getMediaEntityRequest(builder.build()); final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute(); assertEquals(200, retrieveRes.getStatusCode()); @@ -163,16 +163,16 @@ public class MediaEntityTestITCase extends AbstractTestITCase { @Test public void updateNamedStream() throws Exception { - URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL). + URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Car").appendKeySegment(16).appendNavigationSegment("Photo"); final String TO_BE_UPDATED = "buffered stream sample"; final InputStream input = new ByteArrayInputStream(TO_BE_UPDATED.getBytes()); final ODataStreamUpdateRequest updateReq = - client.getStreamedRequestFactory().getStreamUpdateRequest(builder.build(), input); + client.getCUDRequestFactory().getStreamUpdateRequest(builder.build(), input); - final StreamUpdateStreamManager streamManager = updateReq.execute(); + final StreamUpdateStreamManager streamManager = updateReq.payloadManager(); final ODataStreamUpdateResponse updateRes = streamManager.getResponse(); updateRes.close(); assertEquals(204, updateRes.getStatusCode()); diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/OpenTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/OpenTypeTestITCase.java index b3490a0e6..05d8a07f8 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/OpenTypeTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/OpenTypeTestITCase.java @@ -53,7 +53,7 @@ public class OpenTypeTestITCase extends AbstractTestITCase { } private ODataEntity readRow(final ODataPubFormat format, final String uuid) { - final URIBuilder builder = getClient().getURIBuilder(testOpenTypeServiceRootURL). + final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL). appendEntitySetSegment("Row").appendKeySegment(UUID.fromString(uuid)); return read(format, builder.build()); } @@ -139,13 +139,13 @@ public class OpenTypeTestITCase extends AbstractTestITCase { getClient().getObjectFactory().newComplexProperty("aContact", contactDetails)); final ODataEntityCreateRequest<ODataEntity> createReq = getClient().getCUDRequestFactory(). - getEntityCreateRequest(getClient().getURIBuilder(testOpenTypeServiceRootURL). + getEntityCreateRequest(getClient().newURIBuilder(testOpenTypeServiceRootURL). appendEntitySetSegment("RowIndex").build(), rowIndex); createReq.setFormat(format); final ODataEntityCreateResponse<ODataEntity> createRes = createReq.execute(); assertEquals(201, createRes.getStatusCode()); - final URIBuilder builder = getClient().getURIBuilder(testOpenTypeServiceRootURL). + final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL). appendEntitySetSegment("RowIndex").appendKeySegment(id); rowIndex = read(format, builder.build()); assertNotNull(rowIndex); diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/PrimitiveKeysTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/PrimitiveKeysTestITCase.java index 079439b2d..73c7d9d17 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/PrimitiveKeysTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/PrimitiveKeysTestITCase.java @@ -34,7 +34,7 @@ public class PrimitiveKeysTestITCase extends AbstractTestITCase { private void readEntity(final String entityType, final Object key, final ODataPubFormat format) { final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest( - client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment(entityType). + client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment(entityType). appendKeySegment(key). build()); req.setFormat(format); diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/PropertyRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/PropertyRetrieveTestITCase.java index 7e67e5483..0904df883 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/PropertyRetrieveTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/PropertyRetrieveTestITCase.java @@ -43,7 +43,7 @@ import org.junit.Test; public class PropertyRetrieveTestITCase extends AbstractTestITCase { private void retrievePropertyTest(final ODataFormat format, String entitySegment, String structuralSegment) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment(entitySegment).appendPropertySegment(structuralSegment); final ODataPropertyRequest<ODataProperty> req = client.getRetrieveRequestFactory(). getPropertyRequest(uriBuilder.build()); @@ -209,7 +209,7 @@ public class PropertyRetrieveTestITCase extends AbstractTestITCase { @Test public void navigationMediaLink() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendNavigationSegment("Product").appendKeySegment(-7).appendLinksSegment("Photos"); final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory(). getEntitySetRequest(uriBuilder.build()); @@ -233,7 +233,7 @@ public class PropertyRetrieveTestITCase extends AbstractTestITCase { @Test public void navigationMediaLinkInvalidQuery() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendNavigationSegment("Product").appendKeySegment(-7).appendLinksSegment("Photo"); final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory(). getEntitySetRequest(uriBuilder.build()); @@ -257,7 +257,7 @@ public class PropertyRetrieveTestITCase extends AbstractTestITCase { @Test public void navigationMediaLinkInvalidFormat() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendNavigationSegment("Product").appendKeySegment(-7).appendLinksSegment("Photos"); final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory(). getEntitySetRequest(uriBuilder.build()); diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java index c46efc09f..e1fa1d4bf 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/PropertyTestITCase.java @@ -124,7 +124,7 @@ public class PropertyTestITCase extends AbstractTestITCase { @Test public void readCountValue() throws IOException { - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()); + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()); uriBuilder.appendEntitySetSegment("Customer").count(); final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); @@ -143,7 +143,7 @@ public class PropertyTestITCase extends AbstractTestITCase { @Test public void nullNullableProperty() { - final ODataDeleteResponse res = client.getCUDRequestFactory().getDeleteRequest(client.getURIBuilder( + final ODataDeleteResponse res = client.getCUDRequestFactory().getDeleteRequest(client.newURIBuilder( getServiceRoot()). appendEntitySetSegment("Order").appendKeySegment(-8). appendPropertySegment("CustomerId").appendValueSegment().build()). @@ -153,7 +153,7 @@ public class PropertyTestITCase extends AbstractTestITCase { @Test(expected = ODataClientErrorException.class) public void nullNonNullableProperty() { - client.getCUDRequestFactory().getDeleteRequest(client.getURIBuilder(getServiceRoot()). + client.getCUDRequestFactory().getDeleteRequest(client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Driver").appendKeySegment("1"). appendPropertySegment("BirthDate").appendValueSegment().build()). execute(); @@ -162,14 +162,13 @@ public class PropertyTestITCase extends AbstractTestITCase { private void updatePropertyValue(final ODataValueFormat format, final UpdateType type) throws IOException, EdmPrimitiveTypeException { - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()). + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Customer").appendKeySegment(-9). appendPropertySegment("PrimaryContactInfo"). appendPropertySegment("HomePhone"). - appendPropertySegment("PhoneNumber"). - appendValueSegment(); + appendPropertySegment("PhoneNumber"); - ODataValueRequest retrieveReq = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + ODataValueRequest retrieveReq = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); retrieveReq.setFormat(format); ODataRetrieveResponse<ODataPrimitiveValue> retrieveRes = retrieveReq.execute(); @@ -192,7 +191,7 @@ public class PropertyTestITCase extends AbstractTestITCase { final ODataValueUpdateResponse updateRes = updateReq.execute(); assertEquals(204, updateRes.getStatusCode()); - retrieveReq = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + retrieveReq = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); retrieveReq.setFormat(format); retrieveRes = retrieveReq.execute(); @@ -205,7 +204,7 @@ public class PropertyTestITCase extends AbstractTestITCase { } private void updateComplexProperty(final ODataFormat format, final UpdateType type) throws IOException { - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()). + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Customer").appendKeySegment(-9).appendPropertySegment("PrimaryContactInfo"); ODataPropertyRequest<ODataProperty> retrieveReq = client.getRetrieveRequestFactory(). @@ -252,7 +251,7 @@ public class PropertyTestITCase extends AbstractTestITCase { } private void updateCollectionProperty(final ODataFormat format) throws IOException { - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()); + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()); uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(-10). appendPropertySegment("PrimaryContactInfo").appendPropertySegment("AlternativeNames"); @@ -300,7 +299,7 @@ public class PropertyTestITCase extends AbstractTestITCase { } private void updatePrimitiveProperty(final ODataFormat format) throws IOException, EdmPrimitiveTypeException { - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()); + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()); uriBuilder.appendEntitySetSegment("Customer").appendKeySegment(-9). appendPropertySegment("PrimaryContactInfo"). appendPropertySegment("HomePhone").appendPropertySegment("PhoneNumber"); @@ -345,7 +344,7 @@ public class PropertyTestITCase extends AbstractTestITCase { } private void rawRequest(final ODataFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(getServiceRoot()). + final URIBuilder uriBuilder = client.newURIBuilder(getServiceRoot()). appendEntitySetSegment("Customer").appendKeySegment(-10).appendPropertySegment("BackupContactInfo"); final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build()); diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/PropertyValueTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/PropertyValueTestITCase.java index cffcec506..2c8c9d904 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/PropertyValueTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/PropertyValueTestITCase.java @@ -34,10 +34,9 @@ public class PropertyValueTestITCase extends AbstractTestITCase { @Test public void retrieveIntPropertyValueTest() { - CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Product").appendKeySegment(-10).appendPropertySegment("ProductId"). - appendValueSegment(); - final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("Product").appendKeySegment(-10).appendPropertySegment("ProductId"); + final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); final ODataValue value = req.execute().getBody(); assertNotNull(value); @@ -46,10 +45,9 @@ public class PropertyValueTestITCase extends AbstractTestITCase { @Test public void retrieveBooleanPropertyValueTest() { - CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Product").appendKeySegment(-10).appendPropertySegment("ProductId"). - appendValueSegment(); - final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("Product").appendKeySegment(-10).appendPropertySegment("ProductId"); + final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); final ODataValue value = req.execute().getBody(); assertNotNull(value); @@ -58,10 +56,9 @@ public class PropertyValueTestITCase extends AbstractTestITCase { @Test public void retrieveStringPropertyValueTest() { - CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Product").appendKeySegment(-6).appendPropertySegment("Description"). - appendValueSegment(); - final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("Product").appendKeySegment(-6).appendPropertySegment("Description"); + final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); final ODataValue value = req.execute().getBody(); assertNotNull(value); @@ -70,10 +67,10 @@ public class PropertyValueTestITCase extends AbstractTestITCase { @Test public void retrieveDatePropertyValueTest() { - CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Product").appendKeySegment(-7).appendPropertySegment( - "NestedComplexConcurrency/ModifiedDate").appendValueSegment(); - final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + "NestedComplexConcurrency/ModifiedDate"); + final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); final ODataValue value = req.execute().getBody(); assertNotNull(value); @@ -82,10 +79,9 @@ public class PropertyValueTestITCase extends AbstractTestITCase { @Test public void retrieveDecimalPropertyValueTest() { - CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Product").appendKeySegment(-6).appendPropertySegment("Dimensions/Height"). - appendValueSegment(); - final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("Product").appendKeySegment(-6).appendPropertySegment("Dimensions/Height"); + final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); final ODataValue value = req.execute().getBody(); assertNotNull(value); @@ -94,7 +90,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase { @Test public void retrieveBinaryPropertyValueTest() throws IOException { - CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendNavigationSegment("ProductPhoto(PhotoId=-3,ProductId=-3)").appendPropertySegment("Photo"); ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setAccept("application/json"); @@ -109,7 +105,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase { @Test(expected = ODataClientErrorException.class) public void retrieveBinaryPropertyValueTestWithAtom() throws IOException { - CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendNavigationSegment("ProductPhoto(PhotoId=-3,ProductId=-3)").appendPropertySegment("Photo"); ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setAccept("application/atom+xml"); @@ -124,7 +120,7 @@ public class PropertyValueTestITCase extends AbstractTestITCase { @Test(expected = IllegalArgumentException.class) public void retrieveBinaryPropertyValueTestWithXML() throws IOException { - CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendNavigationSegment("ProductPhoto(PhotoId=-3,ProductId=-3)").appendPropertySegment("Photo"); ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setAccept("application/xml"); @@ -139,10 +135,10 @@ public class PropertyValueTestITCase extends AbstractTestITCase { @Test public void retrieveCollectionPropertyValueTest() { - CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Product").appendKeySegment(-7).appendPropertySegment( - "ComplexConcurrency/QueriedDateTime").appendValueSegment(); - final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + "ComplexConcurrency/QueriedDateTime"); + final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); final ODataValue value = req.execute().getBody(); if (value.isPrimitive()) { @@ -153,10 +149,10 @@ public class PropertyValueTestITCase extends AbstractTestITCase { @Test public void retrieveNullPropertyValueTest() { - CommonURIBuilder<?> uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + CommonURIBuilder<?> uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Product").appendKeySegment(-10).appendPropertySegment( - "ComplexConcurrency/Token").appendValueSegment(); - final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + "ComplexConcurrency/Token"); + final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); try { req.execute().getBody(); } catch (ODataClientErrorException e) { diff --git a/fit/src/test/java/org/apache/olingo/fit/v3/QueryOptionsTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v3/QueryOptionsTestITCase.java index 72ea45343..1c0f8bd3b 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v3/QueryOptionsTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v3/QueryOptionsTestITCase.java @@ -60,7 +60,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { */ @Test public void filterOrderby() throws EdmPrimitiveTypeException { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Car").filter("(VIN lt 16)"); // 1. check that filtered entity set looks as expected @@ -100,7 +100,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { */ @Test public void format() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customer").appendKeySegment(-10).format("json"); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); @@ -135,7 +135,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { */ @Test public void skiptoken() throws EdmPrimitiveTypeException { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL); uriBuilder.appendEntitySetSegment("Customer").skipToken("-10"); final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory(). @@ -154,7 +154,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { */ @Test public void inlinecount() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car"). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Car"). inlineCount(InlineCount.allpages); final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory(). @@ -170,7 +170,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { */ @Test public void select() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customer").appendKeySegment(-10).select("CustomerId,Orders").expand("Orders"); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); @@ -182,7 +182,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { @Test public void issue131() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customer").appendKeySegment(-7).select("Name"); ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java index 8fed8f76e..32a6e19d0 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/AbstractTestITCase.java @@ -131,7 +131,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase { order.getProperties().add(orderShelfLifes); final ODataEntityCreateRequest<ODataEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest( - getClient().getURIBuilder(testStaticServiceRootURL). + getClient().newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Orders").build(), order); req.setFormat(format); final ODataEntity created = req.execute().getBody(); @@ -139,7 +139,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase { assertEquals(2, created.getProperty("OrderShelfLifes").getCollectionValue().size()); final URI deleteURI = created.getEditLink() == null - ? getClient().getURIBuilder(testStaticServiceRootURL). + ? getClient().newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Orders").appendKeySegment(id).build() : created.getEditLink(); final ODataDeleteRequest deleteReq = getClient().getCUDRequestFactory().getDeleteRequest(deleteURI); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/AsyncTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/AsyncTestITCase.java index bff599313..edeeae551 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/AsyncTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/AsyncTestITCase.java @@ -46,7 +46,7 @@ public class AsyncTestITCase extends AbstractTestITCase { @Test public void clientAsync() throws InterruptedException, ExecutionException { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customers"); final Future<ODataRetrieveResponse<ODataEntitySet>> futureRes = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()).asyncExecute(); @@ -63,7 +63,7 @@ public class AsyncTestITCase extends AbstractTestITCase { } private void withInlineEntry(final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company"); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); @@ -130,7 +130,7 @@ public class AsyncTestITCase extends AbstractTestITCase { } private void asyncOrders(final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("async").appendEntitySetSegment("Orders"); final ODataEntitySetRequest<ODataEntitySet> req = diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java index 0cf694c28..daf4ed280 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/BatchTestITCase.java @@ -34,13 +34,11 @@ import java.util.concurrent.TimeUnit; import org.apache.http.HttpResponse; import org.apache.olingo.client.api.ODataBatchConstants; import org.apache.olingo.client.api.communication.header.HeaderName; -import org.apache.olingo.client.api.communication.request.ODataStreamManager; +import org.apache.olingo.client.api.communication.request.ODataPayloadManager; +import org.apache.olingo.client.api.communication.request.batch.BatchManager; import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem; import org.apache.olingo.client.api.communication.request.batch.ODataChangeset; -import org.apache.olingo.client.api.communication.request.batch.ODataRetrieve; -import org.apache.olingo.client.api.communication.request.batch.v4.BatchStreamManager; import org.apache.olingo.client.api.communication.request.batch.v4.ODataBatchRequest; -import org.apache.olingo.client.api.communication.request.batch.v4.ODataOutsideUpdate; import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest; import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest; import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType; @@ -57,8 +55,7 @@ import org.apache.olingo.client.api.uri.v4.URIBuilder; import org.apache.olingo.client.core.communication.request.AbstractODataStreamManager; import org.apache.olingo.client.core.communication.request.Wrapper; import org.apache.olingo.client.core.communication.request.batch.ODataChangesetResponseItem; -import org.apache.olingo.client.core.communication.request.batch.ODataRetrieveResponseItem; -import org.apache.olingo.client.core.communication.request.batch.v4.ODataOutsideUpdateResponseItem; +import org.apache.olingo.client.core.communication.request.batch.ODataSingleResponseItem; import org.apache.olingo.client.core.communication.request.retrieve.ODataEntityRequestImpl; import org.apache.olingo.client.core.communication.request.retrieve.ODataEntityRequestImpl.ODataEntityResponseImpl; import org.apache.olingo.client.core.uri.URIUtils; @@ -79,13 +76,6 @@ public class BatchTestITCase extends AbstractTestITCase { private static final int MAX = 10000; - // ------------------------ - // Uncomment to check externally ... - // ------------------------ - // private final static String testStaticServiceRootURL= - // "http://odatae2etest.azurewebsites.net/javatest/DefaultService/"; - // private final static String ACCEPT = ContentType.MULTIPART_MIXED; - // ------------------------ private final static String ACCEPT = ContentType.APPLICATION_OCTET_STREAM; @Test @@ -110,7 +100,7 @@ public class BatchTestITCase extends AbstractTestITCase { final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testStaticServiceRootURL); request.setAccept(ACCEPT); - final BatchStreamManager payload = request.execute(); + final BatchManager payload = request.payloadManager(); final ODataBatchResponse response = payload.getResponse(); assertEquals(200, response.getStatusCode()); @@ -126,13 +116,13 @@ public class BatchTestITCase extends AbstractTestITCase { final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testStaticServiceRootURL); request.setAccept(ACCEPT); - final BatchStreamManager payload = request.execute(); + final BatchManager payload = request.payloadManager(); final ODataChangeset changeset = payload.addChangeset(); URIBuilder targetURI; ODataEntityCreateRequest<ODataEntity> createReq; - targetURI = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders"); + targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders"); for (int i = 1; i <= 2; i++) { // Create Customer into the changeset createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(100 + i)); @@ -140,12 +130,12 @@ public class BatchTestITCase extends AbstractTestITCase { changeset.addRequest(createReq); } - targetURI = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("WrongEntitySet"); + targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("WrongEntitySet"); createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(105)); createReq.setFormat(ODataPubFormat.JSON); changeset.addRequest(createReq); - targetURI = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders"); + targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders"); for (int i = 3; i <= 4; i++) { // Create Customer into the changeset createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), newOrder(100 + i)); @@ -188,36 +178,32 @@ public class BatchTestITCase extends AbstractTestITCase { request.setAccept(ACCEPT); request.continueOnError(); - final BatchStreamManager streamManager = request.execute(); + final BatchManager streamManager = request.payloadManager(); // ------------------------------------------- // Add retrieve item // ------------------------------------------- - ODataRetrieve retrieve = streamManager.addRetrieve(); - // prepare URI - URIBuilder targetURI = client.getURIBuilder(testStaticServiceRootURL); + URIBuilder targetURI = client.newURIBuilder(testStaticServiceRootURL); targetURI.appendEntitySetSegment("UnexistinfEntitySet").appendKeySegment(1); // create new request ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build()); queryReq.setFormat(ODataPubFormat.JSON); - retrieve.setRequest(queryReq); + streamManager.addRequest(queryReq); // ------------------------------------------- // ------------------------------------------- // Add retrieve item // ------------------------------------------- - retrieve = streamManager.addRetrieve(); - // prepare URI - targetURI = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").appendKeySegment(1); + targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").appendKeySegment(1); // create new request queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build()); - retrieve.setRequest(queryReq); + streamManager.addRequest(queryReq); // ------------------------------------------- final ODataBatchResponse response = streamManager.getResponse(); @@ -227,18 +213,18 @@ public class BatchTestITCase extends AbstractTestITCase { // retrieve the first item (ODataRetrieve) ODataBatchResponseItem item = iter.next(); - assertTrue(item instanceof ODataRetrieveResponseItem); + assertTrue(item instanceof ODataSingleResponseItem); - ODataRetrieveResponseItem retitem = (ODataRetrieveResponseItem) item; + ODataSingleResponseItem retitem = (ODataSingleResponseItem) item; ODataResponse res = retitem.next(); assertEquals(404, res.getStatusCode()); assertEquals("Not Found", res.getStatusMessage()); if (continueOnError) { item = iter.next(); - assertTrue(item instanceof ODataRetrieveResponseItem); + assertTrue(item instanceof ODataSingleResponseItem); - retitem = (ODataRetrieveResponseItem) item; + retitem = (ODataSingleResponseItem) item; res = retitem.next(); assertTrue(res instanceof ODataEntityResponseImpl); assertEquals(200, res.getStatusCode()); @@ -252,12 +238,12 @@ public class BatchTestITCase extends AbstractTestITCase { // create your request final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testStaticServiceRootURL); request.setAccept(ACCEPT); - final BatchStreamManager streamManager = request.execute(); + final BatchManager streamManager = request.payloadManager(); final ODataChangeset changeset = streamManager.addChangeset(); ODataEntity order = newOrder(20); - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders"); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders"); // add create request final ODataEntityCreateRequest<ODataEntity> createReq = @@ -272,7 +258,7 @@ public class BatchTestITCase extends AbstractTestITCase { final ODataEntity customerChanges = client.getObjectFactory().newEntity(order.getTypeName()); customerChanges.addLink(client.getObjectFactory().newEntitySetNavigationLink( "OrderDetails", - client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("OrderDetails"). + client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("OrderDetails"). appendKeySegment(new HashMap<String, Object>() { private static final long serialVersionUID = 3109256773218160485L; @@ -336,15 +322,13 @@ public class BatchTestITCase extends AbstractTestITCase { // create your request final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testStaticServiceRootURL); request.setAccept(ACCEPT); - final BatchStreamManager streamManager = request.execute(); + final BatchManager streamManager = request.payloadManager(); // ------------------------------------------- // Add retrieve item // ------------------------------------------- - ODataRetrieve retrieve = streamManager.addRetrieve(); - // prepare URI - URIBuilder targetURI = client.getURIBuilder(testStaticServiceRootURL); + URIBuilder targetURI = client.newURIBuilder(testStaticServiceRootURL); targetURI.appendEntitySetSegment("Customers").appendKeySegment(1). expand("Orders").select("PersonID,Orders/OrderID"); @@ -352,21 +336,19 @@ public class BatchTestITCase extends AbstractTestITCase { ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build()); queryReq.setFormat(ODataPubFormat.JSON); - retrieve.setRequest(queryReq); + streamManager.addRequest(queryReq); // ------------------------------------------- // ------------------------------------------- // Add new order with outside item // ------------------------------------------- - final ODataOutsideUpdate outside = streamManager.addOutsideUpdate(); - // prepare URI - targetURI = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders"); + targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders"); final ODataEntity original = newOrder(2000); final ODataEntityCreateRequest<ODataEntity> createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original); createReq.setFormat(ODataPubFormat.JSON); - outside.setRequest(createReq); + streamManager.addRequest(createReq); // ------------------------------------------- final ODataBatchResponse response = streamManager.getResponse(); @@ -376,9 +358,9 @@ public class BatchTestITCase extends AbstractTestITCase { // retrieve the first item (ODataRetrieve) ODataBatchResponseItem item = iter.next(); - assertTrue(item instanceof ODataRetrieveResponseItem); + assertTrue(item instanceof ODataSingleResponseItem); - ODataRetrieveResponseItem retitem = (ODataRetrieveResponseItem) item; + ODataSingleResponseItem retitem = (ODataSingleResponseItem) item; ODataResponse res = retitem.next(); assertTrue(res instanceof ODataEntityResponseImpl); assertEquals(200, res.getStatusCode()); @@ -386,9 +368,9 @@ public class BatchTestITCase extends AbstractTestITCase { // retrieve the second item (ODataChangeset) item = iter.next(); - assertTrue(item instanceof ODataOutsideUpdateResponseItem); + assertTrue(item instanceof ODataSingleResponseItem); - final ODataOutsideUpdateResponseItem outitem = (ODataOutsideUpdateResponseItem) item; + final ODataSingleResponseItem outitem = (ODataSingleResponseItem) item; res = outitem.next(); assertTrue(res instanceof ODataEntityCreateResponse); assertEquals(201, res.getStatusCode()); @@ -408,22 +390,20 @@ public class BatchTestITCase extends AbstractTestITCase { final ODataBatchRequest request = client.getBatchRequestFactory().getBatchRequest(testStaticServiceRootURL); request.setAccept(ACCEPT); - final BatchStreamManager streamManager = request.execute(); + final BatchManager streamManager = request.payloadManager(); // ------------------------------------------- // Add retrieve item // ------------------------------------------- - ODataRetrieve retrieve = streamManager.addRetrieve(); - // prepare URI - URIBuilder targetURI = client.getURIBuilder(testStaticServiceRootURL); + URIBuilder targetURI = client.newURIBuilder(testStaticServiceRootURL); targetURI.appendEntitySetSegment("Customers").appendKeySegment(1); // create new request ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build()); queryReq.setFormat(ODataPubFormat.JSON); - retrieve.setRequest(queryReq); + streamManager.addRequest(queryReq); // ------------------------------------------- // ------------------------------------------- @@ -432,7 +412,7 @@ public class BatchTestITCase extends AbstractTestITCase { final ODataChangeset changeset = streamManager.addChangeset(); // Update Customer into the changeset - targetURI = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").appendKeySegment(1); + targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").appendKeySegment(1); final URI editLink = targetURI.build(); final ODataEntity patch = client.getObjectFactory().newEntity( @@ -450,7 +430,7 @@ public class BatchTestITCase extends AbstractTestITCase { changeset.addRequest(changeReq); // Create Order into the changeset - targetURI = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders"); + targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders"); final ODataEntity original = newOrder(1000); final ODataEntityCreateRequest<ODataEntity> createReq = client.getCUDRequestFactory().getEntityCreateRequest(targetURI.build(), original); @@ -461,15 +441,13 @@ public class BatchTestITCase extends AbstractTestITCase { // ------------------------------------------- // Add retrieve item // ------------------------------------------- - retrieve = streamManager.addRetrieve(); - // prepare URI - targetURI = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").appendKeySegment(1); + targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").appendKeySegment(1); // create new request queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build()); - retrieve.setRequest(queryReq); + streamManager.addRequest(queryReq); // ------------------------------------------- final ODataBatchResponse response = streamManager.getResponse(); @@ -479,9 +457,9 @@ public class BatchTestITCase extends AbstractTestITCase { // retrieve the first item (ODataRetrieve) ODataBatchResponseItem item = iter.next(); - assertTrue(item instanceof ODataRetrieveResponseItem); + assertTrue(item instanceof ODataSingleResponseItem); - ODataRetrieveResponseItem retitem = (ODataRetrieveResponseItem) item; + ODataSingleResponseItem retitem = (ODataSingleResponseItem) item; ODataResponse res = retitem.next(); assertTrue(res instanceof ODataEntityResponseImpl); assertEquals(200, res.getStatusCode()); @@ -514,9 +492,9 @@ public class BatchTestITCase extends AbstractTestITCase { // retrive the third item (ODataRetrieve) item = iter.next(); - assertTrue(item instanceof ODataRetrieveResponseItem); + assertTrue(item instanceof ODataSingleResponseItem); - retitem = (ODataRetrieveResponseItem) item; + retitem = (ODataSingleResponseItem) item; res = retitem.next(); assertTrue(res instanceof ODataEntityResponseImpl); assertEquals(200, res.getStatusCode()); @@ -541,31 +519,27 @@ public class BatchTestITCase extends AbstractTestITCase { // ------------------------------------------- // Add retrieve item // ------------------------------------------- - ODataRetrieve retrieve = async.addRetrieve(); - // prepare URI - URIBuilder targetURI = client.getURIBuilder(testStaticServiceRootURL); + URIBuilder targetURI = client.newURIBuilder(testStaticServiceRootURL); targetURI.appendEntitySetSegment("People").appendKeySegment(5); // create new request ODataEntityRequest<ODataEntity> queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build()); queryReq.setFormat(ODataPubFormat.JSON); - retrieve.setRequest(queryReq); + async.addRetrieve(queryReq); // ------------------------------------------- // ------------------------------------------- // Add retrieve item // ------------------------------------------- - retrieve = async.addRetrieve(); - // prepare URI - targetURI = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").appendKeySegment(1); + targetURI = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").appendKeySegment(1); // create new request queryReq = client.getRetrieveRequestFactory().getEntityRequest(targetURI.build()); - retrieve.setRequest(queryReq); + async.addRetrieve(queryReq); // ------------------------------------------- final AsyncResponseWrapper<ODataBatchResponse> responseWrapper = async.execute(); @@ -581,10 +555,10 @@ public class BatchTestITCase extends AbstractTestITCase { // retrieve the first item (ODataRetrieve) ODataBatchResponseItem item = iter.next(); - assertTrue(item instanceof ODataRetrieveResponseItem); + assertTrue(item instanceof ODataSingleResponseItem); // The service return interim results to an asynchronously executing batch. - ODataRetrieveResponseItem retitem = (ODataRetrieveResponseItem) item; + ODataSingleResponseItem retitem = (ODataSingleResponseItem) item; ODataResponse res = retitem.next(); assertTrue(res instanceof AsyncResponse); assertEquals(202, res.getStatusCode()); @@ -606,7 +580,7 @@ public class BatchTestITCase extends AbstractTestITCase { super(new Wrapper<Future<HttpResponse>>()); } - public ODataStreamManager<ODataBatchResponse> addObject(final byte[] src) { + public ODataPayloadManager<ODataBatchResponse> addObject(final byte[] src) { stream(src); return this; } @@ -658,9 +632,9 @@ public class BatchTestITCase extends AbstractTestITCase { private static class BatchStreamingThread extends Thread { - private final BatchStreamManager streaming; + private final BatchManager streaming; - public BatchStreamingThread(final BatchStreamManager streaming) { + public BatchStreamingThread(final BatchManager streaming) { super(); this.streaming = streaming; } diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java index da05c7b8f..4a139436b 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/BoundOperationInvokeTestITCase.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.Collections; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest; @@ -38,10 +39,6 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntitySet; import org.apache.olingo.commons.api.domain.v4.ODataEnumValue; import org.apache.olingo.commons.api.domain.v4.ODataProperty; import org.apache.olingo.commons.api.domain.v4.Singleton; -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmAction; -import org.apache.olingo.commons.api.edm.EdmEntityContainer; -import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.FullQualifiedName; @@ -50,20 +47,9 @@ import org.junit.Test; public class BoundOperationInvokeTestITCase extends AbstractTestITCase { - private Edm getEdm() { - final Edm edm = client.getRetrieveRequestFactory().getMetadataRequest(testStaticServiceRootURL).execute().getBody(); - assertNotNull(edm); - - return edm; - } - private void functions(final ODataPubFormat format) throws EdmPrimitiveTypeException { - final Edm edm = getEdm(); - final EdmEntityContainer container = edm.getSchemas().get(0).getEntityContainer(); - assertNotNull(container); - // GetEmployeesCount - URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company"); + URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company"); final ODataEntityRequest<Singleton> singletonReq = client.getRetrieveRequestFactory().getSingletonRequest(builder.build()); singletonReq.setFormat(format); @@ -73,19 +59,15 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { ODataOperation boundOp = company.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount"); assertNotNull(boundOp); - EdmFunction func = edm.getBoundFunction(new FullQualifiedName(boundOp.getTitle()), company.getTypeName(), - false, null); - assertNotNull(func); - final ODataInvokeRequest<ODataProperty> getEmployeesCountReq = - client.getInvokeRequestFactory().getInvokeRequest(boundOp.getTarget(), func); + client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataProperty.class); getEmployeesCountReq.setFormat(format); final ODataProperty getEmployeesCountRes = getEmployeesCountReq.execute().getBody(); assertNotNull(getEmployeesCountRes); assertTrue(getEmployeesCountRes.hasPrimitiveValue()); // GetProductDetails - builder = client.getURIBuilder(testStaticServiceRootURL). + builder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Products").appendKeySegment(5); ODataEntityRequest<ODataEntity> entityReq = client.getRetrieveRequestFactory(). getEntityRequest(builder.build()); @@ -96,12 +78,9 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails"); assertNotNull(boundOp); - func = edm.getBoundFunction(new FullQualifiedName(boundOp.getTitle()), entity.getTypeName(), false, null); - assertNotNull(func); - final ODataPrimitiveValue count = client.getObjectFactory().newPrimitiveValueBuilder().buildInt32(1); final ODataInvokeRequest<ODataEntitySet> getProductDetailsReq = - client.getInvokeRequestFactory().getInvokeRequest(boundOp.getTarget(), func, + client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataEntitySet.class, Collections.<String, ODataValue>singletonMap("count", count)); getProductDetailsReq.setFormat(format); final ODataEntitySet getProductDetailsRes = getProductDetailsReq.execute().getBody(); @@ -112,7 +91,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { final Map<String, Object> keyMap = new LinkedHashMap<String, Object>(); keyMap.put("ProductID", 6); keyMap.put("ProductDetailID", 1); - builder = client.getURIBuilder(testStaticServiceRootURL). + builder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("ProductDetails").appendKeySegment(keyMap); entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build()); entityReq.setFormat(format); @@ -122,11 +101,8 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetRelatedProduct"); assertNotNull(boundOp); - func = edm.getBoundFunction(new FullQualifiedName(boundOp.getTitle()), entity.getTypeName(), false, null); - assertNotNull(func); - final ODataInvokeRequest<ODataEntity> getRelatedProductReq = - client.getInvokeRequestFactory().getInvokeRequest(boundOp.getTarget(), func); + client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataEntity.class); getRelatedProductReq.setFormat(format); final ODataEntity getRelatedProductRes = getRelatedProductReq.execute().getBody(); assertNotNull(getRelatedProductRes); @@ -135,8 +111,8 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { assertEquals(6, getRelatedProductRes.getProperty("ProductID").getPrimitiveValue().toCastValue(Integer.class), 0); // GetDefaultPI - builder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Accounts").appendKeySegment(101); + builder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("Accounts").appendKeySegment(102); entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build()); entityReq.setFormat(format); entity = entityReq.execute().getBody(); @@ -145,28 +121,22 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetDefaultPI"); assertNotNull(boundOp); - func = edm.getBoundFunction(new FullQualifiedName(boundOp.getTitle()), entity.getTypeName(), false, null); - assertNotNull(func); - final ODataInvokeRequest<ODataEntity> getDefaultPIReq = - client.getInvokeRequestFactory().getInvokeRequest(boundOp.getTarget(), func); + client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataEntity.class); getDefaultPIReq.setFormat(format); final ODataEntity getDefaultPIRes = getDefaultPIReq.execute().getBody(); assertNotNull(getDefaultPIRes); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", getDefaultPIRes.getTypeName().toString()); - assertEquals(101901, + assertEquals(102901, getDefaultPIRes.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0); // GetAccountInfo boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetAccountInfo"); assertNotNull(boundOp); - func = edm.getBoundFunction(new FullQualifiedName(boundOp.getTitle()), entity.getTypeName(), false, null); - assertNotNull(func); - final ODataInvokeRequest<ODataProperty> getAccountInfoReq = - client.getInvokeRequestFactory().getInvokeRequest(boundOp.getTarget(), func); + client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataProperty.class); getAccountInfoReq.setFormat(format); final ODataProperty getAccountInfoRes = getAccountInfoReq.execute().getBody(); assertNotNull(getAccountInfoRes); @@ -185,12 +155,9 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.GetActualAmount"); assertNotNull(boundOp); - func = edm.getBoundFunction(new FullQualifiedName(boundOp.getTitle()), entity.getTypeName(), false, null); - assertNotNull(func); - final ODataPrimitiveValue bonusRate = client.getObjectFactory().newPrimitiveValueBuilder().buildDouble(1.1); final ODataInvokeRequest<ODataProperty> getActualAmountReq = - client.getInvokeRequestFactory().getInvokeRequest(boundOp.getTarget(), func, + client.getInvokeRequestFactory().getFunctionInvokeRequest(boundOp.getTarget(), ODataProperty.class, Collections.<String, ODataValue>singletonMap("bonusRate", bonusRate)); getActualAmountReq.setFormat(format); final ODataProperty getActualAmountRes = getActualAmountReq.execute().getBody(); @@ -208,13 +175,95 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { functions(ODataPubFormat.JSON_FULL_METADATA); } - private void actions(final ODataPubFormat format) throws EdmPrimitiveTypeException { - final Edm edm = getEdm(); - final EdmEntityContainer container = edm.getSchemas().get(0).getEntityContainer(); - assertNotNull(container); + @Test + public void edmEnabledFunctions() throws EdmPrimitiveTypeException { + // GetEmployeesCount + final ODataInvokeRequest<ODataProperty> getEmployeesCountReq = + edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest( + edmClient.newURIBuilder().appendSingletonSegment("Company").build(), + new FullQualifiedName(("Microsoft.Test.OData.Services.ODataWCFService.GetEmployeesCount")), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company"), + false); + final ODataProperty getEmployeesCountRes = getEmployeesCountReq.execute().getBody(); + assertNotNull(getEmployeesCountRes); + assertTrue(getEmployeesCountRes.hasPrimitiveValue()); + // GetProductDetails + final ODataPrimitiveValue count = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildInt32(1); + final ODataInvokeRequest<ODataEntitySet> getProductDetailsReq = + edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest( + edmClient.newURIBuilder().appendEntitySetSegment("Products").appendKeySegment(5).build(), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GetProductDetails"), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Product"), + false, + Collections.<String, ODataValue>singletonMap("count", count)); + final ODataEntitySet getProductDetailsRes = getProductDetailsReq.execute().getBody(); + assertNotNull(getProductDetailsRes); + assertEquals(1, getProductDetailsRes.getCount()); + + // GetRelatedProduct + final Map<String, Object> keyMap = new LinkedHashMap<String, Object>(); + keyMap.put("ProductID", 6); + keyMap.put("ProductDetailID", 1); + URIBuilder builder = edmClient.newURIBuilder().appendEntitySetSegment("ProductDetails").appendKeySegment(keyMap); + + final ODataInvokeRequest<ODataEntity> getRelatedProductReq = + edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest( + builder.build(), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GetRelatedProduct"), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.ProductDetail"), + false); + final ODataEntity getRelatedProductRes = getRelatedProductReq.execute().getBody(); + assertNotNull(getRelatedProductRes); + assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Product", + getRelatedProductRes.getTypeName().toString()); + assertEquals(6, getRelatedProductRes.getProperty("ProductID").getPrimitiveValue().toCastValue(Integer.class), 0); + + // GetDefaultPI + final ODataInvokeRequest<ODataEntity> getDefaultPIReq = + edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest( + edmClient.newURIBuilder().appendEntitySetSegment("Accounts").appendKeySegment(102).build(), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GetDefaultPI"), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Account"), + false); + final ODataEntity getDefaultPIRes = getDefaultPIReq.execute().getBody(); + assertNotNull(getDefaultPIRes); + assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", + getDefaultPIRes.getTypeName().toString()); + assertEquals(102901, + getDefaultPIRes.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0); + + // GetAccountInfo + final ODataInvokeRequest<ODataProperty> getAccountInfoReq = + edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest( + edmClient.newURIBuilder().appendEntitySetSegment("Accounts").appendKeySegment(102).build(), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GetAccountInfo"), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Account"), + false); + final ODataProperty getAccountInfoRes = getAccountInfoReq.execute().getBody(); + assertNotNull(getAccountInfoRes); + assertTrue(getAccountInfoRes.hasComplexValue()); + assertEquals("Microsoft.Test.OData.Services.ODataWCFService.AccountInfo", + getAccountInfoRes.getComplexValue().getTypeName()); + + // GetActualAmount + final ODataPrimitiveValue bonusRate = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildDouble(1.1); + final ODataInvokeRequest<ODataProperty> getActualAmountReq = + edmClient.getInvokeRequestFactory().getBoundFunctionInvokeRequest( + edmClient.newURIBuilder().appendEntitySetSegment("Accounts").appendKeySegment(102). + appendNavigationSegment("MyGiftCard").build(), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GetActualAmount"), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.GiftCard"), + false, + Collections.<String, ODataValue>singletonMap("bonusRate", bonusRate)); + final ODataProperty getActualAmountRes = getActualAmountReq.execute().getBody(); + assertNotNull(getActualAmountRes); + assertEquals(41.79, getActualAmountRes.getPrimitiveValue().toCastValue(Double.class), 0); + } + + private void actions(final ODataPubFormat format) throws EdmPrimitiveTypeException { // IncreaseRevenue - URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company"); + URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company"); ODataEntityRequest<ODataEntity> entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build()); entityReq.setFormat(format); @@ -224,13 +273,10 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { ODataOperation boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue"); assertNotNull(boundOp); - EdmAction act = edm.getBoundAction(new FullQualifiedName(boundOp.getTitle()), entity.getTypeName(), false); - assertNotNull(act); - final ODataPrimitiveValue increaseValue = client.getObjectFactory().newPrimitiveValueBuilder().buildInt64(12L); final ODataInvokeRequest<ODataProperty> increaseRevenueReq = - client.getInvokeRequestFactory().getInvokeRequest(boundOp.getTarget(), act, + client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ODataProperty.class, Collections.<String, ODataValue>singletonMap("IncreaseValue", increaseValue)); increaseRevenueReq.setFormat(format); final ODataProperty increaseRevenueRes = increaseRevenueReq.execute().getBody(); @@ -238,7 +284,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { assertTrue(increaseRevenueRes.hasPrimitiveValue()); // AddAccessRight - builder = client.getURIBuilder(testStaticServiceRootURL). + builder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Products").appendKeySegment(5); entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build()); entityReq.setFormat(format); @@ -248,13 +294,10 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight"); assertNotNull(boundOp); - act = edm.getBoundAction(new FullQualifiedName(boundOp.getTitle()), entity.getTypeName(), false); - assertNotNull(act); - final ODataEnumValue accessRight = client.getObjectFactory(). newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "Execute"); final ODataInvokeRequest<ODataProperty> getProductDetailsReq = - client.getInvokeRequestFactory().getInvokeRequest(boundOp.getTarget(), act, + client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ODataProperty.class, Collections.<String, ODataValue>singletonMap("accessRight", accessRight)); getProductDetailsReq.setFormat(format); final ODataProperty getProductDetailsRes = getProductDetailsReq.execute().getBody(); @@ -262,7 +305,7 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { assertTrue(getProductDetailsRes.hasEnumValue()); // ResetAddress - builder = client.getURIBuilder(testStaticServiceRootURL). + builder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customers").appendKeySegment(2); entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build()); entityReq.setFormat(format); @@ -272,10 +315,6 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.ResetAddress"); assertNotNull(boundOp); - act = edm.getBoundAction(new FullQualifiedName(boundOp.getTitle()), - edm.getEntityType(entity.getTypeName()).getBaseType().getFullQualifiedName(), false); - assertNotNull(act); - final ODataCollectionValue<org.apache.olingo.commons.api.domain.v4.ODataValue> addresses = client.getObjectFactory(). newCollectionValue("Collection(Microsoft.Test.OData.Services.ODataWCFService.Address)"); @@ -293,15 +332,15 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { params.put("addresses", addresses); params.put("index", index); final ODataInvokeRequest<ODataEntity> resetAddressReq = - client.getInvokeRequestFactory().getInvokeRequest(boundOp.getTarget(), act, params); + client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ODataEntity.class, params); resetAddressReq.setFormat(format); final ODataEntity resetAddressRes = resetAddressReq.execute().getBody(); assertNotNull(resetAddressRes); assertEquals(2, resetAddressRes.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0); // RefreshDefaultPI - builder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Accounts").appendKeySegment(101); + builder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("Accounts").appendKeySegment(102); entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build()); entityReq.setFormat(format); entity = entityReq.execute().getBody(); @@ -310,20 +349,17 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { boundOp = entity.getOperation("Microsoft.Test.OData.Services.ODataWCFService.RefreshDefaultPI"); assertNotNull(boundOp); - act = edm.getBoundAction(new FullQualifiedName(boundOp.getTitle()), entity.getTypeName(), false); - assertNotNull(act); - final ODataPrimitiveValue newDate = client.getObjectFactory().newPrimitiveValueBuilder(). setType(EdmPrimitiveTypeKind.DateTimeOffset).setText("2014-04-09T00:00:00Z").build(); final ODataInvokeRequest<ODataEntity> getDefaultPIReq = - client.getInvokeRequestFactory().getInvokeRequest(boundOp.getTarget(), act, + client.getInvokeRequestFactory().getActionInvokeRequest(boundOp.getTarget(), ODataEntity.class, Collections.<String, ODataValue>singletonMap("newDate", newDate)); getDefaultPIReq.setFormat(format); final ODataEntity getDefaultPIRes = getDefaultPIReq.execute().getBody(); assertNotNull(getDefaultPIRes); assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", getDefaultPIRes.getTypeName().toString()); - assertEquals(101901, + assertEquals(102901, getDefaultPIRes.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0); } @@ -337,4 +373,80 @@ public class BoundOperationInvokeTestITCase extends AbstractTestITCase { actions(ODataPubFormat.JSON_FULL_METADATA); } + @Test + public void edmEnabledActions() throws EdmPrimitiveTypeException { + // IncreaseRevenue + final ODataPrimitiveValue increaseValue = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildInt64(12L); + final ODataInvokeRequest<ODataProperty> increaseRevenueReq = + edmClient.getInvokeRequestFactory().getBoundActionInvokeRequest( + edmClient.newURIBuilder().appendSingletonSegment("Company").build(), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.IncreaseRevenue"), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Company"), + false, + Collections.<String, ODataValue>singletonMap("IncreaseValue", increaseValue)); + final ODataProperty increaseRevenueRes = increaseRevenueReq.execute().getBody(); + assertNotNull(increaseRevenueRes); + assertTrue(increaseRevenueRes.hasPrimitiveValue()); + + // AddAccessRight + final ODataEnumValue accessRight = edmClient.getObjectFactory(). + newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "Execute"); + final ODataInvokeRequest<ODataProperty> getProductDetailsReq = + edmClient.getInvokeRequestFactory().getBoundActionInvokeRequest( + edmClient.newURIBuilder().appendEntitySetSegment("Products").appendKeySegment(5).build(), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.AddAccessRight"), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Product"), + false, + Collections.<String, ODataValue>singletonMap("accessRight", accessRight)); + final ODataProperty getProductDetailsRes = getProductDetailsReq.execute().getBody(); + assertNotNull(getProductDetailsRes); + assertTrue(getProductDetailsRes.hasEnumValue()); + + // ResetAddress + final ODataCollectionValue<org.apache.olingo.commons.api.domain.v4.ODataValue> addresses = + edmClient.getObjectFactory(). + newCollectionValue("Collection(Microsoft.Test.OData.Services.ODataWCFService.Address)"); + final ODataComplexValue<ODataProperty> address = edmClient.getObjectFactory(). + newLinkedComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address"); + address.add(edmClient.getObjectFactory().newPrimitiveProperty("Street", + edmClient.getObjectFactory().newPrimitiveValueBuilder().buildString("Piazza La Bomba E Scappa"))); + address.add(edmClient.getObjectFactory().newPrimitiveProperty("City", + edmClient.getObjectFactory().newPrimitiveValueBuilder().buildString("Tollo"))); + address.add(edmClient.getObjectFactory().newPrimitiveProperty("PostalCode", + edmClient.getObjectFactory().newPrimitiveValueBuilder().buildString("66010"))); + addresses.add(address); + final ODataPrimitiveValue index = edmClient.getObjectFactory().newPrimitiveValueBuilder().buildInt32(0); + final Map<String, ODataValue> params = new LinkedHashMap<String, ODataValue>(2); + params.put("addresses", addresses); + params.put("index", index); + final Map<String, Object> keys = new HashMap<String, Object>(); + keys.put("PersonID", 2); + final ODataInvokeRequest<ODataEntity> resetAddressReq = + edmClient.getInvokeRequestFactory().getBoundActionInvokeRequest( + edmClient.newURIBuilder().appendEntitySetSegment("Customers").appendKeySegment(keys).build(), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.ResetAddress"), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Person"), + false, + params); + final ODataEntity resetAddressRes = resetAddressReq.execute().getBody(); + assertNotNull(resetAddressRes); + assertEquals(2, resetAddressRes.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0); + + // RefreshDefaultPI + final ODataPrimitiveValue newDate = edmClient.getObjectFactory().newPrimitiveValueBuilder(). + setType(EdmPrimitiveTypeKind.DateTimeOffset).setText("2014-04-09T00:00:00Z").build(); + final ODataInvokeRequest<ODataEntity> getDefaultPIReq = + edmClient.getInvokeRequestFactory().getBoundActionInvokeRequest( + edmClient.newURIBuilder().appendEntitySetSegment("Accounts").appendKeySegment(102).build(), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.RefreshDefaultPI"), + new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Account"), + false, + Collections.<String, ODataValue>singletonMap("newDate", newDate)); + final ODataEntity getDefaultPIRes = getDefaultPIReq.execute().getBody(); + assertNotNull(getDefaultPIRes); + assertEquals("Microsoft.Test.OData.Services.ODataWCFService.PaymentInstrument", + getDefaultPIRes.getTypeName().toString()); + assertEquals(102901, + getDefaultPIRes.getProperty("PaymentInstrumentID").getPrimitiveValue().toCastValue(Integer.class), 0); + } } diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/DeltaTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/DeltaTestITCase.java index 700ed98ea..77c55a044 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/DeltaTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/DeltaTestITCase.java @@ -34,7 +34,7 @@ public class DeltaTestITCase extends AbstractTestITCase { private void parse(final ODataPubFormat format) { final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest( - client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").build()); + client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").build()); req.setPrefer(client.newPreferences().trackChanges()); final ODataEntitySet customers = req.execute().getBody(); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java index 9063c9b2a..bb1bcff14 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/DerivedTypeTestITCase.java @@ -40,7 +40,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase { private void read(final ODataPubFormat format) { // 1. entity set - URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("People"). appendDerivedEntityTypeSegment("Microsoft.Test.OData.Services.ODataWCFService.Customer"); ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory(). @@ -52,7 +52,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase { } // 2. contained entity set - uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Accounts").appendKeySegment(101). appendNavigationSegment("MyPaymentInstruments"). appendDerivedEntityTypeSegment("Microsoft.Test.OData.Services.ODataWCFService.CreditCardPI"); @@ -112,7 +112,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase { final ODataEntityCreateRequest<ODataEntity> createReq = client.getCUDRequestFactory(). getEntityCreateRequest( - client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People").build(), + client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People").build(), customer); createReq.setFormat(format); @@ -120,7 +120,7 @@ public class DerivedTypeTestITCase extends AbstractTestITCase { assertEquals(201, createRes.getStatusCode()); final ODataEntityRequest<ODataEntity> fetchReq = client.getRetrieveRequestFactory(). - getEntityRequest(client.getURIBuilder(testStaticServiceRootURL). + getEntityRequest(client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("People").appendKeySegment(976).build()); fetchReq.setFormat(format); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java index 4c7f4b78d..82035131f 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/EntityCreateTestITCase.java @@ -50,7 +50,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase { } private void onContained(final ODataPubFormat format) { - final URI uri = getClient().getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Accounts"). + final URI uri = getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Accounts"). appendKeySegment(101).appendNavigationSegment("MyPaymentInstruments").build(); // 1. read contained collection before any operation @@ -87,7 +87,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase { // 5. remove the contained entity created above final ODataDeleteResponse deleteRes = getClient().getCUDRequestFactory(). - getDeleteRequest(getClient().getURIBuilder(uri.toASCIIString()).appendKeySegment(id).build()).execute(); + getDeleteRequest(getClient().newURIBuilder(uri.toASCIIString()).appendKeySegment(id).build()).execute(); assertEquals(204, deleteRes.getStatusCode()); // 6. verify that the contained collection effectively reduced @@ -157,7 +157,7 @@ public class EntityCreateTestITCase extends AbstractTestITCase { product.addLink(inlineDetails); final ODataEntityCreateRequest<ODataEntity> req = getClient().getCUDRequestFactory().getEntityCreateRequest( - getClient().getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Products").build(), product); + getClient().newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Products").build(), product); req.setFormat(format); final ODataEntityCreateResponse<ODataEntity> res = req.execute(); assertEquals(201, res.getStatusCode()); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java index dafe38cd0..fc3767a98 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/EntityRetrieveTestITCase.java @@ -54,7 +54,7 @@ import org.junit.Test; public class EntityRetrieveTestITCase extends AbstractTestITCase { private void withInlineEntity(final ODataClient client, final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customers").appendKeySegment(1).expand("Company"); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory(). @@ -124,7 +124,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { } private void withInlineEntitySet(final ODataClient client, final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders"); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory(). @@ -167,7 +167,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { } private void rawRequest(final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("People").appendKeySegment(5); final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build()); @@ -199,7 +199,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { multiKey.put("ProductID", "6"); multiKey.put("ProductDetailID", 1); - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("ProductDetails").appendKeySegment(multiKey); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); @@ -224,7 +224,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { private void checkForETag(final ODataClient client, final ODataPubFormat format) { final URIBuilder uriBuilder = - client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8); + client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders").appendKeySegment(8); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(format); @@ -261,7 +261,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { @Test(expected = IllegalArgumentException.class) public void issue99() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders"); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Orders"); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); req.setFormat(ODataPubFormat.JSON); @@ -272,7 +272,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { } private void reference(final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Orders").appendKeySegment(8).appendNavigationSegment("CustomerForOrder"). appendRefSegment(); @@ -287,7 +287,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { assertTrue(entity.getReference().endsWith("/StaticService/V40/Static.svc/Customers(PersonID=1)")); final URI referenceURI = - client.getURIBuilder(testStaticServiceRootURL).appendEntityIdSegment(entity.getReference()).build(); + client.newURIBuilder(testStaticServiceRootURL).appendEntityIdSegment(entity.getReference()).build(); req = client.getRetrieveRequestFactory().getEntityRequest(referenceURI); req.setFormat(format); @@ -308,7 +308,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { } private void contained(final ODataClient client, final ODataPubFormat format) throws EdmPrimitiveTypeException { - final URI uri = client.getURIBuilder(testStaticServiceRootURL). + final URI uri = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Accounts").appendKeySegment(101). appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101902).build(); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri); @@ -338,7 +338,7 @@ public class EntityRetrieveTestITCase extends AbstractTestITCase { } private void entitySetNavigationLink(final ODataClient client, final ODataPubFormat format) { - final URI uri = client.getURIBuilder(testStaticServiceRootURL). + final URI uri = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Accounts").appendKeySegment(101).build(); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uri); req.setFormat(format); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java index cca2b3bb4..e2a8bdedd 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/EntitySetTestITCase.java @@ -45,7 +45,7 @@ import org.junit.Test; public class EntitySetTestITCase extends AbstractTestITCase { private void rawRequest(final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People"); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People"); final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build()); req.setFormat(format.toString(client.getServiceVersion())); @@ -69,7 +69,7 @@ public class EntitySetTestITCase extends AbstractTestITCase { } private void readWithInlineCount(final ODataClient client, final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("People").count(true); final ODataRawRequest req = client.getRetrieveRequestFactory().getRawRequest(uriBuilder.build()); @@ -101,7 +101,7 @@ public class EntitySetTestITCase extends AbstractTestITCase { } private void readODataEntitySetIterator(final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People"); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People"); final ODataEntitySetIteratorRequest<ODataEntitySet, ODataEntity> req = client.getRetrieveRequestFactory().getEntitySetIteratorRequest(uriBuilder.build()); @@ -143,7 +143,7 @@ public class EntitySetTestITCase extends AbstractTestITCase { } private void readWithNext(final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People"); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People"); final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory(). getEntitySetRequest(uriBuilder.build()); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/EntityUpdateTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/EntityUpdateTestITCase.java index 669c10ce2..a51dd62d0 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/EntityUpdateTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/EntityUpdateTestITCase.java @@ -50,7 +50,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { getClient().getObjectFactory().newPrimitiveValueBuilder(). setType(EdmPrimitiveTypeKind.Duration).setText("PT0.0000002S").build())); - final URI upsertURI = getClient().getURIBuilder(testStaticServiceRootURL). + final URI upsertURI = getClient().newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Orders").appendKeySegment(9).build(); final ODataEntityUpdateRequest<ODataEntity> req = getClient().getCUDRequestFactory(). getEntityUpdateRequest(upsertURI, updateType, order); @@ -89,7 +89,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { changes.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("FriendlyName", getClient().getObjectFactory().newPrimitiveValueBuilder().buildString(newName))); - final URI uri = getClient().getURIBuilder(testStaticServiceRootURL). + final URI uri = getClient().newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Accounts").appendKeySegment(101). appendNavigationSegment("MyPaymentInstruments").appendKeySegment(101901).build(); final ODataEntityUpdateRequest<ODataEntity> req = getClient().getCUDRequestFactory(). @@ -118,11 +118,11 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { final ODataEntity changes = getClient().getObjectFactory().newEntity( new FullQualifiedName("Microsoft.Test.OData.Services.ODataWCFService.Customer")); final ODataLink parent = getClient().getObjectFactory().newEntityNavigationLink("Parent", - getClient().getURIBuilder(testStaticServiceRootURL). + getClient().newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("People").appendKeySegment(1).build()); changes.getNavigationLinks().add(parent); - final URI uri = getClient().getURIBuilder(testStaticServiceRootURL). + final URI uri = getClient().newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("People").appendKeySegment(5).build(); final ODataEntityUpdateRequest<ODataEntity> req = getClient().getCUDRequestFactory(). getEntityUpdateRequest(uri, UpdateType.PATCH, changes); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/ErrorResponseTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/ErrorResponseTestITCase.java index a9530cc32..902e73106 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/ErrorResponseTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/ErrorResponseTestITCase.java @@ -35,7 +35,7 @@ public class ErrorResponseTestITCase extends AbstractTestITCase { @Test public void jsonError() { - final URI readURI = getClient().getURIBuilder(testStaticServiceRootURL). + final URI readURI = getClient().newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customers").appendKeySegment(32). build(); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/FilterFactoryTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/FilterFactoryTestITCase.java index a85891ebb..2bb38516c 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/FilterFactoryTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/FilterFactoryTestITCase.java @@ -47,7 +47,7 @@ public class FilterFactoryTestITCase extends AbstractTestITCase { getFilterArgFactory().property("Orders/OrderID"), getFilterArgFactory().property("Customers/Order")); final URIBuilder uriBuilder = - client.getURIBuilder(testStaticServiceRootURL).appendCrossjoinSegment("Customers", "Orders").filter(filter); + client.newURIBuilder(testStaticServiceRootURL).appendCrossjoinSegment("Customers", "Orders").filter(filter); final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/KeyAsSegmentTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/KeyAsSegmentTestITCase.java index 56a6fd225..c6eca38da 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/KeyAsSegmentTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/KeyAsSegmentTestITCase.java @@ -50,7 +50,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase { } private void read(final ODataPubFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testKeyAsSegmentServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testKeyAsSegmentServiceRootURL). appendEntitySetSegment("Accounts").appendKeySegment(101); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); @@ -94,7 +94,7 @@ public class KeyAsSegmentTestITCase extends AbstractTestITCase { getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("middle")); changes.getProperties().add(middleName); - final URI uri = getClient().getURIBuilder(testKeyAsSegmentServiceRootURL). + final URI uri = getClient().newURIBuilder(testKeyAsSegmentServiceRootURL). appendEntitySetSegment("People").appendKeySegment(5).build(); final ODataEntityUpdateRequest<ODataEntity> req = getClient().getCUDRequestFactory(). getEntityUpdateRequest(uri, UpdateType.PATCH, changes); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java index 63c77acc1..5d0806b31 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/MediaEntityTestITCase.java @@ -57,11 +57,12 @@ import org.junit.Test; public class MediaEntityTestITCase extends AbstractTestITCase { private void read(final ODataClient client, final ODataPubFormat format) throws IOException { - final URIBuilder builder = client.getURIBuilder(testDemoServiceRootURL). + final URIBuilder builder = client.newURIBuilder(testDemoServiceRootURL). appendEntitySetSegment("Advertisements"). appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7")); final ODataEntityRequest<ODataEntity> entityReq = client.getRetrieveRequestFactory().getEntityRequest(builder.build()); + entityReq.setFormat(format); final ODataEntity entity = entityReq.execute().getBody(); assertNotNull(entity); @@ -98,10 +99,10 @@ public class MediaEntityTestITCase extends AbstractTestITCase { final String random = RandomStringUtils.random(110); final InputStream input = IOUtils.toInputStream(random); - final URI uri = client.getURIBuilder(testDemoServiceRootURL).appendEntitySetSegment("Advertisements").build(); + final URI uri = client.newURIBuilder(testDemoServiceRootURL).appendEntitySetSegment("Advertisements").build(); final ODataMediaEntityCreateRequest<ODataEntity> createReq = - client.getStreamedRequestFactory().getMediaEntityCreateRequest(uri, input); - final MediaEntityCreateStreamManager<ODataEntity> streamManager = createReq.execute(); + client.getCUDRequestFactory().getMediaEntityCreateRequest(uri, input); + final MediaEntityCreateStreamManager<ODataEntity> streamManager = createReq.payloadManager(); final ODataMediaEntityCreateResponse<ODataEntity> createRes = streamManager.getResponse(); assertEquals(201, createRes.getStatusCode()); @@ -124,7 +125,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase { assertEquals(204, updateRes.getStatusCode()); final ODataMediaRequest retrieveReq = client.getRetrieveRequestFactory(). - getMediaRequest(client.getURIBuilder(createdLocation.toASCIIString()).appendValueSegment().build()); + getMediaEntityRequest(client.newURIBuilder(createdLocation.toASCIIString()).build()); final ODataRetrieveResponse<InputStream> retrieveRes = retrieveReq.execute(); assertEquals(200, retrieveRes.getStatusCode()); @@ -144,23 +145,23 @@ public class MediaEntityTestITCase extends AbstractTestITCase { } private void update(final ODataPubFormat format) throws IOException, EdmPrimitiveTypeException { - final URI uri = client.getURIBuilder(testDemoServiceRootURL). + final URI uri = client.newURIBuilder(testDemoServiceRootURL). appendEntitySetSegment("Advertisements"). - appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7")).appendValueSegment().build(); + appendKeySegment(UUID.fromString("f89dee73-af9f-4cd4-b330-db93c25ff3c7")).build(); final String random = RandomStringUtils.random(124); // 1. update providing media content - final ODataMediaEntityUpdateRequest<ODataEntity> updateReq = client.getStreamedRequestFactory(). + final ODataMediaEntityUpdateRequest<ODataEntity> updateReq = client.getCUDRequestFactory(). getMediaEntityUpdateRequest(uri, IOUtils.toInputStream(random)); updateReq.setFormat(format); - final MediaEntityUpdateStreamManager<ODataEntity> streamManager = updateReq.execute(); + final MediaEntityUpdateStreamManager<ODataEntity> streamManager = updateReq.payloadManager(); final ODataMediaEntityUpdateResponse<ODataEntity> createRes = streamManager.getResponse(); assertEquals(204, createRes.getStatusCode()); // 2. check that media content was effectively uploaded - final ODataMediaRequest streamReq = client.getRetrieveRequestFactory().getMediaRequest(uri); + final ODataMediaRequest streamReq = client.getRetrieveRequestFactory().getMediaEntityRequest(uri); final ODataRetrieveResponse<InputStream> streamRes = streamReq.execute(); assertEquals(200, streamRes.getStatusCode()); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java index 08e671db8..495b9d07f 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/OpenTypeTestITCase.java @@ -53,7 +53,7 @@ public class OpenTypeTestITCase extends AbstractTestITCase { } private ODataEntity readRow(final ODataPubFormat format, final String uuid) { - final URIBuilder builder = getClient().getURIBuilder(testOpenTypeServiceRootURL). + final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL). appendEntitySetSegment("Row").appendKeySegment(UUID.fromString(uuid)); return read(format, builder.build()); } @@ -146,13 +146,13 @@ public class OpenTypeTestITCase extends AbstractTestITCase { getClient().getObjectFactory().newComplexProperty("aContact", contactDetails)); final ODataEntityCreateRequest<ODataEntity> createReq = getClient().getCUDRequestFactory(). - getEntityCreateRequest(getClient().getURIBuilder(testOpenTypeServiceRootURL). + getEntityCreateRequest(getClient().newURIBuilder(testOpenTypeServiceRootURL). appendEntitySetSegment("RowIndex").build(), rowIndex); createReq.setFormat(format); final ODataEntityCreateResponse<ODataEntity> createRes = createReq.execute(); assertEquals(201, createRes.getStatusCode()); - final URIBuilder builder = getClient().getURIBuilder(testOpenTypeServiceRootURL). + final URIBuilder builder = getClient().newURIBuilder(testOpenTypeServiceRootURL). appendEntitySetSegment("RowIndex").appendKeySegment(id); rowIndex = read(format, builder.build()); assertNotNull(rowIndex); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java index 9c6defb01..17b992185 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/OperationImportInvokeTestITCase.java @@ -35,10 +35,6 @@ import org.apache.olingo.commons.api.domain.v4.ODataEntity; import org.apache.olingo.commons.api.domain.v4.ODataEntitySet; import org.apache.olingo.commons.api.domain.v4.ODataEnumValue; import org.apache.olingo.commons.api.domain.v4.ODataProperty; -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmActionImport; -import org.apache.olingo.commons.api.edm.EdmEntityContainer; -import org.apache.olingo.commons.api.edm.EdmFunctionImport; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; import org.apache.olingo.commons.api.format.ODataPubFormat; @@ -46,26 +42,11 @@ import org.junit.Test; public class OperationImportInvokeTestITCase extends AbstractTestITCase { - private Edm getEdm() { - final Edm edm = getClient().getRetrieveRequestFactory(). - getMetadataRequest(testStaticServiceRootURL).execute().getBody(); - assertNotNull(edm); - - return edm; - } - private void functionImports(final ODataPubFormat format) throws EdmPrimitiveTypeException { - final Edm edm = getEdm(); - final EdmEntityContainer container = edm.getSchemas().get(0).getEntityContainer(); - assertNotNull(container); - // GetDefaultColor - EdmFunctionImport funcImp = container.getFunctionImport("GetDefaultColor"); - final ODataInvokeRequest<ODataProperty> defaultColorReq = getClient().getInvokeRequestFactory(). - getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment(funcImp.getName()).build(), - funcImp.getUnboundFunctions().get(0)); + getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL). + appendOperationCallSegment("GetDefaultColor").build(), ODataProperty.class); defaultColorReq.setFormat(format); final ODataProperty defaultColor = defaultColorReq.execute().getBody(); assertNotNull(defaultColor); @@ -74,15 +55,11 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase { assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Color", defaultColor.getEnumValue().getTypeName()); // GetPerson2 - funcImp = container.getFunctionImport("GetPerson2"); - - final ODataPrimitiveValue city = - getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("London"); + final ODataPrimitiveValue city = getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("London"); final ODataInvokeRequest<ODataEntity> person2Req = getClient().getInvokeRequestFactory(). - getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment(funcImp.getName()).build(), - funcImp.getUnboundFunctions().get(0), + getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL). + appendOperationCallSegment("GetPerson2").build(), ODataEntity.class, Collections.<String, ODataValue>singletonMap("city", city)); person2Req.setFormat(format); final ODataEntity person2 = person2Req.execute().getBody(); @@ -91,8 +68,6 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase { assertEquals(1, person2.getProperty("PersonID").getPrimitiveValue().toCastValue(Integer.class), 0); // GetPerson - funcImp = container.getFunctionImport("GetPerson"); - final ODataComplexValue<ODataProperty> address = getClient().getObjectFactory(). newLinkedComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address"); address.add(client.getObjectFactory().newPrimitiveProperty("Street", @@ -103,9 +78,8 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase { client.getObjectFactory().newPrimitiveValueBuilder().buildString("98052"))); final ODataInvokeRequest<ODataEntity> personReq = getClient().getInvokeRequestFactory(). - getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment(funcImp.getName()).build(), - funcImp.getUnboundFunctions().get(0), + getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL). + appendOperationCallSegment("GetPerson").build(), ODataEntity.class, Collections.<String, ODataValue>singletonMap("address", address)); personReq.setFormat(format); final ODataEntity person = personReq.execute().getBody(); @@ -113,27 +87,21 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase { assertEquals(person2, person); // GetAllProducts - funcImp = container.getFunctionImport("GetAllProducts"); - - final ODataInvokeRequest<ODataEntitySet> productsReq = getClient().getInvokeRequestFactory(). - getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment(funcImp.getName()).build(), - funcImp.getUnboundFunctions().get(0)); + final ODataInvokeRequest<ODataEntitySet> productsReq = getClient().getInvokeRequestFactory() + .getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL). + appendOperationCallSegment("GetAllProducts").build(), ODataEntitySet.class); productsReq.setFormat(format); final ODataEntitySet products = productsReq.execute().getBody(); assertNotNull(products); assertEquals(5, products.getCount()); // GetProductsByAccessLevel - funcImp = container.getFunctionImport("GetProductsByAccessLevel"); - final ODataEnumValue accessLevel = getClient().getObjectFactory(). newEnumValue("Microsoft.Test.OData.Services.ODataWCFService.AccessLevel", "None"); final ODataInvokeRequest<ODataProperty> prodByALReq = getClient().getInvokeRequestFactory(). - getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment(funcImp.getName()).build(), - funcImp.getUnboundFunctions().get(0), + getFunctionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL). + appendOperationCallSegment("GetProductsByAccessLevel").build(), ODataProperty.class, Collections.<String, ODataValue>singletonMap("accessLevel", accessLevel)); prodByALReq.setFormat(format); final ODataProperty prodByAL = prodByALReq.execute().getBody(); @@ -215,26 +183,17 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase { } private void actionImports(final ODataPubFormat format) { - final Edm edm = getEdm(); - final EdmEntityContainer container = edm.getSchemas().get(0).getEntityContainer(); - assertNotNull(container); - // Discount - EdmActionImport actImp = container.getActionImport("Discount"); - final ODataPrimitiveValue percentage = getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(22); final ODataInvokeRequest<ODataNoContent> discountReq = getClient().getInvokeRequestFactory(). - getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment(actImp.getName()).build(), - actImp.getUnboundAction(), + getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL). + appendOperationCallSegment("Discount").build(), ODataNoContent.class, Collections.<String, ODataValue>singletonMap("percentage", percentage)); discountReq.setFormat(format); final ODataNoContent discount = discountReq.execute().getBody(); assertNotNull(discount); // ResetBossAddress - actImp = container.getActionImport("ResetBossAddress"); - final ODataComplexValue<ODataProperty> address = getClient().getObjectFactory(). newLinkedComplexValue("Microsoft.Test.OData.Services.ODataWCFService.Address"); address.add(client.getObjectFactory().newPrimitiveProperty("Street", @@ -245,9 +204,8 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase { client.getObjectFactory().newPrimitiveValueBuilder().buildString("66010"))); final ODataInvokeRequest<ODataProperty> resetBossAddressReq = getClient().getInvokeRequestFactory(). - getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment(actImp.getName()).build(), - actImp.getUnboundAction(), + getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL). + appendOperationCallSegment("ResetBossAddress").build(), ODataProperty.class, Collections.<String, ODataValue>singletonMap("address", address)); resetBossAddressReq.setFormat(format); final ODataProperty resetBossAddress = resetBossAddressReq.execute().getBody(); @@ -294,21 +252,14 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase { } private void bossEmails(final ODataPubFormat format) { - final Edm edm = getEdm(); - final EdmEntityContainer container = edm.getSchemas().get(0).getEntityContainer(); - assertNotNull(container); - // ResetBossEmail - final EdmActionImport actImp = container.getActionImport("ResetBossEmail"); - final ODataCollectionValue<org.apache.olingo.commons.api.domain.v4.ODataValue> emails = getClient().getObjectFactory().newCollectionValue("Collection(Edm.String)"); emails.add(getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("first@olingo.apache.org")); emails.add(getClient().getObjectFactory().newPrimitiveValueBuilder().buildString("second@olingo.apache.org")); ODataInvokeRequest<ODataProperty> bossEmailsReq = getClient().getInvokeRequestFactory(). - getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment(actImp.getName()).build(), - actImp.getUnboundAction(), + getActionInvokeRequest(getClient().newURIBuilder(testStaticServiceRootURL). + appendOperationCallSegment("ResetBossEmail").build(), ODataProperty.class, Collections.<String, ODataValue>singletonMap("emails", emails)); bossEmailsReq.setFormat(format); final ODataProperty bossEmails = bossEmailsReq.execute().getBody(); @@ -316,16 +267,12 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase { assertTrue(bossEmails.hasCollectionValue()); assertEquals(2, bossEmails.getCollectionValue().size()); - final EdmFunctionImport funcImp = container.getFunctionImport("GetBossEmails"); - final Map<String, ODataValue> params = new LinkedHashMap<String, ODataValue>(2); params.put("start", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(0)); params.put("count", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt32(100)); - bossEmailsReq = getClient().getInvokeRequestFactory(). - getInvokeRequest(getClient().getURIBuilder(testStaticServiceRootURL). - appendOperationCallSegment(funcImp.getName()).build(), - funcImp.getUnboundFunctions().get(0), - params); + bossEmailsReq = getClient().getInvokeRequestFactory().getFunctionInvokeRequest( + getClient().newURIBuilder(testStaticServiceRootURL). + appendOperationCallSegment("GetBossEmails").build(), ODataProperty.class, params); bossEmailsReq.setFormat(format); final ODataProperty bossEmailsViaGET = bossEmailsReq.execute().getBody(); assertNotNull(bossEmailsViaGET); @@ -344,5 +291,4 @@ public class OperationImportInvokeTestITCase extends AbstractTestITCase { public void jsonBossEmails() throws EdmPrimitiveTypeException { bossEmails(ODataPubFormat.JSON_FULL_METADATA); } - } diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java index 8dbeb8647..abd4cd0b8 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyTestITCase.java @@ -22,14 +22,19 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.io.IOException; +import org.apache.olingo.client.api.communication.request.cud.ODataDeleteRequest; +import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateRequest; import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest; import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType; import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest; +import org.apache.olingo.client.api.communication.response.ODataDeleteResponse; +import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse; import org.apache.olingo.client.api.communication.response.ODataPropertyUpdateResponse; import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse; import org.apache.olingo.client.api.http.HttpMethod; import org.apache.olingo.client.api.uri.v4.URIBuilder; import org.apache.olingo.client.api.v4.ODataClient; +import org.apache.olingo.commons.api.domain.v4.ODataEntity; import org.apache.olingo.commons.api.domain.v4.ODataProperty; import org.apache.olingo.commons.api.domain.v4.ODataValuable; import org.apache.olingo.commons.api.format.ODataFormat; @@ -38,7 +43,7 @@ import org.junit.Test; public class PropertyTestITCase extends AbstractTestITCase { private void _enum(final ODataClient client, final ODataFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Products").appendKeySegment(5).appendPropertySegment("CoverColors"); final ODataPropertyRequest<ODataProperty> req = client.getRetrieveRequestFactory(). getPropertyRequest(uriBuilder.build()); @@ -67,7 +72,7 @@ public class PropertyTestITCase extends AbstractTestITCase { } private void geospatial(final ODataClient client, final ODataFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Home"); final ODataPropertyRequest<ODataProperty> req = client.getRetrieveRequestFactory(). getPropertyRequest(uriBuilder.build()); @@ -95,7 +100,7 @@ public class PropertyTestITCase extends AbstractTestITCase { } private void complex(final ODataClient client, final ODataFormat format) { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customers").appendKeySegment(2).appendPropertySegment("HomeAddress"); final ODataPropertyRequest<ODataProperty> req = client.getRetrieveRequestFactory(). getPropertyRequest(uriBuilder.build()); @@ -104,7 +109,7 @@ public class PropertyTestITCase extends AbstractTestITCase { final ODataProperty prop = req.execute().getBody(); assertNotNull(prop); // cast to workaround JDK 6 bug, fixed in JDK 7 - assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Address", + assertEquals("Microsoft.Test.OData.Services.ODataWCFService.Address", ((ODataValuable) prop).getValue().getTypeName()); } @@ -124,7 +129,7 @@ public class PropertyTestITCase extends AbstractTestITCase { } private void updateComplexProperty(final ODataFormat format, final UpdateType type) throws IOException { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customers").appendKeySegment(1).appendPropertySegment("HomeAddress"); ODataPropertyRequest<ODataProperty> retrieveReq = @@ -167,4 +172,31 @@ public class PropertyTestITCase extends AbstractTestITCase { updateComplexProperty(ODataFormat.JSON_FULL_METADATA, UpdateType.PATCH); } + @Test + public void createAndDelete() { + // 1. create + final ODataEntity category = client.getObjectFactory().newEntity(null); + category.setReference(client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("Categories").appendKeySegment(1).build().toASCIIString()); + + final URIBuilder createBuilder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("Products").appendKeySegment(0).appendNavigationSegment("Categories"). + appendRefSegment(); + final ODataEntityCreateRequest<ODataEntity> createReq = client.getCUDRequestFactory(). + getEntityCreateRequest(createBuilder.build(), category); + + final ODataEntityCreateResponse<ODataEntity> createRes = createReq.execute(); + assertEquals(204, createRes.getStatusCode()); + + // 2. delete + final URIBuilder deleteBuilder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("Products").appendKeySegment(0).appendNavigationSegment("Categories"). + appendKeySegment(1).appendRefSegment(); + final ODataDeleteRequest deleteReq = client.getCUDRequestFactory(). + getDeleteRequest(deleteBuilder.build()); + + final ODataDeleteResponse deleteRes = deleteReq.execute(); + assertEquals(204, deleteRes.getStatusCode()); + } + } diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java index 5f7615319..1d99bb30e 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/PropertyValueTestITCase.java @@ -41,40 +41,36 @@ public class PropertyValueTestITCase extends AbstractTestITCase { @Test public void retrieveIntPropertyValueTest() throws EdmPrimitiveTypeException { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PersonID"). - appendValueSegment(); - final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PersonID"); + final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); assertEquals("5", req.execute().getBody().toString()); } @Test public void retrieveBooleanPropertyValueTest() throws EdmPrimitiveTypeException { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("IsRegistered"). - appendValueSegment(); - final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("IsRegistered"); + final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); assertEquals("true", req.execute().getBody().toString()); } @Test public void retrieveStringPropertyValueTest() throws EdmPrimitiveTypeException { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("FirstName"). - appendValueSegment(); - final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("FirstName"); + final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); assertEquals("Peter", req.execute().getBody().toString()); } @Test public void retrieveDatePropertyValueTest() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("Orders").appendKeySegment(8).appendPropertySegment("OrderDate"). - appendValueSegment(); - final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("Orders").appendKeySegment(8).appendPropertySegment("OrderDate"); + final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); final ODataPrimitiveValue property = req.execute().getBody(); assertEquals("2011-03-04T16:03:57Z", property.toString()); @@ -82,10 +78,9 @@ public class PropertyValueTestITCase extends AbstractTestITCase { @Test public void retrieveDecimalPropertyValueTest() throws EdmPrimitiveTypeException { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Height"). - appendValueSegment(); - final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Height"); + final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); final ODataPrimitiveValue property = req.execute().getBody(); assertEquals("179", property.toString()); @@ -93,10 +88,9 @@ public class PropertyValueTestITCase extends AbstractTestITCase { @Test public void retrieveBinaryPropertyValueTest() throws IOException { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC"). - appendValueSegment(); - final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC"); + final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); final ODataPrimitiveValue property = req.execute().getBody(); assertEquals("fi653p3+MklA/LdoBlhWgnMTUUEo8tEgtbMXnF0a3CUNL9BZxXpSRiD9ebTnmNR0zWPjJ" @@ -105,43 +99,40 @@ public class PropertyValueTestITCase extends AbstractTestITCase { @Test(expected = ODataClientErrorException.class) public void retrieveBinaryPropertyValueTestWithAtom() throws IOException { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC"). - appendValueSegment(); - final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC"); + final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); req.setAccept(ODataPubFormat.ATOM.toString(ODataServiceVersion.V40)); req.execute().getBody(); } @Test(expected = ODataClientErrorException.class) public void retrieveBinaryPropertyValueTestWithXML() throws IOException { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC"). - appendValueSegment(); - final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("PDC"); + final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); req.setAccept(ODataFormat.XML.toString(client.getServiceVersion())); req.execute().getBody(); } @Test public void retrieveCollectionPropertyValueTest() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("Numbers"); final ODataPropertyRequest<ODataProperty> req = client.getRetrieveRequestFactory(). getPropertyRequest(uriBuilder.build()); req.setFormat(ODataFormat.XML); final ODataProperty property = req.execute().getBody(); // cast to workaround JDK 6 bug, fixed in JDK 7 - assertTrue(((ODataValuable)property).getValue().isCollection()); + assertTrue(((ODataValuable) property).getValue().isCollection()); assertEquals("555-555-5555", property.getCollectionValue().iterator().next().asPrimitive().toString()); } @Test public void retrieveNullPropertyValueTest() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). - appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("HomeAddress"). - appendValueSegment(); - final ODataValueRequest req = client.getRetrieveRequestFactory().getValueRequest(uriBuilder.build()); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). + appendEntitySetSegment("People").appendKeySegment(5).appendPropertySegment("HomeAddress"); + final ODataValueRequest req = client.getRetrieveRequestFactory().getPropertyValueRequest(uriBuilder.build()); req.setFormat(ODataValueFormat.TEXT); final ODataPrimitiveValue property = req.execute().getBody(); assertTrue(StringUtils.isBlank(property.toString())); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java index 20684b512..207cbd063 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/QueryOptionsTestITCase.java @@ -47,7 +47,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { * Test <tt>$expand</tt>. */ public void expand() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customers").appendKeySegment(1).expand("Orders"); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); @@ -58,7 +58,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { @Test public void expandWithFilter() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customers").appendKeySegment(1). expandWithOptions("Orders", Collections.<QueryOption, Object>singletonMap( QueryOption.FILTER, getClient().getFilterFactory().gt("OrderID", 7).build())); @@ -76,7 +76,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { */ @Test public void filterOrderby() throws EdmPrimitiveTypeException { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("People").filter("(PersonID lt 3)"); // 1. check that filtered entity set looks as expected @@ -120,7 +120,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { */ @Test public void format() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customers").appendKeySegment(1).format("json"); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); @@ -136,7 +136,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { * Test <tt>$skip</tt>. */ public void skip() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People"); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People"); // 1. check that filtered entity set looks as expected final ODataEntitySetRequest<ODataEntitySet> req = @@ -150,7 +150,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { * Test <tt>$top</tt>. */ public void top() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People"); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("People"); // 1. check that filtered entity set looks as expected final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory(). @@ -165,7 +165,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { */ @Test public void skiptoken() throws EdmPrimitiveTypeException { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL); + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL); uriBuilder.appendEntitySetSegment("People").skipToken("5"); final ODataEntitySetRequest<ODataEntitySet> req = @@ -186,7 +186,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { @Test public void count() { final URIBuilder uriBuilder = - client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").count(true); + client.newURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Customers").count(true); final ODataEntitySetRequest<ODataEntitySet> req = client.getRetrieveRequestFactory().getEntitySetRequest(uriBuilder.build()); @@ -201,7 +201,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { */ @Test public void select() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("Customers").appendKeySegment(1).select("PersonID,Orders").expand("Orders"); final ODataEntityRequest<ODataEntity> req = client.getRetrieveRequestFactory().getEntityRequest(uriBuilder.build()); @@ -214,7 +214,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { @Test public void issue253() { - final URIBuilder uriBuilder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder uriBuilder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("relatedEntitySelect").appendEntitySetSegment("Customers").appendKeySegment(1). expandWithSelect("Orders", "OrderID", "OrderDetails"); @@ -226,7 +226,7 @@ public class QueryOptionsTestITCase extends AbstractTestITCase { @Test public void search() { - final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL). + final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL). appendEntitySetSegment("People").search(client.getSearchFactory(). or(client.getSearchFactory().literal("Bob"), client.getSearchFactory().literal("Jill"))); diff --git a/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java index 953640bc9..46429c695 100644 --- a/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/v4/SingletonTestITCase.java @@ -41,7 +41,7 @@ import org.junit.Test; public class SingletonTestITCase extends AbstractTestITCase { private void read(final ODataClient client, final ODataPubFormat format) throws EdmPrimitiveTypeException { - final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company"); + final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company"); final ODataEntityRequest<Singleton> singleton = client.getRetrieveRequestFactory().getSingletonRequest(builder.build()); singleton.setFormat(format); @@ -73,7 +73,7 @@ public class SingletonTestITCase extends AbstractTestITCase { private void readWithAnnotations(final ODataClient client, final ODataPubFormat format) throws EdmPrimitiveTypeException { - final URIBuilder builder = client.getURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Boss"); + final URIBuilder builder = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Boss"); final ODataEntityRequest<Singleton> singleton = client.getRetrieveRequestFactory().getSingletonRequest(builder.build()); singleton.setFormat(format); @@ -107,7 +107,7 @@ public class SingletonTestITCase extends AbstractTestITCase { changes.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Revenue", getClient().getObjectFactory().newPrimitiveValueBuilder().buildInt64(132520L))); - final URI uri = client.getURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company").build(); + final URI uri = client.newURIBuilder(testStaticServiceRootURL).appendSingletonSegment("Company").build(); final ODataEntityUpdateRequest<Singleton> req = getClient().getCUDRequestFactory(). getSingletonUpdateRequest(uri, UpdateType.PATCH, changes); req.setFormat(format); diff --git a/fit/src/test/resources/META-INF/org.apache.olingo.ext.proxy.complex b/fit/src/test/resources/META-INF/org.apache.olingo.ext.proxy.complex index 3c43cdf66..066bbc134 100644 --- a/fit/src/test/resources/META-INF/org.apache.olingo.ext.proxy.complex +++ b/fit/src/test/resources/META-INF/org.apache.olingo.ext.proxy.complex @@ -19,3 +19,4 @@ org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odata org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.CompanyAddress org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.AccountInfo org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.ContactDetails +org.apache.olingo.fit.proxy.v4.opentype.microsoft.test.odata.services.opentypesservicev4.types.AccountInfo diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonEdmEnabledODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonEdmEnabledODataClient.java index ab5569ee7..196c6e96c 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonEdmEnabledODataClient.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonEdmEnabledODataClient.java @@ -50,7 +50,7 @@ public interface CommonEdmEnabledODataClient<UT extends CommonUpdateType> extend */ Edm getCachedEdm(); - CommonURIBuilder<?> getURIBuilder(); + CommonURIBuilder<?> newURIBuilder(); @Override EdmEnabledInvokeRequestFactory getInvokeRequestFactory(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java index 1d9cdd399..1a838492f 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java @@ -25,7 +25,6 @@ import org.apache.olingo.client.api.communication.request.cud.CommonCUDRequestFa import org.apache.olingo.client.api.communication.request.cud.CommonUpdateType; import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory; import org.apache.olingo.client.api.communication.request.retrieve.CommonRetrieveRequestFactory; -import org.apache.olingo.client.api.communication.request.streamed.StreamedRequestFactory; import org.apache.olingo.client.api.op.ClientODataDeserializer; import org.apache.olingo.commons.api.domain.CommonODataObjectFactory; import org.apache.olingo.client.api.op.CommonODataBinder; @@ -45,13 +44,13 @@ public interface CommonODataClient<UT extends CommonUpdateType> { ODataServiceVersion getServiceVersion(); - ODataHeaders getVersionHeaders(); + ODataHeaders newVersionHeaders(); CommonConfiguration getConfiguration(); ODataPreferences newPreferences(); - CommonURIBuilder<?> getURIBuilder(String serviceRoot); + CommonURIBuilder<?> newURIBuilder(String serviceRoot); CommonFilterFactory getFilterFactory(); @@ -71,8 +70,6 @@ public interface CommonODataClient<UT extends CommonUpdateType> { CommonCUDRequestFactory<UT> getCUDRequestFactory(); - StreamedRequestFactory getStreamedRequestFactory(); - InvokeRequestFactory getInvokeRequestFactory(); CommonBatchRequestFactory getBatchRequestFactory(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataHeaders.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataHeaders.java index 51de80dfc..bc00459e5 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataHeaders.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataHeaders.java @@ -56,4 +56,35 @@ public interface ODataHeaders { * @return header names. */ Collection<String> getHeaderNames(); + + /** + * Add the specified (custom) header (header name is case-insensitive). + * + * @param name header key. + * @param value header value. + * @return the current updated header instance. + */ + ODataHeaders setHeader(String name, String value); + + /** + * Add the specified header. + * + * @param name header key. + * @param value header value. + * @return the current updated header instance. + */ + ODataHeaders setHeader(HeaderName name, String value); + + /** + * Removes the header identified by the given name. + * <br/> + * Please note that header name is case-insensitive. + * + * @param name name of the header to be retrieved. + * @return header name (if found). + */ + String removeHeader(HeaderName name); + + String removeHeader(String name); + } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataStreamManager.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataPayloadManager.java similarity index 95% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataStreamManager.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataPayloadManager.java index a371f1d73..478bb5936 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataStreamManager.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataPayloadManager.java @@ -27,7 +27,7 @@ import org.apache.olingo.client.api.communication.response.ODataResponse; * * @param <T> OData response type corresponding to the request implementation. */ -public interface ODataStreamManager<T extends ODataResponse> extends ODataStreamer { +public interface ODataPayloadManager<T extends ODataResponse> extends ODataStreamer { /** * Gets payload stream. diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataStreamedRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataStreamedRequest.java index 5a3a19334..978dc35ee 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataStreamedRequest.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/ODataStreamedRequest.java @@ -26,13 +26,13 @@ import org.apache.olingo.client.api.communication.response.ODataResponse; * @param <V> OData response type corresponding to the request implementation. * @param <T> OData request payload type corresponding to the request implementation. */ -public interface ODataStreamedRequest<V extends ODataResponse, T extends ODataStreamManager<V>> +public interface ODataStreamedRequest<V extends ODataResponse, T extends ODataPayloadManager<V>> extends ODataRequest { /** - * Streamed request execute. + * Streamed payload manager. * * @return OData request payload manager object. */ - T execute(); + T payloadManager(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/BatchStreamManager.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/BatchManager.java similarity index 75% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/BatchStreamManager.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/BatchManager.java index e448b57d5..76321802a 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/BatchStreamManager.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/BatchManager.java @@ -18,13 +18,14 @@ */ package org.apache.olingo.client.api.communication.request.batch; -import org.apache.olingo.client.api.communication.request.ODataStreamManager; +import org.apache.olingo.client.api.communication.request.ODataBatchableRequest; +import org.apache.olingo.client.api.communication.request.ODataPayloadManager; import org.apache.olingo.client.api.communication.response.ODataBatchResponse; /** * Batch request payload management. */ -public interface BatchStreamManager extends ODataStreamManager<ODataBatchResponse> { +public interface BatchManager extends ODataPayloadManager<ODataBatchResponse> { /** * Gets a changeset batch item instance. A changeset can be submitted embedded into a batch request only. @@ -34,9 +35,9 @@ public interface BatchStreamManager extends ODataStreamManager<ODataBatchRespons ODataChangeset addChangeset(); /** - * Gets a retrieve batch item instance. A retrieve item can be submitted embedded into a batch request only. + * Adds a retrieve batch item instance. A retrieve item can be submitted embedded into a batch request only. * - * @return ODataRetrieve instance. + * @param request retrieve request to batch. */ - ODataRetrieve addRetrieve(); + void addRequest(final ODataBatchableRequest request); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/ODataRetrieve.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/ODataSingleRequest.java similarity index 90% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/ODataRetrieve.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/ODataSingleRequest.java index 948cdc323..0f3bc79d1 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/ODataRetrieve.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/ODataSingleRequest.java @@ -23,7 +23,7 @@ import org.apache.olingo.client.api.communication.request.ODataBatchableRequest; /** * Retrieve request wrapper for the corresponding batch item. */ -public interface ODataRetrieve extends ODataBatchRequestItem { +public interface ODataSingleRequest extends ODataBatchRequestItem { /** * Serialize and send the given request. @@ -33,5 +33,5 @@ public interface ODataRetrieve extends ODataBatchRequestItem { * @param request request to be serialized. * @return current item instance. */ - ODataRetrieve setRequest(final ODataBatchableRequest request); + ODataSingleRequest setRequest(final ODataBatchableRequest request); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v3/ODataBatchRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v3/ODataBatchRequest.java index 6d45b0c92..009f7d06a 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v3/ODataBatchRequest.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v3/ODataBatchRequest.java @@ -19,6 +19,7 @@ package org.apache.olingo.client.api.communication.request.batch.v3; import org.apache.olingo.client.api.communication.request.ODataStreamedRequest; +import org.apache.olingo.client.api.communication.request.batch.BatchManager; import org.apache.olingo.client.api.communication.request.batch.CommonODataBatchRequest; import org.apache.olingo.client.api.communication.response.ODataBatchResponse; @@ -26,5 +27,5 @@ import org.apache.olingo.client.api.communication.response.ODataBatchResponse; * This class implements a batch request. */ public interface ODataBatchRequest - extends CommonODataBatchRequest, ODataStreamedRequest<ODataBatchResponse, BatchStreamManager> { + extends CommonODataBatchRequest, ODataStreamedRequest<ODataBatchResponse, BatchManager> { } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v4/ODataBatchRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v4/ODataBatchRequest.java index 817546552..6c348ad9d 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v4/ODataBatchRequest.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/batch/v4/ODataBatchRequest.java @@ -19,6 +19,7 @@ package org.apache.olingo.client.api.communication.request.batch.v4; import org.apache.olingo.client.api.communication.request.ODataStreamedRequest; +import org.apache.olingo.client.api.communication.request.batch.BatchManager; import org.apache.olingo.client.api.communication.request.batch.CommonODataBatchRequest; import org.apache.olingo.client.api.communication.response.ODataBatchResponse; @@ -26,7 +27,7 @@ import org.apache.olingo.client.api.communication.response.ODataBatchResponse; * This class implements a batch request. */ public interface ODataBatchRequest - extends CommonODataBatchRequest, ODataStreamedRequest<ODataBatchResponse, BatchStreamManager> { + extends CommonODataBatchRequest, ODataStreamedRequest<ODataBatchResponse, BatchManager> { ODataBatchRequest continueOnError(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java index ac09277fe..eac9a8a94 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/cud/CommonCUDRequestFactory.java @@ -18,8 +18,12 @@ */ package org.apache.olingo.client.api.communication.request.cud; +import java.io.InputStream; import java.io.Serializable; import java.net.URI; +import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityCreateRequest; +import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityUpdateRequest; +import org.apache.olingo.client.api.communication.request.streamed.ODataStreamUpdateRequest; import org.apache.olingo.commons.api.domain.CommonODataEntity; import org.apache.olingo.commons.api.domain.ODataPrimitiveValue; import org.apache.olingo.commons.api.domain.CommonODataProperty; @@ -119,4 +123,41 @@ public interface CommonCUDRequestFactory<UT extends CommonUpdateType> extends Se * @return new ODataDeleteRequest instance. */ ODataDeleteRequest getDeleteRequest(URI targetURI); + + /** + * Gets a media entity create request object instance. + * <br/> + * Use this kind of request to create a new media entity. + * + * @param <E> concrete ODataEntity implementation + * @param targetURI entity set URI. + * @param media entity blob to be created. + * @return new ODataMediaEntityCreateRequest instance. + */ + <E extends CommonODataEntity> ODataMediaEntityCreateRequest<E> getMediaEntityCreateRequest( + URI targetURI, InputStream media); + + /** + * Gets a stream update request object instance. + * <br/> + * Use this kind of request to update a named stream property. + * + * @param targetURI target URI. + * @param stream stream to be updated. + * @return new ODataStreamUpdateRequest instance. + */ + ODataStreamUpdateRequest getStreamUpdateRequest(URI targetURI, InputStream stream); + + /** + * Gets a media entity update request object instance. + * <br/> + * Use this kind of request to update a media entity. + * + * @param <E> concrete ODataEntity implementation + * @param editURI media entity edit link URI. + * @param media entity blob to be updated. + * @return new ODataMediaEntityUpdateRequest instance. + */ + <E extends CommonODataEntity> ODataMediaEntityUpdateRequest<E> getMediaEntityUpdateRequest( + URI editURI, InputStream media); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/EdmEnabledInvokeRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/EdmEnabledInvokeRequestFactory.java index d8d2538e6..8429b51f2 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/EdmEnabledInvokeRequestFactory.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/EdmEnabledInvokeRequestFactory.java @@ -18,9 +18,11 @@ */ package org.apache.olingo.client.api.communication.request.invoke; +import java.net.URI; import java.util.Map; import org.apache.olingo.commons.api.domain.ODataInvokeResult; import org.apache.olingo.commons.api.domain.ODataValue; +import org.apache.olingo.commons.api.edm.FullQualifiedName; public interface EdmEnabledInvokeRequestFactory extends InvokeRequestFactory { @@ -48,7 +50,7 @@ public interface EdmEnabledInvokeRequestFactory extends InvokeRequestFactory { /** * Gets an invoke request instance for the action import with the given name. * - * @param <RES> OData domain object result, derived from return type defined in the function import + * @param <RES> OData domain object result, derived from return type defined in the action import * @param actionImportName operation to be invoked * @return new {@link ODataInvokeRequest} instance. */ @@ -58,11 +60,70 @@ public interface EdmEnabledInvokeRequestFactory extends InvokeRequestFactory { /** * Gets an invoke request instance for the action import with the given name. * - * @param <RES> OData domain object result, derived from return type defined in the function import + * @param <RES> OData domain object result, derived from return type defined in the action import * @param actionImportName operation to be invoked * @param parameters parameters to pass to operation import invocation * @return new {@link ODataInvokeRequest} instance. */ <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getActionImportInvokeRequest( String actionImportName, Map<String, ODataValue> parameters); + + /** + * Gets an invoke request instance for the function bound to given URI (no parameters). + * + * @param <RES> OData domain object result + * @param bindingParameterURI binding parameter URI + * @param functionName operation to be invoked + * @param bindingParameterTypeName binding parameter type full qualified name + * @param isBindingParameterCollection whether binding parameter is collection + * @return new {@link ODataInvokeRequest} instance. + */ + <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getBoundFunctionInvokeRequest( + URI bindingParameterURI, FullQualifiedName functionName, FullQualifiedName bindingParameterTypeName, + Boolean isBindingParameterCollection); + + /** + * Gets an invoke request instance for the function bound to given URI (with parameters). + * + * @param <RES> OData domain object result + * @param bindingParameterURI binding parameter URI + * @param functionName operation to be invoked + * @param bindingParameterTypeName binding parameter type full qualified name + * @param isBindingParameterCollection whether binding parameter is collection + * @param parameters parameters to pass to function invocation + * @return new {@link ODataInvokeRequest} instance. + */ + <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getBoundFunctionInvokeRequest( + URI bindingParameterURI, FullQualifiedName functionName, FullQualifiedName bindingParameterTypeName, + Boolean isBindingParameterCollection, Map<String, ODataValue> parameters); + + /** + * Gets an invoke request instance for the action bound to given URI (no parameters). + * + * @param <RES> OData domain object result + * @param bindingParameterURI binding parameter URI + * @param actionName operation to be invoked + * @param bindingParameterTypeName binding parameter type full qualified name + * @param isBindingParameterCollection whether binding parameter is collection + * @return new {@link ODataInvokeRequest} instance. + */ + <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getBoundActionInvokeRequest( + URI bindingParameterURI, FullQualifiedName actionName, FullQualifiedName bindingParameterTypeName, + Boolean isBindingParameterCollection); + + /** + * Gets an invoke request instance for the action bound to given URI (with parameters). + * + * @param <RES> OData domain object result + * @param bindingParameterURI binding parameter URI + * @param actionName operation to be invoked + * @param bindingParameterTypeName binding parameter type full qualified name + * @param isBindingParameterCollection whether binding parameter is collection + * @param parameters parameters to pass to function invocation + * @return new {@link ODataInvokeRequest} instance. + */ + <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getBoundActionInvokeRequest( + URI bindingParameterURI, FullQualifiedName actionName, FullQualifiedName bindingParameterTypeName, + Boolean isBindingParameterCollection, Map<String, ODataValue> parameters); + } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/InvokeRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/InvokeRequestFactory.java index 1eeaf1c9f..e869ed6bf 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/InvokeRequestFactory.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/InvokeRequestFactory.java @@ -21,9 +21,9 @@ package org.apache.olingo.client.api.communication.request.invoke; import java.io.Serializable; import java.net.URI; import java.util.Map; +import org.apache.olingo.client.api.http.HttpMethod; import org.apache.olingo.commons.api.domain.ODataInvokeResult; import org.apache.olingo.commons.api.domain.ODataValue; -import org.apache.olingo.commons.api.edm.EdmOperation; /** * OData request factory class. @@ -31,24 +31,62 @@ import org.apache.olingo.commons.api.edm.EdmOperation; public interface InvokeRequestFactory extends Serializable { /** - * Gets an invoke request instance. + * Gets an invoke request instance for the operation bound to given URI. + * <br/> + * This method is mainly meant for internal usage, but defined for generic calls from proxy; normally, one of other + * methods should be used instead. * - * @param <RES> OData domain object result, derived from return type defined in the function import - * @param uri URI that identifies the function import - * @param operation operation to be invoked - * @return new {@link ODataInvokeRequest} instance. - */ - <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getInvokeRequest(URI uri, EdmOperation operation); - - /** - * Gets an invoke request instance. - * - * @param <RES> OData domain object result, derived from return type defined in the function import - * @param uri URI that identifies the function import - * @param operation operation to be invoked - * @param parameters parameters to pass to operation invocation + * @param <RES> OData domain object result + * @param method HTTP invocation method + * @param uri invocation URI + * @param resultRef reference Class for result + * @param parameters parameters to pass to function invocation * @return new {@link ODataInvokeRequest} instance. */ <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getInvokeRequest( - URI uri, EdmOperation operation, Map<String, ODataValue> parameters); + HttpMethod method, URI uri, Class<RES> resultRef, Map<String, ODataValue> parameters); + + /** + * Gets an invoke request instance for the function bound to given URI (no parameters). + * + * @param <RES> OData domain object result + * @param uri invocation URI + * @param resultRef reference Class for result + * @return new {@link ODataInvokeRequest} instance. + */ + <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getFunctionInvokeRequest(URI uri, Class<RES> resultRef); + + /** + * Gets an invoke request instance for the function bound to given URI (with parameters). + * + * @param <RES> OData domain object result + * @param uri invocation URI + * @param resultRef reference Class for result + * @param parameters parameters to pass to function invocation + * @return new {@link ODataInvokeRequest} instance. + */ + <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getFunctionInvokeRequest( + URI uri, Class<RES> resultRef, Map<String, ODataValue> parameters); + + /** + * Gets an invoke request instance for the action bound to given URI (no parameters). + * + * @param <RES> OData domain object result + * @param uri invocation URI + * @param resultRef reference Class for result + * @return new {@link ODataInvokeRequest} instance. + */ + <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getActionInvokeRequest(URI uri, Class<RES> resultRef); + + /** + * Gets an invoke request instance for the action bound to given URI (with parameters). + * + * @param <RES> OData domain object result + * @param uri invocation URI + * @param resultRef reference Class for result + * @param parameters parameters to pass to action invocation + * @return new {@link ODataInvokeRequest} instance. + */ + <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getActionInvokeRequest( + URI uri, Class<RES> resultRef, Map<String, ODataValue> parameters); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java index 69e53e7e4..0c992987d 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java @@ -99,6 +99,15 @@ public interface CommonRetrieveRequestFactory extends Serializable { * @return new {@link ODataPropertyRequest} instance. */ <T extends CommonODataProperty> ODataPropertyRequest<T> getPropertyRequest(URI uri); + + /** + * Gets a uri request returning a single OData entity property value. + * + * @param <T> concrete ODataProperty implementation. + * @param uri request URI. + * @return new {@link ODataValueRequest} instance. + */ + ODataValueRequest getPropertyValueRequest(URI uri); /** * Gets a uri request returning a single OData entity property value. @@ -115,6 +124,14 @@ public interface CommonRetrieveRequestFactory extends Serializable { * @return new {@link ODataMediaRequest} instance. */ ODataMediaRequest getMediaRequest(URI uri); + + /** + * Gets a uri request returning a media entity. + * + * @param uri request URI. + * @return new {@link ODataMediaRequest} instance. + */ + ODataMediaRequest getMediaEntityRequest(URI uri); /** * Implements a raw request request without specifying any return type. diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/MediaEntityCreateStreamManager.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/MediaEntityCreateStreamManager.java index 7b24fb4b3..74d5827a1 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/MediaEntityCreateStreamManager.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/MediaEntityCreateStreamManager.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.client.api.communication.request.streamed; -import org.apache.olingo.client.api.communication.request.ODataStreamManager; +import org.apache.olingo.client.api.communication.request.ODataPayloadManager; import org.apache.olingo.client.api.communication.response.ODataMediaEntityCreateResponse; import org.apache.olingo.commons.api.domain.CommonODataEntity; @@ -28,5 +28,5 @@ import org.apache.olingo.commons.api.domain.CommonODataEntity; * @param <E> concrete ODataEntity implementation */ public interface MediaEntityCreateStreamManager<E extends CommonODataEntity> - extends ODataStreamManager<ODataMediaEntityCreateResponse<E>> { + extends ODataPayloadManager<ODataMediaEntityCreateResponse<E>> { } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/MediaEntityUpdateStreamManager.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/MediaEntityUpdateStreamManager.java index 230fab10d..0fa37d5db 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/MediaEntityUpdateStreamManager.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/MediaEntityUpdateStreamManager.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.client.api.communication.request.streamed; -import org.apache.olingo.client.api.communication.request.ODataStreamManager; +import org.apache.olingo.client.api.communication.request.ODataPayloadManager; import org.apache.olingo.client.api.communication.response.ODataMediaEntityUpdateResponse; import org.apache.olingo.commons.api.domain.CommonODataEntity; @@ -28,5 +28,5 @@ import org.apache.olingo.commons.api.domain.CommonODataEntity; * @param <E> concrete ODataEntity implementation */ public interface MediaEntityUpdateStreamManager<E extends CommonODataEntity> - extends ODataStreamManager<ODataMediaEntityUpdateResponse<E>> { + extends ODataPayloadManager<ODataMediaEntityUpdateResponse<E>> { } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/ODataStreamedEntityRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/ODataStreamedEntityRequest.java index 7d898f50c..1af787e88 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/ODataStreamedEntityRequest.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/ODataStreamedEntityRequest.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.client.api.communication.request.streamed; -import org.apache.olingo.client.api.communication.request.ODataStreamManager; +import org.apache.olingo.client.api.communication.request.ODataPayloadManager; import org.apache.olingo.client.api.communication.request.ODataStreamedRequest; import org.apache.olingo.client.api.communication.response.ODataResponse; import org.apache.olingo.commons.api.format.ODataPubFormat; @@ -29,7 +29,7 @@ import org.apache.olingo.commons.api.format.ODataPubFormat; * @param <V> OData response type corresponding to the request implementation. * @param <T> OData request payload type corresponding to the request implementation. */ -public interface ODataStreamedEntityRequest<V extends ODataResponse, T extends ODataStreamManager<V>> +public interface ODataStreamedEntityRequest<V extends ODataResponse, T extends ODataPayloadManager<V>> extends ODataStreamedRequest<V, T> { /** diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/StreamUpdateStreamManager.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/StreamUpdateStreamManager.java index af1e2593c..73c8858a2 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/StreamUpdateStreamManager.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/StreamUpdateStreamManager.java @@ -18,11 +18,11 @@ */ package org.apache.olingo.client.api.communication.request.streamed; -import org.apache.olingo.client.api.communication.request.ODataStreamManager; +import org.apache.olingo.client.api.communication.request.ODataPayloadManager; import org.apache.olingo.client.api.communication.response.ODataStreamUpdateResponse; /** * Streamed entity payload object. */ -public interface StreamUpdateStreamManager extends ODataStreamManager<ODataStreamUpdateResponse> { +public interface StreamUpdateStreamManager extends ODataPayloadManager<ODataStreamUpdateResponse> { } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/StreamedRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/StreamedRequestFactory.java deleted file mode 100644 index b70642f77..000000000 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/streamed/StreamedRequestFactory.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.api.communication.request.streamed; - -import java.io.InputStream; -import java.io.Serializable; -import java.net.URI; -import org.apache.olingo.commons.api.domain.CommonODataEntity; - -/** - * OData request factory class. - */ -public interface StreamedRequestFactory extends Serializable { - - /** - * Gets a media entity create request object instance. - * <br/> - * Use this kind of request to create a new media entity. - * - * @param <E> concrete ODataEntity implementation - * @param targetURI entity set URI. - * @param media entity blob to be created. - * @return new ODataMediaEntityCreateRequest instance. - */ - <E extends CommonODataEntity> ODataMediaEntityCreateRequest<E> getMediaEntityCreateRequest( - URI targetURI, InputStream media); - - /** - * Gets a stream update request object instance. - * <br/> - * Use this kind of request to update a named stream property. - * - * @param targetURI target URI. - * @param stream stream to be updated. - * @return new ODataStreamUpdateRequest instance. - */ - ODataStreamUpdateRequest getStreamUpdateRequest(URI targetURI, InputStream stream); - - /** - * Gets a media entity update request object instance. - * <br/> - * Use this kind of request to update a media entity. - * - * @param <E> concrete ODataEntity implementation - * @param editURI media entity edit link URI. - * @param media entity blob to be updated. - * @return new ODataMediaEntityUpdateRequest instance. - */ - <E extends CommonODataEntity> ODataMediaEntityUpdateRequest<E> getMediaEntityUpdateRequest( - URI editURI, InputStream media); -} diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/v4/AsyncBatchRequestWrapper.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/v4/AsyncBatchRequestWrapper.java index 9efa0fd48..65f98ec73 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/v4/AsyncBatchRequestWrapper.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/v4/AsyncBatchRequestWrapper.java @@ -18,9 +18,8 @@ */ package org.apache.olingo.client.api.communication.request.v4; +import org.apache.olingo.client.api.communication.request.ODataBatchableRequest; import org.apache.olingo.client.api.communication.request.batch.ODataChangeset; -import org.apache.olingo.client.api.communication.request.batch.ODataRetrieve; -import org.apache.olingo.client.api.communication.request.batch.v4.ODataOutsideUpdate; import org.apache.olingo.client.api.communication.response.ODataBatchResponse; public interface AsyncBatchRequestWrapper extends AsyncRequestWrapper<ODataBatchResponse> { @@ -33,16 +32,16 @@ public interface AsyncBatchRequestWrapper extends AsyncRequestWrapper<ODataBatch ODataChangeset addChangeset(); /** - * Gets a retrieve batch item instance. A retrieve item can be submitted embedded into a batch request only. + * Adds a retrieve batch item instance. A retrieve item can be submitted embedded into a batch request only. * - * @return ODataRetrieve instance. + * @param request retrieve request to batch. */ - ODataRetrieve addRetrieve(); + void addRetrieve(final ODataBatchableRequest request); /** - * Gets an outside change batch item instance. An outside item can be submitted embedded into a batch request only. + * Adds an outside change batch item instance. An outside item can be submitted embedded into a batch request only. * - * @return ODataOutsideUpdate instance. + * @param request update request to batch outside a changeset. */ - ODataOutsideUpdate addOutsideUpdate(); + void addOutsideUpdate(final ODataBatchableRequest request); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/EdmEnabledODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/EdmEnabledODataClient.java index 6f525aab3..764be15d7 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/EdmEnabledODataClient.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/EdmEnabledODataClient.java @@ -26,7 +26,7 @@ import org.apache.olingo.client.api.uri.v3.URIBuilder; public interface EdmEnabledODataClient extends CommonEdmEnabledODataClient<UpdateType>, ODataClient { @Override - URIBuilder getURIBuilder(); + URIBuilder newURIBuilder(); @Override EdmEnabledInvokeRequestFactory getInvokeRequestFactory(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java index bca42cce0..760631384 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java @@ -45,7 +45,7 @@ public interface ODataClient extends CommonODataClient<UpdateType> { ODataBinder getBinder(); @Override - URIBuilder getURIBuilder(String serviceRoot); + URIBuilder newURIBuilder(String serviceRoot); @Override FilterFactory getFilterFactory(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/EdmEnabledODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/EdmEnabledODataClient.java index 3f6a49c88..2e9e8c23a 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/EdmEnabledODataClient.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/EdmEnabledODataClient.java @@ -26,7 +26,7 @@ import org.apache.olingo.client.api.uri.v4.URIBuilder; public interface EdmEnabledODataClient extends CommonEdmEnabledODataClient<UpdateType>, ODataClient { @Override - URIBuilder getURIBuilder(); + URIBuilder newURIBuilder(); @Override EdmEnabledInvokeRequestFactory getInvokeRequestFactory(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java index 0aefdc71a..eff7ce741 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java @@ -47,7 +47,7 @@ public interface ODataClient extends CommonODataClient<UpdateType> { ODataBinder getBinder(); @Override - URIBuilder getURIBuilder(String serviceRoot); + URIBuilder newURIBuilder(String serviceRoot); @Override FilterFactory getFilterFactory(); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java index 00a7d667d..203f624d8 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractODataClient.java @@ -33,7 +33,6 @@ public abstract class AbstractODataClient<UT extends CommonUpdateType> implement @Override public ODataPreferences newPreferences() { return new ODataPreferences(getServiceVersion()); - } @Override diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataHeadersImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataHeadersImpl.java index ace190eb7..25f9981fb 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataHeadersImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataHeadersImpl.java @@ -24,12 +24,6 @@ import java.util.TreeMap; import org.apache.olingo.client.api.communication.header.HeaderName; import org.apache.olingo.client.api.communication.header.ODataHeaders; -/** - * ODataHeaders wraps OData request/response headers. - * - * @see org.apache.olingo.client.core.communication.request.ODataRequest - * @see org.apache.olingo.client.core.communication.response.ODataResponse - */ public class ODataHeadersImpl implements ODataHeaders { /** @@ -37,73 +31,38 @@ public class ODataHeadersImpl implements ODataHeaders { */ private final Map<String, String> headers = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); - /** - * Add the specified (custom) header (header name is case-insensitive). - * - * @param name header key. - * @param value header value. - * @return the current updated header instance. - */ + @Override public ODataHeaders setHeader(final String name, final String value) { headers.put(name, value); return this; } - /** - * Add the specified header. - * - * @param name header key. - * @param value header value. - * @return the current updated header instance. - */ + @Override public ODataHeaders setHeader(final HeaderName name, final String value) { headers.put(name.toString(), value); return this; } - /** - * {@inheritDoc } - */ @Override public String getHeader(final HeaderName name) { return headers.get(name.toString()); } - /** - * {@inheritDoc } - */ @Override public String getHeader(final String name) { return headers.get(name); } - /** - * Removes the header identified by the given name. - * <br/> - * Please note that header name is case-insensitive. - * - * @param name name of the header to be retrieved. - * @return header name (if found). - */ + @Override public String removeHeader(final HeaderName name) { return headers.remove(name.toString()); } - /** - * Removes the header identified by the given name. - * <br/> - * Please note that header name is case-insensitive. - * - * @param name name of the header to be retrieved. - * @return header name (if found). - */ + @Override public String removeHeader(final String name) { return headers.remove(name); } - /** - * {@inheritDoc } - */ @Override public Collection<String> getHeaderNames() { return headers.keySet(); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java index c8185d4cc..6b2bcf7c9 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataRequest.java @@ -41,7 +41,6 @@ import org.apache.olingo.client.api.communication.response.ODataResponse; import org.apache.olingo.commons.api.format.Format; import org.apache.olingo.client.api.http.HttpClientException; import org.apache.olingo.client.api.http.HttpMethod; -import org.apache.olingo.client.core.communication.header.ODataHeadersImpl; import org.apache.olingo.commons.api.format.ODataMediaFormat; import org.apache.olingo.commons.api.format.ODataPubFormat; import org.apache.olingo.commons.api.format.ODataValueFormat; @@ -74,7 +73,7 @@ public abstract class AbstractODataRequest<T extends Format> extends AbstractReq /** * OData request header. */ - protected final ODataHeadersImpl odataHeaders; + protected final ODataHeaders odataHeaders; /** * Target URI. @@ -108,7 +107,7 @@ public abstract class AbstractODataRequest<T extends Format> extends AbstractReq this.method = method; // initialize default headers - this.odataHeaders = (ODataHeadersImpl) odataClient.getVersionHeaders(); + this.odataHeaders = odataClient.newVersionHeaders(); // target uri this.uri = uri; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataStreamManager.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataStreamManager.java index 94f49d1e0..ef48fcdb8 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataStreamManager.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractODataStreamManager.java @@ -28,7 +28,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.apache.commons.io.IOUtils; import org.apache.http.HttpResponse; -import org.apache.olingo.client.api.communication.request.ODataStreamManager; +import org.apache.olingo.client.api.communication.request.ODataPayloadManager; import org.apache.olingo.client.api.communication.response.ODataResponse; import org.apache.olingo.client.api.http.HttpClientException; @@ -38,7 +38,7 @@ import org.apache.olingo.client.api.http.HttpClientException; * @param <T> OData response type corresponding to the request implementation. */ public abstract class AbstractODataStreamManager<T extends ODataResponse> extends AbstractODataStreamer - implements ODataStreamManager<T> { + implements ODataPayloadManager<T> { /** * Body input stream. diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractBatchStreamManager.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractBatchManager.java similarity index 83% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractBatchStreamManager.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractBatchManager.java index 52c40e61a..e5ec4327b 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractBatchStreamManager.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractBatchManager.java @@ -21,10 +21,11 @@ package org.apache.olingo.client.core.communication.request.batch; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.apache.http.HttpResponse; +import org.apache.olingo.client.api.communication.request.ODataBatchableRequest; import org.apache.olingo.client.api.communication.request.batch.CommonODataBatchRequest; import org.apache.olingo.client.api.communication.request.batch.ODataBatchRequestItem; import org.apache.olingo.client.api.communication.request.batch.ODataChangeset; -import org.apache.olingo.client.api.communication.request.batch.ODataRetrieve; +import org.apache.olingo.client.api.communication.request.batch.ODataSingleRequest; import org.apache.olingo.client.api.communication.response.ODataBatchResponse; import org.apache.olingo.client.core.communication.request.AbstractODataStreamManager; import org.apache.olingo.client.core.communication.request.Wrapper; @@ -32,7 +33,7 @@ import org.apache.olingo.client.core.communication.request.Wrapper; /** * Batch request payload management. */ -public abstract class AbstractBatchStreamManager extends AbstractODataStreamManager<ODataBatchResponse> { +public abstract class AbstractBatchManager extends AbstractODataStreamManager<ODataBatchResponse> { /** * Batch request current item. @@ -49,7 +50,7 @@ public abstract class AbstractBatchStreamManager extends AbstractODataStreamMana * * @param req batch request reference. */ - protected AbstractBatchStreamManager( + protected AbstractBatchManager( final CommonODataBatchRequest req, final Wrapper<Future<HttpResponse>> futureWrap) { super(futureWrap); this.req = req; @@ -75,22 +76,24 @@ public abstract class AbstractBatchStreamManager extends AbstractODataStreamMana } /** - * Gets a retrieve batch item instance. A retrieve item can be submitted embedded into a batch request only. + * Adds a retrieve batch item instance. A retrieve item can be submitted embedded into a batch request only. * - * @return ODataRetrieve instance. + * @param request retrieve request to batch. */ - public ODataRetrieve addRetrieve() { + public void addRequest(final ODataBatchableRequest request) { + validateSingleRequest(request); + closeCurrentItem(); // stream dash boundary streamDashBoundary(); - final ODataRetrieveResponseItem expectedResItem = new ODataRetrieveResponseItem(); - currentItem = new ODataRetrieveImpl(req, expectedResItem); + final ODataSingleResponseItem expectedResItem = new ODataSingleResponseItem(); + currentItem = new ODataSingleRequestImpl(req, expectedResItem); ((AbstractODataBatchRequest) req).addExpectedResItem(expectedResItem); - return (ODataRetrieve) currentItem; + ((ODataSingleRequest) currentItem).setRequest(request); } /** @@ -135,4 +138,6 @@ public abstract class AbstractBatchStreamManager extends AbstractODataStreamMana newLine(); stream(("--" + ((AbstractODataBatchRequest) req).boundary + "--").getBytes()); } + + protected abstract void validateSingleRequest(final ODataBatchableRequest request); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequest.java index 382cbd1eb..df03f49c4 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequest.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequest.java @@ -25,7 +25,7 @@ import java.util.List; import java.util.UUID; import org.apache.olingo.client.api.ODataBatchConstants; import org.apache.olingo.client.api.CommonODataClient; -import org.apache.olingo.client.api.communication.request.ODataStreamManager; +import org.apache.olingo.client.api.communication.request.ODataPayloadManager; import org.apache.olingo.client.api.communication.request.batch.CommonODataBatchRequest; import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem; import org.apache.olingo.client.api.communication.response.ODataResponse; @@ -36,7 +36,7 @@ import org.apache.olingo.commons.api.format.ContentType; /** * This class implements a batch request. */ -public abstract class AbstractODataBatchRequest<V extends ODataResponse, T extends ODataStreamManager<V>> +public abstract class AbstractODataBatchRequest<V extends ODataResponse, T extends ODataPayloadManager<V>> extends AbstractODataStreamedRequest<V, T> { /** @@ -73,7 +73,7 @@ public abstract class AbstractODataBatchRequest<V extends ODataResponse, T exten * {@inheritDoc } */ public PipedOutputStream getOutputStream() { - return getStreamManager().getBodyStreamWriter(); + return getPayloadManager().getBodyStreamWriter(); } /** diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequestItem.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequestItem.java index 1f107dd9b..251d161ec 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequestItem.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/AbstractODataBatchRequestItem.java @@ -81,7 +81,7 @@ public abstract class AbstractODataBatchRequestItem extends AbstractODataStreame * @param request request to be batched. * @param contentId changeset item id. */ - protected void streamRequestHeader(final ODataBatchableRequest request, final String contentId) { + protected void streamRequestHeader(final String contentId) { //stream batch content type stream(ODataBatchConstants.ITEM_CONTENT_TYPE_LINE.getBytes()); newLine(); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetImpl.java index ec032202e..c86fff4d1 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataChangesetImpl.java @@ -117,7 +117,7 @@ public class ODataChangesetImpl extends AbstractODataBatchRequestItem newLine(); // stream the request - streamRequestHeader(request, String.valueOf(contentId)); + streamRequestHeader(String.valueOf(contentId)); request.batch(req, String.valueOf(contentId)); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataRetrieveImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataSingleRequestImpl.java similarity index 73% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataRetrieveImpl.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataSingleRequestImpl.java index f7375ffa4..8b915fed9 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataRetrieveImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataSingleRequestImpl.java @@ -20,17 +20,17 @@ package org.apache.olingo.client.core.communication.request.batch; import org.apache.olingo.client.api.communication.request.ODataBatchableRequest; import org.apache.olingo.client.api.communication.request.batch.CommonODataBatchRequest; -import org.apache.olingo.client.api.communication.request.batch.ODataRetrieve; +import org.apache.olingo.client.api.communication.request.batch.ODataSingleRequest; import org.apache.olingo.client.api.http.HttpMethod; import org.apache.olingo.client.core.communication.request.AbstractODataRequest; /** * Retrieve request wrapper for the corresponding batch item. */ -public class ODataRetrieveImpl extends AbstractODataBatchRequestItem - implements ODataRetrieve { +public class ODataSingleRequestImpl extends AbstractODataBatchRequestItem + implements ODataSingleRequest { - private final ODataRetrieveResponseItem expectedResItem; + private final ODataSingleResponseItem expectedResItem; /** * Constructor. @@ -38,7 +38,7 @@ public class ODataRetrieveImpl extends AbstractODataBatchRequestItem * @param req batch request. * @param expectedResItem expected batch response item. */ - ODataRetrieveImpl(final CommonODataBatchRequest req, final ODataRetrieveResponseItem expectedResItem) { + ODataSingleRequestImpl(final CommonODataBatchRequest req, final ODataSingleResponseItem expectedResItem) { super(req); this.expectedResItem = expectedResItem; } @@ -55,26 +55,27 @@ public class ODataRetrieveImpl extends AbstractODataBatchRequestItem * {@inheritDoc } */ @Override - public ODataRetrieve setRequest(final ODataBatchableRequest request) { + public ODataSingleRequest setRequest(final ODataBatchableRequest request) { if (!isOpen()) { throw new IllegalStateException("Current batch item is closed"); } - if (((AbstractODataRequest) request).getMethod() != HttpMethod.GET) { - throw new IllegalArgumentException("Invalid request. Only GET method is allowed"); - } - hasStreamedSomething = true; // stream the request - streamRequestHeader(request); + if (request.getMethod() == HttpMethod.GET) { + streamRequestHeader(request); + } else { + streamRequestHeader(ODataSingleResponseItem.SINGLE_CONTENT_ID); + request.batch(req, ODataSingleResponseItem.SINGLE_CONTENT_ID); + } // close before in order to avoid any further setRequest calls. close(); // add request to the list expectedResItem.addResponse( - ODataRetrieveResponseItem.RETRIEVE_CONTENT_ID, ((AbstractODataRequest) request).getResponseTemplate()); + ODataSingleResponseItem.SINGLE_CONTENT_ID, ((AbstractODataRequest) request).getResponseTemplate()); return this; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataRetrieveResponseItem.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataSingleResponseItem.java similarity index 93% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataRetrieveResponseItem.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataSingleResponseItem.java index a180b379a..12e50f38c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataRetrieveResponseItem.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/ODataSingleResponseItem.java @@ -29,14 +29,14 @@ import org.apache.olingo.client.core.communication.response.v4.AsyncResponseImpl /** * Retrieve response wrapper for the corresponding batch item. */ -public class ODataRetrieveResponseItem extends AbstractODataBatchResponseItem { +public class ODataSingleResponseItem extends AbstractODataBatchResponseItem { - public static final String RETRIEVE_CONTENT_ID = "__RETRIEVE__"; + public static final String SINGLE_CONTENT_ID = "__SINGLE__"; /** * Constructor. */ - public ODataRetrieveResponseItem() { + public ODataSingleResponseItem() { super(false); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/BatchRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/BatchRequestFactoryImpl.java index d79653271..d68a83d20 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/BatchRequestFactoryImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/BatchRequestFactoryImpl.java @@ -35,6 +35,6 @@ public class BatchRequestFactoryImpl extends AbstractBatchRequestFactory @Override public ODataBatchRequest getBatchRequest(final String serviceRoot) { return new ODataBatchRequestImpl( - (ODataClient) client, client.getURIBuilder(serviceRoot).appendBatchSegment().build()); + (ODataClient) client, client.newURIBuilder(serviceRoot).appendBatchSegment().build()); } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java index c0050192d..3fbfddb4f 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v3/ODataBatchRequestImpl.java @@ -24,15 +24,18 @@ import java.util.Iterator; import java.util.concurrent.TimeUnit; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; +import org.apache.olingo.client.api.communication.request.ODataBatchableRequest; import org.apache.olingo.client.api.communication.request.ODataStreamedRequest; +import org.apache.olingo.client.api.communication.request.batch.BatchManager; import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem; -import org.apache.olingo.client.api.communication.request.batch.v3.BatchStreamManager; import org.apache.olingo.client.api.communication.request.batch.v3.ODataBatchRequest; import org.apache.olingo.client.api.communication.response.ODataBatchResponse; +import org.apache.olingo.client.api.http.HttpMethod; import org.apache.olingo.client.api.v3.ODataClient; -import org.apache.olingo.client.core.communication.request.batch.AbstractBatchStreamManager; +import org.apache.olingo.client.core.communication.request.AbstractODataRequest; +import org.apache.olingo.client.core.communication.request.batch.AbstractBatchManager; import org.apache.olingo.client.core.communication.request.batch.AbstractODataBatchRequest; -import org.apache.olingo.client.core.communication.request.batch.v3.ODataBatchRequestImpl.BatchStreamManagerImpl; +import org.apache.olingo.client.core.communication.request.batch.v3.ODataBatchRequestImpl.BatchManagerImpl; import org.apache.olingo.client.core.communication.request.batch.v3.ODataBatchRequestImpl.ODataBatchResponseImpl; import org.apache.olingo.client.core.communication.response.AbstractODataResponse; import org.apache.olingo.client.core.communication.response.batch.ODataBatchResponseManager; @@ -41,8 +44,8 @@ import org.apache.olingo.client.core.communication.response.batch.ODataBatchResp * This class implements a batch request. */ public class ODataBatchRequestImpl - extends AbstractODataBatchRequest<ODataBatchResponse, BatchStreamManager> - implements ODataBatchRequest, ODataStreamedRequest<ODataBatchResponse, BatchStreamManager> { + extends AbstractODataBatchRequest<ODataBatchResponse, BatchManager> + implements ODataBatchRequest, ODataStreamedRequest<ODataBatchResponse, BatchManager> { public ODataBatchRequestImpl(final ODataClient odataClient, final URI uri) { super(odataClient, uri); @@ -50,11 +53,11 @@ public class ODataBatchRequestImpl } @Override - protected BatchStreamManager getStreamManager() { - if (streamManager == null) { - streamManager = new BatchStreamManagerImpl(this); + protected BatchManager getPayloadManager() { + if (payloadManager == null) { + payloadManager = new BatchManagerImpl(this); } - return (BatchStreamManager) streamManager; + return (BatchManager) payloadManager; } /** @@ -62,7 +65,7 @@ public class ODataBatchRequestImpl */ @Override public ODataBatchRequest rawAppend(final byte[] toBeStreamed) throws IOException { - getStreamManager().getBodyStreamWriter().write(toBeStreamed); + getPayloadManager().getBodyStreamWriter().write(toBeStreamed); return this; } @@ -71,16 +74,16 @@ public class ODataBatchRequestImpl */ @Override public ODataBatchRequest rawAppend(final byte[] toBeStreamed, int off, int len) throws IOException { - getStreamManager().getBodyStreamWriter().write(toBeStreamed, off, len); + getPayloadManager().getBodyStreamWriter().write(toBeStreamed, off, len); return this; } /** * Batch request payload management. */ - public class BatchStreamManagerImpl extends AbstractBatchStreamManager implements BatchStreamManager { + public class BatchManagerImpl extends AbstractBatchManager implements BatchManager { - public BatchStreamManagerImpl(final ODataBatchRequest req) { + public BatchManagerImpl(final ODataBatchRequest req) { super(req, ODataBatchRequestImpl.this.futureWrapper); } @@ -88,6 +91,13 @@ public class ODataBatchRequestImpl protected ODataBatchResponse getResponseInstance(final long timeout, final TimeUnit unit) { return new ODataBatchResponseImpl(httpClient, getHttpResponse(timeout, unit)); } + + @Override + protected void validateSingleRequest(final ODataBatchableRequest request) { + if (((AbstractODataRequest) request).getMethod() != HttpMethod.GET) { + throw new IllegalArgumentException("Invalid request. Only GET method is allowed"); + } + } } /** diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/BatchRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/BatchRequestFactoryImpl.java index bb448122a..159db1d1f 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/BatchRequestFactoryImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/BatchRequestFactoryImpl.java @@ -35,6 +35,6 @@ public class BatchRequestFactoryImpl extends AbstractBatchRequestFactory @Override public ODataBatchRequest getBatchRequest(final String serviceRoot) { return new ODataBatchRequestImpl( - (ODataClient) client, client.getURIBuilder(serviceRoot).appendBatchSegment().build()); + (ODataClient) client, client.newURIBuilder(serviceRoot).appendBatchSegment().build()); } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java index 497a4e839..0c4354970 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataBatchRequestImpl.java @@ -26,13 +26,13 @@ import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.olingo.client.api.communication.header.HeaderName; import org.apache.olingo.client.api.communication.header.ODataPreferences; +import org.apache.olingo.client.api.communication.request.ODataBatchableRequest; +import org.apache.olingo.client.api.communication.request.batch.BatchManager; import org.apache.olingo.client.api.communication.request.batch.ODataBatchResponseItem; -import org.apache.olingo.client.api.communication.request.batch.v4.BatchStreamManager; import org.apache.olingo.client.api.communication.request.batch.v4.ODataBatchRequest; -import org.apache.olingo.client.api.communication.request.batch.v4.ODataOutsideUpdate; import org.apache.olingo.client.api.communication.response.ODataBatchResponse; import org.apache.olingo.client.api.v4.ODataClient; -import org.apache.olingo.client.core.communication.request.batch.AbstractBatchStreamManager; +import org.apache.olingo.client.core.communication.request.batch.AbstractBatchManager; import org.apache.olingo.client.core.communication.request.batch.AbstractODataBatchRequest; import org.apache.olingo.client.core.communication.response.AbstractODataResponse; import org.apache.olingo.client.core.communication.response.batch.ODataBatchResponseManager; @@ -41,7 +41,7 @@ import org.apache.olingo.client.core.communication.response.batch.ODataBatchResp * This class implements a batch request. */ public class ODataBatchRequestImpl - extends AbstractODataBatchRequest<ODataBatchResponse, BatchStreamManager> + extends AbstractODataBatchRequest<ODataBatchResponse, BatchManager> implements ODataBatchRequest { private boolean continueOnError = false; @@ -52,11 +52,11 @@ public class ODataBatchRequestImpl } @Override - protected BatchStreamManager getStreamManager() { - if (streamManager == null) { - streamManager = new BatchStreamManagerImpl(this); + protected BatchManager getPayloadManager() { + if (payloadManager == null) { + payloadManager = new BatchManagerImpl(this); } - return (BatchStreamManager) streamManager; + return (BatchManager) payloadManager; } /** @@ -64,7 +64,7 @@ public class ODataBatchRequestImpl */ @Override public ODataBatchRequest rawAppend(final byte[] toBeStreamed) throws IOException { - getStreamManager().getBodyStreamWriter().write(toBeStreamed); + getPayloadManager().getBodyStreamWriter().write(toBeStreamed); return this; } @@ -73,7 +73,7 @@ public class ODataBatchRequestImpl */ @Override public ODataBatchRequest rawAppend(final byte[] toBeStreamed, int off, int len) throws IOException { - getStreamManager().getBodyStreamWriter().write(toBeStreamed, off, len); + getPayloadManager().getBodyStreamWriter().write(toBeStreamed, off, len); return this; } @@ -87,9 +87,9 @@ public class ODataBatchRequestImpl /** * Batch request payload management. */ - public class BatchStreamManagerImpl extends AbstractBatchStreamManager implements BatchStreamManager { + public class BatchManagerImpl extends AbstractBatchManager implements BatchManager { - public BatchStreamManagerImpl(final ODataBatchRequest req) { + public BatchManagerImpl(final ODataBatchRequest req) { super(req, ODataBatchRequestImpl.this.futureWrapper); } @@ -99,18 +99,7 @@ public class ODataBatchRequestImpl } @Override - public ODataOutsideUpdate addOutsideUpdate() { - closeCurrentItem(); - - // stream dash boundary - streamDashBoundary(); - - final ODataOutsideUpdateResponseItem expectedResItem = new ODataOutsideUpdateResponseItem(); - currentItem = new ODataOutsideUpdateImpl(req, expectedResItem); - - ((ODataBatchRequestImpl) req).expectedResItems.add(expectedResItem); - - return (ODataOutsideUpdate) currentItem; + protected void validateSingleRequest(final ODataBatchableRequest request) { } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataOutsideUpdateImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataOutsideUpdateImpl.java deleted file mode 100644 index fd79e0bb6..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataOutsideUpdateImpl.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.communication.request.batch.v4; - -import org.apache.olingo.client.api.communication.request.ODataBatchableRequest; -import org.apache.olingo.client.api.communication.request.batch.CommonODataBatchRequest; -import org.apache.olingo.client.api.communication.request.batch.v4.ODataOutsideUpdate; -import org.apache.olingo.client.api.http.HttpMethod; -import org.apache.olingo.client.core.communication.request.AbstractODataRequest; -import org.apache.olingo.client.core.communication.request.batch.AbstractODataBatchRequestItem; - -/** - * Retrieve request wrapper for the corresponding batch item. - */ -public class ODataOutsideUpdateImpl extends AbstractODataBatchRequestItem - implements ODataOutsideUpdate { - - private final ODataOutsideUpdateResponseItem expectedResItem; - - /** - * Constructor. - * - * @param req batch request. - * @param expectedResItem expected batch response item. - */ - ODataOutsideUpdateImpl(final CommonODataBatchRequest req, final ODataOutsideUpdateResponseItem expectedResItem) { - super(req); - this.expectedResItem = expectedResItem; - } - - /** - * Close item. - */ - @Override - protected void closeItem() { - // nop - } - - /** - * {@inheritDoc } - */ - @Override - public ODataOutsideUpdate setRequest(final ODataBatchableRequest request) { - if (!isOpen()) { - throw new IllegalStateException("Current batch item is closed"); - } - - if (((AbstractODataRequest) request).getMethod() == HttpMethod.GET) { - throw new IllegalArgumentException("Invalid request. Use ODataRetrieve for GET method"); - } - - hasStreamedSomething = true; - - // stream the request - streamRequestHeader(request, ODataOutsideUpdateResponseItem.OUTSIDE_CONTENT_ID); - - request.batch(req, ODataOutsideUpdateResponseItem.OUTSIDE_CONTENT_ID); - - // close before in order to avoid any further setRequest calls. - close(); - - // add request to the list - expectedResItem.addResponse( - ODataOutsideUpdateResponseItem.OUTSIDE_CONTENT_ID, ((AbstractODataRequest) request).getResponseTemplate()); - - return this; - } -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataOutsideUpdateResponseItem.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataOutsideUpdateResponseItem.java deleted file mode 100644 index 149c24a81..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/batch/v4/ODataOutsideUpdateResponseItem.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.communication.request.batch.v4; - -import java.util.Collection; -import java.util.Map; -import java.util.NoSuchElementException; -import org.apache.olingo.client.api.communication.response.ODataResponse; -import org.apache.olingo.client.core.communication.request.batch.AbstractODataBatchResponseItem; -import org.apache.olingo.client.core.communication.request.batch.ODataBatchUtilities; -import org.apache.olingo.client.core.communication.response.batch.ODataBatchErrorResponse; - -/** - * Retrieve response wrapper for the corresponding batch item. - */ -public class ODataOutsideUpdateResponseItem extends AbstractODataBatchResponseItem { - - public static final String OUTSIDE_CONTENT_ID = "__OUTSIDEUPDATE__"; - - /** - * Constructor. - */ - public ODataOutsideUpdateResponseItem() { - super(false); - } - - /** - * {@inheritDoc } - */ - @Override - public ODataResponse next() { - if (closed) { - throw new IllegalStateException("Invalid request - the item has been closed"); - } - - final Map.Entry<Integer, String> responseLine = ODataBatchUtilities.readResponseLine(batchLineIterator); - LOG.debug("Retrieved item response {}", responseLine); - - final Map<String, Collection<String>> headers = ODataBatchUtilities.readHeaders(batchLineIterator); - LOG.debug("Retrieved item headers {}", headers); - - final ODataResponse res; - - if (responseLine.getKey() >= 400) { - // generate error response - res = new ODataBatchErrorResponse(responseLine, headers, batchLineIterator, boundary); - } else { - if (!hasNext()) { - throw new NoSuchElementException("No item found"); - } - res = expectedItemsIterator.next().initFromBatch(responseLine, headers, batchLineIterator, boundary); - } - - return res; - } - - /** - * Unsupported operation. - */ - @Override - public void remove() { - throw new UnsupportedOperationException("Operation not supported."); - } -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java index a45afc771..1a7e5b153 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/AbstractCUDRequestFactory.java @@ -18,6 +18,7 @@ */ package org.apache.olingo.client.core.communication.request.cud; +import java.io.InputStream; import java.net.URI; import org.apache.olingo.client.api.CommonODataClient; import org.apache.olingo.client.api.communication.request.cud.CommonCUDRequestFactory; @@ -27,7 +28,14 @@ import org.apache.olingo.client.api.communication.request.cud.ODataEntityCreateR import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateRequest; import org.apache.olingo.client.api.communication.request.cud.ODataPropertyUpdateRequest; import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest; +import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityCreateRequest; +import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityUpdateRequest; +import org.apache.olingo.client.api.communication.request.streamed.ODataStreamUpdateRequest; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.client.core.communication.request.streamed.ODataMediaEntityCreateRequestImpl; +import org.apache.olingo.client.core.communication.request.streamed.ODataMediaEntityUpdateRequestImpl; +import org.apache.olingo.client.core.communication.request.streamed.ODataStreamUpdateRequestImpl; +import org.apache.olingo.client.core.uri.URIUtils; import org.apache.olingo.commons.api.domain.CommonODataEntity; import org.apache.olingo.commons.api.domain.CommonODataProperty; import org.apache.olingo.commons.api.domain.ODataPrimitiveValue; @@ -92,10 +100,10 @@ public abstract class AbstractCUDRequestFactory<UT extends CommonUpdateType> imp final ODataValueUpdateRequest req; if (client.getConfiguration().isUseXHTTPMethod()) { - req = new ODataValueUpdateRequestImpl(client, HttpMethod.POST, targetURI, value); + req = new ODataValueUpdateRequestImpl(client, HttpMethod.POST, URIUtils.addValueSegment(targetURI), value); req.setXHTTPMethod(type.getMethod().name()); } else { - req = new ODataValueUpdateRequestImpl(client, type.getMethod(), targetURI, value); + req = new ODataValueUpdateRequestImpl(client, type.getMethod(), URIUtils.addValueSegment(targetURI), value); } return req; @@ -174,4 +182,41 @@ public abstract class AbstractCUDRequestFactory<UT extends CommonUpdateType> imp return req; } + + @Override + public <E extends CommonODataEntity> ODataMediaEntityCreateRequest<E> getMediaEntityCreateRequest( + final URI targetURI, final InputStream media) { + + return new ODataMediaEntityCreateRequestImpl<E>(client, targetURI, media); + } + + @Override + public ODataStreamUpdateRequest getStreamUpdateRequest(final URI targetURI, final InputStream stream) { + final ODataStreamUpdateRequest req; + + if (client.getConfiguration().isUseXHTTPMethod()) { + req = new ODataStreamUpdateRequestImpl(client, HttpMethod.POST, targetURI, stream); + req.setXHTTPMethod(HttpMethod.PUT.name()); + } else { + req = new ODataStreamUpdateRequestImpl(client, HttpMethod.PUT, targetURI, stream); + } + + return req; + } + + @Override + public <E extends CommonODataEntity> ODataMediaEntityUpdateRequest<E> getMediaEntityUpdateRequest( + final URI editURI, final InputStream media) { + + final ODataMediaEntityUpdateRequest<E> req; + + if (client.getConfiguration().isUseXHTTPMethod()) { + req = new ODataMediaEntityUpdateRequestImpl<E>(client, HttpMethod.POST, URIUtils.addValueSegment(editURI), media); + req.setXHTTPMethod(HttpMethod.PUT.name()); + } else { + req = new ODataMediaEntityUpdateRequestImpl<E>(client, HttpMethod.PUT, URIUtils.addValueSegment(editURI), media); + } + + return req; + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java index 81e1dd4b8..fe2fdbbbd 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataPropertyUpdateRequestImpl.java @@ -55,7 +55,7 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD * @param targetURI entity set or entity or entity property URI. * @param property value to be created. */ - ODataPropertyUpdateRequestImpl(final CommonODataClient odataClient, + ODataPropertyUpdateRequestImpl(final CommonODataClient<?> odataClient, final HttpMethod method, final URI targetURI, final CommonODataProperty property) { super(odataClient, ODataFormat.class, method, targetURI); @@ -63,9 +63,6 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD this.property = property; } - /** - * {@inheritDoc } - */ @Override public ODataPropertyUpdateResponse execute() { final InputStream input = getPayload(); @@ -78,9 +75,6 @@ public class ODataPropertyUpdateRequestImpl extends AbstractODataBasicRequest<OD } } - /** - * {@inheritDoc } - */ @Override protected InputStream getPayload() { return odataClient.getWriter().writeProperty(property, ODataFormat.fromString(getContentType())); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractEdmEnabledInvokeRequestFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractEdmEnabledInvokeRequestFactory.java new file mode 100644 index 000000000..a9ed3f493 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractEdmEnabledInvokeRequestFactory.java @@ -0,0 +1,172 @@ +/* + * 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.client.core.communication.request.invoke; + +import java.net.URI; +import java.util.ArrayList; +import java.util.Map; +import org.apache.olingo.client.api.CommonEdmEnabledODataClient; +import org.apache.olingo.client.api.communication.request.invoke.EdmEnabledInvokeRequestFactory; +import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest; +import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.commons.api.domain.ODataInvokeResult; +import org.apache.olingo.commons.api.domain.ODataValue; +import org.apache.olingo.commons.api.edm.EdmAction; +import org.apache.olingo.commons.api.edm.EdmActionImport; +import org.apache.olingo.commons.api.edm.EdmEntityContainer; +import org.apache.olingo.commons.api.edm.EdmFunction; +import org.apache.olingo.commons.api.edm.EdmFunctionImport; +import org.apache.olingo.commons.api.edm.EdmSchema; +import org.apache.olingo.commons.api.edm.FullQualifiedName; + +public abstract class AbstractEdmEnabledInvokeRequestFactory extends AbstractInvokeRequestFactory + implements EdmEnabledInvokeRequestFactory { + + private static final long serialVersionUID = -3637346544674184337L; + + private final CommonEdmEnabledODataClient<?> edmClient; + + public AbstractEdmEnabledInvokeRequestFactory(final CommonEdmEnabledODataClient<?> edmClient) { + this.edmClient = edmClient; + } + + @Override + public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getFunctionImportInvokeRequest( + final String functionImportName) { + + return getFunctionImportInvokeRequest(functionImportName, null); + } + + @Override + @SuppressWarnings("unchecked") + public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getFunctionImportInvokeRequest( + final String functionImportName, final Map<String, ODataValue> parameters) { + + EdmFunctionImport efi = null; + for (EdmSchema schema : edmClient.getCachedEdm().getSchemas()) { + final EdmEntityContainer container = schema.getEntityContainer(); + if (container != null) { + efi = container.getFunctionImport(functionImportName); + } + } + if (efi == null) { + throw new IllegalArgumentException("Could not find FunctionImport for name " + functionImportName); + } + + final EdmFunction function = edmClient.getCachedEdm(). + getUnboundFunction(efi.getFunctionFqn(), + parameters == null ? null : new ArrayList<String>(parameters.keySet())); + if (function == null) { + throw new IllegalArgumentException("Could not find Function " + efi.getFunctionFqn()); + } + + return (ODataInvokeRequest<RES>) getInvokeRequest(HttpMethod.GET, + edmClient.newURIBuilder().appendOperationCallSegment(functionImportName).build(), + getResultReference(function.getReturnType()), + parameters); + } + + @Override + public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getActionImportInvokeRequest( + final String actionImportName) { + + return getActionImportInvokeRequest(actionImportName, null); + } + + @Override + @SuppressWarnings("unchecked") + public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getActionImportInvokeRequest( + final String actionImportName, final Map<String, ODataValue> parameters) { + + EdmActionImport eai = null; + for (EdmSchema schema : edmClient.getCachedEdm().getSchemas()) { + final EdmEntityContainer container = schema.getEntityContainer(); + if (container != null) { + eai = container.getActionImport(actionImportName); + } + } + if (eai == null) { + throw new IllegalArgumentException("Could not find ActionImport for name " + actionImportName); + } + + return (ODataInvokeRequest<RES>) getInvokeRequest(HttpMethod.POST, + edmClient.newURIBuilder().appendOperationCallSegment(actionImportName).build(), + getResultReference(eai.getUnboundAction().getReturnType()), + parameters); + } + + @Override + public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getBoundFunctionInvokeRequest( + final URI bindingParameterURI, final FullQualifiedName functionName, + final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) { + + return getBoundFunctionInvokeRequest( + bindingParameterURI, functionName, bindingParameterTypeName, isBindingParameterCollection, null); + } + + @Override + @SuppressWarnings("unchecked") + public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getBoundFunctionInvokeRequest( + final URI bindingParameterURI, final FullQualifiedName functionName, + final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection, + final Map<String, ODataValue> parameters) { + + final EdmFunction function = edmClient.getCachedEdm().getBoundFunction( + functionName, bindingParameterTypeName, isBindingParameterCollection, + parameters == null ? null : new ArrayList<String>(parameters.keySet())); + if (function == null) { + throw new IllegalArgumentException("Could not find Function for name " + functionName); + } + + return (ODataInvokeRequest<RES>) getInvokeRequest(HttpMethod.GET, + edmClient.newURIBuilder(bindingParameterURI.toASCIIString()). + appendOperationCallSegment(function.getFullQualifiedName().toString()).build(), + getResultReference(function.getReturnType()), + parameters); + } + + @Override + public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getBoundActionInvokeRequest( + final URI bindingParameterURI, final FullQualifiedName actionName, + final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) { + + return getBoundActionInvokeRequest( + bindingParameterURI, actionName, bindingParameterTypeName, isBindingParameterCollection, null); + } + + @Override + @SuppressWarnings("unchecked") + public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getBoundActionInvokeRequest( + final URI bindingParameterURI, final FullQualifiedName actionName, + final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection, + final Map<String, ODataValue> parameters) { + + final EdmAction action = edmClient.getCachedEdm().getBoundAction( + actionName, bindingParameterTypeName, isBindingParameterCollection); + if (action == null) { + throw new IllegalArgumentException("Could not find Action for name " + actionName); + } + + return (ODataInvokeRequest<RES>) getInvokeRequest(HttpMethod.POST, + edmClient.newURIBuilder(bindingParameterURI.toASCIIString()). + appendOperationCallSegment(action.getFullQualifiedName().toString()).build(), + getResultReference(action.getReturnType()), + parameters); + } +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractInvokeRequestFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractInvokeRequestFactory.java index 08fc6f296..536088e5c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractInvokeRequestFactory.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractInvokeRequestFactory.java @@ -19,20 +19,67 @@ package org.apache.olingo.client.core.communication.request.invoke; import java.net.URI; +import java.util.Map; import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory; import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest; +import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent; +import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.commons.api.domain.CommonODataEntity; +import org.apache.olingo.commons.api.domain.CommonODataEntitySet; +import org.apache.olingo.commons.api.domain.CommonODataProperty; import org.apache.olingo.commons.api.domain.ODataInvokeResult; -import org.apache.olingo.commons.api.edm.EdmOperation; +import org.apache.olingo.commons.api.domain.ODataValue; +import org.apache.olingo.commons.api.edm.EdmReturnType; +import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; public abstract class AbstractInvokeRequestFactory implements InvokeRequestFactory { private static final long serialVersionUID = -906760270085197249L; @Override - public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getInvokeRequest( - final URI uri, final EdmOperation operation) { + public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getFunctionInvokeRequest( + final URI uri, final Class<RES> resultRef) { - return getInvokeRequest(uri, operation, null); + return getFunctionInvokeRequest(uri, resultRef, null); } + @Override + public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getFunctionInvokeRequest( + final URI uri, final Class<RES> resultRef, final Map<String, ODataValue> parameters) { + + return getInvokeRequest(HttpMethod.GET, uri, resultRef, parameters); + } + + @Override + public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getActionInvokeRequest( + final URI uri, final Class<RES> resultRef) { + + return getActionInvokeRequest(uri, resultRef, null); + } + + @Override + public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getActionInvokeRequest( + final URI uri, final Class<RES> resultRef, final Map<String, ODataValue> parameters) { + + return getInvokeRequest(HttpMethod.POST, uri, resultRef, parameters); + } + + @SuppressWarnings("unchecked") + protected <RES extends ODataInvokeResult> Class<RES> getResultReference(final EdmReturnType returnType) { + Class<RES> result; + + if (returnType == null) { + result = (Class<RES>) ODataNoContent.class; + } else { + if (returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) { + result = (Class<RES>) CommonODataEntitySet.class; + } else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) { + result = (Class<RES>) CommonODataEntity.class; + } else { + result = (Class<RES>) CommonODataProperty.class; + } + } + + return result; + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/EdmEnabledInvokeRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/EdmEnabledInvokeRequestFactoryImpl.java index de22c30e3..b9eeeb1ad 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/EdmEnabledInvokeRequestFactoryImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/EdmEnabledInvokeRequestFactoryImpl.java @@ -18,21 +18,16 @@ */ package org.apache.olingo.client.core.communication.request.invoke.v3; -import java.util.ArrayList; +import java.net.URI; import java.util.Map; -import org.apache.olingo.client.api.communication.request.invoke.EdmEnabledInvokeRequestFactory; import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest; +import org.apache.olingo.client.api.http.HttpMethod; import org.apache.olingo.client.api.v3.EdmEnabledODataClient; +import org.apache.olingo.client.core.communication.request.invoke.AbstractEdmEnabledInvokeRequestFactory; import org.apache.olingo.commons.api.domain.ODataInvokeResult; import org.apache.olingo.commons.api.domain.ODataValue; -import org.apache.olingo.commons.api.edm.EdmActionImport; -import org.apache.olingo.commons.api.edm.EdmEntityContainer; -import org.apache.olingo.commons.api.edm.EdmFunction; -import org.apache.olingo.commons.api.edm.EdmFunctionImport; -import org.apache.olingo.commons.api.edm.EdmSchema; -public class EdmEnabledInvokeRequestFactoryImpl - extends InvokeRequestFactoryImpl implements EdmEnabledInvokeRequestFactory { +public class EdmEnabledInvokeRequestFactoryImpl extends AbstractEdmEnabledInvokeRequestFactory { private static final long serialVersionUID = 5854571629835831697L; @@ -44,66 +39,15 @@ public class EdmEnabledInvokeRequestFactoryImpl } @Override - public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getFunctionImportInvokeRequest( - final String functionImportName) { + public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getInvokeRequest( + final HttpMethod method, final URI uri, final Class<RES> resultRef, + final Map<String, ODataValue> parameters) { - return getFunctionImportInvokeRequest(functionImportName, null); + final ODataInvokeRequest<RES> request = new ODataInvokeRequestImpl<RES>(edmClient, resultRef, method, uri); + if (parameters != null) { + request.setParameters(parameters); + } + + return request; } - - @Override - public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getFunctionImportInvokeRequest( - final String functionImportName, final Map<String, ODataValue> parameters) { - - EdmFunctionImport efi = null; - for (EdmSchema schema : edmClient.getCachedEdm().getSchemas()) { - final EdmEntityContainer container = schema.getEntityContainer(); - if (container != null) { - efi = container.getFunctionImport(functionImportName); - } - } - if (efi == null) { - throw new IllegalArgumentException("Could not find FunctionImport for name " + functionImportName); - } - - final EdmFunction function = edmClient.getCachedEdm(). - getUnboundFunction(efi.getFunctionFqn(), - parameters == null ? null : new ArrayList<String>(parameters.keySet())); - if (function == null) { - throw new IllegalArgumentException("Could not find Function " + efi.getFunctionFqn()); - } - - return getInvokeRequest( - edmClient.getURIBuilder().appendOperationCallSegment(functionImportName).build(), - function, - parameters); - } - - @Override - public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getActionImportInvokeRequest( - final String actionImportName) { - - return getActionImportInvokeRequest(actionImportName, null); - } - - @Override - public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getActionImportInvokeRequest( - final String actionImportName, final Map<String, ODataValue> parameters) { - - EdmActionImport eai = null; - for (EdmSchema schema : edmClient.getCachedEdm().getSchemas()) { - final EdmEntityContainer container = schema.getEntityContainer(); - if (container != null) { - eai = container.getActionImport(actionImportName); - } - } - if (eai == null) { - throw new IllegalArgumentException("Could not find ActionImport for name " + actionImportName); - } - - return getInvokeRequest( - edmClient.getURIBuilder().appendOperationCallSegment(actionImportName).build(), - eai.getUnboundAction(), - parameters); - } - } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java index 0d71a4a9e..e6ff223fd 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java @@ -22,55 +22,27 @@ import java.net.URI; import java.util.Map; import org.apache.olingo.client.api.v3.ODataClient; import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest; -import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent; import org.apache.olingo.commons.api.domain.ODataInvokeResult; import org.apache.olingo.commons.api.domain.ODataValue; import org.apache.olingo.client.api.http.HttpMethod; import org.apache.olingo.client.core.communication.request.invoke.AbstractInvokeRequestFactory; -import org.apache.olingo.commons.api.domain.v3.ODataEntity; -import org.apache.olingo.commons.api.domain.v3.ODataEntitySet; -import org.apache.olingo.commons.api.domain.v3.ODataProperty; -import org.apache.olingo.commons.api.edm.EdmAction; -import org.apache.olingo.commons.api.edm.EdmOperation; -import org.apache.olingo.commons.api.edm.EdmReturnType; -import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; public class InvokeRequestFactoryImpl extends AbstractInvokeRequestFactory { private static final long serialVersionUID = -659256862901915496L; private final ODataClient client; - + public InvokeRequestFactoryImpl(final ODataClient client) { this.client = client; } @Override - @SuppressWarnings("unchecked") public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getInvokeRequest( - final URI uri, final EdmOperation operation, final Map<String, ODataValue> parameters) { + final HttpMethod method, final URI uri, final Class<RES> resultRef, + final Map<String, ODataValue> parameters) { - final HttpMethod method = operation instanceof EdmAction - ? HttpMethod.POST - : HttpMethod.GET; - final EdmReturnType returnType = operation.getReturnType(); - - ODataInvokeRequest<RES> request; - if (returnType == null) { - request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataNoContent>( - client, ODataNoContent.class, method, uri); - } else { - if (returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) { - request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataEntitySet>( - client, ODataEntitySet.class, method, uri); - } else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) { - request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataEntity>( - client, ODataEntity.class, method, uri); - } else { - request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataProperty>( - client, ODataProperty.class, method, uri); - } - } + final ODataInvokeRequest<RES> request = new ODataInvokeRequestImpl<RES>(client, resultRef, method, uri); if (parameters != null) { request.setParameters(parameters); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/EdmEnabledInvokeRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/EdmEnabledInvokeRequestFactoryImpl.java index 4df6c3ff4..2579108cd 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/EdmEnabledInvokeRequestFactoryImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/EdmEnabledInvokeRequestFactoryImpl.java @@ -18,21 +18,16 @@ */ package org.apache.olingo.client.core.communication.request.invoke.v4; -import java.util.ArrayList; +import java.net.URI; import java.util.Map; -import org.apache.olingo.client.api.communication.request.invoke.EdmEnabledInvokeRequestFactory; import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest; +import org.apache.olingo.client.api.http.HttpMethod; import org.apache.olingo.client.api.v4.EdmEnabledODataClient; +import org.apache.olingo.client.core.communication.request.invoke.AbstractEdmEnabledInvokeRequestFactory; import org.apache.olingo.commons.api.domain.ODataInvokeResult; import org.apache.olingo.commons.api.domain.ODataValue; -import org.apache.olingo.commons.api.edm.EdmActionImport; -import org.apache.olingo.commons.api.edm.EdmEntityContainer; -import org.apache.olingo.commons.api.edm.EdmFunction; -import org.apache.olingo.commons.api.edm.EdmFunctionImport; -import org.apache.olingo.commons.api.edm.EdmSchema; -public class EdmEnabledInvokeRequestFactoryImpl - extends InvokeRequestFactoryImpl implements EdmEnabledInvokeRequestFactory { +public class EdmEnabledInvokeRequestFactoryImpl extends AbstractEdmEnabledInvokeRequestFactory { private static final long serialVersionUID = 5854571629835831697L; @@ -44,66 +39,15 @@ public class EdmEnabledInvokeRequestFactoryImpl } @Override - public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getFunctionImportInvokeRequest( - final String functionImportName) { + public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getInvokeRequest( + final HttpMethod method, final URI uri, final Class<RES> resultRef, + final Map<String, ODataValue> parameters) { - return getFunctionImportInvokeRequest(functionImportName, null); + final ODataInvokeRequest<RES> request = new ODataInvokeRequestImpl<RES>(edmClient, resultRef, method, uri); + if (parameters != null) { + request.setParameters(parameters); + } + + return request; } - - @Override - public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getFunctionImportInvokeRequest( - final String functionImportName, final Map<String, ODataValue> parameters) { - - EdmFunctionImport efi = null; - for (EdmSchema schema : edmClient.getCachedEdm().getSchemas()) { - final EdmEntityContainer container = schema.getEntityContainer(); - if (container != null) { - efi = container.getFunctionImport(functionImportName); - } - } - if (efi == null) { - throw new IllegalArgumentException("Could not find FunctionImport for name " + functionImportName); - } - - final EdmFunction function = edmClient.getCachedEdm(). - getUnboundFunction(efi.getFunctionFqn(), - parameters == null ? null : new ArrayList<String>(parameters.keySet())); - if (function == null) { - throw new IllegalArgumentException("Could not find Function " + efi.getFunctionFqn()); - } - - return getInvokeRequest( - edmClient.getURIBuilder().appendOperationCallSegment(functionImportName).build(), - function, - parameters); - } - - @Override - public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getActionImportInvokeRequest( - final String actionImportName) { - - return getActionImportInvokeRequest(actionImportName, null); - } - - @Override - public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getActionImportInvokeRequest( - final String actionImportName, final Map<String, ODataValue> parameters) { - - EdmActionImport eai = null; - for (EdmSchema schema : edmClient.getCachedEdm().getSchemas()) { - final EdmEntityContainer container = schema.getEntityContainer(); - if (container != null) { - eai = container.getActionImport(actionImportName); - } - } - if (eai == null) { - throw new IllegalArgumentException("Could not find ActionImport for name " + actionImportName); - } - - return getInvokeRequest( - edmClient.getURIBuilder().appendOperationCallSegment(actionImportName).build(), - eai.getUnboundAction(), - parameters); - } - } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/InvokeRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/InvokeRequestFactoryImpl.java index ded99922d..15035b5c9 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/InvokeRequestFactoryImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/InvokeRequestFactoryImpl.java @@ -22,18 +22,10 @@ import java.net.URI; import java.util.Map; import org.apache.olingo.client.api.v4.ODataClient; import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest; -import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent; import org.apache.olingo.client.api.http.HttpMethod; +import org.apache.olingo.client.core.communication.request.invoke.AbstractInvokeRequestFactory; import org.apache.olingo.commons.api.domain.ODataInvokeResult; import org.apache.olingo.commons.api.domain.ODataValue; -import org.apache.olingo.client.core.communication.request.invoke.AbstractInvokeRequestFactory; -import org.apache.olingo.commons.api.domain.v4.ODataEntity; -import org.apache.olingo.commons.api.domain.v4.ODataEntitySet; -import org.apache.olingo.commons.api.domain.v4.ODataProperty; -import org.apache.olingo.commons.api.edm.EdmAction; -import org.apache.olingo.commons.api.edm.EdmOperation; -import org.apache.olingo.commons.api.edm.EdmReturnType; -import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; public class InvokeRequestFactoryImpl extends AbstractInvokeRequestFactory { @@ -45,32 +37,12 @@ public class InvokeRequestFactoryImpl extends AbstractInvokeRequestFactory { this.client = client; } - @SuppressWarnings("unchecked") @Override public <RES extends ODataInvokeResult> ODataInvokeRequest<RES> getInvokeRequest( - final URI uri, final EdmOperation operation, final Map<String, ODataValue> parameters) { + final HttpMethod method, final URI uri, final Class<RES> resultRef, + final Map<String, ODataValue> parameters) { - final HttpMethod method = operation instanceof EdmAction - ? HttpMethod.POST - : HttpMethod.GET; - final EdmReturnType returnType = operation.getReturnType(); - - ODataInvokeRequest<RES> request; - if (returnType == null) { - request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataNoContent>( - client, ODataNoContent.class, method, uri); - } else { - if (returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) { - request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataEntitySet>( - client, ODataEntitySet.class, method, uri); - } else if (!returnType.isCollection() && returnType.getType().getKind() == EdmTypeKind.ENTITY) { - request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataEntity>( - client, ODataEntity.class, method, uri); - } else { - request = (ODataInvokeRequest<RES>) new ODataInvokeRequestImpl<ODataProperty>( - client, ODataProperty.class, method, uri); - } - } + final ODataInvokeRequest<RES> request = new ODataInvokeRequestImpl<RES>(client, resultRef, method, uri); if (parameters != null) { request.setParameters(parameters); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java index b5ba1a98c..8ac4dc185 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java @@ -27,6 +27,7 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataRawReque import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest; import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest; import org.apache.olingo.client.api.communication.request.retrieve.CommonRetrieveRequestFactory; +import org.apache.olingo.client.core.uri.URIUtils; public abstract class AbstractRetrieveRequestFactory implements CommonRetrieveRequestFactory { @@ -43,11 +44,21 @@ public abstract class AbstractRetrieveRequestFactory implements CommonRetrieveRe return new ODataValueRequestImpl(client, uri); } + @Override + public ODataValueRequest getPropertyValueRequest(final URI uri) { + return getValueRequest(URIUtils.addValueSegment(uri)); + } + @Override public ODataMediaRequest getMediaRequest(final URI uri) { return new ODataMediaRequestImpl(client, uri); } + @Override + public ODataMediaRequest getMediaEntityRequest(final URI uri) { + return getMediaRequest(URIUtils.addValueSegment(uri)); + } + @Override public ODataRawRequest getRawRequest(final URI uri) { return new ODataRawRequestImpl(client, uri); @@ -56,14 +67,14 @@ public abstract class AbstractRetrieveRequestFactory implements CommonRetrieveRe @Override public EdmMetadataRequest getMetadataRequest(final String serviceRoot) { return new EdmMetadataRequestImpl(client, serviceRoot, - client.getURIBuilder(serviceRoot).appendMetadataSegment().build()); + client.newURIBuilder(serviceRoot).appendMetadataSegment().build()); } @Override public ODataServiceDocumentRequest getServiceDocumentRequest(final String serviceRoot) { return new ODataServiceDocumentRequestImpl(client, StringUtils.isNotBlank(serviceRoot) && serviceRoot.endsWith("/") - ? client.getURIBuilder(serviceRoot).build() - : client.getURIBuilder(serviceRoot + "/").build()); + ? client.newURIBuilder(serviceRoot).build() + : client.newURIBuilder(serviceRoot + "/").build()); } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java index 460b695bc..7bc9fdf02 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java @@ -42,7 +42,7 @@ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest<ODataPri * @param odataClient client instance getting this request * @param query query to be executed. */ - ODataValueRequestImpl(final CommonODataClient odataClient, final URI query) { + ODataValueRequestImpl(final CommonODataClient<?> odataClient, final URI query) { super(odataClient, ODataValueFormat.class, query); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/ODataLinkCollectionRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/ODataLinkCollectionRequestImpl.java index b11088e4f..e64a7645e 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/ODataLinkCollectionRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/ODataLinkCollectionRequestImpl.java @@ -45,7 +45,7 @@ public class ODataLinkCollectionRequestImpl extends AbstractODataRetrieveRequest */ ODataLinkCollectionRequestImpl(final ODataClient odataClient, final URI targetURI, final String linkName) { super(odataClient, ODataFormat.class, - odataClient.getURIBuilder(targetURI.toASCIIString()).appendLinksSegment(linkName).build()); + odataClient.newURIBuilder(targetURI.toASCIIString()).appendLinksSegment(linkName).build()); } /** diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java index 0e8db345b..359ddb807 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java @@ -49,7 +49,7 @@ public class RetrieveRequestFactoryImpl extends AbstractRetrieveRequestFactory @Override public XMLMetadataRequest getXMLMetadataRequest(final String serviceRoot) { return new XMLMetadataRequestImpl(((ODataClient) client), - client.getURIBuilder(serviceRoot).appendMetadataSegment().build()); + client.newURIBuilder(serviceRoot).appendMetadataSegment().build()); } @Override diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java index 804d2deaa..5006e1a71 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java @@ -50,7 +50,7 @@ public class RetrieveRequestFactoryImpl extends AbstractRetrieveRequestFactory @Override public XMLMetadataRequest getXMLMetadataRequest(final String serviceRoot) { return new XMLMetadataRequestImpl(((ODataClient) client), - client.getURIBuilder(serviceRoot).appendMetadataSegment().build()); + client.newURIBuilder(serviceRoot).appendMetadataSegment().build()); } @Override diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java index 0a1d48e81..865b95ca8 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java @@ -61,7 +61,7 @@ public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<Map<Stri // process external references for (Reference reference : rootMetadata.getReferences()) { final SingleXMLMetadatRequestImpl includeReq = new SingleXMLMetadatRequestImpl( - (ODataClient) odataClient, odataClient.getURIBuilder(reference.getUri().toASCIIString()).build()); + (ODataClient) odataClient, odataClient.newURIBuilder(reference.getUri().toASCIIString()).build()); final XMLMetadata includeMetadata = includeReq.execute().getBody(); // edmx:Include diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java index ec5f7737b..e04d5d22e 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedEntityRequest.java @@ -20,7 +20,7 @@ package org.apache.olingo.client.core.communication.request.streamed; import java.net.URI; import org.apache.olingo.client.api.CommonODataClient; -import org.apache.olingo.client.api.communication.request.ODataStreamManager; +import org.apache.olingo.client.api.communication.request.ODataPayloadManager; import org.apache.olingo.client.api.communication.request.streamed.ODataStreamedEntityRequest; import org.apache.olingo.client.api.communication.response.ODataResponse; import org.apache.olingo.commons.api.format.ODataPubFormat; @@ -32,7 +32,7 @@ import org.apache.olingo.client.api.http.HttpMethod; * @param <V> OData response type corresponding to the request implementation. * @param <T> OData request payload type corresponding to the request implementation. */ -public abstract class AbstractODataStreamedEntityRequest<V extends ODataResponse, T extends ODataStreamManager<V>> +public abstract class AbstractODataStreamedEntityRequest<V extends ODataResponse, T extends ODataPayloadManager<V>> extends AbstractODataStreamedRequest<V, T> implements ODataStreamedEntityRequest<V, T> { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java index 0a78d834e..3d5c0a2e6 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/AbstractODataStreamedRequest.java @@ -29,7 +29,7 @@ import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; import org.apache.http.entity.ContentType; import org.apache.olingo.client.api.ODataBatchConstants; import org.apache.olingo.client.api.CommonODataClient; -import org.apache.olingo.client.api.communication.request.ODataStreamManager; +import org.apache.olingo.client.api.communication.request.ODataPayloadManager; import org.apache.olingo.client.api.communication.request.ODataStreamedRequest; import org.apache.olingo.client.api.communication.request.ODataStreamer; import org.apache.olingo.client.api.communication.request.batch.CommonODataBatchRequest; @@ -47,13 +47,13 @@ import org.apache.commons.io.IOUtils; * @param <V> OData response type corresponding to the request implementation. * @param <T> OData request payload type corresponding to the request implementation. */ -public abstract class AbstractODataStreamedRequest<V extends ODataResponse, T extends ODataStreamManager<V>> +public abstract class AbstractODataStreamedRequest<V extends ODataResponse, T extends ODataPayloadManager<V>> extends AbstractODataRequest<ODataMediaFormat> implements ODataStreamedRequest<V, T> { /** * OData payload stream manager. */ - protected ODataStreamManager<V> streamManager; + protected ODataPayloadManager<V> payloadManager; /** * Wrapper for actual streamed request's future. This holds information about the HTTP request / response currently @@ -81,18 +81,18 @@ public abstract class AbstractODataStreamedRequest<V extends ODataResponse, T ex * * @return OData request payload management object. */ - protected abstract T getStreamManager(); + protected abstract T getPayloadManager(); /** * {@inheritDoc } */ @Override @SuppressWarnings("unchecked") - public T execute() { - streamManager = getStreamManager(); + public T payloadManager() { + payloadManager = getPayloadManager(); ((HttpEntityEnclosingRequestBase) request).setEntity( - URIUtils.buildInputStreamEntity(odataClient, streamManager.getBody())); + URIUtils.buildInputStreamEntity(odataClient, payloadManager.getBody())); futureWrapper.setWrapped(odataClient.getConfiguration().getExecutor().submit(new Callable<HttpResponse>() { @Override @@ -102,7 +102,7 @@ public abstract class AbstractODataStreamedRequest<V extends ODataResponse, T ex })); // returns the stream manager object - return (T) streamManager; + return (T) payloadManager; } /** @@ -125,11 +125,11 @@ public abstract class AbstractODataStreamedRequest<V extends ODataResponse, T ex * @param contentId ContentId header value to be added to the serialization. Use this in case of changeset items. */ public void batch(final CommonODataBatchRequest req, final String contentId) { - final InputStream input = getStreamManager().getBody(); + final InputStream input = getPayloadManager().getBody(); try { // finalize the body - getStreamManager().finalizeBody(); + getPayloadManager().finalizeBody(); req.rawAppend(toByteArray()); if (StringUtils.isNotBlank(contentId)) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java index 89b0da07b..60bca42ae 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityCreateRequestImpl.java @@ -52,7 +52,7 @@ public class ODataMediaEntityCreateRequestImpl<E extends CommonODataEntity> * @param targetURI target entity set. * @param media media entity blob to be created. */ - ODataMediaEntityCreateRequestImpl(final CommonODataClient<?> odataClient, final URI targetURI, + public ODataMediaEntityCreateRequestImpl(final CommonODataClient<?> odataClient, final URI targetURI, final InputStream media) { super(odataClient, HttpMethod.POST, targetURI); @@ -60,11 +60,11 @@ public class ODataMediaEntityCreateRequestImpl<E extends CommonODataEntity> } @Override - protected MediaEntityCreateStreamManager<E> getStreamManager() { - if (streamManager == null) { - streamManager = new MediaEntityCreateStreamManagerImpl(media); + protected MediaEntityCreateStreamManager<E> getPayloadManager() { + if (payloadManager == null) { + payloadManager = new MediaEntityCreateStreamManagerImpl(media); } - return (MediaEntityCreateStreamManager<E>) streamManager; + return (MediaEntityCreateStreamManager<E>) payloadManager; } /** diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java index bd9fa820c..a63efa82b 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataMediaEntityUpdateRequestImpl.java @@ -53,7 +53,7 @@ public class ODataMediaEntityUpdateRequestImpl<E extends CommonODataEntity> * @param editURI edit URI of the entity to be updated. * @param media media entity blob to be created. */ - ODataMediaEntityUpdateRequestImpl(final CommonODataClient<?> odataClient, + public ODataMediaEntityUpdateRequestImpl(final CommonODataClient<?> odataClient, final HttpMethod method, final URI editURI, final InputStream media) { super(odataClient, method, editURI); @@ -61,11 +61,11 @@ public class ODataMediaEntityUpdateRequestImpl<E extends CommonODataEntity> } @Override - protected MediaEntityUpdateStreamManager<E> getStreamManager() { - if (streamManager == null) { - streamManager = new MediaEntityUpdateStreamManagerImpl(media); + protected MediaEntityUpdateStreamManager<E> getPayloadManager() { + if (payloadManager == null) { + payloadManager = new MediaEntityUpdateStreamManagerImpl(media); } - return (MediaEntityUpdateStreamManager<E>) streamManager; + return (MediaEntityUpdateStreamManager<E>) payloadManager; } /** diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataStreamUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataStreamUpdateRequestImpl.java index bf567a571..216c5214c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataStreamUpdateRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/ODataStreamUpdateRequestImpl.java @@ -48,7 +48,7 @@ public class ODataStreamUpdateRequestImpl * @param targetURI target URI. * @param stream stream to be updated. */ - ODataStreamUpdateRequestImpl(final CommonODataClient<?> odataClient, + public ODataStreamUpdateRequestImpl(final CommonODataClient<?> odataClient, final HttpMethod method, final URI targetURI, final InputStream stream) { super(odataClient, method, targetURI); @@ -59,12 +59,12 @@ public class ODataStreamUpdateRequestImpl * {@inheritDoc } */ @Override - protected StreamUpdateStreamManager getStreamManager() { - if (streamManager == null) { - streamManager = new StreamUpdateStreamManagerImpl(this.stream); + protected StreamUpdateStreamManager getPayloadManager() { + if (payloadManager == null) { + payloadManager = new StreamUpdateStreamManagerImpl(this.stream); } - return (StreamUpdateStreamManager) streamManager; + return (StreamUpdateStreamManager) payloadManager; } public class StreamUpdateStreamManagerImpl extends AbstractODataStreamManager<ODataStreamUpdateResponse> diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/StreamedRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/StreamedRequestFactoryImpl.java deleted file mode 100644 index a7f1b56b8..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/streamed/StreamedRequestFactoryImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.client.core.communication.request.streamed; - -import java.io.InputStream; -import java.net.URI; -import org.apache.olingo.client.api.CommonODataClient; -import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityCreateRequest; -import org.apache.olingo.client.api.communication.request.streamed.ODataMediaEntityUpdateRequest; -import org.apache.olingo.client.api.communication.request.streamed.ODataStreamUpdateRequest; -import org.apache.olingo.client.api.communication.request.streamed.StreamedRequestFactory; -import org.apache.olingo.client.api.http.HttpMethod; -import org.apache.olingo.commons.api.domain.CommonODataEntity; - -public class StreamedRequestFactoryImpl implements StreamedRequestFactory { - - private static final long serialVersionUID = -2438839640443961168L; - - protected final CommonODataClient<?> client; - - public StreamedRequestFactoryImpl(final CommonODataClient<?> client) { - this.client = client; - } - - @Override - public <E extends CommonODataEntity> ODataMediaEntityCreateRequest<E> getMediaEntityCreateRequest( - final URI targetURI, final InputStream media) { - - return new ODataMediaEntityCreateRequestImpl<E>(client, targetURI, media); - } - - @Override - public ODataStreamUpdateRequest getStreamUpdateRequest(final URI targetURI, final InputStream stream) { - final ODataStreamUpdateRequest req; - - if (client.getConfiguration().isUseXHTTPMethod()) { - req = new ODataStreamUpdateRequestImpl(client, HttpMethod.POST, targetURI, stream); - req.setXHTTPMethod(HttpMethod.PUT.name()); - } else { - req = new ODataStreamUpdateRequestImpl(client, HttpMethod.PUT, targetURI, stream); - } - - return req; - } - - @Override - public <E extends CommonODataEntity> ODataMediaEntityUpdateRequest<E> getMediaEntityUpdateRequest( - final URI editURI, final InputStream media) { - - final ODataMediaEntityUpdateRequest<E> req; - - if (client.getConfiguration().isUseXHTTPMethod()) { - req = new ODataMediaEntityUpdateRequestImpl<E>(client, HttpMethod.POST, editURI, media); - req.setXHTTPMethod(HttpMethod.PUT.name()); - } else { - req = new ODataMediaEntityUpdateRequestImpl<E>(client, HttpMethod.PUT, editURI, media); - } - - return req; - } -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncBatchRequestWrapperImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncBatchRequestWrapperImpl.java index 8a3d903a6..e1fe1023f 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncBatchRequestWrapperImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/v4/AsyncBatchRequestWrapperImpl.java @@ -23,11 +23,10 @@ import java.util.Collection; import org.apache.commons.io.IOUtils; import org.apache.olingo.client.api.communication.header.HeaderName; import org.apache.olingo.client.api.communication.header.ODataPreferences; +import org.apache.olingo.client.api.communication.request.ODataBatchableRequest; +import org.apache.olingo.client.api.communication.request.batch.BatchManager; import org.apache.olingo.client.api.communication.request.batch.ODataChangeset; -import org.apache.olingo.client.api.communication.request.batch.ODataRetrieve; -import org.apache.olingo.client.api.communication.request.batch.v4.BatchStreamManager; import org.apache.olingo.client.api.communication.request.batch.v4.ODataBatchRequest; -import org.apache.olingo.client.api.communication.request.batch.v4.ODataOutsideUpdate; import org.apache.olingo.client.api.communication.request.v4.AsyncBatchRequestWrapper; import org.apache.olingo.client.api.communication.response.ODataBatchResponse; import org.apache.olingo.client.api.communication.response.v4.AsyncResponseWrapper; @@ -37,11 +36,11 @@ import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; public class AsyncBatchRequestWrapperImpl extends AsyncRequestWrapperImpl<ODataBatchResponse> implements AsyncBatchRequestWrapper { - private BatchStreamManager batchStreamManager; + private BatchManager batchManager; protected AsyncBatchRequestWrapperImpl(final ODataClient odataClient, final ODataBatchRequest odataRequest) { super(odataClient, odataRequest); - batchStreamManager = odataRequest.execute(); + batchManager = odataRequest.payloadManager(); } /** @@ -49,28 +48,28 @@ public class AsyncBatchRequestWrapperImpl extends AsyncRequestWrapperImpl<ODataB */ @Override public ODataChangeset addChangeset() { - return batchStreamManager.addChangeset(); + return batchManager.addChangeset(); } /** * {@inheritDoc} */ @Override - public ODataRetrieve addRetrieve() { - return batchStreamManager.addRetrieve(); + public void addRetrieve(final ODataBatchableRequest request) { + batchManager.addRequest(request); } /** * {@inheritDoc} */ @Override - public ODataOutsideUpdate addOutsideUpdate() { - return batchStreamManager.addOutsideUpdate(); + public void addOutsideUpdate(final ODataBatchableRequest request) { + batchManager.addRequest(request); } @Override public AsyncResponseWrapper<ODataBatchResponse> execute() { - return new AsyncResponseWrapperImpl(batchStreamManager.getResponse()); + return new AsyncResponseWrapperImpl(batchManager.getResponse()); } public class AsyncResponseWrapperImpl diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java index ddf84fc6f..324e05373 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataBinderImpl.java @@ -50,7 +50,7 @@ import org.apache.olingo.commons.api.domain.ODataInlineEntitySet; import org.apache.olingo.commons.api.domain.ODataLinked; import org.apache.olingo.commons.api.domain.ODataServiceDocument; import org.apache.olingo.commons.api.domain.ODataValue; -import org.apache.olingo.commons.api.domain.v4.ODataAnnotatatable; +import org.apache.olingo.commons.api.domain.v4.ODataAnnotatable; import org.apache.olingo.commons.api.domain.v4.ODataAnnotation; import org.apache.olingo.commons.api.domain.v4.ODataDeletedEntity.Reason; import org.apache.olingo.commons.api.domain.v4.ODataDelta; @@ -138,7 +138,7 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder } } - private void annotations(final ODataAnnotatatable odataAnnotatable, final Annotatable annotatable, + private void annotations(final ODataAnnotatable odataAnnotatable, final Annotatable annotatable, final Class<? extends Entity> reference) { for (ODataAnnotation odataAnnotation : odataAnnotatable.getAnnotations()) { @@ -220,7 +220,7 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder return valueResource; } - private void odataAnnotations(final Annotatable annotatable, final ODataAnnotatatable odataAnnotatable) { + private void odataAnnotations(final Annotatable annotatable, final ODataAnnotatable odataAnnotatable) { for (Annotation annotation : annotatable.getAnnotations()) { FullQualifiedName fqn = null; if (client instanceof EdmEnabledODataClient) { @@ -265,7 +265,7 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder super.odataNavigationLinks(edmType, linked, odataLinked, metadataETag, base); for (org.apache.olingo.commons.api.domain.ODataLink link : odataLinked.getNavigationLinks()) { if (!(link instanceof ODataInlineEntity) && !(link instanceof ODataInlineEntitySet)) { - odataAnnotations(linked.getNavigationLink(link.getName()), (ODataAnnotatatable) link); + odataAnnotations(linked.getNavigationLink(link.getName()), (ODataAnnotatable) link); } } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java index 017041b2e..c97e6fd26 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/uri/URIUtils.java @@ -23,6 +23,7 @@ import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.net.URI; +import java.net.URISyntaxException; import java.net.URLEncoder; import java.sql.Timestamp; import java.util.Calendar; @@ -39,15 +40,16 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; +import org.apache.http.client.utils.URIBuilder; import org.apache.http.entity.AbstractHttpEntity; import org.apache.http.entity.ByteArrayEntity; import org.apache.http.entity.InputStreamEntity; import org.apache.olingo.client.api.CommonODataClient; import org.apache.olingo.client.api.http.HttpClientFactory; +import org.apache.olingo.client.api.uri.SegmentType; import org.apache.olingo.client.core.http.BasicAuthHttpClientFactory; import org.apache.olingo.client.core.http.ProxyWrapperHttpClientFactory; import org.apache.olingo.commons.api.Constants; -import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; @@ -145,25 +147,6 @@ public final class URIUtils { return uri.normalize(); } - /** - * Gets operation import URI segment. - * - * @param entityContainer entity container. - * @param operationImportName action / function import name. - * @return URI segment. - */ - public static String operationImportURISegment( - final EdmEntityContainer entityContainer, final String operationImportName) { - - final StringBuilder result = new StringBuilder(); - if (!entityContainer.isDefault()) { - result.append(entityContainer.getName()).append('.'); - } - result.append(operationImportName); - - return result.toString(); - } - private static String prefix(final ODataServiceVersion version, final EdmPrimitiveTypeKind typeKind) { String result = StringUtils.EMPTY; if (version.compareTo(ODataServiceVersion.V40) < 0) { @@ -230,12 +213,12 @@ public final class URIUtils { return version.compareTo(ODataServiceVersion.V40) < 0 ? prefix(version, EdmPrimitiveTypeKind.DateTime) + URLEncoder.encode(EdmDateTime.getInstance(). - valueToString(timestamp, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), - Constants.UTF8) + valueToString(timestamp, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), + Constants.UTF8) + suffix(version, EdmPrimitiveTypeKind.DateTime) : URLEncoder.encode(EdmDateTimeOffset.getInstance(). - valueToString(timestamp, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), - Constants.UTF8); + valueToString(timestamp, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), + Constants.UTF8); } private static String calendar(final ODataServiceVersion version, final Calendar calendar) @@ -246,8 +229,8 @@ public final class URIUtils { if (version.compareTo(ODataServiceVersion.V40) < 0) { result = prefix(version, EdmPrimitiveTypeKind.DateTime) + URLEncoder.encode(EdmDateTime.getInstance(). - valueToString(calendar, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), - Constants.UTF8) + valueToString(calendar, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), + Constants.UTF8) + suffix(version, EdmPrimitiveTypeKind.DateTime); } else { if (calendar.get(Calendar.YEAR) == 0 && calendar.get(Calendar.MONTH) == 0 @@ -265,8 +248,8 @@ public final class URIUtils { } else { result = prefix(version, EdmPrimitiveTypeKind.DateTimeOffset) + URLEncoder.encode(EdmDateTimeOffset.getInstance(). - valueToString(calendar, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), - Constants.UTF8) + valueToString(calendar, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), + Constants.UTF8) + suffix(version, EdmPrimitiveTypeKind.DateTimeOffset); } @@ -278,11 +261,11 @@ public final class URIUtils { return version.compareTo(ODataServiceVersion.V40) < 0 ? EdmTime.getInstance().toUriLiteral(URLEncoder.encode(EdmTime.getInstance(). - valueToString(duration, null, null, - Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), Constants.UTF8)) + valueToString(duration, null, null, + Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), Constants.UTF8)) : EdmDuration.getInstance().toUriLiteral(URLEncoder.encode(EdmDuration.getInstance(). - valueToString(duration, null, null, - Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), Constants.UTF8)); + valueToString(duration, null, null, + Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), Constants.UTF8)); } private static String quoteString(final String string, final boolean singleQuoteEscape) @@ -360,24 +343,24 @@ public final class URIUtils { ? duration(version, (Duration) obj) : (obj instanceof BigDecimal) ? EdmDecimal.getInstance().valueToString(obj, null, null, - Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + suffix(version, EdmPrimitiveTypeKind.Decimal) : (obj instanceof Double) ? EdmDouble.getInstance().valueToString(obj, null, null, - Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + suffix(version, EdmPrimitiveTypeKind.Double) : (obj instanceof Float) ? EdmSingle.getInstance().valueToString(obj, null, null, - Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + suffix(version, EdmPrimitiveTypeKind.Single) : (obj instanceof Long) ? EdmInt64.getInstance().valueToString(obj, null, null, - Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null) + suffix(version, EdmPrimitiveTypeKind.Int64) : (obj instanceof Geospatial) ? URLEncoder.encode(EdmPrimitiveTypeFactory.getInstance(((Geospatial) obj).getEdmPrimitiveTypeKind()). - valueToString(obj, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), - Constants.UTF8) + valueToString(obj, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), + Constants.UTF8) : (obj instanceof String) ? quoteString((String) obj, singleQuoteEscape) : obj.toString(); @@ -407,18 +390,18 @@ public final class URIUtils { public static HttpEntity buildInputStreamEntity(final CommonODataClient<?> client, final InputStream input) { HttpEntity entity; - + // -------------------------- // Check just required by batch requests since their ansynchronous entity specification mechanism // -------------------------- boolean contentAvailable; try { - contentAvailable = input.available()>0; + contentAvailable = input.available() > 0; } catch (IOException ex) { contentAvailable = false; } // -------------------------- - + boolean repeatableRequired = shouldUseRepeatableHttpBodyEntry(client); if (!contentAvailable || !repeatableRequired) { entity = new InputStreamEntity(input, -1); @@ -437,4 +420,19 @@ public final class URIUtils { ((AbstractHttpEntity) entity).setChunked(client.getConfiguration().isUseChuncked()); return entity; } + + public static URI addValueSegment(final URI uri) { + final URI res; + if (uri.getPath().endsWith(SegmentType.VALUE.getValue())) { + res = uri; + } else { + try { + res = new URIBuilder(uri).setPath(uri.getPath() + "/" + SegmentType.VALUE.getValue()).build(); + } catch (URISyntaxException e) { + throw new IllegalArgumentException(e); + } + } + + return res; + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/EdmEnabledODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/EdmEnabledODataClientImpl.java index 60f753d70..a2e92d038 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/EdmEnabledODataClientImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/EdmEnabledODataClientImpl.java @@ -65,7 +65,7 @@ public class EdmEnabledODataClientImpl extends ODataClientImpl implements EdmEna } @Override - public URIBuilder getURIBuilder() { + public URIBuilder newURIBuilder() { return new URIBuilderImpl(getServiceVersion(), configuration, serviceRoot); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java index 8b3b2e40b..8d696eca5 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java @@ -27,7 +27,6 @@ import org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFacto import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType; import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory; import org.apache.olingo.client.api.communication.request.retrieve.v3.RetrieveRequestFactory; -import org.apache.olingo.client.api.communication.request.streamed.StreamedRequestFactory; import org.apache.olingo.commons.api.op.ODataSerializer; import org.apache.olingo.client.api.op.v3.ODataDeserializer; import org.apache.olingo.client.api.op.v3.ODataBinder; @@ -40,7 +39,6 @@ import org.apache.olingo.client.core.communication.request.batch.v3.BatchRequest import org.apache.olingo.client.core.communication.request.cud.v3.CUDRequestFactoryImpl; import org.apache.olingo.client.core.communication.request.invoke.v3.InvokeRequestFactoryImpl; import org.apache.olingo.client.core.communication.request.retrieve.v3.RetrieveRequestFactoryImpl; -import org.apache.olingo.client.core.communication.request.streamed.StreamedRequestFactoryImpl; import org.apache.olingo.client.core.op.impl.v3.ODataBinderImpl; import org.apache.olingo.client.core.op.impl.v3.ODataDeserializerImpl; import org.apache.olingo.client.core.op.impl.v3.ODataReaderImpl; @@ -73,8 +71,6 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements private final CUDRequestFactory cudReqFact = new CUDRequestFactoryImpl(this); - private final StreamedRequestFactory streamedReqFact = new StreamedRequestFactoryImpl(this); - private final InvokeRequestFactory invokeReqFact = new InvokeRequestFactoryImpl(this); private final BatchRequestFactory batchReqFact = new BatchRequestFactoryImpl(this); @@ -85,7 +81,7 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements } @Override - public ODataHeaders getVersionHeaders() { + public ODataHeaders newVersionHeaders() { final ODataHeadersImpl odataHeaders = new ODataHeadersImpl(); odataHeaders.setHeader(HeaderName.minDataServiceVersion, ODataServiceVersion.V30.toString()); odataHeaders.setHeader(HeaderName.maxDataServiceVersion, ODataServiceVersion.V30.toString()); @@ -99,7 +95,7 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements } @Override - public URIBuilder getURIBuilder(final String serviceRoot) { + public URIBuilder newURIBuilder(final String serviceRoot) { return new URIBuilderImpl(getServiceVersion(), configuration, serviceRoot); } @@ -144,11 +140,6 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements return cudReqFact; } - @Override - public StreamedRequestFactory getStreamedRequestFactory() { - return streamedReqFact; - } - @Override public InvokeRequestFactory getInvokeRequestFactory() { return invokeReqFact; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/EdmEnabledODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/EdmEnabledODataClientImpl.java index a9eb35227..1cd605963 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/EdmEnabledODataClientImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/EdmEnabledODataClientImpl.java @@ -72,7 +72,7 @@ public class EdmEnabledODataClientImpl extends ODataClientImpl implements EdmEna } @Override - public URIBuilder getURIBuilder() { + public URIBuilder newURIBuilder() { return new URIBuilderImpl(getServiceVersion(), configuration, serviceRoot); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java index fd298a0c6..4b4efd422 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java @@ -27,7 +27,6 @@ import org.apache.olingo.client.api.communication.request.cud.v4.CUDRequestFacto import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType; import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory; import org.apache.olingo.client.api.communication.request.retrieve.v4.RetrieveRequestFactory; -import org.apache.olingo.client.api.communication.request.streamed.StreamedRequestFactory; import org.apache.olingo.client.api.communication.request.v4.AsyncRequestFactory; import org.apache.olingo.commons.api.op.ODataSerializer; import org.apache.olingo.client.api.op.v4.ODataBinder; @@ -42,7 +41,6 @@ import org.apache.olingo.client.core.communication.request.batch.v4.BatchRequest import org.apache.olingo.client.core.communication.request.cud.v4.CUDRequestFactoryImpl; import org.apache.olingo.client.core.communication.request.invoke.v4.InvokeRequestFactoryImpl; import org.apache.olingo.client.core.communication.request.retrieve.v4.RetrieveRequestFactoryImpl; -import org.apache.olingo.client.core.communication.request.streamed.StreamedRequestFactoryImpl; import org.apache.olingo.client.core.communication.request.v4.AsyncRequestFactoryImpl; import org.apache.olingo.client.core.op.impl.v4.ODataBinderImpl; import org.apache.olingo.client.core.op.impl.v4.ODataDeserializerImpl; @@ -80,8 +78,6 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements private final CUDRequestFactory cudReqFact = new CUDRequestFactoryImpl(this); - private final StreamedRequestFactory streamedReqFact = new StreamedRequestFactoryImpl(this); - private final InvokeRequestFactory invokeReqFact = new InvokeRequestFactoryImpl(this); private final BatchRequestFactory batchReqFact = new BatchRequestFactoryImpl(this); @@ -92,7 +88,7 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements } @Override - public ODataHeaders getVersionHeaders() { + public ODataHeaders newVersionHeaders() { final ODataHeadersImpl odataHeaders = new ODataHeadersImpl(); odataHeaders.setHeader(HeaderName.odataMaxVersion, ODataServiceVersion.V40.toString()); odataHeaders.setHeader(HeaderName.odataVersion, ODataServiceVersion.V40.toString()); @@ -105,7 +101,7 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements } @Override - public URIBuilder getURIBuilder(final String serviceRoot) { + public URIBuilder newURIBuilder(final String serviceRoot) { return new URIBuilderImpl(getServiceVersion(), getConfiguration(), serviceRoot); } @@ -160,11 +156,6 @@ public class ODataClientImpl extends AbstractODataClient<UpdateType> implements return cudReqFact; } - @Override - public StreamedRequestFactory getStreamedRequestFactory() { - return streamedReqFact; - } - @Override public InvokeRequestFactory getInvokeRequestFactory() { return invokeReqFact; diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v3/URIBuilderTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v3/URIBuilderTest.java index a0bb04c23..11227f3b3 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v3/URIBuilderTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v3/URIBuilderTest.java @@ -42,14 +42,14 @@ public class URIBuilderTest extends AbstractTest { @Test public void metadata() throws URISyntaxException { - final URI uri = getClient().getURIBuilder(SERVICE_ROOT).appendMetadataSegment().build(); + final URI uri = getClient().newURIBuilder(SERVICE_ROOT).appendMetadataSegment().build(); assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/$metadata").build(), uri); } @Test public void entity() throws URISyntaxException { - final URI uri = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("AnEntitySet"). + final URI uri = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("AnEntitySet"). appendKeySegment(11).build(); assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/AnEntitySet(11)").build(), uri); @@ -57,21 +57,21 @@ public class URIBuilderTest extends AbstractTest { final Map<String, Object> multiKey = new HashMap<String, Object>(); multiKey.put("OrderId", -10); multiKey.put("ProductId", -10); - URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT). + URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT). appendEntitySetSegment("OrderLine").appendKeySegment(multiKey). appendPropertySegment("Quantity").appendValueSegment(); assertEquals(new org.apache.http.client.utils.URIBuilder( SERVICE_ROOT + "/OrderLine(OrderId=-10,ProductId=-10)/Quantity/$value").build(), uriBuilder.build()); - uriBuilder = getClient().getURIBuilder(SERVICE_ROOT). + uriBuilder = getClient().newURIBuilder(SERVICE_ROOT). appendEntitySetSegment("Customer").appendKeySegment(-10). select("CustomerId", "Name", "Orders").expand("Orders"); assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Customer(-10)"). addParameter("$select", "CustomerId,Name,Orders").addParameter("$expand", "Orders").build(), uriBuilder.build()); - uriBuilder = getClient().getURIBuilder(SERVICE_ROOT). + uriBuilder = getClient().newURIBuilder(SERVICE_ROOT). appendEntitySetSegment("Customer").appendKeySegment(-10).appendLinksSegment("Orders"); assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Customer(-10)/$links/Orders").build(), uriBuilder.build()); @@ -79,11 +79,11 @@ public class URIBuilderTest extends AbstractTest { @Test public void count() throws URISyntaxException { - URI uri = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").count().build(); + URI uri = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").count().build(); assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Products/$count").build(), uri); - uri = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products"). + uri = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products"). inlineCount(URIBuilder.InlineCount.allpages).build(); assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Products"). @@ -92,7 +92,7 @@ public class URIBuilderTest extends AbstractTest { @Test public void filter() throws URISyntaxException { - final URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("AnEntitySet"). + final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("AnEntitySet"). filter(getClient().getFilterFactory().lt("VIN", 16)); assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/AnEntitySet"). @@ -103,7 +103,7 @@ public class URIBuilderTest extends AbstractTest { @Test public void filterWithParameter() throws URISyntaxException { // http://host/service.svc/Employees?$filter=Region eq @p1&@p1='WA' - final URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Employees"). + final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Employees"). filter(getClient().getFilterFactory().eq("Region", new ParameterAlias("p1"))). addParameterAlias("p1", "'WA'"); @@ -114,7 +114,7 @@ public class URIBuilderTest extends AbstractTest { @Test public void boundAction() throws URISyntaxException { - final URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT). + final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT). appendEntitySetSegment("Products").appendOperationCallSegment("MostExpensive"); assertEquals(new org.apache.http.client.utils.URIBuilder( @@ -123,7 +123,7 @@ public class URIBuilderTest extends AbstractTest { @Test public void derived() throws URISyntaxException { - final URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT). + final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT). appendEntitySetSegment("Customers").appendNavigationSegment("Model"). appendDerivedEntityTypeSegment("Namespace.VipCustomer").appendKeySegment(1); @@ -133,7 +133,7 @@ public class URIBuilderTest extends AbstractTest { @Test public void expandMoreThenOnce() throws URISyntaxException { - URI uri = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").appendKeySegment(5). + URI uri = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").appendKeySegment(5). expand("Orders", "Customers").expand("Info").build(); assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Products(5)"). @@ -142,7 +142,7 @@ public class URIBuilderTest extends AbstractTest { @Test public void selectMoreThenOnce() throws URISyntaxException { - URI uri = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Customers").appendKeySegment(5). + URI uri = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Customers").appendKeySegment(5). select("Name", "Surname").expand("Info").select("Gender").build(); assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Customers(5)"). diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v4/URIBuilderTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v4/URIBuilderTest.java index 777236d67..9b8ea7598 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v4/URIBuilderTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/v4/URIBuilderTest.java @@ -41,7 +41,7 @@ public class URIBuilderTest extends AbstractTest { @Test public void expandWithOptions() throws URISyntaxException { - final URI uri = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").appendKeySegment(5). + final URI uri = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").appendKeySegment(5). expandWithOptions("ProductDetails", new LinkedHashMap<QueryOption, Object>() { private static final long serialVersionUID = 3109256773218160485L; @@ -57,7 +57,7 @@ public class URIBuilderTest extends AbstractTest { @Test public void expandWithLevels() throws URISyntaxException { - final URI uri = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").appendKeySegment(1). + final URI uri = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").appendKeySegment(1). expandWithOptions("Customer", Collections.<QueryOption, Object>singletonMap(QueryOption.LEVELS, 4)). build(); @@ -67,11 +67,11 @@ public class URIBuilderTest extends AbstractTest { @Test public void count() throws URISyntaxException { - URI uri = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").count().build(); + URI uri = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").count().build(); assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Products/$count").build(), uri); - uri = getClient().getURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").count(true).build(); + uri = getClient().newURIBuilder(SERVICE_ROOT).appendEntitySetSegment("Products").count(true).build(); assertEquals(new org.apache.http.client.utils.URIBuilder(SERVICE_ROOT + "/Products"). addParameter("$count", "true").build(), uri); @@ -79,7 +79,7 @@ public class URIBuilderTest extends AbstractTest { @Test public void singleton() throws URISyntaxException { - final URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT). + final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT). appendSingletonSegment("BestProductEverCreated"); assertEquals(new org.apache.http.client.utils.URIBuilder( @@ -88,7 +88,7 @@ public class URIBuilderTest extends AbstractTest { @Test public void entityId() throws URISyntaxException { - final URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT). + final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT). appendEntityIdSegment("Products(0)"); assertEquals(new org.apache.http.client.utils.URIBuilder( @@ -97,7 +97,7 @@ public class URIBuilderTest extends AbstractTest { @Test public void boundAction() throws URISyntaxException { - final URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT). + final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT). appendEntitySetSegment("Categories").appendKeySegment(1). appendNavigationSegment("Products").appendNavigationSegment("Model"). appendOperationCallSegment("AllOrders"); @@ -108,14 +108,14 @@ public class URIBuilderTest extends AbstractTest { @Test public void ref() throws URISyntaxException { - URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT). + URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT). appendEntitySetSegment("Categories").appendKeySegment(1). appendNavigationSegment("Products").appendRefSegment(); assertEquals(new org.apache.http.client.utils.URIBuilder( SERVICE_ROOT + "/Categories(1)/Products/$ref").build(), uriBuilder.build()); - uriBuilder = getClient().getURIBuilder(SERVICE_ROOT). + uriBuilder = getClient().newURIBuilder(SERVICE_ROOT). appendEntitySetSegment("Categories").appendKeySegment(1). appendNavigationSegment("Products").appendRefSegment().id("../../Products(0)"); @@ -126,7 +126,7 @@ public class URIBuilderTest extends AbstractTest { @Test public void derived() throws URISyntaxException { - final URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT). + final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT). appendEntitySetSegment("Customers").appendDerivedEntityTypeSegment("Model.VipCustomer").appendKeySegment(1); assertEquals(new org.apache.http.client.utils.URIBuilder( @@ -135,7 +135,7 @@ public class URIBuilderTest extends AbstractTest { @Test public void crossjoin() throws URISyntaxException { - final URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT). + final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT). appendCrossjoinSegment("Products", "Sales"); assertEquals(new org.apache.http.client.utils.URIBuilder( @@ -144,7 +144,7 @@ public class URIBuilderTest extends AbstractTest { @Test public void all() throws URISyntaxException { - final URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT).appendAllSegment(); + final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT).appendAllSegment(); assertEquals(new org.apache.http.client.utils.URIBuilder( SERVICE_ROOT + "/$all").build(), uriBuilder.build()); @@ -152,7 +152,7 @@ public class URIBuilderTest extends AbstractTest { @Test public void search() throws URISyntaxException { - final URIBuilder uriBuilder = getClient().getURIBuilder(SERVICE_ROOT). + final URIBuilder uriBuilder = getClient().newURIBuilder(SERVICE_ROOT). appendEntitySetSegment("Products").search("blue OR green"); assertEquals(new org.apache.http.client.utils.URIBuilder( diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataAnnotatatable.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataAnnotatable.java similarity index 96% rename from lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataAnnotatatable.java rename to lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataAnnotatable.java index 7481efcd3..be4c6e8ee 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataAnnotatatable.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataAnnotatable.java @@ -20,7 +20,7 @@ package org.apache.olingo.commons.api.domain.v4; import java.util.List; -public interface ODataAnnotatatable { +public interface ODataAnnotatable { List<ODataAnnotation> getAnnotations(); } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDeltaLink.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDeltaLink.java index ff9e08841..c9b54e6c4 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDeltaLink.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataDeltaLink.java @@ -20,7 +20,7 @@ package org.apache.olingo.commons.api.domain.v4; import java.net.URI; -public interface ODataDeltaLink extends ODataAnnotatatable { +public interface ODataDeltaLink extends ODataAnnotatable { URI getSource(); diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntity.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntity.java index fb24dda0a..2c1111b63 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntity.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntity.java @@ -21,7 +21,7 @@ package org.apache.olingo.commons.api.domain.v4; import java.util.List; import org.apache.olingo.commons.api.domain.CommonODataEntity; -public interface ODataEntity extends CommonODataEntity, ODataAnnotatatable { +public interface ODataEntity extends CommonODataEntity, ODataAnnotatable { @Override ODataProperty getProperty(String name); diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntitySet.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntitySet.java index ca25b0bd0..683375a1a 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntitySet.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataEntitySet.java @@ -22,7 +22,7 @@ import java.net.URI; import java.util.List; import org.apache.olingo.commons.api.domain.CommonODataEntitySet; -public interface ODataEntitySet extends CommonODataEntitySet, ODataAnnotatatable { +public interface ODataEntitySet extends CommonODataEntitySet, ODataAnnotatable { @Override List<ODataEntity> getEntities(); diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataLink.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataLink.java index 5ff76a821..5c14386d8 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataLink.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataLink.java @@ -24,7 +24,7 @@ import java.util.List; import org.apache.olingo.commons.api.domain.ODataLinkType; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; -public class ODataLink extends org.apache.olingo.commons.api.domain.ODataLink implements ODataAnnotatatable { +public class ODataLink extends org.apache.olingo.commons.api.domain.ODataLink implements ODataAnnotatable { private static final long serialVersionUID = 8953805653775734101L; diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataLinkedComplexValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataLinkedComplexValue.java index 671751072..c50c9a8d1 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataLinkedComplexValue.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataLinkedComplexValue.java @@ -22,6 +22,6 @@ import org.apache.olingo.commons.api.domain.ODataComplexValue; import org.apache.olingo.commons.api.domain.ODataLinked; public interface ODataLinkedComplexValue - extends ODataValue, ODataLinked, ODataComplexValue<ODataProperty>, ODataAnnotatatable { + extends ODataValue, ODataLinked, ODataComplexValue<ODataProperty>, ODataAnnotatable { } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java index 09507ba2a..f8096818e 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/v4/ODataProperty.java @@ -20,5 +20,5 @@ package org.apache.olingo.commons.api.domain.v4; import org.apache.olingo.commons.api.domain.CommonODataProperty; -public interface ODataProperty extends CommonODataProperty, ODataAnnotatatable, ODataValuable { +public interface ODataProperty extends CommonODataProperty, ODataAnnotatable, ODataValuable { } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java index 78f05a716..1713a7c5d 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AbstractJsonSerializer.java @@ -121,7 +121,7 @@ abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> { if (StringUtils.isNotBlank(link.getHref())) { jgen.writeStringField( link.getTitle() + StringUtils.prependIfMissing( - version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK), "@"), + version.getJSONMap().get(ODataServiceVersion.JSON_MEDIAEDIT_LINK), "@"), link.getHref()); } } @@ -136,6 +136,10 @@ abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> { } for (Link link : linked.getNavigationLinks()) { + for (Annotation annotation : link.getAnnotations()) { + valuable(jgen, annotation, link.getTitle() + "@" + annotation.getTerm()); + } + if (StringUtils.isNotBlank(link.getHref())) { jgen.writeStringField( link.getTitle() + version.getJSONMap().get(ODataServiceVersion.JSON_NAVIGATION_LINK), diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java index dad1bfa63..9e1b22d48 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomDeserializer.java @@ -637,6 +637,7 @@ public class AtomDeserializer extends AbstractAtomDealer { } } else if (link.getRel().startsWith( version.getNamespaceMap().get(ODataServiceVersion.NAVIGATION_LINK_REL))) { + entity.getNavigationLinks().add(link); inline(reader, event.asStartElement(), link); } else if (link.getRel().startsWith( diff --git a/pom.xml b/pom.xml index 0047b4d30..0f4af7c2b 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ <commons.codec.version>1.9</commons.codec.version> <commons.io.version>2.4</commons.io.version> <commons.lang3.version>3.3.2</commons.lang3.version> - <commons.beanutils.version>1.8.3</commons.beanutils.version> + <commons.beanutils.version>1.9.1</commons.beanutils.version> <commons.logging.version>1.1.3</commons.logging.version> <commons.vfs.version>2.0</commons.vfs.version> @@ -124,7 +124,7 @@ </dependency> <dependency> <groupId>commons-beanutils</groupId> - <artifactId>commons-beanutils-core</artifactId> + <artifactId>commons-beanutils</artifactId> <version>${commons.beanutils.version}</version> </dependency> @@ -363,6 +363,12 @@ <artifactId>maven-invoker-plugin</artifactId> <version>1.8</version> </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>2.9.1</version> + </plugin> </plugins> </pluginManagement> @@ -457,4 +463,37 @@ </plugin> </plugins> </build> + + <profiles> + <profile> + <id>javadocs</id> + + <build> + <defaultGoal>javadoc:aggregate</defaultGoal> + + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <inherited>true</inherited> + <configuration> + <destDir>javadocs</destDir> + <detectLinks>true</detectLinks> + <detectJavaApiLink>true</detectJavaApiLink> + <links> + <link>http://docs.oracle.com/javaee/6/api/</link> + <link>http://www.slf4j.org/api/</link> + <link>http://commons.apache.org/proper/commons-lang/javadocs/api-release/</link> + <link>http://commons.apache.org/proper/commons-io/javadocs/api-release/</link> + <link>http://commons.apache.org/proper/commons-beanutils/javadocs/v1.9.1/apidocs/</link> + <link>http://commons.apache.org/proper/commons-codec/archives/1.9/apidocs/</link> + <link>http://www.viste.com/Java/Language/http-client/httpcomponents-client-4.2.3-bin/httpcomponents-client-4.2.3/javadoc/</link> + <link>http://fasterxml.github.io/jackson-databind/javadoc/2.3.0/</link> + </links> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> </project>