/** * Handles requests with message handler implementation. Previously sets Http request method as * header parameter. * * @param method * @param requestEntity * @return */ private ResponseEntity<String> handleRequestInternal( HttpMethod method, HttpEntity<String> requestEntity) { Map<String, ?> httpRequestHeaders = headerMapper.toHeaders(requestEntity.getHeaders()); Map<String, String> customHeaders = new HashMap<String, String>(); for (Entry<String, List<String>> header : requestEntity.getHeaders().entrySet()) { if (!httpRequestHeaders.containsKey(header.getKey())) { customHeaders.put( header.getKey(), StringUtils.collectionToCommaDelimitedString(header.getValue())); } } HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); UrlPathHelper pathHelper = new UrlPathHelper(); customHeaders.put(CitrusHttpMessageHeaders.HTTP_REQUEST_URI, pathHelper.getRequestUri(request)); customHeaders.put( CitrusHttpMessageHeaders.HTTP_CONTEXT_PATH, pathHelper.getContextPath(request)); String queryParams = pathHelper.getOriginatingQueryString(request); customHeaders.put( CitrusHttpMessageHeaders.HTTP_QUERY_PARAMS, queryParams != null ? queryParams : ""); customHeaders.put(CitrusHttpMessageHeaders.HTTP_REQUEST_METHOD, method.toString()); Message<?> response = messageHandler.handleMessage( MessageBuilder.withPayload(requestEntity.getBody()) .copyHeaders(convertHeaderTypes(httpRequestHeaders)) .copyHeaders(customHeaders) .build()); return generateResponse(response); }
@ModelAttribute("poolSettings") public PoolSettings getPoolSettings( /*@PathVariable("accountId") Long accountId, @PathVariable("poolId") Long poolId */ HttpServletRequest request) { // return getAccountPool( accountId, poolId ).getPoolSettings(); Map pathVariables = (Map) request.getAttribute( "org.springframework.web.servlet.HandlerMapping.uriTemplateVariables"); if (pathVariables.containsKey("accountId") && pathVariables.containsKey("poolId")) { long accountId = Long.parseLong((String) pathVariables.get("accountId")); long poolId = Long.parseLong((String) pathVariables.get("poolId")); return poolDao.readPoolByIdAndAccountId(poolId, accountId).getPoolSettings(); } else { return null; } }
/** * Only for internal use * * <p>Count total for each control * * @param strArray * @param adminJdbcService * @return */ private static Map countStringOccurences(String[] strArray, AdminJdbcService adminJdbcService) { logger.debug("Count String Occurences method found"); Map<String, Integer> countMap = new TreeMap<String, Integer>(); Map<String, Integer> controlIdsMap = new TreeMap<String, Integer>(); Set<String> controlIdsSet = new TreeSet<String>(); Set<String> keySet = countMap.keySet(); List list = new ArrayList(); for (String string : strArray) { String control[] = string.split(":"); if (!Utils.isNullOrEmpty(control[1]) && Integer.parseInt(control[1].trim()) == 2) { if (!countMap.containsKey(control[0])) { countMap.put(control[0], 1); } else { Integer count = countMap.get(control[0]); count = count + 1; countMap.put(control[0], count); } } } return countMap; }