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

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

Introduction

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

Prototype

public static boolean contains(String str, String searchStr) 

Source Link

Document

Checks if String contains a search String, handling null.

Usage

From source file:com.fengduo.bee.service.impl.file.FileServiceImpl.java

public File getFile(String path) {
    if (StringUtils.isEmpty(path)) {
        return null;
    }/*from   w w  w . j a v  a 2s .  c  om*/
    if (StringUtils.contains(path, STATIC_TMP_IMG)) {
        path = StringUtils.replace(path, STATIC_TMP_IMG, StringUtils.EMPTY);
    }
    File file = new File(UPLOAD_TMP_PATH + path);
    if (file == null || !file.isFile()) {
        return null;
    }
    if (file.getParentFile() == null || !file.getParentFile().exists()) {
        return null;
    }
    return file;
}

From source file:com.enitalk.controllers.bots.FillWordsRunnable.java

public void sendCandidates(String url, Integer type) {
    try {/*from w ww .  ja  v a  2  s .  c om*/
        Response json = Request.Get(url).execute();
        String rs = json.returnContent().asString();
        JsonNode randomContent = jackson.readTree(rs);

        Iterator<JsonNode> els = randomContent.elements();
        while (els.hasNext()) {
            ObjectNode el = (ObjectNode) els.next();
            if (Character.isUpperCase(el.path("word").asText().charAt(0))
                    || StringUtils.contains(el.path("word").asText(), " ")) {
                els.remove();
            } else {
                el.put("type", type);
                rabbit.send("words", MessageBuilder.withBody(jackson.writeValueAsBytes(el)).build());
            }
        }

    } catch (Exception e) {
        logger.error(ExceptionUtils.getFullStackTrace(e));
    }
}

From source file:com.adobe.acs.tools.csv_asset_importer.impl.Column.java

public Column(final String raw, final int index) {
    this.index = index;
    this.raw = StringUtils.trim(raw);

    String paramsStr = StringUtils.substringBetween(raw, "{{", "}}");
    String[] params = StringUtils.split(paramsStr, ":");

    if (StringUtils.isBlank(paramsStr)) {
        this.relPropertyPath = this.getRaw();
    } else {//from   www  .  ja  v a  2 s . c o m
        this.relPropertyPath = StringUtils.trim(StringUtils.substringBefore(this.getRaw(), "{{"));

        if (params.length == 2) {
            this.dataType = nameToClass(StringUtils.stripToEmpty(params[0]));
            this.multi = StringUtils.equalsIgnoreCase(StringUtils.stripToEmpty(params[1]), MULTI);
        }

        if (params.length == 1) {
            if (StringUtils.equalsIgnoreCase(MULTI, StringUtils.stripToEmpty(params[0]))) {
                this.multi = true;
            } else {
                this.dataType = nameToClass(StringUtils.stripToEmpty(params[0]));
            }
        }
    }

    if (StringUtils.contains(this.relPropertyPath, "/")) {
        this.propertyName = StringUtils.trim(StringUtils.substringAfterLast(this.relPropertyPath, "/"));
    } else {
        this.propertyName = StringUtils.trim(this.relPropertyPath);
    }

}

From source file:com.thoughtworks.go.server.web.IgnoreResolver.java

private boolean isGoingToAbout(HttpServletRequest request) {
    return StringUtils.contains(request.getRequestURI(), request.getContextPath() + "/about");
}

From source file:com.jgeppert.struts2.bootstrap.showcase.Languages.java

@Action(value = "/languages", results = {
        @Result(type = "json", name = "success", params = { "root", "languages" }) })
public String execute() throws Exception {
    if (term != null && term.length() > 1) {
        ArrayList<String> tmp = new ArrayList<String>();
        for (String staticLanguage : staticLanguages) {
            if (StringUtils.contains(staticLanguage.toLowerCase(), term.toLowerCase())) {
                tmp.add(staticLanguage);
            }//from  w ww. j av a2 s.c om
        }
        languages = tmp.toArray(new String[tmp.size()]);
    }
    return SUCCESS;
}

From source file:cec.easyshop.storefront.interceptors.beforeview.CartRestorationBeforeViewHandler.java

/**
 * Decide whether or not the modifications related to the cart restoration or merge should be displayed in the
 * notifications//from  w w  w.  j a v a 2  s  . c  o m
 * 
 * @param request
 * @return whether or not to display the modifications
 */
