public Repository createRepository(HttpServletRequest request, String repoType, String slug) throws Exception {
ExtendedProperties properties = getProperties();
String dbDir = properties.getString("backstage.databaseDir","databases");
SailRepository repository = null;
File thisDbDir = new File(new File(dbDir,repoType),slug);
if (repoType.equals(REPOTYPE_MEM)) {
DataLoadingUtilities.RepoSailTuple rs = DataLoadingUtilities.createMemoryRepository(thisDbDir);
repository = (SailRepository)rs.repository;
rs = null;
} else if (repoType.equals(REPOTYPE_DISK)) {
DataLoadingUtilities.RepoSailTuple rs = DataLoadingUtilities.createNativeRepository(thisDbDir);
repository = (SailRepository)rs.repository;
rs = null;
} else {
return null;
}
String lang = DataLoadingUtilities.contentTypeToLang(request.getContentType());
if (lang == null) {
throw new Exception("Unsupported content type");
}
DataLoadingUtilities.loadDataFromStream( (InputStream)request.getInputStream(),
request.getRequestURL().toString(),
lang, repository.getSail() );
return repository;
}