LCOV - code coverage report
Current view: top level - libreoffice/connectivity/source/drivers/hsqldb - StorageFileAccess.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 40 0.0 %
Date: 2012-12-27 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #if defined(HAVE_CONFIG_H) && HAVE_CONFIG_H
      22             : #include <config.h>
      23             : #endif
      24             : #include <com/sun/star/container/XNameAccess.hpp>
      25             : #include <com/sun/star/embed/XStorage.hpp>
      26             : #include "hsqldb/StorageFileAccess.h"
      27             : #include "hsqldb/HStorageMap.hxx"
      28             : 
      29             : #include <rtl/logfile.hxx>
      30             : 
      31             : using namespace ::com::sun::star::container;
      32             : using namespace ::com::sun::star::uno;
      33             : using namespace ::com::sun::star::embed;
      34             : using namespace ::com::sun::star::io;
      35             : using namespace ::com::sun::star::lang;
      36             : using namespace ::connectivity::hsqldb;
      37             : 
      38             : /*****************************************************************************/
      39             : /* exception macros */
      40             : 
      41             : #define ThrowException(env, type, msg) { \
      42             :     env->ThrowNew(env->FindClass(type), msg); }
      43             : 
      44             : /*
      45             :  * Class:     com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
      46             :  * Method:    isStreamElement
      47             :  * Signature: (Ljava/lang/String;Ljava/lang/String;)Z
      48             :  */
      49           0 : SAL_JNI_EXPORT jboolean JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_isStreamElement
      50             :   (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name)
      51             : {
      52           0 :     TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(StorageContainer::jstring2ustring(env,key));
      53           0 :     if ( aStoragePair.first.first.is() )
      54             :     {
      55             :         try
      56             :         {
      57           0 :             ::rtl::OUString sName = StorageContainer::jstring2ustring(env,name);
      58             :             try
      59             :             {
      60           0 :                 ::rtl::OUString sOldName = StorageContainer::removeOldURLPrefix(sName);
      61           0 :                 if ( aStoragePair.first.first->isStreamElement(sOldName) )
      62             :                 {
      63             :                     try
      64             :                     {
      65           0 :                         aStoragePair.first.first->renameElement(sOldName,StorageContainer::removeURLPrefix(sName,aStoragePair.first.second));
      66             :                     }
      67           0 :                     catch(const Exception&)
      68             :                     {
      69             :                     }
      70           0 :                 }
      71             :             }
      72           0 :             catch(const NoSuchElementException&)
      73             :             {
      74             :             }
      75           0 :             catch(const IllegalArgumentException&)
      76             :             {
      77             :             }
      78           0 :             return aStoragePair.first.first->isStreamElement(StorageContainer::removeURLPrefix(sName,aStoragePair.first.second));
      79             :         }
      80           0 :         catch(const NoSuchElementException&)
      81             :         {
      82             :         }
      83           0 :         catch(const Exception& e)
      84             :         {
      85             :             OSL_FAIL("Exception caught! : Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_isStreamElement");
      86           0 :             if (JNI_FALSE != env->ExceptionCheck())
      87           0 :                 env->ExceptionClear();
      88           0 :             ::rtl::OString cstr( ::rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_JAVA_UTF8 ) );
      89           0 :             OSL_TRACE( __FILE__": forwarding Exception: %s", cstr.getStr() );
      90             :         }
      91             :     }
      92           0 :     return JNI_FALSE;
      93             : }
      94             : // -----------------------------------------------------------------------------
      95             : 
      96             : /*
      97             :  * Class:     com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
      98             :  * Method:    removeElement
      99             :  * Signature: (Ljava/lang/String;Ljava/lang/String;)V
     100             :  */
     101           0 : SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_removeElement
     102             :   (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name)
     103             : {
     104             : #ifdef HSQLDB_DBG
     105             :     {
     106             :         ::rtl::OUString sKey = StorageContainer::jstring2ustring(env,key);
     107             :         ::rtl::OUString sName = StorageContainer::jstring2ustring(env,name);
     108             :     }
     109             : #endif
     110           0 :     TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(StorageContainer::jstring2ustring(env,key));
     111           0 :     if ( aStoragePair.first.first.is() )
     112             :     {
     113             :         try
     114             :         {
     115           0 :             aStoragePair.first.first->removeElement(StorageContainer::removeURLPrefix(StorageContainer::jstring2ustring(env,name),aStoragePair.first.second));
     116             :         }
     117           0 :         catch(const NoSuchElementException&)
     118             :         {
     119           0 :             if (JNI_FALSE != env->ExceptionCheck())
     120           0 :                 env->ExceptionClear();
     121             :         }
     122           0 :         catch(const Exception& e)
     123             :         {
     124             :             OSL_FAIL("Exception caught! : Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_removeElement");
     125           0 :             StorageContainer::throwJavaException(e,env);
     126             :         }
     127           0 :     }
     128           0 : }
     129             : // -----------------------------------------------------------------------------
     130             : 
     131             : /*
     132             :  * Class:     com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
     133             :  * Method:    renameElement
     134             :  * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
     135             :  */
     136           0 : SAL_JNI_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_renameElement
     137             :   (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring oldname, jstring newname)
     138             : {
     139             : #ifdef HSQLDB_DBG
     140             :     {
     141             :         ::rtl::OUString sKey = StorageContainer::jstring2ustring(env,key);
     142             :         ::rtl::OUString sNewName = StorageContainer::jstring2ustring(env,newname);
     143             :         ::rtl::OUString sOldName = StorageContainer::jstring2ustring(env,oldname);
     144             :     }
     145             : #endif
     146           0 :     TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(StorageContainer::jstring2ustring(env,key));
     147           0 :     if ( aStoragePair.first.first.is() )
     148             :     {
     149             :         try
     150             :         {
     151           0 :             aStoragePair.first.first->renameElement(
     152             :                 StorageContainer::removeURLPrefix(StorageContainer::jstring2ustring(env,oldname),aStoragePair.first.second),
     153             :                 StorageContainer::removeURLPrefix(StorageContainer::jstring2ustring(env,newname),aStoragePair.first.second)
     154           0 :             );
     155             : #ifdef HSQLDB_DBG
     156             :             {
     157             :                 ::rtl::OUString sNewName = StorageContainer::removeURLPrefix(StorageContainer::jstring2ustring(env,newname),aStoragePair.first.second);
     158             :                 OSL_ENSURE(aStoragePair.first.first->isStreamElement(sNewName),"Stream could not be renamed");
     159             :             }
     160             : #endif
     161             :         }
     162           0 :         catch(const NoSuchElementException&)
     163             :         {
     164             :         }
     165           0 :         catch(const Exception& e)
     166             :         {
     167             :             OSL_FAIL("Exception caught! : Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_renameElement");
     168           0 :             StorageContainer::throwJavaException(e,env);
     169             :         }
     170           0 :     }
     171           0 : }
     172             : // -----------------------------------------------------------------------------
     173             : 
     174             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10