org.deepamehta.plugins.twitter
Class TwitterPlugin

Show UML class diagram
java.lang.Object
  extended by de.deepamehta.core.osgi.PluginActivator
      extended by org.deepamehta.plugins.twitter.TwitterPlugin
All Implemented Interfaces:
PluginContext, PluginService, TwitterService, org.osgi.framework.BundleActivator

public class TwitterPlugin
extends PluginActivator
implements TwitterService

A very basic client for researching with the public Twitter Search API v1.1 and DeepaMehta 4.1.2

Version:
1.3.0-SNAPSHOT
Author:
Malte Reißig ()

Field Summary
private  AccessControlService acService
           
private static String AGGREGATION
           
private  String bearerToken
           
private  String CHARSET
           
private static String CHILD_URI
           
private static String COMPOSITION
           
private  String DEEPAMEHTA_VERSION
           
private  String GEO_COORDINATE_TOPIC_URI
           
private  String GEO_LATITUDE_TYPE_URI
           
private  String GEO_LONGITUDE_TYPE_URI
           
private  boolean isAuthorized
           
private  boolean isInitialized
           
private  Logger log
           
private static String PARENT_URI
           
private static String TWEET_CONTENT_URI
           
private static String TWEET_ENTITIES_URI
           
private static String TWEET_FAVOURITE_COUNT_URI
           
private static String TWEET_ID_URI
           
private static String TWEET_LOCATION_URI
           
private static String TWEET_METADATA_URI
           
private static String TWEET_SOURCE_BUTTON_URI
           
private static String TWEET_TIME_URI
           
private static String TWEET_URI
           
private static String TWEET_WITHHELD_DMCA_URI
           
private static String TWEET_WITHHELD_IN_URI
           
private static String TWEET_WITHHELD_SCOPE_URI
           
private static String TWEETED_TO_STATUS_ID
           
private static String TWITTER_AUTHENTICATION_URL
           
private  String TWITTER_RESEARCH_VERSION
           
private static String TWITTER_SEARCH_BASE_URL
           
private static String TWITTER_SEARCH_LANG_URI
           
private static String TWITTER_SEARCH_LOCATION_URI
           
private static String TWITTER_SEARCH_MAX_TWEET_URI
           
private static String TWITTER_SEARCH_NEXT_PAGE_URI
           
private static String TWITTER_SEARCH_REFRESH_URL_URI
           
private static String TWITTER_SEARCH_RESULT_SIZE_URI
           
private static String TWITTER_SEARCH_TIME_URI
           
private static String TWITTER_SEARCH_TYPE_URI
           
private static String TWITTER_SEARCH_URI
           
private static String TWITTER_USER_ID_URI
           
private static String TWITTER_USER_IMAGE_URI
           
private static String TWITTER_USER_NAME_URI
           
private static String TWITTER_USER_URI
           
 
Fields inherited from class de.deepamehta.core.osgi.PluginActivator
bundle, dms
 
Constructor Summary
TwitterPlugin()
           
 
Method Summary
private  void authorizeSearchRequests()
           
private  void checkACLsOfMigration()
          Code running once, after plugin initialization.
private  void configureIfReady()
           
private  TopicModel createGeoCoordinateTopicModel(double lng, double lat)
           
private  Topic createTweet(org.codehaus.jettison.json.JSONObject item, long userTopicId, ClientState clientState)
           
private  Topic createTwitterUser(String userId, String userName, String userImageUrl, ClientState clientState)
           
private  Topic getTweet(org.codehaus.jettison.json.JSONObject item, long userTopicId, ClientState clientState)
           
private  Topic getTwitterUser(String userId, String userName, String userImageUrl, ClientState clientState)
           
 void init()
          Initialize the migrated soundsets ACL-Entries.
private  void processTwitterSearchResponse(Topic twitterSearch, StringBuffer resultBody, ClientState clientState)
          Private Helper Methods
 Topic searchMoreTweets(long searchId, boolean nextPage, ClientState clientState)
          This method executes an existing search-query to either: (a) fetch more (older) tweets for the same query or (b) fetch new tweets and assign them to the current search result
 Topic searchPublicTweets(long searchId, String query, String resultType, String lang, String location, ClientState clientState)
          Fetches public tweets matching the given query, maintains a search-query topic and references existing tweets and users, as it should be.
 void serviceArrived(PluginService service)
          --- Implementing PluginService Interfaces to consume AccessControlService ---
 void serviceGone(PluginService service)
           
 
