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

The following examples show how to use org.apache.commons.lang.StringUtils#containsIgnoreCase() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BudgetAdjustmentAccountingLineAccountIncomeStreamValidation.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Validate that, if current adjustment amount is non zero, account has an associated income stream chart and account
 * @see org.kuali.kfs.sys.document.validation.Validation#validate(org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent)
 */
public boolean validate(AttributedDocumentEvent event) {
    boolean accountNumberAllowed = true;
    if (getAccountingLineForValidation().getCurrentBudgetAdjustmentAmount().isNonZero()) {
        getAccountingLineForValidation().refreshReferenceObject("account");
        
        if (!ObjectUtils.isNull(getAccountingLineForValidation().getAccount())) {
            //KFSMI-4877: if fund group is in system parameter values then income stream account number must exist.
            String fundGroupCode = getAccountingLineForValidation().getAccount().getSubFundGroup().getFundGroupCode();
            String incomeStreamRequiringFundGroupCode = SpringContext.getBean(ParameterService.class).getParameterValueAsString(Account.class, KFSConstants.ChartApcParms.INCOME_STREAM_ACCOUNT_REQUIRING_FUND_GROUPS);
            if (StringUtils.containsIgnoreCase(fundGroupCode, incomeStreamRequiringFundGroupCode)) {
                if (ObjectUtils.isNull(getAccountingLineForValidation().getAccount().getIncomeStreamAccount())) {
                    GlobalVariables.getMessageMap().putError(KFSPropertyConstants.ACCOUNT_NUMBER, KFSKeyConstants.ERROR_DOCUMENT_BA_NO_INCOME_STREAM_ACCOUNT, getAccountingLineForValidation().getAccountNumber());
                    accountNumberAllowed = false;
                }
            }
        }
    }
    
    return accountNumberAllowed;
}
 
Example 2
Source File: KylinUserService.java    From kylin with Apache License 2.0 6 votes vote down vote up
private List<ManagedUser> getManagedUsersByFuzzMatching(String nameSeg, boolean isFuzzMatch,
        List<ManagedUser> userList, String groupName) {
    aclEvaluate.checkIsGlobalAdmin();
    //for name fuzzy matching
    if (StringUtils.isBlank(nameSeg) && StringUtils.isBlank(groupName)) {
        return userList;
    }

    List<ManagedUser> usersByFuzzyMatching = new ArrayList<>();
    for (ManagedUser u : userList) {
        if (!isFuzzMatch && StringUtils.equals(u.getUsername(), nameSeg) && isUserInGroup(u, groupName)) {
            usersByFuzzyMatching.add(u);
        }
        if (isFuzzMatch && StringUtils.containsIgnoreCase(u.getUsername(), nameSeg)
                && isUserInGroup(u, groupName)) {
            usersByFuzzyMatching.add(u);
        }

    }
    return usersByFuzzyMatching;
}
 
Example 3
Source File: FeedsGroupControll.java    From rebuild with GNU General Public License v3.0 6 votes vote down vote up
@RequestMapping("group-list")
public void groupList(HttpServletRequest request, HttpServletResponse response) throws IOException {
    final ID user = getRequestUser(request);
    final String query = getParameter(request, "q");
    Set<Team> teams = Application.getUserStore().getUser(user).getOwningTeams();

    JSONArray ret = new JSONArray();
    for (Team t : teams) {
        if (StringUtils.isBlank(query)
                || StringUtils.containsIgnoreCase(t.getName(), query)) {
            JSONObject o = JSONUtils.toJSONObject(
                    new String[] { "id", "name" }, new Object[] { t.getIdentity(), t.getName() });
            ret.add(o);
            if (ret.size() >= 20) {
                break;
            }
        }
    }
    writeSuccess(response, ret);
}
 
