コード例 #1
0
ファイル: Pay99billPlugin.java プロジェクト: choelea/EShop
 @Override
 public Map<String, Object> getParameterMap(
     String sn, String description, HttpServletRequest request) {
   PluginConfig pluginConfig = getPluginConfig();
   Payment payment = getPayment(sn);
   Map<String, Object> parameterMap = new LinkedHashMap<String, Object>();
   parameterMap.put("inputCharset", "1");
   parameterMap.put("pageUrl", getNotifyUrl(sn, NotifyMethod.sync));
   parameterMap.put("bgUrl", getNotifyUrl(sn, NotifyMethod.async));
   parameterMap.put("version", "v2.0");
   parameterMap.put("language", "1");
   parameterMap.put("signType", "1");
   parameterMap.put("merchantAcctId", pluginConfig.getAttribute("partner"));
   parameterMap.put("payerIP", request.getLocalAddr());
   parameterMap.put("orderId", sn);
   parameterMap.put(
       "orderAmount", payment.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
   parameterMap.put("orderTime", new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()));
   parameterMap.put("orderTimestamp", new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()));
   parameterMap.put(
       "productName",
       StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 100));
   parameterMap.put(
       "productDesc",
       StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 400));
   parameterMap.put("ext1", "eshop");
   parameterMap.put("payType", "00");
   parameterMap.put("signMsg", generateSign(parameterMap));
   return parameterMap;
 }
コード例 #2
0
 public Prediction createPrediction(SecurityContext sec, Prediction pred) {
   User user = securityCheck(sec, Roles.CREATE_PREDICTION);
   pred.setTags(TextUtils.tag(pred.getTags()));
   int id;
   pred = InputSanitizer.sanitize(pred);
   if (StringUtils.isBlank(pred.getSourceAuthor())) {
     pred.setType(Prediction.PredictionType.quote.name());
   } else {
     pred.setType(Prediction.PredictionType.prediction.name());
   }
   if (pred.getTitle() == null || pred.getTitle().trim().isEmpty()) {
     pred.setTitle(StringUtils.abbreviate(pred.getText(), 64));
   } else {
     pred.setTitle(StringUtils.abbreviate(pred.getTitle(), 64));
   }
   pred.setText(StringUtils.abbreviate(pred.getText(), MAX_PREDICTION_LENGTH));
   if (sec != getAdminSecurityContext()) {
     pred.setCreatedByUserId(user.getId());
     pred.setCreatedByUser(user.getFullName());
   }
   pred.setTime(TextUtils.getProbablePredictionTime(pred.getText()));
   id = db.createPrediction(pred);
   pred.setId(id);
   return db.getPrediction(id);
 }
コード例 #3
0
 @Override
 public String toString() {
   return "TextEditActivity("
       + 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
       + ")";
 }
コード例 #4
0
ファイル: Twitter.java プロジェクト: cvanorman/openhab
  /**
   * Sends a direct message via Twitter
   *
   * @param recipientId the receiver of this direct message
   * @param messageTxt the direct message to send
   * @return <code>true</code>, if sending the direct message has been successful and <code>false
   *     </code> in all other cases.
   */
  @ActionDoc(
      text = "Sends a direct message via Twitter",
      returns =
          "<code>true</code>, if sending the direct message has been successful and <code>false</code> in all other cases.")
  public static boolean sendDirectMessage(
      @ParamDoc(name = "recipientId", text = "the receiver of this direct message")
          String recipientId,
      @ParamDoc(name = "messageTxt", text = "the direct message to send") String messageTxt) {
    if (!isEnabled) {
      logger.debug("Twitter client is disabled > execution aborted!");
      return false;
    }

    try {
      // abbreviate the Tweet to meet the 140 character limit ...
      messageTxt = StringUtils.abbreviate(messageTxt, CHARACTER_LIMIT);
      // send the direct message
      DirectMessage message = client.sendDirectMessage(recipientId, messageTxt);
      logger.debug(
          "Successfully sent direct message '{}' to @",
          message.getText(),
          message.getRecipientScreenName());
      return true;
    } catch (TwitterException e) {
      logger.error(
          "Failed to send Tweet '" + messageTxt + "' because of: " + e.getLocalizedMessage());
      return false;
    }
  }
コード例 #5
0
ファイル: ResourceModel.java プロジェクト: Zidanela/sonar-git
 /** Sets the long name of the resource, truncated to NAME_COLUMN_SIZE */
 public void setLongName(String s) {
   if (StringUtils.isBlank(s)) {
     this.longName = name;
   } else {
     this.longName = StringUtils.abbreviate(s, NAME_COLUMN_SIZE);
   }
 }
