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.burlov.amazon.s3.dirsync.DirSync.java

public DirSync(String accessKey, String secretKey, String bucket, String location, char[] encPassword)
        throws DirSyncException {
    super();// w ww .  j a  va  2  s.  com
    try {
        shaDigest = MessageDigest.getInstance("SHA-1");
        md5Digest = MessageDigest.getInstance("MD5");
    } catch (NoSuchAlgorithmException e) {
        throw new DirSyncException(e.getMessage());
    }
    this.accessKey = accessKey;
    this.secretKey = secretKey;
    if (encPassword == null) {
        throw new IllegalArgumentException("encryption password is null");
    }
    this.bucket = bucket;
    this.location = location;
    if (StringUtils.equalsIgnoreCase(location, S3Bucket.LOCATION_EUROPE)) {
        this.location = S3Bucket.LOCATION_EUROPE;
    } else {
        this.location = null;
    }
    if (StringUtils.isBlank(this.bucket)) {
        this.bucket = accessKey + ".dirsync";
    }
    cipher = new SerpentEngine();
    pbeKey = generatePbeKey(encPassword);
    try {
        s3Service = new RestS3Service(new AWSCredentials(accessKey, secretKey));
    } catch (S3ServiceException e1) {
        throw new DirSyncException("Connecting to S3 service failed", e1);
    }
}

From source file:com.hangum.tadpole.rdb.core.editors.main.composite.plandetail.OraclePlanComposite.java

/**
 * ? F4  ???  ?? ? ? .//ww w .  jav a  2 s  .  c om
 * @param selElement
 */
private void openInformationDialog(OraclePlanDAO selElement) {
    if (StringUtils.equalsIgnoreCase("TABLE", selElement.getObjectType())) {

        TableDAO tableDao = new TableDAO();

        String temp = selElement.getName();
        String object[] = StringUtils.split(temp, '.');

        if (object.length > 1) {
            tableDao.setSchema_name(object[0]);

            String obj = object[1];
            String tbl[] = StringUtils.split(obj, '(');
            if (tbl.length > 1) {
                tableDao.setSysName(tbl[0]);
                tableDao.setTable_name(tbl[0]);
            } else {
                tableDao.setSysName(obj);
                tableDao.setTable_name(obj);
            }
        } else {
            tableDao.setSysName(temp);
            tableDao.setTable_name(temp);
        }

        new TableInformationDialog(getShell(), false, getRsDAO().getUserDB(), tableDao).open();
    } else if (StringUtils.startsWithIgnoreCase(selElement.getObjectType(), "INDEX")) {

        InformationSchemaDAO indexDao = new InformationSchemaDAO();

        String temp = selElement.getName();
        String object[] = StringUtils.split(temp, '.');

        if (object.length > 1) {
            indexDao.setTABLE_SCHEMA(object[0]);

            String obj = object[1];
            String tbl[] = StringUtils.split(obj, '(');
            if (tbl.length > 1) {
                indexDao.setINDEX_NAME(tbl[0]);
            } else {
                indexDao.setINDEX_NAME(obj);
            }
        } else {
            indexDao.setINDEX_NAME(temp);
        }

        new IndexInformationDialog(getShell(), false, getRsDAO().getUserDB(), indexDao).open();
    }
}

From source file:com.sfs.whichdoctor.beans.AgedDebtorsAnalysisBean.java

/**
 * Gets the group name.//from   ww w .ja  v a 2 s. c o  m
 *
 * @param guid the guid
 * @return the group name
 */
