List of usage examples for org.springframework.http HttpHeaders add
@Override public void add(String headerName, @Nullable String headerValue)
From source file:ua.aits.Carpath.controller.AjaxController.java
@RequestMapping(value = { "/filter_by_country_routes", "/Carpath/filter_by_country_routes" }, method = RequestMethod.GET) public @ResponseBody ResponseEntity<String> routes_content_filter(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setCharacterEncoding("UTF-8"); String lan = request.getParameter("lan"); String country = request.getParameter("country"); String page_type = request.getParameter("page_type"); String menu_id = request.getParameter("menu_id"); String type = request.getParameter("type"); System.out.println("lan = " + lan); System.out.println("country = " + country); List<RouteModel> tempR = routes.get_routes_by_country_filter(lan, country, type); Integer items_count = routes.get_count_routes_by_country_filter(lan, country, type); String returnHTML = ""; Integer loop = 0;// w ww . j a v a2s .co m String files_array = ""; //files_array = "["; System.out.println("items_count = " + items_count); for (RouteModel route : tempR) { returnHTML = returnHTML + "<div class=\"s-cell\">\n" + " <div class=\"s-block newsHeight\">\n" + " <div class=\"newsImage\">\n" + " <a href=\"" + Constants.URL + lan + "/routes/" + route.id + "\">\n" + " <div class=\"imageHover\">\n" + " <div class=\"imageHoverDate\">\n" + " " + route.date + "\n" + " </div>\n" + " <div class=\"imageHoverCountry\">\n" + " <div class=\"newsCountryText\">" + route.public_country + "</div><img src=\"" + Constants.URL + "img/newsImageHover.png\">\n" + " </div>\n" + " <div class=\"routeType\" id=\"type" + loop + "\"></div>\n" + " <div class=\"routeType\" id=\"category" + loop + "\"></div>\n" + " </div>\n" + " <div class=\"routesListMap\" id=\"map" + loop + "\"></div>\n" + " </a>\n" + " </div>\n" + " <img class=\"newsImageUnderline\" src=\"" + Constants.URL + "img/newsLine.png\">\n" + " <div class=\"news_text_box\">\n" + " <div class=\"news_title\"><a href=\"" + Constants.URL + "routes/" + route.id + "\">" + route.title + "</a></div>\n" + " <a href=\"" + Constants.URL + "routes/" + route.id + "\">\n" + " <div class=\"news_text\">" + route.textUA + "</div>\n" + " </a>\n" + " </div>\n" + " </div>\n" + " </div> "; files_array = files_array + route.file; if (items_count - 1 > loop) { files_array = files_array + ","; } System.out.println("loop = " + loop); loop++; } //files_array = files_array + "]"; System.out.println(files_array); returnHTML = returnHTML + "<input type=\"hidden\" id=\"file_array\" value=\"" + files_array + "\"/> "; //System.out.println("========================================"+returnHTML+"========================================"); HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.add("Content-Type", "application/json; charset=utf-8"); return new ResponseEntity<>(returnHTML, responseHeaders, HttpStatus.CREATED); //return returnHTML; }
From source file:ua.aits.Carpath.controller.AjaxController.java
@RequestMapping(value = { "/filter_by_type_routes", "/Carpath/filter_by_type_routes" }, method = RequestMethod.GET) public @ResponseBody ResponseEntity<String> routes_type_filter(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setCharacterEncoding("UTF-8"); String lan = request.getParameter("lan"); String country = request.getParameter("country"); String page_type = request.getParameter("page_type"); String menu_id = request.getParameter("menu_id"); String type = request.getParameter("type"); System.out.println("lan = " + lan); System.out.println("country = " + country); List<RouteModel> tempR = routes.get_routes_by_country_filter(lan, country, type); Integer items_count = routes.get_count_routes_by_country_filter(lan, country, type); String returnHTML = ""; Integer loop = 0;//from w ww.ja v a 2 s.c o m String files_array = ""; //files_array = "["; System.out.println("items_count = " + items_count); for (RouteModel route : tempR) { returnHTML = returnHTML + "<div class=\"s-cell\">\n" + " <div class=\"s-block newsHeight\">\n" + " <div class=\"newsImage\">\n" + " <a href=\"" + Constants.URL + lan + "routes/" + route.id + "\">\n" + " <div class=\"imageHover\">\n" + " <div class=\"imageHoverDate\">\n" + " " + route.date + "\n" + " </div>\n" + " <div class=\"imageHoverCountry\">\n" + " <div class=\"newsCountryText\">" + route.public_country + "</div><img src=\"" + Constants.URL + "img/newsImageHover.png\">\n" + " </div>\n" + " <div class=\"routeType\" id=\"type" + loop + "\"></div>\n" + " <div class=\"routeType\" id=\"category" + loop + "\"></div>\n" + " </div>\n" + " <div class=\"routesListMap\" id=\"map" + loop + "\"></div>\n" + " </a>\n" + " </div>\n" + " <img class=\"newsImageUnderline\" src=\"" + Constants.URL + "img/newsLine.png\">\n" + " <div class=\"news_text_box\">\n" + " <div class=\"news_title\"><a href=\"" + Constants.URL + lan + "/routes/" + route.id + "\">" + route.title + "</a></div>\n" + " <a href=\"" + Constants.URL + lan + "/routes/" + route.id + "\">\n" + " <div class=\"news_text\">" + route.textUA + "</div>\n" + " </a>\n" + " </div>\n" + " </div>\n" + " </div> "; files_array = files_array + route.file; if (items_count - 1 > loop) { files_array = files_array + ","; } System.out.println("loop = " + loop); loop++; } //files_array = files_array + "]"; System.out.println(files_array); returnHTML = returnHTML + "<input type=\"hidden\" id=\"file_array\" value=\"" + files_array + "\"/> "; //System.out.println("========================================"+returnHTML+"========================================"); HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.add("Content-Type", "application/json; charset=utf-8"); return new ResponseEntity<>(returnHTML, responseHeaders, HttpStatus.CREATED); //return returnHTML; }
From source file:uk.co.jassoft.markets.api.SystemController.java
@PreAuthorize("hasRole('ROLE_ADMIN')") @RequestMapping(value = "/queues", method = RequestMethod.GET) public @ResponseBody List<String> getQueues(final HttpServletResponse response) throws IOException { response.setHeader("Cache-Control", "no-cache"); // http://activemq.apache.org/jmx.html // http://localhost:32783/api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost String plainCreds = "admin:admin"; byte[] plainCredsBytes = plainCreds.getBytes(); byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes); String base64Creds = new String(base64CredsBytes); HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Basic " + base64Creds); String url = String.format( "http://%s:%s/api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost", activeMQHost, activeMQPort);/*from www .ja va2 s. com*/ LOG.info("Requesting Queues from url [{}]", url); HttpEntity<String> request = new HttpEntity<String>(headers); ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, String.class); JsonNode root = mapper.readTree(responseEntity.getBody()); JsonNode queues = root.get("value").get("Queues"); List<String> objectnames = queues.findValuesAsText("objectName"); return objectnames.parallelStream() .map(objectname -> objectname .replace("org.apache.activemq:brokerName=localhost,destinationName=", "") .replace(",destinationType=Queue,type=Broker", "")) .collect(Collectors.toList()); }
From source file:uk.co.jassoft.markets.api.SystemController.java
@PreAuthorize("hasRole('ROLE_ADMIN')") @RequestMapping(value = "/queue/{destinationType}/{destinationName}", method = RequestMethod.GET) public @ResponseBody Map<String, Object> getQueueStats(final HttpServletResponse response, @PathVariable String destinationType, @PathVariable String destinationName) throws IOException { response.setHeader("Cache-Control", "no-cache"); String plainCreds = "admin:admin"; byte[] plainCredsBytes = plainCreds.getBytes(); byte[] base64CredsBytes = Base64.encodeBase64(plainCredsBytes); String base64Creds = new String(base64CredsBytes); HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Basic " + base64Creds); String url = String.format( "http://%s:%s/api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost,destinationName=%s,destinationType=%s", activeMQHost, activeMQPort, destinationName, destinationType); LOG.info("Requesting Queue Stats from url [{}]", url); HttpEntity<String> request = new HttpEntity<String>(headers); ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, String.class); JsonNode root = mapper.readTree(responseEntity.getBody()); JsonNode queue = root.get("value"); if (queue == null) { return new HashMap<>(); }/*w w w . j ava2s . c om*/ return mapper.convertValue(queue, Map.class); }