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

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

Introduction

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

Prototype

public static String trim(String str) 

Source Link

Document

Removes control characters (char <= 32) from both ends of this String, handling null by returning null.

Usage

From source file:com.allinfinance.struts.system.action.AuthoriseAction.java

public String authorise() {

    try {// www.  ja v  a 2s .  co m
        if (StringUtil.isNull(username)) {
            return returnService("???");
        }
        if (StringUtil.isNull(pass)) {
            return returnService("???");
        }
        if (StringUtil.isNull(txnCode)) {
            return returnService("??");
        }

        //???
        TblOprInfoDAO tblOprInfoDAO = (TblOprInfoDAO) ContextUtil.getBean("OprInfoDAO");
        TblOprInfo user = tblOprInfoDAO.get(username);

        if (getOperator().getOprId().equals(username)) {
            return returnService("???????");
        }

        // Step 1 :??
        if (user == null) {
            return returnService("???");
        }
        // ???
        if ("1".equals(user.getOprSta().trim())) {
            return returnService("??????");
        }
        // ??
        if (Integer.parseInt(user.getPwdOutDate().trim()) <= Integer
                .parseInt(CommonFunction.getCurrentDate())) {
            return returnService("?????");
        }

        // Step 2 :??
        if (!getOperator().getOprBrhId().equals(user.getBrhId())) {
            return returnService(
                    "????????");
        }

        // Step 3 :?????
        String txn = "select KEY_ID from TBL_ROLE_FUNC_MAP " + "where KEY_ID = '" + user.getOprDegree().trim()
                + "' and VALUE_ID = '" + txnCode.trim() + "'";
        List list = commQueryDAO.findBySQLQuery(txn);
        if (list != null && !list.isEmpty()) {
            // ??
            String oprPassword = StringUtils.trim(user.getOprPwd());
            pass = StringUtils.trim(Encryption.encrypt(pass));
            if (pass.equals(oprPassword)) {
                return returnService(Constants.SUCCESS_CODE);
            } else {
                return returnService("????");
            }
        } else {
            return returnService("?????");
        }
    } catch (Exception e) {
        e.printStackTrace();
        return returnService(rspCode, e);
    }
}

From source file:com.haulmont.cuba.core.entity.EntitySnapshot.java

@MetaProperty(related = { "snapshotDate,author" })
public String getLabel() {
    String name = "";
    if (author != null && StringUtils.isNotEmpty(this.author.getCaption())) {
        name += this.author.getCaption() + " ";
    }//  w  w w  .j  a v  a2  s.c o  m

    Datatype datatype = Datatypes.getNN(Date.class);

    UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.NAME);
    if (userSessionSource != null && userSessionSource.checkCurrentUserSession()) {
        name += datatype.format(snapshotDate, userSessionSource.getLocale());
    }

    return StringUtils.trim(name);
}

From source file:com.cnnic.whois.controller.oauth.EchoController.java

/**
 * access query api/*from w w w.j  a  v a2  s.  c o m*/
 * @param accessToken
 * @param request
 * @param response
 * @throws Exception
 */
