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:ch.entwine.weblounge.dispatcher.impl.handler.FeedRequestHandlerImpl.java

/**
 * Compiles the feed based on feed type, version and request parameters.
 * //  w ww .j  a v  a2  s.  com
 * @param feedType
 *          feed type
 * @param feedVersion
 *          feed version
 * @param site
 *          the site
 * @param request
 *          the request
 * @param response
 *          the response
 * @return the feed object
 * @throws ContentRepositoryException
 *           if the content repository can't be accessed
 */
private SyndFeed createFeed(String feedType, String feedVersion, Site site, WebloungeRequest request,
        WebloungeResponse response) throws ContentRepositoryException {

    // Extract the subjects. The parameter may be specified multiple times
    // and add more than one subject by separating them using a comma.
    String[] subjectParameter = request.getParameterValues(PARAM_SUBJECT);
    List<String> subjects = new ArrayList<String>();
    if (subjectParameter != null) {
        for (String parameter : subjectParameter) {
            for (String subject : parameter.split(",")) {
                if (StringUtils.isNotBlank(subject))
                    subjects.add(StringUtils.trim(subject));
            }
        }
    }

    // How many entries do we need?
    int limit = DEFAULT_LIMIT;
    String limitParameter = StringUtils.trimToNull(request.getParameter(PARAM_LIMIT));
    if (limitParameter != null) {
        try {
            limit = Integer.parseInt(limitParameter);
        } catch (Throwable t) {
            logger.debug("Non parseable number {} specified as limit", limitParameter);
            limit = DEFAULT_LIMIT;
        }
    }

    // Get hold of the content repository
    ContentRepository contentRepository = site.getContentRepository();
    if (contentRepository == null) {
        logger.warn("No content repository found for site '{}'", site);
        return null;
    } else if (contentRepository.isIndexing()) {
        logger.debug("Content repository of site '{}' is currently being indexed", site);
        DispatchUtils.sendServiceUnavailable(request, response);
        return null;
    }

    // User and language
    Language language = request.getLanguage();
    // User user = request.getUser();

    // Determine the feed type
    feedType = feedType.toLowerCase() + "_" + feedVersion;
    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType(feedType);
    feed.setLink(request.getRequestURL().toString());
    feed.setTitle(site.getName());
    feed.setDescription(site.getName());
    feed.setLanguage(language.getIdentifier());
    feed.setPublishedDate(new Date());

    // TODO: Add more feed metadata, ask site

    SearchQuery query = new SearchQueryImpl(site);
    query.withVersion(Resource.LIVE);
    query.withTypes(Page.TYPE);
    query.withLimit(limit);
    query.sortByPublishingDate(Order.Descending);
    for (String subject : subjects) {
        query.withSubject(subject);
    }

    // Load the result and add feed entries
    SearchResult result = contentRepository.find(query);
    List<SyndEntry> entries = new ArrayList<SyndEntry>();
    int items = Math.min(limit, result.getItems().length);

    for (int i = 0; i < items; i++) {
        SearchResultItem item = result.getItems()[i];

        // Get the page
        PageSearchResultItem pageItem = (PageSearchResultItem) item;
        Page page = pageItem.getPage();

        // TODO: Can the page be accessed?

        // Set the page's language to the feed language
        page.switchTo(language);

        // Tag the cache entry
        response.addTag(CacheTag.Resource, page.getIdentifier());

        // If this is to become the most recent entry, let's set the feed's
        // modification date to be that of this entry
        if (entries.size() == 0) {
            feed.setPublishedDate(page.getPublishFrom());
        }

        // Create the entry
        SyndEntry entry = new SyndEntryImpl();
        entry.setPublishedDate(page.getPublishFrom());
        entry.setUpdatedDate(page.getModificationDate());
        entry.setLink(site.getHostname(request.getEnvironment()).toExternalForm() + item.getUrl().getLink());
        entry.setAuthor(page.getCreator().getName());
        entry.setTitle(page.getTitle());
        entry.setUri(page.getIdentifier());

        // Categories
        if (page.getSubjects().length > 0) {
            List<SyndCategory> categories = new ArrayList<SyndCategory>();
            for (String subject : page.getSubjects()) {
                SyndCategory category = new SyndCategoryImpl();
                category.setName(subject);
                categories.add(category);
            }
            entry.setCategories(categories);
        }

        // Try to render the preview pagelets and write them to the feed
        List<SyndContent> entryContent = new ArrayList<SyndContent>();
        Composer composer = new ComposerImpl("preview", page.getPreview());
        StringBuffer renderedContent = new StringBuffer();

        for (Pagelet pagelet : composer.getPagelets()) {
            Module module = site.getModule(pagelet.getModule());
            PageletRenderer renderer = null;
            if (module == null) {
                logger.warn("Skipping pagelet {} in feed due to missing module '{}'", pagelet,
                        pagelet.getModule());
                continue;
            }

            renderer = module.getRenderer(pagelet.getIdentifier());
            if (renderer == null) {
                logger.warn("Skipping pagelet {} in feed due to missing renderer '{}/{}'",
                        new Object[] { pagelet, pagelet.getModule(), pagelet.getIdentifier() });
                continue;
            }

            URL rendererURL = renderer.getRenderer(RendererType.Feed.toString());
            Environment environment = request.getEnvironment();
            if (rendererURL == null)
                rendererURL = renderer.getRenderer();
            if (rendererURL != null) {
                String pageletContent = null;
                try {
                    pagelet.switchTo(language);
                    pageletContent = loadContents(rendererURL, site, page, composer, pagelet, environment);
                    renderedContent.append(pageletContent);
                } catch (ServletException e) {
                    logger.warn("Error processing the pagelet renderer at {}: {}", rendererURL, e.getMessage());
                    DispatchUtils.sendInternalError(request, response);
                } catch (IOException e) {
                    logger.warn("Error processing the pagelet renderer at {}: {}", rendererURL, e.getMessage());
                    DispatchUtils.sendInternalError(request, response);
                }
            }
        }

        if (renderedContent.length() > 0) {
            SyndContent content = new SyndContentImpl();
            content.setType("text/html");
            content.setMode("escaped");
            content.setValue(renderedContent.toString());
            entryContent.add(content);
            entry.setContents(entryContent);
        }

        entries.add(entry);
    }

    feed.setEntries(entries);

    return feed;
}

