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.googlecode.fascinator.messaging.ConveyerBelt.java

/**
 * Find out what transformers are required to run for a particular render
 * step.//from w w w  .j av a 2 s  .  c om
 * 
 * @param object The digital object to transform.
 * @param config The configuration for the particular harvester.
 * @param thisType The type of render chain (step).
 * @param routing Flag if query is for routing. Set this value will force a
 *            check for user priority, and then clear the flag if found.
 * @return List<String> A list of names for instantiated transformers.
 */
public static List<String> getTransformList(DigitalObject object, JsonSimpleConfig config, String thisType,
        boolean routing) throws StorageException {
    List<String> plugins = new ArrayList<String>();
    Properties props = object.getMetadata();

    // User initiated event
    if (routing) {
        String user = props.getProperty("userPriority");
        if (user != null && user.equals("true")) {
            log.info("User priority flag set: '{}'", object.getId());
            plugins.add(CRITICAL_USER_SELECTOR);
            props.remove("userPriority");
            object.close();
        }
    }

    // Property data, highest priority
    String pluginList = props.getProperty(thisType);
    if (pluginList != null) {
        // Turn the string into a real list
        for (String plugin : StringUtils.split(pluginList, ",")) {
            plugins.add(StringUtils.trim(plugin));
        }

    } else {
        // The harvester specified none, fallback to the
        // default list for this harvest source.
        List<String> transformerList = config.getStringList("transformer", thisType);
        if (transformerList != null) {
            for (String entry : transformerList) {
                plugins.add(StringUtils.trim(entry));
            }
        } else {
            log.info("No transformers configured!");
        }
    }
    return plugins;
}

From source file:com.hangum.tadpole.sql.util.SQLUtil.java

/**
 * ?    ?./*  w w w  . j av a 2s  . co m*/
 *  ? ?? ... -- / ** * / / * * /
 * 
 * @param strSQL
 * @return
 */
public static boolean isNotAllowed(String strSQL) {
    boolean isRet = false;
    strSQL = removeComment(strSQL);

    String cmpSql = StringUtils.trim(strSQL);

    for (String strNAllSQL : NOT_ALLOWED_SQL) {
        if (StringUtils.startsWith(cmpSql.toLowerCase(), strNAllSQL.toLowerCase())) {
            return true;
        }
    }

    return isRet;
}

From source file:com.bstek.dorado.view.loader.Package.java

/**
 * ?????ContentType//from   w  w w . j  a  v  a  2  s .co  m
 */
public void setFileNames(String[] fileNames) {
    for (int i = 0; i < fileNames.length; i++) {
        String fileName = fileNames[i];
        if (fileName != null) {
            fileNames[i] = StringUtils.trim(fileName);
        }
    }
    this.fileNames = fileNames;
}

From source file:com.intuit.tank.common.ScriptUtil.java

private static void addKeys(Map<String, String> ret, Set<RequestData> rds, String type) {
    for (RequestData rd : rds) {
        if (StringUtils.isNotBlank(rd.getKey())) {
            if (type == null || StringUtils.containsIgnoreCase(rd.getType(), type)) {
                ret.put(rd.getKey().trim(), StringUtils.trim(rd.getValue()));
            }/*from w  w w.j  av a 2s.  co  m*/
        }
    }

}

From source file:com.github.woonsanko.katharsis.examples.hippo.katharsis.resource.repository.ProjectRepository.java

@Override
public Iterable<ProjectResource> findAll(RequestParams requestParams) {
    List<ProjectResource> projectResList = new LinkedList<>();

    try {/*from  w w  w. jav a2s  .co  m*/
        final HstRequestContext requestContext = RequestContextProvider.get();
        final HippoBean scope = requestContext.getSiteContentBaseBean();
        final HstQuery hstQuery = requestContext.getQueryManager().createQuery(scope, ProjectDocument.class,
                true);

        String queryTerm = null;

        if (requestParams.getFilters() != null) {
            queryTerm = StringUtils.trim(requestParams.getFilters().get("q").asText());
        }

        if (StringUtils.isNotEmpty(queryTerm)) {
            final Filter filter = hstQuery.createFilter();
            filter.addContains(".", queryTerm);
            hstQuery.setFilter(filter);
        }

        hstQuery.setOffset(getPaginationOffset(requestParams, 0));
        hstQuery.setLimit(this.getPaginationLimit(requestParams, 200));

        final HstQueryResult result = hstQuery.execute();

        ProjectDocument projectDoc;
        ProjectResource projectRes;

        for (HippoBeanIterator it = result.getHippoBeans(); it.hasNext();) {
            projectDoc = (ProjectDocument) it.nextHippoBean();
            projectRes = new ProjectResource().represent(projectDoc);
            projectResList.add(projectRes);
        }
    } catch (Exception e) {
        log.error("Failed to query projects.", e);
    }

    return projectResList;
}

From source file:com.hangum.tadpole.engine.security.DBPasswordDialog.java

@Override
protected void okPressed() {
    //  ? ? .// w ww.j  av  a2s .c  om
    try {
        userDB.setPasswd(StringUtils.trim(textPassword.getText()));
        TadpoleSQLManager.getInstance(userDB);
    } catch (Exception e) {
        logger.error("test passwd Connection error ");

        String msg = e.getMessage();
        if (StringUtils.contains(msg, "No more data to read from socket")) {
            MessageDialog.openWarning(getShell(), CommonMessages.get().Warning,
                    msg + CommonMessages.get().Check_DBAccessSystem);
        } else {
            MessageDialog.openWarning(getShell(), CommonMessages.get().Warning, msg);
        }

        textPassword.setFocus();

        return;
    }

    super.okPressed();
}