private void accessApi(String accessToken, HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    OAuthAccessorBean oauthAccessorBean = oauthAccessorDao.getOAuthAccessorBeanByAccessToken(accessToken);
    AuthenticationHolder.setAuthentication(new Authentication(oauthAccessorBean.getOauth_user_role()));

    for (Object item : request.getParameterMap().entrySet()) {
        Map.Entry parameter = (Map.Entry) item;
        String[] values = (String[]) parameter.getValue();
        for (String value : values) {

            if (value.equals("ip")) {

                String net = "0";
                String ip = StringUtils.trim("1.1.1.1");

                Map<String, Object> resultMap = null;
                IpQueryParam queryParam = super.praseIpQueryParams(request);
                String strInfo = ip;
                if (!ValidateUtils.verifyIP(strInfo, net)) {
                    resultMap = WhoisUtil.processError(WhoisUtil.COMMENDRRORCODE, queryParam);
                    viewResolver.writeResponse(queryParam.getFormat(), queryParam.getQueryType(), request,
                            response, resultMap);
                    return;
                }
                queryParam.setQ(ip);
                queryParam.setIpInfo(strInfo);
                queryParam.setIpLength(Integer.parseInt(net));
                resultMap = queryService.queryIP(queryParam);
                request.setAttribute("queryPara", ip);
                request.setAttribute("queryType", "ip");
                viewResolver.writeResponse(queryParam.getFormat(), queryParam.getQueryType(), request, response,
                        resultMap);
            }
            if (value.equals("domain")) {
                String domainName = StringUtils.trim("z.cn");
                String queryParaPuny = IDN.toASCII(domainName);
                Map<String, Object> resultMap = null;
                QueryParam queryParam = super.praseQueryParams(request);
                if (!ValidateUtils.validateDomainNameIsValidIdna(queryParaPuny)) {
                    resultMap = WhoisUtil.processError(WhoisUtil.COMMENDRRORCODE, queryParam);
                } else {
                    queryParam.setQ(domainName);
                    resultMap = queryService.queryDomain(queryParam);
                    System.err.println(resultMap);
                }
                viewResolver.writeResponse(queryParam.getFormat(), queryParam.getQueryType(), request, response,
                        resultMap);
            }
            if (value.equals("entity")) {
                EntityQueryParam queryParam = super.praseEntityQueryParams(request);
                queryParam.setQ("IBM-1");
                Map<String, Object> resultMap = queryService.queryEntity(queryParam);
                request.setAttribute("queryType", "entity");
                request.setAttribute("queryPara", "IBM-1");
                renderResponse(request, response, resultMap, queryParam);
            }
        }
    }
}

From source file:com.thalesgroup.sonar.plugins.tusar.TUSARResource.java

private static String parseKey(String key) {
    if (StringUtils.isBlank(key)) {
        return null;
    }//from w w w  .  j a  v  a2  s  .c om

    key = key.replace('\\', '/');
    key = StringUtils.trim(key);
    return key;
}

From source file:mitm.common.cifs.SMBURLBuilder.java

public String buildURL(SMBFileParameters parameters)
        throws MalformedURLException, HierarchicalPropertiesException {
    StrBuilder sb = new StrBuilder();

    sb.append("smb://");

    if (StringUtils.isNotBlank(parameters.getServer())) {
        String userInfo = buildUserInfo(parameters);

        if (StringUtils.isNotBlank(userInfo)) {
            sb.append(userInfo).append("@");
        }/*from  w w w .  jav a 2s  .c om*/

        sb.append(StringUtils.trim(parameters.getServer()));

        if (parameters.getPort() != null) {
            sb.append(":").append(parameters.getPort());
        }

        sb.append("/");

        if (StringUtils.isNotBlank(parameters.getShare())) {
            sb.append(normalizeShareAndDir(parameters.getShare()));
        }

        if (StringUtils.isNotBlank(parameters.getDir())) {
            sb.append(normalizeShareAndDir(parameters.getDir()));
        }

        if (StringUtils.isNotBlank(parameters.getFile())) {
            sb.append(StringUtils.trim(parameters.getFile()));
        }
    }
    return sb.toString();
}

From source file:mitm.djigzo.web.pages.dlp.patterns.PatternsRename.java

public void onValidateFromNewName(String newName) throws ValidationException, WebServiceCheckedException {
    if (newName != null) {
        if (policyPatternManagerWS.getPattern(StringUtils.trim(newName)) != null) {
            throw new ValidationException("A pattern with this name already exists.");
        }//from   ww w  .  j a va2 s.  c  o  m
    }
}

From source file:com.twitter.ambrose.hive.AmbroseHiveFinishHook.java

