private Object createInstance(final Class<?> complexClass) throws ODataException { try { return complexClass.newInstance(); } catch (InstantiationException e) { throw new ODataException("Unable to create instance for complex data class '" + complexClass + "'.", e); } catch (IllegalAccessException e) { throw new ODataException("Unable to create instance for complex data class '" + complexClass + "'.", e); } }
private Exception extractException(final Exception exception) { if (exception instanceof ODataException) { ODataException odataException = (ODataException) exception; if (odataException.isCausedByApplicationException()) { return odataException.getApplicationExceptionCause(); } else if (odataException.isCausedByHttpException()) { return odataException.getHttpExceptionCause(); } else if (odataException.isCausedByMessageException()) { return odataException.getMessageExceptionCause(); } } return exception; }
/** * Search for and return first (from top) {@link ODataHttpException} in the cause hierarchy. * If there is no {@link ODataHttpException} in the cause hierarchy, <code>NULL</code> is returned. * * @return the first found {@link ODataHttpException} in the cause exception hierarchy * or <code>NULL</code> if no {@link ODataHttpException} is found in the cause hierarchy */ public ODataHttpException getHttpExceptionCause() { return getSpecificCause(ODataHttpException.class); }
@Override public IDataProviderResponse executeFunctionImport(GetFunctionImportUriInfo uriInfo, ODataContext context) throws ODataException { IDataProvider dataProvider = null; dataProvider = getDataProvider(getFunctionFqn(uriInfo.getFunctionImport())); try{ if (dataProvider !=null){ return dataProvider.executeFunctionImport(uriInfo, context); } else return null; } catch (ODataException e) { logger.error("Error in executeFunctionImport",e); throw new ODataException(e.getMessage(),e); } }
/** * {@inheritDoc} */ @Override public String getMessage() { if (messageReference == null) { return "No message reference given. Inherit message is = '" + super.getMessage() + "'"; } String message = RuntimeDelegate.extractExceptionMessage(this); if (message == null) { return "Message Reference key = '" + messageReference.getKey() + "' and inherit message = '" + super.getMessage() + "'"; } return message; } }
if(odataException!=null && odataException.getHttpExceptionCause()!=null) { errorContext.setHttpStatus(odataException.getHttpExceptionCause().getHttpStatus()); errorContext.setErrorCode(String.valueOf(odataException.getHttpExceptionCause().getHttpStatus().getStatusCode())); errorContext.setMessage(odataException.getMessage()); errorContext.setLocale(getLocale(contextFromBatchTask)); errorContext.setRequestUri(contextFromBatchTask.getPathInfo().getRequestUri());
if(e.getCause() != null && e.getCause() instanceof IGWException) { IGWe = (IGWException) e.getCause(); throw new ODataApplicationException( e.getMessage(), Locale.getDefault(), IGWe.getHttpStatusCode(), IGWe.getErrorCode(), IGWe);//NOPMD - suppressed as the exception is preserved
/** * Checks whether this exception is an or was caused by an {@link ODataHttpException} exception. * * @return <code>true</code> if this is an or was caused by an {@link ODataHttpException}, otherwise * <code>false</code> */ public boolean isCausedByHttpException() { return getHttpExceptionCause() != null; }
/** * Checks whether this exception is an or was caused by an {@link ODataApplicationException} exception. * * @return <code>true</code> if this is an or was caused by an {@link ODataApplicationException}, otherwise * <code>false</code> */ public boolean isCausedByApplicationException() { return getApplicationExceptionCause() != null; }
/** * Checks whether this exception is an or was caused by an {@link ODataMessageException} exception. * * @return <code>true</code> if this is an or was caused by an {@link ODataMessageException}, otherwise * <code>false</code> */ public boolean isCausedByMessageException() { return getMessageExceptionCause() != null; }
@Override public IDataProviderResponse countEntitySet(GetEntitySetCountUriInfo uriInfo, ODataContext context) throws ODataException { IDataProvider dataProvider = null; String targetEntitySet = uriInfo.getTargetEntitySet().getEntityType().getNamespace()+"."+uriInfo.getTargetEntitySet().getName(); dataProvider = getDataProvider(targetEntitySet); try{ if (dataProvider !=null){ return dataProvider.countEntitySet(uriInfo, context); } else return null; } catch (ODataException e) { logger.error("Error in countEntity",e); throw new ODataException(e.getMessage(),e); } }
/** * {@inheritDoc} */ @Override public String getMessage() { if (messageReference == null) { return "No message reference given. Inherit message is = '" + super.getMessage() + "'"; } String message = RuntimeDelegate.extractExceptionMessage(this); if (message == null) { return "Message Reference key = '" + messageReference.getKey() + "' and inherit message = '" + super.getMessage() + "'"; } return message; } }
if(e.getCause() != null && e.getCause() instanceof IGWException) { IGWe = (IGWException) e.getCause(); throw new ODataApplicationException( e.getMessage(), Locale.getDefault(), IGWe.getHttpStatusCode(), IGWe.getErrorCode(), IGWe);//NOPMD - suppressed as the exception is preserved
/** * Checks whether this exception is an or was caused by an {@link ODataHttpException} exception. * * @return <code>true</code> if this is an or was caused by an {@link ODataHttpException}, otherwise * <code>false</code> */ public boolean isCausedByHttpException() { return getHttpExceptionCause() != null; }
/** * Checks whether this exception is an or was caused by an {@link ODataApplicationException} exception. * * @return <code>true</code> if this is an or was caused by an {@link ODataApplicationException}, otherwise * <code>false</code> */ public boolean isCausedByApplicationException() { return getApplicationExceptionCause() != null; }
/** * Checks whether this exception is an or was caused by an {@link ODataMessageException} exception. * * @return <code>true</code> if this is an or was caused by an {@link ODataMessageException}, otherwise * <code>false</code> */ public boolean isCausedByMessageException() { return getMessageExceptionCause() != null; }
private Object createInstance(final Class<?> complexClass) throws ODataException { try { return complexClass.newInstance(); } catch (InstantiationException e) { throw new ODataException("Unable to create instance for complex data class '" + complexClass + "'.", e); } catch (IllegalAccessException e) { throw new ODataException("Unable to create instance for complex data class '" + complexClass + "'.", e); } }
@Override public IDataProviderResponse updateEntity(PutMergePatchUriInfo uriInfo, ODataEntry content,String requestContentType, boolean merge, ODataContext context) throws ODataException { IDataProvider dataProvider = null; String targetEntitySet = uriInfo.getTargetEntitySet().getEntityType().getNamespace()+"."+uriInfo.getTargetEntitySet().getName(); dataProvider = getDataProvider(targetEntitySet); try{ if (dataProvider !=null){ return dataProvider.updateEntity(uriInfo, content, requestContentType, merge, context); } else return null; } catch (ODataException e) { logger.error("Error in updateEntity",e); throw new ODataException(e.getMessage(),e); } }
private Exception extractException(final Exception exception) { if (exception instanceof ODataException) { ODataException odataException = (ODataException) exception; if (odataException.isCausedByApplicationException()) { return odataException.getApplicationExceptionCause(); } else if (odataException.isCausedByHttpException()) { return odataException.getHttpExceptionCause(); } else if (odataException.isCausedByMessageException()) { return odataException.getMessageExceptionCause(); } } return exception; }
/** * {@inheritDoc} */ @Override public String getMessage() { if (messageReference == null) { return "No message reference given. Inherit message is = '" + super.getMessage() + "'"; } String message = RuntimeDelegate.extractExceptionMessage(this); if (message == null) { return "Message Reference key = '" + messageReference.getKey() + "' and inherit message = '" + super.getMessage() + "'"; } return message; } }