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

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

Introduction

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

Prototype

public static boolean equalsIgnoreCase(String str1, String str2) 

Source Link

Document

Compares two Strings, returning true if they are equal ignoring the case.

Usage

From source file:de.tudarmstadt.ukp.clarin.webanno.api.dao.SecurityUtil.java

/**
 * Determine if the User is allowed to update a project
 *
 * @param aProject the project//w w w  . j av  a  2 s .  com
 * @param aProjectRepository the repository service.
 * @param aUser the user.
 * @return if the user may update a project.
 */
public static boolean isProjectAdmin(Project aProject, RepositoryService aProjectRepository, User aUser) {
    boolean roleAdmin = false;
    List<Authority> authorities = aProjectRepository.listAuthorities(aUser);
    for (Authority authority : authorities) {
        if (authority.getAuthority().equals("ROLE_ADMIN")) {
            roleAdmin = true;
            break;
        }
    }

    boolean projectAdmin = false;
    if (!roleAdmin) {

        try {
            List<ProjectPermission> permissionLevels = aProjectRepository.listProjectPermisionLevel(aUser,
                    aProject);
            for (ProjectPermission permissionLevel : permissionLevels) {
                if (StringUtils.equalsIgnoreCase(permissionLevel.getLevel().getName(),
                        PermissionLevel.ADMIN.getName())) {
                    projectAdmin = true;
                    break;
                }
            }
        } catch (NoResultException ex) {
            LOG.info("No permision is given to this user " + ex);
        }
    }

    return (projectAdmin || roleAdmin);
}

From source file:hydrograph.ui.graph.action.PropagateDataAction.java

@Override
protected boolean calculateEnabled() {
    List<Object> selectedObjects = getSelectedObjects();
    if (selectedObjects != null && !selectedObjects.isEmpty() && selectedObjects.size() == 1) {
        for (Object obj : selectedObjects) {
            if (obj instanceof ComponentEditPart) {
                component = ((ComponentEditPart) obj).getCastedModel();
                if (StringUtils.equalsIgnoreCase(Constants.STRAIGHTPULL, component.getCategory())
                        || StringUtils.equalsIgnoreCase(Constants.TRANSFORM, component.getCategory())
                        || StringUtils.equalsIgnoreCase(Constants.SUBJOB_COMPONENT,
                                component.getComponentName())

                ) {// ww  w  . jav a  2  s.  co m
                    if (!component.getTargetConnections().isEmpty())
                        return true;
                }
            }
        }
    }
    return false;
}

From source file:com.sfs.whichdoctor.search.TagSearchDAOImpl.java

/**
 * Perform a search for tags./*w ww. j a  v  a 2  s .  co m*/
 *
 * @param objecttype the objecttype
 * @param order Order options are: alpha (alphabetical), count (tag count)
 * @param user the user
 *
 * @return the map< string, collection< tag bean>>
 *
 * @throws WhichDoctorSearchDaoException the which doctor search dao
 *             exception
 */
@SuppressWarnings("unchecked")
public final Map<String, Collection<TagBean>> search(final String objecttype, final String order,
        final UserBean user) throws WhichDoctorSearchDaoException {

    if (objecttype == null) {
        throw new WhichDoctorSearchDaoException("An object type must be " + "specified for a tag search");
    }

    Map<String, Collection<TagBean>> results = new HashMap<String, Collection<TagBean>>();

    // Holds a running total of the maximum tag count for each tag type
    HashMap<String, Integer> maxTagCount = new HashMap<String, Integer>();

    String searchSQL = this.getSQL().getValue("tag/search");

    /* Default order is alphabetical */
    if (StringUtils.equalsIgnoreCase(order, "count")) {
        searchSQL += " ORDER BY TagCount DESC";
    } else {
        searchSQL += " ORDER BY TagName ASC";
    }

    dataLogger.info("Performing tag search");

    Collection<TagBean> tagResults = new ArrayList<TagBean>();

    try {
        tagResults = this.getJdbcTemplateReader().query(searchSQL,
                new Object[] { objecttype, "Private", "Private", user.getDN() }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        TagBean tag = new TagBean();
                        tag.setTagName(rs.getString("TagName"));
                        tag.setTagType(rs.getString("TagType"));
                        tag.setTagCount(rs.getInt("TagCount"));

                        return tag;
                    }
                });
    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for search: " + ie.getMessage());
    }

    for (TagBean tag : tagResults) {
        Collection<TagBean> tags = new ArrayList<TagBean>();
        if (results.containsKey(tag.getTagType())) {
            // Get existing array from
            tags = results.get(tag.getTagType());
        }

        if (maxTagCount.containsKey(tag.getTagType())) {
            Integer maxCount = maxTagCount.get(tag.getTagType());
            if (tag.getTagCount() > maxCount) {
                maxTagCount.put(tag.getTagType(), tag.getTagCount());
            }
        } else {
            maxTagCount.put(tag.getTagType(), new Integer(tag.getTagCount()));
        }
        tags.add(tag);

        results.put(tag.getTagType(), tags);
    }

    /* Iterate through results setting max tag count */
    for (String key : results.keySet()) {
        Integer maxCount = maxTagCount.get(key);

        Collection<TagBean> tempTags = results.get(key);
        Collection<TagBean> tags = new ArrayList<TagBean>();

        for (TagBean tag : tempTags) {
            tag.setMaxCount(maxCount);
            tags.add(tag);
        }
        results.put(key, tags);
    }

    /* Load all tags */
    String searchAllSQL = getSQL().getValue("tag/searchAll");

    if (order.compareToIgnoreCase("count") == 0) {
        searchAllSQL += " ORDER BY TagCount DESC";
    } else {
        searchAllSQL += " ORDER BY TagName ASC";
    }

    Collection<TagBean> allTagResults = new ArrayList<TagBean>();
    try {
        allTagResults = this.getJdbcTemplateReader().query(searchAllSQL,
                new Object[] { objecttype, "Private", "Private", user.getDN() }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        TagBean tag = new TagBean();
                        tag.setTagName(rs.getString("TagName"));
                        tag.setTagType("All");
                        tag.setTagCount(rs.getInt("TagCount"));

                        return tag;
                    }
                });
    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for search: " + ie.getMessage());
    }

    int maxAllTagCount = 0;
    for (TagBean tag : allTagResults) {
        if (tag.getTagCount() > maxAllTagCount) {
            maxAllTagCount = tag.getTagCount();
        }
    }

    Collection<TagBean> allTags = new ArrayList<TagBean>();

    for (TagBean tag : allTagResults) {
        tag.setMaxCount(maxAllTagCount);
        allTags.add(tag);
    }

    if (allTags.size() > 0) {
        // At least one tag has been found, add it to results
        results.put("All", allTags);
    }
    return results;
}

