@Test public void extractUriForController() { String [][] uris = { { "http: { "http: { "http: { "http: { "http: { "http: { "http: { "http: { "http: { "http: { "http: }; for (String[] p : uris) { HttpServletRequest hr = mock(HttpServletRequest.class); String requestUrl = p[0] + p[1] + p[2] + p[3] + p[4]; String requestUri = p[1] + p[2] + p[3] + p[4]; String queryString = p[5].isEmpty() ? null : p[5]; when(hr.getRequestURL()).thenReturn(new StringBuffer(requestUrl)); when(hr.getRequestURI()).thenReturn(requestUri); when(hr.getQueryString()).thenReturn(queryString); when(hr.getContextPath()).thenReturn(p[1]); when(hr.getServletPath()).thenReturn(p[2]); ODataRequest odr = new ODataRequest(); String rawBaseUri = p[0] + p[1] + p[2] + p[3]; String rawODataPath = p[4]; String rawQueryPath = "".equals(p[5]) ? null : p[5]; String rawRequestUri = requestUrl + (queryString == null ? "" : "?" + queryString); String rawServiceResolutionUri = ("0".equals(p[6])) ? p[2] : p[3]; when(hr.getAttribute("requestMapping")).thenReturn(p[2]); ODataHttpHandlerImpl.fillUriInformation(odr, hr, Integer.parseInt(p[6])); assertEquals(rawBaseUri, odr.getRawBaseUri()); assertEquals(rawODataPath, odr.getRawODataPath()); assertEquals(rawQueryPath, odr.getRawQueryPath()); assertEquals(rawRequestUri, odr.getRawRequestUri()); assertEquals(rawServiceResolutionUri, odr.getRawServiceResolutionUri()); } }
static void fillUriInformation(final ODataRequest odRequest, final HttpServletRequest httpRequest, final int split) { String rawRequestUri = httpRequest.getRequestURL().toString(); String rawServiceResolutionUri = null; String rawODataPath; if(httpRequest.getAttribute(REQUESTMAPPING)!=null){ String requestMapping = httpRequest.getAttribute(REQUESTMAPPING).toString(); rawServiceResolutionUri = requestMapping; int beginIndex = rawRequestUri.indexOf(requestMapping) + requestMapping.length(); rawODataPath = rawRequestUri.substring(beginIndex); }else if(!"".equals(httpRequest.getServletPath())) { int beginIndex = rawRequestUri.indexOf(httpRequest.getServletPath()) + httpRequest.getServletPath().length(); rawODataPath = rawRequestUri.substring(beginIndex); } else if (!"".equals(httpRequest.getContextPath())) { int beginIndex = rawRequestUri.indexOf(httpRequest.getContextPath()) + httpRequest.getContextPath().length(); rawODataPath = rawRequestUri.substring(beginIndex); } else { rawODataPath = httpRequest.getRequestURI(); } if (split > 0) { rawServiceResolutionUri = rawODataPath; for (int i = 0; i < split; i++) { int index = rawODataPath.indexOf('/', 1); if (-1 == index) { rawODataPath = ""; break; } else { rawODataPath = rawODataPath.substring(index); } } int end = rawServiceResolutionUri.length() - rawODataPath.length(); rawServiceResolutionUri = rawServiceResolutionUri.substring(0, end); } String rawBaseUri = rawRequestUri.substring(0, rawRequestUri.length() - rawODataPath.length()); odRequest.setRawQueryPath(httpRequest.getQueryString()); odRequest.setRawRequestUri(rawRequestUri + (httpRequest.getQueryString() == null ? "" : "?" + httpRequest.getQueryString())); odRequest.setRawODataPath(rawODataPath); odRequest.setRawBaseUri(rawBaseUri); odRequest.setRawServiceResolutionUri(rawServiceResolutionUri); }
ODataHttpHandlerImpl implements ODataHttpHandler { static void fillUriInformation(final ODataRequest odRequest, final HttpServletRequest httpRequest, final int split) { String rawRequestUri = httpRequest.getRequestURL().toString(); String rawServiceResolutionUri = null; String rawODataPath; if(httpRequest.getAttribute(REQUESTMAPPING)!=null){ String requestMapping = httpRequest.getAttribute(REQUESTMAPPING).toString(); rawServiceResolutionUri = requestMapping; int beginIndex = rawRequestUri.indexOf(requestMapping) + requestMapping.length(); rawODataPath = rawRequestUri.substring(beginIndex); }else if(!"".equals(httpRequest.getServletPath())) { int beginIndex = rawRequestUri.indexOf(httpRequest.getServletPath()) + httpRequest.getServletPath().length(); rawODataPath = rawRequestUri.substring(beginIndex); } else if (!"".equals(httpRequest.getContextPath())) { int beginIndex = rawRequestUri.indexOf(httpRequest.getContextPath()) + httpRequest.getContextPath().length(); rawODataPath = rawRequestUri.substring(beginIndex); } else { rawODataPath = httpRequest.getRequestURI(); } if (split > 0) { rawServiceResolutionUri = rawODataPath; for (int i = 0; i < split; i++) { int index = rawODataPath.indexOf('/', 1); if (-1 == index) { rawODataPath = ""; break; } else { rawODataPath = rawODataPath.substring(index); } } int end = rawServiceResolutionUri.length() - rawODataPath.length(); rawServiceResolutionUri = rawServiceResolutionUri.substring(0, end); } String rawBaseUri = rawRequestUri.substring(0, rawRequestUri.length() - rawODataPath.length()); odRequest.setRawQueryPath(httpRequest.getQueryString()); odRequest.setRawRequestUri(rawRequestUri + (httpRequest.getQueryString() == null ? "" : "?" + httpRequest.getQueryString())); odRequest.setRawODataPath(rawODataPath); odRequest.setRawBaseUri(rawBaseUri); odRequest.setRawServiceResolutionUri(rawServiceResolutionUri); } }
ODataHttpHandlerImpl implements ODataHttpHandler { static void fillUriInformation(final ODataRequest odRequest, final HttpServletRequest httpRequest, final int split) { String rawRequestUri = httpRequest.getRequestURL().toString(); String rawServiceResolutionUri = null; String rawODataPath; if(httpRequest.getAttribute(REQUESTMAPPING)!=null){ String requestMapping = httpRequest.getAttribute(REQUESTMAPPING).toString(); rawServiceResolutionUri = requestMapping; int beginIndex = rawRequestUri.indexOf(requestMapping) + requestMapping.length(); rawODataPath = rawRequestUri.substring(beginIndex); }else if(!"".equals(httpRequest.getServletPath())) { int beginIndex = rawRequestUri.indexOf(httpRequest.getServletPath()) + httpRequest.getServletPath().length(); rawODataPath = rawRequestUri.substring(beginIndex); } else if (!"".equals(httpRequest.getContextPath())) { int beginIndex = rawRequestUri.indexOf(httpRequest.getContextPath()) + httpRequest.getContextPath().length(); rawODataPath = rawRequestUri.substring(beginIndex); } else { rawODataPath = httpRequest.getRequestURI(); } if (split > 0) { rawServiceResolutionUri = rawODataPath; for (int i = 0; i < split; i++) { int index = rawODataPath.indexOf('/', 1); if (-1 == index) { rawODataPath = ""; break; } else { rawODataPath = rawODataPath.substring(index); } } int end = rawServiceResolutionUri.length() - rawODataPath.length(); rawServiceResolutionUri = rawServiceResolutionUri.substring(0, end); } String rawBaseUri = rawRequestUri.substring(0, rawRequestUri.length() - rawODataPath.length()); odRequest.setRawQueryPath(httpRequest.getQueryString()); odRequest.setRawRequestUri(rawRequestUri + (httpRequest.getQueryString() == null ? "" : "?" + httpRequest.getQueryString())); odRequest.setRawODataPath(rawODataPath); odRequest.setRawBaseUri(rawBaseUri); odRequest.setRawServiceResolutionUri(rawServiceResolutionUri); } ODataHttpHandlerImpl(final OData odata, final ServiceMetadata serviceMetadata); }
ODataHttpHandlerImpl implements ODataHttpHandler { static void fillUriInformation(final ODataRequest odRequest, final HttpServletRequest httpRequest, final int split) { String rawRequestUri = httpRequest.getRequestURL().toString(); String rawServiceResolutionUri = null; String rawODataPath; if(httpRequest.getAttribute(REQUESTMAPPING)!=null){ String requestMapping = httpRequest.getAttribute(REQUESTMAPPING).toString(); rawServiceResolutionUri = requestMapping; int beginIndex = rawRequestUri.indexOf(requestMapping) + requestMapping.length(); rawODataPath = rawRequestUri.substring(beginIndex); }else if(!"".equals(httpRequest.getServletPath())) { int beginIndex = rawRequestUri.indexOf(httpRequest.getServletPath()) + httpRequest.getServletPath().length(); rawODataPath = rawRequestUri.substring(beginIndex); } else if (!"".equals(httpRequest.getContextPath())) { int beginIndex = rawRequestUri.indexOf(httpRequest.getContextPath()) + httpRequest.getContextPath().length(); rawODataPath = rawRequestUri.substring(beginIndex); } else { rawODataPath = httpRequest.getRequestURI(); } if (split > 0) { rawServiceResolutionUri = rawODataPath; for (int i = 0; i < split; i++) { int index = rawODataPath.indexOf('/', 1); if (-1 == index) { rawODataPath = ""; break; } else { rawODataPath = rawODataPath.substring(index); } } int end = rawServiceResolutionUri.length() - rawODataPath.length(); rawServiceResolutionUri = rawServiceResolutionUri.substring(0, end); } String rawBaseUri = rawRequestUri.substring(0, rawRequestUri.length() - rawODataPath.length()); odRequest.setRawQueryPath(httpRequest.getQueryString()); odRequest.setRawRequestUri(rawRequestUri + (httpRequest.getQueryString() == null ? "" : "?" + httpRequest.getQueryString())); odRequest.setRawODataPath(rawODataPath); odRequest.setRawBaseUri(rawBaseUri); odRequest.setRawServiceResolutionUri(rawServiceResolutionUri); } ODataHttpHandlerImpl(final OData odata, final ServiceMetadata serviceMetadata); @Override ODataResponse process(ODataRequest request); @Override void process(final HttpServletRequest request, final HttpServletResponse response); @Override void setSplit(final int split); @Override void register(final Processor processor); @Override void register(OlingoExtension extension); @Override void register(final CustomContentTypeSupport customContentTypeSupport); @Override void register(final CustomETagSupport customConcurrencyControlSupport); @Override void register(final DebugSupport debugSupport); }
ODataHttpHandlerImpl implements ODataHttpHandler { static void fillUriInformation(final ODataRequest odRequest, final HttpServletRequest httpRequest, final int split) { String rawRequestUri = httpRequest.getRequestURL().toString(); String rawServiceResolutionUri = null; String rawODataPath; if(httpRequest.getAttribute(REQUESTMAPPING)!=null){ String requestMapping = httpRequest.getAttribute(REQUESTMAPPING).toString(); rawServiceResolutionUri = requestMapping; int beginIndex = rawRequestUri.indexOf(requestMapping) + requestMapping.length(); rawODataPath = rawRequestUri.substring(beginIndex); }else if(!"".equals(httpRequest.getServletPath())) { int beginIndex = rawRequestUri.indexOf(httpRequest.getServletPath()) + httpRequest.getServletPath().length(); rawODataPath = rawRequestUri.substring(beginIndex); } else if (!"".equals(httpRequest.getContextPath())) { int beginIndex = rawRequestUri.indexOf(httpRequest.getContextPath()) + httpRequest.getContextPath().length(); rawODataPath = rawRequestUri.substring(beginIndex); } else { rawODataPath = httpRequest.getRequestURI(); } if (split > 0) { rawServiceResolutionUri = rawODataPath; for (int i = 0; i < split; i++) { int index = rawODataPath.indexOf('/', 1); if (-1 == index) { rawODataPath = ""; break; } else { rawODataPath = rawODataPath.substring(index); } } int end = rawServiceResolutionUri.length() - rawODataPath.length(); rawServiceResolutionUri = rawServiceResolutionUri.substring(0, end); } String rawBaseUri = rawRequestUri.substring(0, rawRequestUri.length() - rawODataPath.length()); odRequest.setRawQueryPath(httpRequest.getQueryString()); odRequest.setRawRequestUri(rawRequestUri + (httpRequest.getQueryString() == null ? "" : "?" + httpRequest.getQueryString())); odRequest.setRawODataPath(rawODataPath); odRequest.setRawBaseUri(rawBaseUri); odRequest.setRawServiceResolutionUri(rawServiceResolutionUri); } ODataHttpHandlerImpl(final OData odata, final ServiceMetadata serviceMetadata); @Override ODataResponse process(ODataRequest request); @Override void process(final HttpServletRequest request, final HttpServletResponse response); @Override void setSplit(final int split); @Override void register(final Processor processor); @Override void register(OlingoExtension extension); @Override void register(final CustomContentTypeSupport customContentTypeSupport); @Override void register(final CustomETagSupport customConcurrencyControlSupport); @Override void register(final DebugSupport debugSupport); static final int COPY_BUFFER_SIZE; }