Example 4
Source File: ModuleLookupableHelperServiceImpl.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
    super.setBackLocation((String) fieldValues.get(KFSConstants.BACK_LOCATION));
    super.setDocFormKey((String) fieldValues.get(KFSConstants.DOC_FORM_KEY));
    List<ModuleService> modules = SpringContext.getBean(KualiModuleService.class).getInstalledModuleServices();
    String codeValue = fieldValues.get("moduleCode");
    String nameValue = fieldValues.get("moduleName");
    List<KualiModuleBO> boModules = new ArrayList();
    String tempNamespaceName;
    for (ModuleService mod : modules) {
        if (!StringUtils.isEmpty(nameValue) && !StringUtils.containsIgnoreCase(mod.getModuleConfiguration().getNamespaceCode(), nameValue)) {
            continue;
        }
        tempNamespaceName = SpringContext.getBean(KualiModuleService.class).getNamespaceName(mod.getModuleConfiguration().getNamespaceCode());
        if (!StringUtils.isEmpty(codeValue) && !StringUtils.containsIgnoreCase(tempNamespaceName, codeValue)) {
            continue;
        }
        boModules.add(new KualiModuleBO(mod.getModuleConfiguration().getNamespaceCode(), 
                mod.getModuleConfiguration().getNamespaceCode(), tempNamespaceName));
    }
    return boModules;
}
 
Example 5
Source File: LoginPageModelImpl.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
@Override
public void setServerName(final String serverName) {
    if (!StringUtils.equals(this.serverName, serverName)) {
        final String newServerName;
        // Allow just the server name as a short hand
        if (StringUtils.isNotEmpty(serverName) && !StringUtils.contains(serverName, UrlHelper.URL_SEPARATOR)
                && !StringUtils.equals(serverName, TfPluginBundle.message(TfPluginBundle.KEY_USER_ACCOUNT_PANEL_VSO_SERVER_NAME))
                && !StringUtils.containsIgnoreCase(serverName, UrlHelper.HOST_VSO)
                && !StringUtils.containsIgnoreCase(serverName, UrlHelper.HOST_TFS_ALL_IN)) {
            // no slash, not "Microsoft Account" and does not contain visualstudio.com or tfsallin.net
            // means it must just be a on-premise TFS server name, so add all the normal stuff
            newServerName = String.format(DEFAULT_SERVER_FORMAT, serverName);
        } else if ((!StringUtils.contains(serverName, UrlHelper.URL_SEPARATOR)
                && (StringUtils.containsIgnoreCase(serverName, UrlHelper.HOST_VSO) ||
                    StringUtils.containsIgnoreCase(serverName, UrlHelper.HOST_TFS_ALL_IN))) ||
                (UrlHelper.isOrganizationUrl(String.format(DEFAULT_VSTS_ACCOUNT_FORMAT, serverName)) )) {
            // add "https://" to VSTS accounts if it isn't provided
            newServerName = String.format(DEFAULT_VSTS_ACCOUNT_FORMAT, serverName);
        } else {
            newServerName = serverName;
        }
        setServerNameInternal(newServerName);
    }
}
 
Example 6
Source File: RESTUtil.java    From rest-client with Apache License 2.0 5 votes vote down vote up
/**
* 
* @Title: isHtml 
* @Description: Check if it is HTML string 
* @param @param html
* @param @return 
* @return boolean
* @throws
 */
public static boolean isHtml(String html)
{
    if (StringUtils.isEmpty(html))
    {
        return false;
    }

    if (StringUtils.containsIgnoreCase(html, RESTConst.HTML_LABEL))
    {
        return true;
    }

    return false;
}
 
Example 7
Source File: PrincipalPropertySearchReport.java    From cosmo with Apache License 2.0 5 votes vote down vote up
private boolean matchText(String test,
                          String match) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Matching {} against {}", test,  match);
    }
    return StringUtils.containsIgnoreCase(test, match);
}
 
Example 8
Source File: CollectorReportServiceImpl.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Sends email message to batch mailing list notifying of email send failures during the collector processing
 *
 * @param collectorReportData - data from collector run
 */
