[Lutinweb-commits] r72 - trunk/lutinrss/src/main/java/org/codelutin/rss
Author: tchemit Date: 2008-05-30 09:51:30 +0000 (Fri, 30 May 2008) New Revision: 72 Modified: trunk/lutinrss/src/main/java/org/codelutin/rss/RSSConfig.java trunk/lutinrss/src/main/java/org/codelutin/rss/RSSGeneratorHelper.java Log: test de coherence des param?\195?\168tres pass?\195?\169s (null,...) Modified: trunk/lutinrss/src/main/java/org/codelutin/rss/RSSConfig.java =================================================================== --- trunk/lutinrss/src/main/java/org/codelutin/rss/RSSConfig.java 2008-05-29 21:42:11 UTC (rev 71) +++ trunk/lutinrss/src/main/java/org/codelutin/rss/RSSConfig.java 2008-05-30 09:51:30 UTC (rev 72) @@ -22,6 +22,8 @@ public static int DEFAULT_GENERATOR_NB_ITEM = 100; + public static FeedType DEFAULT_GENERATOR_FORMAT = FeedType.RSS_2_0; + public static Class<? extends FeedRenderer> DEFAULT_RENDERER_CLASS = FeedHTMLRenderer.class; public static Class<? extends FeedURLResolver> DEFAULT_RESOLVER_CLASS = SimpleFeedURLResolver.class; @@ -49,6 +51,11 @@ public static void setDEFAULT_GENERATOR_NB_ITEM(int DEFAULT_GENERATOR_NB_ITEM) { RSSConfig.DEFAULT_GENERATOR_NB_ITEM = DEFAULT_GENERATOR_NB_ITEM; } + + public static void setDEFAULT_GENERATOR_FORMAT(FeedType DEFAULT_GENERATOR_FORMAT) { + RSSConfig.DEFAULT_GENERATOR_FORMAT = DEFAULT_GENERATOR_FORMAT; + } + /** * * @param T la classe sources de la configuration @@ -77,6 +84,7 @@ loadConfig(config, instance, prefixConfig, "DEFAULT_RENDERER_CLASS"); loadConfig(config, instance, prefixConfig, "DEFAULT_RESOLVER_CLASS"); loadConfig(config, instance, prefixConfig, "DEFAULT_GENERATOR_NB_ITEM"); + loadConfig(config, instance, prefixConfig, "DEFAULT_GENERATOR_FORMAT"); } protected void loadConfig(T config, RSSConfig instance, String prefix, String configName) { Modified: trunk/lutinrss/src/main/java/org/codelutin/rss/RSSGeneratorHelper.java =================================================================== --- trunk/lutinrss/src/main/java/org/codelutin/rss/RSSGeneratorHelper.java 2008-05-29 21:42:11 UTC (rev 71) +++ trunk/lutinrss/src/main/java/org/codelutin/rss/RSSGeneratorHelper.java 2008-05-30 09:51:30 UTC (rev 72) @@ -80,6 +80,16 @@ * @param values properties of the feed */ public void createFeedFile(URL url, FeedType type, Map<Field, Object> values) throws IOException, FeedException, ParseException { + if (url==null) { + throw new NullPointerException("can not create a feed with null url"); + } + if (type==null) { + throw new NullPointerException("can not create a feed with null feedtype"); + } + if (values==null || values.isEmpty()) { + //TODO Should check mandatory values (title, link,...) + throw new NullPointerException("can not create a feed with null nor empty values dictonnary"); + } File f = getFile(url); if (f.exists()) { @@ -112,7 +122,13 @@ * @param values dictionnary of properties to write */ public void addItemToFeedFile(URL url, int nbEntries, Map<Field, Object> values) throws FileNotFoundException, IOException, IllegalArgumentException, FeedException, ParseException { - + if (url==null) { + throw new NullPointerException("can not add a feed's entry with null url"); + } + if (values==null || values.isEmpty()) { + //TODO Should check mandatory values (title, link,...) + throw new NullPointerException("can not add a feed's entry with null nor empty values dictonnary"); + } File f = getFile(url); if (!f.exists()) {
participants (1)
-
tchemit@users.labs.libre-entreprise.org