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:cn.vko.cache.dao.ha.PassiveEventHotSwappableAdvice.java

@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
    if (!StringUtils.equalsIgnoreCase(invocation.getMethod().getName(), "getConnection")) {
        return invocation.proceed();
    }/*w  ww  . j  a  va2  s  . co m*/

    try {
        return invocation.proceed();
        // need to check with detecting sql?

    } catch (Throwable t) {
        if (t instanceof SQLException) {
            // we use SQLStateSQLExceptionTranslator to translate SQLExceptions , but it doesn't mean it will work as we expected, 
            // so maybe more scope should be covered. we will check out later with runtime data statistics.
            DataAccessException dae = sqlExTranslator.translate(
                    "translate to check whether it's a resource failure exception", null, (SQLException) t);
            if (dae instanceof DataAccessResourceFailureException) {
                logger.warn("failed to get Connection from data source with exception:\n{}", t);
                doSwap();
                return invocation.getMethod().invoke(targetSource.getTarget(), invocation.getArguments());
            }
        }
        // other exception conditions should be handled by application, 
        // 'cause we don't have enough context information to decide what to do here.
        throw t;
    }
}

From source file:com.alibaba.cobar.client.datasources.ha.PassiveEventHotSwappableAdvice.java

public Object invoke(MethodInvocation invocation) throws Throwable {
    if (!StringUtils.equalsIgnoreCase(invocation.getMethod().getName(), "getConnection")) {
        return invocation.proceed();
    }//  w  w  w  .  ja v  a 2  s  . co  m

    try {
        return invocation.proceed();
        // need to check with detecting sql?

    } catch (Throwable t) {
        if (t instanceof SQLException) {
            // we use SQLStateSQLExceptionTranslator to translate SQLExceptions , but it doesn't mean it will work as we expected, 
            // so maybe more scope should be covered. we will check out later with runtime data statistics.
            DataAccessException dae = sqlExTranslator.translate(
                    "translate to check whether it's a resource failure exception", null, (SQLException) t);
            if (dae instanceof DataAccessResourceFailureException) {
                logger.warn("failed to get Connection from data source with exception:\n{}", t);
                doSwap();
                return invocation.getMethod().invoke(targetSource.getTarget(), invocation.getArguments());
            }
        }
        // other exception conditions should be handled by application, 
        // 'cause we don't have enough context information to decide what to do here.
        throw t;
    }
}

From source file:com.xhm.longxin.qth.web.user.module.action.UserAction.java

public void doLogin(@FormGroup("login") LoginVO vo,
        @FormField(name = "validateStr", group = "login") CustomErrors validateField,
        @FormField(name = "loginError", group = "login") CustomErrors err, Navigator nav,
        ParameterParser params) {/*from w w  w  .j a  v  a  2  s  . c  o  m*/
    String validateCode = (String) session.getAttribute(UserConstant.VALIDATE_CODE);
    if (validateCode == null || StringUtils.equalsIgnoreCase(validateCode, vo.getValidateStr()) == false) {
        validateField.setMessage("validateError");
        return;
    }

    User user = userService.login(vo);
    if (user != null) {
        setSession(user);
        redirectToReturnPage(nav, params);
    } else {
        err.setMessage("invalidUserOrPassword");
    }

}

From source file:com.scottwoodward.chestmail.manager.ChestMailManager.java

public static boolean doesMailBoxWithNameExist(String mailbox) {
    boolean doesMailBoxExist = false;

    ChestMailDatabaseManager dbManager = new ChestMailDatabaseManager(ChestMail.getPluginName());
    Connection connection = dbManager.getConnection();

    doesMailBoxExist = getChestAtLocation(dbManager.getMailBox(connection, mailbox)) != null;

    dbManager.closeConnection(connection);

    if (!doesMailBoxExist) {
        for (String value : playersSettingMailBox.values()) {
            if (StringUtils.equalsIgnoreCase(value, mailbox)) {
                doesMailBoxExist = true;
                break;
            }//w ww. ja  va2  s  .c  o m
        }
    }
    return doesMailBoxExist;
}

