Java Code Examples for org.apache.commons.lang.StringUtils.startsWithIgnoreCase()

The following are Jave code examples for showing how to use startsWithIgnoreCase() of the org.apache.commons.lang.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: otter-G   File: DbDialectGenerator.java   View Source Code Vote up 6 votes
protected DbDialect generate(JdbcTemplate jdbcTemplate, String databaseName, int databaseMajorVersion,
                             int databaseMinorVersion, DataMediaType dataMediaType) {
    DbDialect dialect = null;

    if (StringUtils.startsWithIgnoreCase(databaseName, ORACLE)) { // for
                                                                  // oracle
        dialect = new OracleDialect(jdbcTemplate, oracleLobHandler, databaseName, databaseMajorVersion,
                                    databaseMinorVersion);
    } else if (StringUtils.startsWithIgnoreCase(databaseName, MYSQL)) { // for
                                                                        // mysql
        dialect = new MysqlDialect(jdbcTemplate, defaultLobHandler, databaseName, databaseMajorVersion,
                                   databaseMinorVersion);
    } else if (StringUtils.startsWithIgnoreCase(databaseName, TDDL_GROUP)) { // for
                                                                             // tddl
                                                                             // group
        throw new RuntimeException(databaseName + " type is not support!");
    } else if (StringUtils.startsWithIgnoreCase(databaseName, TDDL_CLIENT)) {
        throw new RuntimeException(databaseName + " type is not support!");
    }

    // diamond is delegated to mysql/oracle, so don't need to extend here

    return dialect;
}
 
Example 2
Project: ymate-payment-v2   File: WxPayBaseRequest.java   View Source Code Vote up 6 votes
/**
 * @return 提交请求并返回回应结果
 * @throws Exception 可能产生的任何异常
 */
public RESPONSE execute() throws Exception {
    Map<String, Object> _params = buildSignatureParams();
    _params.put(IWxPay.Const.SIGN, __doCreateSignature(_params, __accountMeta.getMchKey()));
    // 处理沙箱URL地址
    String _requestURL = __doGetRequestURL();
    if (!StringUtils.startsWithIgnoreCase(_requestURL, "http")) {
        _requestURL = "https://api.mch.weixin.qq.com/" + __accountMeta.getSandboxPrefix() + _requestURL;
    }
    IHttpResponse _response = HttpClientHelper.create()
            .customSSL(__accountMeta.getConnectionSocketFactory())
            .post(_requestURL, __doBuildXML(_params));
    if (_response != null) {
        if (_response.getStatusCode() == 200) {
            return __doParseResponse(_response);
        } else if (_LOG.isDebugEnabled()) {
            _LOG.debug("ResponseBody: " + _response.toString());
        }
    }
    return null;
}
 
