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

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

Introduction

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

Prototype

public static boolean containsIgnoreCase(final CharSequence str, final CharSequence searchStr) 

Source Link

Document

Checks if CharSequence contains a search CharSequence irrespective of case, handling null .

Usage

From source file:com.glaf.oa.borrow.web.springmvc.BorrowController.java

@RequestMapping("/edit")
public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) {
    RequestUtils.setRequestParameterToAttribute(request);
    request.removeAttribute("canSubmit");

    Borrow borrow = borrowService.getBorrow(RequestUtils.getLong(request, "borrowid"));
    if (borrow != null) {
        request.setAttribute("borrow", borrow);
        JSONObject rowJSON = borrow.toJsonObject();
        request.setAttribute("x_json", rowJSON.toJSONString());
    }//from w  w  w .  j a  v  a2s  .c o  m

    boolean canUpdate = false;
    String x_method = request.getParameter("x_method");
    if (StringUtils.equals(x_method, "submit")) {

    }

    if (StringUtils.containsIgnoreCase(x_method, "update")) {
        if (borrow != null) {
            if (borrow.getStatus() == 0 || borrow.getStatus() == -1) {
                canUpdate = true;
            }
        }
    }

    request.setAttribute("canUpdate", canUpdate);

    String view = request.getParameter("view");
    if (StringUtils.isNotEmpty(view)) {
        return new ModelAndView(view, modelMap);
    }

    String x_view = ViewProperties.getString("borrow.edit");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/oa/borrow/edit", modelMap);
}

From source file:com.glaf.oa.purchase.web.springmvc.PurchaseController.java

@RequestMapping("/edit")
public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) {
    User user = RequestUtils.getUser(request);
    String actorId = user.getActorId();
    RequestUtils.setRequestParameterToAttribute(request);
    request.removeAttribute("canSubmit");
    Purchase purchase = purchaseService.getPurchase(RequestUtils.getLong(request, "purchaseId"));
    if (purchase == null) {
        purchase = new Purchase();
        purchase.setStatus(-1);// 
        SysDepartment sysDepartment = BaseDataManager.getInstance().getSysDepartmentService()
                .findById(user.getDeptId());
        String areaCode = "";
        if (sysDepartment.getCode() != null && sysDepartment.getCode().length() >= 2) {
            areaCode = sysDepartment.getCode().substring(0, 2);
        }/* w w  w  .j a va  2  s.c om*/
        purchase.setArea(areaCode);// 
        purchase.setDept(sysDepartment.getCode());// 
        purchase.setPost(RequestUtil.getLoginUser(request).getHeadship());// ??
        purchase.setAppuser(actorId);
        purchase.setAppdate(new Date());
        purchase.setCreateBy(actorId);
        purchaseService.save(purchase);
    }
    request.setAttribute("purchase", purchase);
    JSONObject rowJSON = purchase.toJsonObject();
    request.setAttribute("x_json", rowJSON.toJSONString());

    boolean canUpdate = false;
    String x_method = request.getParameter("x_method");
    if (StringUtils.equals(x_method, "submit")) {

    }

    if (StringUtils.containsIgnoreCase(x_method, "update")) {
        if (purchase != null) {
            if (purchase.getStatus() == 0 || purchase.getStatus() == -1) {
                canUpdate = true;
            }
        }
    }

    request.setAttribute("canUpdate", canUpdate);

    String view = request.getParameter("view");
    if (StringUtils.isNotEmpty(view)) {
        return new ModelAndView(view, modelMap);
    }

    String x_view = ViewProperties.getString("purchase.edit");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/oa/purchase/edit", modelMap);
}

From source file:com.erudika.scoold.core.Profile.java

public boolean hasBadge(Badge b) {
    return StringUtils.containsIgnoreCase(badges, ",".concat(b.toString()).concat(","));
}

From source file:javax.portlet.tck.portlets.HeaderPortletTests_SPEC14_HeaderReq.java

