tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1131512 - in /openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools: ./ examples/ twitter/ twitter/util/
Date Sun, 05 Jun 2011 01:48:46 GMT
Author: dblevins
Date: Sun Jun  5 01:48:46 2011
New Revision: 1131512

URL: http://svn.apache.org/viewvc?rev=1131512&view=rev
Log:
Reformat

Modified:
    openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/Daily.java
    openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/Hourly.java
    openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/examples/GenerateIndex.java
    openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/AccessTokenGenerator.java
    openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/AuthorizationUrlGenerator.java
    openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/ContribListStatusRetriever.java
    openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/JsonResponseParser.java
    openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/OpenEJBMessageFilterUtil.java
    openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/Retweet.java
    openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/StoreAccessToken.java
    openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/util/RetweetAppUtil.java

Modified: openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/Daily.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/Daily.java?rev=1131512&r1=1131511&r2=1131512&view=diff
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/Daily.java (original)
+++ openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/Daily.java Sun Jun
 5 01:48:46 2011
@@ -19,12 +19,12 @@ package org.apache.openejb.tools;
 import org.apache.openejb.tools.examples.GenerateIndex;
 
 /**
- *  You can execute standalone java programs with Maven like so:
- *
- *  mvn clean install exec:java -Dexec.mainClass=org.apache.openejb.tools.Daily
- *
- *  The idea is to setup this main class as an Daily cron job
- *  If we have other things we want to do daily, we can do them here.
+ * You can execute standalone java programs with Maven like so:
+ * <p/>
+ * mvn clean install exec:java -Dexec.mainClass=org.apache.openejb.tools.Daily
+ * <p/>
+ * The idea is to setup this main class as an Daily cron job
+ * If we have other things we want to do daily, we can do them here.
  *
  * @version $Rev$ $Date$
  */

Modified: openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/Hourly.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/Hourly.java?rev=1131512&r1=1131511&r2=1131512&view=diff
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/Hourly.java (original)
+++ openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/Hourly.java Sun Jun
 5 01:48:46 2011
@@ -19,12 +19,12 @@ package org.apache.openejb.tools;
 import org.apache.openejb.tools.twitter.Retweet;
 
 /**
- *  You can execute standalone java programs with Maven like so:
- *
- *  mvn clean install exec:java -Dexec.mainClass=org.apache.openejb.tools.Hourly
- *
- *  The idea is to setup this main class as an Hourly cron job
- *  If we have other things we want to do hourly, we can do them here.
+ * You can execute standalone java programs with Maven like so:
+ * <p/>
+ * mvn clean install exec:java -Dexec.mainClass=org.apache.openejb.tools.Hourly
+ * <p/>
+ * The idea is to setup this main class as an Hourly cron job
+ * If we have other things we want to do hourly, we can do them here.
  *
  * @version $Rev$ $Date$
  */

Modified: openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/examples/GenerateIndex.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/examples/GenerateIndex.java?rev=1131512&r1=1131511&r2=1131512&view=diff
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/examples/GenerateIndex.java
(original)
+++ openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/examples/GenerateIndex.java
Sun Jun  5 01:48:46 2011
@@ -18,24 +18,24 @@ package org.apache.openejb.tools.example
 
 /**
  * Most the examples do not have any documentation.
- *
+ * <p/>
  * There are some wiki pages for some of the examples, but these are hard to create and maintain.
 The examples change frequently enough that we really should have documentation that goes
with each version of the examples.
- *
+ * <p/>
  * If we put a README.md file in each example and use Markdown which is a really simple text
format that has many tools capable of generating html, we could probably generate a web page
for each example.  Then we could generate a index for all the examples.
- *
+ * <p/>
  * We could then take this all and upload it to the website
- *
+ * <p/>
  * Something kind of like this, but nicer looking, with breadcrumbs and links for navigating
around to other examples: http://people.apache.org/~dblevins/simple-stateless.html
- *
- *
- *
- *
+ * <p/>
+ * <p/>
+ * <p/>
+ * <p/>
  * IDEAS FOR AFTER SOMETHING IS WORKING
- *
+ * <p/>
  * Perhaps at some point some xref style processing of the source and links to the source
- *
+ * <p/>
  * Perhaps at some point use ASM to see what annotations and API classes were used and make
an index that lists examples by which APIs are used
- *
+ * <p/>
  * Perhaps at some point use Swizzle stream to do a sort of SNIPPET thing like the Confluence
plugin, so we wouldn't have to copy source into the example
  *
  * @version $Rev$ $Date$
@@ -52,12 +52,12 @@ public class GenerateIndex {
 
     /**
      * Can be run in an IDE or via Maven like so:
-     *
+     * <p/>
      * mvn clean install exec:java -Dexec.mainClass=org.apache.openejb.tools.examples.GenerateIndex
+     *
      * @param args
      */
