summaryrefslogtreecommitdiff
path: root/src/repoList.cpp
blob: f66e019ff00675bcd4c164fde37c361b47ff43cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "repoList.h"
#include "repo.h"
#include <Ice/ObjectAdapter.h>
#include <Ice/Properties.h>

#include <compileTimeFormatter.h>

GitFS::RepoList::RepoList(Ice::PropertiesPtr && p) : properties(std::move(p)) { }

AdHocFormatter(RepoPropertyName, "GitFS.%?.%?");

NetFS::VolumePrxPtr
GitFS::RepoList::connect(const ::std::string volume, const ::std::string auth, const ::Ice::Current & ice)
{
	if (volume.empty()) {
		throw NetFS::ConfigError();
	}

	const auto propReader = [volume, this](auto n) {
		return properties->getProperty(RepoPropertyName::get(volume, n));
	};

	if (propReader("gitdir").empty()) {
		throw NetFS::ConfigError();
	}
	if (propReader("authkey") != auth) {
		throw NetFS::AuthError();
	}
	return Ice::uncheckedCast<NetFS::VolumePrx>(ice.adapter->addWithUUID(std::make_shared<Repo>(propReader)));
}