From source file:me.taylorkelly.mywarp.util.MatchList.java

/**
 * Gets an Optional that contains an exact match (if such a Warp exists). A Warp is an exact match if it fulfills one
 * of the following conditions, starting from the top: <ol> <li>the only Warp whose name contains case-insensitively
 * this MatchList's filer,</li> <li>the only Warp whose name is case insensitively equal to this MatchList's filter,
 * <li>the only Warp whose name is equal to this MatchList's filter.</li> </ol>
 *
 * @return a exactly matching Warp/*w ww .ja v a  2s.  c o m*/
 */
// REVIEW this could be done when the MatchList is created?
public Optional<Warp> getExactMatch() {
    // only one warp contains the filter sequence (case insensitive)
    if (matchingWarps.size() <= 1) {
        return IterableUtils.getFirst(matchingWarps);
    }

    // filter for warps that have the exact name (case insensitive)
    List<Warp> sameNameWarps = new ArrayList<Warp>();
    for (Warp warp : matchingWarps) {
        if (StringUtils.equalsIgnoreCase(warp.getName(), filter)) {
            sameNameWarps.add(warp);
        }
    }
    if (sameNameWarps.size() <= 1) {
        return IterableUtils.getFirst(sameNameWarps);
    }

    // filter for warps that have the exact name (case sensitive)
    List<Warp> sameCaseNameWarps = new ArrayList<Warp>();
    for (Warp warp : sameNameWarps) {
        if (warp.getName().equals(filter)) {
            sameCaseNameWarps.add(warp);
        }
    }
    return IterableUtils.getFirst(sameCaseNameWarps);
}

From source file:de.hybris.platform.b2bpunchoutaddon.services.impl.DefaultPunchOutUserAuthenticationService.java

/**
 * Select page that user will be redirected in seamless login, depending on the selected operation.
 * /*from w  ww  .  j  a  v  a2s.  co  m*/
 * @param punchOutSession
 * @param request
 */
private void selectRedirectPage(final PunchOutSession punchOutSession, final HttpServletRequest request) {
    final Configuration configuration = configurationService.getConfiguration();
    final String operation = punchOutSession.getOperation();

    if (StringUtils.equalsIgnoreCase(operation, PunchOutSetupOperation.CREATE.toString())) {
        request.setAttribute(B2bpunchoutaddonConstants.SEAMLESS_PAGE,
                configuration.getString("b2bpunchoutaddon.redirect.create"));
    } else if (StringUtils.equalsIgnoreCase(operation, PunchOutSetupOperation.EDIT.toString())) {
        request.setAttribute(B2bpunchoutaddonConstants.SEAMLESS_PAGE,
                configuration.getString("b2bpunchoutaddon.redirect.edit"));
    } else if (StringUtils.equalsIgnoreCase(operation, PunchOutSetupOperation.INSPECT.toString())) {
        request.setAttribute(B2bpunchoutaddonConstants.SEAMLESS_PAGE,
                configuration.getString("b2bpunchoutaddon.redirect.inspect"));
    }
}

From source file:com.mirth.connect.server.util.SMTPConnection.java