protected Boolean showModifications(final HttpServletRequest request) {
    for (final String targetPage : getPagesToShowModifications()) {
        if (StringUtils.contains(request.getRequestURI().toString(), targetPage)) {
            return Boolean.TRUE;
        }
    }
    return Boolean.FALSE;
}

From source file:gov.nih.nci.cacisweb.action.SecureFTPAction.java

@Override
public String input() throws Exception {
    log.debug("input() - START");
    secureFTPRecepientList = new ArrayList<SecureFTPModel>();
    String secureFTPPropertyFileLocation = CaCISUtil
            .getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECFTP_PROPERTIES_FILE_LOCATION);
    String secureFTPKeystoreLocation = CaCISUtil.getPropertyFromPropertiesFile(secureFTPPropertyFileLocation,
            CaCISUtil.getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECFTP_TRUSTSTORE_LOCATION_PROP_NAME));
    String secureFTPKeystorePassword = CaCISUtil.getPropertyFromPropertiesFile(secureFTPPropertyFileLocation,
            CaCISUtil.getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECFTP_TRUSTSTORE_PASSWORD_PROP_NAME));

    CaCISUtil caCISUtil = new CaCISUtil();
    String propertyFileLocation = CaCISUtil
            .getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECFTP_CONFIG_FILE_LOCATION);

    try {//from w  w  w .ja v a2s .  c  o  m
        caCISUtil.isPropertyFileAndKeystoreInSync(propertyFileLocation, secureFTPKeystoreLocation,
                CaCISWebConstants.COM_KEYSTORE_TYPE_JKS, secureFTPKeystorePassword);
    } catch (PropFileAndKeystoreOutOfSyncException e) {
        if (!StringUtils.contains(e.getMessage(), "sftp")) {
            log.error(e.getMessage());
            addActionError(e.getMessage());
        }
    }

    try {
        KeyStore keystore = caCISUtil.getKeystore(secureFTPKeystoreLocation,
                CaCISWebConstants.COM_KEYSTORE_TYPE_JKS, secureFTPKeystorePassword);
        // // List the aliases
        // Enumeration<String> enumeration = keystore.aliases();
        Properties configFile = new Properties();
        InputStream is = new FileInputStream(propertyFileLocation);
        configFile.load(is);
        is.close();
        Enumeration<Object> enumeration = configFile.keys();
        // while (enumeration.hasMoreElements()) {
        // String alias = (String) enumeration.nextElement();
        // X509Certificate x509Certificate = (X509Certificate) keystore.getCertificate(alias);
        // SecureFTPModel secureFTPModel = new SecureFTPModel();
        // secureFTPModel.setCertificateAlias(alias);
        // secureFTPModel.setCertificateDN(x509Certificate.getSubjectDN().toString());
        // secureFTPRecepientList.add(secureFTPModel);
        // log.debug("Alias: " + alias + " DN: " + x509Certificate.getSubjectDN().getName());
        // }
        while (enumeration.hasMoreElements()) {
            String alias = (String) enumeration.nextElement();
            X509Certificate x509Certificate = (X509Certificate) keystore.getCertificate(alias);
            String distinguishedName = "";
            if (x509Certificate != null) {
                distinguishedName = x509Certificate.getSubjectDN().toString();
            }
            SecureFTPModel secureFTPModel = new SecureFTPModel();
            secureFTPModel.setCertificateAlias(alias);
            secureFTPModel.setCertificateDN(distinguishedName);
            secureFTPRecepientList.add(secureFTPModel);
            log.debug("Alias: " + alias + " DN: " + distinguishedName);
        }

        caCISUtil.releaseKeystore();
    } catch (KeystoreInstantiationException kie) {
        log.error(kie.getMessage());
        addActionError(getText("exception.keystoreInstantiation"));
        return ERROR;
    }
    log.debug("input() - END");
    return INPUT;
}

From source file:com.shin1ogawa.appengine.marketplace.controller.SetupForAdminController.java