-    public static void main(String[] args)
-    {
+    public static void main(String[] args) {
         // crack open the examples zip file
 
         // create a directory for each example

Modified: openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/AccessTokenGenerator.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/AccessTokenGenerator.java?rev=1131512&r1=1131511&r2=1131512&view=diff
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/AccessTokenGenerator.java
(original)
+++ openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/AccessTokenGenerator.java
Sun Jun  5 01:48:46 2011
@@ -16,68 +16,67 @@
  */
 package org.apache.openejb.tools.twitter;
 
-import java.util.Scanner;
-
 import oauth.signpost.exception.OAuthCommunicationException;
 import oauth.signpost.exception.OAuthExpectationFailedException;
 import oauth.signpost.exception.OAuthMessageSignerException;
 import oauth.signpost.exception.OAuthNotAuthorizedException;
-import static org.apache.openejb.tools.twitter.AuthorizationUrlGenerator.*;
+
+import java.util.Scanner;
+
+import static org.apache.openejb.tools.twitter.AuthorizationUrlGenerator.consumer;
+import static org.apache.openejb.tools.twitter.AuthorizationUrlGenerator.provider;
 
 public class AccessTokenGenerator {
-	
-	public static void main(String[] args)
-	{
-		AuthorizationUrlGenerator.getAuthorizationUrlForUser();
-		getTokensToReadWriteIntoTwitterAccountOfUser();
-	
-	}
-
-	private static void getTokensToReadWriteIntoTwitterAccountOfUser()
-	{
-		
-		try {
-			retrieveAccessTokens();
-		} catch (OAuthMessageSignerException e) {
-			e.printStackTrace();
-		} catch (OAuthNotAuthorizedException e) {
-			e.printStackTrace();
-		} catch (OAuthExpectationFailedException e) {
-			e.printStackTrace();
-		} catch (OAuthCommunicationException e) {
-			e.printStackTrace();
-		}
-	}
-
-	private static void retrieveAccessTokens()
-			throws OAuthMessageSignerException, OAuthNotAuthorizedException,
-			OAuthExpectationFailedException, OAuthCommunicationException {
-		
-		Scanner keyBoardInputScanner = new Scanner(System.in);
-		String pinFromUser = scanPIN(keyBoardInputScanner);
-		
-		System.out.println("User has provided this PIN:"+pinFromUser);
-		
-		provider.retrieveAccessToken(consumer,pinFromUser);
-		
-		System.out.println("Consumer Token: (Copy and Paste this value in the RetweetTool.properties
against retweetApp.authorizedUser.consumer.token)");	
-		System.out.println(consumer.getToken());
-		
-		
-		System.out.println("Consumer Token Secret: (Copy and Paste this value in RetweetTool.properties
against retweetApp.authorizedUser.consumer.tokenSecret)");
-		System.out.println(consumer.getTokenSecret());
-		
-	}
-
-	private static String scanPIN(Scanner keyBoardInputScanner) {
-		String pinFromUser = null;
-		System.out.println("Please enter the PIN number to complete authorization:");
-		if(keyBoardInputScanner.hasNext())
-				{
-					pinFromUser=keyBoardInputScanner.next();
-				}
-		return pinFromUser;
-	}
+
+    public static void main(String[] args) {
+        AuthorizationUrlGenerator.getAuthorizationUrlForUser();
+        getTokensToReadWriteIntoTwitterAccountOfUser();
+
+    }
+
+    private static void getTokensToReadWriteIntoTwitterAccountOfUser() {
+
+        try {
+            retrieveAccessTokens();
+        } catch (OAuthMessageSignerException e) {
+            e.printStackTrace();
+        } catch (OAuthNotAuthorizedException e) {
+            e.printStackTrace();
+        } catch (OAuthExpectationFailedException e) {
+            e.printStackTrace();
+        } catch (OAuthCommunicationException e) {
+            e.printStackTrace();
+        }
+    }
+
+    private static void retrieveAccessTokens()
+            throws OAuthMessageSignerException, OAuthNotAuthorizedException,
+            OAuthExpectationFailedException, OAuthCommunicationException {
+
+        Scanner keyBoardInputScanner = new Scanner(System.in);
+        String pinFromUser = scanPIN(keyBoardInputScanner);
+
+        System.out.println("User has provided this PIN:" + pinFromUser);
+
+        provider.retrieveAccessToken(consumer, pinFromUser);
+
+        System.out.println("Consumer Token: (Copy and Paste this value in the RetweetTool.properties
against retweetApp.authorizedUser.consumer.token)");
+        System.out.println(consumer.getToken());
+
+
+        System.out.println("Consumer Token Secret: (Copy and Paste this value in RetweetTool.properties
against retweetApp.authorizedUser.consumer.tokenSecret)");
+        System.out.println(consumer.getTokenSecret());
+
+    }
+
+    private static String scanPIN(Scanner keyBoardInputScanner) {
+        String pinFromUser = null;
+        System.out.println("Please enter the PIN number to complete authorization:");
+        if (keyBoardInputScanner.hasNext()) {
+            pinFromUser = keyBoardInputScanner.next();
+        }
+        return pinFromUser;
+    }
 
 
 }

Modified: openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/AuthorizationUrlGenerator.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/AuthorizationUrlGenerator.java?rev=1131512&r1=1131511&r2=1131512&view=diff
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/AuthorizationUrlGenerator.java
(original)
+++ openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/AuthorizationUrlGenerator.java
Sun Jun  5 01:48:46 2011
@@ -16,8 +16,6 @@
  */
 package org.apache.openejb.tools.twitter;
 
-import java.util.Properties;
-
 import oauth.signpost.OAuth;
 import oauth.signpost.OAuthConsumer;
 import oauth.signpost.OAuthProvider;
@@ -27,71 +25,72 @@ import oauth.signpost.exception.OAuthCom
 import oauth.signpost.exception.OAuthExpectationFailedException;
 import oauth.signpost.exception.OAuthMessageSignerException;
 import oauth.signpost.exception.OAuthNotAuthorizedException;
-
 import org.apache.openejb.tools.twitter.util.RetweetAppUtil;
 
+import java.util.Properties;
+
 public class AuthorizationUrlGenerator {
-	static Properties retweetToolProperties;
-	static OAuthConsumer consumer;
-	static OAuthProvider provider;
-
-	public static String getAuthorizationUrlForUser(){
-		retweetToolProperties = RetweetAppUtil.getTwitterAppProperties();
-		intializeOAuthConsumerAndProvider();
-		return getAuthorizationUrl();
-
-	}	
-	
-	private static void intializeOAuthConsumerAndProvider() {
-
-		consumer = new DefaultOAuthConsumer(
-				retweetToolProperties.getProperty("retweetApp.consumer.key"),
-				retweetToolProperties
-				.getProperty("retweetApp.consumerSecret.key"));
-
-		provider = new DefaultOAuthProvider(
-				"http://twitter.com/oauth/request_token",
-				"http://twitter.com/oauth/access_token",
-				"http://twitter.com/oauth/authorize");
-
-	}
-
-	
-	private static String getAuthorizationUrl() {
-
-		String authUrl=null;
-		try {
-		authUrl=getAccessAuthorizationURL();
-		} catch (OAuthMessageSignerException e) {
-			e.printStackTrace();
-		} catch (OAuthNotAuthorizedException e) {
-			e.printStackTrace();
-		} catch (OAuthExpectationFailedException e) {
-			e.printStackTrace();
-		} catch (OAuthCommunicationException e) {
-			e.printStackTrace();
-		}
-		
-		return authUrl;
-
-	}
-
-	private static String getAccessAuthorizationURL()
-	throws OAuthMessageSignerException, OAuthNotAuthorizedException,
-	OAuthExpectationFailedException, OAuthCommunicationException {
-
-		String authUrl;
-		authUrl = provider.retrieveRequestToken(consumer, OAuth.OUT_OF_BAND);
-		System.out.println("#####################");
-		System.out.println("Paste the below URL in the browser and authorize");
-		System.out.println(authUrl);
-		System.out.println("#####################");
-		
-		return authUrl;
-		
-				
-	}
+    static Properties retweetToolProperties;
+    static OAuthConsumer consumer;
+    static OAuthProvider provider;
+
+    public static String getAuthorizationUrlForUser() {
+
+        retweetToolProperties = RetweetAppUtil.getTwitterAppProperties();
+        intializeOAuthConsumerAndProvider();
+        return getAuthorizationUrl();
+
+    }
+
+    private static void intializeOAuthConsumerAndProvider() {
+
+        consumer = new DefaultOAuthConsumer(
+                retweetToolProperties.getProperty("retweetApp.consumer.key"),
+                retweetToolProperties
+                        .getProperty("retweetApp.consumerSecret.key"));
+
+        provider = new DefaultOAuthProvider(
+                "http://twitter.com/oauth/request_token",
+                "http://twitter.com/oauth/access_token",
+                "http://twitter.com/oauth/authorize");
+
+    }
+
+
+    private static String getAuthorizationUrl() {
+
+        String authUrl = null;
+        try {
+            authUrl = getAccessAuthorizationURL();
+        } catch (OAuthMessageSignerException e) {
+            e.printStackTrace();
+        } catch (OAuthNotAuthorizedException e) {
+            e.printStackTrace();
+        } catch (OAuthExpectationFailedException e) {
+            e.printStackTrace();
+        } catch (OAuthCommunicationException e) {
+            e.printStackTrace();
+        }
+
+        return authUrl;
+
+    }
+
+    private static String getAccessAuthorizationURL()
+            throws OAuthMessageSignerException, OAuthNotAuthorizedException,
+            OAuthExpectationFailedException, OAuthCommunicationException {
+
+        String authUrl;
+        authUrl = provider.retrieveRequestToken(consumer, OAuth.OUT_OF_BAND);
+        System.out.println("#####################");
+        System.out.println("Paste the below URL in the browser and authorize");
+        System.out.println(authUrl);
+        System.out.println("#####################");
+
+        return authUrl;
+
+
+    }
+
 
-	
-	
 }

Modified: openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/ContribListStatusRetriever.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/ContribListStatusRetriever.java?rev=1131512&r1=1131511&r2=1131512&view=diff
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/ContribListStatusRetriever.java
(original)
+++ openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/ContribListStatusRetriever.java
Sun Jun  5 01:48:46 2011
@@ -16,42 +16,43 @@
  */
 package org.apache.openejb.tools.twitter;
 
-import java.io.IOException;
-
 import org.apache.http.HttpResponse;
 import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.methods.HttpGet;
 
+import java.io.IOException;
+
 public class ContribListStatusRetriever {
 
-	public static HttpResponse getStatusesFromOpenEJBContributorsList() {
-		String listName="contributors";
-		String ownerScreenName="OpenEJB";
-		HttpGet httpGet = getHttpRequestToRetrieveListStatuses(listName, ownerScreenName);
-		HttpResponse contributorsListStatusesResponse = getContribListStatusesResponse(httpGet);
-		
-		return contributorsListStatusesResponse;
-	}
-	
-	private static HttpGet getHttpRequestToRetrieveListStatuses(String listName,
-			String ownerScreenName) {
-		HttpGet httpGet = new HttpGet("http://api.twitter.com/1/lists/statuses.json?slug="+listName
-				+"&owner_screen_name="+ownerScreenName);
-		System.out.println("Getting list using "+httpGet.getURI());
-		return httpGet;
-	}
-	
-
-	private static HttpResponse getContribListStatusesResponse(
-			HttpGet httpGet) {
-		HttpResponse response = null;
-		try {
-			response = Retweet.getHttpClient().execute(httpGet);
-		} catch (ClientProtocolException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		return response;
-	}
+    public static HttpResponse getStatusesFromOpenEJBContributorsList() {
+
+        String listName = "contributors";
+        String ownerScreenName = "OpenEJB";
+        HttpGet httpGet = getHttpRequestToRetrieveListStatuses(listName, ownerScreenName);
+        HttpResponse contributorsListStatusesResponse = getContribListStatusesResponse(httpGet);
+
+        return contributorsListStatusesResponse;
+    }
+
+    private static HttpGet getHttpRequestToRetrieveListStatuses(String listName, String ownerScreenName)
{
+
+        HttpGet httpGet = new HttpGet("http://api.twitter.com/1/lists/statuses.json?slug="
+ listName
+                + "&owner_screen_name=" + ownerScreenName);
+        System.out.println("Getting list using " + httpGet.getURI());
+        return httpGet;
+    }
+
+
+    private static HttpResponse getContribListStatusesResponse(HttpGet httpGet) {
+
+        HttpResponse response = null;
+        try {
+            response = Retweet.getHttpClient().execute(httpGet);
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return response;
+    }
 }

Modified: openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/JsonResponseParser.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/JsonResponseParser.java?rev=1131512&r1=1131511&r2=1131512&view=diff
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/JsonResponseParser.java
(original)
+++ openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/JsonResponseParser.java
Sun Jun  5 01:48:46 2011
@@ -16,12 +16,6 @@
  */
 package org.apache.openejb.tools.twitter;
 
-import java.io.IOException;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.http.HttpResponse;
 import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.ResponseHandler;
@@ -31,41 +25,47 @@ import org.codehaus.jackson.map.JsonMapp
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.type.TypeReference;
 
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
 
 public class JsonResponseParser {
-	
-	public static String getResponseBody(HttpResponse response) {
-		ResponseHandler<String> responseHander = new BasicResponseHandler();
-		String responseBody=null;
-		try {
-			responseBody = (String)responseHander.handleResponse(response);
-		} catch (ClientProtocolException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		
-		System.out.println("Response Body Data:"+responseBody);
-		
-		return responseBody;
-	}
-
-	@SuppressWarnings("rawtypes")
-	public static List<Map> getListFromJson(Reader jsonDataReader) {
-		ObjectMapper mapper = new ObjectMapper();
-		List<Map> result = null;
-		try {
-			result=mapper.readValue(jsonDataReader, new TypeReference<ArrayList<Map>>()
{
-			});
-		} catch (JsonParseException e) {
-			e.printStackTrace();
-		} catch (JsonMappingException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		System.out.println("Json to List of key value pairs:"+result);
-		return result;
-	}
+
+    public static String getResponseBody(HttpResponse response) {
+        ResponseHandler<String> responseHander = new BasicResponseHandler();
+        String responseBody = null;
+        try {
+            responseBody = (String) responseHander.handleResponse(response);
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        System.out.println("Response Body Data:" + responseBody);
+
+        return responseBody;
+    }
+
+    @SuppressWarnings("rawtypes")
+    public static List<Map> getListFromJson(Reader jsonDataReader) {
+        ObjectMapper mapper = new ObjectMapper();
+        List<Map> result = null;
+        try {
+            result = mapper.readValue(jsonDataReader, new TypeReference<ArrayList<Map>>()
{
+            });
+        } catch (JsonParseException e) {
+            e.printStackTrace();
+        } catch (JsonMappingException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        System.out.println("Json to List of key value pairs:" + result);
+        return result;
+    }
 
 }

Modified: openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/OpenEJBMessageFilterUtil.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/OpenEJBMessageFilterUtil.java?rev=1131512&r1=1131511&r2=1131512&view=diff
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/OpenEJBMessageFilterUtil.java
(original)
+++ openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/OpenEJBMessageFilterUtil.java
Sun Jun  5 01:48:46 2011
@@ -23,66 +23,58 @@ import java.util.Map;
 
 public class OpenEJBMessageFilterUtil {
 
-	@SuppressWarnings("rawtypes")
-	public static List<String> getNonRetweetedOpenEJBStatusIDs( List<Map> keyValuePairs)
{
-		
-		List<String> openEJBStatusIDs = new ArrayList<String>();
-		
-		for (Object keyValuePair : keyValuePairs) {
-			Map keyValue = (Map) keyValuePair;
-			if (keyValue.containsKey("text")) {
-				String tweet = (String) keyValue.get("text");
-				if(isOpenEJBTweet(tweet) && !isRetweeted(keyValue))
-				{
-					System.out.println("Adding Tweet:"+tweet);
-					Number tweetId=(Number) keyValue.get("id");
-					openEJBStatusIDs.add(tweetId.toString());					
-				}
-				else
-				{
-					System.out.println("Tweet Not Considered:" +keyValue.get("text"));
-					System.out.println("IsOpenEJBTweet?:"+isOpenEJBTweet(tweet));
-					System.out.println("Was it retweeted before:"+isRetweeted(keyValue));
-				}
-				
-			}
-		}
-		
-		return openEJBStatusIDs;
-	}
-
-	@SuppressWarnings("rawtypes")
-	private static boolean isRetweeted( Map keyValue) {
-		Integer retweetCount= new Integer((Integer) keyValue.get("retweet_count"));
-		if(retweetCount>0)
-		{
-			return true;
-		}
-		else
-		{
-			return false;
-		}
-	}
-	
-	
-	private static boolean isOpenEJBTweet(String tweet) {
-		String[] words = tweet.split(" ");
-		List<String> wordsAsList = Arrays.asList(words);
-		for (String word : wordsAsList) {
-			if (isOpenEJBMentioned(word))
-			{
-				String mentionName=word.trim().substring(1,8);
-				if(mentionName.equalsIgnoreCase("openejb"))
-				{return true;}
-			}
-		}
-		return false;
-	}
-
-
-	private static boolean isOpenEJBMentioned(String word) {
-		return (word.startsWith("#") || word.startsWith("@")) &&word.trim().length()>=8;
-	}
-	
-	
+    @SuppressWarnings("rawtypes")
+    public static List<String> getNonRetweetedOpenEJBStatusIDs(List<Map> keyValuePairs)
{
+
+        List<String> openEJBStatusIDs = new ArrayList<String>();
+
+        for (Object keyValuePair : keyValuePairs) {
+            Map keyValue = (Map) keyValuePair;
+            if (keyValue.containsKey("text")) {
+                String tweet = (String) keyValue.get("text");
+                if (isOpenEJBTweet(tweet) && !isRetweeted(keyValue)) {
+                    System.out.println("Adding Tweet:" + tweet);
+                    Number tweetId = (Number) keyValue.get("id");
+                    openEJBStatusIDs.add(tweetId.toString());
+                } else {
+                    System.out.println("Tweet Not Considered:" + keyValue.get("text"));
+                    System.out.println("IsOpenEJBTweet?:" + isOpenEJBTweet(tweet));
+                    System.out.println("Was it retweeted before:" + isRetweeted(keyValue));
+                }
+
+            }
+        }
+
+        return openEJBStatusIDs;
+    }
+
+    @SuppressWarnings("rawtypes")
+    private static boolean isRetweeted(Map keyValue) {
+        Integer retweetCount = new Integer((Integer) keyValue.get("retweet_count"));
+        if (retweetCount > 0) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+
+    private static boolean isOpenEJBTweet(String tweet) {
+        String[] words = tweet.split(" ");
+        List<String> wordsAsList = Arrays.asList(words);
+        for (String word : wordsAsList) {
+            if (isOpenEJBMentioned(word)) {
+                String mentionName = word.trim().substring(1, 8);
+                if (mentionName.equalsIgnoreCase("openejb")) {return true;}
+            }
+        }
+        return false;
+    }
+
+
+    private static boolean isOpenEJBMentioned(String word) {
+        return (word.startsWith("#") || word.startsWith("@")) && word.trim().length()
>= 8;
+    }
+
+
 }

Modified: openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/Retweet.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/Retweet.java?rev=1131512&r1=1131511&r2=1131512&view=diff
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/Retweet.java
(original)
+++ openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/Retweet.java
Sun Jun  5 01:48:46 2011
@@ -16,41 +16,40 @@
  */
 package org.apache.openejb.tools.twitter;
 
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
 import oauth.signpost.OAuthConsumer;
 import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer;
 import oauth.signpost.exception.OAuthCommunicationException;
 import oauth.signpost.exception.OAuthExpectationFailedException;
 import oauth.signpost.exception.OAuthMessageSignerException;
-
 import org.apache.http.HttpResponse;
 import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.openejb.tools.twitter.util.RetweetAppUtil;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
 /**
- *
  * We should monitor this feed http://twitter.com/#!/OpenEJB/contributors
  * and retweet anything that mentions OpenEJB
- *
+ * <p/>
  * So if anyone in the contributors list tweeted about OpenEJB, the OpenEJB twitter account
would retweet it
- *
+ * <p/>
  * Two things will happen as a result:
- *   -  The more activity on the OpenEJB twitter account the more followers it will get
- *   -  The more @joe and other contributors are seen on the account, the more followers
they will get
- *
+ * -  The more activity on the OpenEJB twitter account the more followers it will get
+ * -  The more @joe and other contributors are seen on the account, the more followers they
will get
+ * <p/>
  * The OpenEJB twitter account has more followers than most everyone else so getting it
  * to retweet is a good way to expose people to all our wonderful contributors
  * and get them some followers and help the project at the same time.
- *
+ * <p/>
  * The result is we as a community will have more ability overall to get the word out!
- * 
+ * <p/>
  * Implemented using :http://code.google.com/p/oauth-signpost/wiki/GettingStarted
  * list - HTTP GET http://api.twitter.com/1/lists/statuses.xml?slug=contributors&owner_screen_name=OpenEJB
  * retweet - HTTP POST http://api.twitter.com/1/statuses/retweet/<statusid>.xml
@@ -58,95 +57,90 @@ import org.apache.openejb.tools.twitter.
  * @version $Rev$ $Date$
  */
 public class Retweet {
-	
-	public static Properties retweetToolProperties=RetweetAppUtil.getTwitterAppProperties();
-	public static OAuthConsumer consumer;
+
+    public static Properties retweetToolProperties = RetweetAppUtil.getTwitterAppProperties();
+    public static OAuthConsumer consumer;
 
     @SuppressWarnings("rawtypes")
-	public static void main(String[] args) {
-    	HttpResponse response = ContribListStatusRetriever.getStatusesFromOpenEJBContributorsList();
-       	String responseBody = JsonResponseParser.getResponseBody(response);
-       	StringReader jsonDataReader = new StringReader(responseBody);
-       	//Each status is a entry in the list. Each status has various properties in the form
of key-value pairs
-       	List<Map> listFromJson = JsonResponseParser.getListFromJson(jsonDataReader);
-       	List<String> nonRetweetedOpenEJBStatusIDs = OpenEJBMessageFilterUtil.getNonRetweetedOpenEJBStatusIDs(listFromJson);
-  	
-       	System.out.println("About to retweet:"+nonRetweetedOpenEJBStatusIDs);
-       	retweetIfListIsNotEmpty(nonRetweetedOpenEJBStatusIDs);
-       	
-       }
-
-	private static void retweetIfListIsNotEmpty(
-			List<String> nonRetweetedOpenEJBStatusIDs) {
-		if(!nonRetweetedOpenEJBStatusIDs.isEmpty())
-       	{
-       	retweetThisListOfStatuses(nonRetweetedOpenEJBStatusIDs);
-       	}
-       	else
-       	{
-       		System.out.println("No message to retweet.");
-       	}
-	}
-
-	private static void retweetThisListOfStatuses(
-			List<String> nonRetweetedOpenEJBStatusIDs) {
-		for(String statusIDToRetweet:nonRetweetedOpenEJBStatusIDs)
-       	{
-       		try {
-				retweet(statusIDToRetweet);
-				pauseBeforeTheNextRetweet();
-			} catch (OAuthMessageSignerException e) {
-				e.printStackTrace();
-			} catch (OAuthExpectationFailedException e) {
-				e.printStackTrace();
-			} catch (OAuthCommunicationException e) {
-				e.printStackTrace();
-			}
-       	}
-	}
-	
-	public static void initConsumer() {
-		
-		consumer=new CommonsHttpOAuthConsumer(
-				retweetToolProperties.getProperty("retweetApp.consumer.key"),
-				retweetToolProperties
-				.getProperty("retweetApp.consumerSecret.key"));
-	
-		
-		consumer.setTokenWithSecret(retweetToolProperties.getProperty("retweetApp.authorizedUser.consumer.token"),
-   			 retweetToolProperties.getProperty("retweetApp.authorizedUser.consumer.tokenSecret"));
-	
-	}
-
-	public static HttpResponse retweet(String statusIDToRetweet) throws OAuthMessageSignerException,
OAuthExpectationFailedException, OAuthCommunicationException {
-		HttpPost httpPost = new HttpPost("http://api.twitter.com/1/statuses/retweet/"+statusIDToRetweet+".json");
-		initConsumer();
-		consumer.sign(httpPost);
-		HttpResponse response = null;
-		try {
-			response = getHttpClient().execute(httpPost);
-			System.out.println(response.getStatusLine());
-			System.out.println("Retweeted "+statusIDToRetweet);
-		} catch (ClientProtocolException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-	
-		return response;
-	}
-	
-    public static HttpClient getHttpClient()
-    {
-    	return new DefaultHttpClient();
-    }
-	
-	private static void pauseBeforeTheNextRetweet() {
-		try {
-			Thread.sleep(1000*60*5);
-		} catch (InterruptedException e) {
-			e.printStackTrace();
-		}
-	}
+    public static void main(String[] args) {
+        HttpResponse response = ContribListStatusRetriever.getStatusesFromOpenEJBContributorsList();
+        String responseBody = JsonResponseParser.getResponseBody(response);
+        StringReader jsonDataReader = new StringReader(responseBody);
+        //Each status is a entry in the list. Each status has various properties in the form
of key-value pairs
+        List<Map> listFromJson = JsonResponseParser.getListFromJson(jsonDataReader);
+        List<String> nonRetweetedOpenEJBStatusIDs = OpenEJBMessageFilterUtil.getNonRetweetedOpenEJBStatusIDs(listFromJson);
+
+        System.out.println("About to retweet:" + nonRetweetedOpenEJBStatusIDs);
+        retweetIfListIsNotEmpty(nonRetweetedOpenEJBStatusIDs);
+
+    }
+
+    private static void retweetIfListIsNotEmpty(List<String> nonRetweetedOpenEJBStatusIDs)
{
+
+        if (!nonRetweetedOpenEJBStatusIDs.isEmpty()) {
+            retweetThisListOfStatuses(nonRetweetedOpenEJBStatusIDs);
+        } else {
+            System.out.println("No message to retweet.");
+        }
+    }
+
+    private static void retweetThisListOfStatuses(List<String> nonRetweetedOpenEJBStatusIDs)
{
+
+        for (String statusIDToRetweet : nonRetweetedOpenEJBStatusIDs) {
+            try {
+                retweet(statusIDToRetweet);
+                pauseBeforeTheNextRetweet();
+            } catch (OAuthMessageSignerException e) {
+                e.printStackTrace();
+            } catch (OAuthExpectationFailedException e) {
+                e.printStackTrace();
+            } catch (OAuthCommunicationException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    public static void initConsumer() {
+
+        consumer = new CommonsHttpOAuthConsumer(
+                retweetToolProperties.getProperty("retweetApp.consumer.key"),
+                retweetToolProperties
+                        .getProperty("retweetApp.consumerSecret.key"));
+
+
+        consumer.setTokenWithSecret(retweetToolProperties.getProperty("retweetApp.authorizedUser.consumer.token"),
+                retweetToolProperties.getProperty("retweetApp.authorizedUser.consumer.tokenSecret"));
+
+    }
+
+    public static HttpResponse retweet(String statusIDToRetweet) throws OAuthMessageSignerException,
OAuthExpectationFailedException, OAuthCommunicationException {
+        HttpPost httpPost = new HttpPost("http://api.twitter.com/1/statuses/retweet/" + statusIDToRetweet
+ ".json");
+        initConsumer();
+        consumer.sign(httpPost);
+        HttpResponse response = null;
+        try {
+            response = getHttpClient().execute(httpPost);
+            System.out.println(response.getStatusLine());
+            System.out.println("Retweeted " + statusIDToRetweet);
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        return response;
+    }
+
+    public static HttpClient getHttpClient() {
+        return new DefaultHttpClient();
+    }
+
+    private static void pauseBeforeTheNextRetweet() {
+        try {
+            Thread.sleep(1000 * 60 * 5);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
 
 }

Modified: openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/StoreAccessToken.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/StoreAccessToken.java?rev=1131512&r1=1131511&r2=1131512&view=diff
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/StoreAccessToken.java
(original)
+++ openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/StoreAccessToken.java
Sun Jun  5 01:48:46 2011
@@ -17,7 +17,7 @@
 package org.apache.openejb.tools.twitter;
 
 public class StoreAccessToken {
-  //Retrieve access token based on the PIN number provided by the user.
-  // Store it in File/DB
-  // This access token would be used for any READ/WRITE
+    //Retrieve access token based on the PIN number provided by the user.
+    // Store it in File/DB
+    // This access token would be used for any READ/WRITE
 }

Modified: openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/util/RetweetAppUtil.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/util/RetweetAppUtil.java?rev=1131512&r1=1131511&r2=1131512&view=diff
==============================================================================
--- openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/util/RetweetAppUtil.java
(original)
+++ openejb/trunk/sandbox/tools/src/main/java/org/apache/openejb/tools/twitter/util/RetweetAppUtil.java
Sun Jun  5 01:48:46 2011
@@ -16,33 +16,33 @@
  */
 package org.apache.openejb.tools.twitter.util;
 
+import org.springframework.core.io.ClassPathResource;
+
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.Properties;
 
-import org.springframework.core.io.ClassPathResource;
-
 public class RetweetAppUtil {
-	
-	public static Properties getTwitterAppProperties() {
 
-		Properties retweetAppProperties = new Properties();
-		try {
-			ClassPathResource retweetToolPropertiesFile = new ClassPathResource(
-			"RetweetTool.properties");
-			retweetAppProperties.load(retweetToolPropertiesFile
-					.getInputStream());
-		} catch (FileNotFoundException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-
-		System.out.print("Using the following properties: ");
-		System.out.print("---------------------------------");
-		retweetAppProperties.list(System.out);
-		return retweetAppProperties;
+    public static Properties getTwitterAppProperties() {
+
+        Properties retweetAppProperties = new Properties();
+        try {
+            ClassPathResource retweetToolPropertiesFile = new ClassPathResource(
+                    "RetweetTool.properties");
+            retweetAppProperties.load(retweetToolPropertiesFile
+                    .getInputStream());
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        System.out.print("Using the following properties: ");
+        System.out.print("---------------------------------");
+        retweetAppProperties.list(System.out);
+        return retweetAppProperties;
 
-	}
+    }
 
 }



Mime
View raw message