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

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

Introduction

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

Prototype

public static boolean equalsIgnoreCase(final CharSequence str1, final CharSequence str2) 

Source Link

Document

Compares two CharSequences, returning true if they represent equal sequences of characters, ignoring case.

null s are handled without exceptions.

Usage

From source file:com.ottogroup.bi.asap.server.emitter.kafka.KafkaTopicConsumer.java

public void initialize(final Map<String, String> settings) throws RequiredInputMissingException {

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////
    // extract data required for setting up a consumer from configuration 

    // read out auto offset reset type and check if it contains a valid value, otherwise reset to 'LARGEST'
    this.autoOffsetResetType = settings.get(CFG_OPT_KAFKA_AUTO_OFFSET_RESET);
    if (!StringUtils.equalsIgnoreCase(this.autoOffsetResetType, KAFKA_AUTO_OFFSET_RESET_TYPE_LARGEST)
            && !StringUtils.equalsIgnoreCase(this.autoOffsetResetType, KAFKA_AUTO_OFFSET_RESET_TYPE_SMALLEST))
        this.autoOffsetResetType = KAFKA_AUTO_OFFSET_RESET_TYPE_LARGEST;

    // read out value indicating whether auto commit is enabled or not and validate it for 'true' or 'false' --> otherwise set to default 'true'
    this.autoCommitEnabled = settings.get(CFG_OPT_KAFKA_ZOOKEEPER_AUTO_COMMIT_ENABLED);
    if (!StringUtils.equalsIgnoreCase(this.autoCommitEnabled, "true")
            && !StringUtils.equalsIgnoreCase(this.autoCommitEnabled, "false"))
        this.autoCommitEnabled = "true";

    // check if the provided session timeout is a valid number --> otherwise reset to default '6000' 
    this.zookeeperSessionTimeout = settings.get(CFG_OPT_KAFKA_ZOOKEEPER_SESSION_TIMEOUT);
    try {/* www .j a  v  a  2  s.  c om*/
        long longVal = Long.parseLong(this.zookeeperSessionTimeout);
        if (longVal < 1) {
            logger.info("Found invalid session timeout value '" + this.zookeeperSessionTimeout
                    + "'. Resetting to '6000'");
            this.zookeeperSessionTimeout = "6000";
        }
    } catch (Exception e) {
        logger.info("Found invalid session timeout value '" + this.zookeeperSessionTimeout
                + "'. Resetting to '6000'");
        this.zookeeperSessionTimeout = "6000";
    }

    // check if the provided sync interval is a valid number --> otherwise reset to default '2000'
    this.zookeeperSyncInterval = settings.get(CFG_OPT_KAFKA_ZOOKEEPER_SYNC_INTERVAL);
    try {
        long longVal = Long.parseLong(this.zookeeperSyncInterval);
        if (longVal < 1) {
            logger.info("Found invalid session sync interval '" + this.zookeeperSyncInterval
                    + "'. Resetting to '2000'");
            this.zookeeperSyncInterval = "2000";
        }
    } catch (Exception e) {
        logger.info("Found invalid session sync interval '" + this.zookeeperSyncInterval
                + "'. Resetting to '2000'");
        this.zookeeperSyncInterval = "2000";
    }

    // check if the provided auto commit interval is a valid number --> otherwise reset to default '60 * 1000'
    this.autoCommitInterval = settings.get(CFG_OPT_KAFKA_ZOOKEEPER_AUTO_COMMIT_INTERVAL);
    try {
        long longVal = Long.parseLong(this.autoCommitInterval);
        if (longVal < 1) {
            logger.info("Found invalid auto commit interval '" + this.autoCommitInterval
                    + "'. Resetting to '60000'");
            this.autoCommitInterval = "60000";
        }
    } catch (Exception e) {
        logger.info(
                "Found invalid auto commit interval '" + this.autoCommitInterval + "'. Resetting to '60000'");
        this.autoCommitInterval = "60000";
    }

    String numOfPartStr = settings.get(CFG_OPT_KAFKA_PARTITIONS);
    try {
        this.numOfPartitions = Integer.parseInt(numOfPartStr);
    } catch (Exception e) {
        logger.info("Found invalid number of partitions '" + numOfPartStr + "'. Resetting to '60000'");
    }
    if (this.numOfPartitions < 1)
        this.numOfPartitions = 5;

    String polIntervallStr = settings.get(CFG_OPT_KAFKA_TOPIC_POLLING_INTERVAL);
    try {
        this.pollingInterval = Long.parseLong(polIntervallStr);
    } catch (Exception e) {
        logger.info("Found invalid polling intervall '" + polIntervallStr + "'. Resetting to '-1'");
    }
    if (this.pollingInterval < 1)
        this.pollingInterval = -1;

    this.groupId = settings.get(CFG_OPT_KAFKA_GROUP_ID);
    this.topic = settings.get(CFG_OPT_KAFKA_TOPIC);
    this.zookeeperConnect = settings.get(CFG_OPT_KAFKA_ZOOKEEPER_CONNECT);

    //
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////
    // establish connection with kafka

    Properties props = new Properties();
    props.put(KAFKA_CONN_PARAM_ZK_CONNECT, this.zookeeperConnect);
    props.put(KAFKA_CONN_PARAM_ZK_SESSION_TIMEOUT, this.zookeeperSessionTimeout);
    props.put(KAFKA_CONN_PARAM_ZK_SYNC_INTERVAL, this.zookeeperSyncInterval);
    props.put(KAFKA_CONN_PARAM_GROUP_ID, this.groupId);
    props.put(KAFKA_CONN_PARAM_AUTO_COMMIT_INTERVAL, this.autoCommitInterval);
    props.put(KAFKA_CONN_PARAM_AUTO_OFFSET_RESET, this.autoOffsetResetType);
    props.put(KAFKA_CONN_PARAM_AUTO_COMMIT_ENABLED, this.autoCommitEnabled);

    ConsumerConfig consumerConfig = new ConsumerConfig(props);
    this.kafkaConsumerConnector = Consumer.createJavaConsumerConnector(consumerConfig);

    // get access to topic streams
    Map<String, Integer> topicCountMap = new HashMap<>();
    topicCountMap.put(this.topic, this.numOfPartitions);
    Map<String, List<KafkaStream<byte[], byte[]>>> consumerMap = this.kafkaConsumerConnector
            .createMessageStreams(topicCountMap);

    // receive topic streams, each entry holds a single partition
    List<KafkaStream<byte[], byte[]>> streams = consumerMap.get(this.topic);
    if (streams == null || streams.isEmpty())
        throw new RuntimeException("Failed to establish connection with kafka topic [zkConnect="
                + this.zookeeperConnect + ", topic=" + this.topic + "]");

    // iterate through streams and assign each to a partition reader
    for (KafkaStream<byte[], byte[]> kafkaStream : streams) {

        if (kafkaStream == null)
            throw new RuntimeException("Found null entry in list of kafka streams [zkConnect="
                    + this.zookeeperConnect + ", topic=" + this.topic + "]");

        String origin = "kafka-topic-" + topic;
        KafkaTopicPartitionConsumer partitionConsumer = new KafkaTopicPartitionConsumer(origin, kafkaStream,
                messages);
        executorService.submit(partitionConsumer);
        this.partitionConsumers.put("kafka-topic-" + topic, partitionConsumer);
    }

}

