Example usage for org.apache.commons.lang StringUtils equalsIgnoreCase

List of usage examples for org.apache.commons.lang StringUtils equalsIgnoreCase

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils equalsIgnoreCase.

Prototype

public static boolean equalsIgnoreCase(String str1, String str2) 

Source Link

Document

Compares two Strings, returning true if they are equal ignoring the case.

Usage

From source file:au.edu.anu.portal.portlets.tweetal.TweetalPortlet.java

/**
 * Process any portlet actions//from w  w  w .  java  2s  . co  m
 */
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException {
    String consumerKey = (String) request.getPreferences().getValue("consumerKey", null);
    String consumerSecret = (String) request.getPreferences().getValue("consumerSecret", null);

    twitterLogic.setOAuthConsumer(consumerKey, consumerSecret);

    PortletPreferences pref = request.getPreferences();
    String portletMode = request.getPortletMode().toString();

    if (StringUtils.equalsIgnoreCase(portletMode, "config")) {
        String operation = request.getParameter("operation");

        if (StringUtils.equalsIgnoreCase(operation, "save")) {

            consumerKey = request.getParameter("consumerKey");
            consumerSecret = request.getParameter("consumerSecret");

            try {
                // validate here
                twitterLogic.setOAuthConsumer(consumerKey, consumerSecret);
                if (twitterLogic.validate()) {
                    // Try to set the prefs
                    pref.setValue("consumerKey", consumerKey);
                    pref.setValue("consumerSecret", consumerSecret);
                    log.info("Changing consumer key and secret to ****");

                } else {
                    log.error("Invalid consumer key and secret");
                    response.setRenderParameter("errorMessage", Messages.getString("config_error_register"));
                    return;
                }

            } catch (ReadOnlyException e) {
                response.setRenderParameter("errorMessage", Messages.getString("error_form_readonly"));
                log.error(e);
                return;
            }

            // save the prefs
            try {
                pref.store();
                response.setPortletMode(PortletMode.VIEW);
            } catch (ValidatorException e) {
                response.setRenderParameter("errorMessage", e.getMessage());
                log.error(e);
            } catch (IOException e) {
                response.setRenderParameter("errorMessage", Messages.getString("error_form_save"));
                log.error(e);
            } catch (PortletModeException e) {
                e.printStackTrace();
                log.error(e);
            }

        } else if (StringUtils.equalsIgnoreCase(operation, "cancel")) {
            response.setPortletMode(PortletMode.VIEW);
        }

    } else if (request.getPortletMode().equals(PortletMode.EDIT)) {
        // when user in edit mode
        String operation = request.getParameter("operation");

        if (operation.equalsIgnoreCase("save")) {

            String pin = StringUtils.stripToNull(request.getParameter("authCode"));

            if (StringUtils.isBlank(pin)) {
                response.setRenderParameter("errorMessage", Messages.getString("error_invalid_pin_empty"));
                log.error("Empty pin");
                return;
            }

            AccessToken accessToken = twitterLogic.getAccessToken(requestToken, pin);

            if (accessToken == null) {
                //inline error - check your pin and try again
                response.setRenderParameter("errorMessage", Messages.getString("error_invalid_pin"));
                log.error("AccessToken was null possibly due to an invalid pin");
                return;
            }

            // persist to the accessToken for future reference.
            String userToken = accessToken.getToken();
            String userSecret = accessToken.getTokenSecret();

            // save them to preferences
            pref.setValue("userToken", userToken);
            pref.setValue("userSecret", userSecret);

            // save the prefs
            try {
                pref.store();
                // redirect to view page
                response.setPortletMode(PortletMode.VIEW);
            } catch (ValidatorException e) {
                response.setRenderParameter("errorMessage", e.getMessage());
                log.error(e);
            } catch (IOException e) {
                response.setRenderParameter("errorMessage", Messages.getString("error_form_save"));
                log.error(e);
            } catch (PortletModeException e) {
                e.printStackTrace();
                log.error(e);
            }

        } else if (operation.equalsIgnoreCase("cancel")) {
            response.setPortletMode(PortletMode.VIEW);

        } else if (operation.equalsIgnoreCase("remove")) {
            //remove stuff
            removeUserPreferences(request);
            // redirect to view page
            response.setPortletMode(PortletMode.VIEW);

        } else {
            //log error, unsupported operation
            log.error("Unsupported operation");
        }
    }
}

