no.ubicollab.osgi
Class ServiceRegistryImpl

java.lang.Object
  extended by no.ubicollab.osgi.ServiceRegistryImpl
All Implemented Interfaces:
ServiceRegistry

public class ServiceRegistryImpl
extends java.lang.Object
implements ServiceRegistry

An interface for UbiCollab Service Registry. Provides the neccessary functionality for the centraliced service registry. The registry will be accessible through web service calls.

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

Constructor Summary
ServiceRegistryImpl(DBConnection dbConn)
          This Constructor creates a new instance.
 
Method Summary
 boolean addService(java.lang.String serviceURI, java.lang.String descriptionURI, java.lang.String friendlyName, java.lang.String type, java.lang.String location, java.lang.String owner, java.lang.String description)
          Adds a service reference to the registry.
 boolean deleteService(int serviceId)
          Removes the service which matches the provided service ID.
 java.lang.String getLogItems(java.lang.String logLevel, int numItems)
          Read from the log and return selected log items in a XML-formatted string.
 java.lang.String getServiceDetails(int serviceId)
          Gets all registered information about the service specified by the provided serviceId.
 java.lang.String getServiceDetails(java.lang.String serviceUri)
          Gets all registered information about the service specified by the provided serviceUri.
 java.lang.String getServices()
          This method returns an XML-formatted list containing all the services in the registry.
 java.lang.String getServices(java.lang.String name, java.lang.String type, java.lang.String location, java.lang.String owner, java.lang.String description)
          Method to return a list of service refrences matching the criteria specified in the query.
 boolean updateService(int serviceID, java.lang.String serviceURI, java.lang.String descriptionURI, java.lang.String friendlyName, java.lang.String type, java.lang.String location, java.lang.String owner, java.lang.String description)
          Updates the properties of service reference in the service registry.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceRegistryImpl

public ServiceRegistryImpl(DBConnection dbConn)
This Constructor creates a new instance.

Parameters:
dbConn - the db connection to use for queries
Method Detail

addService

public boolean addService(java.lang.String serviceURI,
                          java.lang.String descriptionURI,
                          java.lang.String friendlyName,
                          java.lang.String type,
                          java.lang.String location,
                          java.lang.String owner,
                          java.lang.String description)
Adds a service reference to the registry. Use this method to add new services which can be found by other users.

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

getServiceDetails

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

The format used for the returned data is the minimum for a well-formed XML-document, containing only one element with this syntax:

 <Service ID="int" 
   ServiceUri="String" 
   DescriptionUri="String" 
   Name="String" 
   Type="String" 
   Location="String"
   Owner="String" 
   Description="String"/>
 

Specified by:
getServiceDetails in interface ServiceRegistry
Parameters:
serviceUri - The service URI that uniquly identifies the service.
Returns:
A String with an XML-document if successful, "NO SERVICES MATCHES THE QUERY" otherwise.

getServiceDetails

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

The format used for the returned data is the minimum for a well-formed XML-document, containing only one element with this syntax:

 <Service ID="int" 
   ServiceUri="String" 
   DescriptionUri="String" 
   Name="String" 
   Type="String" 
   Location="String"
   Owner="String" 
   Description="String"/>

Specified by:
getServiceDetails in interface ServiceRegistry
Parameters:
serviceId - The unique id refrencing the service.
Returns:
A String with an XML-document if successful, "NO SERVICES MATCHES THE QUERY" otherwise.

getServices

public java.lang.String getServices()
This method returns an XML-formatted list containing all the services in the registry.

The xml-structure used to represent the returned service list is:

   <?xml version='1.0'?>
      <Servicelist>
          <Service ID="int" 
            ServiceUri="String" 
            DescriptionUri="String" 
            Name="String" 
            Type="String" 
            Location="String"
            Owner="String" 
            Description="String"/>
... more services ...
</Servicelist>

Specified by:
getServices in interface ServiceRegistry
Returns:
A String containing an XML-formatted list with 0..n service elements.

getServices

public java.lang.String getServices(java.lang.String name,
                                    java.lang.String type,
                                    java.lang.String location,
                                    java.lang.String owner,
                                    java.lang.String description)
Method to return a list of service refrences matching the criteria specified in the query. The different search criteria can be freely combined and also partial hits will be returned. Criterias not used should contain an empty string.

The xml-structure used to represent the returned service list is:

   <?xml version='1.0'?>
      <Servicelist>
          <Service ID="int" 
            ServiceUri="String" 
            DescriptionUri="String" 
            Name="String" 
            Type="String" 
            Location="String"
            Owner="String" 
            Description="String"/>
... more services ...
</Servicelist>

Specified by:
getServices in interface ServiceRegistry
Parameters:
type - the type of service, or a partial type specification
owner - the owner of the service, or a part of the owners name
description - the textual description of the service
location - the location for the service, or a part of the location
name - the name of the service, or a part of it
Returns:
A String containing an XML-formatted list with 0..n service elements.

deleteService

public boolean deleteService(int serviceId)
Removes the service which matches the provided service ID.

Specified by:
deleteService in interface ServiceRegistry
Parameters:
serviceId - The service ID for the service to remove
Returns:
true if the service reference is successfully removed, false otherwise.

getLogItems

public java.lang.String getLogItems(java.lang.String logLevel,
                                    int numItems)
Read from the log and return selected log items in a XML-formatted string.

The xml-structure used to represent the returned log is:

   <?xml version='1.0'?>
      <Log>
          <Logitem Date="dd.mm.yyyy" 
            Time="hh:mm:ss" 
            Level="String" 
            Message="String"/>
... more log items ...
</Log>

Specified by:
getLogItems in interface ServiceRegistry
Parameters:
logLevel - The log level to include in the report. Valid arguments are: 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'FATAL' and 'ALL' for all types.
numItems - The number of log items to include in the report
Returns:
the String containg the resulting XML

updateService

public boolean updateService(int serviceID,
                             java.lang.String serviceURI,
                             java.lang.String descriptionURI,
                             java.lang.String friendlyName,
                             java.lang.String type,
                             java.lang.String location,
                             java.lang.String owner,
                             java.lang.String description)
Updates the properties of service reference in the service registry. The key used to select which service to update is serviceID.

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