List of usage examples for org.apache.commons.lang StringEscapeUtils StringEscapeUtils
StringEscapeUtils
From source file:org.kuali.ole.select.service.impl.PreOrderServiceImpl.java
@Override /*/*from w w w . j a v a2 s . co m*/ * public String createPreOrderForForm(String title, String author, String edition, String series, String publisher, String * placeOfPublication, String yearOfPublication, String standardNumber, String typeOfStandardNumber, String * routeRequestorReceipt, String requestorsNote, String requestorsFirstName, String requestorsLastName, String * requestorsAddress1, String requestorsAddress2, String requestorsCity, String requestorsState, String requestorsZipCode, * String requestorsCountryCode, String requestorsPhone, String requestorsEmail, String requestorsSMS, String requestorType) * throws WSException_Exception { */ public String createPreOrderForForm(String title, String author, String edition, String series, String publisher, String placeOfPublication, String yearOfPublication, String standardNumber, String typeOfStandardNumber, String requestorsNote, String requestorType, String requestorId) throws WSException_Exception { PopulateBibInfoService populateBibInfoService = getPopulateBibInfoService(); BibInfoBean bibInfoBean = getBibInfoBean(); StringEscapeUtils stringEscapeUtils = new StringEscapeUtils(); title = stringEscapeUtils.escapeHtml(title); author = stringEscapeUtils.escapeHtml(author); edition = stringEscapeUtils.escapeHtml(edition); publisher = stringEscapeUtils.escapeHtml(publisher); placeOfPublication = stringEscapeUtils.escapeHtml(placeOfPublication); requestorId = stringEscapeUtils.escapeHtml(requestorId); /* * setRequestorDetail(requestorsNote, requestorsFirstName, requestorsLastName, requestorsAddress1, requestorsAddress2, * requestorsCity, requestorsState, requestorsZipCode, requestorsCountryCode, requestorsPhone, requestorsEmail, * requestorsSMS, requestorType); */ setRequestorDetail(requestorsNote, requestorType, requestorId); String docNumber = null; try { /* * docNumber = populateBibInfoService.processBibInfoForForm(bibInfoBean, title, author, edition, series, publisher, * placeOfPublication, yearOfPublication, standardNumber, typeOfStandardNumber, routeRequestorReceipt); */ docNumber = populateBibInfoService.processBibInfoForForm(bibInfoBean, title, author, edition, series, publisher, placeOfPublication, yearOfPublication, standardNumber, typeOfStandardNumber, requestorId); LOG.info("docNumber in createPreOrderForForm>>>>>>>>>>>>>>" + docNumber); } catch (Exception E) { } return docNumber; }
From source file:org.kuali.ole.service.impl.OleLicenseRequestServiceImpl.java
/** * This method returns the uuids for the given bibliographic Title * @param title/* w w w.ja va 2s . com*/ * @return uuids */ private List<String> getUUIDs(String title) { StringEscapeUtils stringEscapeUtils = new StringEscapeUtils(); List<String> uuids = new ArrayList<String>(); try { List<HashMap<String, Object>> bibDocumentList = QueryServiceImpl.getInstance() .retriveResults(queryString + stringEscapeUtils.escapeXml(title)); if (bibDocumentList.size() > 0) { Iterator listIterator = bibDocumentList.iterator(); while (listIterator.hasNext()) { Map results = (Map) listIterator.next(); uuids.add((String) results.get("uniqueId")); } } } catch (Exception e) { e.printStackTrace(); } return uuids; }
From source file:org.motechproject.server.decisiontree.web.VxmlController.java
/** * Handles Decision Tree Node HTTP requests and generates a VXML document based on a Velocity template. * The HTTP request should contain the Tree ID, Node ID, Patient ID and Selected Transition Key (optional) parameters * *//*ww w . j ava 2 s .c om*/ public ModelAndView node(HttpServletRequest request, HttpServletResponse response) { logger.info("Generating decision tree node VXML"); response.setContentType("text/plain"); response.setCharacterEncoding("UTF-8"); Node node = null; String transitionPath = null; Map<String, Object> params = convertParams(request.getParameterMap()); String patientId = request.getParameter(PATIENT_ID_PARAM); String language = request.getParameter(LANGUAGE_PARAM); String treeNameString = request.getParameter(TREE_NAME_PARAM); String encodedParentTransitionPath = request.getParameter(TRANSITION_PATH_PARAM); String transitionKey = request.getParameter(TRANSITION_KEY_PARAM); logger.info(" Node HTTP request parameters: " + PATIENT_ID_PARAM + ": " + patientId + ", " + LANGUAGE_PARAM + ": " + language + ", " + TREE_NAME_PARAM + ": " + treeNameString + ", " + TRANSITION_PATH_PARAM + ": " + encodedParentTransitionPath + ", " + TRANSITION_KEY_PARAM + ": " + transitionKey); if (StringUtils.isBlank(patientId) || StringUtils.isBlank(language) || StringUtils.isBlank(treeNameString)) { logger.error("Invalid HTTP request - the following parameters: " + PATIENT_ID_PARAM + ", " + LANGUAGE_PARAM + " and " + TREE_NAME_PARAM + " are mandatory"); return getErrorModelAndView(Errors.NULL_PATIENTID_LANGUAGE_OR_TREENAME_PARAM); } String[] treeNames = treeNameString.split(TREE_NAME_SEPARATOR); String currentTree = treeNames[0]; // put only one tree name in params params.put(TREE_NAME_PARAM, currentTree); if (transitionKey == null) { // get root node try { String rootTransitionPath = TreeNodeLocator.PATH_DELIMITER; node = decisionTreeService.getNode(currentTree, rootTransitionPath); transitionPath = rootTransitionPath; } catch (Exception e) { logger.error("Can not get node by Tree Name: " + currentTree + " transition path: " + patientId, e); } } else { // get not root node String parentTransitionPath = null; try { if (encodedParentTransitionPath == null) { logger.error( "Invalid HTTP request - the " + TRANSITION_PATH_PARAM + " parameter is mandatory"); return getErrorModelAndView(Errors.NULL_TRANSITION_PATH_PARAM); } parentTransitionPath = new String(Base64.decodeBase64(encodedParentTransitionPath)); Node parentNode = decisionTreeService.getNode(currentTree, parentTransitionPath); Transition transition = parentNode.getTransitions().get(transitionKey); if (transition == null) { logger.error("Invalid Transition Key. There is no transition with key: " + transitionKey + " in the Node: " + parentNode); return getErrorModelAndView(Errors.INVALID_TRANSITION_KEY); } treeEventProcessor.sendActionsAfter(parentNode, parentTransitionPath, params); treeEventProcessor.sendTransitionActions(transition, params); node = transition.getDestinationNode(); if (node == null || (node.getPrompts().isEmpty() && node.getActionsAfter().isEmpty() && node.getActionsBefore().isEmpty() && node.getTransitions().isEmpty())) { if (treeNames.length > 1) { //reduce the current tree and redirect to the next tree treeNames = (String[]) ArrayUtils.remove(treeNames, 0); String view = String.format( "redirect:/tree/vxml/node?" + PATIENT_ID_PARAM + "=%s&" + TREE_NAME_PARAM + "=%s&" + LANGUAGE_PARAM + "=%s", patientId, StringUtils.join(treeNames, TREE_NAME_SEPARATOR), language); ModelAndView mav = new ModelAndView(view); return mav; } else { //TODO: Add support for return url ModelAndView mav = new ModelAndView(EXIT_TEMPLATE_NAME); return mav; } } else { transitionPath = parentTransitionPath + (TreeNodeLocator.PATH_DELIMITER.equals(parentTransitionPath) ? "" : TreeNodeLocator.PATH_DELIMITER) + transitionKey; } } catch (Exception e) { logger.error("Can not get node by Tree ID : " + currentTree + " and Transition Path: " + parentTransitionPath, e); } } if (node != null) { //validate node for (Map.Entry<String, Transition> transitionEntry : node.getTransitions().entrySet()) { try { Integer.parseInt(transitionEntry.getKey()); } catch (NumberFormatException e) { logger.error("Invalid node: " + node + "\n In order to be used in VXML transition keys should be an Integer"); return getErrorModelAndView(Errors.INVALID_TRANSITION_KEY_TYPE); } Transition transition = transitionEntry.getValue(); if (transition.getDestinationNode() == null) { logger.error( "Invalid node: " + node + "\n Null Destination Node in the Transition: " + transition); return getErrorModelAndView(Errors.NULL_DESTINATION_NODE); } } treeEventProcessor.sendActionsBefore(node, transitionPath, params); ModelAndView mav = new ModelAndView(); if (node.getTransitions().size() > 0) { mav.setViewName(NODE_TEMPLATE_NAME); mav.addObject("treeName", treeNameString); } else { // leaf //reduce the current tree and redirect to the next tree treeNames = (String[]) ArrayUtils.remove(treeNames, 0); mav.setViewName(LEAF_TEMPLATE_NAME); mav.addObject("treeName", StringUtils.join(treeNames, TREE_NAME_SEPARATOR)); } mav.addObject("contentPath", request.getContextPath()); mav.addObject("node", node); mav.addObject("patientId", patientId); mav.addObject("language", language); mav.addObject("transitionPath", Base64.encodeBase64URLSafeString(transitionPath.getBytes())); mav.addObject("escape", new StringEscapeUtils()); return mav; } else { return getErrorModelAndView(Errors.GET_NODE_ERROR); } }
From source file:oscar.oscarReport.bean.RptByExampleQueryBean.java
public RptByExampleQueryBean(int id, String query, String queryName) { oscar.oscarReport.data.RptByExampleData exampleData = new oscar.oscarReport.data.RptByExampleData(); this.id = id; this.query = query; this.queryName = queryName; //this.queryWithEscapeChar = exampleData.replaceSQLString ("'","\\'",query); StringEscapeUtils strEscUtils = new StringEscapeUtils(); this.queryWithEscapeChar = StringEscapeUtils.escapeJavaScript(query); MiscUtils.getLogger().debug("query with javascript escape char: " + queryWithEscapeChar); }
From source file:oscar.oscarReport.bean.RptByExampleQueryBean.java
public RptByExampleQueryBean(String providerLastName, String providerFirstName, String query, String date) { oscar.oscarReport.data.RptByExampleData exampleData = new oscar.oscarReport.data.RptByExampleData(); this.providerLastName = providerLastName; this.providerFirstName = providerFirstName; this.query = query; this.date = date; //this.queryWithEscapeChar = exampleData.replaceSQLString ("'","\\'",query); StringEscapeUtils strEscUtils = new StringEscapeUtils(); this.queryWithEscapeChar = StringEscapeUtils.escapeJavaScript(query); }
From source file:oscar.oscarReport.bean.RptByExampleQueryBeanHandler.java
public Collection getFavoriteCollection(String providerNo) { try {/*from w ww.j a va 2 s .com*/ String sql = "SELECT * from reportByExamplesFavorite WHERE providerNo='" + providerNo + "' ORDER BY name"; MiscUtils.getLogger().debug("Sql Statement: " + sql); ResultSet rs; for (rs = DBHandler.GetSQL(sql); rs.next();) { StringEscapeUtils strEscUtils = new StringEscapeUtils(); String queryWithEscapeChar = StringEscapeUtils.escapeJava(oscar.Misc.getString(rs, "query")); //oscar.oscarReport.data.RptByExampleData exampleData = new oscar.oscarReport.data.RptByExampleData(); //queryWithEscapeChar = exampleData.replaceSQLString (";","",queryWithEscapeChar); //queryWithEscapeChar = exampleData.replaceSQLString("\"", "\'", queryWithEscapeChar); String queryNameWithEscapeChar = StringEscapeUtils.escapeJava(oscar.Misc.getString(rs, "name")); RptByExampleQueryBean query = new RptByExampleQueryBean(rs.getInt("id"), oscar.Misc.getString(rs, "query"), oscar.Misc.getString(rs, "name")); favoriteVector.add(query); } rs.close(); } catch (SQLException e) { MiscUtils.getLogger().error("Error", e); } return favoriteVector; }
From source file:oscar.oscarReport.bean.RptByExampleQueryBeanHandler.java
public Vector getQueryVector() { try {/*from w w w. j a va 2s.c o m*/ String sql = "SELECT r.query, r.date, p.last_name, p.first_name from reportByExamples r, provider p " + "WHERE r.providerNo=p.provider_No AND date>= '" + startDate + "' AND date <='" + endDate + "' ORDER BY date DESC"; MiscUtils.getLogger().debug("Sql Statement: " + sql); ResultSet rs; for (rs = DBHandler.GetSQL(sql); rs.next();) { StringEscapeUtils strEscUtils = new StringEscapeUtils(); String queryWithEscapeChar = StringEscapeUtils.escapeJava(oscar.Misc.getString(rs, "query")); RptByExampleQueryBean query = new RptByExampleQueryBean(oscar.Misc.getString(rs, "last_name"), oscar.Misc.getString(rs, "first_name"), oscar.Misc.getString(rs, "query"), oscar.Misc.getString(rs, "date")); queryVector.add(query); } rs.close(); } catch (SQLException e) { MiscUtils.getLogger().error("Error", e); } return queryVector; }
From source file:oscar.oscarReport.pageUtil.RptByExampleAction.java
public void write2Database(String query, String providerNo) { if (query != null && query.compareTo("") != 0) { try {//from ww w . j a v a 2s .c om StringEscapeUtils strEscUtils = new StringEscapeUtils(); //query = exampleData.replaceSQLString (";","",query); //query = exampleData.replaceSQLString("\"", "\'", query); query = StringEscapeUtils.escapeSql(query); String sql = "INSERT INTO reportByExamples(providerNo, query, date) VALUES('" + providerNo + "','" + query + "', NOW())"; DBHandler.RunSQL(sql); } catch (SQLException e) { MiscUtils.getLogger().error("Error", e); } } }
From source file:oscar.oscarReport.pageUtil.RptByExamplesFavoriteAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { RptByExamplesFavoriteForm frm = (RptByExamplesFavoriteForm) form; String providerNo = (String) request.getSession().getAttribute("user"); if (frm.getNewQuery() != null) { if (frm.getNewQuery().compareTo("") != 0) { frm.setQuery(frm.getNewQuery()); if (frm.getNewName() != null) frm.setFavoriteName(frm.getNewName()); else { try { String sql = "SELECT * from reportByExamplesFavorite WHERE query LIKE '" + StringEscapeUtils.escapeSql(frm.getNewQuery()) + "'"; MiscUtils.getLogger().debug("HERE " + sql); ResultSet rs = DBHandler.GetSQL(sql); if (rs.next()) frm.setFavoriteName(rs.getString("name")); } catch (SQLException e) { MiscUtils.getLogger().error("Error", e); }/*from w w w. j av a 2 s. c o m*/ } return mapping.findForward("edit"); } else if (frm.getToDelete() != null) { if (frm.getToDelete().compareTo("true") == 0) { deleteQuery(frm.getId()); } } } else { MiscUtils.getLogger().debug("STEP:1 " + frm.getQuery()); String favoriteName = frm.getFavoriteName(); String query = frm.getQuery(); //oscar.oscarReport.data.RptByExampleData exampleData = new oscar.oscarReport.data.RptByExampleData(); //String queryWithEscapeChar = exampleData.replaceSQLString ("\"","\'",query); StringEscapeUtils strEscUtils = new StringEscapeUtils(); String queryWithEscapeChar = StringEscapeUtils.escapeSql(query);///queryWithEscapeChar); MiscUtils.getLogger().debug("escapeSql: " + queryWithEscapeChar); write2Database(providerNo, favoriteName, queryWithEscapeChar); } RptByExampleQueryBeanHandler hd = new RptByExampleQueryBeanHandler(providerNo); request.setAttribute("allFavorites", hd); return mapping.findForward("success"); }
From source file:oscar.util.JDBCUtil.java
public static Document toDocument(ResultSet rs) throws ParserConfigurationException, SQLException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.newDocument(); StringEscapeUtils strEscUtils = new StringEscapeUtils(); Element results = doc.createElement("Results"); doc.appendChild(results);// www . j a va2s . c om ResultSetMetaData rsmd = rs.getMetaData(); int colCount = rsmd.getColumnCount(); while (rs.next()) { Element row = doc.createElement("Row"); results.appendChild(row); for (int i = 1; i <= colCount; i++) { String columnName = StringEscapeUtils.escapeXml(rsmd.getColumnName(i)); String value = StringEscapeUtils.escapeXml(oscar.Misc.getString(rs, i)); Element node = doc.createElement(columnName); node.appendChild(doc.createTextNode(value)); row.appendChild(node); } } rs.close(); return doc; }