[OLINGO-399] Changing flush exception management done in OLINGO-369

This commit is contained in:
Francesco Chicchiriccò 2014-08-13 11:18:49 +02:00
parent 0a0344d69b
commit 7be1e99213
27 changed files with 280 additions and 161 deletions

View File

@ -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<ODataResponseError> errors;
public ODataFlushException(final int statusCode, final List<ODataResponseError> errors) {
super("Errors found during flush()");
this.statusCode = statusCode;
this.errors = errors;
}
public int getStatusCode() {
return statusCode;
}
public List<ODataResponseError> getErrors() {
return errors;
}
}

View File

@ -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;
}
}

View File

@ -19,9 +19,7 @@
package org.apache.olingo.ext.proxy.api; package org.apache.olingo.ext.proxy.api;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import org.apache.olingo.commons.api.ODataResponseError;
/** /**
* Interface for container operations. * Interface for container operations.
@ -31,16 +29,15 @@ public interface PersistenceManager extends Serializable {
/** /**
* Flushes all pending changes to the OData service. * 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 * @throws ODataFlushException in case of errors
* bearing the error returned from the service.
*/ */
List<ODataResponseError> flush(); void flush();
/** /**
* Asynchronously flushes all pending changes to the OData service. * 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) * @return a future handle
* or the exception bearing the error returned from the service. * @throws ODataFlushException in case of errors
*/ */
Future<List<ODataResponseError>> flushAsync(); Future<Void> flushAsync();
} }

View File

