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

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

Introduction

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

Prototype

public static boolean contains(final CharSequence seq, final CharSequence searchSeq) 

Source Link

Document

Checks if CharSequence contains a search CharSequence, handling null .

Usage

From source file:com.haulmont.cuba.web.gui.components.table.AbbreviatedCellClickListener.java

@SuppressWarnings("unchecked")
@Override//from ww  w. ja v  a  2 s. co  m
public void onClick(Entity item, String columnId) {
    Table.Column column = table.getColumn(columnId);
    MetaProperty metaProperty;
    String value;
    if (DynamicAttributesUtils.isDynamicAttribute(columnId)) {
        metaProperty = dynamicAttributesTools.getMetaPropertyPath(item.getMetaClass(), columnId)
                .getMetaProperty();
        value = dynamicAttributesTools.getDynamicAttributeValueAsString(metaProperty,
                item.getValueEx(columnId));
    } else {
        value = item.getValueEx(columnId);
    }
    if (column.getMaxTextLength() != null) {
        boolean isMultiLineCell = StringUtils.contains(value, "\n");
        if (value == null
                || (value.length() <= column.getMaxTextLength() + MAX_TEXT_LENGTH_GAP && !isMultiLineCell)) {
            // todo artamonov if we click with CTRL and Table is multiselect then we lose previous selected items
            //noinspection SuspiciousMethodCalls
            if (!table.getSelected().contains(item)) {
                table.setSelected(item);
            }
            // do not show popup view
            return;
        }
    }

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(false);
    layout.setSpacing(false);
    layout.setWidthUndefined();
    layout.setStyleName("c-table-view-textcut");

    CubaTextArea textArea = new CubaTextArea();
    textArea.setValue(Strings.nullToEmpty(value));
    textArea.setReadOnly(true);

    CubaResizableTextAreaWrapper content = new CubaResizableTextAreaWrapper(textArea);
    content.setResizableDirection(ResizeDirection.BOTH);

    // todo implement injection for ThemeConstains in components
    ThemeConstants theme = App.getInstance().getThemeConstants();
    if (theme != null) {
        content.setWidth(theme.get("cuba.web.Table.abbreviatedPopupWidth"));
        content.setHeight(theme.get("cuba.web.Table.abbreviatedPopupHeight"));
    } else {
        content.setWidth("320px");
        content.setHeight("200px");
    }

    layout.addComponent(content);

    CubaEnhancedTable enhancedTable = table.unwrap(CubaEnhancedTable.class);
    enhancedTable.showCustomPopup(layout);
    enhancedTable.setCustomPopupAutoClose(false);
}

From source file:com.jt.leave.tools.DataFixtures.java

/**
 * DataSource?Connection(??)?url??Connection.
 *//*  www.ja  v  a2  s  .co m*/
protected static IDatabaseConnection getConnection(DataSource dataSource)
        throws DatabaseUnitException, SQLException {
    Connection connection = dataSource.getConnection();
    String jdbcUrl = connection.getMetaData().getURL();
    if (StringUtils.contains(jdbcUrl, ":h2:")) {
        return new H2Connection(connection, null);
    } else if (StringUtils.contains(jdbcUrl, ":mysql:")) {
        return new MySqlConnection(connection, null);
    } else if (StringUtils.contains(jdbcUrl, ":oracle:")) {
        return new OracleConnection(connection, null);
    } else {
        return new DatabaseConnection(connection);
    }
}

From source file:com.erudika.para.security.PasswordAuthFilter.java

/**
 * Handles an authentication request./*w  ww.  j  a  v a 2  s .  com*/
 * @param request HTTP request
 * @param response HTTP response
 * @return an authentication object that contains the principal object if successful.
 * @throws IOException ex
 * @throws ServletException ex
 */
