Merge branch 'subtree'
[fanfix.git] / src / be / nikiroo / fanfix / supported / BasicSupport.java
index f1635589bfd70b0dca80b5972dcfd241bda895f8..9b56f885d94a14ff1025b3833aa34209c48374dd 100644 (file)
@@ -12,6 +12,7 @@ import java.util.Map;
 import java.util.Scanner;
 import java.util.Map.Entry;
 
+import org.json.JSONException;
 import org.json.JSONObject;
 import org.jsoup.helper.DataUtil;
 import org.jsoup.nodes.Document;
@@ -271,7 +272,14 @@ public abstract class BasicSupport {
                pg.setProgress(30);
 
                Story story = new Story();
+               
                MetaData meta = getMeta();
+               meta.setType(getType().toString());
+               meta.setSource(getType().getSourceName());
+               if (meta.getPublisher() == null) {
+                       meta.setPublisher(getType().getSourceName());
+               }
+
                if (meta.getCreationDate() == null
                                || meta.getCreationDate().trim().isEmpty()) {
                        meta.setCreationDate(bsHelper
@@ -346,7 +354,12 @@ public abstract class BasicSupport {
                        Scanner scan = new Scanner(in);
                        scan.useDelimiter("\0");
                        try {
+                               if(!scan.hasNext())
+                                       throw new IOException("The given input was empty");
+                               
                                return new JSONObject(scan.next());
+                       } catch (JSONException e) {
+                               throw new IOException(e);
                        } finally {
                                scan.close();
                        }