List of usage examples for org.apache.commons.lang StringUtils equalsIgnoreCase
public static boolean equalsIgnoreCase(String str1, String str2)
Compares two Strings, returning true
if they are equal ignoring the case.
From source file:com.sfs.whichdoctor.beans.TagBean.java
/** * Allow delete./*from w w w . ja v a 2s .c o m*/ * * @param objectType the object type * @param user the user * @param privileges the privileges * * @return true, if successful */ public final boolean allowDelete(final String objectType, final UserBean user, final PrivilegesBean privileges) { boolean allowDelete = false; if (privileges.getPrivilege(user, objectType, "modify")) { if (StringUtils.equals(this.getTagType(), "Finance")) { if (user.isFinancialUser()) { allowDelete = true; } } else { allowDelete = true; } } if (StringUtils.equalsIgnoreCase(this.getTagType(), "Private")) { allowDelete = true; } return allowDelete; }
From source file:com.kylinolap.metadata.validation.rule.FunctionRule.java
@Override public void validate(CubeDesc cube, ValidateContext context) { List<MeasureDesc> measures = cube.getMeasures(); List<FunctionDesc> countFuncs = new ArrayList<FunctionDesc>(); Iterator<MeasureDesc> it = measures.iterator(); while (it.hasNext()) { MeasureDesc measure = it.next(); FunctionDesc func = measure.getFunction(); ParameterDesc parameter = func.getParameter(); if (parameter == null) { context.addResult(ResultLevel.ERROR, "Must define parameter for function " + func.getExpression() + " in " + measure.getName()); return; }// w w w . j a va 2 s . co m String type = func.getParameter().getType(); String value = func.getParameter().getValue(); if (StringUtils.isEmpty(type)) { context.addResult(ResultLevel.ERROR, "Must define type for parameter type " + func.getExpression() + " in " + measure.getName()); return; } if (StringUtils.isEmpty(value)) { context.addResult(ResultLevel.ERROR, "Must define type for parameter value " + func.getExpression() + " in " + measure.getName()); return; } if (StringUtils.isEmpty(func.getReturnType())) { context.addResult(ResultLevel.ERROR, "Must define return type for function " + func.getExpression() + " in " + measure.getName()); return; } if (StringUtils.equalsIgnoreCase(FunctionDesc.PARAMETER_TYPE_COLUMN, type)) { validateColumnParameter(context, cube, value); } else if (StringUtils.equals(FunctionDesc.PARAMTER_TYPE_CONSTANT, type)) { validateCostantParameter(context, cube, value); } validateReturnType(context, cube, func); if (func.isCount()) countFuncs.add(func); } if (countFuncs.size() != 1) { context.addResult(ResultLevel.ERROR, "Must define one and only one count(1) function, but there are " + countFuncs.size() + " -- " + countFuncs); } }
From source file:eu.arthepsy.sonar.plugins.elixir.language.ElixirParser.java
private void parseLines(List<String> lines) { hasDoc = false;// ww w .ja v a2 s. co m inClass = false; lineCount = lines.size(); for (int i = 0; i < lineCount; i++) { String line = lines.get(i); if (StringUtils.isBlank(line)) { emptyLineCount++; } docMatcher.reset(line); boolean inDoc = docMatcher.find(); if (inDoc) { commentLineCount++; String docHead = docMatcher.group(2).trim(); if (!(StringUtils.equalsIgnoreCase(docHead, "false") || StringUtils.equalsIgnoreCase(docHead, "nil"))) { switch (docMatcher.group(1)) { case "doc": hasDoc = true; break; case "moduledoc": if (inClass) { documentedClassCount++; } break; case "typedoc": break; } } } heredocMatcher.reset(line); if (heredocMatcher.find()) { while (i < lineCount - 1) { if (inDoc) { commentLineCount++; } i++; line = lines.get(i); if (line.matches("^\\s*\"\"\"\\s*$")) { break; } } continue; } defMatcher.reset(line); if (defMatcher.find()) { switch (defMatcher.group(1)) { case "module": classCount++; inClass = true; break; case "": publicFunctionCount++; if (hasDoc) { documentedPublicFunctionCount++; } break; case "p": privateFunctionCount++; if (hasDoc) { documentedPrivateFunctionCount++; } break; } hasDoc = false; } if (line.matches("^\\s*#.*$")) { commentLineCount++; } } }
From source file:com.glaf.core.db.DataTableBean.java
/** * ????/*from w ww . j a v a 2 s .c om*/ * * @param sysDataTable * ? * @param loginContext * * @param ipAddress * IP? */ public void checkPermission(SysDataTable sysDataTable, LoginContext loginContext, String ipAddress) { boolean hasPermission = false; /** * ?????? */ if (!StringUtils.equals(sysDataTable.getAccessType(), "PUB")) { /** * IP??? */ if (StringUtils.isNotEmpty(sysDataTable.getAddressPerms())) { List<String> addressList = StringTools.split(sysDataTable.getAddressPerms()); for (String addr : addressList) { if (StringUtils.equals(ipAddress, addr)) { hasPermission = true; } if (StringUtils.equals(ipAddress, "127.0.0.1")) { hasPermission = true; } if (StringUtils.equals(ipAddress, "localhost")) { hasPermission = true; } if (addr.endsWith("*")) { String tmp = addr.substring(0, addr.indexOf("*")); if (StringUtils.contains(ipAddress, tmp)) { hasPermission = true; } } } if (!hasPermission) { throw new RuntimeException("Permission denied."); } } /** * ??? */ if (StringUtils.isNotEmpty(sysDataTable.getPerms()) && !StringUtils.equalsIgnoreCase(sysDataTable.getPerms(), "anyone")) { if (loginContext.hasSystemPermission() || loginContext.hasAdvancedPermission()) { hasPermission = true; } List<String> permissions = StringTools.split(sysDataTable.getPerms()); for (String perm : permissions) { if (loginContext.getPermissions().contains(perm)) { hasPermission = true; } if (loginContext.getRoles().contains(perm)) { hasPermission = true; } if (StringUtils.isNotEmpty(perm) && StringUtils.isNumeric(perm)) { if (loginContext.getRoleIds().contains(Long.parseLong(perm))) { hasPermission = true; } } } if (!hasPermission) { throw new RuntimeException("Permission denied."); } } } }
From source file:eu.arthepsy.sonar.plugins.scapegoat.rule.ScapegoatQualityProfile.java
private void processRule(RulesProfile profile, SMInputCursor ruleC, ValidationMessages messages) throws XMLStreamException { String key = null, severity = Severity.defaultSeverity(), status = null; SMInputCursor cursor = ruleC.childElementCursor(); while (cursor.getNext() != null) { String nodeName = cursor.getLocalName(); if (StringUtils.equalsIgnoreCase("key", nodeName)) { key = XmlUtils.getNodeText(cursor); } else if (StringUtils.equalsIgnoreCase("severity", nodeName)) { severity = XmlUtils.getNodeText(cursor); } else if (StringUtils.equalsIgnoreCase("status", nodeName)) { status = XmlUtils.getNodeText(cursor); }//from w w w . j a v a 2s.c om } if (status != null && RuleStatus.valueOf(status) != RuleStatus.READY) { return; } profile.activateRule(Rule.create(ScapegoatRulesDefinition.SCAPEGOAT_REPOSITORY, key), RulePriority.valueOf(severity)); }
From source file:hydrograph.ui.dataviewer.filter.FilterValidator.java
/** * Checks if all filter conditions are valid. * //w w w . j ava 2 s .c om * @param conditionList * the condition list * @param fieldsAndTypes * the fields and types * @param fieldNames * the field names * @param debugDataViewer * the debug data viewer * @return true, if is all filter conditions valid */ public boolean isAllFilterConditionsValid(List<Condition> conditionList, Map<String, String> fieldsAndTypes, String[] fieldNames, DebugDataViewer debugDataViewer) { Map<String, String[]> conditionalOperatorsMap = FilterHelper.INSTANCE.getTypeBasedOperatorMap(); for (int index = 0; index < conditionList.size(); index++) { Condition condition = conditionList.get(index); String relationalOperator = condition.getRelationalOperator(); String fieldName = condition.getFieldName(); String conditional = condition.getConditionalOperator(); String value1 = condition.getValue1(); String value2 = condition.getValue2(); if (index != 0 && StringUtils.isBlank(relationalOperator)) { logger.trace("Relational Operator at {} is blank" + index); return false; } if (StringUtils.isBlank(fieldName) || StringUtils.isBlank(conditional) || StringUtils.isBlank(value1)) { logger.trace("Field name at {} is blank" + index); return false; } if (FilterConstants.BETWEEN.equalsIgnoreCase(conditional)) { if (StringUtils.isBlank(value2)) { logger.trace("Value 2 at {} is blank" + index); return false; } } if (StringUtils.equalsIgnoreCase(FilterConstants.BETWEEN_FIELD, conditional)) { if (StringUtils.isBlank(value2)) { logger.trace("Value 2 at {} is blank" + index); return false; } } if (index != 0 && !relationalList.contains(relationalOperator)) { logger.trace("Relational Operator at {} is incorrect", index); return false; } if (!Arrays.asList(fieldNames).contains(fieldName)) { logger.trace("Field Name at {} is incorrect {}", index); return false; } String type = getType(fieldName, fieldsAndTypes); List<String> operators = Arrays.asList(conditionalOperatorsMap.get(type)); if (!operators.contains(condition.getConditionalOperator())) { logger.trace("operator at {} is incorrect", condition.getConditionalOperator()); return false; } else { if (condition.getConditionalOperator().contains(FIELD)) { if (StringUtils.equalsIgnoreCase(condition.getConditionalOperator(), FilterConstants.BETWEEN_FIELD)) { if (validateField(fieldsAndTypes, value1, fieldName) && validateField(fieldsAndTypes, value2, fieldName)) { return true; } else { return false; } } else if (validateField(fieldsAndTypes, value1, fieldName)) { return true; } else { return false; } } else if (StringUtils.isNotBlank(value1)) { if (!validateDataBasedOnTypes(type, value1, condition.getConditionalOperator(), debugDataViewer, fieldName)) { return false; } } if (condition.getConditionalOperator().equalsIgnoreCase(FilterConstants.BETWEEN)) { if (StringUtils.isNotBlank(value2)) { if (!validateDataBasedOnTypes(type, value2, condition.getConditionalOperator(), debugDataViewer, fieldName)) { return false; } } } } } return true; }
From source file:info.magnolia.rendering.template.configured.ConfiguredInheritance.java
@Override public AbstractPredicate<Node> getComponentPredicate() { if (isEnabled() == null || !isEnabled()) { return new InheritNothingInheritancePredicate(); }/* w w w . ja va 2 s . co m*/ if (predicateClass != null) { return Components.newInstance(predicateClass); } if (StringUtils.equalsIgnoreCase(StringUtils.trim(components), COMPONENTS_ALL)) { return new AllComponentsAndResourcesInheritancePredicate(); } if (StringUtils.equalsIgnoreCase(StringUtils.trim(components), COMPONENTS_FILTERED)) { return new FilteredComponentInheritancePredicate(); } return new InheritNothingInheritancePredicate(); }
From source file:au.edu.anu.portal.portlets.rss.SimpleRSSPortlet.java
/** * Delegate to appropriate PortletMode./*from ww w . j a va 2s.c om*/ */ protected void doDispatch(RenderRequest request, RenderResponse response) throws PortletException, IOException { log.debug("Simple RSS doDispatch()"); if (StringUtils.equalsIgnoreCase(request.getPortletMode().toString(), "CONFIG")) { doConfig(request, response); } else { super.doDispatch(request, response); } }
From source file:hydrograph.ui.propertywindow.filter.FilterLogicWidget.java
@Override public void attachToPropertySubGroup(AbstractELTContainerWidget subGroup) { ELTDefaultSubgroupComposite defaultSubgroupComposite = new ELTDefaultSubgroupComposite( subGroup.getContainerControl()); defaultSubgroupComposite.createContainerWidget(); dataStructure.setComponentName(getComponent().getComponentName()); AbstractELTWidget defaultLable = null; if (StringUtils.equalsIgnoreCase(getComponent().getComponentName(), Constants.PARTITION_BY_EXPRESSION)) { defaultLable = new ELTDefaultLable("Partition Logic"); } else {/*from w w w. jav a2s .c o m*/ defaultLable = new ELTDefaultLable("Filter Logic"); } defaultSubgroupComposite.attachWidget(defaultLable); setPropertyHelpWidget((Control) defaultLable.getSWTWidgetControl()); AbstractELTWidget defaultButton; if (OSValidator.isMac()) { defaultButton = new ELTDefaultButton(Constants.EDIT).buttonWidth(120); } else { defaultButton = new ELTDefaultButton(Constants.EDIT); } defaultSubgroupComposite.attachWidget(defaultButton); button = (Button) defaultButton.getSWTWidgetControl(); addSelectionListerner(); }
From source file:hydrograph.ui.validators.impl.MixedSchemeGridValidationRule.java
private boolean validateSchema(Schema schema, String propertyName) { List<GridRow> gridRowList = (List<GridRow>) schema.getGridRow(); /* this list is used for checking duplicate names in the grid */ List<String> uniqueNamesList = new ArrayList<>(); boolean mixedSchemeGrid = false; if (gridRowList == null || gridRowList.isEmpty()) { errorMessage = propertyName + " is mandatory"; return false; }/*from www. ja v a 2 s . c o m*/ GridRow gridRowTest = gridRowList.iterator().next(); if (MixedSchemeGridRow.class.isAssignableFrom(gridRowTest.getClass())) { mixedSchemeGrid = true; } for (GridRow gridRow : gridRowList) { if (StringUtils.isBlank(gridRow.getFieldName())) { errorMessage = "Field name can not be blank"; return false; } if (DATA_TYPE_BIG_DECIMAL.equalsIgnoreCase(gridRow.getDataTypeValue())) { if (StringUtils.isBlank(gridRow.getScale()) || StringUtils.equalsIgnoreCase(gridRow.getScale(), "0") || !(gridRow.getScale().matches(REGULAR_EXPRESSION_FOR_NUMBER))) { errorMessage = "Scale can not be blank"; return false; } try { Integer.parseInt(gridRow.getScale()); } catch (NumberFormatException exception) { logger.debug("Failed to parse the scale", exception); errorMessage = "Scale must be integer value"; return false; } } else if (DATA_TYPE_DATE.equalsIgnoreCase(gridRow.getDataTypeValue()) && StringUtils.isBlank(gridRow.getDateFormat())) { errorMessage = "Date format is mandatory"; return false; } if (StringUtils.equalsIgnoreCase(DATA_TYPE_BIG_DECIMAL, gridRow.getDataTypeValue()) && (StringUtils.isBlank(gridRow.getScaleTypeValue()) || StringUtils.equalsIgnoreCase(SCALE_TYPE_NONE, gridRow.getScaleTypeValue()))) { errorMessage = "Scale type cannot be blank or none for Big Decimal data type"; return false; } if (mixedSchemeGrid) { MixedSchemeGridRow mixedSchemeGridRow = (MixedSchemeGridRow) gridRow; if (mixedSchemeGridRow.getLength().equals("0") || mixedSchemeGridRow.getLength().contains("-")) { errorMessage = "Length should be positive integer"; return false; } if (StringUtils.isBlank(mixedSchemeGridRow.getLength()) && StringUtils.isEmpty(mixedSchemeGridRow.getDelimiter())) { errorMessage = "Length Or Delimiter is mandatory"; return false; } if (StringUtils.isNotBlank(mixedSchemeGridRow.getLength()) && StringUtils.isNotEmpty(mixedSchemeGridRow.getDelimiter())) { errorMessage = "Either Length Or Delimiter should be given"; return false; } } if (uniqueNamesList.isEmpty() || !uniqueNamesList.contains(gridRow.getFieldName())) { uniqueNamesList.add(gridRow.getFieldName()); } else { errorMessage = "Schema grid must have unique names"; return false; } } return true; }