Skip to content
This repository was archived by the owner on Jun 2, 2026. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d29017d
update httpclient version.
indraninm-sap Dec 18, 2025
c0a941b
version update
indraninm-sap Dec 18, 2025
0179b32
Apache http client upgrade
indraninm-sap Dec 22, 2025
986c2b4
Upgrade http client version
indraninm-sap Dec 24, 2025
ff771c3
update httpclient version.
indraninm-sap Jan 1, 2026
7cba55e
update httpclient version.
indraninm-sap Jan 1, 2026
a1aee7d
update httpclient version.
indraninm-sap Jan 1, 2026
eb4872d
update httpclient version
indraninm-sap Jan 5, 2026
e685f6b
update httpclient version.
indraninm-sap Jan 5, 2026
42dbcc9
update httpclient version.
indraninm-sap Jan 5, 2026
e24637b
update httpclient version
indraninm-sap Jan 5, 2026
ea04944
update httpclient version.
indraninm-sap Jan 5, 2026
a04a90d
update httpclient version.
indraninm-sap Jan 5, 2026
df1c164
update httpclient version.
indraninm-sap Jan 5, 2026
12d6f58
update httpclient version
indraninm-sap Jan 5, 2026
fca7671
update httpclient version
indraninm-sap Jan 5, 2026
6cdfa26
update httpclient version
indraninm-sap Jan 5, 2026
edd1e10
update httpclient version
indraninm-sap Jan 5, 2026
236b0ec
update httpclient version
indraninm-sap Jan 5, 2026
2fccff7
update httpclient version
indraninm-sap Jan 7, 2026
b53f6e0
update httpclient version
indraninm-sap Jan 7, 2026
9ab4936
update httpclient version
indraninm-sap Jan 7, 2026
71c33a3
update httpclient version
indraninm-sap Jan 7, 2026
433f5e9
update httpclient version
indraninm-sap Jan 8, 2026
d66ca86
update httpclient version
indraninm-sap Jan 8, 2026
49dad08
update httpclient version
indraninm-sap Jan 8, 2026
4082dc0
update httpclient version
indraninm-sap Jan 8, 2026
e21455a
update httpclient version
indraninm-sap Jan 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,28 @@
package org.apache.olingo.client.core.android.http;

import java.net.URI;

import org.apache.http.client.HttpClient;
import java.io.IOException;
import org.apache.hc.client5.http.classic.HttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.olingo.client.core.http.AbstractHttpClientFactory;
import org.apache.olingo.commons.api.http.HttpMethod;

import android.net.http.AndroidHttpClient;

