synapsi.data
Interface DataForMain

All Known Implementing Classes:
DataMain

public interface DataForMain

Interface to access methods and data in synapsi.data package


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
 int addGroup(java.lang.String groupID, java.lang.String version)
          Add 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 IP)
          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.
 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.
 

Method Detail

init


public int init()
Initialize the data's from disk. Uses the default name for serilized file
Returns:
0 if OK else some error code

init


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

save


public int save()
Saves the data to disk Uses the default name for file
Returns:
0 if OK else some error code

save


public int save(java.lang.String pathToFile)
Save's the data to disk
Parameters:
pathToFiles - location where we wish to save.
Returns:
0 if OK else some error code

getGroups


public java.util.Vector getGroups()
Gets all groups.
Returns:
A Vector containing DataGroup objects

getGroupClients


public java.util.Vector getGroupClients(java.lang.String groupID)
Get clients for specified group
Parameters:
groupID - - String containing the groups ID
Returns:
A Vector containing DataClient objects

getPackages


public java.util.Vector getPackages()
Get all software packages/versions
Returns:
A Vector containing DataVersion objects

getClientVersion


public DataVersion getClientVersion(java.lang.String clientIP)
TO BE REMOVED - This is not needed since you can get clients version from DataClient

getGroupVersion


public DataVersion getGroupVersion(java.lang.String groupID)
Gets version of specified group
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)
Sets new group ID and/or software version to a group.
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)
Add a new group with specified version.
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.

removeGroup


public int removeGroup(java.lang.String groupID)
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.
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)
Set servers settings. Currently the only setting is the number of concurrent client updates.
Parameters:
concurrentClients - number of client that can update concurrently
Returns:
0 if OK else some error code

getNSSettings


public int getNSSettings()
Gets the number of concurrent clients to do update
Returns:
the number of concurrent updates

clientExist


public boolean clientExist(java.lang.String IP)
Is there a client with given IP
Parameters:
IP - The IP to be checked
Returns:
value indicating if the client exist in current system

getClient


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

activateClient


public 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
Parameters:
b - activate/disactivate
IP - the client ip-address that is to be activated/disactivated
Returns:
0 if OK else some error code

getDefaultGroup


public 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
Returns:
DataGroup the default group object

addNewPackage


public 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. Params need some refinement
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)
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.
Parameters:
version - The version to be removed
Returns:
false if no success. Cause version exists

createNewClient


public DataGroup createNewClient(java.lang.String clientIP)
Creates new client and add's it to default group
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)
Set's the client to group
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)
Set specified version to client. This is to be used from network only.So please no call from elsewhere
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