use of org.springframework.web.context.request.ServletRequestAttributes in project com.revolsys.open by revolsys.
the class HtmlUiBuilder method getRequest.
public static HttpServletRequest getRequest() {
final ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
final HttpServletRequest request = requestAttributes.getRequest();
return request;
}
use of org.springframework.web.context.request.ServletRequestAttributes in project commons by craftercms.
the class GDataPropertyFilter method checkProperty.
protected boolean checkProperty(final String propertyName) {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
Object attributes = request.getParameter(selectorParameterName);
if (attributes == null) {
return true;
} else {
List<String> query = parseRequestSelector(attributes.toString());
if (query == null || query.isEmpty()) {
log.warn("Result of parsing selector {} is null or empty ignoring selector", attributes);
return true;
} else {
return checkPropertyAgainstPattern(query, propertyName);
}
}
}
use of org.springframework.web.context.request.ServletRequestAttributes in project molgenis by molgenis.
the class MolgenisUiUtilsTest method getCurrentUri.
@Test
public void getCurrentUri() {
String uri = "/menu/test";
String queryString = "a=b&c=d";
MockHttpServletRequest request = new MockHttpServletRequest();
request.setAttribute("javax.servlet.forward.request_uri", uri);
request.setQueryString(queryString);
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
String currentUri = MolgenisUiUtils.getCurrentUri();
assertNotNull(currentUri);
assertEquals(currentUri, uri + "?" + queryString);
request.setQueryString(null);
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
currentUri = MolgenisUiUtils.getCurrentUri();
assertNotNull(currentUri);
assertEquals(currentUri, uri);
}
use of org.springframework.web.context.request.ServletRequestAttributes in project molgenis by molgenis.
the class SwaggerControllerTest method testInit.
@Test
@WithMockUser
public void testInit() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
when(tokenService.generateAndStoreToken("user", "For Swagger UI")).thenReturn("ABCDEFG");
assertEquals("view-swagger-ui", swaggerController.init(model));
verify(model).addAttribute("molgenisUrl", "http://localhost/plugin/swagger/swagger.yml");
verify(model).addAttribute("baseUrl", "http://localhost");
verify(model).addAttribute("token", "ABCDEFG");
verifyNoMoreInteractions(model);
}
use of org.springframework.web.context.request.ServletRequestAttributes in project molgenis by molgenis.
the class SwaggerControllerTest method testInitWithoutUser.
@Test
public void testInitWithoutUser() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
assertEquals("view-swagger-ui", swaggerController.init(model));
verify(model).addAttribute("molgenisUrl", "http://localhost/plugin/swagger/swagger.yml");
verify(model).addAttribute("baseUrl", "http://localhost");
verifyNoMoreInteractions(model);
}
Aggregations