コード例 #6
0
ファイル: Twitter.java プロジェクト: cvanorman/openhab
  /**
   * Sends a Tweet via Twitter
   *
   * @param tweetTxt the Tweet to send
   * @return <code>true</code>, if sending the tweet has been successful and <code>false</code> in
   *     all other cases.
   */
  @ActionDoc(
      text = "Sends a Tweet via Twitter",
      returns =
          "<code>true</code>, if sending the tweet has been successful and <code>false</code> in all other cases.")
  public static boolean sendTweet(
      @ParamDoc(name = "tweetTxt", text = "the Tweet to send") String tweetTxt) {
    if (!TwitterActionService.isProperlyConfigured) {
      logger.debug("Twitter client is not yet configured > execution aborted!");
      return false;
    }
    if (!isEnabled) {
      logger.debug("Twitter client is disabled > execution aborted!");
      return false;
    }

    try {
      // abbreviate the Tweet to meet the 140 character limit ...
      tweetTxt = StringUtils.abbreviate(tweetTxt, CHARACTER_LIMIT);
      // send the Tweet
      Status status = client.updateStatus(tweetTxt);
      logger.debug("Successfully sent Tweet '{}'", status.getText());
      return true;
    } catch (TwitterException e) {
      logger.error(
          "Failed to send Tweet '" + tweetTxt + "' because of: " + e.getLocalizedMessage());
      return false;
    }
  }
コード例 #7
0
ファイル: QQWeibo.java プロジェクト: nyer/sns
 @Override
 public WeiboResponse publish(
     OAuthTokenPair accessTokenPair, String title, String message, String url, String clientIP) {
   Map<String, String> additionalParams = new HashMap<String, String>();
   additionalParams.put("content", StringUtils.abbreviate(message, 140));
   additionalParams.put("format", "json");
   return this.protocal.post(PUBLISH_URL, additionalParams, accessTokenPair);
 }
