weblib: fix delete and imprt
authorNiki Roo <niki@nikiroo.be>
Thu, 14 May 2020 11:11:37 +0000 (13:11 +0200)
committerNiki Roo <niki@nikiroo.be>
Thu, 14 May 2020 11:11:37 +0000 (13:11 +0200)
src/be/nikiroo/fanfix/library/BasicLibrary.java
src/be/nikiroo/fanfix/library/WebLibrary.java
src/be/nikiroo/fanfix/library/WebLibraryServer.java
src/be/nikiroo/fanfix/library/WebLibraryServerHtml.java

index f6024eef85025eefc0f0df1ada0b02fd2c2b254a..8b72f19b3a92ad1c1d7ada09d915440596330ee2 100644 (file)
@@ -595,6 +595,28 @@ abstract public class BasicLibrary {
         *             in case of I/O error
         */
        public MetaData imprt(URL url, Progress pg) throws IOException {
+               return imprt(url, null, pg);
+       }
+
+       /**
+        * Import the {@link Story} at the given {@link URL} into the
+        * {@link BasicLibrary}.
+        * 
+        * @param url
+        *            the {@link URL} to import
+        * @param luid
+        *            the LUID to use
+        * @param pg
+        *            the optional progress reporter
+        * 
+        * @return the imported Story {@link MetaData}
+        * 
+        * @throws UnknownHostException
+        *             if the host is not supported
+        * @throws IOException
+        *             in case of I/O error
+        */
+       MetaData imprt(URL url, String luid, Progress pg) throws IOException {
                if (pg == null)
                        pg = new Progress();
 
@@ -609,7 +631,7 @@ abstract public class BasicLibrary {
                        throw new UnknownHostException("" + url);
                }
 
-               Story story = save(support.process(pgProcess), pgSave);
+               Story story = save(support.process(pgProcess), luid, pgSave);
                pg.done();
 
                return story.getMeta();
index ac1349e7ac51b3015050a4725a28265ef13a211a..978dd9af51c05e5b56f93c2d61948e34fcbcc968 100644 (file)
@@ -353,6 +353,11 @@ public class WebLibrary extends BasicLibrary {
                }
        }
 
+       @Override
+       public synchronized void delete(String luid) throws IOException {
+               post(WebLibraryUrls.getDeleteUrlStory(luid), null).close();
+       }
+
        @Override
        protected void updateInfo(MetaData meta) {
                // Will be taken care of directly server side
index 810cc4dbfbf6bafe532c9f2ae72fd73889a27e5e..9073b8cad58895f02ccbd88d2a8d2a9deebf6397 100644 (file)
@@ -422,7 +422,7 @@ public class WebLibraryServer extends WebLibraryServerHtml {
                        @Override
                        public void run() {
                                try {
-                                       lib.imprt(url, pg);
+                                       lib.imprt(url, luid, pg);
                                } catch (IOException e) {
                                        Instance.getInstance().getTraceHandler().error(e);
                                } finally {
index e96edef95584b5f18a63f62ab630c75abe92f6b0..ac0631dd60ba32abc8f34b7297510bbc78039c95 100644 (file)
@@ -256,9 +256,7 @@ abstract class WebLibraryServerHtml implements Runnable {
                        }
                };
 
-               if (ssf != null)
-
-               {
+               if (ssf != null) {
                        getTraceHandler().trace("Install SSL on the web server...");
                        server.makeSecure(ssf, null);
                        getTraceHandler().trace("Done.");