@Override
public void renderHeaders(HeaderRequest headerRequest, HeaderResponse headerResponse)
        throws PortletException, IOException {

    StringWriter writer = new StringWriter();

    ModuleTestCaseDetails tcd = new ModuleTestCaseDetails();

    /* TestCase: V3HeaderPortletTests_SPEC14_HeaderReq_contentType1 */
    /*//from   w  w  w.  j av a 2 s.  c  o m
     * Details: "The getResponseContentType method returns a String
     * representing the default content type the portlet container assumes for
     * the output"
     */
    {
        TestResult result = tcd.getTestResultFailed(V3HEADERPORTLETTESTS_SPEC14_HEADERREQ_CONTENTTYPE1);
        if (headerRequest.getResponseContentType() != null && !headerRequest.getResponseContentType().isEmpty())
            result.setTcSuccess(true);
        result.writeTo(writer);
    }

    /* TestCase: V3HeaderPortletTests_SPEC14_HeaderReq_contentType2 */
    /*
     * Details: "The getResponseContentTypes method returns an Enumeration of
     * String elements representing the acceptable content types for the
     * output
     */
    /* in order of preference" */
    {
        TestResult result = tcd.getTestResultFailed(V3HEADERPORTLETTESTS_SPEC14_HEADERREQ_CONTENTTYPE2);
        Enumeration<String> contentTypesTr1 = headerRequest.getResponseContentTypes();
        if (contentTypesTr1 != null && contentTypesTr1.hasMoreElements()
                && !contentTypesTr1.nextElement().isEmpty())
            result.setTcSuccess(true);
        result.writeTo(writer);
    }

    /* TestCase: V3HeaderPortletTests_SPEC14_HeaderReq_contentType3 */
    /* Details: "The first element of the Enumeration returned by the */
    /* getResponseContentTypes method must equal the value returned by the */
    /* getResponseContentType method" */
    {
        TestResult result = tcd.getTestResultFailed(V3HEADERPORTLETTESTS_SPEC14_HEADERREQ_CONTENTTYPE3);
        if (headerRequest.getResponseContentTypes().nextElement()
                .equals(headerRequest.getResponseContentType()))
            result.setTcSuccess(true);
        result.writeTo(writer);
    }

    /* TestCase: V3HeaderPortletTests_SPEC14_HeaderReq_contentType4 */
    /* Details: "If a portlet defines support for all content types using a */
    /* wildcard and the portlet container supports all content types, the */
    /* getResponseContentType may return the wildcard" */
    {
        TestResult result = tcd.getTestResultFailed(V3HEADERPORTLETTESTS_SPEC14_HEADERREQ_CONTENTTYPE4);
        result.appendTcDetail("Cannot really test this. ");
        if (headerRequest.getResponseContentType().equals("text/html")) {
            result.setTcSuccess(true);
        } else {
            result.appendTcDetail("Content type is " + headerRequest.getResponseContentType());
        }
        result.writeTo(writer);
    }

    /* TestCase: V3HeaderPortletTests_SPEC14_HeaderReq_contentType5 */
    /* Details: "If a portlet defines support for all content types using a */
    /* wildcard and the portlet container supports all content types, the */
    /* getResponseContentType may return the preferred content type" */
    {
        TestResult result = tcd.getTestResultFailed(V3HEADERPORTLETTESTS_SPEC14_HEADERREQ_CONTENTTYPE5);
        if (headerRequest.getResponseContentType().equals("text/html")) {
            result.setTcSuccess(true);
        } else {
            result.appendTcDetail("Content type is " + headerRequest.getResponseContentType());
        }
        result.writeTo(writer);
    }

    /* TestCase: V3HeaderPortletTests_SPEC14_HeaderReq_windowId1 */
    /*
     * Details: "The getWindowID method returns a String representing the
     * current window ID"
     */
    {
        TestResult result = tcd.getTestResultFailed(V3HEADERPORTLETTESTS_SPEC14_HEADERREQ_WINDOWID1);
        String windowId = headerRequest.getWindowID();
        if (windowId != null) {
            result.setTcSuccess(true);
            result.appendTcDetail("Window ID is " + windowId);
        } else {
            result.appendTcDetail("Failed because windowID is null");
        }
        result.writeTo(writer);
    }

    /* TestCase: V3HeaderPortletTests_SPEC14_HeaderReq_windowId4 */
    /*
     * Details: "The string returned by getWindowID method must be the same ID
     * used for scoping portlet-scope session attributes"
     */
    {
        TestResult result = tcd.getTestResultFailed(V3HEADERPORTLETTESTS_SPEC14_HEADERREQ_WINDOWID4);
        headerRequest.getPortletSession().setAttribute("tr5", headerRequest.getWindowID(), PORTLET_SCOPE);
        String tr5SessionAttribute = (String) headerRequest.getPortletSession()
                .getAttribute("javax.portlet.p." + headerRequest.getWindowID() + "?tr5", APPLICATION_SCOPE);
        if (tr5SessionAttribute != null && tr5SessionAttribute.equals(headerRequest.getWindowID())) {
            result.setTcSuccess(true);
        } else {
            result.appendTcDetail(
                    "Couldn't find javax.portlet.p." + headerRequest.getWindowID() + ".tr5 attribute");
        }
        result.writeTo(writer);
    }

    /* TestCase: V3HeaderPortletTests_SPEC14_HeaderReq_contentType10 */
    /*
     * Details: "Within the header method, the content type must include only
     * the MIME type, not the character set"
     */
    {
        TestResult result = tcd.getTestResultFailed(V3HEADERPORTLETTESTS_SPEC14_HEADERREQ_CONTENTTYPE10);
        if (!StringUtils.containsIgnoreCase(headerRequest.getResponseContentType(),
                headerResponse.getCharacterEncoding()))
            result.setTcSuccess(true);
        result.writeTo(writer);
    }

    /* TestCase: V3HeaderPortletTests_SPEC14_HeaderReq_contentType11 */
    /*
     * Details: "Within the header method, the getResponseContentTypes method
     * must return only the content types supported by the current portlet
     * mode"
     */
    {
        TestResult result = tcd.getTestResultFailed(V3HEADERPORTLETTESTS_SPEC14_HEADERREQ_CONTENTTYPE11);
        Enumeration<String> contentTypesTr7 = headerRequest.getResponseContentTypes();
        if (contentTypesTr7.nextElement().equals("text/html") && !contentTypesTr7.hasMoreElements())
            result.setTcSuccess(true);
        result.writeTo(writer);
    }

    /* TestCase: V3HeaderPortletTests_SPEC14_HeaderReq_contentType13 */
    /* Details: "The character set of the response can be retrieved via the */
    /* HeaderResponse.getCharacterEncoding method" */
    {
        TestResult result = tcd.getTestResultFailed(V3HEADERPORTLETTESTS_SPEC14_HEADERREQ_CONTENTTYPE13);
        if (headerResponse.getCharacterEncoding() != null) {
            result.setTcSuccess(true);
        } else {
            result.appendTcDetail("Character Encoding is null");
        }
        result.writeTo(writer);
    }

    headerRequest.setAttribute(RESULT_ATTR_PREFIX + "HeaderPortletTests_SPEC14_HeaderReq", writer.toString());
}

