1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
30*cdf0e10cSrcweir #include "hsqldb/HStorageMap.hxx"
31*cdf0e10cSrcweir #include <comphelper/types.hxx>
32*cdf0e10cSrcweir #include <com/sun/star/embed/XTransactionBroadcaster.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/embed/XTransactedObject.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
36*cdf0e10cSrcweir #include "diagnose_ex.h"
37*cdf0e10cSrcweir #include <osl/thread.h>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir //........................................................................
40*cdf0e10cSrcweir namespace connectivity
41*cdf0e10cSrcweir {
42*cdf0e10cSrcweir //........................................................................
43*cdf0e10cSrcweir 	namespace hsqldb
44*cdf0e10cSrcweir 	{
45*cdf0e10cSrcweir 	//........................................................................
46*cdf0e10cSrcweir 		using namespace ::com::sun::star::uno;
47*cdf0e10cSrcweir 		using namespace ::com::sun::star::lang;
48*cdf0e10cSrcweir 		using namespace ::com::sun::star::embed;
49*cdf0e10cSrcweir 		using namespace ::com::sun::star::io;
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir #define ThrowException(env, type, msg) { \
52*cdf0e10cSrcweir 	env->ThrowNew(env->FindClass(type), msg); }
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir 		StreamHelper::StreamHelper(const Reference< XStream>& _xStream)
56*cdf0e10cSrcweir 			: m_xStream(_xStream)
57*cdf0e10cSrcweir 		{
58*cdf0e10cSrcweir 		}
59*cdf0e10cSrcweir 		// -----------------------------------------------------------------------------
60*cdf0e10cSrcweir 		StreamHelper::~StreamHelper()
61*cdf0e10cSrcweir 		{
62*cdf0e10cSrcweir 			try
63*cdf0e10cSrcweir 			{
64*cdf0e10cSrcweir                 m_xStream.clear();
65*cdf0e10cSrcweir 			    m_xSeek.clear();
66*cdf0e10cSrcweir 				if ( m_xInputStream.is() )
67*cdf0e10cSrcweir 				{
68*cdf0e10cSrcweir 					m_xInputStream->closeInput();
69*cdf0e10cSrcweir 				    m_xInputStream.clear();
70*cdf0e10cSrcweir 				}
71*cdf0e10cSrcweir                 // this is done implicity by the closing of the input stream
72*cdf0e10cSrcweir 				else if ( m_xOutputStream.is() )
73*cdf0e10cSrcweir 				{
74*cdf0e10cSrcweir 					m_xOutputStream->closeOutput();
75*cdf0e10cSrcweir 					try
76*cdf0e10cSrcweir 					{
77*cdf0e10cSrcweir 						::comphelper::disposeComponent(m_xOutputStream);
78*cdf0e10cSrcweir 					}
79*cdf0e10cSrcweir                     catch(DisposedException&)
80*cdf0e10cSrcweir                     {
81*cdf0e10cSrcweir                     }
82*cdf0e10cSrcweir 					catch(const Exception& e)
83*cdf0e10cSrcweir 					{
84*cdf0e10cSrcweir                         OSL_UNUSED( e );
85*cdf0e10cSrcweir                         OSL_ENSURE(0,"Could not dispose OutputStream");
86*cdf0e10cSrcweir                     }
87*cdf0e10cSrcweir 				    m_xOutputStream.clear();
88*cdf0e10cSrcweir 				}
89*cdf0e10cSrcweir 			}
90*cdf0e10cSrcweir 			catch(Exception& ex)
91*cdf0e10cSrcweir 			{
92*cdf0e10cSrcweir                 OSL_UNUSED( ex );
93*cdf0e10cSrcweir 				OSL_ENSURE(0,"Exception catched!");
94*cdf0e10cSrcweir 			}
95*cdf0e10cSrcweir 		}
96*cdf0e10cSrcweir 		// -----------------------------------------------------------------------------
97*cdf0e10cSrcweir 		Reference< XInputStream> StreamHelper::getInputStream()
98*cdf0e10cSrcweir 		{
99*cdf0e10cSrcweir 			if ( !m_xInputStream.is() )
100*cdf0e10cSrcweir 				m_xInputStream = m_xStream->getInputStream();
101*cdf0e10cSrcweir 			return m_xInputStream;
102*cdf0e10cSrcweir 		}
103*cdf0e10cSrcweir 		// -----------------------------------------------------------------------------
104*cdf0e10cSrcweir 		Reference< XOutputStream> StreamHelper::getOutputStream()
105*cdf0e10cSrcweir 		{
106*cdf0e10cSrcweir 			if ( !m_xOutputStream.is() )
107*cdf0e10cSrcweir 				m_xOutputStream = m_xStream->getOutputStream();
108*cdf0e10cSrcweir 			return m_xOutputStream;
109*cdf0e10cSrcweir 		}
110*cdf0e10cSrcweir 		// -----------------------------------------------------------------------------
111*cdf0e10cSrcweir 		Reference< XSeekable> StreamHelper::getSeek()
112*cdf0e10cSrcweir 		{
113*cdf0e10cSrcweir 			if ( !m_xSeek.is() )
114*cdf0e10cSrcweir 				m_xSeek.set(m_xStream,UNO_QUERY);
115*cdf0e10cSrcweir 			return m_xSeek;
116*cdf0e10cSrcweir 		}
117*cdf0e10cSrcweir 		// -----------------------------------------------------------------------------
118*cdf0e10cSrcweir 		TStorages& lcl_getStorageMap()
119*cdf0e10cSrcweir 		{
120*cdf0e10cSrcweir 			static TStorages s_aMap;
121*cdf0e10cSrcweir 			return s_aMap;
122*cdf0e10cSrcweir 		}
123*cdf0e10cSrcweir 		// -----------------------------------------------------------------------------
124*cdf0e10cSrcweir 		::rtl::OUString lcl_getNextCount()
125*cdf0e10cSrcweir 		{
126*cdf0e10cSrcweir 			static sal_Int32 s_nCount = 0;
127*cdf0e10cSrcweir 			return ::rtl::OUString::valueOf(s_nCount++);
128*cdf0e10cSrcweir 		}
129*cdf0e10cSrcweir 		// -----------------------------------------------------------------------------
130*cdf0e10cSrcweir         ::rtl::OUString StorageContainer::removeURLPrefix(const ::rtl::OUString& _sURL,const ::rtl::OUString& _sFileURL)
131*cdf0e10cSrcweir 		{
132*cdf0e10cSrcweir 			return _sURL.copy(_sFileURL.getLength()+1);
133*cdf0e10cSrcweir 		}
134*cdf0e10cSrcweir 		// -----------------------------------------------------------------------------
135*cdf0e10cSrcweir 		::rtl::OUString StorageContainer::removeOldURLPrefix(const ::rtl::OUString& _sURL)
136*cdf0e10cSrcweir 		{
137*cdf0e10cSrcweir 			::rtl::OUString sRet = _sURL;
138*cdf0e10cSrcweir #if defined(WNT)
139*cdf0e10cSrcweir 			sal_Int32 nIndex = sRet.lastIndexOf('\\');
140*cdf0e10cSrcweir #else
141*cdf0e10cSrcweir 			sal_Int32 nIndex = sRet.lastIndexOf('/');
142*cdf0e10cSrcweir #endif
143*cdf0e10cSrcweir 			if ( nIndex != -1 )
144*cdf0e10cSrcweir 			{
145*cdf0e10cSrcweir 				sRet = _sURL.copy(nIndex+1);
146*cdf0e10cSrcweir 			}
147*cdf0e10cSrcweir 			return sRet;
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 		}
150*cdf0e10cSrcweir 		/*****************************************************************************/
151*cdf0e10cSrcweir 		/* convert jstring to rtl_uString */
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 		::rtl::OUString StorageContainer::jstring2ustring(JNIEnv * env, jstring jstr)
154*cdf0e10cSrcweir 		{
155*cdf0e10cSrcweir 			if (JNI_FALSE != env->ExceptionCheck())
156*cdf0e10cSrcweir 			{
157*cdf0e10cSrcweir 				env->ExceptionClear();
158*cdf0e10cSrcweir 				OSL_ENSURE(0,"ExceptionClear");
159*cdf0e10cSrcweir 			}
160*cdf0e10cSrcweir 			::rtl::OUString aStr;
161*cdf0e10cSrcweir 			if ( jstr )
162*cdf0e10cSrcweir 			{
163*cdf0e10cSrcweir 				jboolean bCopy(sal_True);
164*cdf0e10cSrcweir 				const jchar* pChar = env->GetStringChars(jstr,&bCopy);
165*cdf0e10cSrcweir 				jsize len = env->GetStringLength(jstr);
166*cdf0e10cSrcweir 				aStr = ::rtl::OUString(pChar,len);
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir 				if(bCopy)
169*cdf0e10cSrcweir 					env->ReleaseStringChars(jstr,pChar);
170*cdf0e10cSrcweir 			}
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 			if (JNI_FALSE != env->ExceptionCheck())
173*cdf0e10cSrcweir 			{
174*cdf0e10cSrcweir 				env->ExceptionClear();
175*cdf0e10cSrcweir 				OSL_ENSURE(0,"ExceptionClear");
176*cdf0e10cSrcweir 			}
177*cdf0e10cSrcweir 			return aStr;
178*cdf0e10cSrcweir 		}
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir 		// -----------------------------------------------------------------------------
181*cdf0e10cSrcweir 		::rtl::OUString StorageContainer::registerStorage(const Reference< XStorage>& _xStorage,const ::rtl::OUString& _sURL)
182*cdf0e10cSrcweir 		{
183*cdf0e10cSrcweir 			OSL_ENSURE(_xStorage.is(),"Storage is NULL!");
184*cdf0e10cSrcweir 			TStorages& rMap = lcl_getStorageMap();
185*cdf0e10cSrcweir 			// check if the storage is already in our map
186*cdf0e10cSrcweir 			TStorages::iterator aFind = ::std::find_if(rMap.begin(),rMap.end(),
187*cdf0e10cSrcweir 										::std::compose1(
188*cdf0e10cSrcweir 											::std::bind2nd(::std::equal_to<Reference<XStorage> >(),_xStorage)
189*cdf0e10cSrcweir 											,::std::compose1(::std::select1st<TStorageURLPair>(),::std::compose1(::std::select1st<TStorages::mapped_type>(),::std::select2nd<TStorages::value_type>())))
190*cdf0e10cSrcweir 					);
191*cdf0e10cSrcweir 			if ( aFind == rMap.end() )
192*cdf0e10cSrcweir 			{
193*cdf0e10cSrcweir 				aFind = rMap.insert(TStorages::value_type(lcl_getNextCount(),TStorages::mapped_type(TStorageURLPair(_xStorage,_sURL),TStreamMap()))).first;
194*cdf0e10cSrcweir 			}
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir 			return aFind->first;
197*cdf0e10cSrcweir 		}
198*cdf0e10cSrcweir 		// -----------------------------------------------------------------------------
199*cdf0e10cSrcweir 		TStorages::mapped_type StorageContainer::getRegisteredStorage(const ::rtl::OUString& _sKey)
200*cdf0e10cSrcweir 		{
201*cdf0e10cSrcweir 			TStorages::mapped_type aRet;
202*cdf0e10cSrcweir 			TStorages& rMap = lcl_getStorageMap();
203*cdf0e10cSrcweir 			TStorages::iterator aFind = rMap.find(_sKey);
204*cdf0e10cSrcweir 			OSL_ENSURE(aFind != rMap.end(),"Storage could not be found in list!");
205*cdf0e10cSrcweir 			if ( aFind != rMap.end() )
206*cdf0e10cSrcweir 				aRet = aFind->second;
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir 			return aRet;
209*cdf0e10cSrcweir 		}
210*cdf0e10cSrcweir         // -----------------------------------------------------------------------------
211*cdf0e10cSrcweir         ::rtl::OUString StorageContainer::getRegisteredKey(const Reference< XStorage>& _xStorage)
212*cdf0e10cSrcweir         {
213*cdf0e10cSrcweir             ::rtl::OUString sKey;
214*cdf0e10cSrcweir             OSL_ENSURE(_xStorage.is(),"Storage is NULL!");
215*cdf0e10cSrcweir 			TStorages& rMap = lcl_getStorageMap();
216*cdf0e10cSrcweir 			// check if the storage is already in our map
217*cdf0e10cSrcweir 			TStorages::iterator aFind = ::std::find_if(rMap.begin(),rMap.end(),
218*cdf0e10cSrcweir 										::std::compose1(
219*cdf0e10cSrcweir 											::std::bind2nd(::std::equal_to<Reference<XStorage> >(),_xStorage)
220*cdf0e10cSrcweir 											,::std::compose1(::std::select1st<TStorageURLPair>(),::std::compose1(::std::select1st<TStorages::mapped_type>(),::std::select2nd<TStorages::value_type>())))
221*cdf0e10cSrcweir 					);
222*cdf0e10cSrcweir 			if ( aFind != rMap.end() )
223*cdf0e10cSrcweir                 sKey = aFind->first;
224*cdf0e10cSrcweir             return sKey;
225*cdf0e10cSrcweir         }
226*cdf0e10cSrcweir 		// -----------------------------------------------------------------------------
227*cdf0e10cSrcweir 		void StorageContainer::revokeStorage(const ::rtl::OUString& _sKey,const Reference<XTransactionListener>& _xListener)
228*cdf0e10cSrcweir 		{
229*cdf0e10cSrcweir 			TStorages& rMap = lcl_getStorageMap();
230*cdf0e10cSrcweir             TStorages::iterator aFind = rMap.find(_sKey);
231*cdf0e10cSrcweir             if ( aFind != rMap.end() )
232*cdf0e10cSrcweir             {
233*cdf0e10cSrcweir                 try
234*cdf0e10cSrcweir                 {
235*cdf0e10cSrcweir                     if ( _xListener.is() )
236*cdf0e10cSrcweir                     {
237*cdf0e10cSrcweir                         Reference<XTransactionBroadcaster> xBroad(aFind->second.first.first,UNO_QUERY);
238*cdf0e10cSrcweir                         if ( xBroad.is() )
239*cdf0e10cSrcweir                             xBroad->removeTransactionListener(_xListener);
240*cdf0e10cSrcweir                         Reference<XTransactedObject> xTrans(aFind->second.first.first,UNO_QUERY);
241*cdf0e10cSrcweir                         if ( xTrans.is() )
242*cdf0e10cSrcweir                             xTrans->commit();
243*cdf0e10cSrcweir                     }
244*cdf0e10cSrcweir                 }
245*cdf0e10cSrcweir                 catch(Exception&)
246*cdf0e10cSrcweir                 {
247*cdf0e10cSrcweir                 }
248*cdf0e10cSrcweir 			    rMap.erase(aFind);
249*cdf0e10cSrcweir             }
250*cdf0e10cSrcweir 		}
251*cdf0e10cSrcweir 		// -----------------------------------------------------------------------------
252*cdf0e10cSrcweir 		TStreamMap::mapped_type StorageContainer::registerStream(JNIEnv * env,jstring name, jstring key,sal_Int32 _nMode)
253*cdf0e10cSrcweir 		{
254*cdf0e10cSrcweir 			TStreamMap::mapped_type pHelper;
255*cdf0e10cSrcweir 			TStorages& rMap = lcl_getStorageMap();
256*cdf0e10cSrcweir 			::rtl::OUString sKey = jstring2ustring(env,key);
257*cdf0e10cSrcweir 			TStorages::iterator aFind = rMap.find(sKey);
258*cdf0e10cSrcweir 			OSL_ENSURE(aFind != rMap.end(),"Storage could not be found in list!");
259*cdf0e10cSrcweir 			if ( aFind != rMap.end() )
260*cdf0e10cSrcweir 			{
261*cdf0e10cSrcweir 				TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(sKey);
262*cdf0e10cSrcweir 				OSL_ENSURE(aStoragePair.first.first.is(),"No Storage available!");
263*cdf0e10cSrcweir 				if ( aStoragePair.first.first.is() )
264*cdf0e10cSrcweir 				{
265*cdf0e10cSrcweir                     ::rtl::OUString sOrgName = StorageContainer::jstring2ustring(env,name);
266*cdf0e10cSrcweir 					::rtl::OUString sName = removeURLPrefix(sOrgName,aStoragePair.first.second);
267*cdf0e10cSrcweir 					TStreamMap::iterator aStreamFind = aFind->second.second.find(sName);
268*cdf0e10cSrcweir 					OSL_ENSURE( aStreamFind == aFind->second.second.end(),"A Stream was already registered for this object!");
269*cdf0e10cSrcweir 					if ( aStreamFind != aFind->second.second.end() )
270*cdf0e10cSrcweir 					{
271*cdf0e10cSrcweir 						pHelper = aStreamFind->second;
272*cdf0e10cSrcweir 					}
273*cdf0e10cSrcweir 					else
274*cdf0e10cSrcweir 					{
275*cdf0e10cSrcweir 						try
276*cdf0e10cSrcweir 						{
277*cdf0e10cSrcweir                             try
278*cdf0e10cSrcweir 						    {
279*cdf0e10cSrcweir 							    pHelper.reset(new StreamHelper(aStoragePair.first.first->openStreamElement(sName,_nMode)));
280*cdf0e10cSrcweir                             }
281*cdf0e10cSrcweir                             catch(Exception& )
282*cdf0e10cSrcweir 						    {
283*cdf0e10cSrcweir                                 ::rtl::OUString sStrippedName = removeOldURLPrefix(sOrgName);
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir                                 if ( ((_nMode & ElementModes::WRITE) != ElementModes::WRITE ) )
286*cdf0e10cSrcweir                                 {
287*cdf0e10cSrcweir                                     sal_Bool bIsStream = sal_True;
288*cdf0e10cSrcweir                                     try
289*cdf0e10cSrcweir                                     {
290*cdf0e10cSrcweir                                        bIsStream = aStoragePair.first.first->isStreamElement(sStrippedName);
291*cdf0e10cSrcweir                                     }
292*cdf0e10cSrcweir                                     catch(Exception& )
293*cdf0e10cSrcweir 						            {
294*cdf0e10cSrcweir                                         bIsStream = sal_False;
295*cdf0e10cSrcweir                                     }
296*cdf0e10cSrcweir                                     if ( !bIsStream )
297*cdf0e10cSrcweir 									    return pHelper; // readonly file without data stream
298*cdf0e10cSrcweir                                 }
299*cdf0e10cSrcweir                                 pHelper.reset( new StreamHelper(aStoragePair.first.first->openStreamElement( sStrippedName, _nMode ) ) );
300*cdf0e10cSrcweir                             }
301*cdf0e10cSrcweir 							aFind->second.second.insert(TStreamMap::value_type(sName,pHelper));
302*cdf0e10cSrcweir 						}
303*cdf0e10cSrcweir 						catch(Exception& e)
304*cdf0e10cSrcweir 						{
305*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
306*cdf0e10cSrcweir                             ::rtl::OString sMessage( "[HSQLDB-SDBC] caught an exception while opening a stream\n" );
307*cdf0e10cSrcweir                             sMessage += "Name: ";
308*cdf0e10cSrcweir                             sMessage += ::rtl::OString( sName.getStr(), sName.getLength(), osl_getThreadTextEncoding() );
309*cdf0e10cSrcweir                             sMessage += "\nMode: 0x";
310*cdf0e10cSrcweir                             if ( _nMode < 16 )
311*cdf0e10cSrcweir                                 sMessage += "0";
312*cdf0e10cSrcweir                             sMessage += ::rtl::OString::valueOf( _nMode, 16 ).toAsciiUpperCase();
313*cdf0e10cSrcweir 							OSL_ENSURE( false, sMessage.getStr() );
314*cdf0e10cSrcweir #endif
315*cdf0e10cSrcweir                             StorageContainer::throwJavaException(e,env);
316*cdf0e10cSrcweir 						}
317*cdf0e10cSrcweir 					}
318*cdf0e10cSrcweir 				}
319*cdf0e10cSrcweir 			}
320*cdf0e10cSrcweir 			return pHelper;
321*cdf0e10cSrcweir 		}
322*cdf0e10cSrcweir 		// -----------------------------------------------------------------------------
323*cdf0e10cSrcweir 		void StorageContainer::revokeStream( JNIEnv * env,jstring name, jstring key)
324*cdf0e10cSrcweir 		{
325*cdf0e10cSrcweir 			TStorages& rMap = lcl_getStorageMap();
326*cdf0e10cSrcweir 			TStorages::iterator aFind = rMap.find(jstring2ustring(env,key));
327*cdf0e10cSrcweir 			OSL_ENSURE(aFind != rMap.end(),"Storage could not be found in list!");
328*cdf0e10cSrcweir 			if ( aFind != rMap.end() )
329*cdf0e10cSrcweir 				aFind->second.second.erase(removeURLPrefix(jstring2ustring(env,name),aFind->second.first.second));
330*cdf0e10cSrcweir 		}
331*cdf0e10cSrcweir 		// -----------------------------------------------------------------------------
332*cdf0e10cSrcweir 		TStreamMap::mapped_type StorageContainer::getRegisteredStream( JNIEnv * env,jstring name, jstring key)
333*cdf0e10cSrcweir 		{
334*cdf0e10cSrcweir 			TStreamMap::mapped_type  pRet;
335*cdf0e10cSrcweir 			TStorages& rMap = lcl_getStorageMap();
336*cdf0e10cSrcweir 			TStorages::iterator aFind = rMap.find(jstring2ustring(env,key));
337*cdf0e10cSrcweir 			OSL_ENSURE(aFind != rMap.end(),"Storage could not be found in list!");
338*cdf0e10cSrcweir 			if ( aFind != rMap.end() )
339*cdf0e10cSrcweir 			{
340*cdf0e10cSrcweir 				TStreamMap::iterator aStreamFind = aFind->second.second.find(removeURLPrefix(jstring2ustring(env,name),aFind->second.first.second));
341*cdf0e10cSrcweir 				if ( aStreamFind != aFind->second.second.end() )
342*cdf0e10cSrcweir 					pRet = aStreamFind->second;
343*cdf0e10cSrcweir 			}
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir 			return pRet;
346*cdf0e10cSrcweir 		}
347*cdf0e10cSrcweir 		// -----------------------------------------------------------------------------
348*cdf0e10cSrcweir         void StorageContainer::throwJavaException(const Exception& _aException,JNIEnv * env)
349*cdf0e10cSrcweir         {
350*cdf0e10cSrcweir             if (JNI_FALSE != env->ExceptionCheck())
351*cdf0e10cSrcweir 			    env->ExceptionClear();
352*cdf0e10cSrcweir 		    ::rtl::OString cstr( ::rtl::OUStringToOString(_aException.Message, RTL_TEXTENCODING_JAVA_UTF8 ) );
353*cdf0e10cSrcweir 		    OSL_TRACE( __FILE__": forwarding Exception: %s", cstr.getStr() );
354*cdf0e10cSrcweir             env->ThrowNew(env->FindClass("java/io/IOException"), cstr.getStr());
355*cdf0e10cSrcweir         }
356*cdf0e10cSrcweir 	//........................................................................
357*cdf0e10cSrcweir 	}	// namespace hsqldb
358*cdf0e10cSrcweir 	//........................................................................
359*cdf0e10cSrcweir //........................................................................
360*cdf0e10cSrcweir }
361*cdf0e10cSrcweir // namespace connectivity
362*cdf0e10cSrcweir //........................................................................
363