From source file:hydrograph.ui.expression.editor.buttons.ValidateExpressionToolButton.java

/**
 * Returns expression-text after resolving its parameters
 * //ww  w  .j a v  a2 s .c  om
 * @param expressionText
 * @return
 */
public static String getExpressionText(String expressionText) {
    String resolvedExpressionText = Utils.INSTANCE.getParamValueForRunSql(expressionText);
    if (StringUtils.equalsIgnoreCase(resolvedExpressionText, Utils.PARAMETER_NOT_FOUND)) {
        resolvedExpressionText = expressionText;
    }
    return resolvedExpressionText;
}

From source file:com.sfs.whichdoctor.beans.BulkContactBean.java

/**
 * Gets the web object type./*from w  ww  . j a  va  2 s .c  om*/
 *
 * @return the web object type
 */
public final String getWebObjectType() {
    String webObjectType = "";
    if (this.objectType != null) {
        if (StringUtils.equalsIgnoreCase(this.objectType, "people")
                || StringUtils.equalsIgnoreCase(this.objectType, "rotations")) {
            webObjectType = "person";
        } else {
            if (this.objectType.length() > 0) {
                webObjectType = this.objectType.substring(0, this.objectType.length() - 1);
            }
        }
    }
    return webObjectType;
}

From source file:hydrograph.ui.propertywindow.widgets.customwidgets.JDBCDriverClassWidget.java

private void populateWidget() {
    jdbcDriverClassTextBox.setText(propertyValue);
    if (StringUtils.equalsIgnoreCase(propertyValue, Messages.ORACLE_DRIVER_CLASS)) {
        combo.select(dropDownConfig.getItems().indexOf(Messages.ORACLE));
    } else if (StringUtils.equalsIgnoreCase(propertyValue, Messages.REDSHIFT_DRIVER_CLASS)) {
        combo.select(dropDownConfig.getItems().indexOf(Messages.REDSHIFT));
    } else if (StringUtils.equalsIgnoreCase(propertyValue, Messages.MYSQL_DRIVER_CLASS)) {
        combo.select(dropDownConfig.getItems().indexOf(Messages.MYSQL));
    } else if (StringUtils.equalsIgnoreCase(propertyValue, Messages.TERADATA_DRIVER_CLASS)) {
        combo.select(dropDownConfig.getItems().indexOf(Messages.TERADATA));
    } else {//from w w  w .  j a v  a  2 s  .  c  o m
        combo.select(dropDownConfig.getItems().indexOf(Messages.OTHERS));
    }

    //      if(propertyValue.isParameter()){
    //         combo.select(dropDownConfig.getItems().indexOf(Constants.PARAMETER));
    //      }else{
    //         if(dropDownConfig.getItems().contains(propertyValue.getDataBaseValue())){
    //            int indexOf = dropDownConfig.getItems().indexOf(propertyValue.getDataBaseValue());
    //            combo.select(indexOf);
    //         }
    //      }
    //         jdbcDriverClassTextBox.setText(propertyValue.getJdbcDriverClassValue());
}

From source file:com.sfs.whichdoctor.beans.TagBean.java

/**
 * Gets the search url.//from ww w  . j a v  a 2s.co m
 *
 * @param objectType the object type
 * @param tagTypeVal the tag type
 * @param preferences the preferences
 *
 * @return the search url
 */