Methods inherited from class de.deepamehta.core.osgi.PluginActivator
getBundleContext, postInstall, publishDirectory, setCoreService, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private Logger log

DEEPAMEHTA_VERSION

private final String DEEPAMEHTA_VERSION
See Also:
Constant Field Values

TWITTER_RESEARCH_VERSION

private final String TWITTER_RESEARCH_VERSION
See Also:
Constant Field Values

CHARSET

private final String CHARSET
See Also:
Constant Field Values

CHILD_URI

private static final String CHILD_URI
See Also:
Constant Field Values

PARENT_URI

private static final String PARENT_URI
See Also:
Constant Field Values

AGGREGATION

private static final String AGGREGATION
See Also:
Constant Field Values

COMPOSITION

private static final String COMPOSITION
See Also:
Constant Field Values

TWEET_URI

private static final String TWEET_URI
See Also:
Constant Field Values

TWEET_ID_URI

private static final String TWEET_ID_URI
See Also:
Constant Field Values

TWEET_TIME_URI

private static final String TWEET_TIME_URI
See Also:
Constant Field Values

TWEET_CONTENT_URI

private static final String TWEET_CONTENT_URI
See Also:
Constant Field Values

TWEET_ENTITIES_URI

private static final String TWEET_ENTITIES_URI
See Also:
Constant Field Values

TWEET_METADATA_URI

private static final String TWEET_METADATA_URI
See Also:
Constant Field Values

TWEET_SOURCE_BUTTON_URI

private static final String TWEET_SOURCE_BUTTON_URI
See Also:
Constant Field Values

TWEET_LOCATION_URI

private static final String TWEET_LOCATION_URI
See Also:
Constant Field Values

TWEET_FAVOURITE_COUNT_URI

private static final String TWEET_FAVOURITE_COUNT_URI
See Also:
Constant Field Values

TWEET_WITHHELD_DMCA_URI

private static final String TWEET_WITHHELD_DMCA_URI
See Also:
Constant Field Values

TWEET_WITHHELD_IN_URI

private static final String TWEET_WITHHELD_IN_URI
See Also:
Constant Field Values

TWEET_WITHHELD_SCOPE_URI

private static final String TWEET_WITHHELD_SCOPE_URI
See Also:
Constant Field Values

TWEETED_TO_STATUS_ID

private static final String TWEETED_TO_STATUS_ID
See Also:
Constant Field Values

TWITTER_USER_URI

private static final String TWITTER_USER_URI
See Also:
Constant Field Values

TWITTER_USER_ID_URI

private static final String TWITTER_USER_ID_URI
See Also:
Constant Field Values

TWITTER_USER_NAME_URI

private static final String TWITTER_USER_NAME_URI
See Also:
Constant Field Values

TWITTER_USER_IMAGE_URI

private static final String TWITTER_USER_IMAGE_URI
See Also:
Constant Field Values

TWITTER_SEARCH_URI

private static final String TWITTER_SEARCH_URI
See Also:
Constant Field Values

TWITTER_SEARCH_LANG_URI

private static final String TWITTER_SEARCH_LANG_URI
See Also:
Constant Field Values

TWITTER_SEARCH_LOCATION_URI

private static final String TWITTER_SEARCH_LOCATION_URI
See Also:
Constant Field Values

TWITTER_SEARCH_TYPE_URI

private static final String TWITTER_SEARCH_TYPE_URI
See Also:
Constant Field Values

TWITTER_SEARCH_NEXT_PAGE_URI

private static final String TWITTER_SEARCH_NEXT_PAGE_URI
See Also:
Constant Field Values

TWITTER_SEARCH_REFRESH_URL_URI

private static final String TWITTER_SEARCH_REFRESH_URL_URI
See Also:
Constant Field Values

TWITTER_SEARCH_MAX_TWEET_URI

