Elements 6.3.1
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
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 "ElementsServices/DataSync/WebdavSynchronizer.h" // for WebdavSynchronizer, webdavIsInstalled
20
21#include <stdexcept> // for runtime_error
22#include <string> // for allocator, operator+, char_traits, to_string, string
23
24#include "ElementsServices/DataSync/ConnectionConfiguration.h" // for ConnectionConfiguration
25#include "ElementsServices/DataSync/DataSyncUtils.h" // for checkCall, path
26#include "ElementsServices/DataSync/DataSynchronizer.h" // for DataSynchronizer
27#include "ElementsServices/DataSync/DependencyConfiguration.h" // for DependencyConfiguration
28
29namespace Elements {
30inline namespace Services {
31namespace DataSync {
32
34 return checkCall("wget -h");
35}
36
38 const DependencyConfiguration& dependency)
39 : DataSynchronizer(connection, dependency) {
40 if (not webdavIsInstalled()) {
41 throw std::runtime_error("You are trying to use WebDAV, "
42 "but it does not seem to be installed.");
43 }
44}
45
47 std::string cmd = "wget --no-check-certificate ";
48 cmd += " --user=" + m_connection.user;
49 cmd += " --password=" + m_connection.password;
50 cmd += " -O " + localFile.string();
51 cmd += " " + m_connection.hostUrl + "/" + distantFile.string();
52 cmd += " --tries " + std::to_string(m_connection.tries);
53 return cmd;
54}
55
56} // namespace DataSync
57} // namespace Services
58} // namespace Elements
Base class to synchronize test data.
The dependency configurations holds, for each test file to be retrieved:
WebdavSynchronizer(const ConnectionConfiguration &connection, const DependencyConfiguration &dependency)
std::string createDownloadCommand(path distantFile, path localFile) const override
ELEMENTS_API bool webdavIsInstalled()
Check whether the WebDAV client is installed.
Path::Item path
importing the path item from ElementsKernel
ELEMENTS_API bool checkCall(const std::string &command)
T to_string(T... args)