From source file:de.micromata.tpsb.doc.parser.MethodInfo.java

public boolean matchArgType(int idx, String type) {
    if (idx > getParamCount() && hasVarArgs() == false) {
        return false;
    } else if (idx > getParamCount() && hasVarArgs() == true) {
        ParameterInfo parameterInfo = getParameters().get(getParamCount() - 1);
        return StringUtils.equalsIgnoreCase(parameterInfo.getParamType(), type);
    } else {/*from   w w w  .  j a v  a2s.c om*/
        ParameterInfo parameterInfo = getParameters().get(idx - 1);
        return StringUtils.equalsIgnoreCase(parameterInfo.getParamType(), type);
    }
}

From source file:com.glaf.core.domain.EntityEntry.java

public boolean isPropagationAllowed() {
    if (StringUtils.equalsIgnoreCase(isPropagationAllowed, "1")
            || StringUtils.equalsIgnoreCase(isPropagationAllowed, "Y")
            || StringUtils.equalsIgnoreCase(isPropagationAllowed, "true")) {
        return true;
    }/*  w w  w.  j a  va 2  s.  c om*/
    return false;
}

From source file:com.nike.cerberus.operation.core.UpdateStackOperation.java

@Override
public void run(final UpdateStackCommand command) {
    final String stackId = configStore.getStackId(command.getStackName());
    final Class<? extends LaunchConfigParameters> parametersClass = stackParameterMap
            .get(command.getStackName());
    final Map<String, String> parameters;

    if (parametersClass != null) {
        parameters = getUpdateLaunchConfigParameters(command.getStackName(), command, parametersClass);
    } else if (StackName.BASE == command.getStackName()) {
        parameters = getUpdatedBaseStackParameters(command);
    } else {/*from  w ww.j a  v a2 s.  co m*/
        throw new IllegalArgumentException("The specified stack does not support the update stack command!");
    }

    parameters.putAll(command.getDynamicParameters());

    try {
        logger.info("Starting the update for {}.", command.getStackName().getName());

        if (command.isOverwriteTemplate()) {
            cloudFormationService.updateStack(stackId, parameters,
                    stackTemplatePathMap.get(command.getStackName()), true);
        } else {
            cloudFormationService.updateStack(stackId, parameters, true);
        }

        final StackStatus endStatus = cloudFormationService.waitForStatus(stackId,
                Sets.newHashSet(StackStatus.UPDATE_COMPLETE, StackStatus.UPDATE_COMPLETE_CLEANUP_IN_PROGRESS,
                        StackStatus.UPDATE_ROLLBACK_COMPLETE));

        if (endStatus == StackStatus.ROLLBACK_COMPLETE) {
            final String errorMessage = String.format("Unexpected end status: %s", endStatus.name());
            logger.error(errorMessage);

            throw new UnexpectedCloudFormationStatusException(errorMessage);
        }

        logger.info("Update complete.");
    } catch (AmazonServiceException ase) {
        if (ase.getStatusCode() == 400
                && StringUtils.equalsIgnoreCase(ase.getErrorMessage(), "No updates are to be performed.")) {
            logger.warn("CloudFormation reported no changes detected.");
        } else {
            throw ase;
        }
    }
}

