private void loadDefaultContent( final String domain, final ResourceWithFallbackLoader contentXML, final DataSource dataSource) throws Exception { SAXParserFactory factory = SAXParserFactory.newInstance(); InputStream in = null; try { in = contentXML.getResource().getInputStream(); SAXParser parser = factory.newSAXParser(); parser.parse(in, new ContentLoaderHandler(dataSource, ROOT_ELEMENT, true)); LOG.debug("[{}] Default content successfully loaded", domain); } finally { IOUtils.closeQuietly(in); } }
private void createViews(final String domain, final DataSource dataSource) throws IOException { LOG.debug("[{}] Creating views", domain); JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); Properties views = PropertiesLoaderUtils.loadProperties(viewsXML.getResource()); for (String idx : views.stringPropertyNames()) { LOG.debug("[{}] Creating view {}", domain, views.get(idx).toString()); try { jdbcTemplate.execute(views.get(idx).toString().replaceAll("\\n", " ")); } catch (DataAccessException e) { LOG.error("[{}] Could not create view", domain, e); } } LOG.debug("Views created"); }
private void createIndexes(final String domain, final DataSource dataSource) throws IOException { LOG.debug("[{}] Creating indexes", domain); JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); Properties indexes = PropertiesLoaderUtils.loadProperties(indexesXML.getResource()); for (String idx : indexes.stringPropertyNames()) { LOG.debug("[{}] Creating index {}", domain, indexes.get(idx).toString()); try { jdbcTemplate.execute(indexes.get(idx).toString()); } catch (DataAccessException e) { LOG.error("[{}] Could not create index", domain, e); } } LOG.debug("Indexes created"); }