synapsi.data
Class DataMain


java.lang.Object

  |

  +--synapsi.data.DataMain


public class DataMain
extends java.lang.Object
implements DataForMain

Main class for synapsi.data package. Methods inherited from synapsi.data.DataForMain are not documented here. Look synapsi.data.DataForMain instead


Field Summary
static java.lang.String DEFAULT_NAME
          Default name for the file to be used in saving data
protected static java.lang.String DefGroupName
           
protected static java.lang.String DefVersionName
           
protected static java.lang.String Name
           
 
Constructor Summary
DataMain()
           
 
Method Summary
 int activateClient(boolean b, java.lang.String IP)
          Method for activating/dis-activating client This method is used to set client's online status to true or false
protected  int addGroup(java.lang.String groupID)
          Add's a new group with specified version.
 int addGroup(java.lang.String groupID, java.lang.String version)
          Creates a new group with specified version
 int addNewPackage(java.lang.String pathToFiles, java.lang.String id, java.lang.String version, java.lang.String os, byte[] MD5)
          Adds new software package to server.
 boolean clientExist(java.lang.String clientIP)
          Is there a client with given IP
 DataGroup createNewClient(java.lang.String clientIP)
          Creates new client and add's it to default group
 DataClient getClient(java.lang.String IP)
          Get's the client with specified IP-address
 DataVersion getClientVersion(java.lang.String clientIP)
          TO BE REMOVED - This is not needed since you can get clients version from DataClient
 DataGroup getDefaultGroup()
          Get's reference for the default DataGroup object in this system Default group is the DataGroup object that get's new client's when they come online for a first-time
 java.util.Vector getGroupClients(java.lang.String groupID)
          Get clients for specified group
 java.util.Vector getGroups()
          Gets all groups.
 DataVersion getGroupVersion(java.lang.String groupID)
          Gets version of specified group
 int getNSSettings()
          Gets the number of concurrent clients to do update
 java.util.Vector getPackages()
          Get all software packages/versions
 int init()
          Initialize the data's from disk.
 int init(java.lang.String pathToFile)
          Inittialize the data's from disk.
 void printData()
          Print method for test purposes mainly.
 int removeGroup(java.lang.String groupID)
          Removes the specified group.
 int removePackage(java.lang.String version)
          Removes software package/version from server.
 int save()
          Saves the data to disk Uses the default name for file
 int save(java.lang.String pathToFile)
          Save's the data to disk
 int setClientToGroup(java.lang.String clientIP, java.lang.String groupID)
          Set's the client to group
 int setClientVersion(java.lang.String clientIP, byte[] bMD5, java.lang.String version)
          Set specified version to client.
 int setGroupInfo(java.lang.String oldID, java.lang.String newID, java.lang.String version)
          Sets new group ID and/or software version to a group.
 int setNSSettings(int concurrentClients)
          Set servers settings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NAME


public static final java.lang.String DEFAULT_NAME
Default name for the file to be used in saving data

Name


protected static final java.lang.String Name

DefGroupName


protected static final java.lang.String DefGroupName

DefVersionName


protected static final java.lang.String DefVersionName
Constructor Detail

DataMain


public DataMain()
Method Detail

init


public int init()
Description copied from interface: DataForMain
Initialize the data's from disk. Uses the default name for serilized file
Specified by:
init in interface DataForMain
Tags copied from interface: DataForMain
Returns:
0 if OK else some error code

init


public int init(java.lang.String pathToFile)
Description copied from interface: DataForMain
Inittialize the data's from disk.
Specified by:
init in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
pathToFile - path to file where the saved data is.
Returns:
0 if OK else some error code

save


public int save()
Description copied from interface: DataForMain
Saves the data to disk Uses the default name for file
Specified by:
save in interface DataForMain
Tags copied from interface: DataForMain
Returns:
0 if OK else some error code

save


public int save(java.lang.String pathToFile)
Description copied from interface: DataForMain
Save's the data to disk
Specified by:
save in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
pathToFiles - location where we wish to save.
Returns:
0 if OK else some error code

getGroups


public java.util.Vector getGroups()
Description copied from interface: DataForMain
Gets all groups.
Specified by:
getGroups in interface DataForMain
Tags copied from interface: DataForMain
Returns:
A Vector containing DataGroup objects

getDefaultGroup


public DataGroup getDefaultGroup()
Description copied from interface: DataForMain
Get's reference for the default DataGroup object in this system Default group is the DataGroup object that get's new client's when they come online for a first-time
Specified by:
getDefaultGroup in interface DataForMain
Tags copied from interface: DataForMain
Returns:
DataGroup the default group object

getGroupClients


public java.util.Vector getGroupClients(java.lang.String groupID)
Description copied from interface: DataForMain
Get clients for specified group
Specified by:
getGroupClients in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
groupID - - String containing the groups ID
Returns:
A Vector containing DataClient objects

getPackages


public java.util.Vector getPackages()
Description copied from interface: DataForMain
Get all software packages/versions
Specified by:
getPackages in interface DataForMain
Tags copied from interface: DataForMain
Returns:
A Vector containing DataVersion objects

