List of usage examples for org.apache.commons.httpclient.util URIUtil decode
public static String decode(String escaped, String charset) throws URIException
From source file:org.medici.bia.controller.peoplebase.ShowSearchTitlesOrOccupationsController.java
/** * This controller act as a dispatcher for result view. * //from w w w. ja v a 2 s . co m * @param command * @param result * @return */ @RequestMapping(method = { RequestMethod.POST }) public ModelAndView processSubmit(@ModelAttribute("command") ShowSearchTitlesOrOccupationsCommand command, BindingResult result) { Map<String, Object> model = new HashMap<String, Object>(0); try { command.setTextSearch(URIUtil.decode(command.getTextSearch(), "UTF-8")); } catch (URIException e) { } model.put("yourSearch", command.getTextSearch()); if (command.getTextSearch().contains("\"")) { command.setTextSearch(command.getTextSearch().replace("\"", "\\\"")); } // This number is used to generate an unique id for new search UUID uuid = UUID.randomUUID(); command.setSearchUUID(uuid.toString()); model.put("searchUUID", uuid.toString()); // Add outputFields; List<String> outputFields = getOutputFields(); model.put("outputFields", outputFields); return new ModelAndView("peoplebase/ShowSearchResultTitlesOrOccupations", model); }
From source file:org.medici.bia.controller.search.ExpandResultsSimpleSearchController.java
/** * This controller act as a dispatcher for result view. * //from w ww . j a v a2 s .c o m * @param command * @param result * @return */ @RequestMapping(method = { RequestMethod.GET }) public ModelAndView processSubmit(@ModelAttribute("command") ExpandResultsSimpleSearchCommand command, BindingResult result) { Map<String, Object> model = new HashMap<String, Object>(0); try { command.setsSearch(URIUtil.decode(command.getsSearch(), "UTF-8")); } catch (URIException e) { } if (StringUtils.countMatches(command.getsSearch(), "\"") % 2 != 0) { StringBuffer tempString = new StringBuffer(command.getsSearch()); tempString.setCharAt(tempString.lastIndexOf("\""), ' '); command.setsSearch(tempString.toString()); } //This code is for highlight the correct words StringBuffer yourSearch = new StringBuffer(); if (command.getsSearch().contains("\"")) { StringTokenizer stringTokenizer = new StringTokenizer(command.getsSearch().replace('"', ' '), " "); while (stringTokenizer.hasMoreTokens()) { String currentToken = stringTokenizer.nextToken(); if (currentToken.length() > 0 && currentToken != "") { if (yourSearch.toString().length() > 0) yourSearch.append(" " + currentToken); else yourSearch.append(currentToken); } } } else { yourSearch.append(command.getsSearch()); } model.put("yourSearch", yourSearch.toString()); if (command.getsSearch().contains("\"")) { command.setsSearch(command.getsSearch().replace("\"", "\\\"")); } // This number is used to generate an unique id for new search UUID uuid = UUID.randomUUID(); command.setSearchUUID(uuid.toString()); model.put("searchUUID", uuid.toString()); // Add outputFields; List<String> outputFields = getOutputFields(command.getSimpleSearchPerimeter()); model.put("outputFields", outputFields); return new ModelAndView("search/ExpandSimpleSearchResult", model); }
From source file:org.medici.bia.controller.search.SimpleSearchController.java
/** * This controller act as a dispatcher for result view. * //from w w w . j ava2 s . c o m * @param command * @param result * @return */ @RequestMapping(method = { RequestMethod.POST }) public ModelAndView processSubmit(@ModelAttribute("command") SimpleSearchCommand command, BindingResult result) { Map<String, Object> model = new HashMap<String, Object>(0); try { command.setText(URIUtil.decode(command.getText(), "UTF-8")); } catch (URIException e) { } if (StringUtils.countMatches(command.getText(), "\"") % 2 != 0) { StringBuffer tempString = new StringBuffer(command.getText()); tempString.setCharAt(tempString.lastIndexOf("\""), ' '); command.setText(tempString.toString()); } model.put("yourSearch", command.getText()); // RR: we consider single quote equivalent to double quotes model.put("textSearch", command.getText().replace("'", "%22").replace("\"", "%22")); // This number is used to generate an unique id for new search UUID uuid = UUID.randomUUID(); command.setSearchUUID(uuid.toString()); model.put("searchUUID", uuid.toString()); // Add outputFields; List<String> outputFields = getOutputFields(command.getSimpleSearchPerimeter()); model.put("outputFields", outputFields); return new ModelAndView("search/SimpleSearchResult", model); }
From source file:org.pengyou.client.lib.methods.XMLResponseMethodBase.java
private String getHref(Response response) { String href = response.getHref(); if (this.decodeResponseHrefs != null) { try {// ww w . ja va 2s . c o m href = URIUtil.decode(href, this.decodeResponseHrefs); } catch (URIException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } return href; }
From source file:rapture.common.dp.StepHelper.java
public static String decode(String encoded) { try {/*from ww w. jav a 2 s.c o m*/ return URIUtil.decode(encoded, CharEncoding.UTF_8); } catch (URIException e) { throw RaptureExceptionFactory.create(String.format("Error decoding step name %s:", encoded), e); } }