Example 3
Project: ymate-module-sso   File: DefaultModuleCfg.java   View Source Code Vote up 5 votes
public DefaultModuleCfg(YMP owner) {
    Map<String, String> _moduleCfgs = owner.getConfig().getModuleConfigs(ISSO.MODULE_NAME);
    //
    __tokenCookieName = StringUtils.defaultIfBlank(_moduleCfgs.get("token_cookie_name"), ISSO.MODULE_NAME + "_token");
    //
    __tokenHeaderName = StringUtils.defaultIfBlank(_moduleCfgs.get("token_header_name"), "X-ModuleSSO-Token");
    //
    __tokenParamName = StringUtils.defaultIfBlank(_moduleCfgs.get("token_param_name"), "token");
    //
    __tokenMaxage = BlurObject.bind(_moduleCfgs.get("token_maxage")).toIntValue();
    //
    __tokenValidateTimeInterval = BlurObject.bind(_moduleCfgs.get("token_validate_time_interval")).toIntValue();
    //
    __cacheNamePrefix = StringUtils.trimToEmpty(_moduleCfgs.get("cache_name_prefix"));
    //
    __multiSessionEnabled = BlurObject.bind(_moduleCfgs.get("multi_session_enabled")).toBooleanValue();
    //
    __ipCheckEnabled = BlurObject.bind(_moduleCfgs.get("ip_check_enabled")).toBooleanValue();
    //
    __isClientMode = BlurObject.bind(_moduleCfgs.get("client_mode")).toBooleanValue();
    //
    __serviceAuthKey = StringUtils.trimToEmpty(_moduleCfgs.get("service_auth_key"));
    //
    if (__isClientMode) {
        __serviceBaseUrl = StringUtils.trimToNull(_moduleCfgs.get("service_base_url"));
        if (__serviceBaseUrl != null) {
            if (!StringUtils.startsWithIgnoreCase(__serviceBaseUrl, "http://") &&
                    !StringUtils.startsWithIgnoreCase(__serviceBaseUrl, "https://")) {
                throw new IllegalArgumentException("The parameter service_base_url is invalid");
            } else if (!StringUtils.endsWith(__serviceBaseUrl, "/")) {
                __serviceBaseUrl = __serviceBaseUrl + "/";
            }
        }
    }
    //
    __tokenApater = ClassUtils.impl(_moduleCfgs.get("token_adapter_class"), ISSOTokenAdapter.class, getClass());
    if (__tokenApater == null) {
        __tokenApater = new DefaultSSOTokenAdapter();
    }
    //
    __tokenStorageAdapter = ClassUtils.impl(_moduleCfgs.get("storage_adapter_class"), ISSOTokenStorageAdapter.class, getClass());
    if (!__isClientMode && __tokenStorageAdapter == null) {
        throw new IllegalArgumentException("The parameter storage_adapter_class is invalid");
    }
    //
    if (!__isClientMode) {
        __tokenAttributeAdapter = ClassUtils.impl(_moduleCfgs.get("attribute_adapter_class"), ISSOTokenAttributeAdapter.class, getClass());
    }
}
 
Example 4
Project: kaltura-ce-sakai-extension   File: KalturaAPIService.java   View Source Code Vote up 5 votes
/**
 * Method to process the KalturaMetadata object (and the XML it contains) into a list of field strings
 * @param metadata kaltura metadata object
 * @return List of field strings
 */
private List<String> convertKalturaMetadataToFieldsList(KalturaMetadata metadata) {
    List<String> fields = new ArrayList<String>();
    // if metadata exists for object
    if (metadata != null && StringUtils.isNotEmpty(metadata.xml)) {
        // check for malformed beginning of XML
        String metadataXml = metadata.xml;
        if (StringUtils.startsWithIgnoreCase(metadataXml, "xml=")){ 
            metadataXml = metadataXml.replaceAll("xml=", ""); 
        }

        // ensure XML begins with the <?xml tag
        int lastIndex = StringUtils.lastIndexOf(metadataXml, "<?xml");
        if(lastIndex > 0){
            metadataXml = StringUtils.substring(metadataXml, lastIndex);
        }

        // set the metadata's XML to the updated string
        metadata.xml = metadataXml;

        try {
            Document metadataDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(metadata.xml)));
            org.w3c.dom.Element root = metadataDoc.getDocumentElement();
            NodeList childNodes = root.getChildNodes();
            for (int i = 0; i < childNodes.getLength(); i++) {
                Node node = childNodes.item(i);
                if (node instanceof org.w3c.dom.Element) {
                    fields.add(node.getTextContent());
                }
            }
        } catch (Exception e) {
            throw new RuntimeException("Error processing metadata fields for kaltura metadata object (" + metadata.objectId + ") :: " + e + ", xml="+metadata.xml, e);
        }
    }
    return fields;
}
 
