Elements  6.2
A C++ base framework for the Euclid Software.
WebdavSynchronizer.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2020 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 3.0 of the License, or (at your option)
7  * any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include <string>
20 
22 
23 namespace Elements {
24 inline namespace Services {
25 namespace DataSync {
26 
28  return checkCall("wget -h");
29 }
30 
32  const DependencyConfiguration& dependency)
33  : DataSynchronizer(connection, dependency) {
34  if (not webdavIsInstalled()) {
35  throw std::runtime_error("You are trying to use WebDAV, "
36  "but it does not seem to be installed.");
37  }
38 }
39 
41  std::string cmd = "wget --no-check-certificate ";
42  cmd += " --user=" + m_connection.user;
43  cmd += " --password=" + m_connection.password;
44  cmd += " -O " + localFile.string();
45  cmd += " " + m_connection.hostUrl + "/" + distantFile.string();
46  cmd += " --tries " + std::to_string(m_connection.tries);
47  return cmd;
48 }
49 
50 } // namespace DataSync
51 } // namespace Services
52 } // namespace Elements
Elements::Services::DataSync::checkCall
ELEMENTS_API bool checkCall(const std::string &command)
Definition: DataSyncUtils.cpp:43
Elements::Services::DataSync::WebdavSynchronizer::WebdavSynchronizer
WebdavSynchronizer(const ConnectionConfiguration &connection, const DependencyConfiguration &dependency)
Definition: WebdavSynchronizer.cpp:31
std::string
STL class.
Elements::Services::DataSync::ConnectionConfiguration::password
std::string password
Definition: ConnectionConfiguration.h:101
Elements::Services::DataSync::webdavIsInstalled
ELEMENTS_API bool webdavIsInstalled()
Check whether the WebDAV client is installed.
Definition: WebdavSynchronizer.cpp:27
Elements::Services::DataSync::ConnectionConfiguration::tries
size_t tries
Definition: ConnectionConfiguration.h:103
Elements::Services::DataSync::DataSynchronizer
Base class to synchronize test data.
Definition: DataSynchronizer.h:61
Elements::Services::DataSync::ConnectionConfiguration::user
std::string user
Definition: ConnectionConfiguration.h:100
Elements::Services::DataSync::DependencyConfiguration
The dependency configurations holds, for each test file to be retrieved:
Definition: DependencyConfiguration.h:45
std::to_string
T to_string(T... args)
std::runtime_error
STL class.
Elements::Services::DataSync::WebdavSynchronizer::createDownloadCommand
std::string createDownloadCommand(path distantFile, path localFile) const override
Definition: WebdavSynchronizer.cpp:40
WebdavSynchronizer.h
Elements::Services::DataSync::ConnectionConfiguration::hostUrl
std::string hostUrl
Definition: ConnectionConfiguration.h:99
Elements::Services::DataSync::ConnectionConfiguration
The connection configuration mainly holds:
Definition: ConnectionConfiguration.h:75
Elements
Definition: callBackExample.h:35
Elements::Services::DataSync::path
Path::Item path
importing the path item from ElementsKernel
Definition: DataSyncUtils.h:41
Elements::Services::DataSync::DataSynchronizer::m_connection
ConnectionConfiguration m_connection
Definition: DataSynchronizer.h:82