org.eodisp.core.repos.service
Class ReposModelServiceImpl

java.lang.Object
  extended by org.eodisp.core.repos.service.ReposModelServiceImpl
All Implemented Interfaces:
java.rmi.Remote, ReposModelService

public class ReposModelServiceImpl
extends java.lang.Object
implements ReposModelService

This implementation will be exported by the eodisp_remote package and therefore accessible through the network. Since the remote mechanism takes care of the objects, it is not implemented as singleton.

Version:
$Id:$
Author:
eglimi

Field Summary
(package private) static org.apache.log4j.Logger logger
          Log4J logger for this class
 
Fields inherited from interface org.eodisp.core.common.ReposModelService
REGISTRY_NAME
 
Constructor Summary
ReposModelServiceImpl()
          Constructor.
 
Method Summary
 java.lang.String addSom(SomFile somFile)
          Adds a physical SOM file to the repository.
 void deleteSom(java.lang.String somName, java.lang.String somVersion)
          Deletes the physical SOM file that is locally stored on in the repository.
 org.eclipse.emf.ecore.sdo.EDataGraph getAllData()
          Returns all data currently stored in the model repository.
 SomFile getSom(java.lang.String somName, java.lang.String somVersion)
          Reads a SOM file locally in the repository and returns it.
 void update(org.eclipse.emf.ecore.sdo.EDataGraph dataGraph)
          Updates a data graph in the resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static org.apache.log4j.Logger logger
Log4J logger for this class

Constructor Detail

ReposModelServiceImpl

public ReposModelServiceImpl()
Constructor.

Method Detail

getAllData

public org.eclipse.emf.ecore.sdo.EDataGraph getAllData()
                                                throws java.io.IOException
Description copied from interface: ReposModelService
Returns all data currently stored in the model repository.

Specified by:
getAllData in interface ReposModelService
Returns:
An EDataGraph containing the data.
Throws:
java.rmi.RemoteException - see documentation of RemoteException
java.io.IOException - Thrown if there is a problem loading the data.

update

public void update(org.eclipse.emf.ecore.sdo.EDataGraph dataGraph)
            throws java.io.IOException
Updates a data graph in the resource. The resource is the XML file that holds the repository instance data.

Updates are performed (saved) immediately, without any chance to undo changes.

Specified by:
update in interface ReposModelService
Parameters:
dataGraph - The data graph with the changes to be committed.
Throws:
java.rmi.RemoteException - see documentation of RemoteException
java.io.IOException - thrown if there is a problem while saving the data to the disk.

addSom

public java.lang.String addSom(SomFile somFile)
                        throws java.io.IOException,
                               java.lang.IllegalStateException
Adds a physical SOM file to the repository. The SOM file will be locally stored in a location specified in the configuration.

Specified by:
addSom in interface ReposModelService
Parameters:
somFile - The object containing the physical file.
Returns:
The path at which the file has been stored.
Throws:
java.rmi.RemoteException - see documentation of RemoteException
java.io.IOException - thrown if the file could not be save in the repository.
java.lang.IllegalStateException

getSom

public SomFile getSom(java.lang.String somName,
                      java.lang.String somVersion)
               throws SomNotKnownException,
                      java.io.IOException
Reads a SOM file locally in the repository and returns it. This is a file that has been stored with ReposModelService.addSom(SomFile) method.

The name and version of the SOM will be used to lookup the location of the file on the file system.

Specified by:
getSom in interface ReposModelService
Parameters:
somName - The name of the SOM.
somVersion - The version of the SOM.
Returns:
An instance of SomFile, including the byte array representing the data. It always returns a non null object. In case of an error, an exception will be thrown, but never will be a null object returned.
Throws:
SomNotKnownException - thrown if no SOM file could be found that corresponds to the given somName and somVersion.
java.rmi.RemoteException - see documentation of RemoteException
java.io.IOException - thrown in case of an error when reading the file or if the file is too large.

deleteSom

public void deleteSom(java.lang.String somName,
                      java.lang.String somVersion)
               throws SomNotKnownException
Deletes the physical SOM file that is locally stored on in the repository. The SOM file is identified by the name and version of the SOM. The repository model will be queried to find the location of the file.

An exception will be thrown if the file cannot be deleted, otherwise, the deletion process has succeeded.

Specified by:
deleteSom in interface ReposModelService
Parameters:
somName - The name of SOM.
somVersion - The version of the SOM.
Throws:
SomNotKnownException - thrown if no SOM file could be found that corresponds to the given somName and somVersion.