Example 5
Project: soundwave   File: InstanceTagger.java   View Source Code Vote up 5 votes
public InstanceTags getTags(String name) throws Exception {
  InstanceTags tags = new InstanceTags();
  String matchName = name;
  //All docker instances have been added a prefix cmp-. For ex:
  // pinshot-04215101
  // cmp-pinshot-newkernel-0a0111e9
  // To find out the tag, we need to get rid of the prefix.
  //
  if (StringUtils.isNotEmpty(name) && StringUtils.startsWithIgnoreCase(name, "cmp-")) {
    matchName = name.substring(4);
  }
  List<EsServiceMapping>
      mappings =
      InstanceTagger.getInstance().findMapping(matchName);
  HashSet<String> serviceMapping = new HashSet<>();
  HashSet<String> svcTag = new HashSet<>();
  HashSet<String> sysTag = new HashSet<>();
  HashSet<String> usageTag = new HashSet<>();

  for (EsServiceMapping mapping : mappings) {
    serviceMapping.add(mapping.getName());
    svcTag.add(mapping.getServiceTag());
    sysTag.add(mapping.getSysTag());
    if (!StringUtils.equals(mapping.getUsageTag(), "n/a")) {
      usageTag.add(mapping.getUsageTag());
    }
  }

  tags.setServiceMappings(serviceMapping.toArray(new String[serviceMapping.size()]));
  tags.setSvcTags(svcTag.toArray(new String[svcTag.size()]));
  tags.setSysTags(sysTag.toArray(new String[sysTag.size()]));
  tags.setUsageTags(usageTag.toArray(new String[usageTag.size()]));
  return tags;
}
 
Example 6
Project: ymate-payment-v2   File: DefaultModuleCfg.java   View Source Code Vote up 5 votes
public DefaultModuleCfg(YMP owner) {
    Map<String, String> _moduleCfgs = owner.getConfig().getModuleConfigs(IAliPay.MODULE_NAME);
    //
    __gatewayUrl = StringUtils.defaultIfBlank(_moduleCfgs.get("gateway_url"), "https://openapi.alipay.com/gateway.do");
    if (!StringUtils.startsWithIgnoreCase(__gatewayUrl, "https://") && !StringUtils.startsWithIgnoreCase(__gatewayUrl, "http://")) {
        throw new IllegalArgumentException("gateway_url address is invalid");
    }
    //
    __accountProvider = ClassUtils.impl(_moduleCfgs.get("account_provider_class"), IAliPayAccountProvider.class, getClass());
    if (__accountProvider == null) {
        __accountProvider = new DefaultAliPayAccountProvider();
        //
        AliPayAccountMeta _meta = new AliPayAccountMeta(_moduleCfgs.get(IAliPay.Const.APP_ID), _moduleCfgs.get(IAliPay.Const.SIGN_TYPE), _moduleCfgs.get("private_key"), _moduleCfgs.get("public_key"));
        _meta.setCharset(StringUtils.defaultIfBlank(_moduleCfgs.get(IAliPay.Const.CHARSET), IAliPay.Const.CHARSET_UTF8));
        _meta.setFormat(StringUtils.defaultIfBlank(_moduleCfgs.get(IAliPay.Const.FORMAT), IAliPay.Const.FORMAT_JSON));
        _meta.setNotifyUrl(StringUtils.trimToNull(_moduleCfgs.get(IAliPay.Const.NOTIFY_URL)));
        _meta.setReturnUrl(StringUtils.trimToNull(_moduleCfgs.get(IAliPay.Const.RETURN_URL)));
        //
        __defaultAccountId = _meta.getAppId();
        __accountProvider.registerAccount(_meta);
    } else {
        __defaultAccountId = StringUtils.trimToNull(_moduleCfgs.get("default_account_id"));
    }
    //
    __eventHandler = ClassUtils.impl(_moduleCfgs.get("event_handler_class"), IAliPayEventHandler.class, getClass());
    if (__eventHandler == null) {
        throw new NullArgumentException("event_handler_class");
    }
    //
    __signCheckDisabled = BlurObject.bind(_moduleCfgs.get("sign_check_disabled")).toBooleanValue();
}
 
Example 7
Project: Hydrograph   File: SubjobUtility.java   View Source Code Vote up 5 votes
private String getPortIndex(Link link) {
		if(StringUtils.startsWithIgnoreCase(link.getSourceTerminal(), Constants.INPUT_SOCKET_TYPE)){
			return StringUtils.remove(link.getSourceTerminal(), Constants.INPUT_SOCKET_TYPE);
		}else {
			return StringUtils.remove(link.getSourceTerminal(), Constants.OUTPUT_SOCKET_TYPE);
		}
	
}
 