From source file:com.ottogroup.bi.spqr.pipeline.component.queue.chronicle.DefaultStreamingMessageQueueTest.java

/**
 * Test case for {@link DefaultStreamingMessageQueue#next()} requesting a single message from a
 * temporary queue which must be returned without errors 
 *///from  w  w  w.  j a v a2 s  . c o  m
@Test
public void testNext_withSingleMessage() throws IOException, RequiredInputMissingException {
    Properties props = new Properties();
    props.put(DefaultStreamingMessageQueue.CFG_CHRONICLE_QUEUE_DELETE_ON_EXIT, "true");
    props.put(DefaultStreamingMessageQueue.CFG_CHRONICLE_QUEUE_PATH, System.getProperty("java.io.tmpdir"));
    DefaultStreamingMessageQueue inbox = new DefaultStreamingMessageQueue();
    inbox.setId("testNext_withSingleMessages");
    inbox.initialize(props);

    long timestamp = System.currentTimeMillis();
    String text = "This is a simple test message";
    byte[] content = text.getBytes();

    Assert.assertTrue(inbox.getProducer().insert(new StreamingDataMessage(content, timestamp)));
    StreamingDataMessage msg = inbox.getConsumer().next();

    Assert.assertTrue("Values must be equal",
            StringUtils.equalsIgnoreCase(new String(content), new String(msg.getBody())));
    Assert.assertEquals("Values must be equal", timestamp, msg.getTimestamp());
}

From source file:com.navercorp.lucy.security.xss.servletfilter.XssEscapeFilterConfig.java

/**
 * @param url String/*from   www . j a va2s . c  o  m*/
 * @param nodeList NodeList
 * @return boolean
 */
private boolean addUrlDisableRule(String url, NodeList nodeList) {
    Map<String, XssEscapeFilterRule> paramRuleMap = null;
    boolean result = false;

    if (!url.isEmpty()) {
        boolean disable = StringUtils.equalsIgnoreCase(((Element) nodeList.item(0)).getAttribute("disable"),
                "true") ? true : false;
        paramRuleMap = createRequestParamRuleMap(url, disable);

        if (paramRuleMap != null) {
            urlRuleSetMap.put(url, paramRuleMap);
            result = true;
        }
    }

    return result;
}