protected void sendEmailSendFailureNotice(CollectorReportData collectorReportData) {
    MailMessage message = new MailMessage();

    String returnAddress = parameterService.getParameterValueAsString(KFSConstants.ParameterNamespaces.GL, "Batch", KFSConstants.FROM_EMAIL_ADDRESS_PARM_NM);
    if(StringUtils.isEmpty(returnAddress)) {
        returnAddress = mailService.getBatchMailingList();
    }
    message.setFromAddress(returnAddress);

    String subject = configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_COLLECTOR_EMAILSEND_NOTIFICATION_SUBJECT);
    message.setSubject(subject);

    boolean hasEmailSendErrors = false;

    String body = configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_COLLECTOR_EMAILSEND_NOTIFICATION_BODY);
    for (String batchId : collectorReportData.getEmailSendingStatus().keySet()) {
        String emailStatus = collectorReportData.getEmailSendingStatus().get(batchId);
        if (StringUtils.containsIgnoreCase(emailStatus, "error")) {
            body += "Batch: " + batchId + " - " + emailStatus + "\n";
            hasEmailSendErrors = true;
        }
    }
    message.setMessage(body);

    message.addToAddress(mailService.getBatchMailingList());

    try {
        if (hasEmailSendErrors) {
            mailService.sendMessage(message);
            LOG.info("Email failure notice has been sent to : " + message.getToAddresses() );
        }
    }
    catch (Exception e) {
        LOG.error("sendErrorEmail() Invalid email address. Message not sent", e);
    }
}
 
Example 9
Source File: ImpalaOperationParser.java    From atlas with Apache License 2.0 5 votes vote down vote up
public static ImpalaOperationType getImpalaOperationSubType(ImpalaOperationType operationType, String queryText) {
    if (operationType == ImpalaOperationType.QUERY) {
        if (StringUtils.containsIgnoreCase(queryText, "insert into")) {
            return ImpalaOperationType.INSERT;
        } else if (StringUtils.containsIgnoreCase(queryText, "insert overwrite")) {
            return ImpalaOperationType.INSERT_OVERWRITE;
        }
    }

    return ImpalaOperationType.UNKNOWN;
}
 
Example 10
Source File: DeleteWorkspaceCommand.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
/**
 * There is no useful output from this command unless there is an error. This method parses the error and throws if
 * one exists.
 */
@Override
public String parseOutput(final String stdout, final String stderr) {
    // First check stderr for "not found" message
    if (StringUtils.containsIgnoreCase(stderr, "could not be found")) {
        // No workspace existed, so ignore the error
        return StringUtils.EMPTY;
    }
    // Throw if there was any other error
    super.throwIfError(stderr);

    // There is no useful output on success
    return StringUtils.EMPTY;
}
 
Example 11
Source File: ServerContextTableModel.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
private boolean rowContains(ServerContext repositoryRow) {
    // search for the string in a case insensitive way
    // check each column for a match, if any column contains the string the result is true
    for (int c = 0; c < columns.length; c++) {
        if (StringUtils.containsIgnoreCase(getValueFor(repositoryRow, c), filter)) {
            return true;
        }
    }

    return false;
}
 
