[jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/install/sword s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Tue Sep 28 15:25:12 MST 2004


Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword
In directory www.crosswire.org:/tmp/cvs-serv14678/java/jsword/org/crosswire/jsword/book/install/sword

Modified Files:
	HttpSwordInstaller.java FtpSwordInstaller.java 
Log Message:
User confirmation of download

Index: HttpSwordInstaller.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword/HttpSwordInstaller.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** HttpSwordInstaller.java	21 Sep 2004 17:46:23 -0000	1.6
--- HttpSwordInstaller.java	28 Sep 2004 22:25:10 -0000	1.7
***************
*** 9,12 ****
--- 9,13 ----
  import java.io.OutputStream;
  import java.io.Reader;
+ import java.net.MalformedURLException;
  import java.net.URL;
  import java.net.URLConnection;
***************
*** 189,193 ****
              out = new FileOutputStream(f);
              URLConnection urlConnection = zipurl.openConnection();
-             log.debug("The file size is " + urlConnection.getContentLength()); //$NON-NLS-1$
              in = urlConnection.getInputStream();
              byte[] buf = new byte[4096];
--- 190,193 ----
***************
*** 197,201 ****
              }
              // unpack the zip.
-             log.debug("The file is downlaoded!"); //$NON-NLS-1$
              ZipFile zf = new ZipFile(f);
              Enumeration entries = zf.entries();
--- 197,200 ----
***************
*** 204,208 ****
                  ZipEntry entry = (ZipEntry) entries.nextElement();
                  String entrypath = entry.getName();
-                 log.debug("entry is called " + entrypath); //$NON-NLS-1$
                  String filename = entrypath.substring(entrypath.lastIndexOf('/') + 1);
                  URL child = NetUtil.lengthenURL(destdir, filename);
--- 203,206 ----
***************
*** 261,265 ****
          if (Books.installed().getBookMetaData(bmd.getName()) != null)
          {
-             Reporter.informUser(this, Msg.INSTALLED, bmd.getName());
              return;
          }
--- 259,262 ----
***************
*** 267,272 ****
          final SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
  
-         Reporter.informUser(this, Msg.INSTALLING, sbmd.getName());
- 
          // So now we know what we want to install - all we need to do
          // is installer.install(name) however we are doing it in the
--- 264,267 ----
***************
*** 302,308 ****
  
                      SwordBookDriver.registerNewBook(sbmd, dldir);
- 
-                     // inform the user that we are done
-                     Reporter.informUser(this, Msg.INSTALL_DONE, sbmd.getName());
                  }
                  catch (Exception ex)
--- 297,300 ----
***************
*** 323,326 ****
--- 315,338 ----
      }
  
+     public URL toURL(BookMetaData bmd)
+     {
+         if (!(bmd instanceof SwordBookMetaData))
+         {
+             assert false;
+             return null;
+         }
+ 
+         SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
+ 
+ 	    try
+         {
+             return new URL("http://" + host + directory + '/' + PACKAGE_DIR + '/' + sbmd.getInitials() + ZIP_SUFFIX); //$NON-NLS-1$
+         }
+         catch (MalformedURLException e)
+         {
+             return null;
+         }
+ 	}
+ 
      /* (non-Javadoc)
       * @see java.lang.Comparable#compareTo(java.lang.Object)

Index: FtpSwordInstaller.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword/FtpSwordInstaller.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** FtpSwordInstaller.java	21 Sep 2004 17:46:23 -0000	1.3
--- FtpSwordInstaller.java	28 Sep 2004 22:25:10 -0000	1.4
***************
*** 8,11 ****
--- 8,12 ----
  import java.io.OutputStream;
  import java.io.Reader;
+ import java.net.MalformedURLException;
  import java.net.URL;
  import java.util.ArrayList;
***************
*** 88,91 ****
--- 89,112 ----
      }
  
+     public URL toURL(BookMetaData bmd)
+     {
+         if (!(bmd instanceof SwordBookMetaData))
+         {
+             assert false;
+             return null;
+         }
+ 
+         SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
+ 
+ 	    try
+         {
+             return new URL("ftp://ftp.crosswire.org/pub/sword/packages/rawzip/" + sbmd.getInitials() + ZIP_SUFFIX); //$NON-NLS-1$
+         }
+         catch (MalformedURLException e)
+         {
+             return null;
+         }
+ 	}
+ 
      /* (non-Javadoc)
       * @see org.crosswire.jsword.book.install.Installer#install(java.lang.String)
***************
*** 102,106 ****
          if (Books.installed().getBookMetaData(bmd.getName()) != null)
          {
-             Reporter.informUser(this, Msg.INSTALLED, bmd.getName());
              return;
          }
--- 123,126 ----
***************
*** 108,113 ****
          final SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
  
-         Reporter.informUser(this, Msg.INSTALLING, sbmd.getName());
- 
          // So now we know what we want to install - all we need to do
          // is installer.install(name) however we are doing it in the
--- 128,131 ----
***************
*** 146,152 ****
  
                      SwordBookDriver.registerNewBook(sbmd, dldir);
- 
-                     // inform the user that we are done
-                     Reporter.informUser(this, Msg.INSTALL_DONE, sbmd.getName());
                  }
                  catch (Exception ex)
--- 164,167 ----
***************
*** 663,665 ****
--- 678,685 ----
       */
      private static final Logger log = Logger.getLogger(FtpSwordInstaller.class);
+ 
+     /**
+      * The suffix of zip modules on this server
+      */
+     private static final String ZIP_SUFFIX = ".zip"; //$NON-NLS-1$
  }



More information about the jsword-svn mailing list