private static final String TWITTER_SEARCH_MAX_TWEET_URI
See Also:
Constant Field Values

TWITTER_SEARCH_RESULT_SIZE_URI

private static final String TWITTER_SEARCH_RESULT_SIZE_URI
See Also:
Constant Field Values

TWITTER_SEARCH_TIME_URI

private static final String TWITTER_SEARCH_TIME_URI
See Also:
Constant Field Values

TWITTER_AUTHENTICATION_URL

private static final String TWITTER_AUTHENTICATION_URL
See Also:
Constant Field Values

TWITTER_SEARCH_BASE_URL

private static final String TWITTER_SEARCH_BASE_URL
See Also:
Constant Field Values

GEO_COORDINATE_TOPIC_URI

private final String GEO_COORDINATE_TOPIC_URI
See Also:
Constant Field Values

GEO_LONGITUDE_TYPE_URI

private final String GEO_LONGITUDE_TYPE_URI
See Also:
Constant Field Values

GEO_LATITUDE_TYPE_URI

private final String GEO_LATITUDE_TYPE_URI
See Also:
Constant Field Values

isInitialized

private boolean isInitialized

isAuthorized

private boolean isAuthorized

bearerToken

private String bearerToken

acService

private AccessControlService acService
Constructor Detail

TwitterPlugin

public TwitterPlugin()
Method Detail

init

public void init()
Initialize the migrated soundsets ACL-Entries.

Specified by:
init in interface PluginContext
Overrides:
init in class PluginActivator

configureIfReady

private void configureIfReady()

authorizeSearchRequests

private void authorizeSearchRequests()
                              throws TwitterAPIException
Throws:
TwitterAPIException

searchMoreTweets

public Topic searchMoreTweets(long searchId,
                              boolean nextPage,
                              @HeaderParam(value="Cookie")
                              ClientState clientState)
This method executes an existing search-query to either: (a) fetch more (older) tweets for the same query or (b) fetch new tweets and assign them to the current search result

Specified by:
searchMoreTweets in interface TwitterService
Parameters:
{searchId} - id of the "Twitter-Search"-Topic to operate on
{nextPage} - true for paging query to next page; false for fetching most recent tweets

searchPublicTweets

public Topic searchPublicTweets(long searchId,
                                String query,
                                String resultType,
                                String lang,
                                String location,
                                @HeaderParam(value="Cookie")
                                ClientState clientState)
Fetches public tweets matching the given query, maintains a search-query topic and references existing tweets and users, as it should be.

Specified by:
searchPublicTweets in interface TwitterService
Parameters:
{id} - Twitter Search Topic Id
{resultType} - "mixed", "recent", "popular"
{lang} - ISO-639-1 Code (2 chars) (optional)
{location} - "lat,lng,radiuskm" (optional)

processTwitterSearchResponse

private void processTwitterSearchResponse(Topic twitterSearch,
                                          StringBuffer resultBody,
                                          ClientState clientState)
Private Helper Methods


getTweet

private Topic getTweet(org.codehaus.jettison.json.JSONObject item,
                       long userTopicId,
                       ClientState clientState)

createTweet

private Topic createTweet(org.codehaus.jettison.json.JSONObject item,
                          long userTopicId,
                          ClientState clientState)

getTwitterUser

private Topic getTwitterUser(String userId,
                             String userName,
                             String userImageUrl,
                             ClientState clientState)

createTwitterUser

private Topic createTwitterUser(String userId,
                                String userName,
                                String userImageUrl,
                                ClientState clientState)

createGeoCoordinateTopicModel

private TopicModel createGeoCoordinateTopicModel(double lng,
                                                 double lat)

checkACLsOfMigration

private void checkACLsOfMigration()
Code running once, after plugin initialization.


serviceArrived

public void serviceArrived(PluginService service)
--- Implementing PluginService Interfaces to consume AccessControlService ---

Specified by:
serviceArrived in interface PluginContext
Overrides:
serviceArrived in class PluginActivator

serviceGone

public void serviceGone(PluginService service)
Specified by:
serviceGone in interface PluginContext
Overrides:
serviceGone in class PluginActivator


Copyright © 2014. All Rights Reserved.