Commit 2b20b732 authored by Marco De Marco's avatar Marco De Marco
Browse files

Check if file exists on get property method

parent 9a20bf40
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -23,7 +23,8 @@ CXX_DEBUG_FLAGS=-g -DVERBOSE_DEBUG
CXX_RELEASE_FLAGS=-O3
CXX_DEFAULT_FLAGS=-c -Wall -Wextra -std=c++11 -std=gnu++11
LDFLAGS=-Wall -lomniORB4 -lomniDynamic4 -lCOS4 -lomnithread -ltango -llog4tango \
	-lsoci_core -lsoci_mysql -lboost_system -lboost_thread -lprotobuf -lssl
	-lsoci_core -lsoci_mysql -lboost_system -lboost_thread -lboost_filesystem \
	-lprotobuf -lssl
INC_PARM=$(foreach d, $(INC_DIR), -I$d)
LIB_PARM=$(foreach d, $(LIB_DIR), -L$d)
PROTOC :=/usr/local/protobuf-2.5.0/bin/protoc
+30 −3
Original line number Diff line number Diff line
@@ -45,6 +45,8 @@
#include <PlainClient.h>
#include <SSLClient.h>

#include <boost/filesystem.hpp>

/*----- PROTECTED REGION END -----*/	//	MetadataImporter.cpp

/**
@@ -393,9 +395,14 @@ void MetadataImporter::get_device_property()
        if(remotePassword.empty())
            throw(invalid_argument("RemotePassword property is empty or not defined"));

        if(enableSSL && certificateFile.empty())
        if(enableSSL)
        {
            if(certificateFile.empty())
                throw(invalid_argument("CertificateFile property is empty or not defined"));

            checkIfFileExists(certificateFile);
        }

        if(databaseHost.empty())
                throw(invalid_argument("DatabaseHost property is empty or not defined"));

@@ -561,7 +568,27 @@ void MetadataImporter::off()

/*----- PROTECTED REGION ID(MetadataImporter::namespace_ending) ENABLED START -----*/

//	Additional Methods
//==============================================================================
//      MetadataImporter::checkIfFileExists()
//==============================================================================
void MetadataImporter::checkIfFileExists(std::string fileName)
    throw(std::invalid_argument)
{
    boost::filesystem::path path(fileName);

    if(!boost::filesystem::exists(path))
    {
        std::stringstream errorStream;
        errorStream << "File " << fileName
            << " not exists" << std::endl;
        throw std::invalid_argument(errorStream.str());
    }

    #ifdef VERBOSE_DEBUG
        INFO_STREAM << "FILE: " << fileName << " -> OK" << endl;
        INFO_STREAM << "-------------------------------------------------" << endl;
    #endif
}

/*----- PROTECTED REGION END -----*/	//	MetadataImporter::namespace_ending
} //	namespace
+2 −1
Original line number Diff line number Diff line
@@ -208,7 +208,8 @@ public:

/*----- PROTECTED REGION ID(MetadataImporter::Additional Method prototypes) ENABLED START -----*/

//	Additional Method prototypes
    virtual void checkIfFileExists(std::string)
        throw(std::invalid_argument);

/*----- PROTECTED REGION END -----*/	//	MetadataImporter::Additional Method prototypes
};