private void appendInlineCount(final XMLStreamWriter writer, final Integer inlineCount) throws EntityProviderException { if (inlineCount == null || inlineCount < 0) { throw new EntityProviderException(EntityProviderException.INLINECOUNT_INVALID); } try { writer.writeStartElement(Edm.NAMESPACE_M_2007_08, FormatXml.M_COUNT); writer.writeCharacters(String.valueOf(inlineCount)); writer.writeEndElement(); } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.COMMON, e); } }
@Override public ODataResponse build(final long jpaEntityCount) throws ODataJPARuntimeException { ODataResponse odataResponse = null; try { odataResponse = EntityProvider.writeText(String.valueOf(jpaEntityCount)); odataResponse = ODataResponse.fromResponse(odataResponse).build(); } catch (EntityProviderException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } return odataResponse; }
IGWe.setServiceNamespace(this.service.getNamespace()); IGWe.setServiceVersion(Integer.toString(this.service.getVersion())); IGWe.setStackTrace(e.getStackTrace()); if(e.getCause()!=null && e.getCause().getMessage()!=null && e.getCause() instanceof EdmSimpleTypeException){ IGWe.setHttpStatusCode(HttpStatusCodes.BAD_REQUEST); throw new ODataApplicationException( e.getMessage(), Locale.getDefault(), IGWe.getHttpStatusCode(), IGWe.getErrorCode(), IGWe); //NOPMD - suppressed as the exception is preserved
@Override public ODataResponse build(final long jpaEntityCount) throws ODataJPARuntimeException { ODataResponse odataResponse = null; try { odataResponse = EntityProvider.writeText(String.valueOf(jpaEntityCount)); odataResponse = ODataResponse.fromResponse(odataResponse).build(); } catch (EntityProviderException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } return odataResponse; }
IGWe.setServiceNamespace(this.service.getNamespace()); IGWe.setServiceVersion(Integer.toString(this.service.getVersion())); IGWe.setStackTrace(e.getStackTrace()); if(e.getCause()!=null && e.getCause().getMessage()!=null && e.getCause() instanceof EdmSimpleTypeException){ IGWe.setHttpStatusCode(HttpStatusCodes.BAD_REQUEST); if(e.getCause() instanceof MalformedJsonException){ IGWe.setHttpStatusCode(HttpStatusCodes.BAD_REQUEST); throw new ODataApplicationException( e.getMessage(), Locale.getDefault(), IGWe.getHttpStatusCode(), IGWe.getErrorCode(), IGWe); //NOPMD - suppressed as the exception is preserved
private void appendNextLink(final XMLStreamWriter writer, final String nextLink) throws EntityProviderException { try { writer.writeStartElement(FormatXml.ATOM_LINK); writer.writeAttribute(FormatXml.ATOM_HREF, nextLink); writer.writeAttribute(FormatXml.ATOM_REL, FormatXml.ATOM_NEXT_LINK); writer.writeEndElement(); } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.COMMON, e); } }
public static HttpStatusCodes checkStatus(HttpResponse response) throws ODataApplicationException { final StatusLine statusLine = response.getStatusLine(); HttpStatusCodes httpStatusCode = HttpStatusCodes.fromStatusCode(statusLine.getStatusCode()); if (400 <= httpStatusCode.getStatusCode() && httpStatusCode.getStatusCode() <= 599) { if (response.getEntity() != null) { try { final ContentType responseContentType = ContentType.parse( response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue()); final String mimeType = responseContentType.getMimeType(); if (ODATA_MIME_TYPE.matcher(mimeType).matches()) { final ODataErrorContext errorContext = EntityProvider.readErrorDocument( response.getEntity().getContent(), responseContentType.toString()); throw new ODataApplicationException(errorContext.getMessage(), errorContext.getLocale(), httpStatusCode, errorContext.getErrorCode(), errorContext.getException()); } } catch (EntityProviderException e) { throw new ODataApplicationException(e.getMessage(), response.getLocale(), httpStatusCode, e); } catch (IOException e) { throw new ODataApplicationException(e.getMessage(), response.getLocale(), httpStatusCode, e); } } throw new ODataApplicationException(statusLine.getReasonPhrase(), response.getLocale(), httpStatusCode); } return httpStatusCode; }
IGWe.setServiceNamespace(this.service.getNamespace()); IGWe.setServiceVersion(Integer.toString(this.service.getVersion())); IGWe.setStackTrace(e.getStackTrace()); if(e.getCause()!=null && e.getCause().getMessage()!=null && e.getCause() instanceof EdmSimpleTypeException){ IGWe.setHttpStatusCode(HttpStatusCodes.BAD_REQUEST); throw new ODataApplicationException( e.getMessage(), Locale.getDefault(), IGWe.getHttpStatusCode(), IGWe.getErrorCode(), IGWe); //NOPMD - suppressed as the exception is preserved
private void checkEdmNamespace() throws EntityProviderException { if (!edmNamespaces.contains(edmNamespace)) { throw new EntityProviderException(EntityProviderException.INVALID_NAMESPACE .addContent(XmlMetadataConstants.EDM_SCHEMA)); } }
public static HttpStatusCodes checkStatus(HttpResponse response) throws ODataApplicationException { final StatusLine statusLine = response.getStatusLine(); HttpStatusCodes httpStatusCode = HttpStatusCodes.fromStatusCode(statusLine.getStatusCode()); if (400 <= httpStatusCode.getStatusCode() && httpStatusCode.getStatusCode() <= 599) { if (response.getEntity() != null) { try { final ContentType responseContentType = getContentTypeHeader(response); final String mimeType = responseContentType.getMimeType(); if (ODATA_MIME_TYPE.matcher(mimeType).matches()) { final ODataErrorContext errorContext = EntityProvider.readErrorDocument( response.getEntity().getContent(), responseContentType.toString()); throw new ODataApplicationException(errorContext.getMessage(), errorContext.getLocale(), httpStatusCode, errorContext.getErrorCode(), errorContext.getException()); } } catch (EntityProviderException e) { throw new ODataApplicationException(e.getMessage(), response.getLocale(), httpStatusCode, e); } catch (IOException e) { throw new ODataApplicationException(e.getMessage(), response.getLocale(), httpStatusCode, e); } } throw new ODataApplicationException(statusLine.getReasonPhrase(), response.getLocale(), httpStatusCode); } return httpStatusCode; }
IGWe.setServiceNamespace(this.service.getNamespace()); IGWe.setServiceVersion(Integer.toString(this.service.getVersion())); IGWe.setStackTrace(e.getStackTrace()); if(e.getCause()!=null && e.getCause().getMessage()!=null && e.getCause() instanceof EdmSimpleTypeException){ IGWe.setHttpStatusCode(HttpStatusCodes.BAD_REQUEST); throw new ODataApplicationException( e.getMessage(), Locale.getDefault(), IGWe.getHttpStatusCode(), IGWe.getErrorCode(), IGWe); //NOPMD - suppressed as the exception is preserved
private void validate(final boolean codeFound, final boolean messageFound) throws EntityProviderException { if (!codeFound) { throw new EntityProviderException( EntityProviderException.MISSING_PROPERTY.addContent("Mandatory 'code' property not found.'")); } else if (!messageFound) { throw new EntityProviderException( EntityProviderException.MISSING_PROPERTY.addContent("Mandatory 'message' property not found.'")); } }
} catch (EntityProviderException e) { throw new ODataException(ODataExceptionType.INPUT_DATA_SERIALIZATION_FAILED, "Error during serialization of input payload. " + e.getMessage(), e); ODataConnectivityUtil.safeCloseHttpResponse(httpResponse); throw new ODataException(ODataExceptionType.RESPONSE_DESERIALIZATION_FAILED, "Error while deserializing response. " + e.getMessage(), e); } catch (IllegalStateException | IOException e) { ODataConnectivityUtil.safeCloseHttpResponse(httpResponse);
IGWe.setServiceNamespace(this.service.getNamespace()); IGWe.setServiceVersion(Integer.toString(this.service.getVersion())); IGWe.setStackTrace(e.getStackTrace()); if(e.getCause()!=null && e.getCause().getMessage()!=null && e.getCause() instanceof EdmSimpleTypeException){ IGWe.setHttpStatusCode(HttpStatusCodes.BAD_REQUEST); if(e.getCause() instanceof MalformedJsonException){ IGWe.setHttpStatusCode(HttpStatusCodes.BAD_REQUEST); throw new ODataApplicationException( e.getMessage(), Locale.getDefault(), IGWe.getHttpStatusCode(), IGWe.getErrorCode(), IGWe); //NOPMD - suppressed as the exception is preserved
private void checkEdmNamespace() throws EntityProviderException { if (!edmNamespaces.contains(edmNamespace)) { throw new EntityProviderException(EntityProviderException.INVALID_NAMESPACE .addContent(XmlMetadataConstants.EDM_SCHEMA)); } }
throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } catch (EdmException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
@SuppressWarnings("unchecked") private void mergeWithDefaultValues(final Object value, final EntityPropertyInfo epi) throws EntityProviderException { if (!(value instanceof Map)) { throw new EntityProviderException(EntityProviderException.COMMON); } if (!epi.isComplex()) { throw new EntityProviderException(EntityProviderException.COMMON); } mergeComplexWithDefaultValues((Map<String, Object>) value, (EntityComplexPropertyInfo) epi); }
throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } catch (EdmException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
private void checkEdmNamespace() throws EntityProviderException { if (!edmNamespaces.contains(edmNamespace)) { throw new EntityProviderException(EntityProviderException.INVALID_NAMESPACE .addContent(XmlMetadataConstants.EDM_SCHEMA)); } }
} catch (EntityProviderException e) { throw new ODataException(ODataExceptionType.INPUT_DATA_SERIALIZATION_FAILED, "Error during serialization of input payload." + e.getMessage(), e);