[OLINGO-575] Rename getV4 method to getClient
This commit is contained in:
parent
68ddcaf37f
commit
033f35d617
|
@ -90,7 +90,7 @@ public abstract class AbstractService<C extends EdmEnabledODataClient> {
|
|||
throw new ODataRuntimeException("Only OData V4 or higher supported.");
|
||||
}
|
||||
|
||||
this.client = ODataClientFactory.getEdmEnabledV4(serviceRoot, edm, metadataETag);
|
||||
this.client = ODataClientFactory.getEdmEnabledClient(serviceRoot, edm, metadataETag);
|
||||
this.client.getConfiguration().setDefaultPubFormat(ODataFormat.JSON_FULL_METADATA);
|
||||
this.transactional = transactional;
|
||||
this.context = new Context();
|
||||
|
|
|
@ -49,6 +49,6 @@ public class V4POJOGenMojo extends AbstractPOJOGenMojo {
|
|||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
return ODataClientFactory.getV4();
|
||||
return ODataClientFactory.getClient();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -393,7 +393,7 @@ public class BasicITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getV4();
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
return odata;
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ public class BindingITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getV4();
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
return odata;
|
||||
}
|
||||
|
|
|
@ -353,7 +353,7 @@ public class DeepInsertITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getV4();
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
return odata;
|
||||
}
|
||||
|
|
|
@ -151,6 +151,6 @@ public final class ExpandSelectITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
return ODataClientFactory.getEdmEnabledV4(TecSvcConst.BASE_URI);
|
||||
return ODataClientFactory.getEdmEnabledClient(TecSvcConst.BASE_URI);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -985,7 +985,7 @@ public class FilterSystemQueryITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getV4();
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
return odata;
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ public final class MediaITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getV4();
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
return odata;
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ public final class NavigationITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getV4();
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
return odata;
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ public class OrderBySystemQueryITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getV4();
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
return odata;
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ public class PrimitiveComplexITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getV4();
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
return odata;
|
||||
}
|
||||
|
|
|
@ -301,7 +301,7 @@ public class SystemQueryOptionITCase extends AbstractBaseTestITCase {
|
|||
|
||||
@Override
|
||||
protected ODataClient getClient() {
|
||||
ODataClient odata = ODataClientFactory.getV4();
|
||||
ODataClient odata = ODataClientFactory.getClient();
|
||||
odata.getConfiguration().setDefaultPubFormat(ODataFormat.JSON);
|
||||
return odata;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ import static org.junit.Assert.assertThat;
|
|||
|
||||
public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
||||
|
||||
protected static final ODataClient client = ODataClientFactory.getV4();
|
||||
protected static final ODataClient client = ODataClientFactory.getClient();
|
||||
|
||||
protected static EdmEnabledODataClient edmClient;
|
||||
|
||||
|
@ -87,7 +87,7 @@ public abstract class AbstractTestITCase extends AbstractBaseTestITCase {
|
|||
testAuthServiceRootURL = "http://localhost:9080/stub/DefaultService.svc/V40/Static.svc";
|
||||
testOAuth2ServiceRootURL = "http://localhost:9080/stub/StaticService/V40/OAuth2.svc";
|
||||
|
||||
edmClient = ODataClientFactory.getEdmEnabledV4(testStaticServiceRootURL);
|
||||
edmClient = ODataClientFactory.getEdmEnabledClient(testStaticServiceRootURL);
|
||||
|
||||
edmClient.getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
|
||||
client.getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
|
||||
|
|
|
@ -48,20 +48,20 @@ public class AuthBatchTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void clean() throws EdmPrimitiveTypeException {
|
||||
final ODataClient authclient = ODataClientFactory.getV4();
|
||||
final ODataClient authclient = ODataClientFactory.getClient();
|
||||
batchRequest(authclient, testStaticServiceRootURL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void authorized() throws EdmPrimitiveTypeException {
|
||||
final ODataClient authclient = ODataClientFactory.getV4();
|
||||
final ODataClient authclient = ODataClientFactory.getClient();
|
||||
authclient.getConfiguration().setHttpClientFactory(new BasicAuthHttpClientFactory("odatajclient", "odatajclient"));
|
||||
batchRequest(authclient, testAuthServiceRootURL);
|
||||
}
|
||||
|
||||
@Test(expected = HttpClientException.class)
|
||||
public void unauthorized() throws EdmPrimitiveTypeException {
|
||||
final ODataClient unauthclient = ODataClientFactory.getV4();
|
||||
final ODataClient unauthclient = ODataClientFactory.getClient();
|
||||
unauthclient.getConfiguration().setHttpClientFactory(new BasicAuthHttpClientFactory("not_auth", "not_auth"));
|
||||
batchRequest(unauthclient, testAuthServiceRootURL);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public class MediaEntityTestITCase extends AbstractTestITCase {
|
|||
|
||||
@Test
|
||||
public void readAsJSON() throws IOException {
|
||||
read(ODataClientFactory.getEdmEnabledV4(testDemoServiceRootURL), ODataFormat.JSON);
|
||||
read(ODataClientFactory.getEdmEnabledClient(testDemoServiceRootURL), ODataFormat.JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -62,7 +62,7 @@ public class OAuth2TestITCase extends AbstractTestITCase {
|
|||
|
||||
protected EdmEnabledODataClient getEdmClient() {
|
||||
if (_edmClient == null) {
|
||||
_edmClient = ODataClientFactory.getEdmEnabledV4(testOAuth2ServiceRootURL);
|
||||
_edmClient = ODataClientFactory.getEdmEnabledClient(testOAuth2ServiceRootURL);
|
||||
_edmClient.getConfiguration().setHttpClientFactory(
|
||||
new CXFOAuth2HttpClientFactory(OAUTH2_GRANT_SERVICE_URI, OAUTH2_TOKEN_SERVICE_URI));
|
||||
}
|
||||
|
|
|
@ -25,15 +25,15 @@ import org.apache.olingo.commons.api.format.ODataFormat;
|
|||
|
||||
public final class ODataClientFactory {
|
||||
|
||||
public static ODataClient getV4() {
|
||||
public static ODataClient getClient() {
|
||||
return new ODataClientImpl();
|
||||
}
|
||||
|
||||
public static EdmEnabledODataClient getEdmEnabledV4(final String serviceRoot) {
|
||||
return getEdmEnabledV4(serviceRoot, null, null);
|
||||
public static EdmEnabledODataClient getEdmEnabledClient(final String serviceRoot) {
|
||||
return getEdmEnabledClient(serviceRoot, null, null);
|
||||
}
|
||||
|
||||
public static EdmEnabledODataClient getEdmEnabledV4(
|
||||
public static EdmEnabledODataClient getEdmEnabledClient(
|
||||
final String serviceRoot, final Edm edm, final String metadataETag) {
|
||||
|
||||
final EdmEnabledODataClient instance =
|
||||
|
|
|
@ -43,8 +43,6 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
|
|||
|
||||
private final EntityContainer xmlEntityContainer;
|
||||
|
||||
private final List<? extends Schema> xmlSchemas;
|
||||
|
||||
private EdmAnnotationHelper helper;
|
||||
|
||||
public EdmEntityContainerImpl(final Edm edm, final FullQualifiedName entityContainerName,
|
||||
|
@ -54,7 +52,6 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer {
|
|||
? null : new FullQualifiedName(xmlEntityContainer.getExtends()));
|
||||
|
||||
this.xmlEntityContainer = xmlEntityContainer;
|
||||
this.xmlSchemas = xmlSchemas;
|
||||
if (xmlEntityContainer instanceof EntityContainer) {
|
||||
this.helper = new EdmAnnotationHelperImpl(edm,
|
||||
(EntityContainer) xmlEntityContainer);
|
||||
|
|
|
@ -55,7 +55,7 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
|
|||
|
||||
private final Edm edm;
|
||||
|
||||
private final List<? extends Schema> xmlSchemas;
|
||||
private final List<Schema> xmlSchemas;
|
||||
|
||||
private final Schema schema;
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class EdmSchemaImpl extends AbstractEdmSchema {
|
|||
private List<EdmEntityContainer> entityContainers;
|
||||
|
||||
public EdmSchemaImpl(final ODataServiceVersion version, final Edm edm,
|
||||
final List<? extends Schema> xmlSchemas, final Schema schema) {
|
||||
final List<Schema> xmlSchemas, final Schema schema) {
|
||||
|
||||
super(schema.getNamespace(), schema.getAlias());
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* 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
|
||||
*
|
||||
* 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
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
@ -22,6 +22,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.olingo.client.api.edm.xml.ComplexType;
|
||||
import org.apache.olingo.client.api.edm.xml.EntityType;
|
||||
import org.apache.olingo.client.api.edm.xml.NavigationProperty;
|
||||
import org.apache.olingo.client.api.edm.xml.Property;
|
||||
|
@ -39,28 +40,25 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
|
|||
|
||||
private final FullQualifiedName structuredTypeName;
|
||||
|
||||
private final StructuralType complexType;
|
||||
|
||||
private final List<? extends Schema> xmlSchemas;
|
||||
private final StructuralType structuralType;
|
||||
|
||||
private Map<String, EdmProperty> properties;
|
||||
|
||||
private Map<String, EdmNavigationProperty> navigationProperties;
|
||||
|
||||
public EdmStructuredTypeHelperImpl(final Edm edm, final FullQualifiedName structuredTypeName,
|
||||
final List<? extends Schema> xmlSchemas, final StructuralType structuralType) {
|
||||
final List<? extends Schema> xmlSchemas, final StructuralType structuralType) {
|
||||
|
||||
this.edm = edm;
|
||||
this.structuredTypeName = structuredTypeName;
|
||||
this.complexType = structuralType;
|
||||
this.xmlSchemas = xmlSchemas;
|
||||
this.structuralType = structuralType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, EdmProperty> getProperties() {
|
||||
if (properties == null) {
|
||||
properties = new LinkedHashMap<String, EdmProperty>();
|
||||
for (Property property : complexType.getProperties()) {
|
||||
for (Property property : structuralType.getProperties()) {
|
||||
properties.put(property.getName(), new EdmPropertyImpl(edm, structuredTypeName, property));
|
||||
}
|
||||
}
|
||||
|
@ -71,11 +69,11 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
|
|||
public Map<String, EdmNavigationProperty> getNavigationProperties() {
|
||||
if (navigationProperties == null) {
|
||||
navigationProperties = new LinkedHashMap<String, EdmNavigationProperty>();
|
||||
for (NavigationProperty navigationProperty : complexType.getNavigationProperties()) {
|
||||
for (NavigationProperty navigationProperty : structuralType.getNavigationProperties()) {
|
||||
if (navigationProperty instanceof org.apache.olingo.client.api.edm.xml.NavigationProperty) {
|
||||
navigationProperties.put(navigationProperty.getName(), new EdmNavigationPropertyImpl(
|
||||
edm, structuredTypeName,
|
||||
(org.apache.olingo.client.api.edm.xml.NavigationProperty) navigationProperty));
|
||||
edm, structuredTypeName,
|
||||
(org.apache.olingo.client.api.edm.xml.NavigationProperty) navigationProperty));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,19 +82,23 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper {
|
|||
|
||||
@Override
|
||||
public boolean isOpenType() {
|
||||
return complexType instanceof org.apache.olingo.client.api.edm.xml.ComplexType
|
||||
? ((org.apache.olingo.client.api.edm.xml.ComplexType) complexType).isOpenType()
|
||||
: complexType instanceof EntityType
|
||||
? ((EntityType) complexType).isOpenType()
|
||||
: false;
|
||||
boolean isOpen = false;
|
||||
if(structuralType instanceof ComplexType){
|
||||
isOpen = ((ComplexType) structuralType).isOpenType();
|
||||
}else if(structuralType instanceof EntityType){
|
||||
isOpen = ((EntityType) structuralType).isOpenType();
|
||||
}
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbstract() {
|
||||
return complexType instanceof org.apache.olingo.client.api.edm.xml.ComplexType
|
||||
? ((org.apache.olingo.client.api.edm.xml.ComplexType) complexType).isAbstractType()
|
||||
: complexType instanceof EntityType
|
||||
? ((EntityType) complexType).isAbstractType()
|
||||
: false;
|
||||
boolean isAbstract = false;
|
||||
if(structuralType instanceof ComplexType){
|
||||
isAbstract = ((ComplexType) structuralType).isAbstractType();
|
||||
}else if(structuralType instanceof EntityType){
|
||||
isAbstract = ((EntityType) structuralType).isAbstractType();
|
||||
}
|
||||
return isAbstract;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public abstract class AbstractTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setClientInstances() {
|
||||
v4Client = ODataClientFactory.getV4();
|
||||
v4Client = ODataClientFactory.getClient();
|
||||
}
|
||||
|
||||
protected String getSuffix(final ODataFormat format) {
|
||||
|
|
|
@ -29,7 +29,7 @@ public class ODataClientTest {
|
|||
|
||||
@Test
|
||||
public void before() {
|
||||
ODataClient client = ODataClientFactory.getV4();
|
||||
ODataClient client = ODataClientFactory.getClient();
|
||||
assertNotNull(client);
|
||||
assertEquals(ODataServiceVersion.V40, client.getServiceVersion());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue