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
 void 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  boolean addGroup(java.lang.String groupID)
          Add's a new group with specified version.
 boolean addGroup(java.lang.String groupID, java.lang.String version)
          Creates a new group with specified version
 boolean addNewPackage(java.lang.String pathToFiles, java.lang.String version)
          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
 boolean init()
          Initialize the data's from disk.
 boolean init(java.lang.String pathToFile)
          Inittialize the data's from disk.
 void printData()
          Print method for test purposes mainly.
 boolean removeGroup(java.lang.String groupID)
          Removes the specified group.
 boolean removePackage(java.lang.String version)
          Removes software package/version from server.
 boolean save()
          Saves the data to disk Uses the default name for file
 boolean save(java.lang.String pathToFile)
          Save's the data to disk
 void setClientToGroup(java.lang.String clientIP, java.lang.String groupID)
          Set's the client to group
 void setClientVersion(java.lang.String clientIP, java.lang.String version)
          Set specified version to client.
 void setGroupInfo(java.lang.String groupID, java.lang.String version)
          Set specified version for group
 void 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 boolean 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:
false if init could not convert anything from disk.

init


public boolean 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:
false if init could not convert anything from disk.

save


public boolean 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:
indicates success of failure

save


public boolean 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:
indicates success of failure

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 void setGroupInfo(java.lang.String groupID,
                         java.lang.String version)
Description copied from interface: DataForMain
Set specified version for group
Specified by:
setGroupInfo in interface DataForMain
Tags copied from interface: DataForMain
Parameters:
groupID - Group's identification, who's version is about to be set
version - The version we want to give to this group

addGroup


public boolean 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 boolean 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 boolean 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

setNSSettings


public void 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

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 boolean addNewPackage(java.lang.String pathToFiles,
                             java.lang.String version)
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.
versionId - Version identification string for this software package
Returns:
false if no success. Cause version exists

removePackage


public boolean 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

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 void 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

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 void 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

setClientVersion


public void setClientVersion(java.lang.String clientIP,
                             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
version - the version we wish to set.

printData


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