List of usage examples for javax.servlet.http HttpServletRequest getRemoteHost
public String getRemoteHost();
From source file:siddur.solidtrust.site.APIController.java
@RequestMapping(value = "/extenddata") public @ResponseBody Object extendCarData(@RequestParam("id") String id, HttpServletRequest request) { AccessItem ai = new AccessItem(); ai.setIp(request.getRemoteHost()); ai.setUsername(request.getAttribute(SolidtrustConstants.CLIENT_ID) + ""); ai.setService(Product.EXTEND_CAR_DATA.getId()); ai.setRequest(id);//ww w . j a v a 2 s. c o m Car car = null; try { car = carService.findCar(id); } catch (Exception e) { ai.setStatus(-1); log4j.error(e.getMessage(), e); ai.setResponse(e.getMessage()); } Map<String, String> map = null; if (car != null) { map = new HashMap<String, String>(2); String rear = car.getRearTiresize(); String front = car.getFrontTiresize(); String si = car.getServiceIntervals(); map.put("frontTiresize", StringUtils.isEmpty(si) ? "no-info" : front); map.put("rearTiresize", StringUtils.isEmpty(rear) ? "no-info" : rear); map.put("serviceIntervals", StringUtils.isEmpty(si) ? "no-info" : si); ai.setResponse(rear + "," + si); } else { ai.setResponse("no data"); } free.save(ai); if (map == null) { return "no data"; } return map; }
From source file:org.n52.v3d.terrainserver.povraywts.WebTerrainServlet.java
private void logErrorInfo(String pTmpName, T3dTimeList pTimeProt, HttpServletRequest pRequest, Throwable pExc) { try {// w w w .j av a 2 s.c om PrintWriter lDat = new PrintWriter(new FileWriter(mWorkingDirectory + "/" + pTmpName + ".log")); lDat.println("REMOTE HOST: " + pRequest.getRemoteHost()); lDat.println("REMOTE ADDRESS: " + pRequest.getRemoteAddr()); //lDat.println("REMOTE USER: " + pRequest.getRemoteUser()); lDat.println("QUERY STRING: " + pRequest.getQueryString()); lDat.println("SESSION-ID: " + pRequest.getRequestedSessionId()); lDat.println("PROCESSING_TIMES [msec]: "); String[] lTimeProtStr = pTimeProt.protocol(); for (int i = 0; i < lTimeProtStr.length; i++) lDat.println(lTimeProtStr[i]); lDat.println("ERROR: " + pExc.getMessage()); lDat.println("STACK TRACE: "); pExc.printStackTrace(lDat); lDat.close(); } catch (IOException e) { throw new T3dException(e.getMessage()); } }
From source file:siddur.solidtrust.site.APIController.java
@RequestMapping(value = "/stadagen") public @ResponseBody Object stadagen(@RequestParam("id") String id, HttpServletRequest request) throws Exception { AccessItem ai = new AccessItem(); ai.setIp(request.getRemoteHost()); ai.setUsername(request.getAttribute(SolidtrustConstants.CLIENT_ID) + ""); ai.setService(Product.STADAGEN.getId()); AzureCar entity = azureService.findByLicensePlate(id); String brand = entity.getBrand(); String model = entity.getType(); @SuppressWarnings("deprecation") String build = (entity.getDateOfBuild().getYear() + 1900) + ""; ai.setRequest(id);// www .j a v a 2s .c om int avgDays = mService.averageTimeOnSaleByLucene2(brand, model, build); if (avgDays == 0) { ai.setStatus(0); } ai.setResponse(avgDays + " days"); free.save(ai); return avgDays; }
From source file:siddur.solidtrust.site.APIController.java
@RequestMapping(value = "/car_company_review2") public @ResponseBody Object review(@RequestParam("id") String id, HttpServletRequest request) { AccessItem ai = new AccessItem(); ai.setRequest(id);// w w w .j av a 2 s. com ai.setIp(request.getRemoteHost()); ai.setUsername(request.getAttribute(SolidtrustConstants.CLIENT_ID) + ""); ai.setService(Product.CAR_COMPANY_REVIEW_BY_LICENSEPLATE.getId()); Object result = null; try { CarOwner co = cos.searchLatestOne(id); if (co != null && co.getScrapedName() != null) { List<ReviewInfo> list = rs.search(co.getScrapedName(), co.getCity()); rs.assemble1(list, co); result = co; } } catch (Exception e) { ai.setStatus(-1); log4j.info(e.getMessage(), e); } if (result == null) { result = "no data"; ai.setStatus(0); } ai.setResponse(result + ""); free.save(ai); return result; }
From source file:siddur.solidtrust.site.APIController.java
@RequestMapping(value = "/car_owner") public @ResponseBody Object carOwner(@RequestParam("id") String id, HttpServletRequest request) { AccessItem ai = new AccessItem(); ai.setRequest(id);/*from www . j av a 2 s .c o m*/ ai.setIp(request.getRemoteHost()); ai.setUsername(request.getAttribute(SolidtrustConstants.CLIENT_ID) + ""); ai.setService(Product.CAR_OWNER_HISTORY.getId()); String result = null; List<CarOwner> results = null; try { results = cos.search(id); if (results.size() > 0) { CarOwner co = results.get(0); if (co != null && co.getScrapedName() != null) { List<ReviewInfo> list = rs.search(co.getScrapedName(), co.getCity()); rs.assemble1(list, co); } } } catch (Exception e) { ai.setStatus(-1); log4j.info(e.getMessage(), e); } if (results == null || results.isEmpty()) { result = "no data"; ai.setStatus(0); } else { result = results.get(0).getName() + "..."; } ai.setResponse(result); free.save(ai); return results; }
From source file:siddur.solidtrust.site.APIController.java
@RequestMapping(value = "/tire") public @ResponseBody Object fault( @RequestParam(value = "width", required = false, defaultValue = "0") float width, @RequestParam(value = "height", required = false, defaultValue = "0") float height, @RequestParam(value = "diameter", required = false, defaultValue = "0") float diameter, HttpServletRequest request) { AccessItem ai = new AccessItem(); ai.setIp(request.getRemoteHost()); ai.setUsername(request.getAttribute(SolidtrustConstants.CLIENT_ID) + ""); ai.setService(Product.TIRE.getId()); ai.setRequest(width + ", " + height + ", " + diameter); if (width * height * diameter == 0) { String result = null;// w ww.j a v a2 s . c om if (width == 0) { result = "Width cannot be empty"; } if (height == 0) { result = "Height cannot be empty"; } if (diameter == 0) { result = "Diameter cannot be empty"; } ai.setStatus(-1); ai.setResponse(result); free.save(ai); return result; } String query = "from Tire t where t.season = :season and t.width = :width and t.height = :height and t.diameter = :diameter order by t.price asc"; int max = 10; List<Tire> yearRound = em.createQuery(query, Tire.class).setParameter("season", 0) .setParameter("width", width).setParameter("height", height).setParameter("diameter", diameter) .setMaxResults(max).getResultList(); List<Tire> summer = em.createQuery(query, Tire.class).setParameter("season", 2).setParameter("width", width) .setParameter("height", height).setParameter("diameter", diameter).setMaxResults(max) .getResultList(); List<Tire> winter = em.createQuery(query, Tire.class).setParameter("season", 4).setParameter("width", width) .setParameter("height", height).setParameter("diameter", diameter).setMaxResults(max) .getResultList(); List<Tire> result = new ArrayList<Tire>(); result.addAll(yearRound); result.addAll(summer); result.addAll(winter); ai.setResponse( "year-round:" + yearRound.size() + ", summer:" + summer.size() + ", winter:" + winter.size()); free.save(ai); List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(result.size()); for (Tire tire : result) { Map<String, Object> item = new HashMap<String, Object>(); item.put("name", tire.getName()); item.put("price", tire.getPrice()); item.put("season", tire.getSeasonName()); item.put("productURL", tire.getProductURL()); item.put("imageURL", tire.getImageURL()); list.add(item); } return list; }
From source file:siddur.solidtrust.site.APIController.java
@RequestMapping("/car_info") public @ResponseBody Object carinfo(@RequestParam(value = "startId", required = true) Integer startId, @RequestParam(value = "pageSize", required = false, defaultValue = "12") Integer pageSize, HttpServletRequest request) { AccessItem ai = new AccessItem(); ai.setRequest(request.getQueryString()); ai.setIp(request.getRemoteHost()); ai.setUsername(request.getAttribute(SolidtrustConstants.CLIENT_ID) + ""); ai.setService(Product.CAR_INFO.getId()); CarInfoPage result = carinfoService.sync(startId, pageSize); if (result.getResults().isEmpty()) { ai.setStatus(0);/*from w ww .j a va 2s. c o m*/ } else { ai.setResponse(result.getResults().size() + ""); } free.save(ai); return result; }
From source file:siddur.solidtrust.site.APIController.java
@RequestMapping(value = "/car_company_review") public @ResponseBody Object review(@RequestParam("company") String company, @RequestParam("city") String city, HttpServletRequest request) { AccessItem ai = new AccessItem(); ai.setRequest(company + " " + city); ai.setIp(request.getRemoteHost()); ai.setUsername(request.getAttribute(SolidtrustConstants.CLIENT_ID) + ""); ai.setService(Product.CAR_COMPANY_REVIEW_BY_COMPANY.getId()); Object result = null;/* w w w . j a v a 2s . co m*/ try { List<ReviewInfo> list = rs.search(company, city); result = rs.assemble(list); } catch (Exception e) { ai.setStatus(-1); log4j.info(e.getMessage(), e); } if (result == null) { result = "no data"; ai.setStatus(0); } ai.setResponse(""); free.save(ai); return result; }
From source file:siddur.solidtrust.site.APIController.java
@RequestMapping(value = "/daysOnSale") public @ResponseBody Object daysOnSale(@RequestParam("id") String id, HttpServletRequest request) throws Exception { AccessItem ai = new AccessItem(); ai.setIp(request.getRemoteHost()); ai.setUsername(request.getAttribute(SolidtrustConstants.CLIENT_ID) + ""); ai.setService(Product.DAYS_ON_SALE.getId()); ai.setRequest(id);/* w w w . java2 s. c om*/ List<NewMarktplaats> list = mService.findEntityByLicensePlate(id); List<NewMarktplaats> unremoved = new ArrayList<NewMarktplaats>(); for (NewMarktplaats marktplaats : list) { if (marktplaats.getDateRemoved().equals("0000-00-00")) { unremoved.add(marktplaats); } } Object result = null; if (!unremoved.isEmpty()) { Collections.sort(unremoved, new Comparator<NewMarktplaats>() { @Override public int compare(NewMarktplaats o1, NewMarktplaats o2) { return o2.getAdDate().compareTo(o1.getAdDate()); } }); int msPerDay = 24 * 60 * 60 * 1000; int days = (int) ((new Date().getTime() - DateUtil.string2Date1(unremoved.get(0).getAdDate()).getTime()) / msPerDay); result = days; ai.setResponse(days + " days"); } else { ai.setStatus(0); result = "no data"; } free.save(ai); return result; }
From source file:siddur.solidtrust.site.APIController.java
@SuppressWarnings("deprecation") @RequestMapping(value = "/marktplaats_price") public @ResponseBody Object marktplaatsPrice(@RequestParam(value = "id", required = false) String key, @RequestParam(value = "brand", required = false) String brand, @RequestParam(value = "model", required = false) String model, @RequestParam(value = "build", required = false) String build, @RequestParam(value = "mileage", required = false) Integer mileage, HttpServletRequest request) throws Exception { AccessItem ai = new AccessItem(); ai.setIp(request.getRemoteHost()); ai.setUsername(request.getAttribute(SolidtrustConstants.CLIENT_ID) + ""); ai.setService(Product.MARKTPLAATS_PRICE.getId()); Map<String, Object> map = new HashMap<String, Object>(); if (key != null) { AzureCar entity = azureService.findByLicensePlate(key); build = (entity.getDateOfBuild().getYear() + 1900) + ""; brand = entity.getBrand();//from w w w.j a va 2 s.c om model = entity.getType(); } ai.setRequest(brand + " " + model + " " + build + " " + mileage); List<SortedMarktplaats> list = analyzer.search2(build, brand, model, mileage); if (!list.isEmpty()) { ClassicCarPrice price = analyzer.calc2(list); map.put("Average", price.getAveragePrice()); map.put("Highest", price.getHighestPrice()); map.put("Lowest", price.getLowestPrice()); map.put("count", list.size()); map.put("brand", brand); map.put("model", model); map.put("year", build); } Object result = null; if (map.isEmpty()) { result = "not data"; ai.setStatus(0); ai.setResponse(null); } else { result = map; ai.setResponse(map.get("Average") + ""); } free.save(ai); return result; }