summaryrefslogtreecommitdiff
path: root/src/repoList.cpp
blob: 4eb76af7fd96b08e49e10ec5706c04c82a1c1289 (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
31
32
33
34
35
36
#include <Ice/ObjectAdapter.h>
#include <Ice/Properties.h>
#include "repoList.h"
#include "repo.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 = std::bind(&Ice::Properties::getProperty, properties,
			std::bind((std::string(*)(const std::string_view &, const std::string_view &))
				(&RepoPropertyName::get), volume, std::placeholders::_1));

	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)));
}