コード例 #8
0
ファイル: UnionpayPlugin.java プロジェクト: nabolen/SVN-HYDOM
 @Override
 public Map<String, Object> getParameterMap(
     String sn, String description, HttpServletRequest request) {
   Setting setting = SettingUtils.get();
   PluginConfig pluginConfig = getPluginConfig();
   Payment payment = getPayment(sn);
   Map<String, Object> parameterMap = new HashMap<String, Object>();
   parameterMap.put("version", "1.0.0");
   parameterMap.put("charset", "UTF-8");
   parameterMap.put("transType", "01");
   parameterMap.put("origQid", "");
   parameterMap.put("merId", pluginConfig.getAttribute("partner"));
   parameterMap.put(
       "merAbbr",
       StringUtils.abbreviate(
           setting.getSiteName().replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 40));
   parameterMap.put("acqCode", "");
   parameterMap.put("merCode", "");
   parameterMap.put("commodityUrl", setting.getSiteUrl());
   parameterMap.put(
       "commodityName",
       StringUtils.abbreviate(description.replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 200));
   parameterMap.put("commodityUnitPrice", "");
   parameterMap.put("commodityQuantity", "");
   parameterMap.put("commodityDiscount", "");
   parameterMap.put("transferFee", "");
   parameterMap.put("orderNumber", sn);
   parameterMap.put(
       "orderAmount", payment.getAmount().multiply(new BigDecimal(100)).setScale(0).toString());
   parameterMap.put("orderCurrency", CURRENCY);
   parameterMap.put("orderTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
   parameterMap.put("customerIp", request.getLocalAddr());
   parameterMap.put("customerName", "");
   parameterMap.put("defaultPayType", "");
   parameterMap.put("defaultBankNumber", "");
   parameterMap.put("transTimeout", getTimeout() * 60000);
   parameterMap.put("frontEndUrl", getNotifyUrl(sn, NotifyMethod.sync));
   parameterMap.put("backEndUrl", getNotifyUrl(sn, NotifyMethod.async));
   parameterMap.put("merReserved", "");
   parameterMap.put("signMethod", "MD5");
   parameterMap.put("signature", generateSign(parameterMap));
   return parameterMap;
 }
コード例 #9
0
 @Override
 public SimpleFeature apply(
     ImportTask task, DataStore dataStore, SimpleFeature oldFeature, SimpleFeature feature)
     throws Exception {
   Object origDesc = feature.getAttribute("description");
   if (origDesc == null) {
     return feature;
   }
   String newDesc = StringUtils.abbreviate(origDesc.toString(), 255);
   feature.setAttribute("description", newDesc);
   return feature;
 }
コード例 #10
0
 void add(WikipediaRuleMatch ruleMatch) {
   String sql =
       "INSERT INTO feed_matches "
           + "(title, language_code, rule_id, rule_sub_id, rule_description, rule_message, rule_category, error_context, edit_date, diff_id) "
           + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
   try (PreparedStatement prepSt = conn.prepareStatement(sql)) {
     prepSt.setString(1, StringUtils.abbreviate(ruleMatch.getTitle(), 255));
     prepSt.setString(2, ruleMatch.getLanguage().getShortName());
     prepSt.setString(3, ruleMatch.getRule().getId());
     if (ruleMatch.getRule() instanceof PatternRule) {
       prepSt.setString(4, ((PatternRule) ruleMatch.getRule()).getSubId());
     } else {
       prepSt.setString(4, null);
     }
     prepSt.setString(5, StringUtils.abbreviate(ruleMatch.getRule().getDescription(), 255));
     prepSt.setString(6, StringUtils.abbreviate(ruleMatch.getMessage(), 255));
     if (ruleMatch.getRule().getCategory() != null) {
       prepSt.setString(
           7, StringUtils.abbreviate(ruleMatch.getRule().getCategory().getName(), 255));
     } else {
       prepSt.setString(7, "<no category>");
     }
     prepSt.setString(8, StringUtils.abbreviate(ruleMatch.getErrorContext(), 500));
     prepSt.setTimestamp(9, new Timestamp(ruleMatch.getEditDate().getTime()));
     prepSt.setLong(10, ruleMatch.getDiffId());
     prepSt.execute();
   } catch (SQLException e) {
     if (e.toString().contains("Incorrect string value")) {
       // Let's accept this - i.e. not crash - for now:
       // See http://stackoverflow.com/questions/1168036/ and
       // http://stackoverflow.com/questions/10957238/
       System.err.println(
           "Could not add rule match " + ruleMatch + " to database - stacktrace follows:");
       e.printStackTrace();
     } else {
       throw new RuntimeException("Could not add rule match " + ruleMatch + " to database", e);
     }
   }
 }
コード例 #11
0
  @Override
  public T getValue() {

    if (actualValue != null) {
      return actualValue;
    }

    if (valueForStorageWhenNotEncoded != null) {
      actualValue = valueForStorageWhenNotEncoded;
      return actualValue;
    }

    if (valueForStorageWhenEncoded != null) {
      if (prismContext == null) {
        throw new IllegalStateException(
            "PrismContext not set for SerializationSafeContainer holding "
                + StringUtils.abbreviate(valueForStorageWhenEncoded, MAX_WIDTH));
      }

      if (encodingScheme == EncodingScheme.PRISM) {
        try {
          PrismValue prismValue =
              prismContext.parserFor(valueForStorageWhenEncoded).xml().parseItemValue();
          actualValue = prismValue != null ? prismValue.getRealValue() : null;
        } catch (SchemaException e) {
          throw new SystemException(
              "Couldn't deserialize value from JAXB: "
                  + StringUtils.abbreviate(valueForStorageWhenEncoded, MAX_WIDTH),
              e);
        }
        return actualValue;
      } else {
        throw new IllegalStateException("Unexpected encoding scheme " + encodingScheme);
      }
    }

    return null;
  }
コード例 #12
0
ファイル: DetailsBox.java プロジェクト: gitools/gitools
  private Component createValueLabel(DetailsDecoration property, int maxLength) {

    String value = property.getFormatedValue();
    boolean abbreviate = (value.length() > maxLength);
    String abbreviatedValue;

    if (value.matches("[0-9\\.]+e-?[0-9]+")) {
      value =
          "<html><body>" + value.replaceAll("e(-?[0-9]+)", "·10<sup>$1</sup>") + "</body></html>";
    }

    if (abbreviate) {
      abbreviatedValue = StringUtils.abbreviate(value, maxLength);
    } else {
      abbreviatedValue = value;
    }

    WebLabel label;
    if (StringUtils.isEmpty(property.getValueLink())) {
      label = new WebLabel(abbreviatedValue);
    } else {
      DetailsWebLinkLabel webLabel = new DetailsWebLinkLabel(abbreviatedValue);
      webLabel.setLink(property.getValueLink(), false);
      label = webLabel;
    }

    SwingUtils.changeFontSize(label, -1);

    if (abbreviate) {
      TooltipManager.setTooltip(label, value, TooltipWay.down, 0);
    }

    label.setCursor(new Cursor(Cursor.HAND_CURSOR));
    label.addMouseListener(new PropertyMouseListener(property));

    if (property.isSelected()) {
      SwingUtils.setBoldFont(label);
    }

    if (property.getBgColor() != null) {
      WebPanel colorBox = new WebPanel();
      colorBox.setPreferredSize(new Dimension(15, 15));
      colorBox.setBackground(property.getBgColor());
      return new GroupPanel(4, colorBox, label);
    }

    label.setForeground(property.isVisible() ? Color.BLACK : Color.lightGray);
    return label;
  }
コード例 #13
0
ファイル: Log.java プロジェクト: jbigdata/tinyPlatform
 /**
  * 设置请求参数
  *
  * @param paramMap
  */
 @SuppressWarnings({"unchecked", "rawtypes"})
 public void setParams(Map paramMap) {
   if (paramMap == null) {
     return;
   }
   StringBuilder params = new StringBuilder();
   for (Map.Entry<String, String[]> param : ((Map<String, String[]>) paramMap).entrySet()) {
     params.append(("".equals(params.toString()) ? "" : "&") + param.getKey() + "=");
     String paramValue =
         (param.getValue() != null && param.getValue().length > 0 ? param.getValue()[0] : "");
     params.append(
         StringUtils.abbreviate(
             StringUtils.endsWithIgnoreCase(param.getKey(), "password") ? "" : paramValue, 100));
   }
   this.params = params.toString();
 }
コード例 #14
0
ファイル: TaskWorker.java プロジェクト: znepok/perecoder
 /**
  * Устанавливает параметры завершения задачи
  *
  * @param results результат задачи
  * @param resultStatus статус завершения
  * @param exception исключения, которое произошло в процессе выполнения
  */
 private void endTask(
     Map<String, Object> results, TaskResultStatus resultStatus, Throwable exception) {
   writeLock.lock();
   try {
     result.setContent(results);
     result.setStatus(resultStatus);
     if (exception != null) {
       result.setErrorMessage(
           StringUtils.abbreviate(exception.getMessage(), TaskResult.ERROR_MESSAGE_MAX_SIZE - 3));
     }
     result.setEndDate(new Date());
     executionLock.countDown();
     changeState(null, TaskExecutionStatus.READY);
   } finally {
     writeLock.unlock();
   }
 }
コード例 #15
0
ファイル: QQWeibo.java プロジェクト: nyer/sns
  @Override
  public WeiboResponse publishWithImage(
      OAuthTokenPair accessTokenPair,
      String title,
      String message,
      byte[] imgBytes,
      String imgName,
      String url,
      String clientIP) {
    Map<String, String> additionalParams = new HashMap<String, String>();
    additionalParams.put("content", StringUtils.abbreviate(message, 140));
    additionalParams.put("format", "json");

    MultipartEntity requestEntity = new MultipartEntity();
    requestEntity.addPart("pic", new ByteArrayBody(imgBytes, imgName));

    return this.protocal.post(URL_UPLOADIMG, additionalParams, requestEntity, accessTokenPair);
  }
コード例 #16
0
  @Override
  public void processPacket(Stanza packet) {
    LOGGER.info("got public key: " + StringUtils.abbreviate(packet.toXML().toString(), 300));

    PublicKeyPublish publicKeyPacket = (PublicKeyPublish) packet;

    if (publicKeyPacket.getType() == IQ.Type.set) {
      LOGGER.warning("ignoring public key packet with type 'set'");
      return;
    }

    if (publicKeyPacket.getType() == IQ.Type.result) {
      byte[] keyData = publicKeyPacket.getPublicKey();
      if (keyData == null) {
        LOGGER.warning("got public key packet without public key");
        return;
      }
      mControl.setPGPKey(publicKeyPacket.getFrom(), keyData);
    }
  }
コード例 #17
0
 @Override
 public String toString() {
   String jid = "<" + Utils.shortenJID(user.getJID(), 40) + ">";
   String name = StringUtils.abbreviate(user.getName(), 24);
   return name.isEmpty() ? jid : name + " " + jid;
 }
コード例 #18
0
ファイル: JDialogExc.java プロジェクト: njmube/Invoicex
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    labInt = new javax.swing.JLabel();
    labe = new javax.swing.JLabel();
    jButton1 = new javax.swing.JButton();
    jLabel3 = new javax.swing.JLabel();
    jButton2 = new javax.swing.JButton();

    FormListener formListener = new FormListener();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("Invoicex - Errore");

    labInt.setIcon(
        new javax.swing.ImageIcon(
            getClass()
                .getResource(
                    "/res/icons/tango-icon-theme-080/22x22/actions/process-stop.png"))); // NOI18N
    labInt.setText("Sì è verificato il seguente problema:");

    labe.setFont(labe.getFont().deriveFont(labe.getFont().getStyle() | java.awt.Font.BOLD));
    labe.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    labe.setText("...");
    if (e != null) labe.setText(StringUtils.abbreviate(e.getLocalizedMessage(), 100));

    jButton1.setFont(
        jButton1.getFont().deriveFont(jButton1.getFont().getStyle() | java.awt.Font.BOLD));
    jButton1.setText("Invia al programmatore");
    jButton1.addActionListener(formListener);

    jLabel3.setText(
        "Puoi inviarci la segnalazione dell'errore in modo da tentare di risolvere il problema.");

    jButton2.setText("Ignora");
    jButton2.addActionListener(formListener);

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .add(
                        layout
                            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(
                                labe,
                                org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                430,
                                Short.MAX_VALUE)
                            .add(
                                org.jdesktop.layout.GroupLayout.TRAILING,
                                layout
                                    .createSequentialGroup()
                                    .add(jButton2)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(jButton1))
                            .add(
                                jLabel3,
                                org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                430,
                                Short.MAX_VALUE)
                            .add(
                                labInt,
                                org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                430,
                                Short.MAX_VALUE))
                    .addContainerGap()));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .add(labInt)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(labe)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jLabel3)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 38, Short.MAX_VALUE)
                    .add(
                        layout
                            .createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jButton1)
                            .add(jButton2))
                    .addContainerGap()));

    pack();
  }