From source file:com.glaf.cms.info.web.springmvc.PublicInfoMgmtController.java

@RequestMapping("/edit")
public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) {
    User user = RequestUtils.getUser(request);
    String actorId = user.getActorId();
    RequestUtils.setRequestParameterToAttribute(request);
    request.removeAttribute("canSubmit");

    String serviceKey = request.getParameter("serviceKey");
    Long nodeId = RequestUtils.getLong(request, "nodeId");

    PublicInfo publicInfo = publicInfoService.getPublicInfo(request.getParameter("id"));

    if (publicInfo != null) {
        request.setAttribute("publicInfo", publicInfo);
        JSONObject rowJSON = publicInfo.toJsonObject();
        request.setAttribute("x_json", rowJSON.toJSONString());
        serviceKey = publicInfo.getServiceKey();
        nodeId = publicInfo.getNodeId();
    }//ww w  .ja  v a2  s.c om

    if (StringUtils.isNotEmpty(serviceKey)) {
        TreeModel treeModel = treeModelService.getTreeModelByCode(serviceKey);
        request.setAttribute("treeModel", treeModel);
    }

    if (nodeId > 0) {
        TreeModel treeModel = treeModelService.getTreeModel(nodeId);
        request.setAttribute("treeModel", treeModel);
    }

    boolean canUpdate = false;
    boolean canSubmit = false;
    String x_method = request.getParameter("x_method");
    if (StringUtils.equals(x_method, "submit")) {
        if (publicInfo != null && publicInfo.getProcessInstanceId() != null) {
            ProcessContainer container = ProcessContainer.getContainer();
            Collection<Long> processInstanceIds = container.getRunningProcessInstanceIds(actorId);
            if (processInstanceIds.contains(publicInfo.getProcessInstanceId())) {
                canSubmit = true;
            }
            if (publicInfo.getStatus() == 0 || publicInfo.getStatus() == -1) {
                canUpdate = true;
            }
            TaskItem taskItem = container.getMinTaskItem(actorId, publicInfo.getProcessInstanceId());
            if (taskItem != null) {
                request.setAttribute("taskItem", taskItem);
            }
            List<ActivityInstance> stepInstances = container
                    .getActivityInstances(publicInfo.getProcessInstanceId());
            request.setAttribute("stepInstances", stepInstances);
            request.setAttribute("stateInstances", stepInstances);
        } else {
            canSubmit = true;
            canUpdate = true;
        }
    }

    if (StringUtils.containsIgnoreCase(x_method, "update")) {
        if (publicInfo != null) {
            if (publicInfo.getStatus() == 0 || publicInfo.getStatus() == -1) {
                canUpdate = true;
            }
        }
    }

    if (publicInfo != null) {
        List<DataFile> dataFiles = blobService.getBlobList(publicInfo.getId());
        request.setAttribute("dataFiles", dataFiles);
    }

    request.setAttribute("canSubmit", canSubmit);
    request.setAttribute("canUpdate", canUpdate);

    String view = request.getParameter("view");
    if (StringUtils.isNotEmpty(view)) {
        return new ModelAndView(view, modelMap);
    }

    String x_view = ViewProperties.getString("publicInfo.edit");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/cms/info/edit", modelMap);
}

