/** * Get wrapped {@link ODataApplicationException} or a new created * {@link ODataApplicationException}. * * @return an {@link ODataApplicationException} */ public ODataApplicationException convert() { if(rootCause instanceof ODataApplicationException) { return (ODataApplicationException) rootCause; } return new ODataApplicationException(rootCause.getMessage(), Locale.ENGLISH, HttpStatusCodes.INTERNAL_SERVER_ERROR); }
private void enhanceContextWithApplicationException(final ODataApplicationException toHandleException) { errorContext.setHttpStatus(toHandleException.getHttpStatus()); errorContext.setErrorCode(toHandleException.getCode()); }
throw new ODataApplicationException( e.getMessage(), Locale.getDefault(), IGWe.getHttpStatusCode(), IGWe.getErrorCode(), IGWe); //NOPMD - suppressed as the exception is preserved } else if (e.getCause() != null && e.getCause() instanceof BaseException) { ODataApplicationException exp = (ODataApplicationException) e.getCause(); throw new ODataApplicationException( e.getMessage() + e.getCause().getMessage(), Locale.getDefault(), exp.getHttpStatus(), null, exp);//NOPMD - suppressed as the exception is preserved throw new ODataApplicationException( e.getMessage(), Locale.getDefault(), IGWe.getHttpStatusCode(), IGWe.getErrorCode(), IGWe);//NOPMD - suppressed as the exception is preserved
}catch(ODataApplicationException oDataApplicationException) { if( NO_REF_CONSTRAINT.equalsIgnoreCase(oDataApplicationException.getMessage())) { logger.debug("Referential constraints absent.",oDataApplicationException); if (dataProvider instanceof ODataOperationValidator) { if (!((ODataOperationValidator) dataProvider).isCreatable(serviceName, entitySetName)) { throw new ODataApplicationException("Method not allowed on entity set.", LocaleUtil.getLocaleforException(), HttpStatusCodes.METHOD_NOT_ALLOWED);
statusCode = ((ODataApplicationException) exception).getHttpStatus().getStatusCode(); }else if (exception instanceof ODataHttpException){ statusCode = ((ODataHttpException) exception).getHttpStatus().getStatusCode();
IGWe.setHttpStatusCode(HttpStatusCodes.BAD_REQUEST); throw new ODataApplicationException( e.getMessage(), Locale.getDefault(), IGWe.getHttpStatusCode(), IGWe.getErrorCode(), IGWe); //NOPMD - suppressed as the exception is preserved } else if (e.getCause() != null && e.getCause() instanceof BaseException) { ODataApplicationException exp = (ODataApplicationException) e.getCause(); throw new ODataApplicationException( e.getMessage() + e.getCause().getMessage(), Locale.getDefault(), exp.getHttpStatus(), null, exp);//NOPMD - suppressed as the exception is preserved throw new ODataApplicationException( e.getMessage(), Locale.getDefault(), IGWe.getHttpStatusCode(), IGWe.getErrorCode(), IGWe);//NOPMD - suppressed as the exception is preserved
httpCode = ((ODataApplicationException) exception.getCause()).getHttpStatus();
protected ODataJPARuntimeException createApplicationError(String message, Locale locale) { return ODataJPARuntimeException.throwException( ODataJPARuntimeException.GENERAL, new ODataApplicationException(message, locale)); } }
private void enhanceContextWithApplicationException(final ODataApplicationException toHandleException) { errorContext.setHttpStatus(toHandleException.getHttpStatus()); errorContext.setErrorCode(toHandleException.getCode()); }
protected ODataJPARuntimeException createApplicationError(String message, Locale locale) { return ODataJPARuntimeException.throwException( ODataJPARuntimeException.GENERAL, new ODataApplicationException(message, locale)); }
private void enhanceContextWithApplicationException(final ODataApplicationException toHandleException) { errorContext.setHttpStatus(toHandleException.getHttpStatus()); errorContext.setErrorCode(toHandleException.getCode()); }
public ExtensionException(String msg, int statusCode, Locale locale) { this(new ODataApplicationException(msg, locale, HttpStatusCodes.fromStatusCode(statusCode))); }
private void enhanceContextWithApplicationException(final ODataApplicationException toHandleException) { errorContext.setHttpStatus(toHandleException.getHttpStatus()); errorContext.setErrorCode(toHandleException.getCode()); errorContext.setLocale(messageLocale); }
private ExtensionHolder getFunctionImportExtensionHolder(String functionName) throws ODataException { ExtensionHolder holder = null; if (extensionRegistry.isFunctionExtensionRegistered(functionName)) { holder = extensionRegistry.getFunctionExtension(functionName); } else { throw new ODataApplicationException(NO_IMPLEMENTATION, Locale.ENGLISH); } return holder; }
private void enhanceContextWithApplicationException(final ODataApplicationException toHandleException) { errorContext.setHttpStatus(toHandleException.getHttpStatus()); errorContext.setErrorCode(toHandleException.getCode()); errorContext.setLocale(messageLocale); }
private ExtensionHolder getActionImportExtensionHolder(String functionName) throws ODataException { ExtensionHolder holder = null; if (extensionRegistry.isActionExtensionRegistered(functionName)) { holder = extensionRegistry.getActionExtension(functionName); } else { throw new ODataApplicationException(NO_IMPLEMENTATION, Locale.ENGLISH); } return holder; }
errorContext.setHttpStatus(exp.getHttpStatus()); if(exp.getCode() == null) { errorContext.setErrorCode(exp.getHttpStatus().name()); } else { errorContext.setErrorCode(exp.getCode());
private void handleDraftCreateWithNavigations(PostUriInfo uriInfo, ODataEntry content) throws EdmException, ODataApplicationException { if(uriInfo.getNavigationSegments().size() > 1) { throw new ODataApplicationException("Unable to create. Create with navigation supported only from parent entity", LocaleUtil.getLocaleforException()); } if(!uriInfo.getNavigationSegments().isEmpty()) { Map<String,String> referenceMap = this.getReferenceMap(uriInfo); for(Map.Entry<String, String> entry:referenceMap.entrySet()){ content.getProperties().put(entry.getValue(), this.getKeyPredicateValue((UriInfo)uriInfo, entry.getKey())); } } }
private Map<String,String> getReferenceMap(PostUriInfo uriInfo) throws EdmException, ODataApplicationException{ // Is navigation segment always of size one? // // add try catch // Map<String,String> referenceMap = new HashMap<>(); EdmReferentialConstraint refConstraint = uriInfo.getNavigationSegments().get(0).getNavigationProperty().getRelationship().getReferentialConstraint(); if(refConstraint == null) throw new ODataApplicationException (NO_REF_CONSTRAINT, LocaleUtil.getLocaleforException()); List<String> principalPropertyList = refConstraint.getPrincipal().getPropertyRefNames(); List<String> dependentPropertList = refConstraint.getDependent().getPropertyRefNames(); for (int i = 0; i < principalPropertyList.size(); i++) { referenceMap.put(principalPropertyList.get(i), dependentPropertList.get(i)); } return referenceMap; }
throw new ODataApplicationException(e.getLocalizedMessage(), locale, e);