@ -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.ODataMediaEntityUpdateRequest;
import org.apache.olingo.client.api.communication.request.streamed.ODataStreamUpdateRequest; import org.apache.olingo.client.api.communication.request.streamed.ODataStreamUpdateRequest;
import org.apache.olingo.client.core.uri.URIUtils; 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.CommonODataEntity;
import org.apache.olingo.commons.api.domain.ODataLink; import org.apache.olingo.commons.api.domain.ODataLink;
import org.apache.olingo.commons.api.domain.ODataLinkType; 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.AttachedEntity;
import org.apache.olingo.ext.proxy.context.AttachedEntityStatus; import org.apache.olingo.ext.proxy.context.AttachedEntityStatus;
import org.apache.olingo.ext.proxy.context.EntityLinkDesc; 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.apache.olingo.ext.proxy.utils.CoreUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -71,19 +71,20 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
} }
@Override @Override
public Future<List<ODataResponseError>> flushAsync() { public Future<Void> flushAsync() {
return service.getClient().getConfiguration().getExecutor().submit(new Callable<List<ODataResponseError>>() { return service.getClient().getConfiguration().getExecutor().submit(new Callable<Void>() {
@Override @Override
public List<ODataResponseError> call() throws Exception { public Void call() throws Exception {
return flush(); flush();
return ClassUtils.returnVoid();
} }
}); });
} }
protected abstract List<ODataResponseError> doFlush(PersistenceChanges changes, TransactionItems items); protected abstract void doFlush(PersistenceChanges changes, TransactionItems items);
@Override @Override
public List<ODataResponseError> flush() { public void flush() {
final PersistenceChanges changes = new PersistenceChanges(); final PersistenceChanges changes = new PersistenceChanges();
final TransactionItems items = new TransactionItems(); final TransactionItems items = new TransactionItems();
@ -110,13 +111,11 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
items.put(null, pos); items.put(null, pos);
} }
final List<ODataResponseError> result = new ArrayList<ODataResponseError>();
if (!items.isEmpty()) { if (!items.isEmpty()) {
result.addAll(doFlush(changes, items)); doFlush(changes, items);
} }
service.getContext().detachAll(); service.getContext().detachAll();
return result;
} }
private ODataLink buildNavigationLink(final String name, final URI uri, final ODataLinkType type) { 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 final URI targetURI = currentStatus == AttachedEntityStatus.NEW
? URI.create("$" + startingPos) ? URI.create("$" + startingPos)
: URIUtils.getURI( : URIUtils.getURI(
service.getClient().getServiceRoot(), handler.getEntity().getEditLink().toASCIIString()); service.getClient().getServiceRoot(), handler.getEntity().getEditLink().toASCIIString());
queueUpdate(handler, targetURI, entity, changeset); queueUpdate(handler, targetURI, entity, changeset);
pos++; pos++;
items.put(handler, pos); items.put(handler, pos);
@ -275,8 +274,8 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
final URI targetURI = currentStatus == AttachedEntityStatus.NEW final URI targetURI = currentStatus == AttachedEntityStatus.NEW
? URI.create("$" + startingPos + "/$value") ? URI.create("$" + startingPos + "/$value")
: URIUtils.getURI( : URIUtils.getURI(
service.getClient().getServiceRoot(), service.getClient().getServiceRoot(),
handler.getEntity().getEditLink().toASCIIString() + "/$value"); handler.getEntity().getEditLink().toASCIIString() + "/$value");
queueUpdateMediaEntity(handler, targetURI, handler.getStreamChanges(), changeset); queueUpdateMediaEntity(handler, targetURI, handler.getStreamChanges(), changeset);
@ -290,8 +289,8 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
for (Map.Entry<String, EdmStreamValue> streamedChanges : handler.getStreamedPropertyChanges().entrySet()) { for (Map.Entry<String, EdmStreamValue> streamedChanges : handler.getStreamedPropertyChanges().entrySet()) {
final URI targetURI = currentStatus == AttachedEntityStatus.NEW final URI targetURI = currentStatus == AttachedEntityStatus.NEW
? URI.create("$" + startingPos) : URIUtils.getURI( ? URI.create("$" + startingPos) : URIUtils.getURI(
service.getClient().getServiceRoot(), service.getClient().getServiceRoot(),
CoreUtils.getMediaEditLink(streamedChanges.getKey(), entity).toASCIIString()); CoreUtils.getMediaEditLink(streamedChanges.getKey(), entity).toASCIIString());
queueUpdateMediaResource(handler, targetURI, streamedChanges.getValue(), changeset); queueUpdateMediaResource(handler, targetURI, streamedChanges.getValue(), changeset);
@ -459,10 +458,10 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
service.getClient().getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0 service.getClient().getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0
? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) service.getClient()).getCUDRequestFactory(). ? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) service.getClient()).getCUDRequestFactory().
getEntityUpdateRequest(handler.getEntityURI(), 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(). : ((org.apache.olingo.client.api.v4.EdmEnabledODataClient) service.getClient()).getCUDRequestFactory().
getEntityUpdateRequest(handler.getEntityURI(), 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()); req.setPrefer(new ODataPreferences(service.getClient().getServiceVersion()).returnContent());
@ -509,10 +508,10 @@ abstract class AbstractPersistenceManager implements PersistenceManager {
service.getClient().getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0 service.getClient().getServiceVersion().compareTo(ODataServiceVersion.V30) <= 0
? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) service.getClient()).getCUDRequestFactory(). ? ((org.apache.olingo.client.api.v3.EdmEnabledODataClient) service.getClient()).getCUDRequestFactory().
getEntityUpdateRequest(uri, 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(). : ((org.apache.olingo.client.api.v4.EdmEnabledODataClient) service.getClient()).getCUDRequestFactory().
getEntityUpdateRequest(uri, 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()); req.setPrefer(new ODataPreferences(service.getClient().getServiceVersion()).returnContent());

View File

@ -92,7 +92,8 @@ public final class EntityContainerInvocationHandler extends AbstractInvocationHa
if (isSelfMethod(method, args)) { if (isSelfMethod(method, args)) {
return invokeSelfMethod(method, args); return invokeSelfMethod(method, args);
} else if ("flush".equals(method.getName()) && ArrayUtils.isEmpty(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)) { } else if ("flushAsync".equals(method.getName()) && ArrayUtils.isEmpty(args)) {
return service.getPersistenceManager().flushAsync(); return service.getPersistenceManager().flushAsync();
} else if ("operations".equals(method.getName()) && ArrayUtils.isEmpty(args)) { } else if ("operations".equals(method.getName()) && ArrayUtils.isEmpty(args)) {

View File

@ -19,9 +19,8 @@
package org.apache.olingo.ext.proxy.commons; package org.apache.olingo.ext.proxy.commons;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.olingo.client.api.communication.request.ODataBasicRequest; import org.apache.olingo.client.api.communication.request.ODataBasicRequest;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest; 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.ODataEntityCreateResponse;
import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse; import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse;
import org.apache.olingo.client.api.communication.response.ODataResponse; 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.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 * {@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 @Override
protected List<ODataResponseError> doFlush(final PersistenceChanges changes, final TransactionItems items) { protected void doFlush(final PersistenceChanges changes, final TransactionItems items) {
final List<ODataResponseError> result = new ArrayList<ODataResponseError>();
final Map<Integer, URI> responses = new HashMap<Integer, URI>(); final Map<Integer, URI> responses = new HashMap<Integer, URI>();
int virtualContentID = 0;
int index = 0;
for (Map.Entry<ODataBatchableRequest, EntityInvocationHandler> entry : changes.getChanges().entrySet()) { for (Map.Entry<ODataBatchableRequest, EntityInvocationHandler> entry : changes.getChanges().entrySet()) {
virtualContentID++; index++;
final ODataRequest request = ODataRequest.class.cast(entry.getKey());
final ODataResponse response;
try { try {
final ODataRequest req = ODataRequest.class.cast(entry.getKey()); String uri = request.getURI().toASCIIString();
String uri = req.getURI().toASCIIString();
if (uri.startsWith("$")) { if (uri.startsWith("$")) {
int slashIndex = uri.indexOf('/'); int slashIndex = uri.indexOf('/');
final Integer toBeReplaced = Integer.valueOf(uri.substring(1, slashIndex < 0 ? uri.length() : slashIndex)); final Integer toBeReplaced = Integer.valueOf(uri.substring(1, slashIndex < 0 ? uri.length() : slashIndex));
if (responses.containsKey(toBeReplaced)) { if (responses.containsKey(toBeReplaced)) {
uri = uri.replace("$" + toBeReplaced, responses.get(Integer.valueOf(toBeReplaced)).toASCIIString()); uri = uri.replace("$" + toBeReplaced, responses.get(toBeReplaced).toASCIIString());
req.setURI(URI.create(uri)); request.setURI(URI.create(uri));
} }
} }
final ODataResponse response; if (ODataStreamedRequest.class.isAssignableFrom(request.getClass())) {
if (ODataStreamedRequest.class.isAssignableFrom(req.getClass())) { response = ((ODataStreamedRequest<?, ?>) request).payloadManager().getResponse();
response = ((ODataStreamedRequest<?, ?>) req).payloadManager().getResponse();
} else { } else {
response = ((ODataBasicRequest<?>) req).execute(); response = ((ODataBasicRequest<?>) request).execute();
} }
if (entry.getValue() != null if (entry.getValue() != null
&& response instanceof ODataEntityCreateResponse && response.getStatusCode() == 201) { && response instanceof ODataEntityCreateResponse && response.getStatusCode() == 201) {
entry.getValue().setEntity(((ODataEntityCreateResponse<?>) response).getBody()); 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()); LOG.debug("Upgrade created object '{}'", entry.getValue());
} else if (entry.getValue() != null } else if (entry.getValue() != null
&& response instanceof ODataEntityUpdateResponse && response.getStatusCode() == 200) { && response instanceof ODataEntityUpdateResponse && response.getStatusCode() == 200) {
entry.getValue().setEntity(((ODataEntityUpdateResponse<?>) response).getBody()); 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()); LOG.debug("Upgrade updated object '{}'", entry.getValue());
} else { } else {
responses.put(virtualContentID, null); responses.put(index, null);
} }
} catch (ODataRuntimeException e) {
result.add(null);
} catch (ODataResponseError e) {
LOG.error("While performing {}", entry.getKey().getURI(), e); LOG.error("While performing {}", entry.getKey().getURI(), e);
if (service.getClient().getConfiguration().isContinueOnError()) { throw new ODataFlushException(0, Collections.singletonList(new ODataResponseError(e, index, request)));
result.add(e);
} else {
throw e;
}
} }
} }
return result;
} }
} }

