[Opentrep-svn] SF.net SVN: opentrep:[221] trunk/opentrep
Status: Beta
Brought to you by:
denis_arnaud
From: <den...@us...> - 2010-09-04 16:43:05
|
Revision: 221 http://opentrep.svn.sourceforge.net/opentrep/?rev=221&view=rev Author: denis_arnaud Date: 2010-09-04 16:42:52 +0000 (Sat, 04 Sep 2010) Log Message: ----------- [Dev] Improved the robustness: the path given to the Xapian database is now checked for existence. Modified Paths: -------------- trunk/opentrep/configure.ac trunk/opentrep/opentrep/OPENTREP_Types.hpp trunk/opentrep/opentrep/basic/Makefile.am trunk/opentrep/opentrep/batches/indexer.cpp trunk/opentrep/opentrep/batches/searcher.cpp trunk/opentrep/opentrep/bom/Makefile.am trunk/opentrep/opentrep/command/Makefile.am trunk/opentrep/opentrep/core/Makefile.am trunk/opentrep/opentrep/dbadaptor/Makefile.am trunk/opentrep/opentrep/factory/Makefile.am trunk/opentrep/opentrep/service/Makefile.am trunk/opentrep/opentrep/service/OPENTREP_Service.cpp trunk/opentrep/opentrep/service/OPENTREP_ServiceContext.cpp trunk/opentrep/opentrep/service/sources.mk Added Paths: ----------- trunk/opentrep/opentrep/service/ServiceUtilities.cpp trunk/opentrep/opentrep/service/ServiceUtilities.hpp Modified: trunk/opentrep/configure.ac =================================================================== --- trunk/opentrep/configure.ac 2010-09-04 15:51:55 UTC (rev 220) +++ trunk/opentrep/configure.ac 2010-09-04 16:42:52 UTC (rev 221) @@ -15,7 +15,7 @@ AC_SUBST(RPM_RELEASE) # Shared library versioning -GENERIC_LIBRARY_VERSION="0:4:0" +GENERIC_LIBRARY_VERSION="99:99:99" # | | | # +------+ | +---+ # | | | @@ -148,6 +148,7 @@ AC_SUBST(BOOST_DATE_TIME_LIB) AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) AC_SUBST(BOOST_FILESYSTEM_LIB) +AC_SUBST(BOOST_SYSTEM_LIB) AC_SUBST(BOOST_THREAD_LIB) AC_SUBST(BOOST_PYTHON_LIB) #AC_SUBST(BOOST_ASIO_LIB) @@ -357,6 +358,7 @@ o BOOST_DT_LIB .... : ${BOOST_DATE_TIME_LIB} o BOOST_PO_LIB .... : ${BOOST_PROGRAM_OPTIONS_LIB} o BOOST_FS_LIB .... : ${BOOST_FILESYSTEM_LIB} + o BOOST_SYS_LIB ... : ${BOOST_SYSTEM_LIB} o BOOST_THRD_LIB .. : ${BOOST_THREAD_LIB} o BOOST_PY_LIB .... : ${BOOST_PYTHON_LIB} o BOOST_ASIO_LIB .. : ${BOOST_ASIO_LIB} Modified: trunk/opentrep/opentrep/OPENTREP_Types.hpp =================================================================== --- trunk/opentrep/opentrep/OPENTREP_Types.hpp 2010-09-04 15:51:55 UTC (rev 220) +++ trunk/opentrep/opentrep/OPENTREP_Types.hpp 2010-09-04 16:42:52 UTC (rev 221) @@ -45,6 +45,9 @@ class XapianTravelDatabaseEmptyException : public XapianException { }; + class XapianTravelDatabaseWrongPathnameException : public XapianException { + }; + class XapianTravelDatabaseNotInSyncWithSQLDatabaseException : public XapianException { }; Modified: trunk/opentrep/opentrep/basic/Makefile.am =================================================================== --- trunk/opentrep/opentrep/basic/Makefile.am 2010-09-04 15:51:55 UTC (rev 220) +++ trunk/opentrep/opentrep/basic/Makefile.am 2010-09-04 16:42:52 UTC (rev 221) @@ -1,11 +1,13 @@ -## basic sub-directory +## opentrep/basic sub-directory include $(top_srcdir)/Makefile.common include $(srcdir)/sources.mk -noinst_LTLIBRARIES= libbas.la +# +noinst_LTLIBRARIES = libopentrepbas.la -libbas_la_SOURCES= $(bas_h_sources) $(bas_cc_sources) -libbas_la_CXXFLAGS = +libopentrepbas_la_SOURCES = $(bas_h_sources) $(bas_cc_sources) +libopentrepbas_la_CXXFLAGS = +# #pkgincludedir = $(includedir)/@PACKAGE@/basic #pkginclude_HEADERS = $(bas_h_sources) Modified: trunk/opentrep/opentrep/batches/indexer.cpp =================================================================== --- trunk/opentrep/opentrep/batches/indexer.cpp 2010-09-04 15:51:55 UTC (rev 220) +++ trunk/opentrep/opentrep/batches/indexer.cpp 2010-09-04 16:42:52 UTC (rev 221) @@ -1,6 +1,5 @@ -// C -#include <assert.h> // STL +#include <cassert> #include <iostream> #include <sstream> #include <fstream> @@ -168,6 +167,7 @@ // /////////////// M A I N ///////////////// int main (int argc, char* argv[]) { + try { // Output log File @@ -220,7 +220,7 @@ // std::cout << lNbOfEntries << " entries have been processed" << std::endl; - + } catch (const OPENTREP::RootException& otexp) { std::cerr << "Standard exception: " << otexp.what() << std::endl; return -1; @@ -232,6 +232,6 @@ } catch (...) { return -1; } - + return 0; } Modified: trunk/opentrep/opentrep/batches/searcher.cpp =================================================================== --- trunk/opentrep/opentrep/batches/searcher.cpp 2010-09-04 15:51:55 UTC (rev 220) +++ trunk/opentrep/opentrep/batches/searcher.cpp 2010-09-04 16:42:52 UTC (rev 221) @@ -1,6 +1,5 @@ -// C -#include <assert.h> // STL +#include <cassert> #include <iostream> #include <sstream> #include <fstream> Modified: trunk/opentrep/opentrep/bom/Makefile.am =================================================================== --- trunk/opentrep/opentrep/bom/Makefile.am 2010-09-04 15:51:55 UTC (rev 220) +++ trunk/opentrep/opentrep/bom/Makefile.am 2010-09-04 16:42:52 UTC (rev 221) @@ -1,12 +1,14 @@ -## bom sub-directory +## opentrep/bom sub-directory include $(top_srcdir)/Makefile.common include $(srcdir)/sources.mk -noinst_LTLIBRARIES= libbom.la +# +noinst_LTLIBRARIES= libopentrepbom.la -libbom_la_SOURCES= $(bom_h_sources) $(bom_cc_sources) -libbom_la_CXXFLAGS = $(GSL_CFLAGS) -libbom_la_LDFLAGS = $(GSL_LIBS) +libopentrepbom_la_SOURCES = $(bom_h_sources) $(bom_cc_sources) +libopentrepbom_la_CXXFLAGS = $(GSL_CFLAGS) +libopentrepbom_la_LDFLAGS = $(GSL_LIBS) +# #pkgincludedir = $(includedir)/@PACKAGE@/bom #pkginclude_HEADERS = $(bom_h_sources) Modified: trunk/opentrep/opentrep/command/Makefile.am =================================================================== --- trunk/opentrep/opentrep/command/Makefile.am 2010-09-04 15:51:55 UTC (rev 220) +++ trunk/opentrep/opentrep/command/Makefile.am 2010-09-04 16:42:52 UTC (rev 221) @@ -1,12 +1,15 @@ -## command sub-directory +## opentrep/command sub-directory include $(top_srcdir)/Makefile.common include $(srcdir)/sources.mk -noinst_LTLIBRARIES= libcmd.la +# +noinst_LTLIBRARIES = libopentrepcmd.la -libcmd_la_SOURCES= $(cmd_h_sources) $(cmd_cc_sources) -libcmd_la_CXXFLAGS = $(SOCI_CFLAGS) $(XAPIAN_CFLAGS) $(MYSQL_CFLAGS) -libcmd_la_LDFLAGS = $(SOCI_LIBS) $(XAPIAN_LIBS) $(MYSQL_LIBS) +libopentrepcmd_la_SOURCES= $(cmd_h_sources) $(cmd_cc_sources) +libopentrepcmd_la_CXXFLAGS = $(SOCI_CFLAGS) $(XAPIAN_CFLAGS) \ + $(MYSQL_CFLAGS) $(BOOST_CFLAGS) +libopentrepcmd_la_LDFLAGS = $(SOCI_LIBS) $(XAPIAN_LIBS) $(MYSQL_LIBS) +# #pkgincludedir = $(includedir)/@PACKAGE@/command #pkginclude_HEADERS = $(cmd_h_sources) Modified: trunk/opentrep/opentrep/core/Makefile.am =================================================================== --- trunk/opentrep/opentrep/core/Makefile.am 2010-09-04 15:51:55 UTC (rev 220) +++ trunk/opentrep/opentrep/core/Makefile.am 2010-09-04 16:42:52 UTC (rev 221) @@ -1,3 +1,4 @@ +## opentrep/core sub-directory include $(top_srcdir)/Makefile.common include $(srcdir)/sources.mk @@ -13,17 +14,17 @@ lib@PACKAGE@_la_SOURCES = $(service_h_sources) $(service_cc_sources) lib@PACKAGE@_la_LIBADD = \ - $(top_builddir)/@PACKAGE@/basic/libbas.la \ - $(top_builddir)/@PACKAGE@/bom/libbom.la \ - $(top_builddir)/@PACKAGE@/factory/libfac.la \ - $(top_builddir)/@PACKAGE@/dbadaptor/libdba.la \ - $(top_builddir)/@PACKAGE@/command/libcmd.la \ - $(top_builddir)/@PACKAGE@/service/libsvc.la + $(top_builddir)/@PACKAGE@/basic/libopentrepbas.la \ + $(top_builddir)/@PACKAGE@/bom/libopentrepbom.la \ + $(top_builddir)/@PACKAGE@/factory/libopentrepfac.la \ + $(top_builddir)/@PACKAGE@/dbadaptor/libopentrepdba.la \ + $(top_builddir)/@PACKAGE@/command/libopentrepcmd.la \ + $(top_builddir)/@PACKAGE@/service/libopentrepsvc.la lib@PACKAGE@_la_LDFLAGS = \ $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) \ - $(SOCI_LIBS) -version-info $(GENERIC_LIBRARY_VERSION) + $(BOOST_FILESYSTEM_LIB) $(SOCI_LIBS) \ + -version-info $(GENERIC_LIBRARY_VERSION) # Header files pkginclude_HEADERS = $(service_h_sources) nobase_nodist_pkginclude_HEADERS = $(top_builddir)/@PACKAGE@/config.h - Modified: trunk/opentrep/opentrep/dbadaptor/Makefile.am =================================================================== --- trunk/opentrep/opentrep/dbadaptor/Makefile.am 2010-09-04 15:51:55 UTC (rev 220) +++ trunk/opentrep/opentrep/dbadaptor/Makefile.am 2010-09-04 16:42:52 UTC (rev 221) @@ -1,12 +1,14 @@ -## dba sub-directory +## opentrep/dbadaptor sub-directory include $(top_srcdir)/Makefile.common include $(srcdir)/sources.mk -noinst_LTLIBRARIES= libdba.la +# +noinst_LTLIBRARIES = libopentrepdba.la -libdba_la_SOURCES= $(dba_h_sources) $(dba_cc_sources) -libdba_la_CXXFLAGS = $(CXXFLAGS_OPT) $(SOCI_CFLAGS) -libdba_la_LIBADD = $(SOCI_LIBS) +libopentrepdba_la_SOURCES= $(dba_h_sources) $(dba_cc_sources) +libopentrepdba_la_CXXFLAGS = $(SOCI_CFLAGS) +libopentrepdba_la_LIBADD = $(SOCI_LIBS) +# #pkgincludedir = $(includedir)/@PACKAGE@/dba #pkginclude_HEADERS = $(dba_h_sources) Modified: trunk/opentrep/opentrep/factory/Makefile.am =================================================================== --- trunk/opentrep/opentrep/factory/Makefile.am 2010-09-04 15:51:55 UTC (rev 220) +++ trunk/opentrep/opentrep/factory/Makefile.am 2010-09-04 16:42:52 UTC (rev 221) @@ -1,11 +1,13 @@ -## factory sub-directory +## opentrep/factory sub-directory include $(top_srcdir)/Makefile.common include $(srcdir)/sources.mk -noinst_LTLIBRARIES= libfac.la +# +noinst_LTLIBRARIES = libopentrepfac.la -libfac_la_SOURCES= $(fac_h_sources) $(fac_cc_sources) -libfac_la_CXXFLAGS = +libopentrepfac_la_SOURCES= $(fac_h_sources) $(fac_cc_sources) +libopentrepfac_la_CXXFLAGS = +# #pkgincludedir = $(includedir)/@PACKAGE@/factory #pkginclude_HEADERS = $(fac_h_sources) Modified: trunk/opentrep/opentrep/service/Makefile.am =================================================================== --- trunk/opentrep/opentrep/service/Makefile.am 2010-09-04 15:51:55 UTC (rev 220) +++ trunk/opentrep/opentrep/service/Makefile.am 2010-09-04 16:42:52 UTC (rev 221) @@ -1,11 +1,14 @@ -## command sub-directory +## opentrep/command sub-directory include $(top_srcdir)/Makefile.common include $(srcdir)/sources.mk -noinst_LTLIBRARIES= libsvc.la +# +noinst_LTLIBRARIES = libopentrepsvc.la -libsvc_la_SOURCES= $(svc_h_sources) $(svc_cc_sources) -libsvc_la_CXXFLAGS = $(SOCI_CFLAGS) +libopentrepsvc_la_SOURCES = $(svc_h_sources) $(svc_cc_sources) +libopentrepsvc_la_CXXFLAGS = $(SOCI_CFLAGS) $(BOOST_CFLAGS) +libopentrepsvc_la_LDFLAGS = +# #pkgincludedir = $(includedir)/@PACKAGE@/service #pkginclude_HEADERS = $(svc_h_sources) Modified: trunk/opentrep/opentrep/service/OPENTREP_Service.cpp =================================================================== --- trunk/opentrep/opentrep/service/OPENTREP_Service.cpp 2010-09-04 15:51:55 UTC (rev 220) +++ trunk/opentrep/opentrep/service/OPENTREP_Service.cpp 2010-09-04 16:42:52 UTC (rev 221) @@ -1,7 +1,7 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// C +// STL #include <cassert> // Boost #include <boost/date_time/gregorian/gregorian.hpp> @@ -16,6 +16,7 @@ #include <opentrep/command/RequestInterpreter.hpp> #include <opentrep/factory/FacOpenTrepServiceContext.hpp> #include <opentrep/service/OPENTREP_ServiceContext.hpp> +#include <opentrep/service/ServiceUtilities.hpp> #include <opentrep/service/Logger.hpp> #include <opentrep/OPENTREP_Service.hpp> @@ -62,9 +63,16 @@ // Check that the Xapian travel database is not empty if (iTravelDatabaseName.empty() == true) { OPENTREP_LOG_ERROR ("The filepath for the Xapian travel database is " - << "empty."); - throw XapianTravelDatabaseEmptyException(); + << "not specified."); + throw XapianTravelDatabaseWrongPathnameException(); } + + if (ServiceUtilities::isDirectory (iTravelDatabaseName) == false) { + OPENTREP_LOG_ERROR ("The filepath for the Xapian travel database ('" + << iTravelDatabaseName << "') does " + << "not correspond to a directory."); + throw XapianTravelDatabaseWrongPathnameException(); + } // Check that the parameters for the SQL database are not empty if (iDBParams.check() == false) { Modified: trunk/opentrep/opentrep/service/OPENTREP_ServiceContext.cpp =================================================================== --- trunk/opentrep/opentrep/service/OPENTREP_ServiceContext.cpp 2010-09-04 15:51:55 UTC (rev 220) +++ trunk/opentrep/opentrep/service/OPENTREP_ServiceContext.cpp 2010-09-04 16:42:52 UTC (rev 221) @@ -1,10 +1,8 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// C -#include <assert.h> // STL -#include <iostream> +#include <cassert> #include <sstream> // OpenTrep #include <opentrep/basic/BasConst_OPENTREP_Service.hpp> Added: trunk/opentrep/opentrep/service/ServiceUtilities.cpp =================================================================== --- trunk/opentrep/opentrep/service/ServiceUtilities.cpp (rev 0) +++ trunk/opentrep/opentrep/service/ServiceUtilities.cpp 2010-09-04 16:42:52 UTC (rev 221) @@ -0,0 +1,34 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// Boost::Filesystem +#include <boost/filesystem.hpp> +// OpenTREP +#include <opentrep/service/Logger.hpp> +#include <opentrep/service/ServiceUtilities.hpp> + +namespace OPENTREP { + + // ////////////////////////////////////////////////////////////////////// + bool ServiceUtilities::isDirectory (const std::string& iPath) { + bool oIsDirectory = false; + + if (boost::filesystem::exists (iPath) == true) { + + if (boost::filesystem::is_directory (iPath) == true) { + oIsDirectory = true; + + } else { + OPENTREP_LOG_ERROR (iPath << " exists, but is not a directory"); + } + + } else { + OPENTREP_LOG_ERROR (iPath << " does not exist"); + } + + return oIsDirectory; + } + +} Added: trunk/opentrep/opentrep/service/ServiceUtilities.hpp =================================================================== --- trunk/opentrep/opentrep/service/ServiceUtilities.hpp (rev 0) +++ trunk/opentrep/opentrep/service/ServiceUtilities.hpp 2010-09-04 16:42:52 UTC (rev 221) @@ -0,0 +1,22 @@ +#ifndef __OPENTREP_SVC_SERVICEUTILITIES_HPP +#define __OPENTREP_SVC_SERVICEUTILITIES_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> + +namespace OPENTREP { + + /** Class wrapping some utility functions. */ + class ServiceUtilities { + public: + /** States whether the path given as parameter exists and is a directory. + @param const std::string& Path to be tested for existence. + @return bool Whether or not the path corresponds to a directory. */ + static bool isDirectory (const std::string& iPath); + }; + +} +#endif // __OPENTREP_SVC_SERVICEUTILITIES_HPP Modified: trunk/opentrep/opentrep/service/sources.mk =================================================================== --- trunk/opentrep/opentrep/service/sources.mk 2010-09-04 15:51:55 UTC (rev 220) +++ trunk/opentrep/opentrep/service/sources.mk 2010-09-04 16:42:52 UTC (rev 221) @@ -1,7 +1,11 @@ -svc_h_sources = $(top_srcdir)/opentrep/service/ServiceAbstract.hpp \ - $(top_srcdir)/opentrep/service/OPENTREP_ServiceContext.hpp \ - $(top_srcdir)/opentrep/service/Logger.hpp -svc_cc_sources = $(top_srcdir)/opentrep/service/ServiceAbstract.cpp \ - $(top_srcdir)/opentrep/service/OPENTREP_ServiceContext.cpp \ - $(top_srcdir)/opentrep/service/Logger.cpp \ - $(top_srcdir)/opentrep/service/OPENTREP_Service.cpp +svc_h_sources = \ + $(top_srcdir)/opentrep/service/ServiceAbstract.hpp \ + $(top_srcdir)/opentrep/service/OPENTREP_ServiceContext.hpp \ + $(top_srcdir)/opentrep/service/ServiceUtilities.hpp \ + $(top_srcdir)/opentrep/service/Logger.hpp +svc_cc_sources = \ + $(top_srcdir)/opentrep/service/ServiceAbstract.cpp \ + $(top_srcdir)/opentrep/service/OPENTREP_ServiceContext.cpp \ + $(top_srcdir)/opentrep/service/ServiceUtilities.cpp \ + $(top_srcdir)/opentrep/service/Logger.cpp \ + $(top_srcdir)/opentrep/service/OPENTREP_Service.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |