Class TwitterServiceImpl

java.lang.Object
io.meeds.gamification.twitter.service.impl.TwitterServiceImpl
All Implemented Interfaces:
TwitterService

public class TwitterServiceImpl extends Object implements TwitterService
  • Constructor Details

    • TwitterServiceImpl

      public TwitterServiceImpl(org.exoplatform.commons.api.settings.SettingService settingService, TwitterConsumerService twitterConsumerService, TwitterAccountStorage twitterAccountStorage, TwitterTweetStorage twitterTweetStorage, io.meeds.gamification.service.RuleService ruleService, org.exoplatform.web.security.codec.CodecInitializer codecInitializer)
  • Method Details

    • getTwitterAccounts

      public List<TwitterAccount> getTwitterAccounts(String currentUser, int offset, int limit, boolean forceUpdate) throws IllegalAccessException
      Description copied from interface: TwitterService
      Get available watched twitter accounts using offset and limit.
      Specified by:
      getTwitterAccounts in interface TwitterService
      Parameters:
      currentUser - user name attempting to access watched twitter accounts
      offset - Offset of result
      limit - Limit of result
      forceUpdate - force Load remote accounts or not.
      Returns:
      List of TwitterAccount
      Throws:
      IllegalAccessException - when user is not authorized to access watched twitter accounts
    • getTwitterAccountById

      public TwitterAccount getTwitterAccountById(long accountId)
      Description copied from interface: TwitterService
      Retrieves a watched twitter account identified by its technical identifier.
      Specified by:
      getTwitterAccountById in interface TwitterService
      Parameters:
      accountId - watched twitter account technical identifier
      Returns:
      found TwitterAccount
    • getTwitterAccountById

      public TwitterAccount getTwitterAccountById(long accountId, String username) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: TwitterService
      Retrieves a watched twitter account identified by its technical identifier accessed by a user
      Specified by:
      getTwitterAccountById in interface TwitterService
      Parameters:
      accountId - watched twitter account technical identifier
      username - user name attempting to access watched twitter account
      Returns:
      found TwitterAccount
      Throws:
      IllegalAccessException - when user is not authorized to access watched twitter account
      org.exoplatform.commons.exception.ObjectNotFoundException - twitter account not found
    • getTwitterAccounts

      public List<TwitterAccount> getTwitterAccounts(int offset, int limit)
      Description copied from interface: TwitterService
      Get available watched twitter accounts using offset and limit.
      Specified by:
      getTwitterAccounts in interface TwitterService
      Parameters:
      offset - Offset of result
      limit - Limit of result
      Returns:
      List of TwitterAccount
    • countTwitterAccounts

      public int countTwitterAccounts(String currentUser) throws IllegalAccessException
      Description copied from interface: TwitterService
      Count all watched twitter accounts
      Specified by:
      countTwitterAccounts in interface TwitterService
      Parameters:
      currentUser - User name accessing watched twitter accounts
      Returns:
      Watched twitter accounts count
      Throws:
      IllegalAccessException - when user is not authorized to get watched twitter accounts
    • addTwitterAccount

      public TwitterAccount addTwitterAccount(String twitterUsername, String currentUser) throws org.exoplatform.commons.ObjectAlreadyExistsException, IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: TwitterService
      Add watched Twitter account.
      Specified by:
      addTwitterAccount in interface TwitterService
      Parameters:
      twitterUsername - Twitter username
      currentUser - user name attempting to add watched Twitter account.
      Returns:
      TwitterAccount
      Throws:
      org.exoplatform.commons.ObjectAlreadyExistsException - when watched Twitter account already exists
      IllegalAccessException - when user is not authorized to add watched Twitter account.
      org.exoplatform.commons.exception.ObjectNotFoundException - when the Twitter account identified by its technical name is not found
    • deleteTwitterAccount

      public void deleteTwitterAccount(long twitterAccountId, String currentUser) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: TwitterService
      delete watched Twitter account
      Specified by:
      deleteTwitterAccount in interface TwitterService
      Parameters:
      twitterAccountId - twitter remote account id
      currentUser - user name attempting to delete watched Twitter account
      Throws:
      IllegalAccessException - when user is not authorized to delete the watched Twitter account
      org.exoplatform.commons.exception.ObjectNotFoundException
    • addTweetToWatch

      public Tweet addTweetToWatch(String tweetLink)
      Description copied from interface: TwitterService
      Add watched Tweet.
      Specified by:
      addTweetToWatch in interface TwitterService
      Parameters:
      tweetLink - Tweet link
      Returns:
      TwitterAccount
    • getTweets

      public List<Tweet> getTweets(int offset, int limit)
      Description copied from interface: TwitterService
      Get available watched tweets using offset and limit.
      Specified by:
      getTweets in interface TwitterService
      Parameters:
      offset - Offset of result
      limit - Limit of result
      Returns:
      List of Tweet
    • countTweets

      public int countTweets()
      Description copied from interface: TwitterService
      Count all watched tweets
      Specified by:
      countTweets in interface TwitterService
      Returns:
      Watched tweets count
    • getTweetByLink

      public Tweet getTweetByLink(String tweetLink)
      Description copied from interface: TwitterService
      Retrieves a watched tweet identified by its link
      Specified by:
      getTweetByLink in interface TwitterService
      Parameters:
      tweetLink - watched tweet link
      Returns:
      found TwitterAccount
    • deleteTweet

      public void deleteTweet(long tweetId) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: TwitterService
      delete watched Tweet
      Specified by:
      deleteTweet in interface TwitterService
      Parameters:
      tweetId - tweet Id
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException
    • deleteTweetById

      public void deleteTweetById(long tweetId)
      Specified by:
      deleteTweetById in interface TwitterService
    • saveTwitterBearerToken

      public void saveTwitterBearerToken(String bearerToken, String currentUser) throws IllegalAccessException
      Description copied from interface: TwitterService
      Saves Twitter bearer token
      Specified by:
      saveTwitterBearerToken in interface TwitterService
      Parameters:
      bearerToken - twitter bearer token
      currentUser - user name attempting to save Twitter bearer token
      Throws:
      IllegalAccessException - when user is not authorized save Twitter bearer token
    • deleteTwitterBearerToken

      public void deleteTwitterBearerToken(String currentUser) throws IllegalAccessException
      Description copied from interface: TwitterService
      Deletes Twitter bearer token
      Specified by:
      deleteTwitterBearerToken in interface TwitterService
      Parameters:
      currentUser - user name attempting to delete Twitter bearer token
      Throws:
      IllegalAccessException - when user is not authorized to delete Twitter bearer token
    • getTwitterBearerToken

      public String getTwitterBearerToken(String currentUser) throws IllegalAccessException
      Description copied from interface: TwitterService
      gets Twitter bearer token
      Specified by:
      getTwitterBearerToken in interface TwitterService
      Parameters:
      currentUser - user name attempting to access Twitter bearer token
      Returns:
      Twitter bearer token
      Throws:
      IllegalAccessException - when user is not authorized to access Twitter bearer token
    • getTwitterBearerToken

      public String getTwitterBearerToken()
      Description copied from interface: TwitterService
      gets Twitter bearer token
      Specified by:
      getTwitterBearerToken in interface TwitterService
      Returns:
      Twitter bearer token
    • updateAccountLastMentionTweetId

      public void updateAccountLastMentionTweetId(long accountId, long lastMentionTweetId) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: TwitterService
      Update twitter account last mention tweet Id.
      Specified by:
      updateAccountLastMentionTweetId in interface TwitterService
      Parameters:
      accountId - account Id
      lastMentionTweetId - last mention Tweet Id
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the Twitter account identified by its technical name is not found
    • updateTweetReactions

      public void updateTweetReactions(long tweetId, Set<String> likers, Set<String> retweeters) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: TwitterService
      Update tweet with last reactions.
      Specified by:
      updateTweetReactions in interface TwitterService
      Parameters:
      tweetId - tweetId
      likers - tweet likers
      retweeters - tweet retweeters
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the tweet identified by its technical id is not found