Example 12
Source File: RangerKMSDB.java    From ranger with Apache License 2.0 5 votes vote down vote up
private int getDBFlavor(Configuration newConfig) {
	String[] propertyNames = { PROPERTY_PREFIX+DB_DIALECT,PROPERTY_PREFIX+DB_DRIVER,PROPERTY_PREFIX+DB_URL};

	for(String propertyName : propertyNames) {
		String propertyValue = newConfig.get(propertyName);
		if(StringUtils.isBlank(propertyValue)) {
			continue;
		}
		if (StringUtils.containsIgnoreCase(propertyValue, "mysql")) {
			return DB_FLAVOR_MYSQL;
		} else if (StringUtils.containsIgnoreCase(propertyValue, "oracle")) {
			return DB_FLAVOR_ORACLE;
		} else if (StringUtils.containsIgnoreCase(propertyValue, "postgresql")) {
			return DB_FLAVOR_POSTGRES;
		} else if (StringUtils.containsIgnoreCase(propertyValue, "sqlserver")) {
			return DB_FLAVOR_SQLSERVER;
		} else if (StringUtils.containsIgnoreCase(propertyValue, "mssql")) {
			return DB_FLAVOR_SQLSERVER;
		} else if (StringUtils.containsIgnoreCase(propertyValue, "sqlanywhere")) {
			return DB_FLAVOR_SQLANYWHERE;
		} else if (StringUtils.containsIgnoreCase(propertyValue, "sqla")) {
			return DB_FLAVOR_SQLANYWHERE;
		}else {
			if(logger.isDebugEnabled()) {
				logger.debug("DB Flavor could not be determined from property - " + propertyName + "=" + propertyValue);
			}
		}
	}
	logger.error("DB Flavor could not be determined");
	return DB_FLAVOR_UNKNOWN;
}
 
Example 13
Source File: RangerRESTClient.java    From ranger with Apache License 2.0 5 votes vote down vote up
private void init(Configuration config) {
	try {
		gsonBuilder = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create();
	} catch(Throwable excp) {
		LOG.fatal("RangerRESTClient.init(): failed to create GsonBuilder object", excp);
	}

	mIsSSL = StringUtils.containsIgnoreCase(mUrl, "https");

	if (mIsSSL) {

		InputStream in = null;

		try {
			in = getFileInputStream(mSslConfigFileName);

			if (in != null) {
				config.addResource(in);
			}

			mKeyStoreURL = config.get(RANGER_POLICYMGR_CLIENT_KEY_FILE_CREDENTIAL);
			mKeyStoreAlias = RANGER_POLICYMGR_CLIENT_KEY_FILE_CREDENTIAL_ALIAS;
			mKeyStoreType = config.get(RANGER_POLICYMGR_CLIENT_KEY_FILE_TYPE, RANGER_POLICYMGR_CLIENT_KEY_FILE_TYPE_DEFAULT);
			mKeyStoreFile = config.get(RANGER_POLICYMGR_CLIENT_KEY_FILE);

			mTrustStoreURL = config.get(RANGER_POLICYMGR_TRUSTSTORE_FILE_CREDENTIAL);
			mTrustStoreAlias = RANGER_POLICYMGR_TRUSTSTORE_FILE_CREDENTIAL_ALIAS;
			mTrustStoreType = config.get(RANGER_POLICYMGR_TRUSTSTORE_FILE_TYPE, RANGER_POLICYMGR_TRUSTSTORE_FILE_TYPE_DEFAULT);
			mTrustStoreFile = config.get(RANGER_POLICYMGR_TRUSTSTORE_FILE);
		} catch (IOException ioe) {
			LOG.error("Unable to load SSL Config FileName: [" + mSslConfigFileName + "]", ioe);
		} finally {
			close(in, mSslConfigFileName);
		}

	}
}
 
Example 14
Source File: AccountRule.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * the income stream account is required if account's sub fund group code's fund group code is either GF or CG.
 *
 * @param newAccount
 * @return true if fund group code (obtained through sub fund group) is in the system parameter INCOME_STREAM_ACCOUNT_REQUIRING_FUND_GROUPS (values GF;CG)
 * else return false.
 */
