List of usage examples for org.apache.commons.lang StringUtils indexOf
public static int indexOf(String str, String searchStr)
Finds the first index within a String, handling null
.
From source file:info.magnolia.cms.security.SecurityUtil.java
public static String stripParameterFromCacheLog(String log, String parameter) { if (StringUtils.isBlank(log)) { return null; } else if (!StringUtils.contains(log, parameter)) { return log; }// w w w.j av a 2 s .c o m String value = null; value = StringUtils.substringBefore(log, parameter); String afterString = StringUtils.substringAfter(log, parameter); if (StringUtils.indexOf(afterString, " ") < StringUtils.indexOf(afterString, "}")) { value = value + StringUtils.substringAfter(afterString, " "); } else { value = value + "}" + StringUtils.substringAfter(afterString, "}"); } return value; }
From source file:com.hangum.tadpole.commons.admin.core.editors.sqlaudit.AdminSQLAuditEditor.java
/** * show query editor//from ww w.jav a2 s . c o m */ private void showQueryEditor() { GridItem[] gridItems = gridHistory.getSelection(); if (gridItems.length != 0) { try { RequestResultDAO reqResultDao = mapSQLHistory.get(gridItems[0].getText(0)); if (null != reqResultDao) { String strApiOrSQL = gridItems[0].getText(4); if (reqResultDao.getEXECUSTE_SQL_TYPE() == PublicTadpoleDefine.EXECUTE_SQL_TYPE.API) { int intFindAnd = StringUtils.indexOf(strApiOrSQL, "&"); //$NON-NLS-1$ String strApi = StringUtils.substring(strApiOrSQL, 0, intFindAnd); UserDBResourceDAO userDBResourceDao = TadpoleSystem_UserDBResource.findAPIKey(strApi); String strSQL = TadpoleSystem_UserDBResource.getResourceData(userDBResourceDao); if (logger.isDebugEnabled()) logger.debug(userDBResourceDao.getName() + ", " + strSQL); //$NON-NLS-1$ strApiOrSQL = strSQL; } UserDBDAO dbDao = TadpoleSystem_UserDBQuery.getUserDBInstance(reqResultDao.getDbSeq()); FindEditorAndWriteQueryUtil.run(dbDao, Utils.convHtmlToLine(strApiOrSQL) + PublicTadpoleDefine.SQL_DELIMITER, PublicTadpoleDefine.OBJECT_TYPE.TABLES); } } catch (Exception e) { logger.error("find editor and write query", e); //$NON-NLS-1$ } } }
From source file:com.hangum.tadpole.manager.core.editor.executedsql.SQLAuditEditor.java
/** * show query editor/*from www . ja v a 2 s.co m*/ */ private void showQueryEditor() { GridItem[] gridItems = gridHistory.getSelection(); if (gridItems.length != 0) { try { RequestResultDAO reqResultDao = mapSQLHistory.get(gridItems[0].getText(0)); if (null != reqResultDao) { String strApiOrSQL = gridItems[0].getText(4); if (reqResultDao.getEXECUSTE_SQL_TYPE() == PublicTadpoleDefine.EXECUTE_SQL_TYPE.API) { int intFindAnd = StringUtils.indexOf(strApiOrSQL, "&"); //$NON-NLS-1$ String strApi = StringUtils.substring(strApiOrSQL, 0, intFindAnd); UserDBResourceDAO userDBResourceDao = TadpoleSystem_UserDBResource.findAPIKey(strApi); String strSQL = TadpoleSystem_UserDBResource.getResourceData(userDBResourceDao); if (logger.isDebugEnabled()) logger.debug(userDBResourceDao.getName() + ", " + strSQL); //$NON-NLS-1$ strApiOrSQL = strSQL; } UserDBDAO dbDao = TadpoleSystem_UserDBQuery.getUserDBInstance(reqResultDao.getDbSeq()); FindEditorAndWriteQueryUtil.run(dbDao, Utils.convHtmlToLine(strApiOrSQL) + PublicTadpoleDefine.SQL_DELIMITER, PublicTadpoleDefine.OBJECT_TYPE.TABLES); } } catch (Exception e) { logger.error("find editor and write query", e); //$NON-NLS-1$ } } }
From source file:gnete.card.web.merch.MerchAction.java
public String add() throws Exception { String type = merchInfoReg.getMerchType(); Assert.notEmpty(type, "?"); this.merchInfoReg.setMerchType(StringUtils.substring(type, 0, StringUtils.indexOf(type, "|"))); // //from ww w .j a v a2 s .c o m // // service?;?? // UserInfo admin = new UserInfo(); // admin.setUserId(this.merchAdmin); // this.merchService.addMerch(this.merchInfo, admin, branchCode, this.getSessionUserCode()); // // if (addAdmin == 1) { // this.merchService.addMerch(this.merchInfo, admin, branchCode, this.getSessionUserCode()); // } else { // this.merchService.addMerch(this.merchInfo, null, branchCode, this.getSessionUserCode()); // } this.merchInfoReg.setAdminId(this.merchAdmin); this.merchService.addMerch(this.merchInfoReg, this.getSessionUser()); String msg = LogUtils.r("id[{0}]??", this.merchInfoReg.getId()); this.addActionMessage("/pages/merch/regList.do?goBack=goBack", msg); this.log(msg, UserLogType.ADD); return SUCCESS; }
From source file:gnete.card.web.merch.MerchAction.java
public String addOldMerch() throws Exception { String type = merchInfoReg.getMerchType(); Assert.notEmpty(type, "?"); // this.merchInfoReg.setMerchType(type.substring(0, type.indexOf("|"))); this.merchInfoReg.setMerchType(StringUtils.substring(type, 0, StringUtils.indexOf(type, "|"))); // if (addAdmin == 1) { // UserInfo admin = new UserInfo(); // admin.setUserId(this.merchAdmin); // this.merchService.addOldMerch(this.merchInfo, admin, branchCode, this // .getSessionUserCode()); // } else { // this.merchService.addOldMerch(this.merchInfo, null, branchCode, this // .getSessionUserCode()); // }/*from ww w.j a v a2 s. c om*/ this.merchInfoReg.setAdminId(this.merchAdmin); this.merchService.addOldMerch(this.merchInfoReg, this.getSessionUser()); String msg = LogUtils.r("[{0}]?", this.merchInfoReg.getMerchId()); this.addActionMessage("/pages/merch/regList.do?goBack=goBack", msg); this.log(msg, UserLogType.ADD); return SUCCESS; }
From source file:com.mmj.app.common.util.IPTools.java
public Set<String> getCity(String ip) { if (StringUtils.isEmpty(ip)) { return null; }//from w w w . j ava 2 s. c o m String country = getCountry(ip).equals(" CZ88.NET") ? StringUtils.EMPTY : getCountry(ip); Set<String> set = new HashSet<String>(); int provinceIndex = 0; if (country.contains("?")) { int index = StringUtils.indexOf(country, "?"); set.add(StringUtils.substring(country, 0, index)); set.add(StringUtils.substring(country, 0, index + 1)); provinceIndex = index + 1; } if (country.contains("")) { int index = StringUtils.indexOf(country, ""); set.add(StringUtils.substring(country, provinceIndex, index)); set.add(StringUtils.substring(country, provinceIndex, index + 1)); String endStr = StringUtils.substring(country, index + 1); if (StringUtils.isNotEmpty(endStr)) { set.add(endStr); } if (endStr.contains("")) { int end = StringUtils.indexOf(endStr, ""); set.add(StringUtils.substring(endStr, provinceIndex, end)); set.add(StringUtils.substring(endStr, provinceIndex, end + 1)); } if (endStr.contains("")) { int end = StringUtils.indexOf(endStr, ""); set.add(StringUtils.substring(endStr, provinceIndex, end)); set.add(StringUtils.substring(endStr, provinceIndex, end + 1)); } } set.add(country); return set; }
From source file:com.funambol.LDAP.security.LDAPMailUserProvisioningOfficer.java
/** * Generate a MailServer from imap and smtp uri * @param myImapServer//ww w. ja v a 2 s . c o m * @param mySmtpServer * @return * @throws BeanException */ protected MailServer generateMailServer(URI myImapServer, URI mySmtpServer) throws BeanException { MailServer mailserver; if (StringUtils.isNotEmpty(getMailServerConfigBean())) { mailserver = (MailServer) Configuration.getConfiguration() .getBeanInstanceByName(getMailServerConfigBean()); } else { mailserver = new MailServer(); mailserver.setDescription("Generated from LDAPMailUserProvisioningOfficer"); mailserver.setMailServerType("Custom"); mailserver.setIsPublic(false); mailserver.setInboxPath(Def.FOLDER_INBOX_ENG); mailserver.setInboxActivation(true); // mailserver default attributes (could be put in the officer configuration) mailserver.setSentPath(Def.FOLDER_SENT_ENG); mailserver.setSentActivation(true); mailserver.setOutboxPath(Def.FOLDER_OUTBOX_ENG); mailserver.setOutboxActivation(true); mailserver.setDraftsPath(Def.FOLDER_DRAFTS_ENG); mailserver.setDraftsActivation(false); mailserver.setTrashPath(Def.FOLDER_TRASH_ENG); mailserver.setTrashActivation(false); mailserver.setOutAuth(false); } // imap if (myImapServer != null) { mailserver.setInServer(myImapServer.getHost()); if (StringUtils.indexOf(getImapServer(), myImapServer.getScheme().concat(URL_SCHEME_SEPARATOR)) == 0 || StringUtils.isEmpty(mailserver.getProtocol())) { mailserver.setProtocol(myImapServer.getScheme().replace(URL_SCHEME_SEPARATOR, "")); mailserver.setIsSSLIn( myImapServer.getScheme().equals("imaps://") || myImapServer.getScheme().equals("pops://")); } if (mailserver.getInPort() < 0 || StringUtils.indexOf(getImapServer(), ":" + Integer.toString(myImapServer.getPort())) > 0) { mailserver.setInPort(myImapServer.getPort()); } } // smtp // - if port is specified in smtpServer, override default one if (mySmtpServer != null) { mailserver.setOutServer(mySmtpServer.getHost()); if (mailserver.getOutPort() < 0 || StringUtils.indexOf(getSmtpServer(), ":" + Integer.toString(mySmtpServer.getPort())) > 0) { if (log.isTraceEnabled()) log.trace("DefaultMailServer port set to:" + mailserver.getOutPort() + ";" + "Server port set to:" + Integer.toString(mySmtpServer.getPort())); mailserver.setOutPort(mySmtpServer.getPort()); } if (getSmtpServer().startsWith(mySmtpServer.getScheme() + URL_SCHEME_SEPARATOR)) { mailserver.setIsSSLOut(mySmtpServer.getScheme().equals("smtps://")); } } if (StringUtils.isEmpty(mailserver.getInServer()) || StringUtils.isEmpty(mailserver.getProtocol()) || StringUtils.isEmpty(mailserver.getInboxPath())) { if (log.isWarningEnabled()) { log.warn("Imapserver: " + myImapServer); log.warn("SmtpServer: " + mySmtpServer); } throw new BeanException( "One or more of the following fields are empty: InServer, Protocol, InboxPath: please check bean configuration or LDAP values"); } return mailserver; }
From source file:com.photon.maven.plugins.android.AbstractAndroidMojo.java
/** * Determines which {@link IDevice}(s) to use, and performs the callback * action on it/them.//w w w .jav a 2s . c om * * @param deviceCallback * the action to perform on each device * @throws org.apache.maven.plugin.MojoExecutionException * in case there is a problem * @throws org.apache.maven.plugin.MojoFailureException * in case there is a problem */ protected void doWithDevices(final DeviceCallback deviceCallback) throws MojoExecutionException, MojoFailureException { final AndroidDebugBridge androidDebugBridge = initAndroidDebugBridge(); if (androidDebugBridge.isConnected()) { waitForInitialDeviceList(androidDebugBridge); List<IDevice> devices = Arrays.asList(androidDebugBridge.getDevices()); int numberOfDevices = devices.size(); getLog().info("Found " + numberOfDevices + " devices connected with the Android Debug Bridge"); if (devices.size() > 0) { if (StringUtils.isNotBlank(device)) { boolean deviceFound = false; if ("emulator".equals(device) || ("usb".equals(device))) { getLog().info("android.device parameter set to " + device); for (IDevice idevice : devices) { // use specified device or all emulators or all // devices if ("emulator".equals(device) && idevice.isEmulator()) { getLog().info("Emulator " + DeviceHelper.getDescriptiveName(idevice) + " found."); deviceFound = true; deviceCallback.doWithDevice(idevice); } else if ("usb".equals(device) && !idevice.isEmulator()) { getLog().info("Device " + DeviceHelper.getDescriptiveName(idevice) + " found."); deviceFound = true; deviceCallback.doWithDevice(idevice); } } } else { getLog().info("android.device parameter set to serial number: " + device); if (StringUtils.indexOf(device, ",") > -1) { deviceSerialNumberArr = device.trim().split(","); for (final IDevice idevice : devices) { for (int i = 0; i < deviceSerialNumberArr.length; i++) { if (idevice.isEmulator() && (deviceSerialNumberArr[i].equalsIgnoreCase(idevice.getAvdName()) || deviceSerialNumberArr[i] .equalsIgnoreCase(idevice.getSerialNumber()))) { getLog().info( "Emulator " + DeviceHelper.getDescriptiveName(idevice) + " found."); deviceFound = true; deviceCallback.doWithDevice(idevice); break; } else if (!idevice.isEmulator() && deviceSerialNumberArr[i].equals(idevice.getSerialNumber())) { getLog().info( "Device " + DeviceHelper.getDescriptiveName(idevice) + " found."); deviceFound = true; deviceCallback.doWithDevice(idevice); break; } } } } else { deviceSerialNumberArr = new String[1]; deviceSerialNumberArr[0] = device.trim(); for (final IDevice idevice : devices) { for (int i = 0; i < deviceSerialNumberArr.length; i++) { if (idevice.isEmulator() && (deviceSerialNumberArr[i].equalsIgnoreCase(idevice.getAvdName()) || deviceSerialNumberArr[i] .equalsIgnoreCase(idevice.getSerialNumber()))) { getLog().info( "Emulator " + DeviceHelper.getDescriptiveName(idevice) + " found."); deviceFound = true; deviceCallback.doWithDevice(idevice); break; } else if (!idevice.isEmulator() && deviceSerialNumberArr[i].equals(idevice.getSerialNumber())) { getLog().info( "Device " + DeviceHelper.getDescriptiveName(idevice) + " found."); deviceFound = true; deviceCallback.doWithDevice(idevice); break; } } } } } if (!deviceFound) { throw new MojoExecutionException("No device found for android.device=" + device); } } else { getLog().info("android.device parameter not set, using all attached devices"); for (IDevice idevice : devices) { deviceCallback.doWithDevice(idevice); } } } else { throw new MojoExecutionException("No online devices attached."); } } else { throw new MojoExecutionException("Android Debug Bridge is not connected."); } }
From source file:com.meiah.core.util.StringUtil.java
/** * ??????/* www . ja v a 2 s .c o m*/ * @param postUrl * @return */ public static String substringUrl(String postUrl) { if (StringUtils.isBlank(postUrl)) {// return postUrl; } // ?.????????://??. modified by xiegh, 2012/11/12 int beginIndex = StringUtils.indexOf(postUrl, "://"); beginIndex = (beginIndex == -1) ? 0 : (beginIndex + 3); int endIndex = postUrl.indexOf("/", beginIndex); StringBuilder sb = new StringBuilder(postUrl).reverse(); if (beginIndex != 0 || endIndex != -1) { endIndex = endIndex >= 0 ? endIndex : postUrl.length(); postUrl = postUrl.substring(beginIndex, endIndex); sb = new StringBuilder(postUrl).reverse(); } // ??.dict.baidu.com?baidu.com, gwt.google.com.cn?google.com.cn int shouldConcatToken = postUrl.toLowerCase().endsWith("cn") ? 3 : 2;// ?cn?? StringTokenizer st = new StringTokenizer(sb.toString(), "."); sb = new StringBuilder(); while (st.hasMoreTokens()) { if (shouldConcatToken-- == 0) {// ??? break; } if (sb.length() > 0) { sb.append("."); } sb.append(st.nextToken()); } return sb.reverse().toString(); }
From source file:com.egt.core.jsf.JSF.java
private static String addRequestPostBackParameters(String url) { if (StringUtils.isBlank(url)) { return null; }//from w w w. java 2s .c om String param = ""; String state = getRequestParameter(Global.PARAMETRO_RETRUQUE); if (StringUtils.isNotBlank(state)) { param += StringUtils.indexOf(url, "?") < 0 ? "?" : "&"; param += Global.PARAMETRO_RETRUCAR + "=" + true; param += "&" + Global.PARAMETRO_RETRUQUE + "=" + state; } return url + param; }