/**
* Android-specific HTTP client factory. On non-Android platforms this factory is not usable;
* create() will throw UnsupportedOperationException to make this explicit at runtime.
*/
public class AndroidHttpClientFactory extends AbstractHttpClientFactory {

@Override
public AndroidHttpClient create(final HttpMethod method, final URI uri) {
return AndroidHttpClient.newInstance(USER_AGENT);
}
@Override
public HttpClient create(final HttpMethod method, final URI uri) {
// This factory is only meant for Android runtime where a compatible HTTP client exists.
throw new UnsupportedOperationException("AndroidHttpClientFactory is only available on Android runtime");
}

@Override
public void close(final HttpClient httpClient) {
if (httpClient instanceof AndroidHttpClient) {
((AndroidHttpClient) httpClient).close();
}
@Override
public void close(final CloseableHttpClient httpClient) throws IOException {
if (httpClient != null) {
httpClient.close();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,56 +100,61 @@ public Triple<List<T>, URI, List<ClientAnnotation>> fetchPartial(
final URI next;
final List<ClientAnnotation> anns = new ArrayList<ClientAnnotation>();

if (isSingleton) {
final ODataRetrieveResponse<ClientSingleton> res =
((ODataClient) getClient()).getRetrieveRequestFactory().getSingletonRequest(uri).execute();

entities.add(res.getBody());
next = null;
} else {
final ODataEntitySetRequest<ClientEntitySet> req =
getClient().getRetrieveRequestFactory().getEntitySetRequest(uri);
req.setPrefer(getClient().newPreferences().includeAnnotations("*"));

final ODataRetrieveResponse<ClientEntitySet> res = req.execute();

final ClientEntitySet entitySet = res.getBody();
entities.addAll(entitySet.getEntities());
next = entitySet.getNext();
anns.addAll(entitySet.getAnnotations());
}

final List<T> res = new ArrayList<T>(entities.size());

for (ClientEntity entity : entities) {
Class<?> actualRef = null;
if (entity.getTypeName() != null) {
actualRef = service.getEntityTypeClass(entity.getTypeName().toString());
try {
if (isSingleton) {
final ODataRetrieveResponse<ClientSingleton> res =
((ODataClient) getClient()).getRetrieveRequestFactory().getSingletonRequest(uri).execute();

entities.add(res.getBody());
next = null;
} else {
final ODataEntitySetRequest<ClientEntitySet> req =
getClient().getRetrieveRequestFactory().getEntitySetRequest(uri);
req.setPrefer(getClient().newPreferences().includeAnnotations("*"));

final ODataRetrieveResponse<ClientEntitySet> res = req.execute();

final ClientEntitySet entitySet = res.getBody();
entities.addAll(entitySet.getEntities());
next = entitySet.getNext();
anns.addAll(entitySet.getAnnotations());
}
if (actualRef == null) {
actualRef = typeRef;

final List<T> res = new ArrayList<T>(entities.size());

for (ClientEntity entity : entities) {
Class<?> actualRef = null;
if (entity.getTypeName() != null) {
actualRef = service.getEntityTypeClass(entity.getTypeName().toString());
}
if (actualRef == null) {
actualRef = typeRef;
}

final EntityInvocationHandler handler =
this instanceof EntitySetInvocationHandler
? EntityInvocationHandler.getInstance(
entity,
EntitySetInvocationHandler.class.cast(this),
actualRef)
: EntityInvocationHandler.getInstance(
entity,
targetEntitySetURI,
actualRef,
service);

final EntityInvocationHandler handlerInTheContext = getContext().entityContext().getEntity(handler.getUUID());

res.add((T) Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] { actualRef },
handlerInTheContext == null ? handler : handlerInTheContext));
}

final EntityInvocationHandler handler =
this instanceof EntitySetInvocationHandler
? EntityInvocationHandler.getInstance(
entity,
EntitySetInvocationHandler.class.cast(this),
actualRef)
: EntityInvocationHandler.getInstance(
entity,
targetEntitySetURI,
actualRef,
service);

final EntityInvocationHandler handlerInTheContext = getContext().entityContext().getEntity(handler.getUUID());

res.add((T) Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] { actualRef },
handlerInTheContext == null ? handler : handlerInTheContext));
return new ImmutableTriple<List<T>, URI, List<ClientAnnotation>>(res, next, anns);
} catch (Exception e) {
LOG.warn("Error fetching entity set partial '" + uri + "'", e);
throw new IllegalArgumentException("Error fetching entity set", e);
}

return new ImmutableTriple<List<T>, URI, List<ClientAnnotation>>(res, next, anns);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,30 +97,41 @@ public Object invoke(final Object proxy, final Method method, final Object[] arg
@SuppressWarnings("unchecked")
@Override
public Triple<List<T>, URI, List<ClientAnnotation>> fetchPartial(final URI uri, final Class<T> typeRef) {
final ODataPropertyRequest<ClientProperty> req =
getClient().getRetrieveRequestFactory().getPropertyRequest(uri);
req.setPrefer(getClient().newPreferences().includeAnnotations("*"));

final ODataRetrieveResponse<ClientProperty> res = req.execute();

final List<T> resItems = new ArrayList<T>();

final ClientProperty property = res.getBody();
if (property != null && property.hasCollectionValue()) {
for (ClientValue item : (ClientCollectionValue<ClientValue>) property.getValue()) {
Class<?> actualRef = null;
if (StringUtils.isNotBlank(item.getTypeName())) {
actualRef = service.getComplexTypeClass(item.getTypeName());
}
if (actualRef == null) {
actualRef = typeRef;
try {
final ODataPropertyRequest<ClientProperty> req =
getClient().getRetrieveRequestFactory().getPropertyRequest(uri);
req.setPrefer(getClient().newPreferences().includeAnnotations("*"));

final ODataRetrieveResponse<ClientProperty> res = req.execute();

final List<T> resItems = new ArrayList<T>();

final ClientProperty property = res.getBody();
if (property != null && property.hasCollectionValue()) {
for (ClientValue item : (ClientCollectionValue<ClientValue>) property.getValue()) {
Class<?> actualRef = null;
if (StringUtils.isNotBlank(item.getTypeName())) {
actualRef = service.getComplexTypeClass(item.getTypeName());
}
if (actualRef == null) {
actualRef = typeRef;
}

resItems.add((T) getComplex(property.getName(), item, actualRef, null, null, true));
}

resItems.add((T) getComplex(property.getName(), item, actualRef, null, null, true));
}
}

return new ImmutableTriple<List<T>, URI, List<ClientAnnotation>>(
resItems, null, Collections.<ClientAnnotation> emptyList());
return new ImmutableTriple<List<T>, URI, List<ClientAnnotation>>(
resItems, null, Collections.<ClientAnnotation> emptyList());
} catch (java.net.URISyntaxException e) {
LOG.warn("Invalid URI for fetching complex collection '" + uri + "'", e);
throw new IllegalArgumentException("Invalid URI while fetching complex collection", e);
} catch (java.io.IOException e) {
LOG.warn("I/O error while fetching complex collection '" + uri + "'", e);
throw new IllegalArgumentException("I/O error while fetching complex collection", e);
} catch (Exception e) {
LOG.warn("Error fetching complex collection '" + uri + "'", e);
throw new IllegalArgumentException("Error fetching complex collection", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,21 @@ public Object invoke(final Object proxy, final Method method, final Object[] arg

public void load() {
if (this.uri != null) {
final ODataRetrieveResponse<InputStream> res =
getClient().getRetrieveRequestFactory().getMediaRequest(this.uri).execute();
contentType = res.getContentType();
stream = res.getBody();
try {
final ODataRetrieveResponse<InputStream> res =
getClient().getRetrieveRequestFactory().getMediaRequest(this.uri).execute();
contentType = res.getContentType();
stream = res.getBody();
} catch (java.net.URISyntaxException e) {
LOG.warn("Invalid media URI '" + uri + "'", e);
throw new IllegalArgumentException("Invalid media URI: " + uri, e);
} catch (java.io.IOException e) {
LOG.warn("I/O error while retrieving media from '" + uri + "'", e);
throw new IllegalArgumentException("I/O error while retrieving media: " + uri, e);
} catch (Exception e) {
LOG.warn("Error while retrieving media from '" + uri + "'", e);
throw new IllegalArgumentException("Error retrieving media: " + uri, e);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,29 +321,37 @@ public EdmStreamValue getStreamChanges() {
}

public EdmStreamValue loadStream() {
final URI contentSource = getEntity().getMediaContentSource() == null
? getClient().newURIBuilder(baseURI.toASCIIString()).appendValueSegment().build()
: getEntity().getMediaContentSource();
try {
final URI contentSource = getEntity().getMediaContentSource() == null
? getClient().newURIBuilder(baseURI.toASCIIString()).appendValueSegment().build()
: getEntity().getMediaContentSource();

if (this.stream == null
&& typeRef.getAnnotation(EntityType.class).hasStream()
&& contentSource != null) {

if (this.stream == null
&& typeRef.getAnnotation(EntityType.class).hasStream()
&& contentSource != null) {
final ODataMediaRequest retrieveReq =
getClient().getRetrieveRequestFactory().getMediaEntityRequest(contentSource);

final ODataMediaRequest retrieveReq =
getClient().getRetrieveRequestFactory().getMediaEntityRequest(contentSource);
if (StringUtils.isNotBlank(getEntity().getMediaContentType())) {
retrieveReq.setFormat(ContentType.parse(getEntity().getMediaContentType()));
}

if (StringUtils.isNotBlank(getEntity().getMediaContentType())) {
retrieveReq.setFormat(ContentType.parse(getEntity().getMediaContentType()));
final ODataRetrieveResponse<InputStream> res = retrieveReq.execute();
this.stream = EdmStreamValue.class.cast(Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] { EdmStreamValue.class },
new EdmStreamValueHandler(res.getContentType(), res.getBody(), contentSource, service)));
}

final ODataRetrieveResponse<InputStream> res = retrieveReq.execute();
this.stream = EdmStreamValue.class.cast(Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] { EdmStreamValue.class },
new EdmStreamValueHandler(res.getContentType(), res.getBody(), contentSource, service)));
return this.stream;
} catch (java.net.URISyntaxException e) {
LOG.warn("Invalid media content source URI for entity '" + uuid + "'", e);
throw new IllegalArgumentException("Invalid media content source URI for " + typeRef.getSimpleName(), e);
} catch (Exception e) {
LOG.warn("Error retrieving media stream for entity '" + uuid + "'", e);
throw new IllegalArgumentException("Error retrieving media stream for " + typeRef.getSimpleName(), e);
}

return this.stream;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,21 @@ public Object invoke(final Object proxy, final Method method, final Object[] arg

@Override
public Long count() {
final ODataValueRequest req = getClient().getRetrieveRequestFactory().
getValueRequest(getClient().newURIBuilder(this.uri.build().toASCIIString()).count().build());
req.setFormat(ContentType.TEXT_PLAIN);
return Long.valueOf(req.execute().getBody().asPrimitive().toString());
try {
final ODataValueRequest req = getClient().getRetrieveRequestFactory().
getValueRequest(getClient().newURIBuilder(this.uri.build().toASCIIString()).count().build());
req.setFormat(ContentType.TEXT_PLAIN);
return Long.valueOf(req.execute().getBody().asPrimitive().toString());
} catch (java.net.URISyntaxException e) {
LOG.warn("Invalid URI building for count on entity set '" + uri + "'", e);
throw new IllegalArgumentException("Invalid URI for count on " + this.uri, e);
} catch (java.io.IOException e) {
LOG.warn("I/O error while executing count request for entity set '" + uri + "'", e);
throw new IllegalArgumentException("I/O error while executing count for " + this.uri, e);
} catch (Exception e) {
LOG.warn("Error executing count for entity set '" + uri + "'", e);
throw new IllegalArgumentException("Error executing count for " + this.uri, e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ protected void doFlush(final PersistenceChanges changes, final TransactionItems
LOG.error("While performing {}", entry.getKey().getURI(), e);

throw new ODataFlushException(0, Collections.singletonList(new ODataResponseError(e, index, request)));
} catch (Exception e) {
// handle checked exceptions (e.g., URISyntaxException, IOException) by wrapping
LOG.error("While performing {}", entry.getKey().getURI(), e);
throw new ODataFlushException(0, Collections.singletonList(
new ODataResponseError(new org.apache.olingo.commons.api.ex.ODataRuntimeException(e), index, request)));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public Object invoke(final Object proxy, final Method method, final Object[] arg
@Override
@SuppressWarnings("unchecked")
public Triple<List<T>, URI, List<ClientAnnotation>> fetchPartial(final URI uri, final Class<T> typeRef) {
final ODataPropertyRequest<ClientProperty> req =
try {
final ODataPropertyRequest<ClientProperty> req =
getClient().getRetrieveRequestFactory().getPropertyRequest(uri);
req.setPrefer(getClient().newPreferences().includeAnnotations("*"));

Expand All @@ -107,14 +108,23 @@ public Triple<List<T>, URI, List<ClientAnnotation>> fetchPartial(final URI uri,
}
}

return new ImmutableTriple<List<T>, URI, List<ClientAnnotation>>(
resItems, null, Collections.<ClientAnnotation>emptyList());
return new ImmutableTriple<List<T>, URI, List<ClientAnnotation>>(
resItems, null, Collections.<ClientAnnotation>emptyList());
} catch (Exception e) {
LOG.warn("Error fetching primitive collection '" + uri + "'", e);
throw new IllegalArgumentException("Error fetching primitive collection", e);
}
}

public void delete() {
if (baseURI != null) {
getContext().entityContext().addFurtherDeletes(
getClient().newURIBuilder(baseURI.toASCIIString()).appendValueSegment().build());
try {
getContext().entityContext().addFurtherDeletes(
getClient().newURIBuilder(baseURI.toASCIIString()).appendValueSegment().build());
} catch (Exception e) {
LOG.warn("Error scheduling delete for primitive collection '" + baseURI + "'", e);
throw new IllegalArgumentException("Error deleting primitive collection", e);
}
}
}

Expand Down
Loading