Search in sources :

Example 1 with ArchiveLoader

use of org.pentaho.platform.plugin.services.importer.ArchiveLoader in project pentaho-platform by pentaho.

the class DefaultContentSystemListener method startup.

@Override
public boolean startup(IPentahoSession arg0) {
    // By default we'll run in a separate thread. This checks to see if someone has disabled this.
    ISystemConfig systemSettings = PentahoSystem.get(ISystemConfig.class);
    Boolean enableAsyncLoading = true;
    if (systemSettings != null) {
        String disableLoadAsyncStr = systemSettings.getProperty("system.enable-async-default-content-loading");
        enableAsyncLoading = Boolean.valueOf(disableLoadAsyncStr);
    }
    Runnable runnable = new Runnable() {

        @Override
        public void run() {
            try {
                SecurityHelper.getInstance().runAsSystem(new Callable<Void>() {

                    @Override
                    public Void call() throws Exception {
                        Logger.info(this.getClass().getName(), "Default content importer has started");
                        // get a File reference to the directory
                        String solutionPath = PentahoSystem.getApplicationContext().getSolutionPath(DEFAULT_CONTENT_FOLDER);
                        File directory = new File(solutionPath);
                        // Instantiate the importer
                        IPlatformImporter importer = PentahoSystem.get(IPlatformImporter.class);
                        ArchiveLoader archiveLoader = new ArchiveLoader(importer);
                        archiveLoader.loadAll(directory, ArchiveLoader.ZIPS_FILTER);
                        return null;
                    }
                });
            } catch (Exception e) {
                Logger.error(this.getClass().getName(), e.getMessage());
            }
        }
    };
    if (enableAsyncLoading) {
        Thread t = new Thread(runnable);
        t.setDaemon(true);
        t.setName("Default Content Loader Thread");
        t.start();
    } else {
        runnable.run();
    }
    return true;
}
Also used : ArchiveLoader(org.pentaho.platform.plugin.services.importer.ArchiveLoader) ISystemConfig(org.pentaho.platform.api.engine.ISystemConfig) IPlatformImporter(org.pentaho.platform.plugin.services.importer.IPlatformImporter) File(java.io.File)

Aggregations

File (java.io.File)1 ISystemConfig (org.pentaho.platform.api.engine.ISystemConfig)1 ArchiveLoader (org.pentaho.platform.plugin.services.importer.ArchiveLoader)1 IPlatformImporter (org.pentaho.platform.plugin.services.importer.IPlatformImporter)1