Example 8
Project: Hydrograph   File: OutputRecordCountUtility.java   View Source Code Vote up 5 votes
private String getPortCount(String sourceTerminalId) {
	String portCount=null;
	if(StringUtils.startsWithIgnoreCase(sourceTerminalId, Constants.UNUSED_SOCKET_TYPE)){
		portCount=StringUtils.remove(sourceTerminalId, Constants.UNUSED_SOCKET_TYPE);
	}else if(StringUtils.startsWithIgnoreCase(sourceTerminalId, Constants.OUTPUT_SOCKET_TYPE)){
		portCount=StringUtils.remove(sourceTerminalId, Constants.OUTPUT_SOCKET_TYPE);
	}
	return portCount;
}
 
Example 9
Project: Hydrograph   File: SchemaPropagation.java   View Source Code Vote up 5 votes
private String getPortIndex(Link link) {
	if(StringUtils.startsWithIgnoreCase(link.getSourceTerminal(), Constants.INPUT_SOCKET_TYPE)){
		return StringUtils.remove(link.getSourceTerminal(), Constants.INPUT_SOCKET_TYPE);
	}else {
		return StringUtils.remove(link.getSourceTerminal(), Constants.OUTPUT_SOCKET_TYPE);
	}

}
 
Example 10
Project: WC   File: WCCommands.java   View Source Code Vote up 4 votes
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
    List<String> rtrn = null;
    if (label.startsWith(name)) {
        label = label.replaceFirst(name, "");
    }
    /*
    * Auto Complete normal para cada comando si está declarado
     */
    for (WCCmd cmdr : cmds) {
        if (cmdr.getName().equals(label) || cmdr.getAliases().contains(label)) {
            try {
                if ((sender instanceof Player) && (!WCServer.getUser((Player) sender).hasPermission(cmdr.getPermiso())) && !cmdr.getPermiso().equalsIgnoreCase("")) {
                    return new ArrayList<>();
                }
                rtrn = cmdr.onTabComplete(sender, cmd, label, args, args[args.length - 1], args.length - 1);
            } catch (Exception ex) {
                WCCore.getInstance().log(WCServer.Level.WARNING, "Fallo al autocompletar " + label);
            }
            break;
        }
    }
    /*
    * Si el autocomplete es null, que devuelva jugadores
     */
    if (rtrn == null) {
        rtrn = new ArrayList<>();
        for (Player p : Bukkit.getOnlinePlayers()) {
            rtrn.add(p.getName());
        }
    }
    /*
    * Autocomplete para cada argumento
     */
    ArrayList<String> rtrn2 = new ArrayList<>();
    rtrn2.addAll(rtrn);
    rtrn = rtrn2;
    if (!(args[args.length - 1].isEmpty() || args[args.length - 1] == null)) {
        List<String> remv = new ArrayList<>();
        for (String s : rtrn) {
            if (!StringUtils.startsWithIgnoreCase(s, args[args.length - 1])) {
                remv.add(s);
            }
        }
        rtrn.removeAll(remv);
    }
    return rtrn;
}
 
Example 11
Project: otter-G   File: CanalAction.java   View Source Code Vote up 4 votes
/**
 * 修改canal
 */
