Changeset 141
- Timestamp:
- 01/30/06 14:33:45 (2 years ago)
- Files:
-
- feedtree/trunk/build.xml (modified) (2 diffs)
- feedtree/trunk/publisher.conf (modified) (1 diff)
- feedtree/trunk/src/net/feedtree/publisher/JSONPropertyFile.java (added)
- feedtree/trunk/src/net/feedtree/publisher/Publisher.java (modified) (10 diffs)
- feedtree/trunk/src/org (added)
- feedtree/trunk/src/org/json (added)
- feedtree/trunk/src/org/json/JSONArray.java (added)
- feedtree/trunk/src/org/json/JSONException.java (added)
- feedtree/trunk/src/org/json/JSONObject.java (added)
- feedtree/trunk/src/org/json/JSONStringer.java (added)
- feedtree/trunk/src/org/json/JSONTokener.java (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
feedtree/trunk/build.xml
r87 r141 104 104 </jar> 105 105 </target> 106 106 107 107 <!-- command-line proxy JAR file --> 108 108 <target name="ftproxy.jar" depends="compile" … … 141 141 <include name="net/feedtree/util/**/*.class"/> 142 142 <include name="net/feedtree/publisher/*.class"/> 143 <include name="org/json/**/*.class"/> 143 144 </fileset> 144 145 <include name="build.properties"/> feedtree/trunk/publisher.conf
r117 r141 2 2 # default configuration file for the FeedTree publisher 3 3 # http://feedtree.net/ 4 # 5 # File format (version 2): 6 # key = 12345 7 # key = "string" 8 # key = [ "a", "list", "of", "things" ] 4 9 5 #### Feed information ####6 10 7 # whitespace-separated list of URLs to be published 8 feed_urls = http://dsandler.org/wp/feed/atom/ 11 ###################################################################### 12 ## Feed information 13 ###################################################################### 9 14 10 # how often (in seconds) to reload each feed looking for new items (default: 120) 15 # list of feed URLs to be fetched by the publisher & pushed to FeedTree 16 feeds = [ 17 "http://dsandler.org/wp/feed/atom/" 18 ] 19 20 # how often (in seconds) to reload each feed looking for new items (default = 120) 11 21 fetch_interval_sec = 120 12 22 13 # how often a heartbeat should be sent in absence of new items (default :600)23 # how often a heartbeat should be sent in absence of new items (default = 600) 14 24 heartbeat_interval_sec = 600 15 25 16 26 # file to store cached feed data (previously-seen entries) in 17 feed_cache_file = publisher_feeds.cache27 feed_cache_file = "publisher_feeds.cache" 18 28 19 29 #### Keystore information #### 20 30 21 31 # path to a JKS or PKCS#12 keystore file 22 keystore = demokey.jks32 keystore = "demokey.jks" 23 33 24 34 # type of the keystore (e.g. JKS or PKCS12; default JKS) 25 keystore_type = JKS35 keystore_type = "JKS" 26 36 27 # password for the keystore (default :blank)28 keystore_password = monkey37 # password for the keystore (default = blank) 38 keystore_password = "monkey" 29 39 30 # identifier of the key to be used for signing (default :"default")31 key_name = demokey40 # identifier of the key to be used for signing (default = "default") 41 key_name = "demokey" 32 42 33 # password to access <key_name> (default :blank)34 key_password = monkey43 # password to access <key_name> (default = blank) 44 key_password = "monkey" 35 45 36 #### Common FeedTree/Pastry network parameters #### 46 47 ###################################################################### 48 ## Common FeedTree/Pastry network parameters 49 ###################################################################### 37 50 38 51 # port to run the FeedTree node on (default 29690; this is the port that 39 52 # must be forwarded to the Publisher host in a NAT situation) 53 # note that this must be changed to something else (e.g, 29691) if 29690 is 54 # occupied (i.e. by a FeedTree proxy running on the same host) 40 55 node_port = 29691 41 56 42 # port for the Publisher web interface 43 web_port = 850257 # port for the Publisher web interface (currently unused) 58 web_port = 8502 44 59 45 60 # TODO: add access control for the web interface to this file 46 61 47 #### Less common FeedTree/Pastry network parameters #### 62 63 ###################################################################### 64 ## Less common FeedTree/Pastry network parameters 65 ###################################################################### 48 66 49 67 # host to contact when starting (bootstrap.feedtree.net will boot you into 50 68 # the global FeedTree network) 51 bootstrap = bootstrap.feedtree.net69 bootstrap = "bootstrap.feedtree.net" 52 70 53 71 # port on the bootstrap to contact (29690 is the FeedTree default) feedtree/trunk/src/net/feedtree/publisher/Publisher.java
r119 r141 57 57 import java.security.*; 58 58 59 import org.json.*; 60 59 61 public class Publisher 60 62 extends Client … … 97 99 public static final String PROP_WEB_PORT = "web_port"; 98 100 99 /// Whitespace-separated list of URLs to publish (may be 100 /// <tt>file:///</tt> URLs) 101 public static final String PROP_FEED_URLS = "feed_urls"; 102 101 /// JSON list (i.e. enclosed in square-brackets) of feed URLs 102 /// Example: 103 /// feeds = [ 104 /// "http://site.com/feed/atom/", 105 /// "http://site.com/feed/rss2/" 106 /// ] 107 public static final String PROP_FEEDS = "feeds"; 108 103 109 /// Filename of a local keystore (optional; required for signing entries) 104 110 public static final String PROP_KEYSTORE = "keystore"; … … 124 130 protected static ClassLoader g_classLoader; 125 131 protected static Properties g_buildProperties; 126 protected static Propertiesg_config;132 protected static JSONPropertyFile g_config; 127 133 128 134 protected PrivateKey m_key = null; … … 602 608 603 609 m_storage = Shelf.open( 604 g_config. getProperty(PROP_CACHE_FILE, "publisher_feeds.cache"));610 g_config.optString(PROP_CACHE_FILE, "publisher_feeds.cache")); 605 611 Integer storageVers = (Integer)m_storage.get("version"); 606 612 if (storageVers == null || storageVers.intValue() < 1) { … … 647 653 m_startDate = new Date(); 648 654 649 m_checkInterval = new Long(650 g_config. getProperty(PROP_FETCH_INTERVAL, "120")).longValue() * 1000L;651 m_heartbeatInterval = new Long(652 g_config. getProperty(PROP_HEARTBEAT_INTERVAL, "600")).longValue() * 1000L;655 m_checkInterval = 656 g_config.optLong(PROP_FETCH_INTERVAL, 120L) * 1000L; 657 m_heartbeatInterval = 658 g_config.optLong(PROP_HEARTBEAT_INTERVAL, 600L) * 1000L; 653 659 654 660 Logger.global.info("### Scheduling first refresh task for " … … 671 677 } 672 678 673 protected static final int to_int(String s) {674 return new Integer(s).intValue();675 }676 677 679 public static void main(String[] args) { 678 680 // Disable use of graphics accelerator for Sparklines … … 690 692 } 691 693 692 g_config = new Properties();693 694 String confFile = DEFAULT_PROPERTIES_FILE; 694 695 … … 718 719 719 720 try { 720 g_config.load(new FileInputStream(confFile)); 721 g_config = new JSONPropertyFile(confFile); 722 723 //System.out.println("CONFIG:"); 724 //System.out.println(g_config.toString()); 725 } catch (JSONException exc) { 726 Logger.global.severe("error: could not parse publisher configuration from file: " + confFile); 727 Logger.global.severe("error: problem was: " + exc.toString()); 728 Logger.global.severe("error: Maybe your configuration file has an old format? Please see http://feedtree.net/project/wiki/FeedTreePublisher to learn about the new JSON-based config file syntax."); 729 System.exit(1); 721 730 } catch (IOException exc) { 722 731 Logger.global.severe("error: could not load publisher configuration from file: " + confFile); … … 724 733 } 725 734 726 int myPort = to_int(g_config.getProperty( 727 PROP_PASTRY_PORT, new Integer(Client.PASTRY_PORT).toString())); 728 int bsPort = to_int(g_config.getProperty( 729 PROP_BOOTSTRAP_PORT, new Integer(Client.PASTRY_PORT).toString())); 730 String bs = g_config.getProperty( 735 int myPort = g_config.optInt(PROP_PASTRY_PORT, Client.PASTRY_PORT); 736 int bsPort = g_config.optInt(PROP_BOOTSTRAP_PORT, Client.PASTRY_PORT); 737 String bs = g_config.optString( 731 738 PROP_BOOTSTRAP, DEFAULT_BOOTSTRAP); 732 739 733 int webPort = to_int(g_config.getProperty(PROP_WEB_PORT, "8500")); 734 String[] urls = g_config.getProperty(PROP_FEED_URLS,"").split("\\s+"); 735 if (urls.length == 0) { 736 Logger.global.severe("error: no feed_urls specified in " + confFile); 740 int webPort = g_config.optInt(PROP_WEB_PORT, 8500); 741 742 String[] urls = null; 743 744 JSONArray urlList = g_config.optJSONArray(PROP_FEEDS); 745 746 if (urlList == null || urlList.length() == 0) { 747 Logger.global.severe("error: no " + PROP_FEEDS + " specified in " + confFile); 737 748 System.exit(1); 749 } else { 750 int len = urlList.length(); 751 urls = new String[len]; 752 try { 753 for (int i=0; i<len; i++) { 754 urls[i] = urlList.getString(i); 755 } 756 } catch (JSONException exc) { 757 Logger.global.severe("error: invalid syntax for " + PROP_FEEDS + ": " + exc.toString()); 758 } 738 759 } 739 760 740 761 PrivateKey privateKey = null; 741 String keystoreFile = g_config.getProperty( 742 PROP_KEYSTORE); 762 String keystoreFile = g_config.optString(PROP_KEYSTORE, null); 743 763 if (keystoreFile == null) { 744 764 Logger.global.info("No keystore; entries will not be signed"); 745 765 } else { 746 String keystoreType = g_config. getProperty(766 String keystoreType = g_config.optString( 747 767 PROP_KEYSTORE_TYPE, "JKS"); 748 768 try { 749 769 KeyStore ks = KeyStore.getInstance(keystoreType); 750 770 ks.load(new FileInputStream(keystoreFile), 751 g_config. getProperty(PROP_KEYSTORE_PASS, "").toCharArray());771 g_config.optString(PROP_KEYSTORE_PASS, "").toCharArray()); 752 772 privateKey = (PrivateKey)ks.getKey( 753 g_config. getProperty(PROP_KEY_NAME, "default"),754 g_config. getProperty(PROP_KEY_PASS, "").toCharArray());773 g_config.optString(PROP_KEY_NAME, "default"), 774 g_config.optString(PROP_KEY_PASS, "").toCharArray()); 755 775 756 776 } catch (FileNotFoundException exc) { … … 768 788 // systemwide default proxy is a FeedTree web proxy application. 769 789 System.setProperty("http.proxyHost", 770 g_config. getProperty(PROP_HTTP_PROXY, ""));790 g_config.optString(PROP_HTTP_PROXY, "")); 771 791 772 792