@Override
protected Navigation setUp() {
    domain = asString("domain");
    callback = asString("callback");
    if (StringUtils.isEmpty(callback)) {
        callback = sessionScope("callback");
        removeSessionScope("callback");
    }/*  w w  w. j a  v  a 2  s  .  c o  m*/
    if (StringUtils.isEmpty(callback)) {
        // from 'Addional Setup' in cpanel.
        callback = "https://www.google.com/a/cpanel/" + domain + "/PikeplaceAppSettings?appId="
                + Configuration.get().getMarketplaceAppId() + "&licenseNamespace=PACKAGE_GAIAID";
    }
    if (StringUtils.isEmpty(domain) || StringUtils.isEmpty(callback)) {
        return redirect(Configuration.get().getMarketplaceListingUrl());
    }
    UserService us = UserServiceFactory.getUserService();
    if (us.isUserLoggedIn() == false) {
        // if user had not been authenticated then send redirect to login url.
        String callbackURL = request.getRequestURL() + "?domain=" + domain;
        sessionScope("callback", callback);
        logger.log(Level.INFO, "had not been authenticated: callback=" + callbackURL);
        return redirect(us.createLoginURL(callbackURL, domain,
                "https://www.google.com/accounts/o8/site-xrds?hd=" + domain, null));
    }
    if (StringUtils.contains(us.getCurrentUser().getFederatedIdentity(), domain) == false) {
        // if user had been authenticated but invalid domain then send redirect to logout url.
        sessionScope("callback", callback);
        String callbackURL = request.getRequestURL() + "?domain=" + domain;
        logger.log(Level.INFO, "invalid domain: callback=" + callbackURL);
        return redirect(us.createLogoutURL(callbackURL, domain));
    }
    delegate = IncreaseURLFetchDeadlineDelegate.install();
    NamespaceManager.set(domain);
    return super.setUp();
}

From source file:hydrograph.ui.graph.figure.PortFigure.java

/**
 * Instantiates a new port figure./*from w ww  .  j av a  2  s  .c  o m*/
 * 
 * @param portColor
 *            the port color
 * @param portSeq 
 *          Sequence of the port
 * @param totalPorts
 *          Total number of ports
 * @param portTerminal
 *            the port terminal
 * @param labelOfPort 
 *          label to be displayed for port
        
 */
public PortFigure(Color portColor, int portSeq, int totalPorts, String portTerminal, String labelOfPort,
        PortAlignmentEnum alignment) {

    if (alignment == null) {
        if (StringUtils.contains(portTerminal, Constants.INPUT_SOCKET_TYPE))
            alignment = PortAlignmentEnum.LEFT;
        else if (StringUtils.contains(portTerminal, Constants.OUTPUT_SOCKET_TYPE))
            alignment = PortAlignmentEnum.RIGHT;
        else if (StringUtils.contains(portTerminal, Constants.UNUSED_SOCKET_TYPE))
            alignment = PortAlignmentEnum.BOTTOM;
    }

    this.portColor = portColor;
    this.terminal = portTerminal;
    this.anchor = new FixedConnectionAnchor(this, alignment.value(), totalPorts, portSeq, portTerminal);
    this.labelOfPort = labelOfPort;
    this.portAlignment = alignment;
    ////to define the height and width of in, out and unused port 
    setPortDimension();

    portLabelFont = new Font(Display.getDefault(), ELTFigureConstants.labelFont, 8, SWT.NORMAL);
    setFont(portLabelFont);
    setForegroundColor(ColorConstants.black);

    componentBorder = new Color(null, ELTColorConstants.DARK_GREY_RGB[0], ELTColorConstants.DARK_GREY_RGB[1],
            ELTColorConstants.DARK_GREY_RGB[2]);
    componentBorderSelectedColor = new Color(null, ELTColorConstants.COMPONENT_BORDER_SELECTED_RGB[0],
            ELTColorConstants.COMPONENT_BORDER_SELECTED_RGB[1],
            ELTColorConstants.COMPONENT_BORDER_SELECTED_RGB[2]);
    watchColor = new Color(null, ELTColorConstants.WATCH_COLOR_RGB[0], ELTColorConstants.WATCH_COLOR_RGB[1],
            ELTColorConstants.WATCH_COLOR_RGB[2]);

    //NOTE : to Suppress the component tooltip when user hover the mouse on Port 
    addMouseMotionListener(new MouseMotionListener() {
        @Override
        public void mouseMoved(MouseEvent arg0) {
        }

        @Override
        public void mouseHover(MouseEvent arg0) {
        }

        @Override
        public void mouseExited(MouseEvent arg0) {
        }

        @Override
        public void mouseEntered(MouseEvent arg0) {
        }

        @Override
        public void mouseDragged(MouseEvent arg0) {
        }
    });

}

From source file:com.hangum.tadpole.engine.query.dao.mysql.SessionListDAO.java

public String getSID() {
    if (StringUtils.contains(getId(), ",")) {
        return StringUtils.substringBefore(getId(), ",");
    } else {/*from w  ww .j a  v a 2s.c o  m*/
        return getId();
    }
}