X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2FLibrary.java;h=a8d9302bfe15cc05d87fe11345b11e6e3f3c0284;hp=abe760b0d24e31862764093be7bdbcf0b670ce0d;hb=3d247bc3bb955a9b85686f0db431157cb9dc4a10;hpb=301791d3fc0f152942b542e3d98ebddc0af528f2 diff --git a/src/be/nikiroo/fanfix/Library.java b/src/be/nikiroo/fanfix/Library.java index abe760b..a8d9302 100644 --- a/src/be/nikiroo/fanfix/Library.java +++ b/src/be/nikiroo/fanfix/Library.java @@ -52,6 +52,23 @@ public class Library { dir.mkdirs(); } + /** + * List all the known types of stories. + * + * @return the types + */ + public List getTypes() { + List list = new ArrayList(); + for (Entry entry : getStories().entrySet()) { + String storyType = entry.getValue().getParentFile().getName(); + if (!list.contains(storyType)) { + list.add(storyType); + } + } + + return list; + } + /** * List all the stories of the given source type in the {@link Library}, or * all the stories if NULL is passed as a type. @@ -61,13 +78,11 @@ public class Library { * * @return the stories */ - public List getList(SupportType type) { - String typeString = type == null ? null : type.getSourceName(); - + public List getList(String type) { List list = new ArrayList(); for (Entry entry : getStories().entrySet()) { String storyType = entry.getValue().getParentFile().getName(); - if (typeString == null || typeString.equalsIgnoreCase(storyType)) { + if (type == null || type.equalsIgnoreCase(storyType)) { list.add(entry.getKey()); } } @@ -121,7 +136,7 @@ public class Library { * @param luid * the Library UID of the story * - * @return the corresponding {@link Story} + * @return the corresponding {@link Story} or NULL if not found */ public Story getStory(String luid) { if (luid != null) { @@ -194,6 +209,11 @@ public class Library { throw new IOException("Output type not supported: " + type); } + Story story = getStory(luid); + if (story == null) { + throw new IOException("Cannot find story to export: " + luid); + } + return out.process(getStory(luid), target); } @@ -227,7 +247,9 @@ public class Library { * in case of I/O error */ private Story save(Story story, String luid) throws IOException { + // Do not change the original metadata, but change the original story MetaData key = story.getMeta().clone(); + story.setMeta(key); if (luid == null || luid.isEmpty()) { getStories(); // refresh lastId if needed