RetrieverForReddit/src/main/java/com/kdepagter/processor/SubredditProcessorThread.java
/**
	 * Prepares and executes call to Reddit API for subreddit data
	 * Processes Reddit JSON response and calls back to RedditRequestProcessor with SubredditItem
	 */
Prepares and executes call to Reddit API for subreddit data
Processes Reddit JSON response and calls back to RedditRequestProcessor with SubredditItem
Prepares and executes call to Reddit API for subreddit data Processes Reddit JSON response and calls back to RedditRequestProcessor with SubredditItem
@Override
	public void run(){
		log.info("Thread started for " + subredditName);
		long start = System.currentTimeMillis();
		RestTemplate restTemplate = new RestTemplate();
		String url = getUrlForReddit(subredditName);
		HttpEntity<String> httpEntity = setupHttpEntity();
		ResponseEntity<RedditResponse> respEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, RedditResponse.class);
		log.info("Response returned for " + subredditName);
		if(respEntity.getStatusCode().equals(HttpStatus.OK)){
			SubredditItem si = translateSubredditResponse(respEntity.getBody());
			processor.addResponse(subredditName, si);
		} else {
			RedditRequestValidator rrv = new RedditRequestValidator();
			processor.addResponse(subredditName, rrv.createErrorItem(subredditName + " returned bad HTTP response: " + respEntity.getStatusCode().toString()));
		}
		log.info("Process Time for " + subredditName + ": " + (System.currentTimeMillis() - start));
		subredditName = null;
	}
@ Override public void run ( ) { log . info ( "Thread started for " + subredditName ) ; long start = System . currentTimeMillis ( ) ; RestTemplate restTemplate = new RestTemplate ( ) ; String url = getUrlForReddit ( subredditName ) ; HttpEntity < String > httpEntity = setupHttpEntity ( ) ; ResponseEntity < RedditResponse > respEntity = restTemplate . exchange ( url , HttpMethod . GET , httpEntity , RedditResponse . class ) ; log . info ( "Response returned for " + subredditName ) ; if ( respEntity . getStatusCode ( ) . equals ( HttpStatus . OK ) ) { SubredditItem si = translateSubredditResponse ( respEntity . getBody ( ) ) ; processor . addResponse ( subredditName , si ) ; } else { RedditRequestValidator rrv = new RedditRequestValidator ( ) ; processor . addResponse ( subredditName , rrv . createErrorItem ( subredditName + " returned bad HTTP response: " + respEntity . getStatusCode ( ) . toString ( ) ) ) ; } log . info ( "Process Time for " + subredditName + ": " + ( System . currentTimeMillis ( ) - start ) ) ; subredditName = null ; }
Prepares and executes call to Reddit API for subreddit data
 Processes Reddit JSON response and calls back to RedditRequestProcessor with SubredditItem
Prepares and executes call to Reddit API for subreddit data Processes Reddit JSON response and calls back to RedditRequestProcessor with SubredditItem