コード例 #19
0
ファイル: SignupEmailBase.java プロジェクト: yllyx/sakai
 /* Get the meeting title, max length of 30 chars (with ellipsis where required) */
 protected String getAbbreviatedMeetingTitle() {
   return StringUtils.abbreviate(meeting.getTitle(), 30);
 }
コード例 #20
0
ファイル: Graph.java プロジェクト: kevinpeterson/lexevs
 /**
  * Utility method to return the graph based node name for the given concept reference.
  *
  * @param code The concept code to visualize. If null, the code is not included in the returned
  *     name.
  * @param desc The concept description; can be null.
  * @param abbreviate If true, the text will be abbreviated if it exceeds a pre-defined limit (with
  *     '...' appended). This can be used to accomodate more nodes in horizontal space.
  * @param separator the String to use to separate the code from the description
  * @return The corresponding node name.
  */
 public static String getNodeName(String code, String desc, boolean abbreviate, String separator) {
   StringBuffer nameBuf = new StringBuffer(128);
   if (code != null) nameBuf.append('[').append(code.trim()).append("]").append(separator);
   if (StringUtils.isNotBlank(desc)) nameBuf.append(desc);
   return (abbreviate) ? StringUtils.abbreviate(nameBuf.toString(), 64) : nameBuf.toString();
 }