public final String getGroupName(final int guid) {

    String groupName = "";

    if (StringUtils.isNotBlank(this.getGroupBy())) {
        if (this.getPeople().containsKey(guid)) {
            PersonBean person = this.getPerson(guid);

            if (person != null) {
                groupName = person.getMembershipField("Membership Type");

                if (StringUtils.equalsIgnoreCase(this.groupBy, "Division")) {
                    groupName = person.getMembershipField("Division");
                }
                if (StringUtils.equalsIgnoreCase(this.groupBy, "Status")) {
                    groupName = person.getMembershipField("Status");
                }
                if (StringUtils.equalsIgnoreCase(this.groupBy, "Region")) {
                    groupName = person.getRegion();
                }
            }
        }
        if (this.getOrganisations().containsKey(guid)) {
            groupName = "Organisations";
        }
    }
    return groupName;
}

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

/**
 * Determine if the User is member of a project
 *
 * @param aProject the project.//from www . j a v  a2s .c  o m
 * @param aProjectRepository the respository service.
 * @param aUser the user.
 * @return if the user is a member.
 */
public static boolean isMember(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 user = false;
    if (!roleAdmin) {

        try {
            List<ProjectPermission> permissionLevels = aProjectRepository.listProjectPermisionLevel(aUser,
                    aProject);
            for (ProjectPermission permissionLevel : permissionLevels) {
                if (StringUtils.equalsIgnoreCase(permissionLevel.getLevel().getName(),
                        PermissionLevel.USER.getName())) {
                    user = true;
                    break;
                }
            }
        }

        catch (NoResultException ex) {
            LOG.info("No permision is given to this user " + ex);
        }
    }

    return (user || roleAdmin);
}

From source file:com.baoqilai.core.util.WebUtils.java

/**
 * ?contentTypeheaders.//from w w  w .j a  va2 s .  co  m
 */
private static HttpServletResponse initResponseHeader(final String contentType, final String... headers) {
    // ?headers?
    String encoding = DEFAULT_ENCODING;
    boolean noCache = DEFAULT_NOCACHE;
    for (String header : headers) {
        String headerName = StringUtils.substringBefore(header, ":");
        String headerValue = StringUtils.substringAfter(header, ":");

        if (StringUtils.equalsIgnoreCase(headerName, HEADER_ENCODING)) {
            encoding = headerValue;
        } else if (StringUtils.equalsIgnoreCase(headerName, HEADER_NOCACHE)) {
            noCache = Boolean.parseBoolean(headerValue);
        } else {
            throw new IllegalArgumentException(headerName + "??header");
        }
    }

    HttpServletResponse response = ServletActionContext.getResponse();

    // headers?
    String fullContentType = contentType + ";charset=" + encoding;
    response.setContentType(fullContentType);
    if (noCache) {
        setDisableCacheHeader(response);
    }

    return response;
}

From source file:hydrograph.ui.validators.impl.XPathSchemaGridValidationRule.java