public void send(String toList, String ccList, String from, String subject, String body) throws EmailException {
    Email email = new SimpleEmail();
    email.setHostName(host);//from w ww. jav  a 2 s.co  m
    email.setSmtpPort(Integer.parseInt(port));
    email.setSocketConnectionTimeout(socketTimeout);
    email.setDebug(true);

    if (useAuthentication) {
        email.setAuthentication(username, password);
    }

    if (StringUtils.equalsIgnoreCase(secure, "TLS")) {
        email.setTLS(true);
    } else if (StringUtils.equalsIgnoreCase(secure, "SSL")) {
        email.setSSL(true);
    }

    for (String to : StringUtils.split(toList, ",")) {
        email.addTo(to);
    }

    if (StringUtils.isNotEmpty(ccList)) {
        for (String cc : StringUtils.split(ccList, ",")) {
            email.addCc(cc);
        }
    }

    email.setFrom(from);
    email.setSubject(subject);
    email.setMsg(body);
    email.send();
}

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

@Override
protected Navigation run() throws Exception {
    Map<String, String> licenseState = Utils.getLicenseState(domain);
    boolean notLicensed = StringUtils.equalsIgnoreCase(licenseState.get("state"), "ACTIVE") == false
            || StringUtils.equalsIgnoreCase(licenseState.get("enabled"), "true") == false;
    if (notLicensed) {
        Utils.responseRefresh(response, Configuration.get().getMarketplaceAppId(),
                "not licensed(or not enabled).");
        return null;
    }//w  ww  .  j a  v  a2 s.  co  m
    Key appsUserKey = Utils.createAppsUserKey(currentUser);
    Entity appsUser = Datastore.getOrNull(appsUserKey);
    if (appsUser == null) {
        appsUser = new Entity(appsUserKey);
        appsUser.setProperty("email", currentUser.getEmail());
        appsUser.setProperty("createdAt", new Date());
    }
    appsUser.setProperty("updatedAt", new Date());
    Datastore.put(appsUser);

    response.setContentType("text/html");
    response.setCharacterEncoding("utf-8");
    PrintWriter w = response.getWriter();
    w.println("<html><head><title>appengine-gdata-example</title></head><body>");
    w.println("<h1>appengine-gdata-example</h1>");
    w.println("<p>from universal navigation</p>");
    w.println(
            "<p><a target=\"_blank\" href=\"http://github.com/shin1ogawa/appengine-marketplace-example/blob/master/src/main/java/com/shin1ogawa/appengine/marketplace/controller/TopPageController.java\">");
    w.println("source code</a></p>");
    w.println(Utils.getHtmlForDebug(request));
    w.println("</body></html>");
    response.flushBuffer();
    return null;
}

From source file:hudson.plugins.clearcase.history.FieldFilter.java

public boolean accept(String value) {
    switch (type) {
    case Equals:// w ww.  j  ava2s  . c om
        return StringUtils.equals(value, patternText);
    case EqualsIgnoreCase:
        return StringUtils.equalsIgnoreCase(value, patternText);
    case NotEquals:
        return !StringUtils.equals(value, patternText);
    case NotEqualsIgnoreCase:
        return !StringUtils.equalsIgnoreCase(value, patternText);
    case StartsWith:
        return value != null && value.startsWith(patternText);
    case StartsWithIgnoreCase:
        return value != null && value.toLowerCase().startsWith(patternText);
    case EndsWith:
        return value != null && value.endsWith(patternText);
    case EndsWithIgnoreCase:
        return value != null && value.toLowerCase().endsWith(patternText);
    case Contains:
        return StringUtils.contains(value, patternText);
    case ContainsIgnoreCase:
        return StringUtils.contains(StringUtils.lowerCase(value), patternText);
    case DoesNotContain:
        return !StringUtils.contains(value, patternText);
    case DoesNotContainIgnoreCase:
        LOGGER.fine(StringUtils.lowerCase(value) + " <>" + patternText);
        return !StringUtils.contains(StringUtils.lowerCase(value), patternText);
    case ContainsRegxp:
        Matcher m = pattern.matcher(StringUtils.defaultString(value));
        return m.find();
    case DoesNotContainRegxp:
        Matcher m2 = pattern.matcher(StringUtils.defaultString(value));
        return !m2.find();
    }
    return true;
}

From source file:broadwick.graph.Edge.java

/**
 * Obtain an attribute of this edge by the attributes name.
 * @param attributeName the name of the attribute to be found.
 * @return the attribute (or null if no attribute matches the name).
 *//*w w w .  j a v a2s .c  o  m*/
public final EdgeAttribute getAttributeByName(final String attributeName) {
    for (EdgeAttribute attr : attributes) {
        if (StringUtils.equalsIgnoreCase(attributeName, attr.getName())) {
            return attr;
        }
    }
    return null;
}

From source file:info.magnolia.rendering.template.configured.ConfiguredInheritance.java

@Override
public Boolean isInheritsProperties() {
    return isEnabled() != null && isEnabled()
            && StringUtils.equalsIgnoreCase(StringUtils.trim(properties), PROPERTIES_ALL);
}