protected boolean checkIncomeStreamAccountRule() {
    // KFSMI-4877: if fund group is in system parameter values then income stream account number must exist.
    if ( ObjectUtils.isNotNull(newAccount.getSubFundGroup()) && StringUtils.isNotBlank(newAccount.getSubFundGroup().getFundGroupCode())) {
        if (ObjectUtils.isNull(newAccount.getIncomeStreamAccount())) {
            String incomeStreamRequiringFundGroupCode = SpringContext.getBean(ParameterService.class).getParameterValueAsString(Account.class, KFSConstants.ChartApcParms.INCOME_STREAM_ACCOUNT_REQUIRING_FUND_GROUPS);
            if (StringUtils.containsIgnoreCase(newAccount.getSubFundGroup().getFundGroupCode(), incomeStreamRequiringFundGroupCode)) {
                GlobalVariables.getMessageMap().putError(KFSPropertyConstants.ACCOUNT_NUMBER, KFSKeyConstants.ERROR_DOCUMENT_BA_NO_INCOME_STREAM_ACCOUNT, newAccount.getAccountNumber());
                return false;
            }
        }
    }
    return true;
}
 
Example 15
Source File: TaskFilter.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param node
 * @param task
 * @return true if the search string matches at least one field of the task of if this methods returns true for any descendant.
 */
private boolean isVisibleBySearchString(final TaskNode node, final TaskDO task, final TaskDao taskDao, final PFUserDO user)
{
  final Boolean cachedVisibility = taskVisibility.get(task.getId());
  if (cachedVisibility != null) {
    return cachedVisibility;
  }
  if (isVisibleByStatus(node, task) == false && node.isRootNode() == false) {
    taskVisibility.put(task.getId(), false);
    return false;
  }
  if (taskDao != null && taskDao.hasSelectAccess(user, node.getTask(), false) == false) {
    return false;
  }
  final PFUserDO responsibleUser = Registry.instance().getUserGroupCache().getUser(task.getResponsibleUserId());
  final String username = responsibleUser != null ? responsibleUser.getFullname() + " " + responsibleUser.getUsername() : null;
  if (StringUtils.containsIgnoreCase(task.getTitle(), this.searchString) == true
      || StringUtils.containsIgnoreCase(task.getReference(), this.searchString) == true
      || StringUtils.containsIgnoreCase(task.getShortDescription(), this.searchString) == true
      || StringUtils.containsIgnoreCase(task.getDescription(), this.searchString) == true
      || StringUtils.containsIgnoreCase(task.getShortDisplayName(), this.searchString) == true
      || StringUtils.containsIgnoreCase(username, this.searchString) == true
      || StringUtils.containsIgnoreCase(task.getWorkpackageCode(), this.searchString) == true) {
    taskVisibility.put(task.getId(), true);
    tasksMatched.add(task.getId());
    return true;
  } else if (node.hasChilds() == true && node.isRootNode() == false) {
    for (final TaskNode childNode : node.getChilds()) {
      final TaskDO childTask = childNode.getTask();
      if (isVisibleBySearchString(childNode, childTask, taskDao, user) == true) {
        taskVisibility.put(childTask.getId(), true);
        return true;
      }
    }
  }
  taskVisibility.put(task.getId(), false);
  return false;
}
 
Example 16
Source File: VfsTableModelFileNameRowFilter.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
boolean checkIfInclude(String baseName, String patternText) {
  Optional<Pattern> pattern = Optional.empty();
  try {
    String patternString = preparePatternString(patternText);
    pattern = Optional.of(Pattern.compile(patternString));
  } catch (PatternSyntaxException pse) {
    LOGGER.error(pse.getMessage());
    //if pattern can't be compiled we will use String contains test
  }
  return StringUtils.containsIgnoreCase(baseName, patternText) || pattern.map(p -> p.matcher(baseName).matches()).orElse(false);
}
 
