@Override
 @Async
 public void addStatus(final Status status) {
   try {
     internalAddStatus(status);
   } catch (IOException e) {
     log.error(
         "The status wasn't added to the index: "
             + status.getStatusId()
             + " ["
             + status.toString()
             + "]",
         e);
   }
 }
Exemplo n.º 2
0
 @Override
 @CacheEvict(value = "status-cache", key = "#status.statusId")
 public void removeStatus(Status status) {
   status.setRemoved(true);
   if (log.isDebugEnabled()) {
     log.debug("Updating Status : " + status);
   }
   em.persist(status);
 }
Exemplo n.º 3
0
  @Async
  public void sendUserMentionEmail(Status status, User mentionnedUser) {
    if (log.isDebugEnabled()) {
      log.debug(
          "Sending Mention e-mail to User '"
              + mentionnedUser.getLogin()
              + "' with locale : '"
              + locale
              + "'");
    }
    String url =
        tatamiUrl + "/tatami/profile/" + status.getUsername() + "/#/status/" + status.getStatusId();

    Map<String, Object> model = new HashMap<String, Object>();
    model.put("user", mentionnedUser);
    model.put("status", status);
    model.put("statusUrl", url);

    sendTextFromTemplate(mentionnedUser, model, "userMention", this.locale);
  }
Exemplo n.º 4
0
  @Override
  @Cacheable("status-cache")
  public Status findStatusById(String statusId) {
    if (statusId == null || statusId.equals("")) {
      return null;
    }
    if (log.isDebugEnabled()) {
      log.debug("Finding status : " + statusId);
    }
    Status status = em.find(Status.class, statusId);

    if (status != null) {
      // Find status's tags
      List<String> tags =
          getTags(keyspaceOperator, STATUS_CF, statusId, TAG_COLUMN_MIN_NAME, TAG_COLUMN_MAX_NAME);

      status.setTags(tags);

      status = Boolean.TRUE.equals(status.getRemoved()) ? null : status;
    }

    return status;
  }
  private void internalAddStatus(Status status) throws IOException {
    XContentBuilder jsonifiedObject;

    jsonifiedObject =
        XContentFactory.jsonBuilder()
            .startObject()
            .field("username", status.getUsername())
            .field("domain", status.getDomain())
            .field("statusDate", status.getStatusDate())
            .field("content", status.getContent())
            .endObject();

    addObject(status.getClass(), status.getStatusId(), jsonifiedObject);
  }
 @Override
 public void removeStatus(final Status status) {
   Assert.notNull(status, "status can't be null");
   removeObject(status.getClass(), status.getStatusId());
 }
Exemplo n.º 7
0
  @Override
  public Status createStatus(
      String login,
      String username,
      String domain,
      String content,
      String replyTo,
      String replyToUsername,
      List<String> tags)
      throws ConstraintViolationException {

    Status status = new Status();
    String statusId = TimeUUIDUtils.getUniqueTimeUUIDinMillis().toString();
    status.setStatusId(statusId);
    status.setLogin(login);
    status.setUsername(username);
    status.setDomain(domain);
    status.setContent(content);
    status.setStatusDate(Calendar.getInstance().getTime());
    status.setReplyTo(replyTo);
    status.setReplyToUsername(replyToUsername);
    status.setRemoved(false);
    status.setTags(tags);
    if (log.isDebugEnabled()) {
      log.debug("Persisting Status : " + status);
    }
    Set<ConstraintViolation<Status>> constraintViolations = validator.validate(status);
    if (!constraintViolations.isEmpty()) {
      throw new ConstraintViolationException(
          new HashSet<ConstraintViolation<?>>(constraintViolations));
    }
    em.persist(status);

    // Persist tags
    addTags(keyspaceOperator, STATUS_CF, statusId, tags);

    return status;
  }