From source file:au.edu.anu.portal.portlets.sakaiconnector.support.WebServiceSupport.java

/**
 * Convert the string type to a qname/*from w  ww. j a v a 2  s.  c o m*/
 * @param type
 * @return
 */
private static QName getNameForType(String type) throws SOAPException {

    if (StringUtils.equalsIgnoreCase(type, "string")) {
        return XMLType.XSD_STRING;
    } else if (StringUtils.equalsIgnoreCase(type, "boolean")) {
        return XMLType.XSD_BOOLEAN;
    } else {
        throw new SOAPException("Invalid value for type attribute, must be one of 'string' or 'boolean'.");
    }

}

From source file:com.edgenius.wiki.model.Invitation.java

/**
 * @param email//from  w w  w  . ja  v  a  2s  .com
 * @return
 */
public boolean includeUserEmail(String inEmail) {
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // check if this email still inside emailGroup, if not, it means this 
    //invitation already be accepted, don't need continue handle
    String emailGroup = this.getToEmailGroup();
    String[] emails = emailGroup.split(",");
    for (String email : emails) {
        if (StringUtils.equalsIgnoreCase(email, inEmail)) {
            return true;
        }
    }
    return false;
}

From source file:com.microsoft.alm.plugin.idea.common.starters.ApplicationStarterBase.java

/**
 * Checking arguments passed. They should follow the forms:
 * "vsts <command> <args>"//from  w ww . java  2 s  .  c om
 * "vsts <uri>
 *
 * @param args the command line args
 * @return whether the arguments given meet the requirements
 */
protected boolean checkArguments(String[] args) {
    if (args.length < 2) {
        logger.error(
                "VSTS failed due to lack of commands. Please specify the command that you want VSTS to execute");
        return false;
    } else if (!StringUtils.equalsIgnoreCase(VSTS_COMMAND, args[0])) {
        logger.error(
                "VSTS checkout failed due to the incorrect command being used. Expected \"vsts\" but found \"{}\".",
                args[0]);
        return false;
    } else {
        return true;
    }
}

From source file:com.baifendian.swordfish.masterserver.master.StreamingCheckThread.java

