private String getMessageText(final Throwable throwable) { return throwable instanceof ODataMessageException ? MessageService.getMessage(locale, ((ODataMessageException) throwable).getMessageReference()).getText() : throwable.getLocalizedMessage() == null ? "Exception text missing" : throwable.getLocalizedMessage(); } }
private void enhanceContextWithMessageException(final ODataMessageException toHandleException) { errorContext.setErrorCode(toHandleException.getErrorCode()); MessageReference messageReference = toHandleException.getMessageReference(); Message localizedMessage = messageReference == null ? null : extractEntity(messageReference); if (localizedMessage != null) { errorContext.setMessage(localizedMessage.getText()); errorContext.setLocale(localizedMessage.getLocale()); } if (toHandleException instanceof ODataHttpException) { errorContext.setHttpStatus(((ODataHttpException) toHandleException).getHttpStatus()); } else if (toHandleException instanceof EntityProviderException) { errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST); } else if (toHandleException instanceof BatchException) { errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST); } }
public ODataCreateResult getResponseFromLocation(String completeUrl, String destinationName) throws ODataException { HttpResponse httpResponse = null; try { Edm edm = metadataCache.getEdm(completeUrl, getHttpClient(destinationName), destinationRelevantHeaders, errorHandler, cacheMetadata,metadataFilePath,cacheKey,isCacheRefresh); EdmEntitySet eSet = edm.getDefaultEntityContainer().getEntitySet(this.entitySet); HttpGet requestGet = new HttpGet(location); httpResponse = getHttpClient(destinationName).execute(requestGet); ODataConnectivityUtil.checkHttpStatus(httpResponse, errorHandler); EntityStream entityStream = new EntityStream(); entityStream.setContent(httpResponse.getEntity().getContent()); entityStream.setReadProperties(DeserializerProperties.init().build()); String contentType = "application/atom+xml"; if (!httpResponse.getFirstHeader("Content-Type").toString().contains(contentType)) contentType = "application/json"; ODataEntry deepInsResponse = ODataClient.newInstance().createDeserializer(contentType).readEntry(eSet, entityStream); return new ODataCreateResult(httpResponse, deepInsResponse.getProperties()); } catch (IOException e1) { HttpClientUtils.closeQuietly(httpResponse); throw new ODataException(null, "IOException", e1); } catch (EntityProviderException | EdmException e1) { HttpClientUtils.closeQuietly(httpResponse); throw new ODataException(ODataExceptionType.RESPONSE_DESERIALIZATION_FAILED, "Error during serialization of input payload. " + e1.getMessage(), e1); } finally { HttpClientUtils.closeQuietly(httpResponse); } } private boolean isNavigationFlow(){
private void enhanceContextWithMessageException(final ODataMessageException toHandleException) { errorContext.setErrorCode(toHandleException.getErrorCode()); MessageReference messageReference = toHandleException.getMessageReference(); Message localizedMessage = messageReference == null ? null : extractEntity(messageReference); if (localizedMessage != null) { errorContext.setMessage(localizedMessage.getText()); errorContext.setLocale(localizedMessage.getLocale()); } if (toHandleException instanceof ODataHttpException) { errorContext.setHttpStatus(((ODataHttpException) toHandleException).getHttpStatus()); } else if (toHandleException instanceof EntityProviderException) { if(toHandleException instanceof EntityProviderProducerException){ /* * As per OLINGO-763 serializer exceptions are produced by the server and must therefore result * in a 500 internal server error */ errorContext.setHttpStatus(HttpStatusCodes.INTERNAL_SERVER_ERROR); }else{ errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST); } } else if (toHandleException instanceof BatchException) { errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST); } }
private void enhanceContextWithMessageException(final ODataMessageException toHandleException) { errorContext.setErrorCode(toHandleException.getErrorCode()); MessageReference messageReference = toHandleException.getMessageReference(); Message localizedMessage = messageReference == null ? null : extractEntity(messageReference); if (localizedMessage != null) { errorContext.setMessage(localizedMessage.getText()); errorContext.setLocale(localizedMessage.getLocale()); } if (toHandleException instanceof ODataHttpException) { errorContext.setHttpStatus(((ODataHttpException) toHandleException).getHttpStatus()); } else if (toHandleException instanceof EntityProviderException) { if(toHandleException instanceof EntityProviderProducerException){ /* * As per OLINGO-763 serializer exceptions are produced by the server and must therefore result * in a 500 internal server error */ errorContext.setHttpStatus(HttpStatusCodes.INTERNAL_SERVER_ERROR); }else{ errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST); } } else if (toHandleException instanceof BatchException) { errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST); } }
private String getMessageText(final Throwable throwable) { return throwable instanceof ODataMessageException ? MessageService.getMessage(locale, ((ODataMessageException) throwable).getMessageReference()).getText() : throwable.getLocalizedMessage() == null ? "Exception text missing" : throwable.getLocalizedMessage(); } }
private void enhanceContextWithMessageException(final ODataMessageException toHandleException) { errorContext.setErrorCode(toHandleException.getErrorCode()); MessageReference messageReference = toHandleException.getMessageReference(); Message localizedMessage = messageReference == null ? null : extractEntity(messageReference); if (localizedMessage != null) { errorContext.setMessage(localizedMessage.getText()); errorContext.setLocale(localizedMessage.getLocale()); } if (toHandleException instanceof ODataHttpException) { errorContext.setHttpStatus(((ODataHttpException) toHandleException).getHttpStatus()); } else if (toHandleException instanceof EntityProviderException) { if(toHandleException instanceof EntityProviderProducerException){ /* * As per OLINGO-763 serializer exceptions are produced by the server and must therefore result * in a 500 internal server error */ errorContext.setHttpStatus(HttpStatusCodes.INTERNAL_SERVER_ERROR); }else{ errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST); } } else if (toHandleException instanceof BatchException) { errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST); } }
@Override public String extractExceptionMessage(final ODataMessageException exception) { Message msg = MessageService.getMessage(Locale.ENGLISH, exception.getMessageReference()); return msg.getText(); } }
private void enhanceContextWithMessageException(final ODataMessageException toHandleException) { errorContext.setErrorCode(toHandleException.getErrorCode()); MessageReference messageReference = toHandleException.getMessageReference(); Message localizedMessage = messageReference == null ? null : extractEntity(messageReference); if (localizedMessage != null) { errorContext.setMessage(localizedMessage.getText()); errorContext.setLocale(localizedMessage.getLocale()); } if (toHandleException instanceof ODataHttpException) { errorContext.setHttpStatus(((ODataHttpException) toHandleException).getHttpStatus()); } else if (toHandleException instanceof EntityProviderException) { if(toHandleException instanceof EntityProviderProducerException){ /* * As per OLINGO-763 serializer exceptions are produced by the server and must therefore result * in a 500 internal server error */ errorContext.setHttpStatus(HttpStatusCodes.INTERNAL_SERVER_ERROR); }else{ errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST); } } else if (toHandleException instanceof BatchException) { errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST); } }
@Override public String extractExceptionMessage(final ODataMessageException exception) { Message msg = MessageService.getMessage(Locale.ENGLISH, exception.getMessageReference()); return msg.getText(); } }
"message", throwable instanceof ODataMessageException ? MessageService.getMessage(locale, ((ODataMessageException) throwable).getMessageReference()) .getText() : throwable.getLocalizedMessage())