diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/ODataFlushException.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/ODataFlushException.java new file mode 100644 index 000000000..13edbd04e --- /dev/null +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/ODataFlushException.java @@ -0,0 +1,46 @@ +/* + * 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.api; + +import java.util.List; +import org.apache.olingo.commons.api.ODataRuntimeException; + +public class ODataFlushException extends ODataRuntimeException { + + private static final long serialVersionUID = 6077239115913182327L; + + private final int statusCode; + + private final List errors; + + public ODataFlushException(final int statusCode, final List errors) { + super("Errors found during flush()"); + this.statusCode = statusCode; + this.errors = errors; + } + + public int getStatusCode() { + return statusCode; + } + + public List getErrors() { + return errors; + } + +} diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/ODataResponseError.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/ODataResponseError.java new file mode 100644 index 000000000..ead17f514 --- /dev/null +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/ODataResponseError.java @@ -0,0 +1,50 @@ +/* + * 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.api; + +import org.apache.olingo.client.api.communication.request.ODataRequest; +import org.apache.olingo.commons.api.ODataRuntimeException; + +public class ODataResponseError { + + private final ODataRuntimeException exception; + + private final int index; + + private final ODataRequest request; + + public ODataResponseError(final ODataRuntimeException exception, final int index, final ODataRequest request) { + this.exception = exception; + this.index = index; + this.request = request; + } + + public ODataRuntimeException getException() { + return exception; + } + + public int getIndex() { + return index; + } + + public ODataRequest getRequest() { + return request; + } + +} diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/PersistenceManager.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/PersistenceManager.java index 9d702b034..2c7ae3eab 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/PersistenceManager.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/api/PersistenceManager.java @@ -19,9 +19,7 @@ package org.apache.olingo.ext.proxy.api; import java.io.Serializable; -import java.util.List; import java.util.concurrent.Future; -import org.apache.olingo.commons.api.ODataResponseError; /** * Interface for container operations. @@ -31,16 +29,15 @@ public interface PersistenceManager extends Serializable { /** * Flushes all pending changes to the OData service. * - * @return a list where n-th item is either null (if corresponding request went out successfully) or the exception - * bearing the error returned from the service. + * @throws ODataFlushException in case of errors */ - List flush(); + void flush(); /** * Asynchronously flushes all pending changes to the OData service. * - * @return a future handle for a list where n-th item is either null (if corresponding request went out successfully) - * or the exception bearing the error returned from the service. + * @return a future handle + * @throws ODataFlushException in case of errors */ - Future> flushAsync(); + Future flushAsync(); } diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java index 79350b0d6..917ea7b97 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractPersistenceManager.java @@ -38,7 +38,6 @@ import org.apache.olingo.client.api.communication.request.cud.v4.ODataReferenceA 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.core.uri.URIUtils; -import org.apache.olingo.commons.api.ODataResponseError; import org.apache.olingo.commons.api.domain.CommonODataEntity; import org.apache.olingo.commons.api.domain.ODataLink; import org.apache.olingo.commons.api.domain.ODataLinkType; @@ -51,6 +50,7 @@ import org.apache.olingo.ext.proxy.api.EdmStreamValue; import org.apache.olingo.ext.proxy.context.AttachedEntity; import org.apache.olingo.ext.proxy.context.AttachedEntityStatus; import org.apache.olingo.ext.proxy.context.EntityLinkDesc; +import org.apache.olingo.ext.proxy.utils.ClassUtils; import org.apache.olingo.ext.proxy.utils.CoreUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -71,19 +71,20 @@ abstract class AbstractPersistenceManager implements PersistenceManager { } @Override - public Future> flushAsync() { - return service.getClient().getConfiguration().getExecutor().submit(new Callable>() { + public Future flushAsync() { + return service.getClient().getConfiguration().getExecutor().submit(new Callable() { @Override - public List call() throws Exception { - return flush(); + public Void call() throws Exception { + flush(); + return ClassUtils.returnVoid(); } }); } - protected abstract List doFlush(PersistenceChanges changes, TransactionItems items); + protected abstract void doFlush(PersistenceChanges changes, TransactionItems items); @Override - public List flush() { + public void flush() { final PersistenceChanges changes = new PersistenceChanges(); final TransactionItems items = new TransactionItems(); @@ -110,13 +111,11 @@ abstract class AbstractPersistenceManager implements PersistenceManager { items.put(null, pos); } - final List result = new ArrayList(); if (!items.isEmpty()) { - result.addAll(doFlush(changes, items)); + doFlush(changes, items); } service.getContext().detachAll(); - return result; } private ODataLink buildNavigationLink(final String name, final URI uri, final ODataLinkType type) { @@ -263,7 +262,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager { final URI targetURI = currentStatus == AttachedEntityStatus.NEW ? URI.create("$" + startingPos) : URIUtils.getURI( - service.getClient().getServiceRoot(), handler.getEntity().getEditLink().toASCIIString()); + service.getClient().getServiceRoot(), handler.getEntity().getEditLink().toASCIIString()); queueUpdate(handler, targetURI, entity, changeset); pos++; items.put(handler, pos); @@ -275,8 +274,8 @@ abstract class AbstractPersistenceManager implements PersistenceManager { final URI targetURI = currentStatus == AttachedEntityStatus.NEW ? URI.create("$" + startingPos + "/$value") : URIUtils.getURI( - service.getClient().getServiceRoot(), - handler.getEntity().getEditLink().toASCIIString() + "/$value"); + service.getClient().getServiceRoot(), + handler.getEntity().getEditLink().toASCIIString() + "/$value"); queueUpdateMediaEntity(handler, targetURI, handler.getStreamChanges(), changeset); @@ -290,8 +289,8 @@ abstract class AbstractPersistenceManager implements PersistenceManager { for (Map.Entry streamedChanges : handler.getStreamedPropertyChanges().entrySet()) { final URI targetURI = currentStatus == AttachedEntityStatus.NEW ? URI.create("$" + startingPos) : URIUtils.getURI( - service.getClient().getServiceRoot(), - CoreUtils.getMediaEditLink(streamedChanges.getKey(), entity).toASCIIString()); + service.getClient().getServiceRoot(), + CoreUtils.getMediaEditLink(streamedChanges.getKey(), entity).toASCIIString()); queueUpdateMediaResource(handler, targetURI, streamedChanges.getValue(), changeset); @@ -459,10 +458,10 @@ abstract class AbstractPersistenceManager implements PersistenceManager { service.getClient().getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0 ? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) service.getClient()).getCUDRequestFactory(). getEntityUpdateRequest(handler.getEntityURI(), - org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes) + org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes) : ((org.apache.olingo.client.api.v4.EdmEnabledODataClient) service.getClient()).getCUDRequestFactory(). getEntityUpdateRequest(handler.getEntityURI(), - org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes); + org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes); req.setPrefer(new ODataPreferences(service.getClient().getServiceVersion()).returnContent()); @@ -509,10 +508,10 @@ abstract class AbstractPersistenceManager implements PersistenceManager { service.getClient().getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0 ? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) service.getClient()).getCUDRequestFactory(). getEntityUpdateRequest(uri, - org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes) + org.apache.olingo.client.api.communication.request.cud.v3.UpdateType.PATCH, changes) : ((org.apache.olingo.client.api.v4.EdmEnabledODataClient) service.getClient()).getCUDRequestFactory(). getEntityUpdateRequest(uri, - org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes); + org.apache.olingo.client.api.communication.request.cud.v4.UpdateType.PATCH, changes); req.setPrefer(new ODataPreferences(service.getClient().getServiceVersion()).returnContent()); diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java index 4339cba82..74f23c451 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/EntityContainerInvocationHandler.java @@ -92,7 +92,8 @@ public final class EntityContainerInvocationHandler extends AbstractInvocationHa if (isSelfMethod(method, args)) { return invokeSelfMethod(method, args); } else if ("flush".equals(method.getName()) && ArrayUtils.isEmpty(args)) { - return service.getPersistenceManager().flush(); + service.getPersistenceManager().flush(); + return ClassUtils.returnVoid(); } else if ("flushAsync".equals(method.getName()) && ArrayUtils.isEmpty(args)) { return service.getPersistenceManager().flushAsync(); } else if ("operations".equals(method.getName()) && ArrayUtils.isEmpty(args)) { diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/NonTransactionalPersistenceManagerImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/NonTransactionalPersistenceManagerImpl.java index 52cfde63e..04d1851cf 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/NonTransactionalPersistenceManagerImpl.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/NonTransactionalPersistenceManagerImpl.java @@ -19,9 +19,8 @@ package org.apache.olingo.ext.proxy.commons; import java.net.URI; -import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; -import java.util.List; import java.util.Map; import org.apache.olingo.client.api.communication.request.ODataBasicRequest; import org.apache.olingo.client.api.communication.request.ODataBatchableRequest; @@ -30,8 +29,10 @@ import org.apache.olingo.client.api.communication.request.ODataStreamedRequest; import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse; import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse; import org.apache.olingo.client.api.communication.response.ODataResponse; -import org.apache.olingo.commons.api.ODataResponseError; +import org.apache.olingo.commons.api.ODataRuntimeException; import org.apache.olingo.ext.proxy.AbstractService; +import org.apache.olingo.ext.proxy.api.ODataFlushException; +import org.apache.olingo.ext.proxy.api.ODataResponseError; /** * {@link org.apache.olingo.ext.proxy.api.PersistenceManager} implementation not using OData batch requests: any @@ -46,60 +47,50 @@ public class NonTransactionalPersistenceManagerImpl extends AbstractPersistenceM } @Override - protected List doFlush(final PersistenceChanges changes, final TransactionItems items) { - final List result = new ArrayList(); - + protected void doFlush(final PersistenceChanges changes, final TransactionItems items) { final Map responses = new HashMap(); - int virtualContentID = 0; + int index = 0; for (Map.Entry entry : changes.getChanges().entrySet()) { - virtualContentID++; + index++; + final ODataRequest request = ODataRequest.class.cast(entry.getKey()); + final ODataResponse response; try { - final ODataRequest req = ODataRequest.class.cast(entry.getKey()); - String uri = req.getURI().toASCIIString(); + String uri = request.getURI().toASCIIString(); if (uri.startsWith("$")) { int slashIndex = uri.indexOf('/'); final Integer toBeReplaced = Integer.valueOf(uri.substring(1, slashIndex < 0 ? uri.length() : slashIndex)); if (responses.containsKey(toBeReplaced)) { - uri = uri.replace("$" + toBeReplaced, responses.get(Integer.valueOf(toBeReplaced)).toASCIIString()); - req.setURI(URI.create(uri)); + uri = uri.replace("$" + toBeReplaced, responses.get(toBeReplaced).toASCIIString()); + request.setURI(URI.create(uri)); } } - final ODataResponse response; - if (ODataStreamedRequest.class.isAssignableFrom(req.getClass())) { - response = ((ODataStreamedRequest) req).payloadManager().getResponse(); + if (ODataStreamedRequest.class.isAssignableFrom(request.getClass())) { + response = ((ODataStreamedRequest) request).payloadManager().getResponse(); } else { - response = ((ODataBasicRequest) req).execute(); + response = ((ODataBasicRequest) request).execute(); } if (entry.getValue() != null && response instanceof ODataEntityCreateResponse && response.getStatusCode() == 201) { entry.getValue().setEntity(((ODataEntityCreateResponse) response).getBody()); - responses.put(virtualContentID, entry.getValue().getEntityURI()); + responses.put(index, entry.getValue().getEntityURI()); LOG.debug("Upgrade created object '{}'", entry.getValue()); } else if (entry.getValue() != null && response instanceof ODataEntityUpdateResponse && response.getStatusCode() == 200) { entry.getValue().setEntity(((ODataEntityUpdateResponse) response).getBody()); - responses.put(virtualContentID, entry.getValue().getEntityURI()); + responses.put(index, entry.getValue().getEntityURI()); LOG.debug("Upgrade updated object '{}'", entry.getValue()); } else { - responses.put(virtualContentID, null); + responses.put(index, null); } - - result.add(null); - } catch (ODataResponseError e) { + } catch (ODataRuntimeException e) { LOG.error("While performing {}", entry.getKey().getURI(), e); - if (service.getClient().getConfiguration().isContinueOnError()) { - result.add(e); - } else { - throw e; - } + throw new ODataFlushException(0, Collections.singletonList(new ODataResponseError(e, index, request))); } } - - return result; } } diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ResponseStatusLine.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ResponseStatusLine.java new file mode 100644 index 000000000..5afb32a18 --- /dev/null +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/ResponseStatusLine.java @@ -0,0 +1,48 @@ +/* + * 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 org.apache.http.ProtocolVersion; +import org.apache.http.StatusLine; +import org.apache.olingo.client.api.communication.response.ODataResponse; + +class ResponseStatusLine implements StatusLine { + + private final ODataResponse response; + + public ResponseStatusLine(final ODataResponse response) { + this.response = response; + } + + @Override + public ProtocolVersion getProtocolVersion() { + return null; + } + + @Override + public int getStatusCode() { + return response.getStatusCode(); + } + + @Override + public String getReasonPhrase() { + return response.getStatusMessage(); + } + +} diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/TransactionalPersistenceManagerImpl.java b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/TransactionalPersistenceManagerImpl.java index 107eb9de1..ae76f8a19 100644 --- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/TransactionalPersistenceManagerImpl.java +++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/TransactionalPersistenceManagerImpl.java @@ -22,8 +22,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; -import org.apache.http.ProtocolVersion; -import org.apache.http.StatusLine; +import org.apache.olingo.client.api.communication.ODataServerErrorException; import org.apache.olingo.client.api.communication.request.ODataBatchableRequest; import org.apache.olingo.client.api.communication.request.ODataRequest; import org.apache.olingo.client.api.communication.request.ODataStreamedRequest; @@ -37,8 +36,9 @@ import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResp import org.apache.olingo.client.api.communication.response.ODataResponse; import org.apache.olingo.client.core.communication.header.ODataErrorResponseChecker; import org.apache.olingo.client.core.communication.request.batch.ODataChangesetResponseItem; -import org.apache.olingo.commons.api.ODataResponseError; import org.apache.olingo.ext.proxy.AbstractService; +import org.apache.olingo.ext.proxy.api.ODataFlushException; +import org.apache.olingo.ext.proxy.api.ODataResponseError; /** * {@link org.apache.olingo.ext.proxy.api.PersistenceManager} implementation using OData batch requests to implement @@ -57,7 +57,7 @@ public class TransactionalPersistenceManagerImpl extends AbstractPersistenceMana * Transactional changes commit. */ @Override - protected List doFlush(final PersistenceChanges changes, final TransactionItems items) { + protected void doFlush(final PersistenceChanges changes, final TransactionItems items) { final CommonODataBatchRequest request = service.getClient().getBatchRequestFactory().getBatchRequest(service.getClient().getServiceRoot()); ((ODataRequest) request).setAccept( @@ -65,9 +65,11 @@ public class TransactionalPersistenceManagerImpl extends AbstractPersistenceMana final BatchManager batchManager = (BatchManager) ((ODataStreamedRequest) request).payloadManager(); + final List requests = new ArrayList(changes.getChanges().size()); final ODataChangeset changeset = batchManager.addChangeset(); for (Map.Entry entry : changes.getChanges().entrySet()) { changeset.addRequest(entry.getKey()); + requests.add(entry.getKey()); } final ODataBatchResponse response = batchManager.getResponse(); @@ -75,12 +77,12 @@ public class TransactionalPersistenceManagerImpl extends AbstractPersistenceMana // 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 in this respect. if (response.getStatusCode() != 202 && response.getStatusCode() != 200) { - throw new IllegalStateException("Operation failed"); + throw new ODataServerErrorException(new ResponseStatusLine(response)); } - final List result = new ArrayList(); - if (!items.isEmpty()) { + final List errors = new ArrayList(); + final Iterator batchResItor = response.getBody(); if (!batchResItor.hasNext()) { throw new IllegalStateException("Unexpected operation result"); @@ -93,38 +95,21 @@ public class TransactionalPersistenceManagerImpl extends AbstractPersistenceMana final ODataChangesetResponseItem chgres = (ODataChangesetResponseItem) item; - for (final Iterator itor = items.sortedValues().iterator(); itor.hasNext();) { + int index = 0; + for (final Iterator itor = items.sortedValues().iterator(); itor.hasNext(); index++) { final Integer changesetItemId = itor.next(); LOG.debug("Expected changeset item {}", changesetItemId); final ODataResponse res = chgres.next(); if (res.getStatusCode() >= 400) { - if (service.getClient().getConfiguration().isContinueOnError()) { - result.add(ODataErrorResponseChecker.checkResponse( - service.getClient(), - new StatusLine() { - @Override - public ProtocolVersion getProtocolVersion() { - return null; - } - - @Override - public int getStatusCode() { - return res.getStatusCode(); - } - - @Override - public String getReasonPhrase() { - return res.getStatusMessage(); - } - }, - res.getRawResponse(), - ((ODataRequest) request).getAccept())); - } else { - throw new IllegalStateException("Transaction failed: " + res.getStatusMessage()); + errors.add(new ODataResponseError(ODataErrorResponseChecker.checkResponse( + service.getClient(), + new ResponseStatusLine(res), + res.getRawResponse(), + ((ODataRequest) request).getAccept()), index, requests.get(index))); + if (!service.getClient().getConfiguration().isContinueOnError()) { + throw new ODataFlushException(response.getStatusCode(), errors); } - } else { - result.add(null); } final EntityInvocationHandler handler = items.get(changesetItemId); @@ -139,9 +124,11 @@ public class TransactionalPersistenceManagerImpl extends AbstractPersistenceMana } } } + + if (!errors.isEmpty()) { + throw new ODataFlushException(response.getStatusCode(), errors); + } } response.close(); - - return result; } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java index 554bde52f..67cb0a104 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/AsyncTestITCase.java @@ -23,11 +23,9 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import java.util.List; import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -import org.apache.olingo.commons.api.ODataResponseError; import org.junit.Test; //CHECKSTYLE:OFF (Maven checkstyle) @@ -63,7 +61,7 @@ public class AsyncTestITCase extends AbstractTestITCase { final Product product = container.getProduct().getByKey(-10); product.setDescription("AsyncTest#updateEntity " + random); - final Future> futureFlush = container.flushAsync(); + final Future futureFlush = container.flushAsync(); assertNotNull(futureFlush); while (!futureFlush.isDone()) { diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PropertyTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PropertyTestITCase.java index 0041103cc..481160b75 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PropertyTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v3/PropertyTestITCase.java @@ -18,13 +18,15 @@ */ package org.apache.olingo.fit.proxy.v3; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import org.apache.olingo.ext.proxy.api.ODataFlushException; import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Driver; import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Order; import org.junit.Test; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - /** * This is the unit test class to check actions overloading. */ @@ -47,9 +49,9 @@ public class PropertyTestITCase extends AbstractTestITCase { try { container.flush(); fail(); - } catch (IllegalStateException e) { - // ignore and detach all - service.getContext().detachAll(); + } catch (ODataFlushException e) { + assertNotNull(e); } + service.getContext().detachAll(); } } diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/APIBasicDesignTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/APIBasicDesignTestITCase.java index 734627597..da0110a48 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/APIBasicDesignTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/APIBasicDesignTestITCase.java @@ -30,12 +30,10 @@ import java.lang.reflect.Proxy; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.Calendar; -import java.util.List; import java.util.TimeZone; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.RandomStringUtils; import org.apache.olingo.client.api.v4.EdmEnabledODataClient; -import org.apache.olingo.commons.api.ODataResponseError; import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.ext.proxy.AbstractService; import org.apache.olingo.ext.proxy.api.EdmStreamValue; @@ -414,7 +412,7 @@ public class APIBasicDesignTestITCase extends AbstractTestITCase { // --------------------------------------- org.apache.olingo.fit.proxy.v3.staticservice.Service v3serv = org.apache.olingo.fit.proxy.v3.staticservice.Service.getV3( - "http://localhost:9080/stub/StaticService/V30/Static.svc"); + "http://localhost:9080/stub/StaticService/V30/Static.svc"); v3serv.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM); final DefaultContainer v3cont = v3serv.getEntityContainer(DefaultContainer.class); assertNotNull(v3cont); @@ -603,8 +601,7 @@ public class APIBasicDesignTestITCase extends AbstractTestITCase { getContainer().getOrders().add(order); getContainer().getOrders().delete(order); - List res = getContainer().flush(); - assertTrue(res.isEmpty() || res.iterator().next() == null); + getContainer().flush(); service.getContext().detachAll(); try { @@ -633,10 +630,10 @@ public class APIBasicDesignTestITCase extends AbstractTestITCase { public void issueOLINGO398() { AbstractCollectionInvocationHandler handler = AbstractCollectionInvocationHandler.class.cast( Proxy.getInvocationHandler(container.getCustomers().getByKey(1).getOrders(). - select("OrderID", "CustomerForOrder"). - expand("CustomerForOrder"). - top(1). - skip(2))); + select("OrderID", "CustomerForOrder"). + expand("CustomerForOrder"). + top(1). + skip(2))); assertEquals("http://localhost:9080/stub/StaticService/V40/Static.svc/Customers(1)/Orders?" + "%24select=OrderID%2CCustomerForOrder&%24expand=CustomerForOrder&%24top=1&%24skip=2", @@ -644,10 +641,10 @@ public class APIBasicDesignTestITCase extends AbstractTestITCase { handler = AbstractCollectionInvocationHandler.class.cast( Proxy.getInvocationHandler(container.getCustomers().getByKey(1).getOrders(). - select("OrderID", "CustomerForOrder"). - expand("CustomerForOrder"). - top(1). - skip(2))); + select("OrderID", "CustomerForOrder"). + expand("CustomerForOrder"). + top(1). + skip(2))); assertEquals("http://localhost:9080/stub/StaticService/V40/Static.svc/Customers(1)/Orders?%24" + "select=OrderID%2CCustomerForOrder&%24expand=CustomerForOrder&%24top=1&%24skip=2", diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AsyncTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AsyncTestITCase.java index 4dd7e9d12..feb958d2f 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AsyncTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/AsyncTestITCase.java @@ -22,12 +22,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import java.util.List; import org.apache.commons.lang3.RandomStringUtils; import org.junit.Test; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -import org.apache.olingo.commons.api.ODataResponseError; //CHECKSTYLE:OFF (Maven checkstyle) import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer; @@ -64,7 +62,7 @@ public class AsyncTestITCase extends AbstractTestITCase { final Person person = container.getPeople().getByKey(1); person.setFirstName(randomFirstName); - final Future> futureFlush = container.flushAsync(); + final Future futureFlush = container.flushAsync(); assertNotNull(futureFlush); while (!futureFlush.isDone()) { diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/ContextTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/ContextTestITCase.java index d0cc00fb7..bd3d2b8da 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/ContextTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/ContextTestITCase.java @@ -19,17 +19,15 @@ package org.apache.olingo.fit.proxy.v4; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; import java.sql.Timestamp; import java.util.Calendar; -import java.util.List; import java.util.TimeZone; -import org.apache.olingo.client.api.communication.ODataClientErrorException; import org.apache.olingo.client.api.v4.EdmEnabledODataClient; -import org.apache.olingo.commons.api.ODataResponseError; import org.apache.olingo.commons.api.format.ContentType; +import org.apache.olingo.ext.proxy.api.ODataFlushException; import org.apache.olingo.ext.proxy.api.PrimitiveCollection; import org.apache.olingo.fit.proxy.v4.staticservice.Service; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities; @@ -70,11 +68,16 @@ public class ContextTestITCase extends AbstractTestITCase { container.getPeople().add(employee); - final List result = container.flush(); - - assertEquals(2, result.size()); - assertTrue(result.get(0) instanceof ODataClientErrorException); - assertNull(result.get(1)); + try { + container.flush(); + fail(); + } catch (ODataFlushException e) { + assertEquals(1, e.getErrors().size()); + assertEquals(0, e.getErrors().get(0).getIndex()); + assertNotNull(e.getErrors().get(0).getRequest()); + } + + service.getContext().detachAll(); } @Test diff --git a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/PropertyTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/PropertyTestITCase.java index 0b0a37602..d0232b1af 100644 --- a/fit/src/test/java/org/apache/olingo/fit/proxy/v4/PropertyTestITCase.java +++ b/fit/src/test/java/org/apache/olingo/fit/proxy/v4/PropertyTestITCase.java @@ -18,9 +18,11 @@ */ package org.apache.olingo.fit.proxy.v4; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; +import org.apache.olingo.ext.proxy.api.ODataFlushException; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.Customer; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.StoredPI; import org.junit.Test; @@ -47,9 +49,9 @@ public class PropertyTestITCase extends AbstractTestITCase { try { container.flush(); fail(); - } catch (IllegalStateException e) { - // ignore and detach all - service.getContext().detachAll(); + } catch (ODataFlushException e) { + assertNotNull(e); } + service.getContext().detachAll(); } } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/ODataClientErrorException.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/ODataClientErrorException.java index 07a4fe60d..178241a3b 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/ODataClientErrorException.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/ODataClientErrorException.java @@ -20,7 +20,7 @@ package org.apache.olingo.client.api.communication; import org.apache.commons.lang3.StringUtils; import org.apache.http.StatusLine; -import org.apache.olingo.commons.api.ODataResponseError; +import org.apache.olingo.commons.api.ODataRuntimeException; import org.apache.olingo.commons.api.domain.ODataError; /** @@ -28,7 +28,7 @@ import org.apache.olingo.commons.api.domain.ODataError; * * @see ODataError */ -public class ODataClientErrorException extends ODataResponseError { +public class ODataClientErrorException extends ODataRuntimeException { private static final long serialVersionUID = -2551523202755268162L; diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/ODataServerErrorException.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/ODataServerErrorException.java index fdd47aa5c..a3d218586 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/ODataServerErrorException.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/ODataServerErrorException.java @@ -19,12 +19,12 @@ package org.apache.olingo.client.api.communication; import org.apache.http.StatusLine; -import org.apache.olingo.commons.api.ODataResponseError; +import org.apache.olingo.commons.api.ODataRuntimeException; /** * Represents a server error in OData. */ -public class ODataServerErrorException extends ODataResponseError { +public class ODataServerErrorException extends ODataRuntimeException { private static final long serialVersionUID = -6423014532618680135L; diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/HeaderName.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/HeaderName.java index a721ba9c3..ed768ec8e 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/HeaderName.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/HeaderName.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.client.api.communication.header; -import org.apache.olingo.commons.api.ODataResponseError; +import org.apache.olingo.commons.api.ODataRuntimeException; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; import java.util.Arrays; @@ -214,7 +214,7 @@ public enum HeaderName { final void isSupportedBy(final ODataServiceVersion serviceVersion) { if (!supportedVersions.contains(serviceVersion)) { - throw new ODataResponseError("Unsupported header " + this.toString()); + throw new ODataRuntimeException("Unsupported header " + this.toString()); } } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataPreferences.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataPreferences.java index 4aa8d0ed3..94ea8ceab 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataPreferences.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/header/ODataPreferences.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.client.api.communication.header; -import org.apache.olingo.commons.api.ODataResponseError; +import org.apache.olingo.commons.api.ODataRuntimeException; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; import java.util.Arrays; @@ -411,7 +411,7 @@ public class ODataPreferences { final PreferenceNames isSupportedBy(final ODataServiceVersion serviceVersion) { if (!supportedVersions.contains(serviceVersion)) { - throw new ODataResponseError("Unsupported header " + this.toString()); + throw new ODataRuntimeException("Unsupported header " + this.toString()); } return this; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java index 209813ac4..967a66649 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java @@ -23,7 +23,7 @@ import org.apache.http.StatusLine; import org.apache.olingo.client.api.CommonODataClient; import org.apache.olingo.client.api.communication.ODataClientErrorException; import org.apache.olingo.client.api.communication.ODataServerErrorException; -import org.apache.olingo.commons.api.ODataResponseError; +import org.apache.olingo.commons.api.ODataRuntimeException; import org.apache.olingo.commons.api.domain.ODataError; import org.apache.olingo.commons.api.format.ODataFormat; import org.apache.olingo.commons.api.serialization.ODataDeserializerException; @@ -41,11 +41,11 @@ public final class ODataErrorResponseChecker { return error; } - public static ODataResponseError checkResponse( + public static ODataRuntimeException checkResponse( final CommonODataClient odataClient, final StatusLine statusLine, final InputStream entity, final String accept) { - ODataResponseError result = null; + ODataRuntimeException result = null; if (entity == null) { result = new ODataClientErrorException(statusLine); 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 d9b436288..0a8e109c0 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 @@ -42,7 +42,7 @@ import java.io.InputStream; import java.lang.reflect.Constructor; import java.net.URI; import java.util.Collection; -import org.apache.olingo.commons.api.ODataResponseError; +import org.apache.olingo.commons.api.ODataRuntimeException; /** * Abstract representation of an OData request. Get instance by using factories. @@ -322,7 +322,7 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD try { checkResponse(odataClient, response, getAccept()); - } catch (ODataResponseError e) { + } catch (ODataRuntimeException e) { odataClient.getConfiguration().getHttpClientFactory().close(httpClient); throw e; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractRequest.java index 8c6ddf8b9..d920a98d5 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractRequest.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/AbstractRequest.java @@ -20,7 +20,7 @@ import org.apache.http.client.methods.HttpUriRequest; import org.apache.olingo.client.api.CommonEdmEnabledODataClient; import org.apache.olingo.client.api.CommonODataClient; import org.apache.olingo.client.core.communication.header.ODataErrorResponseChecker; -import org.apache.olingo.commons.api.ODataResponseError; +import org.apache.olingo.commons.api.ODataRuntimeException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; @@ -50,7 +50,7 @@ public abstract class AbstractRequest { if (response.getStatusLine().getStatusCode() >= 400) { try { - final ODataResponseError exception = ODataErrorResponseChecker.checkResponse( + final ODataRuntimeException exception = ODataErrorResponseChecker.checkResponse( odataClient, response.getStatusLine(), response.getEntity() == null ? null : response.getEntity().getContent(), @@ -59,7 +59,7 @@ public abstract class AbstractRequest { throw exception; } } catch (IOException e) { - throw new ODataResponseError( + throw new ODataRuntimeException( "Received '" + response.getStatusLine() + "' but could not extract error body", e); } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java index 04a0c6b6b..a748980cc 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/response/AbstractODataResponse.java @@ -46,7 +46,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.Map; import java.util.TreeMap; -import org.apache.olingo.commons.api.ODataResponseError; +import org.apache.olingo.commons.api.ODataRuntimeException; /** * Abstract representation of an OData response. @@ -183,7 +183,7 @@ public abstract class AbstractODataResponse implements ODataResponse { this.payload = res.getEntity() == null ? null : res.getEntity().getContent(); } catch (Exception e) { LOG.error("Error retrieving payload", e); - throw new ODataResponseError(e); + throw new ODataRuntimeException(e); } for (Header header : res.getAllHeaders()) { diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataResponseError.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataRuntimeException.java similarity index 80% rename from lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataResponseError.java rename to lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataRuntimeException.java index 59bed1e6d..0c8374aa6 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataResponseError.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/ODataRuntimeException.java @@ -18,19 +18,19 @@ */ package org.apache.olingo.commons.api; -public class ODataResponseError extends RuntimeException { +public class ODataRuntimeException extends RuntimeException { private static final long serialVersionUID = 5492375572049190883L; - public ODataResponseError(final String msg) { + public ODataRuntimeException(final String msg) { super(msg); } - public ODataResponseError(final String msg, final Exception cause) { + public ODataRuntimeException(final String msg, final Exception cause) { super(msg, cause); } - public ODataResponseError(final Exception cause) { + public ODataRuntimeException(final Exception cause) { super(cause); } diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java index 41e0083b6..d1c669820 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/OData.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.server.api; -import org.apache.olingo.commons.api.ODataResponseError; +import org.apache.olingo.commons.api.ODataRuntimeException; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.format.ODataFormat; import org.apache.olingo.server.api.edm.provider.EdmProvider; @@ -47,7 +47,7 @@ public abstract class OData { return (OData) object; } catch (final Exception e) { - throw new ODataResponseError(e); + throw new ODataRuntimeException(e); } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java index 3cf1efc0e..3b7a7a289 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.server.core; -import org.apache.olingo.commons.api.ODataResponseError; +import org.apache.olingo.commons.api.ODataRuntimeException; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.http.HttpHeader; import org.apache.olingo.commons.api.http.HttpMethod; @@ -109,13 +109,13 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler { } } catch (IOException e) { LOG.error(e.getMessage(), e); - throw new ODataResponseError(e); + throw new ODataRuntimeException(e); } finally { if (input != null) { try { input.close(); } catch (IOException e) { - throw new ODataResponseError(e); + throw new ODataRuntimeException(e); } } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java index 8145314cd..2b4b266e3 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriInfoImpl.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.server.core.uri; -import org.apache.olingo.commons.api.ODataResponseError; +import org.apache.olingo.commons.api.ODataRuntimeException; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.server.api.uri.UriInfo; import org.apache.olingo.server.api.uri.UriInfoAll; @@ -266,7 +266,7 @@ public class UriInfoImpl implements UriInfo { } else if (systemOption.getKind() == SystemQueryOptionKind.LEVELS) { systemQueryOptions.put(SystemQueryOptionKind.LEVELS, systemOption); } else { - throw new ODataResponseError("Unsupported System Query Option: " + systemOption.getName()); + throw new ODataRuntimeException("Unsupported System Query Option: " + systemOption.getName()); } return this; diff --git a/samples/client/src/main/java/org/apache/olingo/samples/client/core/http/SocketFactoryHttpClientFactory.java b/samples/client/src/main/java/org/apache/olingo/samples/client/core/http/SocketFactoryHttpClientFactory.java index 0207ce093..1d4100520 100644 --- a/samples/client/src/main/java/org/apache/olingo/samples/client/core/http/SocketFactoryHttpClientFactory.java +++ b/samples/client/src/main/java/org/apache/olingo/samples/client/core/http/SocketFactoryHttpClientFactory.java @@ -30,7 +30,7 @@ import org.apache.http.impl.conn.BasicClientConnectionManager; import org.apache.http.params.CoreProtocolPNames; import org.apache.olingo.client.api.http.HttpMethod; import org.apache.olingo.client.core.http.AbstractHttpClientFactory; -import org.apache.olingo.commons.api.ODataResponseError; +import org.apache.olingo.commons.api.ODataRuntimeException; /** * Shows how to customize the way how the underlying network socket are managed by the HTTP component; the specific @@ -61,7 +61,7 @@ public class SocketFactoryHttpClientFactory extends AbstractHttpClientFactory { new SSLSocketFactory(acceptTrustStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); registry.register(new Scheme(uri.getScheme(), uri.getPort(), ssf)); } catch (Exception e) { - throw new ODataResponseError(e); + throw new ODataRuntimeException(e); } final DefaultHttpClient httpClient = new DefaultHttpClient(new BasicClientConnectionManager(registry));