From source file:com.ibm.jaggr.service.impl.modulebuilder.css.CSSModuleBuilder.java

/**
 * Minifies a CSS string by removing comments and excess white-space, as well as 
 * some unneeded tokens.//from   w  ww.ja  va 2  s. c o m
 * 
 * @param css The contents of a CSS file as a String
 * @param uri The URI for the CSS file
 * @return
 */
protected String minify(String css, IResource res) {

    // replace all quoted strings and url(...) patterns with unique ids so that 
    // they won't be affected by whitespace removal.
    LinkedList<String> quotedStringReplacements = new LinkedList<String>();
    Matcher m = quotedStringPattern.matcher(css);
    StringBuffer sb = new StringBuffer();
    int i = 0;
    while (m.find()) {
        String text = (m.group(1) != null) ? ("url(" + StringUtils.trim(m.group(1)) + ")") : //$NON-NLS-1$ //$NON-NLS-2$
                m.group(0);
        quotedStringReplacements.add(i, text);
        String replacement = "%%" + QUOTED_STRING_MARKER + (i++) + "__%%"; //$NON-NLS-1$ //$NON-NLS-2$
        m.appendReplacement(sb, ""); //$NON-NLS-1$
        sb.append(replacement);
    }
    m.appendTail(sb);
    css = sb.toString();

    // Get rid of extra whitespace
    css = whitespacePattern.matcher(css).replaceAll(" "); //$NON-NLS-1$
    css = endsPattern.matcher(css).replaceAll(""); //$NON-NLS-1$
    css = closeBracePattern.matcher(css).replaceAll("}"); //$NON-NLS-1$
    m = delimitersPattern.matcher(css);
    sb = new StringBuffer();
    while (m.find()) {
        String text = m.group(1);
        m.appendReplacement(sb, ""); //$NON-NLS-1$
        sb.append(text.length() == 1 ? text : text.replace(" ", "")); //$NON-NLS-1$ //$NON-NLS-2$
    }
    m.appendTail(sb);
    css = sb.toString();

    // restore quoted strings and url(...) patterns
    m = QUOTED_STRING_MARKER_PAT.matcher(css);
    sb = new StringBuffer();
    while (m.find()) {
        i = Integer.parseInt(m.group(1));
        m.appendReplacement(sb, ""); //$NON-NLS-1$
        sb.append(quotedStringReplacements.get(i));
    }
    m.appendTail(sb);
    css = sb.toString();

    return css.toString();
}

From source file:com.haulmont.cuba.gui.components.filter.edit.CustomConditionFrame.java

protected String replaceParamWithQuestionMark(String where) {
    String res = StringUtils.trim(where);
    if (!StringUtils.isBlank(res)) {
        Matcher matcher = QueryParserRegex.PARAM_PATTERN.matcher(res);
        StringBuffer sb = new StringBuffer();
        while (matcher.find()) {
            if (!matcher.group().startsWith(":session$"))
                matcher.appendReplacement(sb, "?");
        }//from  w w w.  jav  a  2  s. c o  m
        matcher.appendTail(sb);
        return sb.toString();
    }
    return res;
}

From source file:mitm.application.djigzo.james.mailets.PDFEncrypt.java

private void initViewerPreferences() {
    String param = StringUtils.trimToNull(getInitParameter(Parameter.VIEWER_PREFERENCE.name));

    if (param != null) {
        String[] preferences = StringUtils.split(param, ',');

        for (String preferenceName : preferences) {
            preferenceName = StringUtils.trim(preferenceName);

            ViewerPreference viewerPreference = ViewerPreference.fromName(preferenceName);

            if (viewerPreference == null) {
                throw new IllegalArgumentException(preferenceName + " is not a valid ViewerPreference.");
            }//from   w  w w . jav  a2 s. c  o m

            if (viewerPreferences == null) {
                viewerPreferences = new HashSet<ViewerPreference>();
            }

            viewerPreferences.add(viewerPreference);
        }
    }
}