public void doEdit(@FormGroup("canalInfo") Group canalInfo,
                   @FormGroup("canalParameterInfo") Group canalParameterInfo,
                   @FormField(name = "formCanalError", group = "canalInfo") CustomErrors err,
                   @FormField(name = "formHeartBeatError", group = "canalParameterInfo") CustomErrors heartBeatErr,
                   Navigator nav) throws Exception {
    Canal canal = new Canal();
    CanalParameter parameter = new CanalParameter();
    canalInfo.setProperties(canal);
    canalParameterInfo.setProperties(parameter);

    String zkClustersString = canalParameterInfo.getField("zkClusters").getStringValue();
    String[] zkClusters = StringUtils.split(zkClustersString, ";");
    parameter.setZkClusters(Arrays.asList(zkClusters));

    Long zkClusterId = canalParameterInfo.getField("autoKeeperClusterId").getLongValue();
    parameter.setZkClusterId(zkClusterId);

    String dbAddressesString = canalParameterInfo.getField("groupDbAddresses").getStringValue();
    if (StringUtils.isNotEmpty(dbAddressesString)) {
        List<List<DataSourcing>> dbSocketAddress = new ArrayList<List<DataSourcing>>();
        String[] dbAddresses = StringUtils.split(dbAddressesString, ";");
        for (String dbAddressString : dbAddresses) {
            List<DataSourcing> groupDbSocketAddress = new ArrayList<DataSourcing>();
            String[] groupDbAddresses = StringUtils.split(dbAddressString, ",");
            for (String groupDbAddress : groupDbAddresses) {
                String strs[] = StringUtils.split(groupDbAddress, ":");
                InetSocketAddress address = new InetSocketAddress(strs[0].trim(), Integer.valueOf(strs[1]));
                SourcingType type = parameter.getSourcingType();
                if (strs.length > 2) {
                    type = SourcingType.valueOf(strs[2]);
                }
                groupDbSocketAddress.add(new DataSourcing(type, address));
            }
            dbSocketAddress.add(groupDbSocketAddress);
        }

        parameter.setGroupDbAddresses(dbSocketAddress);
    }

    String positionsString = canalParameterInfo.getField("positions").getStringValue();
    if (StringUtils.isNotEmpty(positionsString)) {
        String positions[] = StringUtils.split(positionsString, ";");
        parameter.setPositions(Arrays.asList(positions));
    }

    if (parameter.getDetectingEnable() && StringUtils.startsWithIgnoreCase(parameter.getDetectingSQL(), "select")) {
        heartBeatErr.setMessage("invaliedHeartBeat");
        return;
    }

    canal.setCanalParameter(parameter);

    try {
        canalService.modify(canal);
    } catch (RepeatConfigureException rce) {
        err.setMessage("invalidCanal");
        return;
    }

    nav.redirectToLocation("canalList.htm");
}
 
Example 12
Project: otter-G   File: MediaPushDataSourceHandler.java   View Source Code Vote up 4 votes
public static boolean isMediaPushDataSource(String url) {
    return StringUtils.startsWithIgnoreCase(url, "jdbc:") && StringUtils.containsIgnoreCase(url, "groupKey");
}
 
Example 13
Project: PA   File: PACommands.java   View Source Code Vote up 4 votes
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
    List<String> rtrn = null;
    if (label.startsWith(name)) {
        label = label.replaceFirst(name, "");
    }
    /*
    * Auto Complete normal para cada comando si está declarado
     */
    for (PACmd cmdr : cmds) {
        if (cmdr.getName().equals(label) || cmdr.getAliases().contains(label)) {
            try {
                if ((sender instanceof Player) && (!PAServer.getUser((Player) sender).isOnRank(cmdr.getGroup()))) {
                    return new ArrayList<>();
                }
                rtrn = cmdr.onTabComplete(sender, cmd, label, args, args[args.length - 1], args.length - 1);
            } catch (Exception ex) {
                Log.log(Log.Level.WARNING, "Fallo al autocompletar " + label);
            }
            break;
        }
    }
    /*
    * Si el autocomplete es null, que devuelva jugadores
     */
    if (rtrn == null) {
        rtrn = new ArrayList<>();
        for (Player p : Bukkit.getOnlinePlayers()) {
            rtrn.add(p.getName());
        }
    }
    /*
    * Autocomplete para cada argumento
     */
    ArrayList<String> rtrn2 = new ArrayList<>();
    rtrn2.addAll(rtrn);
    rtrn = rtrn2;
    if (!(args[args.length - 1].isEmpty() || args[args.length - 1] == null)) {
        List<String> remv = new ArrayList<>();
        for (String s : rtrn) {
            if (!StringUtils.startsWithIgnoreCase(s, args[args.length - 1])) {
                remv.add(s);
            }
        }
        rtrn.removeAll(remv);
    }
    return rtrn;
}