import be.nikiroo.fanfix.bundles.Config;
import be.nikiroo.fanfix.bundles.StringId;
import be.nikiroo.fanfix.data.Chapter;
+import be.nikiroo.fanfix.data.MetaData;
import be.nikiroo.fanfix.data.Story;
import be.nikiroo.fanfix.library.BasicLibrary;
import be.nikiroo.fanfix.library.CacheLibrary;
*/
public static int imprt(String urlString, Progress pg) {
try {
- Story story = Instance.getLibrary().imprt(
+ MetaData meta = Instance.getLibrary().imprt(
BasicReader.getUrl(urlString), pg);
- System.out.println(story.getMeta().getLuid() + ": \""
- + story.getMeta().getTitle() + "\" imported.");
+ System.out.println(meta.getLuid() + ": \"" + meta.getTitle()
+ + "\" imported.");
} catch (IOException e) {
Instance.getTraceHandler().error(e);
return 1;
* @param pg
* the optional progress reporter
*
- * @return the imported {@link Story}
+ * @return the imported Story {@link MetaData}
*
* @throws UnknownHostException
* if the host is not supported
* @throws IOException
* in case of I/O error
*/
- public Story imprt(URL url, Progress pg) throws IOException {
+ public MetaData imprt(URL url, Progress pg) throws IOException {
if (pg == null)
pg = new Progress();
Story story = save(support.process(pgProcess), pgSave);
pg.done();
- return story;
+ return story.getMeta();
}
/**
}
@Override
- public Story imprt(URL url, Progress pg) throws IOException {
+ public MetaData imprt(URL url, Progress pg) throws IOException {
if (pg == null) {
pg = new Progress();
}
pg.addProgress(pgImprt, 7);
pg.addProgress(pgCache, 3);
- Story story = lib.imprt(url, pgImprt);
- cacheLib.save(story, story.getMeta().getLuid(), pgCache);
-
- updateInfo(story.getMeta());
+ MetaData meta = lib.imprt(url, pgImprt);
+ updateInfo(meta);
+
+ clearFromCache(meta.getLuid());
pg.done();
- return story;
+ return meta;
}
// All the following methods are only used by Save and Delete in
* <li><b>wl</b>: flag to allow access to all the stories (bypassing the
* whitelist if it exists)</li>
* </ul>
- *
+ * <p>
* Some examples:
* <ul>
* <li><b>my_key</b>: normal connection, will take the default server
@Override
// Could work (more slowly) without it
- public Story imprt(final URL url, Progress pg) throws IOException {
+ public MetaData imprt(final URL url, Progress pg) throws IOException {
// Import the file locally if it is actually a file
+
if (url == null || url.getProtocol().equalsIgnoreCase("file")) {
return super.imprt(url, pg);
}
pg = new Progress();
}
- pg.setMinMax(0, 2);
- Progress pgImprt = new Progress();
- Progress pgGet = new Progress();
- pg.addProgress(pgImprt, 1);
- pg.addProgress(pgGet, 1);
-
- final Progress pgF = pgImprt;
+ final Progress pgF = pg;
final String[] luid = new String[1];
connectRemoteAction(new RemoteAction() {
throw new IOException("Remote failure");
}
- Story story = getStory(luid[0], pgGet);
- pgGet.done();
-
pg.done();
- return story;
+ return getInfo(luid[0]);
}
@Override
}
Progress pg = createPgForwarder(action);
- Story story = Instance.getLibrary().imprt(
+ MetaData meta = Instance.getLibrary().imprt(
new URL((String) args[0]), pg);
forcePgDoneSent(pg);
- return story.getMeta().getLuid();
+ return meta.getLuid();
} else if ("DELETE_STORY".equals(command)) {
if (!rw) {
throw new RemoteLibraryException("Read-Only remote library: "
import be.nikiroo.fanfix.output.BasicOutput.OutputType;
import be.nikiroo.fanfix.reader.BasicReader;
import be.nikiroo.fanfix.reader.ui.GuiReaderMainPanel.FrameHelper;
-import be.nikiroo.fanfix.reader.ui.GuiReaderMainPanel.StoryRunnable;
+import be.nikiroo.fanfix.reader.ui.GuiReaderMainPanel.MetaDataRunnable;
import be.nikiroo.fanfix.searchable.BasicSearchable;
import be.nikiroo.fanfix.supported.SupportType;
import be.nikiroo.utils.Progress;
final GuiReaderBook selectedBook = mainPanel.getSelectedBook();
if (selectedBook != null) {
final MetaData meta = selectedBook.getInfo().getMeta();
- mainPanel.imprt(meta.getUrl(), new StoryRunnable() {
+ mainPanel.imprt(meta.getUrl(), new MetaDataRunnable() {
@Override
- public void run(Story story) {
- MetaData newMeta = story.getMeta();
+ public void run(MetaData newMeta) {
if (!newMeta.getSource().equals(meta.getSource())) {
reader.changeSource(newMeta.getLuid(),
meta.getSource());
}
/**
- * A {@link Runnable} with a {@link Story} parameter.
+ * A {@link Runnable} with a {@link MetaData} parameter.
*
* @author niki
*/
- public interface StoryRunnable {
+ public interface MetaDataRunnable {
/**
* Run the action.
*
- * @param story
- * the story
+ * @param meta
+ * the meta of the story
*/
- public void run(Story story);
+ public void run(MetaData meta);
}
/**
* @param onSuccessPgName
* the name to use for the onSuccess progress bar
*/
- public void imprt(final String url, final StoryRunnable onSuccess,
+ public void imprt(final String url, final MetaDataRunnable onSuccess,
String onSuccessPgName) {
final Progress pg = new Progress();
final Progress pgImprt = new Progress();
@Override
public void run() {
Exception ex = null;
- Story story = null;
+ MetaData meta = null;
try {
- story = helper.getReader().getLibrary()
+ meta = helper.getReader().getLibrary()
.imprt(BasicReader.getUrl(url), pgImprt);
} catch (IOException e) {
ex = e;
}
} else {
if (onSuccess != null) {
- onSuccess.run(story);
+ onSuccess.run(meta);
}
}
pgOnSuccess.done();