@Override
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    String requestURI = request.getRequestURI();
    Authentication userAuth = null;
    User user = new User();

    if (requestURI.endsWith(PASSWORD_ACTION)) {
        user.setIdentifier(request.getParameter(EMAIL));
        user.setPassword(request.getParameter(PASSWORD));

        if (User.passwordMatches(user) && StringUtils.contains(user.getIdentifier(), "@")) {
            //success!
            user = User.readUserForIdentifier(user);
            userAuth = new UserAuthentication(new AuthenticatedUserDetails(user));
        }
    }

    if (userAuth == null || user == null || user.getIdentifier() == null) {
        throw new BadCredentialsException("Bad credentials.");
    } else if (!user.getActive()) {
        throw new LockedException("Account is locked.");
        //      } else {
        //         SecurityUtils.setAuthCookie(user, request, response);
    }
    return userAuth;
}

From source file:com.mirth.connect.server.migration.Migrate3_0_0.java

@Override
public void updateConfiguration(PropertiesConfiguration configuration) {
    if (configuration.getProperty("database").equals("derby")) {
        String url = (String) configuration.getProperty("database.url");

        if (!StringUtils.contains(url, ";upgrade=")) {
            url += ";upgrade=true";
        }/*from   ww  w  . j a va2s  .c  o  m*/

        configuration.setProperty("database.url", url);
    }
}

From source file:com.glaf.core.web.rest.MxFileSystemResource.java

@GET
@POST/*from  www .  jav  a  2 s.co  m*/
@Path("/json")
@ResponseBody
@Produces({ MediaType.APPLICATION_OCTET_STREAM })
public byte[] json(@Context HttpServletRequest request) throws IOException {
    Map<String, Object> params = RequestUtils.getParameterMap(request);
    LogUtils.debug(params);
    JSONArray array = new JSONArray();
    String path = request.getParameter("path");
    if (StringUtils.isEmpty(path)) {
        path = "/WEB-INF";
    }
    String root = SystemProperties.getAppPath() + "/" + path;
    File dir = new File(root);
    if (dir.exists() && dir.isDirectory()) {
        File[] contents = dir.listFiles();
        if (contents != null) {
            for (int i = 0; i < contents.length; i++) {
                File file = contents[i];
                if (file.exists() && file.isFile()) {
                    if (StringUtils.contains(file.getName(), "jdbc.properties")) {
                        continue;
                    }
                    if (StringUtils.contains(file.getName(), "hibernate.cfg.xml")) {
                        continue;
                    }
                    JSONObject json = new JSONObject();
                    json.put("id", DigestUtils.md5Hex(path + "/" + file.getName()));
                    json.put("parentId", DigestUtils.md5Hex(path + "/"));
                    json.put("startIndex", i + 1);
                    json.put("date", DateUtils.getDateTime(new Date(file.lastModified())));
                    json.put("name", file.getName());
                    json.put("path", path + "/" + file.getName());
                    json.put("class", "file");
                    json.put("size", file.length());
                    json.put("leaf", true);
                    array.add(json);
                }
            }
        }
    }
    return array.toJSONString().getBytes("UTF-8");
}

From source file:info.magnolia.ui.framework.setup.ReplaceSaveModeTypeFieldDefinitionTask.java