View File

@ -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();
}
}

View File

@ -22,8 +22,7 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.http.ProtocolVersion; import org.apache.olingo.client.api.communication.ODataServerErrorException;
import org.apache.http.StatusLine;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest; 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.ODataRequest;
import org.apache.olingo.client.api.communication.request.ODataStreamedRequest; 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.api.communication.response.ODataResponse;
import org.apache.olingo.client.core.communication.header.ODataErrorResponseChecker; import org.apache.olingo.client.core.communication.header.ODataErrorResponseChecker;
import org.apache.olingo.client.core.communication.request.batch.ODataChangesetResponseItem; 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.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 * {@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. * Transactional changes commit.
*/ */
@Override @Override
protected List<ODataResponseError> doFlush(final PersistenceChanges changes, final TransactionItems items) { protected void doFlush(final PersistenceChanges changes, final TransactionItems items) {
final CommonODataBatchRequest request = final CommonODataBatchRequest request =
service.getClient().getBatchRequestFactory().getBatchRequest(service.getClient().getServiceRoot()); service.getClient().getBatchRequestFactory().getBatchRequest(service.getClient().getServiceRoot());
((ODataRequest) request).setAccept( ((ODataRequest) request).setAccept(
@ -65,9 +65,11 @@ public class TransactionalPersistenceManagerImpl extends AbstractPersistenceMana
final BatchManager batchManager = (BatchManager) ((ODataStreamedRequest) request).payloadManager(); final BatchManager batchManager = (BatchManager) ((ODataStreamedRequest) request).payloadManager();
final List<ODataRequest> requests = new ArrayList<ODataRequest>(changes.getChanges().size());
final ODataChangeset changeset = batchManager.addChangeset(); final ODataChangeset changeset = batchManager.addChangeset();
for (Map.Entry<ODataBatchableRequest, EntityInvocationHandler> entry : changes.getChanges().entrySet()) { for (Map.Entry<ODataBatchableRequest, EntityInvocationHandler> entry : changes.getChanges().entrySet()) {
changeset.addRequest(entry.getKey()); changeset.addRequest(entry.getKey());
requests.add(entry.getKey());
} }
final ODataBatchResponse response = batchManager.getResponse(); 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 // 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. // many service implementations are not fully compliant in this respect.
if (response.getStatusCode() != 202 && response.getStatusCode() != 200) { if (response.getStatusCode() != 202 && response.getStatusCode() != 200) {
throw new IllegalStateException("Operation failed"); throw new ODataServerErrorException(new ResponseStatusLine(response));
} }
final List<ODataResponseError> result = new ArrayList<ODataResponseError>();
if (!items.isEmpty()) { if (!items.isEmpty()) {
final List<ODataResponseError> errors = new ArrayList<ODataResponseError>();
final Iterator<ODataBatchResponseItem> batchResItor = response.getBody(); final Iterator<ODataBatchResponseItem> batchResItor = response.getBody();
if (!batchResItor.hasNext()) { if (!batchResItor.hasNext()) {
throw new IllegalStateException("Unexpected operation result"); throw new IllegalStateException("Unexpected operation result");
@ -93,38 +95,21 @@ public class TransactionalPersistenceManagerImpl extends AbstractPersistenceMana
final ODataChangesetResponseItem chgres = (ODataChangesetResponseItem) item; final ODataChangesetResponseItem chgres = (ODataChangesetResponseItem) item;
for (final Iterator<Integer> itor = items.sortedValues().iterator(); itor.hasNext();) { int index = 0;
for (final Iterator<Integer> itor = items.sortedValues().iterator(); itor.hasNext(); index++) {
final Integer changesetItemId = itor.next(); final Integer changesetItemId = itor.next();
LOG.debug("Expected changeset item {}", changesetItemId); LOG.debug("Expected changeset item {}", changesetItemId);
final ODataResponse res = chgres.next(); final ODataResponse res = chgres.next();
if (res.getStatusCode() >= 400) { if (res.getStatusCode() >= 400) {
if (service.getClient().getConfiguration().isContinueOnError()) { errors.add(new ODataResponseError(ODataErrorResponseChecker.checkResponse(
result.add(ODataErrorResponseChecker.checkResponse( service.getClient(),
service.getClient(), new ResponseStatusLine(res),
new StatusLine() { res.getRawResponse(),
@Override ((ODataRequest) request).getAccept()), index, requests.get(index)));
public ProtocolVersion getProtocolVersion() { if (!service.getClient().getConfiguration().isContinueOnError()) {
return null; throw new ODataFlushException(response.getStatusCode(), errors);
}
@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());
} }
} else {
result.add(null);
} }
final EntityInvocationHandler handler = items.get(changesetItemId); 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(); response.close();
return result;
} }
} }

View File

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

View File

@ -18,13 +18,15 @@
*/ */
package org.apache.olingo.fit.proxy.v3; 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.Driver;
import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Order; import org.apache.olingo.fit.proxy.v3.staticservice.microsoft.test.odata.services.astoriadefaultservice.types.Order;
import org.junit.Test; 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. * This is the unit test class to check actions overloading.
*/ */
@ -47,9 +49,9 @@ public class PropertyTestITCase extends AbstractTestITCase {
try { try {
container.flush(); container.flush();
fail(); fail();
} catch (IllegalStateException e) { } catch (ODataFlushException e) {
// ignore and detach all assertNotNull(e);
service.getContext().detachAll();
} }
service.getContext().detachAll();
} }
} }

View File

@ -30,12 +30,10 @@ import java.lang.reflect.Proxy;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Calendar; import java.util.Calendar;
import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.apache.olingo.client.api.v4.EdmEnabledODataClient; 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.commons.api.format.ContentType;
import org.apache.olingo.ext.proxy.AbstractService; import org.apache.olingo.ext.proxy.AbstractService;
import org.apache.olingo.ext.proxy.api.EdmStreamValue; 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<org.apache.olingo.client.api.v3.EdmEnabledODataClient> v3serv = org.apache.olingo.fit.proxy.v3.staticservice.Service<org.apache.olingo.client.api.v3.EdmEnabledODataClient> v3serv =
org.apache.olingo.fit.proxy.v3.staticservice.Service.getV3( 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); v3serv.getClient().getConfiguration().setDefaultBatchAcceptFormat(ContentType.APPLICATION_OCTET_STREAM);
final DefaultContainer v3cont = v3serv.getEntityContainer(DefaultContainer.class); final DefaultContainer v3cont = v3serv.getEntityContainer(DefaultContainer.class);
assertNotNull(v3cont); assertNotNull(v3cont);
@ -603,8 +601,7 @@ public class APIBasicDesignTestITCase extends AbstractTestITCase {
getContainer().getOrders().add(order); getContainer().getOrders().add(order);
getContainer().getOrders().delete(order); getContainer().getOrders().delete(order);
List<ODataResponseError> res = getContainer().flush(); getContainer().flush();
assertTrue(res.isEmpty() || res.iterator().next() == null);
service.getContext().detachAll(); service.getContext().detachAll();
try { try {
@ -633,10 +630,10 @@ public class APIBasicDesignTestITCase extends AbstractTestITCase {
public void issueOLINGO398() { public void issueOLINGO398() {
AbstractCollectionInvocationHandler<?, ?> handler = AbstractCollectionInvocationHandler.class.cast( AbstractCollectionInvocationHandler<?, ?> handler = AbstractCollectionInvocationHandler.class.cast(
Proxy.getInvocationHandler(container.getCustomers().getByKey(1).getOrders(). Proxy.getInvocationHandler(container.getCustomers().getByKey(1).getOrders().
select("OrderID", "CustomerForOrder"). select("OrderID", "CustomerForOrder").
expand("CustomerForOrder"). expand("CustomerForOrder").
top(1). top(1).
skip(2))); skip(2)));
assertEquals("http://localhost:9080/stub/StaticService/V40/Static.svc/Customers(1)/Orders?" assertEquals("http://localhost:9080/stub/StaticService/V40/Static.svc/Customers(1)/Orders?"
+ "%24select=OrderID%2CCustomerForOrder&%24expand=CustomerForOrder&%24top=1&%24skip=2", + "%24select=OrderID%2CCustomerForOrder&%24expand=CustomerForOrder&%24top=1&%24skip=2",
@ -644,10 +641,10 @@ public class APIBasicDesignTestITCase extends AbstractTestITCase {
handler = AbstractCollectionInvocationHandler.class.cast( handler = AbstractCollectionInvocationHandler.class.cast(
Proxy.getInvocationHandler(container.getCustomers().getByKey(1).getOrders(). Proxy.getInvocationHandler(container.getCustomers().getByKey(1).getOrders().
select("OrderID", "CustomerForOrder"). select("OrderID", "CustomerForOrder").
expand("CustomerForOrder"). expand("CustomerForOrder").
top(1). top(1).
skip(2))); skip(2)));
assertEquals("http://localhost:9080/stub/StaticService/V40/Static.svc/Customers(1)/Orders?%24" assertEquals("http://localhost:9080/stub/StaticService/V40/Static.svc/Customers(1)/Orders?%24"
+ "select=OrderID%2CCustomerForOrder&%24expand=CustomerForOrder&%24top=1&%24skip=2", + "select=OrderID%2CCustomerForOrder&%24expand=CustomerForOrder&%24top=1&%24skip=2",

View File

@ -22,12 +22,10 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import java.util.List;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Test; import org.junit.Test;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import org.apache.olingo.commons.api.ODataResponseError;
//CHECKSTYLE:OFF (Maven checkstyle) //CHECKSTYLE:OFF (Maven checkstyle)
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.Customer;
@ -64,7 +62,7 @@ public class AsyncTestITCase extends AbstractTestITCase {
final Person person = container.getPeople().getByKey(1); final Person person = container.getPeople().getByKey(1);
person.setFirstName(randomFirstName); person.setFirstName(randomFirstName);
final Future<List<ODataResponseError>> futureFlush = container.flushAsync(); final Future<Void> futureFlush = container.flushAsync();
assertNotNull(futureFlush); assertNotNull(futureFlush);
while (!futureFlush.isDone()) { while (!futureFlush.isDone()) {

View File

@ -19,17 +19,15 @@
package org.apache.olingo.fit.proxy.v4; package org.apache.olingo.fit.proxy.v4;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Calendar; import java.util.Calendar;
import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.v4.EdmEnabledODataClient; 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.commons.api.format.ContentType;
import org.apache.olingo.ext.proxy.api.ODataFlushException;
import org.apache.olingo.ext.proxy.api.PrimitiveCollection; 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.Service;
import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.InMemoryEntities; 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); container.getPeople().add(employee);
final List<ODataResponseError> result = container.flush(); try {
container.flush();
assertEquals(2, result.size()); fail();
assertTrue(result.get(0) instanceof ODataClientErrorException); } catch (ODataFlushException e) {
assertNull(result.get(1)); assertEquals(1, e.getErrors().size());
assertEquals(0, e.getErrors().get(0).getIndex());
assertNotNull(e.getErrors().get(0).getRequest());
}
service.getContext().detachAll();
} }
@Test @Test

View File

@ -18,9 +18,11 @@
*/ */
package org.apache.olingo.fit.proxy.v4; package org.apache.olingo.fit.proxy.v4;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail; 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.Customer;
import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.StoredPI; import org.apache.olingo.fit.proxy.v4.staticservice.microsoft.test.odata.services.odatawcfservice.types.StoredPI;
import org.junit.Test; import org.junit.Test;
@ -47,9 +49,9 @@ public class PropertyTestITCase extends AbstractTestITCase {
try { try {
container.flush(); container.flush();
fail(); fail();
} catch (IllegalStateException e) { } catch (ODataFlushException e) {
// ignore and detach all assertNotNull(e);
service.getContext().detachAll();
} }
service.getContext().detachAll();
} }
} }

View File

@ -20,7 +20,7 @@ package org.apache.olingo.client.api.communication;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.StatusLine; 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; import org.apache.olingo.commons.api.domain.ODataError;
/** /**
@ -28,7 +28,7 @@ import org.apache.olingo.commons.api.domain.ODataError;
* *
* @see ODataError * @see ODataError
*/ */
public class ODataClientErrorException extends ODataResponseError { public class ODataClientErrorException extends ODataRuntimeException {
private static final long serialVersionUID = -2551523202755268162L; private static final long serialVersionUID = -2551523202755268162L;

View File

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

View File

@ -18,7 +18,7 @@
*/ */
package org.apache.olingo.client.api.communication.header; 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 org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import java.util.Arrays; import java.util.Arrays;
@ -214,7 +214,7 @@ public enum HeaderName {
final void isSupportedBy(final ODataServiceVersion serviceVersion) { final void isSupportedBy(final ODataServiceVersion serviceVersion) {
if (!supportedVersions.contains(serviceVersion)) { if (!supportedVersions.contains(serviceVersion)) {
throw new ODataResponseError("Unsupported header " + this.toString()); throw new ODataRuntimeException("Unsupported header " + this.toString());
} }
} }

View File

@ -18,7 +18,7 @@
*/ */
package org.apache.olingo.client.api.communication.header; 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 org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import java.util.Arrays; import java.util.Arrays;
@ -411,7 +411,7 @@ public class ODataPreferences {
final PreferenceNames isSupportedBy(final ODataServiceVersion serviceVersion) { final PreferenceNames isSupportedBy(final ODataServiceVersion serviceVersion) {
if (!supportedVersions.contains(serviceVersion)) { if (!supportedVersions.contains(serviceVersion)) {
throw new ODataResponseError("Unsupported header " + this.toString()); throw new ODataRuntimeException("Unsupported header " + this.toString());
} }
return this; 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.CommonODataClient;
import org.apache.olingo.client.api.communication.ODataClientErrorException; import org.apache.olingo.client.api.communication.ODataClientErrorException;
import org.apache.olingo.client.api.communication.ODataServerErrorException; 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.domain.ODataError;
import org.apache.olingo.commons.api.format.ODataFormat; import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.commons.api.serialization.ODataDeserializerException; import org.apache.olingo.commons.api.serialization.ODataDeserializerException;
@ -41,11 +41,11 @@ public final class ODataErrorResponseChecker {
return error; return error;
} }
public static ODataResponseError checkResponse( public static ODataRuntimeException checkResponse(
final CommonODataClient<?> odataClient, final StatusLine statusLine, final InputStream entity, final CommonODataClient<?> odataClient, final StatusLine statusLine, final InputStream entity,
final String accept) { final String accept) {
ODataResponseError result = null; ODataRuntimeException result = null;
if (entity == null) { if (entity == null) {
result = new ODataClientErrorException(statusLine); result = new ODataClientErrorException(statusLine);

View File

@ -42,7 +42,7 @@ import java.io.InputStream;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.net.URI; import java.net.URI;
import java.util.Collection; 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. * Abstract representation of an OData request. Get instance by using factories.
@ -322,7 +322,7 @@ public abstract class AbstractODataRequest extends AbstractRequest implements OD
try { try {
checkResponse(odataClient, response, getAccept()); checkResponse(odataClient, response, getAccept());
} catch (ODataResponseError e) { } catch (ODataRuntimeException e) {
odataClient.getConfiguration().getHttpClientFactory().close(httpClient); odataClient.getConfiguration().getHttpClientFactory().close(httpClient);
throw e; 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.CommonEdmEnabledODataClient;
import org.apache.olingo.client.api.CommonODataClient; import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.core.communication.header.ODataErrorResponseChecker; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
@ -50,7 +50,7 @@ public abstract class AbstractRequest {
if (response.getStatusLine().getStatusCode() >= 400) { if (response.getStatusLine().getStatusCode() >= 400) {
try { try {
final ODataResponseError exception = ODataErrorResponseChecker.checkResponse( final ODataRuntimeException exception = ODataErrorResponseChecker.checkResponse(
odataClient, odataClient,
response.getStatusLine(), response.getStatusLine(),
response.getEntity() == null ? null : response.getEntity().getContent(), response.getEntity() == null ? null : response.getEntity().getContent(),
@ -59,7 +59,7 @@ public abstract class AbstractRequest {
throw exception; throw exception;
} }
} catch (IOException e) { } catch (IOException e) {
throw new ODataResponseError( throw new ODataRuntimeException(
"Received '" + response.getStatusLine() + "' but could not extract error body", e); "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.HashSet;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import org.apache.olingo.commons.api.ODataResponseError; import org.apache.olingo.commons.api.ODataRuntimeException;
/** /**
* Abstract representation of an OData response. * 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(); this.payload = res.getEntity() == null ? null : res.getEntity().getContent();
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error retrieving payload", e); LOG.error("Error retrieving payload", e);
throw new ODataResponseError(e); throw new ODataRuntimeException(e);
} }
for (Header header : res.getAllHeaders()) { for (Header header : res.getAllHeaders()) {

View File

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

View File

@ -18,7 +18,7 @@
*/ */
package org.apache.olingo.server.api; 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.edm.Edm;
import org.apache.olingo.commons.api.format.ODataFormat; import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.server.api.edm.provider.EdmProvider; import org.apache.olingo.server.api.edm.provider.EdmProvider;
@ -47,7 +47,7 @@ public abstract class OData {
return (OData) object; return (OData) object;
} catch (final Exception e) { } catch (final Exception e) {
throw new ODataResponseError(e); throw new ODataRuntimeException(e);
} }
} }

View File

@ -18,7 +18,7 @@
*/ */
package org.apache.olingo.server.core; 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.edm.Edm;
import org.apache.olingo.commons.api.http.HttpHeader; import org.apache.olingo.commons.api.http.HttpHeader;
import org.apache.olingo.commons.api.http.HttpMethod; import org.apache.olingo.commons.api.http.HttpMethod;
@ -109,13 +109,13 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
} }
} catch (IOException e) { } catch (IOException e) {
LOG.error(e.getMessage(), e); LOG.error(e.getMessage(), e);
throw new ODataResponseError(e); throw new ODataRuntimeException(e);
} finally { } finally {
if (input != null) { if (input != null) {
try { try {
input.close(); input.close();
} catch (IOException e) { } catch (IOException e) {
throw new ODataResponseError(e); throw new ODataRuntimeException(e);
} }
} }
} }

View File

@ -18,7 +18,7 @@
*/ */
package org.apache.olingo.server.core.uri; 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.commons.api.edm.EdmEntityType;
import org.apache.olingo.server.api.uri.UriInfo; import org.apache.olingo.server.api.uri.UriInfo;
import org.apache.olingo.server.api.uri.UriInfoAll; import org.apache.olingo.server.api.uri.UriInfoAll;
@ -266,7 +266,7 @@ public class UriInfoImpl implements UriInfo {
} else if (systemOption.getKind() == SystemQueryOptionKind.LEVELS) { } else if (systemOption.getKind() == SystemQueryOptionKind.LEVELS) {
systemQueryOptions.put(SystemQueryOptionKind.LEVELS, systemOption); systemQueryOptions.put(SystemQueryOptionKind.LEVELS, systemOption);
} else { } else {
throw new ODataResponseError("Unsupported System Query Option: " + systemOption.getName()); throw new ODataRuntimeException("Unsupported System Query Option: " + systemOption.getName());
} }
return this; return this;

View File

@ -30,7 +30,7 @@ import org.apache.http.impl.conn.BasicClientConnectionManager;
import org.apache.http.params.CoreProtocolPNames; import org.apache.http.params.CoreProtocolPNames;
import org.apache.olingo.client.api.http.HttpMethod; import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.core.http.AbstractHttpClientFactory; 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 * 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); new SSLSocketFactory(acceptTrustStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
registry.register(new Scheme(uri.getScheme(), uri.getPort(), ssf)); registry.register(new Scheme(uri.getScheme(), uri.getPort(), ssf));
} catch (Exception e) { } catch (Exception e) {
throw new ODataResponseError(e); throw new ODataRuntimeException(e);
} }
final DefaultHttpClient httpClient = new DefaultHttpClient(new BasicClientConnectionManager(registry)); final DefaultHttpClient httpClient = new DefaultHttpClient(new BasicClientConnectionManager(registry));