コード例 #21
0
ファイル: ResourceModel.java プロジェクト: Zidanela/sonar-git
 /** Sets the resource name, truncated to NAME_COLUMN_SIZE */
 public void setName(String name) {
   this.name = StringUtils.abbreviate(name, NAME_COLUMN_SIZE);
   if (this.longName == null) {
     this.longName = this.name;
   }
 }
コード例 #22
0
ファイル: ForumEntity.java プロジェクト: yllyx/sakai
  // returns SakaiId of thing just created
  public String importObject(
      String title,
      String topicTitle,
      String text,
      boolean texthtml,
      String base,
      String baseDir,
      String siteId,
      List<String> attachmentHrefs,
      boolean hide) {

    DiscussionForum ourForum = null;
    DiscussionTopic ourTopic = null;

    int forumtry = 0;
    int topictry = 0;

    for (; ; ) {

      ourForum = null;

      SortedSet<DiscussionForum> forums =
          new TreeSet<DiscussionForum>(new ForumBySortIndexAscAndCreatedDateDesc());
      for (DiscussionForum forum : discussionForumManager.getForumsForMainPage()) forums.add(forum);

      for (DiscussionForum forum : forums) {
        if (forum.getTitle().equals(title)) {
          ourForum = forum;
          break;
        }
      }

      if (ourForum == null) {
        if (forumtry > 0) {
          System.out.println("oops, forum still not there the second time");
          return null;
        }
        forumtry++;

        // if a new site, may need to create the area or we'll get a backtrace when creating forum
        areaManager.getDiscussionArea(siteId);

        ourForum = discussionForumManager.createForum();
        ourForum.setTitle(title);
        discussionForumManager.saveForum(siteId, ourForum);

        continue; // reread, better be there this time
      }

      // forum now exists, and was just reread

      ourTopic = null;

      for (Object o : ourForum.getTopicsSet()) {
        DiscussionTopic topic = (DiscussionTopic) o;
        if (topic.getTitle().equals(topicTitle)) {
          ourTopic = topic;
          break;
        }
      }

      if (ourTopic != null) // ok, forum and topic exist
      break;

      if (topictry > 0) {
        System.out.println("oops, topic still not there the second time");
        return null;
      }
      topictry++;

      // create it

      ourTopic = discussionForumManager.createTopic(ourForum);
      ourTopic.setTitle(topicTitle);

      if (attachmentHrefs != null && attachmentHrefs.size() > 0) {
        for (String href : attachmentHrefs) {
          // we don't have any real label for attachments. About all we can do is use the filename,
          // without path
          String label = href;
          int slash = label.lastIndexOf("/");
          if (slash >= 0) label = label.substring(slash + 1);
          if (label.equals("")) label = "Attachment";

          // basedir is a folder in contenthosting starting with /group/ where our content has been
          // loaded
          // discussionForum needs a Sakai content resource ID for the attachment
          Attachment thisDFAttach =
              discussionForumManager.createDFAttachment(removeDotDot(baseDir + href), label);
          ourTopic.addAttachment(thisDFAttach);
        }
      }

      String shortText = null;
      if (texthtml) {
        ourTopic.setExtendedDescription(text.replaceAll("\\$IMS-CC-FILEBASE\\$", base));
        shortText = FormattedText.convertFormattedTextToPlaintext(text);
      } else {
        ourTopic.setExtendedDescription(FormattedText.convertPlaintextToFormattedText(text));
        shortText = text;
      }
      shortText = org.apache.commons.lang.StringUtils.abbreviate(shortText, 254);

      ourTopic.setShortDescription(shortText);

      // there's a better way to do attachments, but it's too complex for now

      if (hide) discussionForumManager.saveTopicAsDraft(ourTopic);
      else discussionForumManager.saveTopic(ourTopic);

      // now go back and mmake sure everything is there

    }

    return "/" + FORUM_TOPIC + "/" + ourTopic.getId();
  }
