@Override
 public void run() {
   List<Tweet> userTimeline;
   try {
     log.info("Getting latest tweets from public timeline and feeding them into processing grid");
     // Return all the tweets from the Twitter API
     userTimeline = twitterTemplate.timelineOperations().getUserTimeline("BriefingcomSMU");
   } catch (ApiException e) {
     log.log(Level.SEVERE, "Error getting tweets from public timeline from twitter", e);
     return;
   }
   try {
     // according to the API we may get duplicate tweets if invoked with frequency of lower than 60
     // seconds.
     // We will filter tweets which are duplicates
     for (Tweet publicTweet : userTimeline) {
       if (previousTimeLineTweets.contains(publicTweet.getId())) {
         continue;
       }
       logTweet(publicTweet);
       gigaSpace.write(buildTweet(publicTweet));
     }
   } catch (DataAccessException e) {
     log.log(Level.SEVERE, "error feeding tweets", e);
   } finally {
     previousTimeLineTweets.clear();
     for (Tweet publicTweet : userTimeline) {
       previousTimeLineTweets.add(publicTweet.getId());
     }
   }
 }
 public SpaceDocument buildTweet(Tweet tweet) {
   return new SpaceDocument(
       "Tweet",
       new DocumentProperties()
           .setProperty("Id", tweet.getId())
           .setProperty("Text", tweet.getText())
           .setProperty("CreatedAt", tweet.getCreatedAt())
           .setProperty("FromUserId", tweet.getFromUserId())
           .setProperty("ToUserId", tweet.getToUserId())
           .setProperty("Processed", Boolean.FALSE));
 }
 private void logTweet(Tweet tweet) {
   log.fine(
       String.format(
           "Tweet id=%d\tfromUser=%s\ttext=%s \n",
           tweet.getId(), tweet.getFromUser(), tweet.getText()));
 }