Search in sources :

Example 1 with ToscaDocumentBuilderFactory

use of org.eclipse.winery.common.ToscaDocumentBuilderFactory in project winery by eclipse.

the class Prefs method contextInitialized.

/**
 * When the servlet is initialized, this method is called.
 */
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
    ServletContext context = servletContextEvent.getServletContext();
    Objects.requireNonNull(context);
    try {
        this.doRepositoryInitialization();
    } catch (Exception e) {
        LOGGER.error("Could not initialize", e);
    }
    if (Environments.getInstance().getRepositoryConfig().getProvider() != RepositoryConfigurationObject.RepositoryProvider.YAML) {
        // Initialize XSD validation in the background. Takes up a few seconds.
        // If we do not do it here, the first save by a user takes a few seconds, which is inconvenient
        LOGGER.debug("Initializing XML validation");
        @SuppressWarnings("unused") ToscaDocumentBuilderFactory builderFactory = ToscaDocumentBuilderFactory.INSTANCE;
        LOGGER.debug("Initialized XML validation");
    }
}
Also used : ToscaDocumentBuilderFactory(org.eclipse.winery.common.ToscaDocumentBuilderFactory) ServletContext(javax.servlet.ServletContext)

Example 2 with ToscaDocumentBuilderFactory

use of org.eclipse.winery.common.ToscaDocumentBuilderFactory in project winery by eclipse.

the class Prefs method doInitialization.

/**
 * Initializes Winery using the given context
 */
private void doInitialization(ServletContext ctx) {
    Objects.requireNonNull(ctx);
    Environment.getUrlConfiguration().setRepositoryApiUrl(ctx.getContextPath());
    // first set default URLs
    // they will be overwritten with the configuration later
    initializeUrlConfigurationWithDefaultValues(ctx);
    // overwrite configuration with local configuration in all cases
    // if winery.property exists in the root of the default repository path (~/winery-repository), load it
    File propFile = new File(FilebasedRepository.getDefaultRepositoryFilePath(), "winery.properties");
    Prefs.LOGGER.info("Trying " + propFile.getAbsolutePath());
    if (propFile.exists()) {
        Prefs.LOGGER.info("Found");
        try {
            Environment.copyConfiguration(propFile.toPath());
        } catch (Exception e) {
            Prefs.LOGGER.error("Could not load repository-local winery.properties", e);
        }
    } else {
        Prefs.LOGGER.info("Not found");
    }
    try {
        this.doRepositoryInitialization();
    } catch (Exception e) {
        LOGGER.error("Could not initialize", e);
    }
    // Initialize XSD validation in the background. Takes up a few seconds.
    // If we do not do it here, the first save by a user takes a few seconds, which is inconvenient
    Prefs.LOGGER.debug("Initializing XML validation");
    @SuppressWarnings("unused") ToscaDocumentBuilderFactory tdbf = ToscaDocumentBuilderFactory.INSTANCE;
    Prefs.LOGGER.debug("Initialized XML validation");
}
Also used : ToscaDocumentBuilderFactory(org.eclipse.winery.common.ToscaDocumentBuilderFactory) File(java.io.File)

Aggregations

ToscaDocumentBuilderFactory (org.eclipse.winery.common.ToscaDocumentBuilderFactory)2 File (java.io.File)1 ServletContext (javax.servlet.ServletContext)1