From source file:com.dell.asm.asmcore.asmmanager.client.devicegroup.integration.DeviceGroupServiceTest.java

/**
 * @param entityTypeSeqIdsMap/*from w  w w.ja  va 2s . c om*/
 */
private void postSetup(Map<String, List<String>> entityTypeSeqIdsMap) {

    // --------------- Delete one or more managed devices.
    Set<String> deviceRefIds = new HashSet<String>();
    deviceRefIds.addAll(entityTypeSeqIdsMap.get("DEVICES1"));
    deviceRefIds.addAll(entityTypeSeqIdsMap.get("DEVICES2"));
    if (CollectionUtils.isNotEmpty(deviceRefIds)) {
        IDeviceInventoryService proxy = TestUtil.createProxyWithTestAuth(URL, IDeviceInventoryService.class);
        for (String deviceRefId : deviceRefIds) {
            proxy.deleteDeviceInventory(deviceRefId, true);
            ManagedDevice deletedDevice = proxy.getDeviceInventory(deviceRefId);
            assertTrue("The DB should not return device",
                    DeviceState.PENDING_DELETE == deletedDevice.getState());
        }
    }

    // --------------- Delete one or more users.
    Set<String> userRefIds = new HashSet<String>();
    userRefIds.addAll(entityTypeSeqIdsMap.get("USERS1"));
    userRefIds.addAll(entityTypeSeqIdsMap.get("USERS2"));
    if (CollectionUtils.isNotEmpty(deviceRefIds)) {
        for (String userRefId : userRefIds) {
            UsersDAO.getInstance().deleteUser(Long.parseLong(userRefId));
            try {
                UsersDAO.getInstance().getUser(Long.parseLong(userRefId));
            } catch (UserManagerDAOException ue) {
                assertTrue("The DB should not return user",
                        StringUtils.containsIgnoreCase("User not found for Id: " + userRefId, ue.getMessage()));
            }
        }
    }

}