@Override
protected void operateOnNode(InstallContext installContext, Node node) {
    String nodePath = NodeUtil.getPathIfPossible(node);
    try {/*from w  ww. j a  v  a 2s  .c  o  m*/
        if (StringUtils.contains(nodePath, "fields")) {
            if (node.hasProperty("multiValueHandlerClass")) {
                String multiValueHandlerClass = node.getProperty("multiValueHandlerClass").getString();
                if (StringUtils.equals("info.magnolia.ui.form.field.property.MultiValuesHandler",
                        multiValueHandlerClass)) {
                    // Simply remove the node. The field definition already contains the default transformerClass.
                    node.remove();
                    log.debug(
                            "The following node will be removed {}. The field definition already contain the definition of the default transformerClass",
                            nodePath);
                } else if (StringUtils.equals("info.magnolia.ui.form.field.property.SubNodesValueHandler",
                        multiValueHandlerClass)) {
                    Node parent = node.getParent();
                    parent.setProperty("transformerClass",
                            MultiValueSubChildrenNodeTransformer.class.getName());
                    node.remove();

                } else if (StringUtils.equals("info.magnolia.ui.form.field.property.CommaSeparatedValueHandler",
                        multiValueHandlerClass)) {
                    Node parent = node.getParent();
                    parent.setProperty("transformerClass", MultiValueJSONTransformer.class.getName());
                    node.remove();
                } else {
                    log.warn(
                            "Unknown value for property 'multiValueHandlerClass' : {}. This node {} will not be handled",
                            multiValueHandlerClass, nodePath);
                }
            }
        } else {
            log.debug(
                    "The following node {} is not a field configuration. The child 'saveModeType' will not be handled. ",
                    nodePath);
        }
    } catch (RepositoryException re) {
        log.warn("Could not Migrate 'saveModeType' child node of the following node {}.", nodePath);
    }
}

From source file:com.bazaarvoice.seo.sdk.url.BVSeoSdkURLBuilder.java

/**
 * Corrects the baseUri that is supplied
 * @return/*  w w  w  .j a  v a  2s. c  om*/
 */
public String correctedBaseUri() {
    String baseUri = bvParameters.getBaseURI() == null ? "" : bvParameters.getBaseURI();

    if (StringUtils.contains(baseUri, "bvrrp") || StringUtils.contains(baseUri, "bvqap")
            || StringUtils.contains(baseUri, "bvsyp") || StringUtils.contains(baseUri, "bvpage")) {
        baseUri = BVUtilty.removeBVQuery(baseUri);
    }

    return baseUri;
}

From source file:com.micmiu.modules.test.data.DataFixtures.java

/**
 * DataSource?Connection(??)?url??Connection.
 *//*from   ww w  . j  a  v a 2 s  .co  m*/
protected static IDatabaseConnection getConnection(DataSource dataSource)
        throws DatabaseUnitException, SQLException {
    Connection connection = dataSource.getConnection();
    String dbName = connection.getMetaData().getURL();
    if (StringUtils.contains(dbName, ":h2:")) {
        return new H2Connection(connection, null);
    } else if (StringUtils.contains(dbName, ":mysql:")) {
        return new MySqlConnection(connection, null);
    } else if (StringUtils.contains(dbName, ":oracle:")) {
        return new OracleConnection(connection, null);
    } else {
        return new DatabaseConnection(connection);
    }
}

From source file:com.glaf.activiti.mail.SendTodoMailTaskBean.java

public void sendAllRunningTasks() {
    ISysTodoService todoService = ContextFactory.getBean("sysTodoService");
    List<Todo> todoList = todoService.getTodoList();
    if (todoList != null && !todoList.isEmpty()) {
        Map<String, User> userMap = IdentityFactory.getUserMap();
        Iterator<User> iterator = userMap.values().iterator();
        while (iterator.hasNext()) {
            User user = iterator.next();
            if (StringUtils.isNotEmpty(user.getMail()) && StringUtils.contains(user.getMail(), "@")) {
                this.sendRunningTasks(user, todoList);
            }/*from ww  w . jav a 2s. c o  m*/
        }
    }
}

From source file:io.wcm.testing.mock.sling.servlet.MockSlingHttpServletResponse.java

@Override
public void setContentType(final String type) {
    this.contentType = type;
    if (StringUtils.contains(this.contentType, CHARSET_SEPARATOR)) {
        this.characterEncoding = StringUtils.substringAfter(this.contentType, CHARSET_SEPARATOR);
        this.contentType = StringUtils.substringBefore(this.contentType, CHARSET_SEPARATOR);
    }//from  w  w  w  .ja v  a  2 s  .co m
}