Fix UTF-8 and "/" -> "\" issues for Win32
[fanfix.git] / src / be / nikiroo / fanfix / reader / LocalReader.java
index 26f48f5a21210fe4d6026b44d0e2bdae3cf3e2c1..86b779c343c0b964d9c80d96493ccd47ec02f7d5 100644 (file)
@@ -10,7 +10,6 @@ import be.nikiroo.fanfix.bundles.Config;
 import be.nikiroo.fanfix.data.MetaData;
 import be.nikiroo.fanfix.data.Story;
 import be.nikiroo.fanfix.output.BasicOutput.OutputType;
-import be.nikiroo.fanfix.supported.BasicSupport.SupportType;
 
 class LocalReader extends BasicReader {
        private Library lib;
@@ -49,21 +48,23 @@ class LocalReader extends BasicReader {
        }
 
        // return new luid
-       public String imprt(String luid) {
+       public String imprt(String luid) throws IOException {
                try {
                        Story story = Instance.getLibrary().getStory(luid);
-                       story = lib.save(story);
-                       return story.getMeta().getLuid();
+                       if (story != null) {
+                               story = lib.save(story);
+                               return story.getMeta().getLuid();
+                       } else {
+                               throw new IOException("Cannot find story in Library: " + luid);
+                       }
                } catch (IOException e) {
-                       Instance.syserr(new IOException(
+                       throw new IOException(
                                        "Cannot import story from library to LocalReader library: "
-                                                       + luid, e));
+                                                       + luid, e);
                }
-
-               return null;
        }
 
-       public File getTarget(String luid) {
+       public File getTarget(String luid) throws IOException {
                MetaData meta = lib.getInfo(luid);
                File file = lib.getFile(luid);
                if (file == null) {
@@ -76,8 +77,8 @@ class LocalReader extends BasicReader {
        }
 
        @Override
-       public void start(SupportType type) {
-               final SupportType typeFinal = type;
+       public void start(String type) {
+               final String typeFinal = type;
                EventQueue.invokeLater(new Runnable() {
                        public void run() {
                                new LocalReaderFrame(LocalReader.this, typeFinal)
@@ -85,8 +86,4 @@ class LocalReader extends BasicReader {
                        }
                });
        }
-
-       public static void main(String[] args) throws IOException {
-               new LocalReader().start(null);
-       }
 }