From source file:com.jgui.ttscrape.htmlunit.GridParser.java

private void parseShowSummary(Show show, String txt) {
    int i1 = txt.indexOf('(');
    if (i1 >= 0) {
        int i2 = txt.indexOf(')', i1);
        if (i2 > 0) {
            String flags = txt.substring(i1 + 1, i2);
            parseShowSummary(show, flags);
            show.setSubtitle(StringUtils.trim(txt.substring(i2 + 1)));
            return;
        }//from  w  w w. ja v a2s  . com
    }

    String[] fields = txt.split(",");
    for (String field : fields) {
        field = field.trim();
        if (StringUtils.isNotEmpty(field)) {
            // look for star rating.
            if (StringUtils.containsOnly(field, "*+")) {
                show.setStars((float) (StringUtils.countMatches(field, "*")
                        + 0.5 * StringUtils.countMatches(field, "+")));
            }
            if (StringUtils.containsOnly(field, "0123456789")) {
                try {
                    show.setYear(Integer.parseInt(field));
                } catch (NumberFormatException e) {
                    logger.error("failed to parse year: {}", field);
                }
            }
            if ("New".equals(field)) {
                show.setNewFlag(true);
            }
            if (knownRatings.contains(field)) {
                show.setRating(field);
            }
        }
    }
}

From source file:$.ResourceServlet.java

@Override
    public void init() throws ServletException {
        jarPathPrefix = getInitParameter("jarPathPrefix", "META-INF");
        cacheTimeout = Integer.parseInt(getInitParameter("cacheTimeout", "31556926"));
        gzipEnabled = Boolean.parseBoolean(getInitParameter("gzipEnabled", "true"));
        webResourceEnabled = Boolean.parseBoolean(getInitParameter("webResourceEnabled", "true"));
        jarResourceEnabled = Boolean.parseBoolean(getInitParameter("jarResourceEnabled", "true"));

        allowedResourcePaths = new HashSet<Pattern>(DEFAULT_ALLOWED_RESOURCE_PATHS);
        mimeTypes = new HashMap<String, String>(DEFAULT_MIME_TYPES);
        compressedMimeTypes = new HashSet<Pattern>(DEFAULT_COMPRESSED_MIME_TYPES);

        String param = getInitParameter("allowedResourcePaths", null);
        if (!StringUtils.isBlank(param)) {
            allowedResourcePaths = new HashSet<Pattern>();
            String[] patterns = StringUtils.split(param, ", ${symbol_escape}t${symbol_escape}r${symbol_escape}n");
            for (int i = 0; i < patterns.length; i++) {
                if (!StringUtils.isBlank(patterns[i])) {
                    allowedResourcePaths.add(Pattern.compile(patterns[i]));
                }//www. j  a  va 2  s .  c  o  m
            }
        }

        param = getInitParameter("mimeTypes", null);
        if (!StringUtils.isBlank(param)) {
            mimeTypes = new HashMap<String, String>();
            String[] pairs = StringUtils.split(param, ",${symbol_escape}t${symbol_escape}r${symbol_escape}n");
            for (int i = 0; i < pairs.length; i++) {
                if (!StringUtils.isBlank(pairs[i])) {
                    String[] pair = StringUtils.split(pairs[i], "=");
                    if (pair.length > 1) {
                        mimeTypes.put(StringUtils.trim(pair[0]), StringUtils.trim(pair[1]));
                    }
                }
            }
        }

        param = getInitParameter("compressedMimeTypes", null);
        if (!StringUtils.isBlank(param)) {
            compressedMimeTypes = new HashSet<Pattern>();
            String[] patterns = StringUtils.split(param, ", ${symbol_escape}t${symbol_escape}r${symbol_escape}n");
            for (int i = 0; i < patterns.length; i++) {
                if (!StringUtils.isBlank(patterns[i])) {
                    compressedMimeTypes.add(Pattern.compile(patterns[i]));
                }
            }
        }

    }

From source file:com.greenline.guahao.web.module.home.controllers.vip.OrderRemindController.java