@Override
public void run() {
    try {/*from w  w w  .  j  ava  2s  .c o m*/
        // ?
        List<StreamingResult> streamingResults = streamingDao.findNoFinishedJob();

        Date now = new Date();

        // ?
        if (CollectionUtils.isNotEmpty(streamingResults)) {
            logger.info("find not finish jobs, size: {}", streamingResults.size());

            // ???
            for (StreamingResult streamingResult : streamingResults) {
                List<String> appIds = streamingResult.getAppLinkList();

                FlowStatus status = streamingResult.getStatus();

                //  appid ?????
                if (StringUtils.equalsIgnoreCase(streamingResult.getType(), SPARK_STREAMING)) {
                    //  appid
                    if (CollectionUtils.isEmpty(appIds)) {
                        // ? appid 
                        if (System.currentTimeMillis() - streamingResult.getScheduleTime()
                                .getTime() >= MasterConfig.streamingTimeoutThreshold * 1000) { // ??, ?
                            // ??
                            status = FlowStatus.FAILED;
                        } else {
                            continue;
                        }
                    } else {
                        // ??, ??, , 
                        String appId = appIds.get(appIds.size() - 1);

                        try {
                            FlowStatus tmpStatus = YarnRestClient.getInstance().getApplicationStatus(appId);

                            // ?
                            if (tmpStatus == null) {
                                logger.error("application not exist: {}", appId);
                                status = FlowStatus.FAILED;
                            } else {
                                status = tmpStatus;
                            }
                        } catch (Exception e) {
                            logger.error(String.format("get application exception: %s", appId), e);
                        }
                    }
                } else if (StringUtils.equalsIgnoreCase(streamingResult.getType(), STORM)) {
                    // , 
                    if (CollectionUtils.isEmpty(appIds)) {
                        continue;
                    }

                    // storm ? appId
                    String topologyId = appIds.get(0);

                    try {
                        FlowStatus tmpStatus = StormRestUtil.getTopologyStatus(topologyId);

                        if (tmpStatus == null) {
                            status = FlowStatus.FAILED;
                            logger.error("Not found topology: {}", topologyId);
                        } else {
                            status = tmpStatus;
                        }
                    } catch (Exception e) {
                        logger.error(String.format("get topology id exception: %s", topologyId), e);
                    }
                } else {
                    logger.error("No support type: {}", streamingResult.getType());
                }

                // ?
                if (status != streamingResult.getStatus()) {
                    // ??
                    streamingResult.setStatus(status);

                    if (status.typeIsFinished()) {
                        streamingResult.setEndTime(now);
                    }

                    streamingDao.updateResult(streamingResult);

                    // ??
                    if (status.typeIsFinished()) {
                        EmailManager.sendMessageOfStreamingJob(streamingResult);
                    }
                }
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}

From source file:com.microsoft.alm.plugin.telemetry.TfsTelemetryHelper.java

private TfsTelemetryHelper() {
    final String skip = System.getProperties()
            .getProperty("com.microsoft.alm.plugin.telemetry.skipClientInitialization");
    if (StringUtils.isNotEmpty(skip) && StringUtils.equalsIgnoreCase(skip, "true")) {
        // this flag is here for testing purposes in which case we do not want to create a telemetry channel
        // or client.
        return;/*from   w  w w.j a  va  2s .c o  m*/
    }

    // Initialize the internal logger
    final Map<String, String> loggerData = new HashMap<String, String>();
    loggerData.put("Level", InternalLogger.LoggingLevel.ERROR.toString()); //$NON-NLS-1$
    loggerData.put("UniquePrefix", UNIQUE_PREFIX); //$NON-NLS-1$
    loggerData.put("BaseFolder", BASE_FOLDER); //$NON-NLS-1$
    InternalLogger.INSTANCE.initialize(LoggerOutputType.FILE.toString(), loggerData);

    // Initialize the active TelemetryConfiguration
    ContextInitializer initializer = PluginServiceProvider.getInstance().getTelemetryContextInitializer();
    TelemetryConfiguration.getActive().getContextInitializers().add(initializer);

    // Create a channel to AppInsights
    final TelemetryChannel channel = TelemetryConfiguration.getActive().getChannel();
    if (channel != null) {
        channel.setDeveloperMode(TfsTelemetryInstrumentationInfo.getInstance().isDeveloperMode());
    } else {
        logger.error("Failed to load telemetry channel");
        return;
    }

    // Create the telemetry client and cache it for later use
    logger.debug("AppInsights telemetry initialized"); //$NON-NLS-1$
    logger.debug(MessageFormat.format("    Developer Mode: {0}", //$NON-NLS-1$
            TfsTelemetryInstrumentationInfo.getInstance().isDeveloperMode()));
    logger.debug(MessageFormat.format("    Production Environment: {0}", //$NON-NLS-1$
            !TfsTelemetryInstrumentationInfo.getInstance().isTestKey()));

    telemetryClient = new TelemetryClient();
    telemetryClient.getContext().getSession().setId(UUID.randomUUID().toString());
}

From source file:io.udvi.amqp.mq.transport.connection.CAMQPConnectionManager.java

public static CAMQPConnection getCAMQPConnection(String targetContainerId) {
    Collection<CAMQPConnectionKey> keys = openConnections.keySet();
    for (CAMQPConnectionKey key : keys) {
        if (StringUtils.equalsIgnoreCase(key.getRemoteContainerId(), targetContainerId)) {
            return openConnections.get(key);
        }/* w  w  w.  j a  va2s.  c om*/
    }
    return null;
}