private boolean isLastCommandProcessed(String currentCmd) {
    currentCmd = StringUtils.trim(currentCmd.replaceAll("\\n|\\r", ""));
    if (currentCmd.equals(lastCmd)) {
        return true;
    }//from www. j a v a2  s. com
    return false;
}

From source file:biz.netcentric.cq.tools.actool.configreader.YamlMacroProcessorImpl.java

private Object evaluateForStatement(Map<String, Object> variables, Object objVal, Matcher forMatcher,
        AcInstallationHistoryPojo history) {
    String varName = StringUtils.trim(forMatcher.group(1));
    String valueOfInClause = StringUtils.trim(forMatcher.group(2));
    String pathOfChildrenOfClause = StringUtils.trim(forMatcher.group(3));
    // allow variables in root path also
    if (StringUtils.isNotBlank(pathOfChildrenOfClause)) {
        pathOfChildrenOfClause = elEvaluator.evaluateEl(pathOfChildrenOfClause, String.class, variables);
    }//from  w ww. j a  v  a 2  s . co  m

    final List<?> iterationValues = valueOfInClause != null ? Arrays.asList(valueOfInClause.split("\\s*,\\s*"))
            : yamlMacroChildNodeObjectsProvider.getValuesForPath(pathOfChildrenOfClause, history);

    List toBeUnfoldedList = unfoldLoop(variables, objVal, varName, iterationValues, history);

    return toBeUnfoldedList;
}

From source file:eionet.cr.util.export.Exporter.java

public void doExportQueryAndWriteDataIntoOutput(ResultSetExportReader reader) throws DAOException {
    Map<String, String> criteria = new HashMap<String, String>();
    for (Entry<String, String> entry : selectedFilters.entrySet()) {
        criteria.put(StringUtils.trim(entry.getKey()), StringUtils.trim(entry.getValue()));
    }/*  www. ja  va 2  s. c  o m*/
    // do the query and write data rows directly to export file
    DAOFactory.get().getDao(ExporterDAO.class).exportByTypeAndFilters(criteria, getSelectedColumnsList(),
            reader);

}

From source file:de.forsthaus.webui.util.InputMessageTextBox.java

private void createBox() {

    setWidth("350px");
    setHeight("150px");
    setTitle(Labels.getLabel("message.Information.PleaseInsertText"));
    setId("confBox");
    setVisible(true);// w  ww  . j a va  2  s. c  om
    setClosable(true);
    addEventListener("onOK", new OnCloseListener());

    // Hbox hbox = new Hbox();
    // hbox.setWidth("100%");
    // hbox.setParent(this);
    // Checkbox cb = new Checkbox();
    // cb.setLabel(Labels.getLabel("common.All"));
    // cb.setChecked(true);

    Separator sp = new Separator();
    sp.setParent(this);

    textbox.setWidth("98%");
    textbox.setHeight("80px");
    textbox.setMultiline(true);
    textbox.setRows(5);
    textbox.setParent(this);

    Separator sp2 = new Separator();
    sp2.setBar(true);
    sp2.setParent(this);

    Button btnSend = new Button();
    btnSend.setLabel(Labels.getLabel("common.Send"));
    btnSend.setParent(this);
    btnSend.addEventListener("onClick", new EventListener() {

        @Override
        public void onEvent(Event event) throws Exception {

            // Check if empty, than do not send
            if (StringUtils.isEmpty(StringUtils.trim(textbox.getText()))) {
                onClose();
                return;
            }

            msg = msg + ZksampleDateFormat.getDateTimeLongFormater().format(new Date()) + " / "
                    + Labels.getLabel("common.Message.From") + " " + userName + ":" + "\n";
            msg = msg + textbox.getText();
            msg = msg + "\n" + "_____________________________________________________" + "\n";

            onClose();
        }
    });

    try {
        doModal();
    } catch (SuspendNotAllowedException e) {
        logger.fatal("", e);
    } catch (InterruptedException e) {
        logger.fatal("", e);
    }
}