private boolean validateSchema(Schema schema, String propertyName) {
    List<GridRow> gridRowList = (List<GridRow>) schema.getGridRow();
    int precision = 0, scale = 0;

    /*this list is used for checking duplicate names in the grid*/
    List<String> uniqueNamesList = new ArrayList<>();

    if (gridRowList == null || gridRowList.isEmpty()) {
        errorMessage = propertyName + " is mandatory";
        return false;
    }//from   w ww  . j a  va2  s.c  o m
    Set<String> xPathDulicateCheck = new HashSet<String>();
    for (GridRow gridRow : gridRowList) {
        if (StringUtils.isBlank(gridRow.getFieldName())) {
            errorMessage = "Field name can not be blank";
            return false;
        }

        XPathGridRow xPathGridRow = (XPathGridRow) gridRow;
        if (StringUtils.isBlank(xPathGridRow.getXPath())) {
            errorMessage = "Absolute/Relative Xpath can not be blank";
            return false;
        }
        if (!xPathDulicateCheck.add(xPathGridRow.getAbsolutexPath())) {
            errorMessage = "Absolute/Relative Xpath can not be duplicate";
            return false;
        }
        if (StringUtils.isNotBlank(gridRow.getScale())) {
            try {
                if (StringUtils.isNotEmpty(gridRow.getPrecision())) {
                    precision = Integer.parseInt(gridRow.getPrecision());
                }
            } catch (NumberFormatException exception) {
                logger.debug("Failed to parse the precision ", exception);
                return false;
            }

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

        if (DATA_TYPE_BIG_DECIMAL.equalsIgnoreCase(gridRow.getDataTypeValue())) {
            if (StringUtils.isBlank(gridRow.getScale()) || scale < 0
                    || !(gridRow.getScale().matches(REGULAR_EXPRESSION_FOR_NUMBER))) {
                errorMessage = "Scale should be positive integer.";
                return false;
            }
            try {
                Integer.parseInt(gridRow.getScale());
            } catch (NumberFormatException exception) {
                logger.debug("Failed to parse the scale", exception);
                errorMessage = "Scale must be integer value";
                return false;
            }
        } else if (DATA_TYPE_DATE.equalsIgnoreCase(gridRow.getDataTypeValue())
                && StringUtils.isBlank(gridRow.getDateFormat())) {
            errorMessage = "Date format is mandatory";
            return false;
        }

        if (StringUtils.equalsIgnoreCase(DATA_TYPE_BIG_DECIMAL, gridRow.getDataTypeValue())
                && (StringUtils.isBlank(gridRow.getScaleTypeValue())
                        || StringUtils.equalsIgnoreCase(SCALE_TYPE_NONE, gridRow.getScaleTypeValue()))) {
            errorMessage = "Scale type cannot be blank or none for Big Decimal data type";
            return false;
        }

        if (uniqueNamesList.isEmpty() || !uniqueNamesList.contains(gridRow.getFieldName())) {
            uniqueNamesList.add(gridRow.getFieldName());
        } else {
            errorMessage = "Schema grid must have unique names";
            return false;
        }
    }
    return true;
}

From source file:hydrograph.ui.validators.impl.SchemaGridValidationRule.java

private boolean validateSchema(Schema schema, String propertyName) {
    List<GridRow> gridRowList = (List<GridRow>) schema.getGridRow();
    int precision = 0, scale = 0;

    /*this list is used for checking duplicate names in the grid*/
    List<String> uniqueNamesList = new ArrayList<>();
    boolean fixedWidthGrid = false;
    boolean generateRecordSchemaGrid = false;

    if (gridRowList == null || gridRowList.isEmpty()) {
        errorMessage = propertyName + " is mandatory";
        return false;
    }/*from   www . j  a  v  a  2 s  . c  o  m*/

    GridRow gridRowTest = gridRowList.iterator().next();

    if (gridRowTest instanceof GenerateRecordSchemaGridRow) {
        generateRecordSchemaGrid = true;
    }
    if (gridRowTest instanceof FixedWidthGridRow) {
        fixedWidthGrid = true;
    }

    for (GridRow gridRow : gridRowList) {
        if (StringUtils.isBlank(gridRow.getFieldName())) {
            errorMessage = "Field name can not be blank";
            return false;
        }

        if (!gridRow.getFieldName().matches(Constants.REGEX)) {
            errorMessage = "Only Underscore and Alphanumeric characters are allowed Ex.jKh_78.";
            return false;
        }
        if (StringUtils.isNotBlank(gridRow.getScale())) {
            try {
                if (StringUtils.isNotEmpty(gridRow.getPrecision())) {
                    precision = Integer.parseInt(gridRow.getPrecision());
                }
            } catch (NumberFormatException exception) {
                logger.debug("Failed to parse the precision ", exception);
                return false;
            }

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

        if (DATA_TYPE_BIG_DECIMAL.equalsIgnoreCase(gridRow.getDataTypeValue())) {
            if (StringUtils.isBlank(gridRow.getScale()) || scale < 0
                    || !(gridRow.getScale().matches(REGULAR_EXPRESSION_FOR_NUMBER))) {
                errorMessage = "Scale should be positive integer.";
                return false;
            }
            try {
                Integer.parseInt(gridRow.getScale());
            } catch (NumberFormatException exception) {
                logger.debug("Failed to parse the scale", exception);
                errorMessage = "Scale must be integer value";
                return false;
            }
        } else if (DATA_TYPE_DATE.equalsIgnoreCase(gridRow.getDataTypeValue())
                && StringUtils.isBlank(gridRow.getDateFormat())) {
            errorMessage = "Date format is mandatory";
            return false;
        }

        if (StringUtils.equalsIgnoreCase(DATA_TYPE_BIG_DECIMAL, gridRow.getDataTypeValue())
                && ((gridRow.getScaleType() == null)
                        || StringUtils.equalsIgnoreCase(gridRow.getScaleTypeValue(), SCALE_TYPE_NONE))) {
            errorMessage = "Scale type cannot be blank or none for Big Decimal data type";
            return false;
        }

        if (fixedWidthGrid && (!generateRecordSchemaGrid)) {
            FixedWidthGridRow fixedWidthGridRow = (FixedWidthGridRow) gridRow;
            if (StringUtils.isBlank(fixedWidthGridRow.getLength())) {
                logger.debug("Length is mandatory for FixedWidthComponent");
                return false;
            } else if (!(fixedWidthGridRow.getLength().matches(REGULAR_EXPRESSION_FOR_NUMBER))
                    || (fixedWidthGridRow.getLength().equals("0"))) {
                logger.debug("Length should be a positive Integer greater than 0");
                return false;
            }
        }
        if (uniqueNamesList.isEmpty() || !uniqueNamesList.contains(gridRow.getFieldName())) {
            uniqueNamesList.add(gridRow.getFieldName());
        } else {
            errorMessage = "Schema grid must have unique names";
            return false;
        }
    }
    return true;
}

From source file:com.baifendian.swordfish.common.storm.StormRestUtil.java

/**
 * kill /*from  w  w  w  .  j  av a 2s  .co  m*/
 */
public static void topologyKill(String topologyId, long waitTime) throws Exception {
    String res = Request.Post(getTopologyKillUrl(topologyId, waitTime)).execute().returnContent().toString();

    TopologyOperationDto topologyOperation = JsonUtil.parseObject(res, TopologyOperationDto.class);

    if (topologyOperation == null) {
        throw new Exception("kill not result return!");
    }

    if (!StringUtils.equalsIgnoreCase(topologyOperation.getStatus(), "success")) {
        String msg = MessageFormat.format("Kill status not equal success: {0}", topologyOperation.getStatus());
        throw new Exception(msg);
    }
}

From source file:com.fengduo.bee.web.controller.account.LoginController.java

/**
 * ?/*from  w w  w  .j  a v a  2  s .  c o  m*/
 * 
 * @param userName
 * @param model
 * @return
 */
@RequestMapping(value = "/login", method = RequestMethod.POST)
public String fail(@RequestParam(FormAuthenticationFilter.DEFAULT_USERNAME_PARAM) String userName,
        HttpServletRequest req, Model model) {
    String exceptionClassName = (String) req.getAttribute("shiroLoginFailure");
    String error = null;
    if (UnknownAccountException.class.getName().equals(exceptionClassName)) {
        error = ",!";
    } else if (IncorrectCredentialsException.class.getName().equals(exceptionClassName)) {
        error = "??/??!";
    } else if (CaptchaInvalidException.class.getName().equals(exceptionClassName)) {
        error = "???,??!";
    } else if (CaptchaException.class.getName().equals(exceptionClassName)) {
        error = "??!";
    } else if (AccountException.class.getName().equals(exceptionClassName)) {
        error = "??/?!";
    } else if (exceptionClassName != null) {
        error = "?!";
    }

    if (StringUtils.isEmpty(exceptionClassName)) {
        String code = request.getParameter("captcha");
        String phone = request.getParameter("username");
        String pwd = request.getParameter("password");
        if (StringUtils.equalsIgnoreCase(code,
                (String) session.getAttribute(ValidateCodeServlet.VALIDATE_CODE))) {
            updateShiroUser(phone, pwd);
            return "redirect:/user/setting";
        } else {
            error = "??!";
        }
    }
    model.addAttribute("errMsg", error);
    // ajax
    if (InvokeTypeTools.isAjax(req)) {
        response.setContentType("application/json");
        PrintWriter writer = null;
        try {
            writer = response.getWriter();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        writer.print(JsonResultUtils.createJsonResult(ResultCode.ERROR, "", error));
        writer.flush();
        writer.close();
    }
    return "account/login";
}

From source file:com.sfs.dao.SAMLAuthenticationDAOImpl.java

/**
 * Load user details.// w  w w. j  a v  a  2  s.c  o m
 *
 * @param username the username
 * @param attributes the attributes
 * @return the user bean
 */
private UserBean loadUserDetails(final String username, final Map<?, ?> attributes) {

    final UserBean user = new UserBean();

    user.setUserName(username);

    Iterator<?> attributeNames = attributes.keySet().iterator();

    for (; attributeNames.hasNext();) {
        final String attribute = (String) attributeNames.next();
        final Object value = attributes.get(attribute);

        if (value != null) {
            dataLogger.debug("Attribute: " + attribute);
            dataLogger.debug("Type: " + value.getClass());
            dataLogger.debug("Value: " + value);

            if (StringUtils.equalsIgnoreCase(attribute, dnAttr)) {
                user.setDN(getStringValue(value));
            }

            if (StringUtils.equalsIgnoreCase(attribute, firstNameAttr)) {
                user.setPreferredName(getStringValue(value));
            }

            if (StringUtils.equalsIgnoreCase(attribute, lastNameAttr)) {
                user.setLastName(getStringValue(value));
            }

            if (StringUtils.equalsIgnoreCase(attribute, emailAddressAttr)) {
                user.setEmail(getStringValue(value));
            }

            if (StringUtils.equalsIgnoreCase(attribute, groupMembershipAttr)) {

                ArrayList<String> roleDNs = new ArrayList<String>();

                if (value instanceof String) {
                    roleDNs.add((String) value);
                }
                if (value instanceof ArrayList<?>) {
                    ArrayList<?> values = (ArrayList<?>) value;
                    for (int i = 0; i < values.size(); i++) {
                        roleDNs.add((String) values.get(i));
                    }
                }

                final Collection<String> roles = new ArrayList<String>();
                for (String role : roleDNs) {
                    // See which valid roles this user has
                    dataLogger.debug("Role: " + role);

                    final int fApos = role.indexOf(",");
                    final String groupType = role.substring(fApos + 1);

                    dataLogger.debug("Group type: " + groupType);

                    if (StringUtils.equalsIgnoreCase(groupType, this.groupContainer)) {
                        final int startOfGroup = role.indexOf("=");
                        final String group = role.substring(startOfGroup + 1, fApos);

                        dataLogger.debug("Group name: " + group);

                        // Get the group mapping
                        if (StringUtils.isNotBlank(group) && this.groupMapping.containsKey(group)) {
                            String whichdoctorGroup = this.groupMapping.get(group);
                            if (StringUtils.isNotBlank(whichdoctorGroup)) {
                                roles.add(whichdoctorGroup);
                            }
                        }
                    }
                }
                user.setMemberOf(roles);
            }
        }
    }

    dataLogger.debug("User DN: " + user.getDN());
    dataLogger.debug("Role count: " + user.getMemberOf().size());

    if (StringUtils.isNotBlank(user.getDN()) && user.getMemberOf().size() > 0) {
        // The user has a DN and belongs to one valid role, log in
        dataLogger.debug("User has at least one valid role - logged in");
        user.setLoggedIn(true);
    }

    return user;
}