no.ubicollab.osgi
Class DBConnection

java.lang.Object
  extended by no.ubicollab.osgi.DBConnection

public class DBConnection
extends java.lang.Object

The Class DBConnection offers methods to open/close database connections, and also the read/write methods that is required by Service Registry.

Since:
0.1
Version:
0.3
Author:
Kim-Steve Johansen

Field Summary
static java.lang.String newline
          Gets the corrects newline character for the system the bundle runs on.
 
Constructor Summary
DBConnection()
          This Constructor will create a new DBConnection instance.
 
Method Summary
 boolean addService(java.lang.String serviceURI, java.lang.String descriptionURI, java.lang.String name, java.lang.String type, java.lang.String location, java.lang.String owner, java.lang.String description)
          Adds a new service record to the database.
 boolean deleteService(int serviceID)
          Deletes a service refrence record from the database.
 void disconnectFromDatabase()
          Disconnects from database.
 java.lang.String getServiceDetails(int serviceId)
          Gets all registered information about the service specified by the provided service ID.
 java.lang.String getServiceDetails(java.lang.String serviceUri)
          Gets all registered information about the service specified by the provided service URI.
 java.lang.String getServiceList(java.lang.String name, java.lang.String type, java.lang.String location, java.lang.String owner, java.lang.String description)
          Get a list of services matching the specified query parameters.
 boolean updateService(int serviceID, java.lang.String serviceURI, java.lang.String descriptionURI, java.lang.String name, java.lang.String type, java.lang.String location, java.lang.String owner, java.lang.String description)
          Updates a service record to the database, based on the serviceID.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

newline

public static java.lang.String newline
Gets the corrects newline character for the system the bundle runs on.

Constructor Detail

DBConnection

public DBConnection()
This Constructor will create a new DBConnection instance. The actual db connection is opened at the moment the class is instanciated.

Method Detail

disconnectFromDatabase

public void disconnectFromDatabase()
Disconnects from database. This method is ment to be called when the bundle is stopped.


addService

public boolean addService(java.lang.String serviceURI,
                          java.lang.String descriptionURI,
                          java.lang.String name,
                          java.lang.String type,
                          java.lang.String location,
                          java.lang.String owner,
                          java.lang.String description)
Adds a new service record to the database.

Parameters:
type - Classification of service (in service type hierarchy)
descriptionURI - The description URI for the service
owner - The owner or responible for the service
description - the textual service description
location - The location of the service
name - A selected name the user should be able to understand
serviceURI - The Url to the service bundle.
Returns:
true if the service refrence is successfully added, false otherwise.

updateService

public boolean updateService(int serviceID,
                             java.lang.String serviceURI,
                             java.lang.String descriptionURI,
                             java.lang.String name,
                             java.lang.String type,
                             java.lang.String location,
                             java.lang.String owner,
                             java.lang.String description)
Updates a service record to the database, based on the serviceID.

Parameters:
serviceID - the service ID of the service to update
descriptionURI - The description URI for the service
type - Classification of service (in service type hierarchy)
owner - The owner or responible for the service
description - the textual service description
location - The location of the service
name - A selected name the user should be able to understand
serviceURI - The Url to the service bundle.
Returns:
true if the service refrence is successfully updated, false otherwise.

deleteService

public boolean deleteService(int serviceID)
Deletes a service refrence record from the database.

Parameters:
serviceID - the service ID for the service to remove
Returns:
true if the service refrence is successfully updated, false otherwise.

getServiceList

public java.lang.String getServiceList(java.lang.String name,
                                       java.lang.String type,
                                       java.lang.String location,
                                       java.lang.String owner,
                                       java.lang.String description)
Get a list of services matching the specified query parameters.

Parameters:
type - The type of service
owner - The owner of the srvice
description - the description of the service
location - The location of the service
name - The name of the service
Returns:
An XML-string string containg the query results if any matches are found, "NO SERVICES MATCHES THE QUERY" otherwise.

getServiceDetails

public java.lang.String getServiceDetails(java.lang.String serviceUri)
Gets all registered information about the service specified by the provided service URI.

Parameters:
serviceUri - The Uri to the service. This location is required to be unique in registry and this ensures that only one service is returned.
Returns:
A String with a all info about the requested service in XML-format. The format used is the minimum for a well-formed XML-document, containing only one element formed like this:
<Service ID='' ServiceUri='' DescriptionUri='' Name='' Type='' Location='' Owner='' />

getServiceDetails

public java.lang.String getServiceDetails(int serviceId)
Gets all registered information about the service specified by the provided service ID.

Parameters:
serviceId - The unique id refrencing the service.
Returns:
A String with a all info about the requested service in XML-format. The format used is the minimum for a well-formed XML-document, containing only one element formed like this:
<Service ID='' ServiceUri='' DescriptionUri='' Name='' Type='' Location='' Owner='' />