com.partnersoft.update.app
Class UpdateFileLogic

java.lang.Object
  extended by com.partnersoft.update.app.UpdateFileLogic

public class UpdateFileLogic
extends java.lang.Object

Update logic pertaining to file management, downloading, and other I/O.

Much of these method are copied from various classes in com.partnersoft.io; they are duplicated here so that the Update subsystem doesn't depend on Java 1.6 or the rest of the Partner platform.

Copyright 2010 Partner Software, Inc.

Version:
$Id$
Author:
Paul Reavis

Field Summary
 int BUFFER_SIZE
          Buffer size used.
 
Constructor Summary
UpdateFileLogic(UpdateApp app)
           
 
Method Summary
 void copy(java.io.InputStream source, java.io.OutputStream sink, long howMany)
          Copies (or downloads) from the source to the sink, using a large buffer.
 long downloadAndChecksum(java.io.InputStream source, java.io.OutputStream sink, long howMany)
          Copies (or downloads) from the source to the sink, using a large buffer, while simultaneously generating a checksum that can be used to verify that the copied data matches what was expected.
 void downloadPackageFile(UpdatePackageFile packageFile)
          Copy the given package from the source to the sink, verifying both size and checksum.
 void downloadUpdatedPackages()
          Download the updated packages from the source to the downloads directory of the destination.
 void installUpdatedPackages()
          Install the updated packages, removing existing files first.
 void lock(java.lang.String explanation)
           
 void moveDownloads()
          Move the downloaded package files to the update/packages directory.
 void removeDownloads()
          Remove the update/downloads directory in the destination and all contents.
 void unlock()
           
 void unpack(UpdatePackageFile packageFile)
           
 void updateInfoFiles()
          Write the update chain and other text files associated with the install.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER_SIZE

public final int BUFFER_SIZE
Buffer size used. We only have one buffer so might as well make it big.

See Also:
Constant Field Values
Constructor Detail

UpdateFileLogic

public UpdateFileLogic(UpdateApp app)
Method Detail

downloadPackageFile

public void downloadPackageFile(UpdatePackageFile packageFile)
                         throws java.io.IOException
Copy the given package from the source to the sink, verifying both size and checksum.

Throws:
java.io.IOException

downloadAndChecksum

public long downloadAndChecksum(java.io.InputStream source,
                                java.io.OutputStream sink,
                                long howMany)
                         throws java.io.IOException
Copies (or downloads) from the source to the sink, using a large buffer, while simultaneously generating a checksum that can be used to verify that the copied data matches what was expected.

Throws:
java.io.IOException

copy

public void copy(java.io.InputStream source,
                 java.io.OutputStream sink,
                 long howMany)
          throws java.io.IOException
Copies (or downloads) from the source to the sink, using a large buffer.

Throws:
java.io.IOException

lock

public void lock(java.lang.String explanation)
          throws java.io.IOException
Throws:
java.io.IOException

unlock

public void unlock()
            throws java.io.IOException
Throws:
java.io.IOException

unpack

public void unpack(UpdatePackageFile packageFile)
            throws java.io.IOException
Throws:
java.io.IOException

downloadUpdatedPackages

public void downloadUpdatedPackages()
                             throws java.io.IOException
Download the updated packages from the source to the downloads directory of the destination.

Throws:
java.io.IOException

installUpdatedPackages

public void installUpdatedPackages()
                            throws java.io.IOException
Install the updated packages, removing existing files first.

Throws:
java.io.IOException

removeDownloads

public void removeDownloads()
                     throws java.io.IOException
Remove the update/downloads directory in the destination and all contents.

Throws:
java.io.IOException

moveDownloads

public void moveDownloads()
                   throws java.io.IOException
Move the downloaded package files to the update/packages directory. Generally only done for source-type installs.

Throws:
java.io.IOException

updateInfoFiles

public void updateInfoFiles()
                     throws java.io.IOException
Write the update chain and other text files associated with the install.

Throws:
java.io.IOException