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

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

Introduction

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

Prototype

public static String abbreviate(String str, int maxWidth) 

Source Link

Document

Abbreviates a String using ellipses.

Usage

From source file:com.fortify.processrunner.tfs.processor.ProcessorTFSSubmitIssueForVulnerabilities.java

@Override
protected SubmittedIssue submitIssue(Context context, LinkedHashMap<String, Object> issueData) {
    IContextTFS contextTFS = context.as(IContextTFS.class);
    TFSRestConnection conn = TFSConnectionFactory.getConnection(context);
    issueData.put("System.Title", StringUtils.abbreviate((String) issueData.get("System.Title"), 254));
    String workItemType = getWorkItemType(contextTFS);
    fieldRenamer.renameFields(workItemType, issueData);
    return conn.submitIssue(contextTFS.getTFSCollection(), contextTFS.getTFSProject(), workItemType, issueData);
}

From source file:net.shopxx.plugin.unionpayPayment.UnionpayPaymentPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    Setting setting = SystemUtils.getSetting();
    PluginConfig pluginConfig = getPluginConfig();
    PaymentLog paymentLog = getPaymentLog(sn);
    Map<String, String> parameterMap = new HashMap<String, String>();
    parameterMap.put("txnType", "01");
    parameterMap.put("channelType", "07");
    parameterMap.put("currencyCode", CURRENCY);
    parameterMap.put("merId", pluginConfig.getAttribute("partner"));
    parameterMap.put("txnSubType", "01");
    parameterMap.put("txnAmt", paymentLog.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
    parameterMap.put("version", getVersion());
    parameterMap.put("signMethod", "01");
    parameterMap.put("bizType", "000201"); //B2Cwap
    parameterMap.put("encoding", getRequestCharset());
    parameterMap.put("origQryId", "");
    parameterMap.put("merAbbr",
            StringUtils.abbreviate(setting.getSiteName().replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 40));
    parameterMap.put("orderId", sn);
    parameterMap.put("txnTime", DateFormatUtils.format(new Date(), "yyyyMMddHHmmss"));
    parameterMap.put("accessType", "0");
    //parameterMap.put("orderTimeout", "10080000");
    parameterMap.put("frontUrl", getNotifyUrl(PaymentPlugin.NotifyMethod.sync));
    parameterMap.put("backUrl", "http://wwww.specialurl.com/");//???
    Map<String, String> submitStringData = AcpService.sign(parameterMap, getRequestCharset()); //certId,signaturesignData???????
    Map<String, Object> submitObjectData = new HashMap<>();
    for (String key : submitStringData.keySet()) {
        submitObjectData.put(key, submitStringData.get(key));
    }/*from   www  .j  a  v a  2  s . c om*/
    return submitObjectData;
}

From source file:com.haulmont.cuba.gui.ScreenHistorySupport.java

public void saveScreenHistory(Window window, WindowManager.OpenMode openMode) {
    Security security = AppBeans.get(Security.NAME);
    if (security.isEntityOpPermitted(ScreenHistoryEntity.class, EntityOp.CREATE) && window.getFrame() != null
            && (window.getFrame() instanceof Window.Editor) && openMode != WindowManager.OpenMode.DIALOG
            && (screenIds == null || screenIds.contains(window.getId()))) {
        String caption = window.getCaption();
        UUID entityId = null;/*w  ww .  ja v  a  2  s.c  o m*/
        Frame frame = window.getFrame();
        Entity entity = null;
        if (frame instanceof Window.Editor) {
            entity = ((Window.Editor) frame).getItem();
            if (entity != null) {
                if (PersistenceHelper.isNew(entity)) {
                    return;
                }
                if (StringUtils.isBlank(caption))
                    caption = messages.getTools().getEntityCaption(entity.getMetaClass()) + " "
                            + entity.getInstanceName();
                entityId = (UUID) entity.getId();
            }
        }
        ScreenHistoryEntity screenHistoryEntity = metadata.create(ScreenHistoryEntity.class);
        screenHistoryEntity.setCaption(StringUtils.abbreviate(caption, 255));
        screenHistoryEntity.setUrl(makeLink(window));
        screenHistoryEntity.setEntityId(entityId);
        addAdditionalFields(screenHistoryEntity, entity);

        CommitContext cc = new CommitContext(Collections.singleton(screenHistoryEntity));
        DataService dataService = AppBeans.get(DataService.NAME);
        dataService.commit(cc);
    }
}