getClientVersion


public DataVersion getClientVersion(java.lang.String clientIP)
Description copied from interface: DataForMain
TO BE REMOVED - This is not needed since you can get clients version from DataClient
Specified by:
getClientVersion in interface DataForMain

getGroupVersion


public DataVersion getGroupVersion(java.lang.String groupID)
Description copied from interface: DataForMain
Gets version of specified group
Specified by:
getGroupVersion in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
groupID - String group identifier
Returns:
Dataversion object for spefied group

setGroupInfo


public int setGroupInfo(java.lang.String oldID,
                        java.lang.String newID,
                        java.lang.String version)
Description copied from interface: DataForMain
Sets new group ID and/or software version to a group.
Specified by:
setGroupInfo in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
oldID - Old group ID of the group.
newID - New group ID for the group (if only software version changed, the same as oldID).
version - New software version to the group.
Returns:
0 if OK else some error code

addGroup


public int addGroup(java.lang.String groupID,
                    java.lang.String version)
Creates a new group with specified version
Specified by:
addGroup in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
groupID - Identification we want give for the group
version - The version we want to give for this group
Returns:
returns false if unsuccessfull. Cause no such version group exists.

addGroup


protected int addGroup(java.lang.String groupID)
Add's a new group with specified version. You cannot access this method directly. Use addGroup(String groupID, String version) with version = null instead
Parameters:
groupID - Identification we want give for the group
Returns:
returns false if unsuccessfull. Cause group exists.

removeGroup


public int removeGroup(java.lang.String groupID)
Description copied from interface: DataForMain
Removes the specified group. Requires that group in question has no clients. DataVersion references to this group are removed as well. This way the group can be collected later by the GC. After this method there is no method to restore the group.
Specified by:
removeGroup in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
groupID - Identification for the group that is about to be removed
Returns:
0 if OK else some error code

setNSSettings


public int setNSSettings(int concurrentClients)
Description copied from interface: DataForMain
Set servers settings. Currently the only setting is the number of concurrent client updates.
Specified by:
setNSSettings in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
concurrentClients - number of client that can update concurrently
Returns:
0 if OK else some error code

getNSSettings


public int getNSSettings()
Description copied from interface: DataForMain
Gets the number of concurrent clients to do update
Specified by:
getNSSettings in interface DataForMain
Tags copied from interface: DataForMain
Returns:
the number of concurrent updates

addNewPackage


public int addNewPackage(java.lang.String pathToFiles,
                         java.lang.String id,
                         java.lang.String version,
                         java.lang.String os,
                         byte[] MD5)
Description copied from interface: DataForMain
Adds new software package to server. Params need some refinement
Specified by:
addNewPackage in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
pathToFiles - Path to file/files, where the update package is located.
Id - Unique version identification string for this software package
version - The version number
os - The OS this version is inteded
MD5 - Package check sum
Returns:
0 if OK else some error code

removePackage


public int removePackage(java.lang.String version)
Description copied from interface: DataForMain
Removes software package/version from server. Removing fails if current version/package is still set for some group or client. This is keeps the data structure intact.
Specified by:
removePackage in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
version - The version to be removed
Returns:
false if no success. Cause version exists

getClient


public DataClient getClient(java.lang.String IP)
Description copied from interface: DataForMain
Get's the client with specified IP-address
Specified by:
getClient in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
IP - the ip-address for client we need to get
Returns:
if such client exist returns the object otherwise null is retured

clientExist


public boolean clientExist(java.lang.String clientIP)
Description copied from interface: DataForMain
Is there a client with given IP
Specified by:
clientExist in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
IP - The IP to be checked
Returns:
value indicating if the client exist in current system

activateClient


public int activateClient(boolean b,
                          java.lang.String IP)
Description copied from interface: DataForMain
Method for activating/dis-activating client This method is used to set client's online status to true or false
Specified by:
activateClient in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
b - activate/disactivate
IP - the client ip-address that is to be activated/disactivated
Returns:
0 if OK else some error code

createNewClient


public DataGroup createNewClient(java.lang.String clientIP)
Description copied from interface: DataForMain
Creates new client and add's it to default group
Specified by:
createNewClient in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
clientIP - Clients IP-address
Returns:
The group to which client was added. Null if creating failed

setClientToGroup


public int setClientToGroup(java.lang.String clientIP,
                            java.lang.String groupID)
Description copied from interface: DataForMain
Set's the client to group
Specified by:
setClientToGroup in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
clientIP - Client we are moving
GroupID - The group we are planning to move the client
Returns:
false if no success. Cause version exists

setClientVersion


public int setClientVersion(java.lang.String clientIP,
                            byte[] bMD5,
                            java.lang.String version)
Description copied from interface: DataForMain
Set specified version to client. This is to be used from network only.So please no call from elsewhere
Specified by:
setClientVersion in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
clientIP - Client who's version is to be set
bMD5 - MD5 checksum of the version.
version - string if to show if no version matching MD5-sumexists
Returns:
false if no success. Cause version exists

printData


public void printData()
Print method for test purposes mainly. Dumps all data held currently by synapsi.data package.