com.universaldevices.autoupdate
Class UDUpdater

java.lang.Object
  extended by com.universaldevices.autoupdate.UDUpdater

public class UDUpdater
extends java.lang.Object

This class provides utilities to update files and programs in ISY. In case a firmware update is issued (based on a zip file) the IUpdaterClient is in charge of rebooting ISY. If an IUpdaterClient is not provided, the methods will automatically reboot the ISY.

Author:
UD Architect

Constructor Summary
UDUpdater()
           
 
Method Summary
static boolean doUpdate(java.net.Socket s, java.io.InputStream is, java.io.OutputStream os, byte[] image, IUpdaterClient view)
          This method is in charge of actually writing the file content to ISY.
static java.util.zip.ZipFile getUpdateImage(java.lang.Object p, java.lang.String uid, java.lang.String pwd)
          Returns the update image in ZipFile format for the given platform (param 1)
static boolean update(IUpdateHandler dev, java.util.zip.ZipFile zip, boolean is_sysload, IUpdaterClient view)
          Updates ISY's files/directories based on the given ZIP file
static boolean updateProgram(java.io.InputStream is, int size, java.lang.String name, IUpdateHandler dev, IUpdaterClient view)
          This method prepares the ISY to receive a file and write it to the given path
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UDUpdater

public UDUpdater()
Method Detail

getUpdateImage

public static java.util.zip.ZipFile getUpdateImage(java.lang.Object p,
                                                   java.lang.String uid,
                                                   java.lang.String pwd)
                                            throws java.lang.Exception
Returns the update image in ZipFile format for the given platform (param 1)

Parameters:
p - - an object of type UDAutoUpdate.UDPlatform
uid - - the AutoUpdate userid to access the update code
pwd - - the AutoUpdate password to access the update code
Returns:
- if successful, the update package in ZipFile; null otherwise
Throws:
java.lang.Exception

update

public static boolean update(IUpdateHandler dev,
                             java.util.zip.ZipFile zip,
                             boolean is_sysload,
                             IUpdaterClient view)
Updates ISY's files/directories based on the given ZIP file

Parameters:
dev - - the IUpdateHandler is any object which has the capability of impacting ISY's files and directories. Note: UDProxyDevice implements IUpdateHandler and, as such, it should be used as the parameter to this method
zip - - the zip file which is going to be updating ISY
is_sysload - - whether or not this is a system restore
view - - the optional IUpdaterClient which is notified of the progress and errors
Returns:
- true if successful, false otherwise

updateProgram

public static boolean updateProgram(java.io.InputStream is,
                                    int size,
                                    java.lang.String name,
                                    IUpdateHandler dev,
                                    IUpdaterClient view)
This method prepares the ISY to receive a file and write it to the given path

Parameters:
is - - the input stream connected to ISY
size - - the size of the file being updated
name - - the path (ISY path) which the file should be written to
dev - - the IUpdateHandler is any object which has the capability of impacting ISY's files and directories. Note: UDProxyDevice implements IUpdateHandler and, as such, it should be used as the parameter to this method
view - - the optional IUpdaterClient which is notified of the progress and errors
Returns:
- true if successful, false otherwise

doUpdate

public static boolean doUpdate(java.net.Socket s,
                               java.io.InputStream is,
                               java.io.OutputStream os,
                               byte[] image,
                               IUpdaterClient view)
This method is in charge of actually writing the file content to ISY. Note this method has to be invoked only after preparing ISY to receive the file using updateProgram(java.io.InputStream, int, java.lang.String, com.universaldevices.autoupdate.IUpdateHandler, com.universaldevices.autoupdate.IUpdaterClient) method

Parameters:
s - - the socket which is already connected to ISY
is - - the input stream
os - - the output stream which writes the contents of the @param image to ISY
image - - the actual file content
view - - the optional IUpdaterClient which is notified of the progress and errors
Returns:
- true if successful, false otherwise