From source file:com.glaf.oa.reimbursement.web.springmvc.ReimbursementController.java

@RequestMapping("/edit")
public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) {
    User user = RequestUtils.getUser(request);
    String actorId = user.getActorId();
    RequestUtils.setRequestParameterToAttribute(request);
    request.removeAttribute("canSubmit");
    Reimbursement reimbursement = reimbursementService
            .getReimbursement(RequestUtils.getLong(request, "reimbursementid"));

    if (reimbursement == null) {
        reimbursement = new Reimbursement();
        reimbursement.setStatus(-1);// 
        SysDepartment sysDepartment = BaseDataManager.getInstance().getSysDepartmentService()
                .findById(user.getDeptId());
        String areaCode = "";
        if (sysDepartment.getCode() != null && sysDepartment.getCode().length() >= 2) {
            areaCode = sysDepartment.getCode().substring(0, 2);
        }/* w w  w.j  a v  a 2 s .  co  m*/
        reimbursement.setAppuser(actorId);
        reimbursement.setArea(areaCode);// 
        reimbursement.setDept(sysDepartment.getCode());// 
        reimbursement.setPost(RequestUtil.getLoginUser(request).getHeadship());// ??
        reimbursement.setAppdate(new Date());
        reimbursement.setCreateBy(actorId);
        reimbursementService.save(reimbursement);
    }

    if (reimbursement.getBrands1() != null && reimbursement.getBrands2() != null) {
        reimbursement.setBrand("MUL");
    }

    request.setAttribute("reimbursement", reimbursement);
    JSONObject rowJSON = reimbursement.toJsonObject();
    request.setAttribute("x_json", rowJSON.toJSONString());

    boolean canUpdate = false;
    String x_method = request.getParameter("x_method");
    if (StringUtils.equals(x_method, "submit")) {

    }

    if (StringUtils.containsIgnoreCase(x_method, "update")) {
        if (reimbursement != null) {
            if (reimbursement.getStatus() == 0 || reimbursement.getStatus() == -1) {
                canUpdate = true;
            }
        }
    }

    request.setAttribute("canUpdate", canUpdate);

    String view = request.getParameter("view");
    if (StringUtils.isNotEmpty(view)) {
        return new ModelAndView(view, modelMap);
    }

    String x_view = ViewProperties.getString("reimbursement.edit");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/oa/reimbursement/edit", modelMap);
}

From source file:com.moto.miletus.application.DeviceListAdapter.java

@Override
public Filter getFilter() {
    return new Filter() {
        @Override//from ww w. j  a  v  a2  s  . c  o m
        protected FilterResults performFiltering(final CharSequence constraint) {
            final FilterResults results = new FilterResults();
            final List<DeviceWrapper> dataSetFilter = new ArrayList<>();

            if (constraint.length() == 0) {
                dataSetFilter.addAll(getDataSetOriginal());
            } else {
                for (final DeviceWrapper device : getDataSetOriginal()) {
                    if (StringUtils.containsIgnoreCase(device.getDevice().getName(), constraint.toString())) {
                        dataSetFilter.add(device);
                    }
                }
            }

            results.values = dataSetFilter;
            results.count = dataSetFilter.size();
            return results;
        }

        @Override
        protected void publishResults(final CharSequence constraint, final FilterResults results) {
            if (results.values instanceof List) {
                getDataSetFilter().clear();
                setDataSetFilter((List<DeviceWrapper>) results.values);
                sort();
            }
        }
    };
}

