public static PathInfoImpl buildODataPathInfo(final SubLocatorParameter param) throws ODataException { PathInfoImpl pathInfo = splitPath(param); pathInfo.setServiceRoot(buildBaseUri(param.getServletRequest(), pathInfo.getPrecedingSegments())); pathInfo.setRequestUri(buildRequestUri(param.getServletRequest())); return pathInfo; }
public static ODataSubLocator create(final SubLocatorParameter param) throws ODataException { ODataSubLocator subLocator = new ODataSubLocator(); subLocator.serviceFactory = param.getServiceFactory(); subLocator.request = ODataRequest.acceptableLanguages(param.getHttpHeaders().getAcceptableLanguages()) .acceptHeaders(RestUtil.extractAcceptHeaders(param)) .body(RestUtil.contentAsStream(RestUtil.extractRequestContent(param))) .pathInfo(RestUtil.buildODataPathInfo(param)) .queryParameters(RestUtil.convertToSinglevaluedMap(param.getUriInfo().getQueryParameters())) .requestHeaders(param.getHttpHeaders().getRequestHeaders()) .contentType(RestUtil.extractRequestContentType(param).toContentTypeString()) .build(); subLocator.httpRequest = param.getServletRequest(); return subLocator; }
public static Response convertResponse(final ODataResponse odataResponse) { return convertResponse(odataResponse, false); }
public static Map<String, String> extractRequestHeaders(final javax.ws.rs.core.HttpHeaders httpHeaders) { final MultivaluedMap<String, String> headers = httpHeaders.getRequestHeaders(); Map<String, String> headerMap = new HashMap<String, String>(); for (final String key : headers.keySet()) { String value = getSafeHeader(key, httpHeaders); if (value != null && !"".equals(value)) { headerMap.put(key, value); } } return headerMap; }
pathInfo.setPrecedingPathSegment(convertPathSegmentList(precedingPathSegments));
public static Map<String, String> extractRequestHeaders(final javax.ws.rs.core.HttpHeaders httpHeaders) { final MultivaluedMap<String, String> headers = httpHeaders.getRequestHeaders(); Map<String, String> headerMap = new HashMap<String, String>(); for (final String key : headers.keySet()) { String value = getSafeHeader(key, httpHeaders); if (value != null && !"".equals(value)) { headerMap.put(key, value); } } return headerMap; }
pathInfo.setPrecedingPathSegment(convertPathSegmentList(precedingPathSegments));
public static ODataSubLocator create(final SubLocatorParameter param) throws ODataException { ODataSubLocator subLocator = new ODataSubLocator(); subLocator.serviceFactory = param.getServiceFactory(); subLocator.request = ODataRequest.acceptableLanguages(param.getHttpHeaders().getAcceptableLanguages()) .httpMethod(param.getServletRequest().getMethod()) .acceptHeaders(RestUtil.extractAcceptHeaders(param)) .body(RestUtil.contentAsStream(RestUtil.extractRequestContent(param))) .pathInfo(RestUtil.buildODataPathInfo(param)) .allQueryParameters(param.getUriInfo().getQueryParameters()) .requestHeaders(param.getHttpHeaders().getRequestHeaders()) .contentType(RestUtil.extractRequestContentType(param).toContentTypeString()) .build(); subLocator.httpRequest = param.getServletRequest(); return subLocator; }
public static PathInfoImpl buildODataPathInfo(final SubLocatorParameter param) throws ODataException { PathInfoImpl pathInfo = splitPath(param); pathInfo.setServiceRoot(buildBaseUri(param.getUriInfo(), param.getServletRequest(), pathInfo.getPrecedingSegments())); pathInfo.setRequestUri(buildRequestUri(param.getServletRequest())); return pathInfo; }
public static Response convertResponse(final ODataResponse odataResponse) { return convertResponse(odataResponse, false); }
public static Map<String, String> extractRequestHeaders(final javax.ws.rs.core.HttpHeaders httpHeaders) { final MultivaluedMap<String, String> headers = httpHeaders.getRequestHeaders(); Map<String, String> headerMap = new HashMap<String, String>(); for (final String key : headers.keySet()) { String value = getSafeHeader(key, httpHeaders); if (value != null && !"".equals(value)) { headerMap.put(key, value); } } return headerMap; }
pathInfo.setPrecedingPathSegment(convertPathSegmentList(precedingPathSegments));
public static ODataSubLocator create(final SubLocatorParameter param) throws ODataException { ODataSubLocator subLocator = new ODataSubLocator(); subLocator.serviceFactory = param.getServiceFactory(); subLocator.request = ODataRequest.acceptableLanguages(param.getHttpHeaders().getAcceptableLanguages()) .httpMethod(param.getServletRequest().getMethod()) .acceptHeaders(RestUtil.extractAcceptHeaders(param)) .body(RestUtil.contentAsStream(RestUtil.extractRequestContent(param))) .pathInfo(RestUtil.buildODataPathInfo(param)) .allQueryParameters(param.getUriInfo().getQueryParameters()) .requestHeaders(param.getHttpHeaders().getRequestHeaders()) .contentType(RestUtil.extractRequestContentType(param).toContentTypeString()) .build(); subLocator.httpRequest = param.getServletRequest(); return subLocator; }
public static PathInfoImpl buildODataPathInfo(final SubLocatorParameter param) throws ODataException { PathInfoImpl pathInfo = splitPath(param); pathInfo.setServiceRoot(buildBaseUri(param.getUriInfo(), param.getServletRequest(), pathInfo.getPrecedingSegments())); pathInfo.setRequestUri(buildRequestUri(param.getServletRequest())); return pathInfo; }
@Override public Response toResponse(final Exception exception) { ODataResponse response; try { if (exception instanceof WebApplicationException) { response = handleWebApplicationException(exception); } else { response = handleException(exception); } } catch (Exception e) { response = ODataResponse.entity("Exception during error handling occured!") .contentHeader(ContentType.TEXT_PLAIN.toContentTypeString()) .status(HttpStatusCodes.INTERNAL_SERVER_ERROR).build(); } // Convert OData response to JAX-RS response. return RestUtil.convertResponse(response); }
public static ContentType extractRequestContentType(final SubLocatorParameter param) throws ODataUnsupportedMediaTypeException { String contentType = getSafeHeader(HttpHeaders.CONTENT_TYPE, param.getHttpHeaders()); if (contentType == null || contentType.isEmpty()) { // RFC 2616, 7.2.1: // "Any HTTP/1.1 message containing an entity-body SHOULD include a // Content-Type header field defining the media type of that body. [...] // If the media type remains unknown, the recipient SHOULD treat it // as type "application/octet-stream"." return ContentType.APPLICATION_OCTET_STREAM; } else if (ContentType.isParseable(contentType)) { return ContentType.create(contentType); } else { throw new ODataUnsupportedMediaTypeException( ODataUnsupportedMediaTypeException.NOT_SUPPORTED_CONTENT_TYPE.addContent(contentType)); } }
@Override public Response toResponse(final Exception exception) { ODataResponse response; try { if (exception instanceof WebApplicationException) { response = handleWebApplicationException(exception); } else { response = handleException(exception); } } catch (Exception e) { response = ODataResponse.entity("Exception during error handling occured!") .contentHeader(ContentType.TEXT_PLAIN.toContentTypeString()) .status(HttpStatusCodes.INTERNAL_SERVER_ERROR).build(); } // Convert OData response to JAX-RS response. return RestUtil.convertResponse(response); }
public static ContentType extractRequestContentType(final SubLocatorParameter param) throws ODataUnsupportedMediaTypeException { String contentType = getSafeHeader(HttpHeaders.CONTENT_TYPE, param.getHttpHeaders()); if (contentType == null || contentType.isEmpty()) { // RFC 2616, 7.2.1: // "Any HTTP/1.1 message containing an entity-body SHOULD include a // Content-Type header field defining the media type of that body. [...] // If the media type remains unknown, the recipient SHOULD treat it // as type "application/octet-stream"." return ContentType.APPLICATION_OCTET_STREAM; } else if (ContentType.isParseable(contentType)) { return ContentType.create(contentType); } else { throw new ODataUnsupportedMediaTypeException( ODataUnsupportedMediaTypeException.NOT_SUPPORTED_CONTENT_TYPE.addContent(contentType)); } }
@Override public Response toResponse(final Exception exception) { ODataResponse response; try { if (exception instanceof WebApplicationException) { response = handleWebApplicationException(exception); } else { response = handleException(exception); } } catch (Exception e) { response = ODataResponse.entity("Exception during error handling occured!") .contentHeader(ContentType.TEXT_PLAIN.toContentTypeString()) .status(HttpStatusCodes.INTERNAL_SERVER_ERROR).build(); } // Convert OData response to JAX-RS response. return RestUtil.convertResponse(response); }
public static ContentType extractRequestContentType(final SubLocatorParameter param) throws ODataUnsupportedMediaTypeException { String contentType = getSafeHeader(HttpHeaders.CONTENT_TYPE, param.getHttpHeaders()); if (contentType == null || contentType.isEmpty()) { // RFC 2616, 7.2.1: // "Any HTTP/1.1 message containing an entity-body SHOULD include a // Content-Type header field defining the media type of that body. [...] // If the media type remains unknown, the recipient SHOULD treat it // as type "application/octet-stream"." return ContentType.APPLICATION_OCTET_STREAM; } else if (ContentType.isParseable(contentType)) { return ContentType.create(contentType); } else { throw new ODataUnsupportedMediaTypeException( ODataUnsupportedMediaTypeException.NOT_SUPPORTED_CONTENT_TYPE.addContent(contentType)); } }