// Path: ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/twitter/PartyListHandler.java
// public class PartyListHandler {
// 
// 	private static final Logger LOGGER = LoggerFactory.getLogger(PartyListHandler.class);
// 
// 	private static final long REFRESH_TIME = 6 * 60 * 60 * 1000;
// 
// 	private final Configuration twitterConfig;
// 	private final Map<String, PartyConfiguration> parties;
// 
// 	private boolean hasChanged;
// 	private Date updateTime;
// 
// 
// 	private Map<String, Set<Long>> partyMemberIds = new HashMap<>();
// 	private Map<Long, String> memberParties = new HashMap<>();
// 
// 	public PartyListHandler(Configuration twitterConfig, Map<String, PartyConfiguration> parties) {
// 		this.twitterConfig = twitterConfig;
// 		this.parties = parties;
// 	}
// 
// 
// 	public void refreshLists() {
// 		Map<String, Set<Long>> memberIds = new HashMap<>();
// 
// 		Authorization auth = AuthorizationFactory.getInstance(twitterConfig);
// 		TwitterFactory tf = new TwitterFactory(twitterConfig);
// 		Twitter twitter = tf.getInstance(auth);
// 		for (PartyConfiguration pc : parties.values()) {
// 			Set<Long> ids = readPartyIds(twitter, pc.getTwitterScreenName(), pc.getTwitterListSlug(), pc.getDisplayName());
// 			if (!ids.isEmpty()) {
// 				memberIds.put(pc.getDisplayName(), ids);
// 			}
// 		}
// 
// 		synchronized(partyMemberIds) {
// 			for (String party : memberIds.keySet()) {
// 				if (!partyMemberIds.containsKey(party) || Sets.symmetricDifference(memberIds.get(party), partyMemberIds.get(party)).size() > 0) {
// 					hasChanged = true;
// 					partyMemberIds.put(party, memberIds.get(party));
// 					LOGGER.debug("Updated list for {} with {} ids", party, memberIds.get(party).size());
// 				}
// 			}
// 		}
// 
// 		if (hasChanged) {
// 			updateTime = new Date();
// 			memberParties.clear();
// 		}
// 	}
// 
// 	private Set<Long> readPartyIds(Twitter twitter, String screenName, String slug, String party) {
// 		Set<Long> ids = new HashSet<>();
// 
// 		try {
// 			long cursor = -1;
// 			PagableResponseList<User> response = null;
// 			do {
// 				response = twitter.getUserListMembers(screenName, slug, cursor);
// 				for (User user : response) {
// 					LOGGER.debug("Read id for user @{}", user.getScreenName());
// 					ids.add(user.getId());
// 				}
// 				cursor = response.getNextCursor();
// 			} while (response != null && response.hasNext());
// 		} catch (TwitterException e) {
// 			LOGGER.error("Twitter exception updating {} party list : {}", party, e.getMessage());
// 		}
// 
// 		return ids;
// 	}
// 
// 
// 	public boolean listsChanged() {
// 		return hasChanged;
// 	}
// 
// 
// 	public boolean isTimeToUpdate() {
// 		return updateTime.before(new Date(new Date().getTime() - REFRESH_TIME));
// 	}
// 
// 	public Collection<Long> getPartyMemberIds(String party) {
// 		return partyMemberIds.get(party);
// 	}
// 
// 	public List<Long> getAllPartyMemberIds() {
// 		List<Long> ids = new ArrayList<>();
// 
// 		for (Set<Long> memberIds : partyMemberIds.values()) {
// 			ids.addAll(memberIds);
// 		}
// 
// 		return ids;
// 	}
// 
// 	public Map<Long, String> getMemberParties() {
// 		if (memberParties == null || memberParties.size() == 0) {
// 			synchronized (memberParties) {
// 				// Initialise member parties map
// 				for (String party : partyMemberIds.keySet()) {
// 					for (Long memberId : partyMemberIds.get(party)) {
// 						memberParties.put(memberId, party);
// 					}
// 				}
// 			}
// 		}
// 
// 		return memberParties;
// 	}
// 
// }


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import org.yaml.snakeyaml.Yaml;
import twitter4j.conf.Configuration;
import twitter4j.conf.PropertyConfiguration;
import uk.co.flax.ukmp.twitter.PartyListHandler;
			br = new BufferedReader(new FileReader(configFile));
			ret = yaml.loadAs(br, IndexerConfiguration.class);
		} finally {
			if (br != null) {
				br.close();
			}
		}

		return ret;
	}


	private Configuration readTwitterConfiguration(String twitterConfigFile) throws IOException {
		Configuration twitterConfig = null;
		InputStream is = null;

		try {
			is = new FileInputStream(config.getAuthenticationFile());
			twitterConfig = new PropertyConfiguration(is);
		} finally {
			if (is != null) {
				is.close();
			}
		}

		return twitterConfig;
	}


	public void run() {
// Path: ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/twitter/PartyListHandler.java
// public class PartyListHandler {
// 
// 	private static final Logger LOGGER = LoggerFactory.getLogger(PartyListHandler.class);
// 
// 	private static final long REFRESH_TIME = 6 * 60 * 60 * 1000;
// 
// 	private final Configuration twitterConfig;
// 	private final Map<String, PartyConfiguration> parties;
// 
// 	private boolean hasChanged;
// 	private Date updateTime;
// 
// 
// 	private Map<String, Set<Long>> partyMemberIds = new HashMap<>();
// 	private Map<Long, String> memberParties = new HashMap<>();
// 
// 	public PartyListHandler(Configuration twitterConfig, Map<String, PartyConfiguration> parties) {
// 		this.twitterConfig = twitterConfig;
// 		this.parties = parties;
// 	}
// 
// 
// 	public void refreshLists() {
// 		Map<String, Set<Long>> memberIds = new HashMap<>();
// 
// 		Authorization auth = AuthorizationFactory.getInstance(twitterConfig);
// 		TwitterFactory tf = new TwitterFactory(twitterConfig);
// 		Twitter twitter = tf.getInstance(auth);
// 		for (PartyConfiguration pc : parties.values()) {
// 			Set<Long> ids = readPartyIds(twitter, pc.getTwitterScreenName(), pc.getTwitterListSlug(), pc.getDisplayName());
// 			if (!ids.isEmpty()) {
// 				memberIds.put(pc.getDisplayName(), ids);
// 			}
// 		}
// 
// 		synchronized(partyMemberIds) {
// 			for (String party : memberIds.keySet()) {
// 				if (!partyMemberIds.containsKey(party) || Sets.symmetricDifference(memberIds.get(party), partyMemberIds.get(party)).size() > 0) {
// 					hasChanged = true;
// 					partyMemberIds.put(party, memberIds.get(party));
// 					LOGGER.debug("Updated list for {} with {} ids", party, memberIds.get(party).size());
// 				}
// 			}
// 		}
// 
// 		if (hasChanged) {
// 			updateTime = new Date();
// 			memberParties.clear();
// 		}
// 	}
// 
// 	private Set<Long> readPartyIds(Twitter twitter, String screenName, String slug, String party) {
// 		Set<Long> ids = new HashSet<>();
// 
// 		try {
// 			long cursor = -1;
// 			PagableResponseList<User> response = null;
// 			do {
// 				response = twitter.getUserListMembers(screenName, slug, cursor);
// 				for (User user : response) {
// 					LOGGER.debug("Read id for user @{}", user.getScreenName());
// 					ids.add(user.getId());
// 				}
// 				cursor = response.getNextCursor();
// 			} while (response != null && response.hasNext());
// 		} catch (TwitterException e) {
// 			LOGGER.error("Twitter exception updating {} party list : {}", party, e.getMessage());
// 		}
// 
// 		return ids;
// 	}
// 
// 
// 	public boolean listsChanged() {
// 		return hasChanged;
// 	}
// 
// 
// 	public boolean isTimeToUpdate() {
// 		return updateTime.before(new Date(new Date().getTime() - REFRESH_TIME));
// 	}
// 
// 	public Collection<Long> getPartyMemberIds(String party) {
// 		return partyMemberIds.get(party);
// 	}
// 
// 	public List<Long> getAllPartyMemberIds() {
// 		List<Long> ids = new ArrayList<>();
// 
// 		for (Set<Long> memberIds : partyMemberIds.values()) {
// 			ids.addAll(memberIds);
// 		}
// 
// 		return ids;
// 	}
// 
// 	public Map<Long, String> getMemberParties() {
// 		if (memberParties == null || memberParties.size() == 0) {
// 			synchronized (memberParties) {
// 				// Initialise member parties map
// 				for (String party : partyMemberIds.keySet()) {
// 					for (Long memberId : partyMemberIds.get(party)) {
// 						memberParties.put(memberId, party);
// 					}
// 				}
// 			}
// 		}
// 
// 		return memberParties;
// 	}
// 
// }


// Path: ukmp/java/indexer/src/main/java/uk/co/flax/ukmp/Indexer.java
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import org.yaml.snakeyaml.Yaml;
import twitter4j.conf.Configuration;
import twitter4j.conf.PropertyConfiguration;
import uk.co.flax.ukmp.twitter.PartyListHandler;

			br = new BufferedReader(new FileReader(configFile));
			ret = yaml.loadAs(br, IndexerConfiguration.class);
		} finally {
			if (br != null) {
				br.close();
			}
		}

		return ret;
	}


	private Configuration readTwitterConfiguration(String twitterConfigFile) throws IOException {
		Configuration twitterConfig = null;
		InputStream is = null;

		try {
			is = new FileInputStream(config.getAuthenticationFile());
			twitterConfig = new PropertyConfiguration(is);
		} finally {
			if (is != null) {
				is.close();
			}
		}

		return twitterConfig;
	}


	public void run() {
		PartyListHandler listHandler = new PartyListHandler(twitterConfig, config.getParties());