From source file:com.glaf.oa.withdrawal.web.springmvc.WithdrawalController.java

@RequestMapping("/edit")
public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) {
    User user = RequestUtils.getUser(request);
    String actorId = user.getActorId();
    RequestUtils.setRequestParameterToAttribute(request);
    request.removeAttribute("canSubmit");
    Withdrawal withdrawal = withdrawalService.getWithdrawal(RequestUtils.getLong(request, "withdrawalid"));
    if (withdrawal == null) {
        withdrawal = new Withdrawal();
        withdrawal.setStatus(-1);// 
        SysDepartment sysDepartment = BaseDataManager.getInstance().getSysDepartmentService()
                .findById(user.getDeptId());
        String areaCode = "";
        if (sysDepartment.getCode() != null && sysDepartment.getCode().length() >= 2) {
            areaCode = sysDepartment.getCode().substring(0, 2);
        }/*from   www . j  a va  2s  .  c om*/
        withdrawal.setAppuser(actorId);
        withdrawal.setArea(areaCode);// 
        withdrawal.setDept(sysDepartment.getCode());// 
        withdrawal.setPost(RequestUtil.getLoginUser(request).getHeadship());// ??
        withdrawal.setAppdate(new Date());
        withdrawal.setCreateBy(actorId);
        withdrawal.setCreateDate(new Date());
        withdrawalService.save(withdrawal);
    }
    if (withdrawal != null) {
        if (withdrawal.getBrands1() != null && withdrawal.getBrands2() != null) {
            withdrawal.setBrand("MUL");
        } else if (withdrawal.getBrands1() != null && withdrawal.getBrands2() == null) {
            withdrawal.setBrand("FLL");
        } else if (withdrawal.getBrands1() == null && withdrawal.getBrands2() != null) {
            withdrawal.setBrand("MSLD");
        }
        request.setAttribute("withdrawal", withdrawal);
        JSONObject rowJSON = withdrawal.toJsonObject();
        request.setAttribute("x_json", rowJSON.toJSONString());
    }

    boolean canUpdate = false;
    String x_method = request.getParameter("x_method");
    if (StringUtils.equals(x_method, "submit")) {

    }

    if (StringUtils.containsIgnoreCase(x_method, "update")) {
        if (withdrawal != null) {
            if (withdrawal.getStatus() == 0 || withdrawal.getStatus() == -1) {
                canUpdate = true;
            }
        }
    }

    request.setAttribute("canUpdate", canUpdate);

    String view = request.getParameter("view");
    if (StringUtils.isNotEmpty(view)) {
        return new ModelAndView(view, modelMap);
    }

    String x_view = ViewProperties.getString("withdrawal.edit");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/oa/withdrawal/edit", modelMap);
}

From source file:com.ephesoft.dcma.util.EphesoftStringUtil.java

/**
 * Checks case insensitively if toBeChecked parameter is contained in original string or not.
 * //from  ww  w  .j a v  a 2 s  .  co  m
 * @param original {@link String}
 * @param toBeChecked {@link String}
 * @return boolean True if toBeChecked string is contained in original string when checked with case insensitivity.
 */
public static boolean containsIgnoreCase(final String original, final String toBeChecked) {
    boolean doesContain;
    if (null != original && null != toBeChecked) {
        doesContain = StringUtils.containsIgnoreCase(original, toBeChecked);
    } else {
        doesContain = false;
    }
    return doesContain;
}