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

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

Introduction

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

Prototype

public static boolean containsIgnoreCase(String str, String searchStr) 

Source Link

Document

Checks if String contains a search String irrespective of case, handling null.

Usage

From source file:de.fhg.iais.cortex.services.AbstractAipIngestService.java

private String sanitizeOldAscFormat(String inputString) throws JDOMException, IOException {
    if (!StringUtils.containsIgnoreCase(inputString, GlobalConstants.CORTEX_NAMESPACE_URI)) {
        inputString = inputString.replaceFirst("<cortex>",
                "<cortex xmlns=\"" + GlobalConstants.CORTEX_NAMESPACE_URI + "\">");
    }//ww w . j  a v  a2s  . com

    StringReader reader = null;
    try {
        reader = new StringReader(inputString);
        Document jdomAip = new SAXBuilder().build(reader);

        XMLOutputter outp = new XMLOutputter();
        outp.setFormat(Format.getPrettyFormat().setEncoding(Charsets.UTF_8.name()));

        if (jdomAip.getRootElement().getChild("edm", GlobalConstants.CORTEX_NAMESPACE) == null) {

            Element child = jdomAip.getRootElement()
                    .getChild("provider-metadata-sets", GlobalConstants.CORTEX_NAMESPACE)
                    .getChild("original-source", GlobalConstants.CORTEX_NAMESPACE);

            if (child.getChildren().size() > 0) {
                String originalSourceCData = outp.outputString((Element) child.getChildren().get(0));
                child.removeContent();
                child.addContent(new CDATA(originalSourceCData));
            }

        }
        return outp.outputString(jdomAip);

    } finally {
        if (reader != null) {
            reader.close();
        }
    }
}

From source file:com.tesora.dve.sql.util.DBHelperConnectionResource.java

@Override
public ExceptionClassification classifyException(Throwable t) {
    if (t.getMessage() == null)
        return null;
    String m = t.getMessage().trim();
    if (StringUtils.containsIgnoreCase(m, "Table") && StringUtils.endsWithIgnoreCase(m, "doesn't exist"))
        return ExceptionClassification.DNE;
    if (StringUtils.containsIgnoreCase(m, "Unknown table")
            || StringUtils.containsIgnoreCase(m, "Unknown column"))
        return ExceptionClassification.DNE;
    if (StringUtils.containsIgnoreCase(m, "Every derived table must have its own alias"))
        return ExceptionClassification.DNE;
    if (StringUtils.containsIgnoreCase(m, "Field")
            && StringUtils.endsWithIgnoreCase(m, "doesn't have a default value"))
        return ExceptionClassification.DNE;
    if (StringUtils.containsIgnoreCase(m, "SAVEPOINT") && StringUtils.endsWithIgnoreCase(m, "does not exist"))
        return ExceptionClassification.DNE;
    if (StringUtils.containsIgnoreCase(m, "Data Truncation:"))
        return ExceptionClassification.OUT_OF_RANGE;
    if (StringUtils.containsIgnoreCase(m, "You have an error in your SQL syntax"))
        return ExceptionClassification.SYNTAX;
    if (StringUtils.containsIgnoreCase(m, "Duplicate entry"))
        return ExceptionClassification.DUPLICATE;
    if (StringUtils.containsIgnoreCase(m, "option not supported"))
        return ExceptionClassification.UNSUPPORTED_OPERATION;
    if (StringUtils.startsWithIgnoreCase(m, "File") && StringUtils.containsIgnoreCase(m, "not found"))
        return ExceptionClassification.FILE_NOT_FOUND;
    if (StringUtils.startsWithIgnoreCase(m, "Table") && StringUtils.endsWithIgnoreCase(m, "already exists"))
        return ExceptionClassification.DUPLICATE;
    return null;//  w w  w . j a va2  s.  c om
}

From source file:hydrograph.ui.propertywindow.widgets.listeners.grid.MouseHoverOnSchemaGridListener.java