コード例 #23
0
 private String getRef() {
   return StringUtils.abbreviate(StringUtils.join(Error.Reference, ", "), 22);
 }
コード例 #24
0
 public String getWrittenData() {
   return StringUtils.abbreviate(writtenData.toString(), MAX_DATA_LENGTH);
 }
コード例 #25
0
ファイル: AuditLogEntry.java プロジェクト: yghandor/ilves
 public AuditLogEntry(
     String event,
     String componentAddress,
     String componentType,
     String userAddress,
     String userId,
     String userName,
     String dataType,
     String dataId,
     String dataOldVersionId,
     String dataNewVersionId,
     String dataLabel,
     Date created) {
   this.event = StringUtils.abbreviate(event, 255);
   this.componentAddress = StringUtils.abbreviate(componentAddress, 60);
   this.componentType = StringUtils.abbreviate(componentType, 20);
   this.userAddress = StringUtils.abbreviate(userAddress, 60);
   this.userId = StringUtils.abbreviate(userId, 36);
   this.userName = StringUtils.abbreviate(userName, 40);
   this.dataType = StringUtils.abbreviate(dataType, 20);
   this.dataId = StringUtils.abbreviate(dataId, 36);
   this.dataOldVersionId = StringUtils.abbreviate(dataOldVersionId, 36);
   this.dataNewVersionId = StringUtils.abbreviate(dataNewVersionId, 36);
   this.dataLabel = StringUtils.abbreviate(dataLabel, 40);
   this.created = created;
 }
コード例 #26
0
 public String getSuperShortStory() {
   return StringUtils.abbreviate(story, 20);
 }
コード例 #27
0
ファイル: ResourceModel.java プロジェクト: Zidanela/sonar-git
 /** Sets the resource description, truncated to DESCRIPTION_COLUMN_SIZE */
 public void setDescription(String description) {
   this.description = StringUtils.abbreviate(description, DESCRIPTION_COLUMN_SIZE);
 }