[OLINGO-399] ODataRuntimeException -> ODataResponseError

This commit is contained in:
Francesco Chicchiriccò 2014-08-11 11:13:30 +02:00
parent bc1d13929a
commit 655dbb8c97
21 changed files with 56 additions and 56 deletions

View File

@ -21,7 +21,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.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
/**
* Interface for container operations.
@ -34,7 +34,7 @@ public interface PersistenceManager extends Serializable {
* @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.
*/
List<ODataRuntimeException> flush();
List<ODataResponseError> flush();
/**
* Asynchronously flushes all pending changes to the OData service.
@ -42,5 +42,5 @@ public interface PersistenceManager extends Serializable {
* @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.
*/
Future<List<ODataRuntimeException>> flushAsync();
Future<List<ODataResponseError>> flushAsync();
}

View File

@ -38,7 +38,7 @@ 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.ODataRuntimeException;
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;
@ -71,19 +71,19 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
}
@Override
public Future<List<ODataRuntimeException>> flushAsync() {
return service.getClient().getConfiguration().getExecutor().submit(new Callable<List<ODataRuntimeException>>() {
public Future<List<ODataResponseError>> flushAsync() {
return service.getClient().getConfiguration().getExecutor().submit(new Callable<List<ODataResponseError>>() {
@Override
public List<ODataRuntimeException> call() throws Exception {
public List<ODataResponseError> call() throws Exception {
return flush();
}
});
}
protected abstract List<ODataRuntimeException> doFlush(PersistenceChanges changes, TransactionItems items);
protected abstract List<ODataResponseError> doFlush(PersistenceChanges changes, TransactionItems items);
@Override
public List<ODataRuntimeException> flush() {
public List<ODataResponseError> flush() {
final PersistenceChanges changes = new PersistenceChanges();
final TransactionItems items = new TransactionItems();
@ -110,7 +110,7 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
items.put(null, pos);
}
final List<ODataRuntimeException> result = new ArrayList<ODataRuntimeException>();
final List<ODataResponseError> result = new ArrayList<ODataResponseError>();
if (!items.isEmpty()) {
result.addAll(doFlush(changes, items));
}

View File

@ -30,7 +30,7 @@ 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.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
import org.apache.olingo.ext.proxy.AbstractService;
/**
@ -46,8 +46,8 @@ public class NonTransactionalPersistenceManagerImpl extends AbstractPersistenceM
}
@Override
protected List<ODataRuntimeException> doFlush(final PersistenceChanges changes, final TransactionItems items) {
final List<ODataRuntimeException> result = new ArrayList<ODataRuntimeException>();
protected List<ODataResponseError> doFlush(final PersistenceChanges changes, final TransactionItems items) {
final List<ODataResponseError> result = new ArrayList<ODataResponseError>();
final Map<Integer, URI> responses = new HashMap<Integer, URI>();
int virtualContentID = 0;
@ -89,7 +89,7 @@ public class NonTransactionalPersistenceManagerImpl extends AbstractPersistenceM
}
result.add(null);
} catch (ODataRuntimeException e) {
} catch (ODataResponseError e) {
LOG.error("While performing {}", entry.getKey().getURI(), e);
if (service.getClient().getConfiguration().isContinueOnError()) {

View File

@ -37,7 +37,7 @@ 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.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
import org.apache.olingo.ext.proxy.AbstractService;
/**
@ -57,7 +57,7 @@ public class TransactionalPersistenceManagerImpl extends AbstractPersistenceMana
* Transactional changes commit.
*/
@Override
protected List<ODataRuntimeException> doFlush(final PersistenceChanges changes, final TransactionItems items) {
protected List<ODataResponseError> doFlush(final PersistenceChanges changes, final TransactionItems items) {
final CommonODataBatchRequest request =
service.getClient().getBatchRequestFactory().getBatchRequest(service.getClient().getServiceRoot());
((ODataRequest) request).setAccept(
@ -78,7 +78,7 @@ public class TransactionalPersistenceManagerImpl extends AbstractPersistenceMana
throw new IllegalStateException("Operation failed");
}
final List<ODataRuntimeException> result = new ArrayList<ODataRuntimeException>();
final List<ODataResponseError> result = new ArrayList<ODataResponseError>();
if (!items.isEmpty()) {
final Iterator<ODataBatchResponseItem> batchResItor = response.getBody();

View File

@ -27,7 +27,7 @@ import java.util.List;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
import org.junit.Test;
//CHECKSTYLE:OFF (Maven checkstyle)
@ -63,7 +63,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
final Product product = container.getProduct().getByKey(-10);
product.setDescription("AsyncTest#updateEntity " + random);
final Future<List<ODataRuntimeException>> futureFlush = container.flushAsync();
final Future<List<ODataResponseError>> futureFlush = container.flushAsync();
assertNotNull(futureFlush);
while (!futureFlush.isDone()) {

View File

@ -34,7 +34,7 @@ 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.ODataRuntimeException;
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;
@ -601,7 +601,7 @@ public class APIBasicDesignTestITCase extends AbstractTestITCase {
getContainer().getOrders().add(order);
getContainer().getOrders().delete(order);
List<ODataRuntimeException> res = getContainer().flush();
List<ODataResponseError> res = getContainer().flush();
assertTrue(res.isEmpty() || res.iterator().next() == null);
service.getContext().detachAll();

View File

@ -27,7 +27,7 @@ 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.ODataRuntimeException;
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 +64,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
final Person person = container.getPeople().getByKey(1);
person.setFirstName(randomFirstName);
final Future<List<ODataRuntimeException>> futureFlush = container.flushAsync();
final Future<List<ODataResponseError>> futureFlush = container.flushAsync();
assertNotNull(futureFlush);
while (!futureFlush.isDone()) {

View File

@ -28,7 +28,7 @@ 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.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.ext.proxy.api.PrimitiveCollection;
import org.apache.olingo.fit.proxy.v4.staticservice.Service;
@ -70,7 +70,7 @@ public class ContextTestITCase extends AbstractTestITCase {
container.getPeople().add(employee);
final List<ODataRuntimeException> result = container.flush();
final List<ODataResponseError> result = container.flush();
assertEquals(2, result.size());
assertTrue(result.get(0) instanceof ODataClientErrorException);

View File

@ -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.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
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 ODataRuntimeException {
public class ODataClientErrorException extends ODataResponseError {
private static final long serialVersionUID = -2551523202755268162L;

View File

@ -19,12 +19,12 @@
package org.apache.olingo.client.api.communication;
import org.apache.http.StatusLine;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
/**
* Represents a server error in OData.
*/
public class ODataServerErrorException extends ODataRuntimeException {
public class ODataServerErrorException extends ODataResponseError {
private static final long serialVersionUID = -6423014532618680135L;

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.api.communication.header;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
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 ODataRuntimeException("Unsupported header " + this.toString());
throw new ODataResponseError("Unsupported header " + this.toString());
}
}

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.api.communication.header;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
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 ODataRuntimeException("Unsupported header " + this.toString());
throw new ODataResponseError("Unsupported header " + this.toString());
}
return this;

View File

@ -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.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
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 ODataRuntimeException checkResponse(
public static ODataResponseError checkResponse(
final CommonODataClient<?> odataClient, final StatusLine statusLine, final InputStream entity,
final String accept) {
ODataRuntimeException result = null;
ODataResponseError result = null;
if (entity == null) {
result = new ODataClientErrorException(statusLine);

View File

@ -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.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
/**
* 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 (ODataRuntimeException e) {
} catch (ODataResponseError e) {
odataClient.getConfiguration().getHttpClientFactory().close(httpClient);
throw e;
}

View File

@ -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.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
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 ODataRuntimeException exception = ODataErrorResponseChecker.checkResponse(
final ODataResponseError 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 ODataRuntimeException(
throw new ODataResponseError(
"Received '" + response.getStatusLine() + "' but could not extract error body", e);
}
}

View File

@ -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.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
/**
* 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 ODataRuntimeException(e);
throw new ODataResponseError(e);
}
for (Header header : res.getAllHeaders()) {

View File

@ -18,19 +18,19 @@
*/
package org.apache.olingo.commons.api;
public class ODataRuntimeException extends RuntimeException {
public class ODataResponseError extends RuntimeException {
private static final long serialVersionUID = 5492375572049190883L;
public ODataRuntimeException(final String msg) {
public ODataResponseError(final String msg) {
super(msg);
}
public ODataRuntimeException(final String msg, final Exception cause) {
public ODataResponseError(final String msg, final Exception cause) {
super(msg, cause);
}
public ODataRuntimeException(final Exception cause) {
public ODataResponseError(final Exception cause) {
super(cause);
}

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.server.api;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
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 ODataRuntimeException(e);
throw new ODataResponseError(e);
}
}

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.server.core;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
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 ODataRuntimeException(e);
throw new ODataResponseError(e);
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
throw new ODataRuntimeException(e);
throw new ODataResponseError(e);
}
}
}

View File

@ -18,7 +18,7 @@
*/
package org.apache.olingo.server.core.uri;
import org.apache.olingo.commons.api.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
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 ODataRuntimeException("Unsupported System Query Option: " + systemOption.getName());
throw new ODataResponseError("Unsupported System Query Option: " + systemOption.getName());
}
return this;

View File

@ -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.ODataRuntimeException;
import org.apache.olingo.commons.api.ODataResponseError;
/**
* 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 ODataRuntimeException(e);
throw new ODataResponseError(e);
}
final DefaultHttpClient httpClient = new DefaultHttpClient(new BasicClientConnectionManager(registry));