예제 #1
0
  @Override
  public void postToFeed(final User user, final String message, final FeedType type)
      throws NimbitsException {
    final Point point = getFeedPoint(user);

    if (point != null) {
      final String shortened = message.length() > LENGTH ? message.substring(0, LENGTH) : message;

      final String finalMessage;
      try {
        finalMessage = generatePostToFeedHtml(shortened, message, type);
      } catch (UnsupportedEncodingException e) {
        throw new NimbitsException(e);
      }

      final FeedValue feedValue = new FeedValueModel(finalMessage, "", type);
      final String json = GsonFactory.getSimpleInstance().toJson(feedValue);
      final Value value =
          ValueModelFactory.createValueModel(
              0.0, 0.0, Const.CONST_IGNORED_NUMBER_VALUE, new Date(), "", json);
      final Value v = ValueModelFactory.createValueModel(value, json);

      RecordedValueServiceFactory.getInstance().recordValue(user, point, v, false);
    }
  }
예제 #2
0
 @Override
 public void postToFeed(
     final User user,
     final Entity entity,
     final Point originalPoint,
     final Value value,
     final FeedType type)
     throws NimbitsException {
   final Point point = getFeedPoint(user);
   if (point != null) {
     final FeedValue feedValue =
         new FeedValueModel(valueToHtml(entity, originalPoint, value), value.getData(), type);
     final String json = GsonFactory.getSimpleInstance().toJson(feedValue);
     final Value v = ValueModelFactory.createValueModel(value, json);
     RecordedValueServiceFactory.getInstance().recordValue(user, point, v, false);
   }
 }