01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.sail.config;
07:
08: import org.openrdf.model.Graph;
09: import org.openrdf.model.Literal;
10: import org.openrdf.model.Resource;
11: import org.openrdf.model.util.GraphUtil;
12: import org.openrdf.model.util.GraphUtilException;
13:
14: public class SailConfigUtil {
15:
16: public static SailImplConfig parseRepositoryImpl(Graph graph,
17: Resource implNode) throws SailConfigException {
18: try {
19: Literal typeLit = GraphUtil.getOptionalObjectLiteral(graph,
20: implNode, SailConfigSchema.SAILTYPE);
21:
22: if (typeLit != null) {
23: SailFactory factory = SailRegistry.getInstance().get(
24: typeLit.getLabel());
25:
26: if (factory != null) {
27: SailImplConfig implConfig = factory.getConfig();
28: implConfig.parse(graph, implNode);
29: return implConfig;
30: } else {
31: throw new SailConfigException(
32: "Unsupported Sail type: "
33: + typeLit.getLabel());
34: }
35: }
36:
37: return null;
38: } catch (GraphUtilException e) {
39: throw new SailConfigException(e.getMessage(), e);
40: }
41: }
42: }
|