From source file:de.fu_berlin.inf.dpp.activities.serializable.TextEditActivityDataObject.java

@Override
public String toString() {
    return "TextEditActivityDataObject(" + this.offset + ",new:'"
            + Utils.escapeForLogging(StringUtils.abbreviate(this.text, 150)) + "',old:'"
            + Utils.escapeForLogging(StringUtils.abbreviate(this.replacedText, 150)) + "',path:"
            + this.path.toString() + ",src:" + this.source + ")";
}

From source file:mobi.chouette.model.Line.java

/**
 * set published name <br/>/*from w  w w.  j a va 2 s. c  om*/
 * truncated to 255 characters if too long
 * 
 * @param value
 *            New value
 */
public void setPublishedName(String value) {
    publishedName = StringUtils.abbreviate(value, 255);
}

From source file:mobi.chouette.model.NeptuneLocalizedObject.java

/**
 * set city name <br/>/*from  w w w  . j  ava2  s. co m*/
 * truncated to 255 characters if too long
 * 
 * @param value
 *            New value
 */
public void setCityName(String value) {
    cityName = StringUtils.abbreviate(value, 255);
}

From source file:gov.nih.nci.caarray.web.action.project.ProjectTabAction.java

/**
 * Helper method for creating and saving appropriate error message when a
 * write operation on a project causes a inconsistent state exception.
 * @param e the exception containing information about the inconsistency
 *///from  w w  w  . java 2s  .co m
protected void handleInconsistentStateError(InconsistentProjectStateException e) {
    List<String> args = new ArrayList<String>();
    args.add(StringUtils.abbreviate(getProject().getExperiment().getTitle(), TRUNCATED_TITLE_WIDTH));
    if (e.getReason() == Reason.INCONSISTENT_ARRAY_DESIGNS) {
        addFieldError("project.experiment.arrayDesigns",
                getText("project.inconsistentState." + e.getReason().name().toLowerCase(),
                        new String[] { StringUtils.join(e.getArguments(), ", ") }));
    } else if (e.getReason() == Reason.ARRAY_DESIGNS_DONT_MATCH_MANUF_OR_TYPE) {
        addFieldError("project.experiment.arrayDesigns",
                getText("project.inconsistentState." + e.getReason().name().toLowerCase()));

    } else {
        addActionError(getText("project.inconsistentState." + e.getReason().name().toLowerCase()));
    }
}

From source file:net.shopxx.plugin.abcPayment.AbcPaymentPlugin.java

@Override
public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) {
    Setting setting = SystemUtils.getSetting();
    PluginConfig pluginConfig = getPluginConfig();
    PaymentLog paymentLog = getPaymentLog(sn);

    Document document = DocumentHelper.createDocument();
    Element msg = document.addElement("MSG");
    Element message = msg.addElement("Message");

    Element merchant = message.addElement("Merchant");
    merchant.addElement("ECMerchantType").setText("B2C");
    merchant.addElement("MerchantID").setText(pluginConfig.getAttribute("merchantId"));

    Element trxRequest = message.addElement("TrxRequest");
    trxRequest.addElement("TrxType").setText("PayReq");

    Element order = trxRequest.addElement("Order");
    order.addElement("OrderNo").setText(sn);
    order.addElement("ExpiredDate").setText("7");
    order.addElement("OrderAmount").setText(paymentLog.getAmount().setScale(2).toString());
    order.addElement("OrderDesc").setText(StringUtils.abbreviate(description, 60));
    order.addElement("OrderDate").setText(DateFormatUtils.format(new Date(), "yyyy/MM/dd"));
    order.addElement("OrderTime").setText(DateFormatUtils.format(new Date(), "HH:mm:ss"));
    order.addElement("OrderURL").setText(setting.getSiteUrl());
    order.addElement("BuyIP").setText(request.getRemoteAddr());
    order.addElement("OrderItems");

    trxRequest.addElement("ProductType").setText("2");
    trxRequest.addElement("PaymentType").setText("A");
    trxRequest.addElement("NotifyType").setText("1");
    trxRequest.addElement("ResultNotifyURL").setText(getNotifyUrl(PaymentPlugin.NotifyMethod.async));
    trxRequest.addElement("MerchantRemarks").setText("shopxx");
    trxRequest.addElement("PaymentLinkType").setText("1");

    msg.addElement("Signature-Algorithm").setText("SHA1withRSA");
    msg.addElement("Signature").setText(generateSign(merchant.asXML() + trxRequest.asXML()));

    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("Signature", document.getRootElement().asXML());
    parameterMap.put("errorPage", setting.getSiteUrl());
    return parameterMap;
}

