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

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

Introduction

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

Prototype

public static boolean equals(final CharSequence cs1, final CharSequence cs2) 

Source Link

Document

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

null s are handled without exceptions.

Usage

From source file:com.glaf.core.web.servlet.SpringDispatcherServlet.java

@Override
protected void doService(HttpServletRequest request, HttpServletResponse response) throws Exception {
    logger.debug("RequestURI:" + request.getRequestURI());
    try {//  ww  w .  j  ava  2 s .co  m
        String systemName = RequestUtils.getCurrentSystem(request);
        if (systemName != null && !StringUtils.equals("GLAF", systemName)) {
            Environment.setCurrentSystemName(systemName);
        }

        String actorId = RequestUtils.getActorId(request);
        if (actorId != null) {
            // logger.debug("actorId:" + actorId);
            Authentication.setAuthenticatedActorId(actorId);
        }

        LoginContext user = RequestUtils.getLoginContext(request);
        if (user != null) {
            Authentication.setLoginContext(user);
            com.glaf.core.security.Authentication.setAuthenticatedActorId(user.getActorId());
        }

        /**
         * ??????
         */
        if ((user == null) || (!user.isSystemAdministrator())) {
            String uri = request.getRequestURI();
            logger.debug("request uri:" + uri);

        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    ThreadContextHolder.setHttpRequest(request);
    ThreadContextHolder.setHttpResponse(response);
    ThreadContextHolder.setServletContext(request.getServletContext());
    try {
        super.doService(request, response);
    } finally {
        Environment.setCurrentSystemName(null);
        Environment.removeCurrentSystemName();
        Environment.clear();
        Authentication.clear();
        ThreadContextHolder.clear();
        ConnectionThreadHolder.closeAndClear();
    }

}

From source file:de.micromata.genome.gwiki.model.config.GWikiAbstractSpringContextBootstrapConfigLoader.java

@Override
public GWikiDAOContext loadConfig(ServletConfig config) {
    if (config != null && StringUtils.isBlank(fileName) == true) {
        fileName = config//  w w  w  .  j a va2 s . c o  m
                .getInitParameter("de.micromata.genome.gwiki.model.config.GWikiBootstrapConfigLoader.fileName");
        supportsJndi = StringUtils.equals(config.getInitParameter("de.micromata.genome.gwiki.supportsJndi"),
                "true");
    }
    ConfigurableApplicationContext actx = createApplicationContext(config, getApplicationContextName());
    actx.addBeanFactoryPostProcessor(new GWikiDAOContextPropertyPlaceholderConfigurer(config, supportsJndi));
    actx.refresh();
    beanFactory = actx;
    GWikiDAOContext daoContext = (GWikiDAOContext) actx.getBean("GWikiBootstrapConfig");

    daoContext.setBeanFactory(beanFactory);
    return daoContext;
}

From source file:minor.register.RegisterAction.java

@Override
public void validate() {
    if (StringUtils.isEmpty(getUname())) {
        addFieldError("uname", "Username cannot be blank.");
    }/*w ww.  j a  va 2 s.com*/
    if (StringUtils.isEmpty(getUname())) {
        addFieldError("name", "Name cannot be blank.");
    }
    if (StringUtils.isEmpty(getUname())) {
        addFieldError("password", "Password cannot be blank.");
    }
    if (StringUtils.isEmpty(getCpassword())) {
        addFieldError("cpassword", "Confirm Password cannot be blank.");
    }
    if (StringUtils.isEmpty(getEmail())) {
        addFieldError("email", "Email cannot be blank");
    }
    if (!StringUtils.equals(getPassword(), getCpassword())) {
        addFieldError("cpassword", "Passwords don't match.");
    }
    try {
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Minor", "root", "");

        PreparedStatement ps = con.prepareStatement("select * from userinfo where username=?");
        ps.setString(1, uname);

        ResultSet rs = ps.executeQuery();
        if (rs.next()) {
            addFieldError("uname", "Username already taken.");
        }
        con.close();
    } catch (ClassNotFoundException e) {
        System.out.println(e);
    } catch (SQLException e) {
        System.out.println(e);
    }
}

From source file:cherry.foundation.testtool.reflect.ReflectionResolverImpl.java

@Override
public List<Method> resolveMethod(Class<?> beanClass, String methodName) {
    List<Method> list = new ArrayList<>();
    for (Method m : beanClass.getDeclaredMethods()) {
        if (StringUtils.equals(m.getName(), methodName)) {
            list.add(m);/*from   www. j  av a2s . c o  m*/
        }
    }
    return list;
}

From source file:io.wcm.config.core.impl.ParameterOverrideInfo.java

ParameterOverrideInfo(String overrideString) {
    Matcher matcher = OVERRIDE_STRING_PATTERN.matcher(overrideString);
    if (!matcher.matches()) {
        throw new IllegalArgumentException(
                "Invalid override string identifying scope and parameter: " + overrideString);
    }/*ww w .j  a  va  2  s .c o m*/

    boolean systemScope = false;
    String scope = matcher.group(2);

    // evaluate overrideSystemDefault
    if (StringUtils.equals(DEFAULT_SCOPE, scope)) {
        overrideSystemDefault = true;
        systemScope = true;
    } else {
        overrideSystemDefault = false;
    }

    // evaluate isLocked
    if (StringUtils.equals(LOCKED_SUFFIX.substring(1), scope)) {
        isLocked = true;
        systemScope = true;
    } else {
        isLocked = StringUtils.equals(matcher.group(3), LOCKED_SUFFIX) || StringUtils.isEmpty(matcher.group(2));
    }

    if (matcher.group(3) != null && systemScope) {
        throw new IllegalArgumentException("Invalid override string identifying scope and parameter "
                + "- ':locked' not allowed here: " + overrideString);
    }

    // evaluate configurationId
    if (systemScope) {
        configurationId = null;
    } else {
        configurationId = matcher.group(2);
    }

    // evaluate parameterName
    parameterName = matcher.group(4);
}

From source file:iqq.app.ui.renderer.node.BuddyNode.java

/**
 * ???/*from  www  . ja  v a 2s.c om*/
 *
 * @return
 */
public IMPanel getView() {
    if (avatar == null || !avatar.equals(buddy.getAvatar())) {
        avatar = buddy.getAvatar();
        avatarImage.setIcon(ImageUtils.createPreviewIcon(avatar, 40));
    }
    if (!StringUtils.equals(nickLbl.getText(), buddy.getNick())) {
        nickLbl.setText(buddy.getNick());
    }
    if (!StringUtils.equals(signLbl.getText(), buddy.getSign())) {
        signLbl.setText(buddy.getSign());
    }
    return view;
}

From source file:com.nortal.petit.orm.ListQuery.java

public void initQueryResult(String queryString) {
    if (queryResult == null) {
        queryResult = new QueryResult<B>(queryString);
        return;//from   www.  j  a  v  a  2 s  . co m
    }
    if (StringUtils.equals(queryString, queryResult.getQueryString())) {
        queryResult.clearActiveResult();
        // QueryResult'i pole vaja le initsialiseerida - sama pring.
        // Kasutaja
        // liigub leheklgede vahel
        // Kontrollime, kas ksitav vahemik on cachetud, kui jah, siis
        // mrgime
        // selle aktiivseks vastuseks
        List<B> result = queryResult.getCachedResult(limit);
        if (result != null) {
            queryResult.setResultList(result, limit);
        }
    } else {
        queryResult = new QueryResult<B>(queryString);
    }
}

From source file:com.silkroad.ui.renderer.node.BuddyNode.java

/**
 * ???/*from w w  w  . java2s  .c o  m*/
 *
 * @return
 */
public UIPanel getView() {
    if (avatar == null || !avatar.equals(buddy.getAvatar())) {
        avatar = buddy.getAvatar();
        ImageIcon icon = new ImageIcon(avatar);
        avatarImage.setIcon(icon);
    }
    if (!StringUtils.equals(nickLbl.getText(), buddy.getNick())) {
        nickLbl.setText(buddy.getNick());
    }
    if (!StringUtils.equals(signLbl.getText(), buddy.getSign())) {
        signLbl.setText(buddy.getSign());
    }
    return view;
}

From source file:com.cognifide.qa.bb.aem.core.component.configuration.ComponentConfiguration.java

/**
 * Returns first {@link FieldConfig} with provided label.
 *
 * @param tabName Tab name in the dialog window
 * @param label   field label/*www .ja v a2  s  .  c o  m*/
 * @return {@link FieldConfig} matching given field in the provided tab
 * @throws IllegalArgumentException when no field is matched
 */
public FieldConfig getFieldConfigByLabel(String tabName, String label) {
    return getConfigurationForTab(tabName).stream().filter(t -> StringUtils.equals(t.getLabel(), label))
            .findFirst()
            .orElseThrow(() -> new IllegalArgumentException("No field config found for provided data"));
}

From source file:com.glaf.core.config.AbstractModule.java

public boolean eq(String key, String value) {
    if (key != null && value != null) {
        String x = properties.getProperty(key);
        if (StringUtils.equals(value, x)) {
            return true;
        }//w w w  .  j  a va 2  s.co  m
    }
    return false;
}