summaryrefslogtreecommitdiff
path: root/src/repoList.cpp
blob: 9fc2848d19c1cf0c05b4c27983dc2852b8eef940 (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
#include <Ice/ObjectAdapter.h>
#include <Ice/Properties.h>
#include "repoList.h"
#include "repo.h"

#include <compileTimeFormatter.h>

GitFS::RepoList::RepoList(const Ice::PropertiesPtr & p) : properties(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)));
}