public boolean bindMobile(ModelMap model, long userId, String mobile, String validCode) {
    try {/*from ww  w  .j av  a 2 s.  co  m*/
        // ?
        if (!RegexUtil.isMobile(StringUtils.trim(mobile))) {
            logger.error(UserProfileConstants.ERR_MSG_MOBILE_FORMAT_ERROR);
            model.put("errorMessage", UserProfileConstants.ERR_MSG_MOBILE_FORMAT_ERROR);
            return false;
        }

        UserDO userCheck = orderRemindProcessor.getCurrentUser();
        if (isBindedMobile(userCheck)) {
            return true;
        }

        UserResult urr = userManager.valiMobileNo(userCheck.getUserId(), mobile, userCheck.getReg_type());

        if (urr != null && urr.getUserDO() != null) {
            // ??
            UserDO userdo = urr.getUserDO();
            logger.warn("??[" + userdo.getUserId() + "]");
            model.put("errorMessage", "??");
            return false;
        }

        if (codeCacheManager.verifyMobileCode(VerifyTypeEnum.UPDATE_PROFILE, mobile, validCode)) { // ??
            UserDO user = new UserDO();
            user.setUserId(userId);
            user.setMobile(mobile);
            user.setBindMobile(1);
            UserResult r = userManager.bindUserMobile(user);
            if (r.isSystemError()) {
                logger.error(r.getResponseDesc());
                model.put("errorMessage", r.getResponseDesc());
                return false;
            }
            codeCacheManager.delCode(VerifyTypeEnum.UPDATE_PROFILE,
                    VCodeCachePrefixEnum.CODE_PRE.getValue() + mobile);
            return true;
        } else {
            logger.error(UserProfileConstants.ERR_MSG_MOBILE_CODE);
            model.put("errorMessage", UserProfileConstants.ERR_MSG_MOBILE_CODE);
            return false;
        }
    } catch (Exception e) {
        logger.error(UserProfileConstants.ERR_MSG_SYSTEM_ERROR, e);
        model.put("errorMessage", UserProfileConstants.ERR_MSG_SYSTEM_ERROR);
        return false;
    }
}

From source file:com.activecq.tools.auth.impl.CookieAuthenticationImpl.java

/**
 * Encrypt token data/*from   www .j a v a  2s.c  o m*/
 *
 * @param data
 * @return
 * @throws NoSuchAlgorithmException
 * @throws InvalidKeyException
 */
private String encryptData(String data) throws NoSuchAlgorithmException, InvalidKeyException {
    SecretKeySpec keySpec = new SecretKeySpec(secret.getBytes(), encryptionType);

    Mac mac = Mac.getInstance(encryptionType);
    mac.init(keySpec);
    byte[] result = mac.doFinal(data.getBytes());
    return StringUtils.trim(new Base64(true).encodeToString(result));
}

From source file:com.allinfinance.bo.impl.mchnt.TblMchntServiceImpl.java

