private Sail createSail(SailImplConfig config) throws RepositoryConfigException, SailConfigException { SailFactory sailFactory = SailRegistry.getInstance().get(config.getType()).orElseThrow( () -> new RepositoryConfigException("Unsupported Sail type: " + config.getType())); return sailFactory.getSail(config); }
public static SailImplConfig parseRepositoryImpl(Model m, Resource implNode) throws SailConfigException { try { Optional<Literal> typeLit = Models.objectLiteral( m.filter(implNode, SailConfigSchema.SAILTYPE, null)); if (typeLit.isPresent()) { Optional<SailFactory> factory = SailRegistry.getInstance().get(typeLit.get().getLabel()); if (factory.isPresent()) { SailImplConfig implConfig = factory.get().getConfig(); implConfig.parse(m, implNode); return implConfig; } else { throw new SailConfigException("Unsupported Sail type: " + typeLit.get().getLabel()); } } return null; } catch (ModelException e) { throw new SailConfigException(e.getMessage(), e); } } }
public static SailImplConfig parseRepositoryImpl(Model m, Resource implNode) throws SailConfigException { try { Optional<Literal> typeLit = Models.objectLiteral( m.filter(implNode, SailConfigSchema.SAILTYPE, null)); if (typeLit.isPresent()) { Optional<SailFactory> factory = SailRegistry.getInstance().get(typeLit.get().getLabel()); if (factory.isPresent()) { SailImplConfig implConfig = factory.get().getConfig(); implConfig.parse(m, implNode); return implConfig; } else { throw new SailConfigException("Unsupported Sail type: " + typeLit.get().getLabel()); } } return null; } catch (ModelException e) { throw new SailConfigException(e.getMessage(), e); } } }
@Override public void parse(Model model, Resource repImplNode) throws RepositoryConfigException { try { Optional<Resource> sailImplNode = Models.objectResource( model.filter(repImplNode, SAILIMPL, null)); if (sailImplNode.isPresent()) { Models.objectLiteral(model.filter(sailImplNode.get(), SAILTYPE, null)).ifPresent(typeLit -> { SailFactory factory = SailRegistry.getInstance().get(typeLit.getLabel()).orElseThrow( () -> new RepositoryConfigException( "Unsupported Sail type: " + typeLit.getLabel())); sailImplConfig = factory.getConfig(); sailImplConfig.parse(model, sailImplNode.get()); }); } } catch (ModelException e) { throw new RepositoryConfigException(e.getMessage(), e); } catch (SailConfigException e) { throw new RepositoryConfigException(e.getMessage(), e); } } }