private String setToolTipForBigDecimal(GridRow gridRow, String componentType) {
    int precision = 0, scale = 0;

    if (StringUtils.isNotBlank(gridRow.getPrecision()) && StringUtils.isNotBlank(gridRow.getScale())) {
        try {// w  ww .  ja v  a2 s . com
            precision = Integer.parseInt(gridRow.getPrecision());
        } catch (NumberFormatException exception) {
            logger.debug("Failed to parse the precision ", exception);
            return Messages.PRECISION_MUST_CONTAINS_NUMBER_ONLY_0_9;
        }

        try {
            scale = Integer.parseInt(gridRow.getScale());
        } catch (NumberFormatException exception) {
            logger.debug("Failed to parse the scale ", exception);
            return Messages.SCALE_MUST_CONTAINS_NUMBER_ONLY_0_9;
        }
    }

    if (StringUtils.isBlank(gridRow.getPrecision()) && (StringUtils.containsIgnoreCase(componentType, "hive")
            || StringUtils.containsIgnoreCase(componentType, "parquet"))) {
        return Messages.PRECISION_MUST_NOT_BE_BLANK;
    } else if (!(gridRow.getPrecision().matches("\\d+")) && StringUtils.isNotBlank(gridRow.getPrecision())) {
        return Messages.PRECISION_MUST_CONTAINS_NUMBER_ONLY_0_9;
    } else if ((StringUtils.isBlank(gridRow.getScale()))) {
        return Messages.SCALE_MUST_NOT_BE_BLANK;
    } else if (!(gridRow.getScale().matches("\\d+")) || scale < 0) {
        return Messages.SCALE_SHOULD_BE_POSITIVE_INTEGER;
    } else if (StringUtils.equalsIgnoreCase(gridRow.getScaleTypeValue(), "none")) {
        return Messages.SCALETYPE_MUST_NOT_BE_NONE;
    } else if (precision <= scale) {
        return Messages.SCALE_MUST_BE_LESS_THAN_PRECISION;
    }
    return "";
}

From source file:com.dumbster.smtp.SimpleSmtpServer.java

/**
 * Function to transcript original message in multipart message. Then,
 * message is loaded in ElasticSearch Index
 * // w ww  . j  ava2  s .  com
 * @param msgs
 *            list of smtpMessage
 * @throws IOException
 * @throws JsonProcessingException
 */
private void saveMessagesInElasticSearch(List<SmtpMessage> msgs) throws IOException, JsonProcessingException {
    for (SmtpMessage smtpMessage : msgs) {

        boolean isMultipart = true;
        if (StringUtils.containsIgnoreCase(smtpMessage.getContentType(), "multipart")) {
            // Multipart message
            PartMessage partMessage = new PartMessage();
            try {
                BufferedReader buffIn = new BufferedReader(new StringReader(smtpMessage.getBody()));
                String line = buffIn.readLine();
                String frontier = null;
                StringBuilder bodyPart = new StringBuilder();

                // On rcupre la premire ligne
                if (line.equalsIgnoreCase("This is a multi-part message in MIME format.")) {
                    // Next line should define frontier
                    // between part message
                    frontier = buffIn.readLine().replaceAll("-", "");
                    // next line should be content type
                    line = buffIn.readLine();
                }

                while (line != null) {

                    if (partMessage.getContentType() == null
                            && StringUtils.containsIgnoreCase(line, "Content-type")) {
                        // Content type for this part message
                        int headerNameEnd = line.indexOf(':');
                        if (headerNameEnd >= 0) {
                            partMessage.setContentType(line.substring(headerNameEnd + 1).trim());
                        } else {
                            // Content is not correct
                            isMultipart = false;
                        }
                    } else if (line.contains(frontier)) {
                        // New part message
                        partMessage.setBody(bodyPart.toString());

                        smtpMessage.getParts().add(partMessage);
                        partMessage = new PartMessage();
                        bodyPart = new StringBuilder();
                    } else if (StringUtils.isEmpty(partMessage.getFileName())
                            && !StringUtils.containsIgnoreCase(partMessage.getContentType(), "text/")
                            && StringUtils.containsIgnoreCase(line, "name=")) {
                        // We are looking for file name of attached file
                        int headerNameEnd = line.indexOf("=\"");
                        if (headerNameEnd >= 0) {
                            String fileName = "";
                            while (line != null && line.indexOf("\"", headerNameEnd + 3) < 0) {
                                // Filename is on multi line
                                // We read stream until we find double quote
                                fileName = fileName + MimeUtility.decodeText(line);
                                line = buffIn.readLine();
                            }

                            // And Remove last double quote
                            fileName = fileName
                                    + MimeUtility.decodeText(line.substring(0, line.length() - 1)).trim();
                            // Remove name="
                            fileName = fileName.substring(fileName.indexOf("=\"") + 2, fileName.length()); // new indexOf
                            // because we remove
                            // whitespace with
                            // trim()

                            partMessage.setFileName(fileName);
                        }
                        bodyPart.append(line);
                    } else if (!StringUtils.containsIgnoreCase(line, "Content-Transfer-Encoding")) {
                        // Body
                        bodyPart.append(line);
                    }

                    // On lit la prochaine ligne
                    line = buffIn.readLine();
                }
            } catch (NullPointerException nullPointerException) {
                isMultipart = false;
            }
        } else {
            // one part message
            isMultipart = false;
        }
        if (!isMultipart) {
            // Default multipart
            PartMessage partMessage = new PartMessage();
            partMessage.setContentType(smtpMessage.getContentType());
            partMessage.setBody(smtpMessage.getBody());
            smtpMessage.getParts().add(partMessage);
        }

        IndexRequest indexRequest = Requests.indexRequest(mockimailConfig.getIndexES())
                .type(mockimailConfig.getTypeES());
        indexRequest.source(mapper.writeValueAsString(smtpMessage));
        clientES.index(indexRequest).actionGet();

    }
}

