OPeNDAP Hyrax Back End Server (BES)
Updated for version 3.8.3
|
00001 // BESFileContainer.cc 00002 00003 // This file is part of bes, A C++ back-end server implementation framework 00004 // for the OPeNDAP Data Access Protocol. 00005 00006 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research 00007 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu> 00008 // 00009 // This library is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU Lesser General Public 00011 // License as published by the Free Software Foundation; either 00012 // version 2.1 of the License, or (at your option) any later version. 00013 // 00014 // This library is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 // Lesser General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU Lesser General Public 00020 // License along with this library; if not, write to the Free Software 00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 // 00023 // You can contact University Corporation for Atmospheric Research at 00024 // 3080 Center Green Drive, Boulder, CO 80301 00025 00026 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005 00027 // Please read the full copyright statement in the file COPYRIGHT_UCAR. 00028 // 00029 // Authors: 00030 // pwest Patrick West <pwest@ucar.edu> 00031 // jgarcia Jose Garcia <jgarcia@ucar.edu> 00032 00033 #include "BESFileContainer.h" 00034 #include "TheBESKeys.h" 00035 #include "BESUncompressManager.h" 00036 #include "BESCache.h" 00037 #include "BESForbiddenError.h" 00038 00045 BESFileContainer::BESFileContainer( const string &sym_name, 00046 const string &real_name, 00047 const string &type ) 00048 : BESContainer( sym_name, real_name, type ) 00049 { 00050 string::size_type dotdot = real_name.find( ".." ) ; 00051 if( dotdot != string::npos ) 00052 { 00053 string s = (string)"'../' not allowed in container real name " 00054 + real_name ; 00055 throw BESForbiddenError( s, __FILE__, __LINE__ ) ; 00056 } 00057 } 00058 00063 BESFileContainer::BESFileContainer( const BESFileContainer ©_from ) 00064 : BESContainer( copy_from ) 00065 { 00066 } 00067 00068 void 00069 BESFileContainer::_duplicate( BESContainer ©_to ) 00070 { 00071 BESContainer::_duplicate( copy_to ) ; 00072 } 00073 00078 BESContainer * 00079 BESFileContainer::ptr_duplicate( ) 00080 { 00081 BESContainer *container = new BESFileContainer ; 00082 BESContainer::_duplicate( *container ) ; 00083 return container ; 00084 } 00085 00091 string 00092 BESFileContainer::access() 00093 { 00094 // This is easy ... create the cache using the different keys 00095 BESKeys *keys = TheBESKeys::TheKeys() ; 00096 BESCache cache( *keys, "BES.CacheDir", "BES.CachePrefix", "BES.CacheSize" ); 00097 00098 _cached = BESUncompressManager::TheManager()->uncompress( get_real_name(), 00099 _target, cache ) ; 00100 if( _cached ) 00101 return _target ; 00102 return get_real_name() ; 00103 } 00104 00112 bool 00113 BESFileContainer::release() 00114 { 00115 // If the file is cached then we will need to release the lock on the 00116 // target 00117 return true ; 00118 } 00119 00127 void 00128 BESFileContainer::dump( ostream &strm ) const 00129 { 00130 strm << BESIndent::LMarg << "BESFileContainer::dump - (" 00131 << (void *)this << ")" << endl ; 00132 BESIndent::Indent() ; 00133 BESContainer::dump( strm ) ; 00134 BESIndent::UnIndent() ; 00135 } 00136