public static <T> InputStream contentAsStream(final T content) throws ODataException { if (content == null) { throw new ODataBadRequestException(ODataBadRequestException.COMMON); } InputStream inputStream; if (content instanceof InputStream) { inputStream = (InputStream) content; } else if (content instanceof String) { try { inputStream = new ByteArrayInputStream(((String) content).getBytes("UTF-8")); } catch (final UnsupportedEncodingException e) { throw new ODataBadRequestException(ODataBadRequestException.COMMON, e); } } else { throw new ODataBadRequestException(ODataBadRequestException.COMMON); } return inputStream; }
@Override public ODataResponse existsEntity(GetEntityCountUriInfo uriInfo,String contentType) throws ODataBadRequestException { ODataBadRequestException exception = new ODataBadRequestException(ODataBadRequestException.COMMON); LoggerFactory.getLogger(GenericODataProcessor.class).error(exception.getMessage(), exception); throw exception; }
public static <T> InputStream contentAsStream(final T content) throws ODataException { if (content == null) { throw new ODataBadRequestException(ODataBadRequestException.COMMON); } InputStream inputStream; if (content instanceof InputStream) { inputStream = (InputStream) content; } else if (content instanceof String) { try { inputStream = new ByteArrayInputStream(((String) content).getBytes("UTF-8")); } catch (final UnsupportedEncodingException e) { throw new ODataBadRequestException(ODataBadRequestException.COMMON, e); } } else { throw new ODataBadRequestException(ODataBadRequestException.COMMON); } return inputStream; }
private void initializeContext(ODataContext context, PathInfoExtractor pathInfoExtractor, IServiceInfo gwService) throws ODataException { if (pathInfoExtractor.isMultiOrigin() && pathInfoExtractor.hasOrigin()) { // combination of both is not supported ODataBadRequestException exception = new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED); log.error(exception.getMessage(), exception); gwLogger.logErrors(GatewayLogMessage.CoreRtMultiOriginAndOriginNotSupp, exception.getMessage(), exception.getMessage()); throw exception; } if (pathInfoExtractor.isMultiOrigin()) { context.setParameter(ContextConstants.MULTI_ORIGIN, Boolean.TRUE); } else if (pathInfoExtractor.hasOrigin()) { String origin = pathInfoExtractor.getOrigin(); origin = DestinationInfoUtil.getDestinationForSid(origin, gwService, context); context.setParameter(ContextConstants.ORIGIN, origin); } }
public static <T> InputStream contentAsStream(final T content) throws ODataException { if (content == null) { throw new ODataBadRequestException(ODataBadRequestException.COMMON); } InputStream inputStream; if (content instanceof InputStream) { inputStream = (InputStream) content; } else if (content instanceof String) { try { inputStream = new ByteArrayInputStream(((String) content).getBytes("UTF-8")); } catch (final UnsupportedEncodingException e) { throw new ODataBadRequestException(ODataBadRequestException.COMMON, e); } } else { throw new ODataBadRequestException(ODataBadRequestException.COMMON); } return inputStream; }
ODataBadRequestException exception = new ODataBadRequestException(ODataBadRequestException.COMMON); LoggerFactory.getLogger(GenericODataProcessor.class).error(exception.getMessage(), exception); throw exception;
/** * Validates that <code>dollar format query/syntax</code> is correct for further processing. * If some validation error occurs an exception is thrown. * * @param uriInfo * @throws ODataBadRequestException */ private void validateFormatQuery(final UriInfoImpl uriInfo) throws ODataBadRequestException { if (uriInfo.isValue()) { throw new ODataBadRequestException(ODataBadRequestException.INVALID_SYNTAX); } }
/** * Validates that <code>dollar format query/syntax</code> is correct for further processing. * If some validation error occurs an exception is thrown. * * @param uriInfo * @throws ODataBadRequestException */ private void validateFormatQuery(final UriInfoImpl uriInfo) throws ODataBadRequestException { if (uriInfo.isValue()) { throw new ODataBadRequestException(ODataBadRequestException.INVALID_SYNTAX); } }
/** * Validates that <code>dollar format query/syntax</code> is correct for further processing. * If some validation error occurs an exception is thrown. * * @param uriInfo * @throws ODataBadRequestException */ private void validateFormatQuery(final UriInfoImpl uriInfo) throws ODataBadRequestException { if (uriInfo.isValue()) { throw new ODataBadRequestException(ODataBadRequestException.INVALID_SYNTAX); } }
private List<ContentType> extractAcceptHeaders(final List<String> acceptHeaderValues) throws ODataBadRequestException { final List<ContentType> mediaTypes = new ArrayList<ContentType>(); if (acceptHeaderValues != null) { for (final String mediaType : acceptHeaderValues) { try { mediaTypes.add(ContentType.create(mediaType.toString())); } catch (IllegalArgumentException e) { throw new ODataBadRequestException(ODataBadRequestException.INVALID_HEADER.addContent("Accept") .addContent(mediaType.toString()), e); } } } return mediaTypes; }
private List<ContentType> extractAcceptHeaders(final List<String> acceptHeaderValues) throws ODataBadRequestException { final List<ContentType> mediaTypes = new ArrayList<ContentType>(); if (acceptHeaderValues != null) { for (final String mediaType : acceptHeaderValues) { try { mediaTypes.add(ContentType.create(mediaType.toString())); } catch (IllegalArgumentException e) { throw new ODataBadRequestException(ODataBadRequestException.INVALID_HEADER.addContent("Accept") .addContent(mediaType.toString()), e); } } } return mediaTypes; }
private static void checkNumberOfNavigationSegments(final UriInfoImpl uriInfo) throws ODataException { switch (uriInfo.getUriType()) { case URI1: case URI6B: case URI7A: case URI7B: if (uriInfo.getNavigationSegments().size() > 1) { throw new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED); } break; case URI3: case URI4: case URI5: case URI17: if (!uriInfo.getNavigationSegments().isEmpty()) { throw new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED); } break; default: break; } }
private static void checkNumberOfNavigationSegments(final UriInfoImpl uriInfo) throws ODataException { switch (uriInfo.getUriType()) { case URI1: case URI6B: case URI7A: case URI7B: if (uriInfo.getNavigationSegments().size() > 1) { throw new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED); } break; case URI3: case URI4: case URI5: case URI17: if (!uriInfo.getNavigationSegments().isEmpty()) { throw new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED); } break; default: break; } }
private List<ContentType> extractAcceptHeaders(final List<String> acceptHeaderValues) throws ODataBadRequestException { final List<ContentType> mediaTypes = new ArrayList<ContentType>(); if (acceptHeaderValues != null) { for (final String mediaType : acceptHeaderValues) { try { mediaTypes.add(ContentType.create(mediaType.toString())); } catch (IllegalArgumentException e) { throw new ODataBadRequestException(ODataBadRequestException.INVALID_HEADER.addContent("Accept") .addContent(mediaType.toString()), e); } } } return mediaTypes; }
private static void validateDataServiceVersion(final String serverDataServiceVersion, final String requestDataServiceVersion) throws ODataException { if (requestDataServiceVersion != null) { try { final boolean isValid = ODataServiceVersion.validateDataServiceVersion(requestDataServiceVersion); if (!isValid || ODataServiceVersion.isBiggerThan(requestDataServiceVersion, serverDataServiceVersion)) { throw new ODataBadRequestException(ODataBadRequestException.VERSIONERROR.addContent(requestDataServiceVersion .toString())); } } catch (final IllegalArgumentException e) { throw new ODataBadRequestException(ODataBadRequestException.PARSEVERSIONERROR .addContent(requestDataServiceVersion), e); } } }
private static void checkNumberOfNavigationSegments(final UriInfoImpl uriInfo) throws ODataException { switch (uriInfo.getUriType()) { case URI1: case URI6B: case URI7A: case URI7B: if (uriInfo.getNavigationSegments().size() > 1) { throw new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED); } break; case URI3: case URI4: case URI5: case URI17: if (!uriInfo.getNavigationSegments().isEmpty()) { throw new ODataBadRequestException(ODataBadRequestException.NOTSUPPORTED); } break; default: break; } }
private static void validateDataServiceVersion(final String serverDataServiceVersion, final String requestDataServiceVersion) throws ODataException { if (requestDataServiceVersion != null) { try { final boolean isValid = ODataServiceVersion.validateDataServiceVersion(requestDataServiceVersion); if (!isValid || ODataServiceVersion.isBiggerThan(requestDataServiceVersion, serverDataServiceVersion)) { throw new ODataBadRequestException(ODataBadRequestException.VERSIONERROR .addContent(requestDataServiceVersion)); } } catch (final IllegalArgumentException e) { throw new ODataBadRequestException(ODataBadRequestException.PARSEVERSIONERROR .addContent(requestDataServiceVersion), e); } } }
private static void validateDataServiceVersion(final String serverDataServiceVersion, final String requestDataServiceVersion) throws ODataException { if (requestDataServiceVersion != null) { try { final boolean isValid = ODataServiceVersion.validateDataServiceVersion(requestDataServiceVersion); if (!isValid || ODataServiceVersion.isBiggerThan(requestDataServiceVersion, serverDataServiceVersion)) { throw new ODataBadRequestException(ODataBadRequestException.VERSIONERROR .addContent(requestDataServiceVersion)); } } catch (final IllegalArgumentException e) { throw new ODataBadRequestException(ODataBadRequestException.PARSEVERSIONERROR .addContent(requestDataServiceVersion), e); } } }
} else { if (segments.size() < pathSplit) { throw new ODataBadRequestException(ODataBadRequestException.URLTOOSHORT);
} else { if (segments.size() < pathSplit) { throw new ODataBadRequestException(ODataBadRequestException.URLTOOSHORT);