From source file:fr.dudie.acrachilisync.model.AcraReport.java

/**
 * Constructor.//from  ww  w. ja  v  a2 s .  c  om
 * <p>
 * Wraps the given spreadsheet list entry and provides read only access to report field values.
 * 
 * @param pCustomElements
 *            custom element collection of a Google Spreadsheet list entry
 * @throws MalformedSpreadsheetLineException
 *             the given ListEntry havn't all {@link AcraReportHeader} tag values, <br>
 *             unable to parse the crash date from the ACRA report
 */
public AcraReport(final CustomElementCollection pCustomElements) throws MalformedSpreadsheetLineException {

    this.elements = pCustomElements;

    // check the list entry contains the
    for (final AcraReportHeader header : AcraReportHeader.values()) {
        if (!elements.getTags().contains(header.tagName())
                || header.isMandatory() && StringUtils.isEmpty(elements.getValue(header.tagName()))) {
            throw new MalformedSpreadsheetLineException(header, elements.getValue(header.tagName()));
        }
    }

    userAppStartDate = toDate(getValue(AcraReportHeader.USER_APP_START_DATE));
    userCrashDate = toDate(getValue(AcraReportHeader.USER_CRASH_DATE));

    stacktraceMD5 = MD5Utils.toMD5hash(StringUtils.trim(getValue(AcraReportHeader.STACK_TRACE)));
}

From source file:com.alibaba.otter.manager.biz.monitor.impl.PipelineTimeoutRuleMonitor.java

private boolean checkTimeout(AlarmRule rule, long elapsed) {
    if (!inPeriod(rule)) {
        return false;
    }//from  w w w  .j a va 2  s  .  c  o m

    String matchValue = rule.getMatchValue();
    matchValue = StringUtils.substringBeforeLast(matchValue, "@");
    Long maxSpentTime = Long.parseLong(StringUtils.trim(matchValue));
    // sinceLastSync maxSpentTime 
    if (elapsed >= (maxSpentTime * 1000)) {
        sendAlarm(rule, String.format(TIME_OUT_MESSAGE, rule.getPipelineId(), (elapsed / 1000)));
        return true;
    }
    return false;
}

From source file:com.hangum.tadpole.engine.security.OTPInputDialog.java

@Override
protected void okPressed() {
    String strOTPCode = StringUtils.trim(textOTPCode.getText());
    if ("".equals(strOTPCode)) {
        MessageDialog.openError(getShell(), CommonMessages.get().Error, Messages.get().OTPEmpty);//"OTP ?  .");
        textOTPCode.setFocus();//from   w  w w .j  a va2 s  .c  o  m
        return;
    }

    try {
        GetOTPCode.isValidate(userID, secretKey, strOTPCode);
    } catch (Exception e) {
        logger.error("OTP check", e);
        MessageDialog.openError(getShell(), CommonMessages.get().Error, e.getMessage());
        textOTPCode.setFocus();
        return;
    }

    super.okPressed();
}

From source file:com.greenline.guahao.web.module.home.controllers.mobile.report.MobileReportController.java

/**
 * //from  w ww .  j ava2  s  .  co  m
 * 
 * @param map
 * @return String
 */
@MethodRemark(value = "remark=,pageSize=,pageNo=?")
@RequestMapping(value = "/mobile/b/get/report")
public String searchMyReport(ModelMap map) {
    String mobile = request.getParameter("mobile");
    String certNo = request.getParameter("certNo");

    if (StringUtils.isBlank(mobile) || StringUtils.isBlank(certNo)) {
        Long cuserId = UserCookieUtil.getUserId(request);// ?cookieuserId
        UserDO userDO = userManager.findUserByUserId(cuserId);
        map.put("userDO", userDO);
        return "mobile/report/search_report";
    }

    if (!StringUtils.isNumeric(StringUtils.trim(mobile))) {
        map.put("hasError", true);
        map.put("message", "?????");
        UserDO userDO = new UserDO();
        userDO.setMobile(mobile);
        userDO.setCertNo(certNo);
        map.put("userDO", userDO);
        return "mobile/report/search_report";
    }

    if (!RegexUtil.isIdCard(StringUtils.trim(certNo))) {
        map.put("hasError", true);
        map.put("message", "???????");
        UserDO userDO = new UserDO();
        userDO.setMobile(mobile);
        userDO.setCertNo(certNo);
        map.put("userDO", userDO);
        return "mobile/report/search_report";
    }

    // 
    Calendar calendar = Calendar.getInstance();
    // ?
    calendar.add(Calendar.DATE, 1);
    Date end = calendar.getTime();
    // 1?
    calendar.add(Calendar.DAY_OF_MONTH, -30);
    Date start = calendar.getTime();

    // ??id
    String hospitalId = "99574b7d-e93e-4c1a-a61a-536f0b04466f";
    List<InspectionReportsDO> list = reportManager.listReport(hospitalId, StringUtils.trim(mobile),
            StringUtils.trim(certNo), start, end);
    map.put("reportList", list);

    map.put("certNO", certNo);
    map.put("mobile", mobile);

    return "mobile/report/report_list";
}