From source file:io.jmnarloch.cd.go.plugin.healthcheck.HealthCheckTaskExecutor.java

/**
 * Matches the expected application status.
 *
 * @param status the status/*from  w  w w . j  a v  a  2s.  c om*/
 * @return the mapping function
 */
private Func1<String, Boolean> matchStatus(final String status) {
    return new Func1<String, Boolean>() {
        @Override
        public Boolean call(String instanceStatus) {
            return StringUtils.equalsIgnoreCase(status, instanceStatus);
        }
    };
}

From source file:com.pinterest.teletraan.resource.EnvCapacities.java

@DELETE
public void delete(@PathParam("envName") String envName, @PathParam("stageName") String stageName,
        @QueryParam("capacityType") Optional<CapacityType> capacityType, @NotEmpty String name,
        @Context SecurityContext sc) throws Exception {
    EnvironBean envBean = Utils.getEnvStage(environDAO, envName, stageName);
    authorizer.authorize(sc, new Resource(envBean.getEnv_name(), Resource.Type.ENV), Role.OPERATOR);
    String operator = sc.getUserPrincipal().getName();
    name = name.replaceAll("\"", "");
    if (capacityType.or(CapacityType.GROUP) == CapacityType.GROUP) {
        LOG.info("Delete group {} from environment {} stage {} capacity", name, envName, stageName);
        groupDAO.removeGroupCapacity(envBean.getEnv_id(), name);
        if (StringUtils.equalsIgnoreCase(envBean.getCluster_name(), name)) {
            LOG.info("Delete cluster {} from environment {} stage {}", name, envName, stageName);
            //The group is set to be the cluster
            environDAO.deleteCluster(envName, stageName);
        }//from   w  w w. j a v  a  2s.  co  m
    } else {
        LOG.info("Delete host {} from environment {} stage {} capacity", name, envName, stageName);
        groupDAO.removeHostCapacity(envBean.getEnv_id(), name);
    }
    LOG.info("Successfully deleted {} from env {}/{} capacity config by {}.", name, envName, stageName,
            operator);
}

From source file:com.hybris.mobile.model.product.Product.java

public String getStockLevelText(Context context) {
    String text = null;/*from  www. j a  v a  2  s. co  m*/
    if (this.getStock().getStockLevelStatus() != null) {
        if (StringUtils.equalsIgnoreCase(this.getStock().getStockLevelStatus().getCode(), "low stock")) {
            text = String.format(context.getResources().getString(R.string.stock_details_low_stock_with_value,
                    this.getStock().getStockLevel()));
        } else if (StringUtils.equalsIgnoreCase(this.getStock().getStockLevelStatus().getCode(),
                "out of stock")) {
            text = context.getResources().getString(R.string.stock_details_out_of_stock);
        } else {
            //               String s = Hybris.getAppContext().getResources().getString(R.string.stock_details_in_stock);
            //               text = String.format(s, this.getStockLevel());
            text = context.getResources().getString(R.string.stock_details_in_stock);
        }
    }
    return text;
}

From source file:com.dominion.salud.pedicom.negocio.tools.PDFService.java

/**
 * Demonio que realiza el borrado de pdf
 *//*from w  w  w  .  jav  a2s  .  c o m*/
@Scheduled(cron = PEDICOMConstantes._TASK_PDF_DELETE)
public void deletePDF() {
    logger.info("Comienza el borrado automatico de pdf");
    File dir = new File(PEDICOMConstantes._HOME + File.separator + "reports" + File.separator);
    logger.debug("     Directorio de borrado en: " + dir.getPath());
    Collection<File> list = FileUtils.listFiles(dir,
            FileFilterUtils.ageFileFilter(DateUtils.addDays(new Date(), -1), true), null);
    for (File fil : list) {
        if (!StringUtils.equalsIgnoreCase(fil.getName(), "No_encontrado.pdf")) {
            FileUtils.deleteQuietly(fil);
        }
    }
    logger.info("Borrado completado");
}