package org.dbxml.core.corba.db;

/**
 *	Generated from IDL definition of interface "Database"
 *	@author JacORB IDL compiler 
 */

public class _DatabaseStub
	extends org.omg.CORBA.portable.ObjectImpl
	implements org.dbxml.core.corba.db.Database
{
	private String[] ids = {"IDL:org/dbxml/core/corba/db/Database:1.0","IDL:org/dbxml/core/corba/db/ServantManagement:1.0","IDL:omg.org/CORBA/Object:1.0"};
	public String[] _ids()
	{
		return ids;
	}

	public final static java.lang.Class _opsClass = org.dbxml.core.corba.db.DatabaseOperations.class;
	public org.dbxml.core.corba.db.DatabaseManager getDatabaseManager() throws org.dbxml.core.corba.db.APIException
	{
		while(true)
		{
		if(! this._is_local())
		{
			org.omg.CORBA.portable.InputStream _is = null;
			try
			{
				org.omg.CORBA.portable.OutputStream _os = _request( "getDatabaseManager", true);
				_is = _invoke(_os);
				org.dbxml.core.corba.db.DatabaseManager _result = org.dbxml.core.corba.db.DatabaseManagerHelper.read(_is);
				return _result;
			}
			catch( org.omg.CORBA.portable.RemarshalException _rx ){}
			catch( org.omg.CORBA.portable.ApplicationException _ax )
			{
				String _id = _ax.getId();
				if( _id.equals("IDL:org/dbxml/core/corba/db/APIException:1.0"))
				{
					throw org.dbxml.core.corba.db.APIExceptionHelper.read(_ax.getInputStream());
				}
				else 
					throw new RuntimeException("Unexpected exception " + _id );
			}
			finally
			{
				this._releaseReply(_is);
			}
		}
		else
		{
			org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke( "getDatabaseManager", _opsClass );
			if( _so == null )
				throw new org.omg.CORBA.UNKNOWN("local invocations not supported!");
			DatabaseOperations _localServant = (DatabaseOperations)_so.servant;
			org.dbxml.core.corba.db.DatabaseManager _result;			try
			{
			_result = _localServant.getDatabaseManager();
			}
			finally
			{
				_servant_postinvoke(_so);
			}
			return _result;
		}

		}

	}

	public void remove()
	{
		while(true)
		{
		if(! this._is_local())
		{
			org.omg.CORBA.portable.InputStream _is = null;
			try
			{
				org.omg.CORBA.portable.OutputStream _os = _request( "remove", true);
				_is = _invoke(_os);
				return;
			}
			catch( org.omg.CORBA.portable.RemarshalException _rx ){}
			catch( org.omg.CORBA.portable.ApplicationException _ax )
			{
				String _id = _ax.getId();
				throw new RuntimeException("Unexpected exception " + _id );
			}
			finally
			{
				this._releaseReply(_is);
			}
		}
		else
		{
			org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke( "remove", _opsClass );
			if( _so == null )
				throw new org.omg.CORBA.UNKNOWN("local invocations not supported!");
			DatabaseOperations _localServant = (DatabaseOperations)_so.servant;
			try
			{
			_localServant.remove();
			}
			finally
			{
				_servant_postinvoke(_so);
			}
			return;
		}

		}

	}

	public org.dbxml.core.corba.db.Collection getCollection(java.lang.String path) throws org.dbxml.core.corba.db.APIException
	{
		while(true)
		{
		if(! this._is_local())
		{
			org.omg.CORBA.portable.InputStream _is = null;
			try
			{
				org.omg.CORBA.portable.OutputStream _os = _request( "getCollection", true);
				org.dbxml.core.corba.db.NameHelper.write(_os,path);
				_is = _invoke(_os);
				org.dbxml.core.corba.db.Collection _result = org.dbxml.core.corba.db.CollectionHelper.read(_is);
				return _result;
			}
			catch( org.omg.CORBA.portable.RemarshalException _rx ){}
			catch( org.omg.CORBA.portable.ApplicationException _ax )
			{
				String _id = _ax.getId();
				if( _id.equals("IDL:org/dbxml/core/corba/db/APIException:1.0"))
				{
					throw org.dbxml.core.corba.db.APIExceptionHelper.read(_ax.getInputStream());
				}
				else 
					throw new RuntimeException("Unexpected exception " + _id );
			}
			finally
			{
				this._releaseReply(_is);
			}
		}
		else
		{
			org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke( "getCollection", _opsClass );
			if( _so == null )
				throw new org.omg.CORBA.UNKNOWN("local invocations not supported!");
			DatabaseOperations _localServant = (DatabaseOperations)_so.servant;
			org.dbxml.core.corba.db.Collection _result;			try
			{
			_result = _localServant.getCollection(path);
			}
			finally
			{
				_servant_postinvoke(_so);
			}
			return _result;
		}

		}

	}

	public java.lang.String[] listCollections() throws org.dbxml.core.corba.db.APIException
	{
		while(true)
		{
		if(! this._is_local())
		{
			org.omg.CORBA.portable.InputStream _is = null;
			try
			{
				org.omg.CORBA.portable.OutputStream _os = _request( "listCollections", true);
				_is = _invoke(_os);
				java.lang.String[] _result = org.dbxml.core.corba.db.NamesHelper.read(_is);
				return _result;
			}
			catch( org.omg.CORBA.portable.RemarshalException _rx ){}
			catch( org.omg.CORBA.portable.ApplicationException _ax )
			{
				String _id = _ax.getId();
				if( _id.equals("IDL:org/dbxml/core/corba/db/APIException:1.0"))
				{
					throw org.dbxml.core.corba.db.APIExceptionHelper.read(_ax.getInputStream());
				}
				else 
					throw new RuntimeException("Unexpected exception " + _id );
			}
			finally
			{
				this._releaseReply(_is);
			}
		}
		else
		{
			org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke( "listCollections", _opsClass );
			if( _so == null )
				throw new org.omg.CORBA.UNKNOWN("local invocations not supported!");
			DatabaseOperations _localServant = (DatabaseOperations)_so.servant;
			java.lang.String[] _result;			try
			{
			_result = _localServant.listCollections();
			}
			finally
			{
				_servant_postinvoke(_so);
			}
			return _result;
		}

		}

	}

	public java.lang.String getName() throws org.dbxml.core.corba.db.APIException
	{
		while(true)
		{
		if(! this._is_local())
		{
			org.omg.CORBA.portable.InputStream _is = null;
			try
			{
				org.omg.CORBA.portable.OutputStream _os = _request( "getName", true);
				_is = _invoke(_os);
				java.lang.String _result = _is.read_string();
				return _result;
			}
			catch( org.omg.CORBA.portable.RemarshalException _rx ){}
			catch( org.omg.CORBA.portable.ApplicationException _ax )
			{
				String _id = _ax.getId();
				if( _id.equals("IDL:org/dbxml/core/corba/db/APIException:1.0"))
				{
					throw org.dbxml.core.corba.db.APIExceptionHelper.read(_ax.getInputStream());
				}
				else 
					throw new RuntimeException("Unexpected exception " + _id );
			}
			finally
			{
				this._releaseReply(_is);
			}
		}
		else
		{
			org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke( "getName", _opsClass );
			if( _so == null )
				throw new org.omg.CORBA.UNKNOWN("local invocations not supported!");
			DatabaseOperations _localServant = (DatabaseOperations)_so.servant;
			java.lang.String _result;			try
			{
			_result = _localServant.getName();
			}
			finally
			{
				_servant_postinvoke(_so);
			}
			return _result;
		}

		}

	}

}
