List of usage examples for java.lang StringBuffer lastIndexOf
@Override public int lastIndexOf(String str)
From source file:test.ShopThreadSrc.java
private String getParams() { StringBuffer parambuff = new StringBuffer(2000); Iterator<String> it = this.params.keys(); while (it.hasNext()) { String key = it.next();//w w w . ja v a 2 s . co m parambuff.append(key + "=" + this.params.getString(key)); parambuff.append("&"); } if (parambuff.indexOf("&") != -1) parambuff.deleteCharAt(parambuff.lastIndexOf("&")); return parambuff.toString(); }
From source file:org.esgf.globusonline.GOauthView1Controller.java
@SuppressWarnings("unchecked") @RequestMapping(method = RequestMethod.POST) public ModelAndView doPost(final HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //grab the dataset name, file names and urls from the query string String dataset_name = request.getParameter("id"); String[] file_names = request.getParameterValues("child_id"); String[] file_urls = request.getParameterValues("child_url"); String esg_user = ""; String esg_password = ""; //String e;/*from w w w . j a v a 2 s . c om*/ //grab the credential string String credential = request.getParameter("credential"); System.out.println("Starting GlobusOnline workflow"); //System.out.println("\n\n\n\t\tGO Credential " + credential + "\n\n\n"); StringBuffer currentURL = request.getRequestURL(); String currentURI = request.getRequestURI(); //System.out.println("current URL is: " + currentURL); //System.out.println("current URI is: " + currentURI); //System.out.println("index is: " + currentURL.lastIndexOf(currentURI)); String BaseURL = currentURL.substring(0, currentURL.lastIndexOf(currentURI)); //System.out.println("BaseURL string is: " + BaseURL ); //Instantiate model object: Map<String, Object> model = new HashMap<String, Object>(); //Bail out if no gsiftp URLs are in file_names if (file_names != null) { for (int i = 0; i < file_names.length; i++) { if (!(file_urls[i] == null) && (file_urls[i].contains("gsiftp"))) { break; } else { model.put(GOFORMVIEW_ERROR, "error"); String error_msg = "Selected dataset " + dataset_name + " contains no GridFTP URLS, and cannot be transferred with this transfer method."; model.put(GOFORMVIEW_ERROR_MSG, error_msg); return new ModelAndView("goauthview3", model); } } } else { System.out.println("file_urls itself was null\n"); model.put(GOFORMVIEW_ERROR, "error"); String error_msg = "Selected dataset(s) " + dataset_name + " contain no GridFTP URLS, and cannot be transferred with this transfer method."; model.put(GOFORMVIEW_ERROR_MSG, error_msg); return new ModelAndView("goauthview3", model); } //Create a session if it doesn't already exist, so we can save state. HttpSession session = request.getSession(true); if (session.isNew() == false) { session.invalidate(); session = request.getSession(true); } //System.out.println("Auth1, session id is:" + session.getId()); session.setAttribute("fileUrls", file_urls); session.setAttribute("fileNames", file_names); session.setAttribute("datasetName", dataset_name); session.setAttribute("baseurl", BaseURL); if (!(credential == null)) { session.setAttribute("usercertificatefile", credential); } Cookie[] cookies = request.getCookies(); String openId = ""; for (int i = 0; i < cookies.length; i++) { if (cookies[i].getName().equals("esgf.idp.cookie")) { openId = cookies[i].getValue(); } } LOG.debug("Got User OpenID: " + openId); // Create the client Properties GOProperties = getGOProperties(); String PortalID = (String) GOProperties.getProperty("GOesgfPortalID", "bogususer"); String PortalPass = (String) GOProperties.getProperty("GOesgfPortalPassword", "boguspassword"); String loginUri = ""; try { GoauthClient cli = new GoauthClient("nexus.api.globusonline.org", "globusonline.org", PortalID, PortalPass); cli.setIgnoreCertErrors(true); // Redirect the user agent to the globusonline log in page loginUri = cli.getLoginUrl(response.encodeURL(BaseURL + "/esgf-web-fe/goauthview2")); } catch (NexusClientException e) { System.out.println("ERROR: GOesgfPortalID and/or GOesgfPortalPassword wrong or not set."); // e.printStackTrace(); model.put(GOFORMVIEW_ERROR, "error"); String error_msg = "GlobusOnline Configuration file not found. Please create /esg/config/globusonline.properties and populate it with GOesgfPortalID and GOesgfPortalPassword"; model.put(GOFORMVIEW_ERROR_MSG, error_msg); return new ModelAndView("goauthview3", model); } String myproxyServerStr = null; return new ModelAndView("redirect:" + loginUri, model); }
From source file:net.alchemiestick.katana.winehqappdb.WineApp.java
@Override protected String doInBackground(HttpUriRequest... url) { if (url[0] == null) return this.body; HttpResponse res = null;//from w w w. j a va2 s . co m while (res == null) try { SearchView.do_sleep(500); res = this.client.execute(url[0]); } finally { continue; } while (res.getStatusLine() == null) { SearchView.do_sleep(500); } StringBuffer sb = new StringBuffer(""); try { BufferedReader br = new BufferedReader(new InputStreamReader(res.getEntity().getContent()), (2 * 1024)); String line; boolean first = true; while ((line = br.readLine()) != null) { if (first) { first = false; continue; } sb.append(line + "\n"); } this.body = sb.substring(sb.indexOf("<body"), (sb.lastIndexOf("</body>") + 7)); } catch (IOException ioe) { this.str = "IO Failed!!!:; ; ;"; this.str += ioe.toString(); } catch (Exception ex) { } finally { this.client.close(); } return this.body; }
From source file:org.talend.dataquality.record.linkage.ui.section.BlockingKeySection.java
/** * if overwrite: need to delete all current keyss, and insert the keys according to the parameter:matchRule; else: * only add the keys in the parameter matchrule, to the current keys. * /* ww w .ja va 2 s. c om*/ * @param matchRule * @param overwrite */ public void importMatchRule(MatchRuleDefinition matchRule, boolean overwrite) { if (overwrite) { // clear current keys this.removeAllBlockingKey(); } List<String> conflictKeys = new ArrayList<String>(); for (BlockKeyDefinition blockKey : matchRule.getBlockKeys()) { if (!overwrite && isKeyDefinitionAdded(blockKey.getName())) { // if conflict with current ones, do not import conflictKeys.add(blockKey.getName()); continue; } BlockKeyDefinition blockKeyDefinition = EcoreUtil.copy(blockKey); setColumnValueIfMatch(blockKeyDefinition); tableComposite.addKeyDefinition(blockKeyDefinition, this.getMatchRuleDefinition().getBlockKeys()); } // if there are some conflict keys, popup to let the user know if (conflictKeys.size() > 0) { StringBuffer names = new StringBuffer(); for (String name : conflictKeys) { names.append(name); names.append(PluginConstant.COMMA_STRING); } if (names.length() > 0) { names.deleteCharAt(names.lastIndexOf(PluginConstant.COMMA_STRING)); } MessageDialog.openWarning(null, DefaultMessagesImpl.getString("BlockingKeySection.conflictImport"), //$NON-NLS-1$ DefaultMessagesImpl.getString("BlockingKeySection.conflictImportKeys") + names.toString()); //$NON-NLS-1$ } }
From source file:com.all.backend.web.controller.LoginServerController.java
private String getEnvironment(StringBuffer requestURL) { String environment = javaMailProperties.getProperty(ENVIRONMENT); log.debug("ENVIRONMENT : " + environment); String url = ""; if (environment.equals("production")) { url = ALL_BACKEND_CONFIRM_URL + "?registrationPendingId="; } else {/*from w ww. j a v a 2s . c o m*/ url = requestURL.substring(0, requestURL.lastIndexOf("/") + 1) + "registration/confirmRegistration?registrationPendingId="; } log.debug("URL de la liga de confirmacion < " + url + ">"); return url; }
From source file:org.apache.zeppelin.elasticsearch.ElasticsearchInterpreter.java
private String buildSearchHitsResponseMessage(ActionResponse response) { if (response.getHits() == null || response.getHits().size() == 0) { return ""; }/*from w w w . j ava2 s. c o m*/ //First : get all the keys in order to build an ordered list of the values for each hit // final List<Map<String, Object>> flattenHits = new LinkedList<>(); final Set<String> keys = new TreeSet<>(); for (final HitWrapper hit : response.getHits()) { final String json = hit.getSourceAsString(); final Map<String, Object> flattenJsonMap = JsonFlattener.flattenAsMap(json); final Map<String, Object> flattenMap = new HashMap<>(); for (final Iterator<String> iter = flattenJsonMap.keySet().iterator(); iter.hasNext();) { // Replace keys that match a format like that : [\"keyname\"][0] final String fieldName = iter.next(); final Matcher fieldNameMatcher = FIELD_NAME_PATTERN.matcher(fieldName); if (fieldNameMatcher.matches()) { flattenMap.put(fieldNameMatcher.group(1) + fieldNameMatcher.group(2), flattenJsonMap.get(fieldName)); } else { flattenMap.put(fieldName, flattenJsonMap.get(fieldName)); } } flattenHits.add(flattenMap); for (final String key : flattenMap.keySet()) { keys.add(key); } } // Next : build the header of the table // final StringBuffer buffer = new StringBuffer(); for (final String key : keys) { buffer.append(key).append('\t'); } buffer.replace(buffer.lastIndexOf("\t"), buffer.lastIndexOf("\t") + 1, "\n"); // Finally : build the result by using the key set // for (final Map<String, Object> hit : flattenHits) { for (final String key : keys) { final Object val = hit.get(key); if (val != null) { buffer.append(val); } buffer.append('\t'); } buffer.replace(buffer.lastIndexOf("\t"), buffer.lastIndexOf("\t") + 1, "\n"); } return buffer.toString(); }
From source file:io.onedecision.engine.decisions.web.DecisionController.java
private String toJson(Map<String, Object> results) throws IOException { StringBuffer sb = new StringBuffer("{"); for (Entry<String, Object> entry : results.entrySet()) { sb.append("\"").append(entry.getKey()).append("\":"); Object val = entry.getValue(); if (val instanceof String && val.equals("{}")) { sb.append(val); } else {/* w ww .ja v a2 s . c o m*/ val = objectMapper.writeValueAsString(val); if (val instanceof String && ((String) val).startsWith("\"{")) { val = ((String) val).substring(1, ((String) val).length() - 1); } sb.append(((String) val).replaceAll("\\\\", "")); } sb.append(","); } if (sb.lastIndexOf(",") != -1) { sb.deleteCharAt(sb.lastIndexOf(",")).append("}"); } return sb.toString(); }
From source file:org.kuali.kfs.pdp.web.struts.BatchAction.java
/** * This method build a string list of error message keys out of the error map in GlobalVariables * /*from w ww . j a va 2 s.c om*/ * @return a String representing the list of error message keys */ private String buildErrorMesageKeyList() { MessageMap errorMap = GlobalVariables.getMessageMap(); StringBuffer errorList = new StringBuffer(); for (String errorKey : (List<String>) errorMap.getPropertiesWithErrors()) { for (ErrorMessage errorMessage : (List<ErrorMessage>) errorMap.getMessages(errorKey)) { errorList.append(errorMessage.getErrorKey()); errorList.append(PdpParameterConstants.ERROR_KEY_LIST_SEPARATOR); } } if (errorList.length() > 0) { errorList.replace(errorList.lastIndexOf(PdpParameterConstants.ERROR_KEY_LIST_SEPARATOR), errorList.lastIndexOf(PdpParameterConstants.ERROR_KEY_LIST_SEPARATOR) + PdpParameterConstants.ERROR_KEY_LIST_SEPARATOR.length(), ""); } return errorList.toString(); }
From source file:org.exoplatform.services.ecm.publication.REST.presentation.document.edit.GetEditedDocumentRESTService.java
private List<Node> getLastEditedNode(String noOfItem, String showGadgetWs) throws Exception { if (showGadgetWs != null && showGadgetWs.length() > 0) { show_gadget = Boolean.parseBoolean(showGadgetWs); }/*from w w w . j a v a2 s. c o m*/ ArrayList<Node> lstNode = new ArrayList<Node>(); StringBuffer bf = new StringBuffer(1024); List<String> lstNodeType = templateService.getDocumentTemplates(); if (lstNodeType != null) { for (String nodeType : lstNodeType) { bf.append("(").append(JCR_PRIMARYTYPE).append("=").append("'").append(nodeType).append("'") .append(")").append(" OR "); } } if (bf.length() == 1) return null; bf.delete(bf.lastIndexOf("OR") - 1, bf.length()); if (noOfItem == null || noOfItem.trim().length() == 0) noOfItem = String.valueOf(NO_PER_PAGE); String queryStatement = StringUtils.replace(QUERY_STATEMENT, "$0", NT_BASE); queryStatement = StringUtils.replace(queryStatement, "$1", bf.toString()); queryStatement = StringUtils.replace(queryStatement, "$2", DATE_MODIFIED); ManageableRepository manageableRepository = repositoryService.getCurrentRepository(); try { String[] workspaces = manageableRepository.getWorkspaceNames(); List<String> lstWorkspace = new ArrayList<String>(); //Arrays.asList() return fixed size list; lstWorkspace.addAll(Arrays.asList(workspaces)); if (!show_gadget && lstWorkspace.contains(GADGET)) { lstWorkspace.remove(GADGET); } SessionProvider provider = WCMCoreUtils.createAnonimProvider(); QueryImpl query = null; Session session = null; QueryResult queryResult = null; QueryManager queryManager = null; for (String workspace : lstWorkspace) { session = provider.getSession(workspace, manageableRepository); queryManager = session.getWorkspace().getQueryManager(); query = (QueryImpl) queryManager.createQuery(queryStatement, Query.SQL); query.setLimit(Integer.parseInt(noOfItem)); query.setOffset(0); queryResult = query.execute(); puttoList(lstNode, queryResult.getNodes()); session.logout(); } } catch (RepositoryException e) { if (LOG.isErrorEnabled()) { LOG.error("Exception when execute SQL " + queryStatement, e); } } return lstNode; }
From source file:net.duckling.ddl.web.controller.task.TaskBaseController.java
/** * Task??/*from w w w . j a va 2s . c om*/ * * @param userIds * ?? xx1@xx.com,xx2@xx.com.... * @param site * Site * @return string xxName%xxEmail,...,... * */ private String convert2TaskNameType(String uIds, Site site) { if (StringUtils.isEmpty(uIds)) { return ""; } String emails[] = uIds.split(","); StringBuffer sb = new StringBuffer(); for (String email : emails) { if (StringUtils.isEmpty(email)) { continue; } sb.append(aoneUserService.getUserNameByID(email)).append("%").append(email).append(","); } if (sb.indexOf(",") > -1) { sb.deleteCharAt(sb.lastIndexOf(",")); } return sb.toString(); }