X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FBasicLibrary.java;h=c2ab12b7b735d8349b51ea1beaaeab3ca7bac8e8;hb=ef98466f666072746af72a45a40274110990f8bd;hp=b92e5b078b01047e4e40375ec401f47b4f6bfe73;hpb=1f2a7d5fe14f98b5dd762207eeaff90494fe102e;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/library/BasicLibrary.java b/src/be/nikiroo/fanfix/library/BasicLibrary.java index b92e5b0..c2ab12b 100644 --- a/src/be/nikiroo/fanfix/library/BasicLibrary.java +++ b/src/be/nikiroo/fanfix/library/BasicLibrary.java @@ -149,7 +149,7 @@ abstract public class BasicLibrary { return custom; } - List metas = getListBySource(source); + List metas = getList().filter(source, null, null); if (metas.size() > 0) { return getCover(metas.get(0).getLuid()); } @@ -177,7 +177,7 @@ abstract public class BasicLibrary { return custom; } - List metas = getListByAuthor(author); + List metas = getList().filter(null, author, null); if (metas.size() > 0) { return getCover(metas.get(0).getLuid()); } @@ -338,13 +338,43 @@ abstract public class BasicLibrary { * @param pg * the optional progress reporter */ - public void refresh(Progress pg) { + public synchronized void refresh(Progress pg) { try { getMetas(pg); } catch (IOException e) { // We will let it fail later } } + + /** + * Check if the {@link Story} denoted by this Library UID is present in the + * cache (if we have no cache, we default to true). + * + * @param luid + * the Library UID + * + * @return TRUE if it is + */ + public boolean isCached(String luid) { + // By default, everything is cached + return true; + } + + /** + * Clear the {@link Story} from the cache, if needed. + *

+ * The next time we try to retrieve the {@link Story}, it may be required to + * cache it again. + * + * @param luid + * the story to clear + * + * @throws IOException + * in case of I/O error + */ + public void clearFromCache(String luid) throws IOException { + // By default, this is a noop. + } /** * List all the known types (sources) of stories. @@ -567,61 +597,8 @@ abstract public class BasicLibrary { * @throws IOException * in case of IOException */ - public synchronized List getList() throws IOException { - return getMetas(null); - } - - /** - * List all the stories of the given source type in the {@link BasicLibrary} , - * or all the stories if NULL is passed as a type. - *

- * Cover images not included. - * - * @param source the type of story to retrieve, or NULL for all - * - * @return the stories - * - * @throws IOException in case of IOException - * - * @deprecated use {@link BasicLibrary#getList(Progress)} and - * {@link MetaResultList#filter(List, List, List)} - */ - @Deprecated - public synchronized List getListBySource(String source) throws IOException { - List sources = null; - if (source != null) { - sources = new ArrayList(); - sources.add(source); - } - - return getList(null).filter(sources, null, null); - } - - /** - * List all the stories of the given author in the {@link BasicLibrary}, or - * all the stories if NULL is passed as an author. - *

- * Cover images not included. - * - * @param author - * the author of the stories to retrieve, or NULL for all - * - * @return the stories - * - * @throws IOException - * in case of IOException - * - * @deprecated use {@link BasicLibrary#getList(Progress)} and - * {@link MetaResultList#filter(List, List, List)} - */ - public synchronized List getListByAuthor(String author) throws IOException { - List authors = null; - if (author != null) { - authors = new ArrayList(); - authors.add(author); - } - - return getList(null).filter(null, authors, null); + public MetaResultList getList() throws IOException { + return getList(null); } /** @@ -1040,8 +1017,6 @@ abstract public class BasicLibrary { meta.setTitle(newTitle); meta.setAuthor(newAuthor); saveMeta(meta, pg); - - invalidateInfo(luid); } /**