private <T> void loadGraph(String graphName, Module<T> module) throws InvalidContentsException { RepositoryConnection connection=getConnection(); try { URI newCtx=null; if(graphName!=null) { newCtx=nextContext(connection,graphName,module.getBase()); } SesameUtils.loadModule(connection,module,newCtx); if(graphName!=null) { URI previousCtx=loadedGraphs.put(graphName, newCtx); if(previousCtx!=null) { connection.clear(previousCtx); } } } catch (ContentProcessingException e) { throw new InvalidContentsException("The contents provided could not be loaded",e,graphName,module); } catch (RepositoryException e) { throw new QueryTemplateSupportFailure(e); } catch (SesameUtilsException e) { throw new QueryTemplateSupportFailure(e); } finally { close(connection); } }