public String accept(String mchntId, TblMchtBaseInfTmp tmp, TblMchtSettleInfTmp tmpSettle, TblMchtBaseInf inf,
        TblMchtSettleInf infSettle, TblRiskParamMng tblRiskParamMng) throws Exception {

    //      TblMchtBaseInfTmp tmp = tblMchtBaseInfTmpDAO.get(mchntId);
    //      TblMchtSettleInfTmp tmpSettle = tblMchtSettleInfTmpDAO.get(mchntId);
    //      if (null == tmp || null == tmpSettle) {
    //         return "??";
    //      }// w w  w .  j  a  va 2s.  c o  m
    //??
    String newMchtNo;
    if (mchntId.contains("AAA")) {
        String idStr = "848" + tmp.getAreaNo().trim() + tmp.getMcc().trim();
        newMchtNo = GenerateNextId.getMchntId(idStr);
        newMchtNo = StringUtils.trim(newMchtNo);

    } else {
        newMchtNo = mchntId;
    }
    System.out.println("?" + newMchtNo);

    //??
    String status = tmp.getMchtStatus();
    //cre
    //      String crtDateTmp= tmp.getRecCrtTs();
    //?
    String upDateTmp = tmp.getRecUpdTs();
    //?
    String oprid = tmp.getUpdOprId();
    if (null == oprid) {
        oprid = tmp.getCrtOprId();
    }

    // ??
    //      TblMchtBaseInf inf = tblMchtBaseInfDAO.get(newMchtNo);
    //      TblMchtSettleInf infSettle = tblMchtSettleInfDAO.get(newMchtNo);
    //?cre
    String crtDate = "0";

    if (null != inf) {
        inf.setMchtStatus("0");
        crtDate = inf.getRecCrtTs();
    }
    if (null == inf) {
        inf = new TblMchtBaseInf();
    }
    if (null == infSettle) {
        infSettle = new TblMchtSettleInf();
    }

    // 
    tmp.setRecUpdTs(CommonFunction.getCurrentDateTime());
    Operator opr = (Operator) ServletActionContext.getRequest().getSession()
            .getAttribute(Constants.OPERATOR_INFO);
    tmp.setUpdOprId(opr.getOprId());
    tmpSettle.setRecUpdTs(CommonFunction.getCurrentDateTime());

    // ?
    tmp.setMchtStatus(StatusUtil.getNextStatus("A." + status));

    // ?
    TblMchntRefuse refuse = new TblMchntRefuse();
    TblMchntRefusePK tblMchntRefusePK = new TblMchntRefusePK(newMchtNo, CommonFunction.getCurrentDateTime());
    refuse.setId(tblMchntRefusePK);
    refuse.setRefuseInfo("");
    refuse.setBrhId(tmp.getBankNo());
    refuse.setOprId(opr.getOprId());

    // ?
    refuse.setRefuseType("");

    //?
    Object[] ret = insertTblMchtBaseInfTmpLog(tmp, inf, tmpSettle, infSettle, status, upDateTmp, oprid);
    String retMsg = Constants.SUCCESS_CODE;
    /*
     * ?
            
     */
    String txnCode = "";
    boolean isOpen = (Boolean) ret[1];
    if (TblMchntInfoConstants.MCHNT_ST_NEW_UNCK.equals(status)
            || TblMchntInfoConstants.MCHNT_ST_NEW_FIRST_UNCK.equals(status)) {
        txnCode = FrontMcht.TXN_CODE_ADDACCT;
        isOpen = true;
    }
    if (!TblMchntInfoConstants.MCHNT_ST_NEW_UNCK.equals(status)
            && !TblMchntInfoConstants.MCHNT_ST_NEW_FIRST_UNCK.equals(status)) {
        if (TblMchntInfoConstants.MCHNT_ST_MODI_UNCK.equals(status)) {
            txnCode = FrontMcht.TXN_CODE_UPDACCT;
        } else if (TblMchntInfoConstants.MCHNT_ST_DEL_UNCK.equals(status)) {
            txnCode = FrontMcht.TXN_CODE_DELACCT;
            isOpen = true;
        }
    }
    if (isOpen) {
        retMsg = optMchtAcct(inf, infSettle, txnCode);
    }

    //======================

    log.info("????");
    retMsg = this.sendMessage(newMchtNo, tmp, inf, tmpSettle, infSettle);
    log.info(":" + retMsg);
    if (!Constants.SUCCESS_CODE.equals(retMsg)) {
        return retMsg;
    }
    log.info("?????");
    //?
    TblRiskParamMngPK key = new TblRiskParamMngPK();
    key.setMchtId(newMchtNo);
    key.setTermId(CommonFunction.fillString("00000000", ' ', 12, true));
    key.setRiskType("0");
    tblRiskParamMng.setId(key);
    tblRiskParamMngDAO.saveOrUpdate(tblRiskParamMng);
    //=============================

    // ????clone??clone???
    //      if(mchntId.contains("AAA")){
    BeanUtils.copyProperties(tmp, inf);
    BeanUtils.copyProperties(tmpSettle, infSettle);
    //      }
    log.info("???" + inf.getCashFlag());
    //??
    if ("1".equals(inf.getCashFlag())) {
        if (mchntId.contains("AAA")) {
            TblMchtCashInfTmpTmp tblMchtCashInfTmpTmp = cashInfTmpTmpDAO.get(mchntId);
            TblMchtCashInfTmp tblMchtCashInfTmp = cashInfTmpDAO.get(mchntId);
            if (tblMchtCashInfTmp != null && tblMchtCashInfTmpTmp != null) {
                tblMchtCashInfTmp.setUpdOpr(inf.getUpdOprId());
                tblMchtCashInfTmp.setUpdTime(CommonFunction.getCurrentDateTime());
                TblMchtCashInf cashInf = new TblMchtCashInf(newMchtNo);
                TblMchtCashInfTmp cashInfTmp = new TblMchtCashInfTmp(newMchtNo);
                TblMchtCashInfTmpTmp cashInfTmpTmp = new TblMchtCashInfTmpTmp(newMchtNo);
                BeanUtils.copyProperties(tblMchtCashInfTmp, cashInf, new String[] { "mchtId" });
                BeanUtils.copyProperties(tblMchtCashInfTmp, cashInfTmp, new String[] { "mchtId" });
                BeanUtils.copyProperties(tblMchtCashInfTmp, cashInfTmpTmp, new String[] { "mchtId" });
                cashInfTmpDAO.delete(tblMchtCashInfTmp);
                cashInfTmpTmpDAO.delete(tblMchtCashInfTmpTmp);
                cashInfDAO.saveOrUpdate(cashInf);
                cashInfTmpDAO.saveOrUpdate(cashInfTmp);
                cashInfTmpTmpDAO.saveOrUpdate(cashInfTmpTmp);
            }
        } else {
            TblMchtCashInfTmp tblMchtCashInfTmp = cashInfTmpDAO.get(mchntId);
            if (tblMchtCashInfTmp != null) {
                tblMchtCashInfTmp.setUpdOpr(inf.getUpdOprId());
                tblMchtCashInfTmp.setUpdTime(CommonFunction.getCurrentDateTime());
                TblMchtCashInf cashInf = new TblMchtCashInf(newMchtNo);
                BeanUtils.copyProperties(tblMchtCashInfTmp, cashInf);
                cashInfDAO.saveOrUpdate(cashInf);
            }
        }
    }
    //
    if (TblMchntInfoConstants.MCHNT_ST_NEW_UNCK.equals(status)
            || TblMchntInfoConstants.MCHNT_ST_NEW_FIRST_UNCK.equals(status)) {
        inf.setRecCrtTs(CommonFunction.getCurrentDateTime());//
    }
    //?crt??
    if (!TblMchntInfoConstants.MCHNT_ST_NEW_UNCK.equals(status)
            && !TblMchntInfoConstants.MCHNT_ST_NEW_FIRST_UNCK.equals(status)) {
        inf.setRecCrtTs(crtDate);
    }

    if (Constants.SUCCESS_CODE.equals(retMsg)) {

        if (status.equals(TblMchntInfoConstants.MCHNT_ST_DEL_UNCK)) {//?
            String update0 = "update tbl_term_inf set TERM_STA = '7' where MCHT_CD = '" + tmp.getMchtNo() + "'";
            String update1 = "update tbl_term_inf_tmp set TERM_STA = '7' where MCHT_CD = '" + tmp.getMchtNo()
                    + "'";
            commQueryDAO.excute(update0);
            commQueryDAO.excute(update1);
        } else if (status.equals(TblMchntInfoConstants.MCHNT_ST_STOP_UNCK)) {//??
            String update0 = "update tbl_term_inf set TERM_STA = '4' where MCHT_CD = '" + tmp.getMchtNo() + "'";
            String update1 = "update tbl_term_inf_tmp set TERM_STA = '4' where MCHT_CD = '" + tmp.getMchtNo()
                    + "'";
            String update2 = "update TBL_ALARM_MCHT set BLOCK_MCHT_FLAG='1' where CARD_ACCP_ID='"
                    + tmp.getMchtNo() + "' ";
            commQueryDAO.excute(update0);
            commQueryDAO.excute(update1);
            commQueryDAO.excute(update2);
        } else if (status.equals(TblMchntInfoConstants.MCHNT_ST_MODI_UNCK)) {//
            if (!tmp.getBankNo().equals(inf.getBankNo())) {
                String update0 = "update BTH_CHK_TXN_SUSPS set stlm_inst='" + tmp.getBankNo()
                        + "' where card_accp_id='" + tmp.getMchtNo() + "'";
                String update1 = "update BTH_CHK_TXN set stlm_inst='" + tmp.getBankNo()
                        + "' where card_accp_id = '" + tmp.getMchtNo() + "'";
                String update2 = "update tbl_mchnt_infile_dtl set brh_code='" + tmp.getBankNo()
                        + "' where mcht_no = '" + tmp.getMchtNo() + "'";
                String update3 = "update tbl_algo_dtl set brh_ins_id_cd='" + tmp.getBankNo()
                        + "' where mcht_cd = '" + tmp.getMchtNo() + "'";
                String update4 = "update tbl_term_algo_sum set brh_ins_id_cd='" + tmp.getBankNo()
                        + "' where mcht_cd = '" + tmp.getMchtNo() + "'";
                String update5 = "update TBL_TERM_INF set TERM_BRANCH='" + tmp.getBankNo()
                        + "' where mcht_cd = '" + tmp.getMchtNo() + "'";
                String update6 = "update TBL_TERM_INF_TMP set TERM_BRANCH='" + tmp.getBankNo()
                        + "' where mcht_cd = '" + tmp.getMchtNo() + "'";
                commQueryDAO.excute(update0);
                commQueryDAO.excute(update1);
                commQueryDAO.excute(update2);
                commQueryDAO.excute(update3);
                commQueryDAO.excute(update4);
                commQueryDAO.excute(update5);
                commQueryDAO.excute(update6);
            }
        } else if (status.equals(TblMchntInfoConstants.MCHNT_ST_RCV_UNCK)) {//??? 
            String update0 = "update TBL_ALARM_MCHT set BLOCK_MCHT_FLAG='0' where CARD_ACCP_ID='"
                    + tmp.getMchtNo() + "' ";
            commQueryDAO.excute(update0);
        }

        // ID?ID?
        if (mchntId.contains("AAA")) {
            String updateRefuse = "update tbl_Mchnt_Refuse set mchnt_id='" + newMchtNo + "' where mchnt_id='"
                    + mchntId + "'";
            commQueryDAO.excute(updateRefuse);
        }
        //TBL_INF_DISC_CD.DISC_NM
        String updateDiscCd = "UPDATE TBL_INF_DISC_CD SET DISC_NM='" + tmp.getMchtFunction().trim()
                + "',REC_UPD_TS='" + CommonFunction.getCurrentDateTime() + "' WHERE DISC_CD='"
                + tmpSettle.getFeeRate().trim() + "'";
        commQueryDAO.excute(updateDiscCd);
        String updateHisDisc = "UPDATE TBL_HIS_DISC_ALGO A SET A.REC_UPD_TS='"
                + CommonFunction.getCurrentDateTime() + "' WHERE A.DISC_ID='" + tmpSettle.getFeeRate().trim()
                + "'";
        commQueryDAO.excute(updateHisDisc);
        if (TblMchntInfoConstants.MCHNT_ST_NEW_UNCK.equals(status)) {
            //?TBL_INF_DISC_CD_MIRROR,TBL_HIS_DISC_ALGO_MIRROR??
            String updateDiscMirror = "INSERT INTO TBL_INF_DISC_CD_MIRROR A SELECT * FROM TBL_INF_DISC_CD B WHERE B.DISC_CD='"
                    + tmpSettle.getFeeRate().trim() + "'";
            commQueryDAO.excute(updateDiscMirror);
            String updateHisDiscMirror = "INSERT INTO TBL_HIS_DISC_ALGO_MIRROR A SELECT * FROM TBL_HIS_DISC_ALGO B WHERE B.DISC_ID='"
                    + tmpSettle.getFeeRate().trim() + "'";
            commQueryDAO.excute(updateHisDiscMirror);
        }

        //?
        iTblMchtBaseInfTmpLogDAO.saveOrUpdate((TblMchtBaseInfTmpLog) ret[0]);
        if (FrontMcht.TXN_CODE_ADDACCT.equals(txnCode)) {// ??
            addOprInfo(newMchtNo);
        }

        //List<TblTermKey> termKeyList=tblTermKeyDAO.getByMchnt(mchntId);
        //         if(termKeyList!=null&&termKeyList.size()!=0){

        //            for (TblTermKey tblTermKey : termKeyList) {
        //? 
        List<TblTermInfTmp> list = null;
        String currentDateTime = CommonFunction.getCurrentDateTime();
        if (!"4".equals(status)) {
            list = tblTermInfTmpDAO.getByMchntAll(mchntId);
            tblTermKeyDAO.updateByTremId(mchntId, newMchtNo, currentDateTime);
        }
        //               String termId = tblTermKey.getId().getTermId();
        //               tblTermKey.setRecUpdTs(CommonFunction.getCurrentDateTime());
        //            }
        //         }
        //termkey
        // 
        if (list != null && list.size() != 0) {
            for (TblTermInfTmp tblTermInfTmp : list) {

                TblTermInf termInf;

                //??
                TblTermInf tblTermInfOld = tblTermInfDAO.get(tblTermInfTmp.getId().getTermId());
                if (tblTermInfOld != null) {
                    tblTermInfOld = (TblTermInf) tblTermInfTmp.cloneHasExists(tblTermInfOld);
                    termInf = tblTermInfOld;
                    tblTermInfTmp.setMisc1(tblTermInfOld.getMisc1());
                    tblTermInfTmp.setProductCd(tblTermInfOld.getProductCd());
                } else {
                    termInf = new TblTermInf();
                    termInf = (TblTermInf) tblTermInfTmp.clone();
                }
                termInf.setTermSerialNum(tblTermInfTmp.getTermSerialNum());
                termInf.setTermPara(tblTermInfTmp.getTermPara().replaceAll("\\|", ""));
                if (tblTermInfTmp.getMisc2() != null && !tblTermInfTmp.getMisc2().equals("")) {
                    EposMisc epos = new EposMisc(termInf.getMisc2());
                    epos.setVersion(tblTermInfTmp.getMisc2());
                    termInf.setMisc2(epos.toString());
                }
                //814???YYYYMMDD YYYYMMDDHHMMSS
                //tblTermInf.setRecUpdTs(CommonFunction.getCurrentDate());
                termInf.setRecUpdTs(CommonFunction.getCurrentDateTime());
                Operator opra = (Operator) ServletActionContext.getRequest().getSession()
                        .getAttribute(Constants.OPERATOR_INFO);
                termInf.setRecUpdOpr(opra.getOprId());
                //mis?7---
                if (!"7".equals(tblTermInfTmp.getTermSta())) {
                    termInf.setTermSta("1");
                    tblTermInfTmp.setTermSta("1");
                }

                tblTermInfTmp.setRecUpdOpr(opra.getOprId());
                tblTermInfTmp.setRecUpdTs(CommonFunction.getCurrentDateTime());
                tblTermInfTmp.setMchtCd(newMchtNo);
                tblTermInfTmpDAO.update(tblTermInfTmp);

                termInf.setMchtCd(newMchtNo);
                tblTermInfDAO.saveOrUpdate(termInf);
                if (mchntId.contains("AAA")) {
                    //?
                    TblRiskParamMng termRiskParamMngNew = new TblRiskParamMng();
                    TblRiskParamMngPK riskParamMngPK = new TblRiskParamMngPK(newMchtNo,
                            tblTermInfTmp.getId().getTermId(), "1");
                    TblRiskParamMng termRiskParamMng = tblRiskParamMngDAO.get(mchntId,
                            CommonFunction.fillString(tblTermInfTmp.getId().getTermId(), ' ', 12, true), "1");
                    if (termRiskParamMng == null) {
                        termRiskParamMngNew.setId(riskParamMngPK);
                        termRiskParamMngNew.setCreditDayAmt(0.0);
                        termRiskParamMngNew.setCreditMonAmt(0.0);
                        termRiskParamMngNew.setCreditSingleAmt(tblRiskParamMng.getCreditSingleAmt());
                        termRiskParamMngNew.setDebitDayAmt(0.0);
                        termRiskParamMngNew.setDebitMonAmt(0.0);
                        termRiskParamMngNew.setDebitSingleAmt(tblRiskParamMng.getDebitSingleAmt());
                        tblRiskParamMngDAO.saveOrUpdate(termRiskParamMngNew);
                    } else {
                        termRiskParamMngNew = (TblRiskParamMng) org.apache.commons.beanutils.BeanUtils
                                .cloneBean(termRiskParamMng);
                        termRiskParamMngNew.setId(riskParamMngPK);
                        tblRiskParamMngDAO.delete(termRiskParamMng);
                        tblRiskParamMngDAO.saveOrUpdate(termRiskParamMngNew);
                    }
                }

            }
        } ////

        //??
        if (!mchntId.equals(newMchtNo)) {
            //List<TblMchtBaseInfTmpHist> histList=tblMchtBaseInfTmpHistDAO.getByMchtNo(mchntId);
            tblMchtBaseInfTmpHistDAO.updateByMchtNo(newMchtNo, mchntId);
            tblMchtSettleInfTmpHistDAO.updateByMchtNo(newMchtNo, mchntId);
        }
        // ?
        if (mchntId.contains("AAA")) {
            tblMchtBaseInfTmpDAO.delete(mchntId);
            tblMchtSettleInfTmpDAO.delete(mchntId);
        }
        //         tblMchtBaseInfDAO.delete(mchntId);
        //         tblMchtSettleInfDAO.delete(mchntId);

        if (tmp.getMchtNo().contains("AAA")) {
            String sql1 = "update TBL_MCHT_BASE_INF_TMP_HIST set MCHT_NO='" + inf.getMchtNo()
                    + "' where MCHT_NO = '" + tmp.getMchtNo() + "'";
            String sql2 = "update TBL_MCHT_SETTLE_INF_TMP_HIST set MCHT_NO='" + inf.getMchtNo()
                    + "' where MCHT_NO = '" + tmpSettle.getMchtNo() + "'";
            commQueryDAO.excute(sql1);
            commQueryDAO.excute(sql2);
        }

        if (mchntId.contains("AAA")) { //?
            inf.setOpenVirtualAcctFlag("1");
            tmp.setOpenVirtualAcctFlag("1");
        }
        inf.setMchtNo(newMchtNo);
        infSettle.setMchtNo(newMchtNo);
        tmp.setMchtNo(newMchtNo);
        tmpSettle.setMchtNo(newMchtNo);

        tblMchtSettleInfDAO.saveOrUpdate(infSettle);
        tblMchtBaseInfTmpDAO.saveOrUpdate(tmp);
        tblMchtBaseInfDAO.saveOrUpdate(inf);
        tblMchtSettleInfTmpDAO.saveOrUpdate(tmpSettle);
        tblMchntRefuseDAO.save(refuse);

        // 
        String basePath = SysParamUtil.getParam(SysParamConstants.FILE_UPLOAD_DISK);
        basePath = basePath.replace("\\", "/");
        String basePathOld = basePath + mchntId + "/";
        for (int i = 0; i < 11; i++) {
            String upload = "upload";
            if (i == 0) {
                upload += "/";
            } else
                upload = upload + i + "/";
            File deleteFile = new File(basePathOld + upload);
            if (deleteFile.exists()) {
                String basePathNew = basePath + newMchtNo + "/" + upload;
                File writeFile = new File(basePathNew);
                if (!writeFile.exists()) {
                    writeFile.mkdirs();
                }

                FileFilter filter = new FileFilter(mchntId);
                File[] files = deleteFile.listFiles(filter);
                for (File file : files) {
                    file.renameTo(new File(basePathNew + file.getName().replaceAll(mchntId, newMchtNo)));// 
                }

                deleteFile.delete();
            }
            // 

        }
        return Constants.SUCCESS_CODE;
    }
    return retMsg;

}