From source file:de.tudarmstadt.lt.n2n.annotators.ExpansionsPrinter.java

@Override
public void process(JCas aJCas) throws AnalysisEngineProcessException {
    _printstream.format("=== %s begin [%s] ===%n%n", getClass().getSimpleName(),
            StringUtils.abbreviate(aJCas.getDocumentText(), 30).replace("\n", ""));
    for (Annotation target_instance : JCasUtil.select(aJCas, _target_annotation_type)) {
        _printstream.format("%s%n  DT:%n", target_instance.getCoveredText());
        for (DistributionalExpansions expansions_for_instance_part : JCasUtil
                .selectCovered(DistributionalExpansions.class, target_instance)) {
            _printstream.format("    %-20.20s%n", expansions_for_instance_part.getCoveredText());
            List<DistributionalExpansion> dt_expansions = JCasUtil.selectCovered(DistributionalExpansion.class,
                    expansions_for_instance_part);
            int[] sorted_ids = ListUtils.sortIdsByValue(dt_expansions, _dt_expansions_comparator_desc); // sort expansions by dt value entry
            for (int i = 0; i < sorted_ids.length; i++) {
                DistributionalExpansion expansion_for_instance_part = dt_expansions.get(sorted_ids[i]);
                _printstream.format("      %-30.30s %.3f%n", expansion_for_instance_part.getKey(),
                        expansion_for_instance_part.getCount());
            }/*  ww  w  .j  a  v a2  s  .co m*/
        }

        _printstream.format("  CT:%n", target_instance.getCoveredText());
        for (ContextualExpansions expansions_for_instance_part : JCasUtil
                .selectCovered(ContextualExpansions.class, target_instance)) {
            _printstream.format("    %-20.20s%n", expansions_for_instance_part.getCoveredText());
            List<ContextualExpansion> ct_expansions = JCasUtil.selectCovered(ContextualExpansion.class,
                    expansions_for_instance_part);
            int[] sorted_ids = ListUtils.sortIdsByValue(ct_expansions, _ct_expansions_comparator_desc); // sort expansions by ct and dt value entries
            for (int i = 0; i < sorted_ids.length; i++) {
                ContextualExpansion expansion_for_instance_part = ct_expansions.get(sorted_ids[i]);
                _printstream.format("      %-30.30s %6.3e (%.3f)%n", expansion_for_instance_part.getKey(),
                        expansion_for_instance_part.getCtScore(), expansion_for_instance_part.getDtScore());
            }
        }
        _printstream.println();
    }
    _printstream.format("=== %s begin ===%n%n", getClass().getSimpleName());
}

From source file:com.dianping.swallow.broker.monitor.DefaultNotifyService.java

@Override
public void recover(String msg, boolean sendSms) {
    log.info(MAIL_RECOVERY_TITLE + " : " + msg);

    if (!devMode) {
        StringBuilder body = new StringBuilder();
        body.append("<strong>").append(msg).append("</strong><br/>");
        body.append("<br/>");
        try {/*w w  w  .j a  va  2 s  .  c om*/
            this.alarmService.sendEmail(body.toString(), MAIL_RECOVERY_TITLE + "_" + localIP, getMailTos());
            if (sendSms) {
                List<String> numbers = getPhoneNums();
                if (numbers != null && numbers.size() > 0) {
                    this.alarmService.sendSmsMessage("[swallow-broker Recovery]" + "_" + localIP + ":"
                            + StringUtils.abbreviate(msg, 1000), numbers);
                }
            }
        } catch (Exception e) {
            log.warn("Alarm failed. BODY: " + body);
        }
    }
}