public final String getSearchUrl(final String objectType, final String tagTypeVal,
        final PreferencesBean preferences) {
    String searchLink = "";

    String tagOptions = "tagName=" + this.getTagName();
    if (StringUtils.isNotBlank(tagTypeVal)) {
        tagOptions += "&tagType=" + tagTypeVal;
    }

    if (StringUtils.equalsIgnoreCase(objectType, "people")
            || StringUtils.equalsIgnoreCase(objectType, "person")) {
        searchLink = preferences.buildUrl("read", "people_search", "advanced", tagOptions);
    }
    if (StringUtils.equalsIgnoreCase(objectType, "organisations")
            || StringUtils.equalsIgnoreCase(objectType, "organisation")) {
        searchLink = preferences.buildUrl("read", "organisations_search", "advanced", tagOptions);
    }
    if (StringUtils.equalsIgnoreCase(objectType, "groups")
            || StringUtils.equalsIgnoreCase(objectType, "group")) {
        searchLink = preferences.buildUrl("read", "groups_search", "advanced", tagOptions);
    }
    if (StringUtils.equalsIgnoreCase(objectType, "invoices")
            || StringUtils.equalsIgnoreCase(objectType, "debit")) {
        searchLink = preferences.buildUrl("read", "debits_search", "advanced", tagOptions);
    }
    if (StringUtils.equalsIgnoreCase(objectType, "credits")
            || StringUtils.equalsIgnoreCase(objectType, "credit")) {
        searchLink = preferences.buildUrl("read", "credits_search", "advanced", tagOptions);
    }
    if (StringUtils.equalsIgnoreCase(objectType, "receipts")
            || StringUtils.equalsIgnoreCase(objectType, "receipt")) {
        searchLink = preferences.buildUrl("read", "receipts_search", "advanced", tagOptions);
    }
    if (StringUtils.equalsIgnoreCase(objectType, "reimbursements")
            || StringUtils.equalsIgnoreCase(objectType, "reimbursement")) {
        searchLink = preferences.buildUrl("read", "reimbursements_search", "advanced", tagOptions);
    }
    if (StringUtils.equalsIgnoreCase(objectType, "rotations")
            || StringUtils.equalsIgnoreCase(objectType, "rotation")) {
        searchLink = preferences.buildUrl("read", "rotations_search", "advanced", tagOptions);
    }

    return searchLink;
}

From source file:hydrograph.ui.propertywindow.widgets.customwidgets.SingleColumnWidget.java

protected List<String> getPropagatedSchema() {
    List<String> propogatedFields = new ArrayList<>();
    if (StringUtils.equalsIgnoreCase(getComponent().getComponentName(), Constants.AGGREGATE)
            || StringUtils.equalsIgnoreCase(getComponent().getComponentName(), Constants.CUMULATE)
            || StringUtils.equalsIgnoreCase(getComponent().getComponentName(), Constants.GROUP_COMBINE)) {
        TransformWidget transformWidget = null;
        for (AbstractWidget abstractWidget : widgets) {
            if (abstractWidget instanceof TransformWidget) {
                transformWidget = (TransformWidget) abstractWidget;
                break;
            }/*from w w w  .j  a  v a 2  s  .c  o m*/
        }
        if (transformWidget != null) {
            TransformMapping transformMapping = (TransformMapping) transformWidget.getProperties()
                    .get(Constants.OPERATION);
            for (InputField inputField : transformMapping.getInputFields()) {
                propogatedFields.add(inputField.getFieldName());
            }
        }
        return propogatedFields;
    } else if (StringUtils.equalsIgnoreCase(getComponent().getComponentName(), Constants.FILTER)
            || StringUtils.equalsIgnoreCase(getComponent().getCategory(), Constants.STRAIGHTPULL)) {
        ELTSchemaGridWidget schemaWidget = null;
        for (AbstractWidget abstractWidget : widgets) {
            if (abstractWidget instanceof ELTSchemaGridWidget) {
                schemaWidget = (ELTSchemaGridWidget) abstractWidget;
                break;
            }
        }
        if (schemaWidget != null) {
            schemaWidget.refresh();
            List<GridRow> gridRowList = (List<GridRow>) schemaWidget.getTableViewer().getInput();
            for (GridRow gridRow : gridRowList) {
                propogatedFields.add(gridRow.getFieldName());
            }
        }
        return propogatedFields;
    }
    return SchemaPropagationHelper.INSTANCE.getFieldsForFilterWidget(getComponent())
            .get(Constants.INPUT_SOCKET_TYPE + 0);
}

From source file:com.sfs.whichdoctor.beans.TrainingSummaryBean.java

/**
 * Check inclusion.//ww w .j  a v a2 s  .c om
 *
 * @param rotation the rotation
 * @param specialtyId the specialty identifier
 *
 * @return true, if successful
 */