Example 17
Source File: Portfolio.java    From PE-HFT-Java with GNU General Public License v3.0 5 votes vote down vote up
public Metric findSymbols(String searchStr, int numResults) throws Exception {

		ArrayList<String> id = new ArrayList<String>();
		ArrayList<String> description = new ArrayList<String>();
		ArrayList<String> exchange = new ArrayList<String>();

		Metric allSymbols = getAllSymbolsList();
		String[] idStrings = allSymbols.getStringArray("id");
		String[] descriptionString = allSymbols.getStringArray("description");
		String[] exchangeString = allSymbols.getStringArray("exchange");

		for (int i = 0; i < idStrings.length; i++) {
			if (StringUtils.containsIgnoreCase(idStrings[i], searchStr) || StringUtils.containsIgnoreCase(descriptionString[i], searchStr)) {
				id.add(idStrings[i]);
				description.add(descriptionString[i]);
				exchange.add(exchangeString[i]);
			}
			if (id.size() >= numResults) {
				break;
			}
		}

		Metric result = new Metric();

		ArrayCache idCache = new ArrayCache(id.toArray(new String[0]));
		result.setData("id", idCache);

		ArrayCache descriptionCache = new ArrayCache(description.toArray(new String[0]));
		result.setData("description", descriptionCache);

		ArrayCache exchangeCache = new ArrayCache(exchange.toArray(new String[0]));
		result.setData("exchange", exchangeCache);

		return result;
	}
 
Example 18
Source File: AccessService.java    From kylin with Apache License 2.0 4 votes vote down vote up
private boolean needAdd(String nameSeg, boolean isCaseSensitive, String name) {
    return isCaseSensitive && StringUtils.contains(name, nameSeg)
            || !isCaseSensitive && StringUtils.containsIgnoreCase(name, nameSeg);
}
 
Example 19
Source File: DatabaseTableMeta.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
private boolean compareTableMeta(TableMeta source, TableMeta target) {
    if (!StringUtils.equalsIgnoreCase(source.getSchema(), target.getSchema())) {
        return false;
    }

    if (!StringUtils.equalsIgnoreCase(source.getTable(), target.getTable())) {
        return false;
    }

    List<FieldMeta> sourceFields = source.getFields();
    List<FieldMeta> targetFields = target.getFields();
    if (sourceFields.size() != targetFields.size()) {
        return false;
    }

    for (int i = 0; i < sourceFields.size(); i++) {
        FieldMeta sourceField = sourceFields.get(i);
        FieldMeta targetField = targetFields.get(i);
        if (!StringUtils.equalsIgnoreCase(sourceField.getColumnName(), targetField.getColumnName())) {
            return false;
        }

        // if (!StringUtils.equalsIgnoreCase(sourceField.getColumnType(),
        // targetField.getColumnType())) {
        // return false;
        // }

        // https://github.com/alibaba/canal/issues/1100
        // 支持一下 int vs int(10)
        if ((sourceField.isUnsigned() && !targetField.isUnsigned())
            || (!sourceField.isUnsigned() && targetField.isUnsigned())) {
            return false;
        }

        String sign = sourceField.isUnsigned() ? "unsigned" : "signed";
        String sourceColumnType = StringUtils.removeEndIgnoreCase(sourceField.getColumnType(), sign).trim();
        String targetColumnType = StringUtils.removeEndIgnoreCase(targetField.getColumnType(), sign).trim();

        boolean columnTypeCompare = false;
        columnTypeCompare |= StringUtils.containsIgnoreCase(sourceColumnType, targetColumnType);
        columnTypeCompare |= StringUtils.containsIgnoreCase(targetColumnType, sourceColumnType);
        if (!columnTypeCompare) {
            return false;
        }

        // if (!StringUtils.equalsIgnoreCase(sourceField.getDefaultValue(),
        // targetField.getDefaultValue())) {
        // return false;
        // }

        if (sourceField.isNullable() != targetField.isNullable()) {
            return false;
        }

        // mysql会有一种处理,针对show create只有uk没有pk时,会在desc默认将uk当做pk
        boolean isSourcePkOrUk = sourceField.isKey() || sourceField.isUnique();
        boolean isTargetPkOrUk = targetField.isKey() || targetField.isUnique();
        if (isSourcePkOrUk != isTargetPkOrUk) {
            return false;
        }
    }

    return true;
}
 
Example 20
Source File: TableMeta.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public boolean isUnsigned() {
    return StringUtils.containsIgnoreCase(columnType, "unsigned");
}