From source file:jp.ikedam.jenkins.plugins.ldap_sasl.LdapSaslSecurityRealm.java

/**
 * Constructor instantiating with parameters in the configuration page.
 * //from   ww  w.  ja  v  a  2  s  . c  om
 * When instantiating from the saved configuration,
 * the object is directly serialized with XStream,
 * and no constructor is used.
 * 
 * @param ldapUriList the URIs of LDAP servers.
 * @param mechanisms the whitespace separated list of mechanisms.
 * @param resolveGroup the configuration of group resolving
 * @param connectionTimeout the timeout of the LDAP server connection.
 * @param readTimeout the timeout of the LDAP server reading.
 */
@DataBoundConstructor
public LdapSaslSecurityRealm(List<String> ldapUriList, String mechanisms, UserDnResolver userDnResolver,
        GroupResolver groupResolver, int connectionTimeout, int readTimeout) {
    this.ldapUriList = new ArrayList<String>();
    if (ldapUriList != null) {
        for (String ldapUri : ldapUriList) {
            if (!StringUtils.isBlank(ldapUri)) {
                this.ldapUriList.add(StringUtils.trim(ldapUri));
            }
        }
    }

    List<String> mechanismList = (mechanisms != null) ? Arrays.asList(mechanisms.split(SEPERATOR_PATTERN))
            : new ArrayList<String>(0);
    this.mechanismList = new ArrayList<String>();
    for (String mechanism : mechanismList) {
        if (!StringUtils.isBlank(mechanism)) {
            this.mechanismList.add(StringUtils.trim(mechanism));
        }
    }
    this.userDnResolver = userDnResolver;
    this.groupResolver = groupResolver;
    this.connectionTimeout = connectionTimeout;
    this.readTimeout = readTimeout;
}