private boolean checkInclusion(final RotationBean rotation, final int specialtyId) {

    // Subtract one from the requested specialtyIdentifier
    // This is to work within the concept of an array index which beings at
    // 0
    final int specialtyIdentifier = specialtyId - 1;

    boolean includeRotation = true;
    // Check to see whether rotation should be included in result set
    // By default all rotations are included unless proven otherwise.

    ArrayList<AssessmentBean> assessments = new ArrayList<AssessmentBean>();
    if (rotation.getAssessment() != null) {
        assessments = (ArrayList<AssessmentBean>) rotation.getAssessment();
    }

    if (assessments.size() > specialtyIdentifier) {

        AssessmentBean assessment = assessments.get(specialtyIdentifier);

        if (StringUtils.equals(getApprovalStatus(), "approved")) {
            // Only want approved rotations for specialty 1
            if (!StringUtils.equalsIgnoreCase(assessment.getApproved(), "Approved")) {
                includeRotation = false;
            }
        }
        if (StringUtils.equals(getApprovalStatus(), "not-approved")) {
            // Only want non-approved rotations for the assessment
            if (StringUtils.equalsIgnoreCase(assessment.getApproved(), "Approved")) {
                includeRotation = false;
            }
        }
        if (StringUtils.equals(getAccreditationStatus(), "accredited")) {
            // Only want accredited rotations for the assessment
            if (!StringUtils.equalsIgnoreCase(assessment.getStatus(), "Accredited")) {
                includeRotation = false;
            }
        }
        if (StringUtils.equals(getAccreditationStatus(), "not-accredited")) {
            // Only want non-accredited rotations for the assessment
            if (StringUtils.equalsIgnoreCase(assessment.getStatus(), "Accredited")) {
                includeRotation = false;
            }
        }
    }

    return includeRotation;
}

From source file:com.sfs.dao.LdapAuthenticationDAOImpl.java

/**
 * Load details./*from   w w w  .  j  a va2 s  .co  m*/
 *
 * @param adapter the adapter
 *
 * @return the user bean
 */
private UserBean loadDetails(final DirContextAdapter adapter) {

    final UserBean user = new UserBean();

    user.setDN(adapter.getDn().toString());
    user.setUserName(adapter.getStringAttribute(this.userName));
    user.setPreferredName(adapter.getStringAttribute(this.preferredName));
    user.setLastName(adapter.getStringAttribute(this.lastName));
    user.setEmail(adapter.getStringAttribute(this.email));
    String[] roleDNs = adapter.getStringAttributes(this.groupMembership);

    final Collection<String> roles = new ArrayList<String>();
    if (roleDNs != null) {
        for (String role : roleDNs) {
            // See which valid roles this user has
            final int firstAppostrophie = role.indexOf(",");
            final String groupType = role.substring(firstAppostrophie + 1);
            if (StringUtils.equalsIgnoreCase(groupType, this.groupContainer)) {
                final int startOfGroup = role.indexOf("=");
                final String className = role.substring(startOfGroup + 1, firstAppostrophie);
                roles.add(className);
            }
        }
    }
    user.setMemberOf(roles);

    if (roles.size() > 0) {
        /** The user belongs to one valid role, log in **/
        dataLogger.debug("User has at least one valid role - logged in");
        user.setLoggedIn(true);
    }

    return user;
}

From source file:net.di2e.ecdr.commons.util.SearchUtils.java

public static <T extends Enum<?>> T enumEqualsIgnoreCase(Class<T> enumeration, String search) {
    for (T each : enumeration.getEnumConstants()) {
        if (StringUtils.equalsIgnoreCase(each.name(), search)) {
            return each;
        }/*from w w w. j a  v a  2 s  .c  o  m*/
    }
    return null;
}

From source file:com.dianping.puma.datahandler.AbstractDataHandler.java

protected void handleQueryEvent(BinlogEvent binlogEvent, DataHandlerResult result) {
    QueryEvent queryEvent = (QueryEvent) binlogEvent;
    String sql = StringUtils.normalizeSpace(queryEvent.getSql());
    if (StringUtils.startsWithIgnoreCase(sql, "ALTER ") || StringUtils.startsWithIgnoreCase(sql, "CREATE ")
            || StringUtils.startsWithIgnoreCase(sql, "DROP ")
            || StringUtils.startsWithIgnoreCase(sql, "RENAME ")
            || StringUtils.startsWithIgnoreCase(sql, "TRUNCATE ")) {

        handleDDlEvent(result, queryEvent, sql);

    } else if (StringUtils.equalsIgnoreCase(sql, "BEGIN")) {

        handleTransactionBeginEvent(binlogEvent, result, queryEvent);
    } else {//from ww  w .  j  a  va  2  s . co  m
        result.setEmpty(true);
        result.setFinished(true);
        // log.info("QueryEvent  sql=" + queryEvent.getSql());
    }
}