From source file:com.tesora.dve.common.PEFileUtils.java

private static Properties decrypt(Properties props) throws PEException {
    // we are going to iterate over all properties looking for any that
    // contain the string "password"
    for (String key : props.stringPropertyNames()) {
        if (StringUtils.containsIgnoreCase(key, "password")) {
            String value = props.getProperty(key);

            if (!StringUtils.isBlank(value)) {
                props.setProperty(key, PECryptoUtils.decrypt(value));
            }//  www  . ja  va2  s  .c om
        }
    }
    return props;
}

From source file:graphene.web.components.ui.MeaningfulBeanDisplay.java

public String getPropertyLinkClass() {
    style.getHexColorForNode(className);
    if (StringUtils.containsIgnoreCase(className, "Location")) {
        return "btn btn-xs bg-color-blueLight txt-color-white";
    } else if (StringUtils.containsIgnoreCase(className, "Address")) {
        return "btn btn-xs bg-color-blueDark txt-color-white";
    } else if (StringUtils.containsIgnoreCase(className, "Account")) {
        return "btn btn-xs bg-color-orange txt-color-white";
    } else if (StringUtils.containsIgnoreCase(className, "Subject")) {
        return "btn btn-xs bg-color-purple txt-color-white";
    } else if (StringUtils.containsIgnoreCase(className, "Name")) {
        return "btn btn-xs bg-color-greenLight txt-color-white";
    } else {/* w  w w  .j  a  v a2 s  . c o  m*/
        return "btn btn-xs bg-color-teal txt-color-white";
    }

}

From source file:com.tw.go.plugin.task.GoPluginImpl.java

private boolean isWindows() {
    String osName = System.getProperty("os.name");
    boolean isWindows = StringUtils.containsIgnoreCase(osName, "windows");
    JobConsoleLogger.getConsoleLogger()//from w w  w .ja  v  a 2 s . co  m
            .printLine("[script-executor] OS detected: '" + osName + "'. Is Windows? " + isWindows);
    return isWindows;
}

From source file:gov.nih.nci.cabig.caaers.web.study.StudyController.java

@Override
protected boolean suppressValidation(final HttpServletRequest request, final Object command) {

    //suppress validation for AJAX requests
    Object isAjax = findInRequest(request, "_isAjax");
    if (isAjax != null || isAjaxRequest(request)) {
        return true;
    }/*  w w  w  . ja v a 2 s  .  c o  m*/

    //suppress validation for request having sub-action
    String action = (String) findInRequest(request, "_action");
    if (StringUtils.isNotEmpty(action) && !StringUtils.containsIgnoreCase(action, "add")) {
        return true;
    }

    return super.suppressValidation(request, command);

}

From source file:it.serverSystem.ClusterTest.java

private static void expectLog(Orchestrator orchestrator, String expectedLog) throws IOException {
    File logFile = orchestrator.getServer().getWebLogs();
    try (Stream<String> lines = Files.lines(logFile.toPath())) {
        assertThat(lines.anyMatch(s -> StringUtils.containsIgnoreCase(s, expectedLog))).isTrue();
    }/*  w w  w .j a va2 s .co  m*/
}

From source file:com.intuit.tank.script.ScriptEditor.java

public String getPrettyString(String s, String mimetype) {
    if (StringUtils.isNotBlank(s)) {
        if (StringUtils.containsIgnoreCase(mimetype, "json")) {
            try {
                JsonParser parser = new JsonParser();
                Gson gson = new GsonBuilder().setPrettyPrinting().create();
                JsonElement el = parser.parse(s);
                s = gson.toJson(el); // done
            } catch (JsonSyntaxException e) {
                LOG.warn("Cannot format json string: " + e);
            }//ww w.  j  a  v a2s  .  c  o  m
        } else if (StringUtils.containsIgnoreCase(mimetype, "xml")) {
            try {
                StringWriter sw;
                final OutputFormat format = OutputFormat.createPrettyPrint();
                final org.dom4j.Document document = DocumentHelper.parseText(s);
                sw = new StringWriter();
                final XMLWriter writer = new XMLWriter(sw, format);
                writer.write(document);
                s = sw.toString();
            } catch (Exception e) {
                LOG.warn("Cannot format xml string: " + e);
            }
        }
        s = s.trim();
    }
    return s;
}