3 # OpenChange provisioning
4 # Copyright (C) Jelmer Vernooij <jelmer@openchange.org> 2008-2009
5 # Copyright (C) Julien Kerihuel <j.kerihuel@openchange.org> 2009
6 # Copyright (C) Brad Hards <bradh@openchange.org> 2010
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 class UnsupportedMapistoreBackend(Exception):
27 def __init__(self, backend):
28 super(UnsupportedMapistoreBackend, self).__init__("unsupported mapistore backend type: %s" % backend)
31 def openchangedb_url(lp):
32 return os.path.join(lp.get("private dir"), "openchange.ldb")
35 def openchangedb_mapistore_dir(lp):
36 return os.path.join(lp.get("private dir"), "mapistore")
39 def openchangedb_mapistore_url(lp, backend):
40 if backend in ("fsocpf", None):
41 return "fsocpf://%s" % openchangedb_mapistore_dir(lp)
42 elif backend == "sqlite":
43 return "sqlite://%s" % openchangedb_mapistore_dir(lp)
44 raise UnsupportedMapistoreBackend(backend)
47 def openchangedb_mapistore_url_split(url):
48 if url.startswith("fsocpf://"):
49 return url.partition("fsocpf://")[1:]
50 if url.startswith("sqlite://"):
51 return url.partition("sqlite://")[1:]
54 def openchangedb_suffix_for_mapistore_url(url):
55 if (url.startswith("fsocpf://")):
57 if (url.startswith("sqlite://")):