Search in sources :

Example 1 with PluginBundleVersion

use of org.bimserver.models.store.PluginBundleVersion in project BIMserver by opensourceBIM.

the class BimServer method start.

public void start() throws DatabaseInitException, BimserverDatabaseException, PluginException, DatabaseRestartRequiredException, ServerException {
    try {
        if (versionChecker != null) {
            SVersion localVersion = versionChecker.getLocalVersion();
            if (localVersion != null) {
                LOGGER.info("Version: " + localVersion.getFullString());
            } else {
                LOGGER.info("Unknown version");
            }
        } else {
            LOGGER.info("Unknown version");
        }
        if (config.getHomeDir() != null) {
            LOGGER.info("Using \"" + config.getHomeDir().toString() + "\" as homedir");
        } else {
            LOGGER.info("Not using a homedir");
        }
        try {
            pluginManager.setPluginChangeListener(new PluginChangeListener() {

                @Override
                public void pluginStateChanged(PluginContext pluginContext, boolean enabled) {
                    // Reflect this change also in the database
                    Condition pluginCondition = new AttributeCondition(StorePackage.eINSTANCE.getPluginDescriptor_PluginClassName(), new StringLiteral(pluginContext.getPlugin().getClass().getName()));
                    DatabaseSession session = bimDatabase.createSession(OperationType.POSSIBLY_WRITE);
                    try {
                        Map<Long, PluginDescriptor> pluginsFound = session.query(pluginCondition, PluginDescriptor.class, OldQuery.getDefault());
                        if (pluginsFound.size() == 0) {
                            LOGGER.error("Error changing plugin-state in database, plugin " + pluginContext.getPlugin().getClass().getName() + " not found");
                        } else if (pluginsFound.size() == 1) {
                            PluginDescriptor pluginConfiguration = pluginsFound.values().iterator().next();
                            pluginConfiguration.setEnabled(pluginContext.isEnabled());
                            session.store(pluginConfiguration);
                        } else {
                            LOGGER.error("Error, too many plugin-objects found in database for name " + pluginContext.getPlugin().getClass().getName());
                        }
                        session.commit();
                    } catch (BimserverDatabaseException e) {
                        LOGGER.error("", e);
                    } catch (ServiceException e) {
                        LOGGER.error("", e);
                    } finally {
                        session.close();
                    }
                }

                @Override
                public long pluginBundleUpdated(PluginBundle pluginBundle) {
                    SPluginBundleVersion sPluginBundleVersion = pluginBundle.getPluginBundleVersion();
                    try (DatabaseSession session = bimDatabase.createSession(OperationType.POSSIBLY_WRITE)) {
                        PluginBundleVersion current = null;
                        IfcModelInterface allOfType = session.getAllOfType(StorePackage.eINSTANCE.getPluginBundleVersion(), OldQuery.getDefault());
                        for (PluginBundleVersion pbv : allOfType.getAll(PluginBundleVersion.class)) {
                            if (pbv.getGroupId().equals(pluginBundle.getPluginBundleVersion().getGroupId()) && pbv.getArtifactId().equals(pluginBundle.getPluginBundleVersion().getArtifactId())) {
                                // Current pluginBundle found
                                current = pbv;
                            }
                        }
                        if (current != null) {
                            current.setDescription(sPluginBundleVersion.getArtifactId());
                            current.setIcon(sPluginBundleVersion.getIcon());
                            current.setMismatch(sPluginBundleVersion.isMismatch());
                            current.setRepository(sPluginBundleVersion.getRepository());
                            current.setType(getSConverter().convertFromSObject(sPluginBundleVersion.getType()));
                            current.setVersion(sPluginBundleVersion.getVersion());
                            current.setOrganization(sPluginBundleVersion.getOrganization());
                            current.setName(sPluginBundleVersion.getName());
                            current.setDate(sPluginBundleVersion.getDate());
                            session.store(current);
                            session.commit();
                        }
                        return current.getOid();
                    } catch (BimserverDatabaseException e) {
                        LOGGER.error("", e);
                    } catch (ServiceException e) {
                        LOGGER.error("", e);
                    }
                    return -1;
                }

                @Override
                public void pluginUpdated(long pluginBundleVersionId, PluginContext newPluginContext, SPluginInformation sPluginInformation) throws BimserverDatabaseException {
                    try (DatabaseSession session = bimDatabase.createSession(OperationType.POSSIBLY_WRITE)) {
                        Plugin plugin = newPluginContext.getPlugin();
                        Condition pluginCondition = new AttributeCondition(StorePackage.eINSTANCE.getPluginDescriptor_Identifier(), new StringLiteral(newPluginContext.getIdentifier()));
                        Map<Long, PluginDescriptor> pluginsFound = session.query(pluginCondition, PluginDescriptor.class, OldQuery.getDefault());
                        for (PluginDescriptor pluginDescriptor : pluginsFound.values()) {
                            pluginDescriptor.setIdentifier(newPluginContext.getIdentifier());
                            pluginDescriptor.setPluginClassName(plugin.getClass().getName());
                            pluginDescriptor.setDescription(newPluginContext.getDescription());
                            pluginDescriptor.setName(sPluginInformation.getName());
                            pluginDescriptor.setLocation(newPluginContext.getLocation().toString());
                            pluginDescriptor.setPluginInterfaceClassName(getPluginInterface(plugin.getClass()).getName());
                            pluginDescriptor.setEnabled(sPluginInformation.isEnabled());
                            pluginDescriptor.setInstallForNewUsers(sPluginInformation.isInstallForNewUsers());
                            PluginBundleVersion value = session.get(pluginBundleVersionId, OldQuery.getDefault());
                            pluginDescriptor.setPluginBundleVersion(value);
                            session.store(pluginDescriptor);
                            if (sPluginInformation.isInstallForAllUsers()) {
                                IfcModelInterface allOfType = session.getAllOfType(StorePackage.eINSTANCE.getUser(), OldQuery.getDefault());
                                for (User user : allOfType.getAll(User.class)) {
                                    if (user.getState() == ObjectState.ACTIVE) {
                                        updateUserPlugin(session, user, pluginDescriptor, newPluginContext);
                                    }
                                }
                            }
                            if (newPluginContext.getPlugin() instanceof WebModulePlugin) {
                                ServerSettings serverSettings = getServerSettingsCache().getServerSettings();
                                WebModulePluginConfiguration webPluginConfiguration = find(serverSettings.getWebModules(), newPluginContext.getIdentifier());
                                if (webPluginConfiguration == null) {
                                    webPluginConfiguration = session.create(WebModulePluginConfiguration.class);
                                    serverSettings.getWebModules().add(webPluginConfiguration);
                                }
                                genericPluginConversion(newPluginContext, session, webPluginConfiguration, pluginDescriptor);
                                String contextPath = "";
                                for (Parameter parameter : webPluginConfiguration.getSettings().getParameters()) {
                                    if (parameter.getName().equals("contextPath")) {
                                        contextPath = ((StringType) parameter.getValue()).getValue();
                                    }
                                }
                                String identifier = webPluginConfiguration.getPluginDescriptor().getIdentifier();
                                webModules.put(contextPath, (WebModulePlugin) pluginManager.getPlugin(identifier, true));
                            } else if (newPluginContext.getPlugin() instanceof ServicePlugin) {
                                IfcModelInterface allOfType = session.getAllOfType(StorePackage.eINSTANCE.getInternalServicePluginConfiguration(), OldQuery.getDefault());
                                List<InternalServicePluginConfiguration> all = new ArrayList<>(allOfType.getAll(InternalServicePluginConfiguration.class));
                                for (InternalServicePluginConfiguration internalServicePluginConfiguration : all) {
                                    if (internalServicePluginConfiguration.getPluginDescriptor().getIdentifier().equals(newPluginContext.getIdentifier())) {
                                        activateService(internalServicePluginConfiguration.getUserSettings().getOid(), internalServicePluginConfiguration);
                                    }
                                }
                            }
                        }
                        try {
                            session.commit();
                        } catch (ServiceException e) {
                            LOGGER.error("", e);
                        }
                    }
                }

                @Override
                public void pluginInstalled(long pluginBundleVersionId, PluginContext pluginContext, SPluginInformation sPluginInformation) throws BimserverDatabaseException {
                    try (DatabaseSession session = bimDatabase.createSession(OperationType.POSSIBLY_WRITE)) {
                        ServerSettings serverSettings = getServerSettingsCache().getServerSettings();
                        Plugin plugin = pluginContext.getPlugin();
                        Condition pluginCondition = new AttributeCondition(StorePackage.eINSTANCE.getPluginDescriptor_Identifier(), new StringLiteral(pluginContext.getIdentifier()));
                        Map<Long, PluginDescriptor> pluginsFound = session.query(pluginCondition, PluginDescriptor.class, OldQuery.getDefault());
                        PluginDescriptor pluginDescriptor = null;
                        ObjectType settings = null;
                        if (pluginsFound.size() > 0) {
                            pluginDescriptor = pluginsFound.values().iterator().next();
                            settings = pluginDescriptor.getSettings();
                        } else {
                            pluginDescriptor = session.create(PluginDescriptor.class);
                            settings = convertSettings(session, pluginContext.getPlugin().getSystemSettingsDefinition());
                            pluginDescriptor.setSettings(settings);
                        }
                        pluginDescriptor.setIdentifier(pluginContext.getIdentifier());
                        pluginDescriptor.setPluginClassName(plugin.getClass().getName());
                        pluginDescriptor.setDescription(pluginContext.getDescription());
                        pluginDescriptor.setName(sPluginInformation.getName());
                        pluginDescriptor.setLocation(pluginContext.getLocation().toString());
                        pluginDescriptor.setPluginInterfaceClassName(getPluginInterface(plugin.getClass()).getName());
                        pluginDescriptor.setEnabled(sPluginInformation.isEnabled());
                        pluginDescriptor.setInstallForNewUsers(sPluginInformation.isInstallForNewUsers());
                        pluginDescriptor.setPluginBundleVersion(session.get(pluginBundleVersionId, OldQuery.getDefault()));
                        try {
                            pluginContext.initialize(new org.bimserver.plugins.PluginConfiguration(settings));
                        } catch (PluginException e) {
                            LOGGER.error("", e);
                        }
                        if (pluginDescriptor.getPluginClassName().contentEquals("org.ifcopenshell.IfcOpenShellEnginePlugin")) {
                            if (serverSettings.getDefaultRenderEnginePlugin() == null) {
                                serverSettings.setDefaultRenderEnginePlugin(pluginDescriptor);
                                session.store(serverSettings);
                            }
                        }
                        if (sPluginInformation.isInstallForAllUsers()) {
                            IfcModelInterface allOfType = session.getAllOfType(StorePackage.eINSTANCE.getUser(), OldQuery.getDefault());
                            for (User user : allOfType.getAll(User.class)) {
                                if (user.getState() == ObjectState.ACTIVE) {
                                    updateUserPlugin(session, user, pluginDescriptor, pluginContext);
                                }
                            }
                        }
                        if (pluginContext.getPlugin() instanceof WebModulePlugin) {
                            WebModulePluginConfiguration webPluginConfiguration = find(serverSettings.getWebModules(), pluginContext.getIdentifier());
                            if (webPluginConfiguration == null) {
                                webPluginConfiguration = session.create(WebModulePluginConfiguration.class);
                                serverSettings.getWebModules().add(webPluginConfiguration);
                                genericPluginConversion(pluginContext, session, webPluginConfiguration, pluginDescriptor);
                                session.store(serverSettings);
                            }
                            String contextPath = "";
                            for (Parameter parameter : webPluginConfiguration.getSettings().getParameters()) {
                                if (parameter.getName().equals("contextPath")) {
                                    contextPath = ((StringType) parameter.getValue()).getValue();
                                }
                            }
                            webModules.put(contextPath, (WebModulePlugin) pluginManager.getPlugin(pluginContext.getIdentifier(), true));
                        }
                        try {
                            session.commit();
                        } catch (ServiceException e) {
                            LOGGER.error("", e);
                        }
                    }
                }

                @Override
                public void pluginUninstalled(PluginContext pluginContext) {
                    // Reflect this change also in the database
                    Condition pluginCondition = new AttributeCondition(StorePackage.eINSTANCE.getPluginDescriptor_Identifier(), new StringLiteral(pluginContext.getIdentifier()));
                    DatabaseSession session = bimDatabase.createSession(OperationType.POSSIBLY_WRITE);
                    try {
                        Map<Long, PluginDescriptor> pluginsFound = session.query(pluginCondition, PluginDescriptor.class, OldQuery.getDefault());
                        if (pluginsFound.size() == 0) {
                            LOGGER.error("Error removing plugin-state in database, plugin " + pluginContext.getPlugin().getClass().getName() + " not found");
                        } else if (pluginsFound.size() == 1) {
                            PluginDescriptor pluginDescriptor = pluginsFound.values().iterator().next();
                            for (PluginConfiguration pluginConfiguration : pluginDescriptor.getConfigurations()) {
                                session.delete(pluginConfiguration, -1);
                            }
                            if (pluginContext.getPlugin() instanceof WebModulePlugin) {
                                ServerSettings serverSettings = getServerSettingsCache().getServerSettings();
                                WebModulePluginConfiguration webPluginConfiguration = find(serverSettings.getWebModules(), pluginContext.getIdentifier());
                                serverSettings.getWebModules().remove(webPluginConfiguration);
                                session.store(serverSettings);
                                String contextPath = "";
                                for (Parameter parameter : webPluginConfiguration.getSettings().getParameters()) {
                                    if (parameter.getName().equals("contextPath")) {
                                        contextPath = ((StringType) parameter.getValue()).getValue();
                                    }
                                }
                                webModules.remove(contextPath);
                            }
                            session.delete(pluginDescriptor, -1);
                        } else {
                            LOGGER.error("Error, too many plugin-objects found in database for name " + pluginContext.getPlugin().getClass().getName());
                        }
                        session.commit();
                    } catch (BimserverDatabaseException e) {
                        LOGGER.error("", e);
                    } catch (ServiceException e) {
                        LOGGER.error("", e);
                    } finally {
                        session.close();
                    }
                }

                @Override
                public long pluginBundleInstalled(PluginBundle pluginBundle) {
                    try (DatabaseSession session = bimDatabase.createSession(OperationType.POSSIBLY_WRITE)) {
                        PluginBundleVersion current = null;
                        IfcModelInterface allOfType = session.getAllOfType(StorePackage.eINSTANCE.getPluginBundleVersion(), OldQuery.getDefault());
                        for (PluginBundleVersion pbv : allOfType.getAll(PluginBundleVersion.class)) {
                            if (pbv.getGroupId().equals(pluginBundle.getPluginBundleVersion().getGroupId()) && pbv.getArtifactId().equals(pluginBundle.getPluginBundleVersion().getArtifactId())) {
                                // Current pluginBundle found
                                current = pbv;
                            }
                        }
                        PluginBundleVersion pluginBundleVersion = null;
                        if (current != null) {
                            pluginBundleVersion = current;
                            session.store(pluginBundleVersion);
                        } else {
                            pluginBundleVersion = session.create(PluginBundleVersion.class);
                        }
                        SPluginBundleVersion sPluginBundleVersion = pluginBundle.getPluginBundleVersion();
                        // SConverter should be used here, but it does not seem to trigger the database session in the rights way, just copying over field for now
                        pluginBundleVersion.setArtifactId(sPluginBundleVersion.getArtifactId());
                        pluginBundleVersion.setDescription(sPluginBundleVersion.getArtifactId());
                        pluginBundleVersion.setGroupId(sPluginBundleVersion.getGroupId());
                        pluginBundleVersion.setIcon(sPluginBundleVersion.getIcon());
                        pluginBundleVersion.setMismatch(sPluginBundleVersion.isMismatch());
                        pluginBundleVersion.setRepository(sPluginBundleVersion.getRepository());
                        pluginBundleVersion.setType(getSConverter().convertFromSObject(sPluginBundleVersion.getType()));
                        pluginBundleVersion.setVersion(sPluginBundleVersion.getVersion());
                        pluginBundleVersion.setOrganization(sPluginBundleVersion.getOrganization());
                        pluginBundleVersion.setName(sPluginBundleVersion.getName());
                        pluginBundleVersion.setDate(sPluginBundleVersion.getDate());
                        session.commit();
                        return pluginBundleVersion.getOid();
                    } catch (BimserverDatabaseException e) {
                        LOGGER.error("", e);
                    } catch (ServiceException e) {
                        LOGGER.error("", e);
                    }
                    return -1;
                }

                @Override
                public void pluginBundleUninstalled(PluginBundle pluginBundle) {
                }
            });
        } catch (Exception e) {
            LOGGER.error("", e);
        }
        try {
            metaDataManager.init(true);
            pluginManager.initAllLoadedPlugins();
        } catch (PluginException e) {
            LOGGER.error("", e);
        }
        serverStartTime = new GregorianCalendar();
        longActionManager = new LongActionManager(this);
        Set<EPackage> packages = new LinkedHashSet<>();
        packages.add(Ifc2x3tc1Package.eINSTANCE);
        packages.add(Ifc4Package.eINSTANCE);
        templateEngine = new TemplateEngine();
        ResourceFetcher resourceFetcher = config.getResourceFetcher();
        if (resourceFetcher.isDirectory("emailtemplates")) {
            templateEngine.init(resourceFetcher.getURL("emailtemplates"));
        } else {
            LOGGER.info("No email templates found");
        }
        Path databaseDir = config.getHomeDir().resolve("database");
        BerkeleyKeyValueStore keyValueStore = new BerkeleyKeyValueStore(databaseDir, config.getBdbEnvironmentProperties());
        geometryAccellerator = new GeometryAccellerator(this);
        schemaConverterManager.registerConverter(new Ifc2x3tc1ToIfc4SchemaConverterFactory());
        schemaConverterManager.registerConverter(new Ifc4ToIfc2x3tc1SchemaConverterFactory());
        authCache = new AuthCache(this);
        pluginSettingsCache = new PluginSettingsCache(this);
        metricsRegistry = new MetricsRegistry();
        Path mavenPath = config.getHomeDir().resolve("maven");
        if (!Files.exists(mavenPath)) {
            Files.createDirectories(mavenPath);
        }
        OldQuery.setPackageMetaDataForDefaultQuery(metaDataManager.getPackageMetaData("store"));
        bimDatabase = new Database(this, packages, keyValueStore, metaDataManager);
        try {
            bimDatabase.init();
        } catch (DatabaseRestartRequiredException e) {
            bimDatabase.close();
            keyValueStore = new BerkeleyKeyValueStore(databaseDir, config.getBdbEnvironmentProperties());
            bimDatabase = new Database(this, packages, keyValueStore, metaDataManager);
            try {
                bimDatabase.init();
            } catch (InconsistentModelsException e1) {
                LOGGER.error("", e);
                serverInfoManager.setServerState(ServerState.FATAL_ERROR);
                serverInfoManager.setErrorMessage("Inconsistent models");
            }
        } catch (InconsistentModelsException e) {
            LOGGER.error("", e);
            serverInfoManager.setServerState(ServerState.FATAL_ERROR);
            serverInfoManager.setErrorMessage("Inconsistent models");
        }
        try (DatabaseSession encsession = bimDatabase.createSession(OperationType.POSSIBLY_WRITE)) {
            byte[] encryptionkeyBytes = null;
            if (!bimDatabase.getRegistry().has(ENCRYPTIONKEY, encsession)) {
                encryptionkeyBytes = new byte[16];
                new SecureRandom().nextBytes(encryptionkeyBytes);
                bimDatabase.getRegistry().save(ENCRYPTIONKEY, encryptionkeyBytes, encsession);
                encsession.commit();
            } else {
                encryptionkeyBytes = bimDatabase.getRegistry().readByteArray(ENCRYPTIONKEY, encsession);
            }
            encryptionkey = new SecretKeySpec(encryptionkeyBytes, "AES");
        }
        cleanupStaleData();
        serverInfoManager.init(this);
        webModuleManager = new WebModuleManager(this);
        jsonHandler = new JsonHandler(this);
        serializerFactory = new SerializerFactory();
        serverSettingsCache = new ServerSettingsCache(bimDatabase);
        for (String schema : new String[] { "ifc2x3tc1", "ifc4" }) {
            for (String type : new String[] { "geometry", "stdlib" }) {
                try {
                    PackageMetaData packageMetaData = getMetaDataManager().getPackageMetaData(schema);
                    JsonQueryObjectModelConverter jsonQueryObjectModelConverter = new JsonQueryObjectModelConverter(packageMetaData);
                    String queryNameSpace = schema + "-" + type;
                    if (type.contentEquals("stdlib")) {
                        Include objectPlacement = jsonQueryObjectModelConverter.getDefineFromFile(queryNameSpace + ":ObjectPlacement", true);
                        // The sole reason is to make sure this is done once, and then cached
                        objectPlacement.makeDirectRecursive(new HashSet<>());
                    }
                } catch (QueryException e) {
                    LOGGER.error(schema + " " + type, e);
                }
            }
        }
        serverInfoManager.update();
        if (serverInfoManager.getServerState() == ServerState.MIGRATION_REQUIRED) {
            serverInfoManager.registerStateChangeListener(new StateChangeListener() {

                @Override
                public void stateChanged(ServerState oldState, ServerState newState) {
                    if (oldState == ServerState.MIGRATION_REQUIRED && newState == ServerState.RUNNING) {
                        try {
                            initDatabaseDependantItems();
                        } catch (BimserverDatabaseException e) {
                            LOGGER.error("", e);
                        }
                    }
                }
            });
        } else {
            initDatabaseDependantItems();
        }
        mailSystem = new MailSystem(this);
        diskCacheManager = new DiskCacheManager(this, config.getHomeDir().resolve("cache"));
        newDiskCacheManager = new NewDiskCacheManager(this, config.getHomeDir().resolve("cache"));
        mergerFactory = new MergerFactory(this);
        RealtimeReflectorFactoryBuilder factoryBuilder = new RealtimeReflectorFactoryBuilder(servicesMap);
        reflectorFactory = factoryBuilder.newReflectorFactory();
        if (reflectorFactory == null) {
            throw new RuntimeException("No reflector factory!");
        }
        servicesMap.setReflectorFactory(reflectorFactory);
        bimScheduler = new JobScheduler(this);
        bimScheduler.start();
        if (config.isStartEmbeddedWebServer()) {
            embeddedWebServer.start();
        }
        if (config.isStartCommandLine()) {
            commandLine = new CommandLine(this);
            commandLine.start();
        }
        if (getServerInfoManager().getServerState() == ServerState.SETUP) {
            getServerInfoManager().setServerState(ServerState.RUNNING);
        }
    } catch (Throwable e) {
        LOGGER.error("", e);
        serverInfoManager.setErrorMessage(e.getMessage());
    }
}
Also used : SPluginBundleVersion(org.bimserver.interfaces.objects.SPluginBundleVersion) LinkedHashSet(java.util.LinkedHashSet) GeometryAccellerator(org.bimserver.geometry.accellerator.GeometryAccellerator) DatabaseSession(org.bimserver.database.DatabaseSession) StringType(org.bimserver.models.store.StringType) IfcModelInterface(org.bimserver.emf.IfcModelInterface) ArrayList(java.util.ArrayList) Include(org.bimserver.database.queries.om.Include) LongActionManager(org.bimserver.longaction.LongActionManager) EPackage(org.eclipse.emf.ecore.EPackage) PluginBundle(org.bimserver.plugins.PluginBundle) TemplateEngine(org.bimserver.templating.TemplateEngine) Ifc4ToIfc2x3tc1SchemaConverterFactory(org.bimserver.schemaconverter.Ifc4ToIfc2x3tc1SchemaConverterFactory) SecretKeySpec(javax.crypto.spec.SecretKeySpec) Database(org.bimserver.database.Database) BimDatabase(org.bimserver.database.BimDatabase) Ifc2x3tc1ToIfc4SchemaConverterFactory(org.bimserver.schemaconverter.Ifc2x3tc1ToIfc4SchemaConverterFactory) PluginChangeListener(org.bimserver.plugins.PluginChangeListener) PackageMetaData(org.bimserver.emf.PackageMetaData) SPluginInformation(org.bimserver.interfaces.objects.SPluginInformation) WebModulePluginConfiguration(org.bimserver.models.store.WebModulePluginConfiguration) PluginException(org.bimserver.shared.exceptions.PluginException) AttributeCondition(org.bimserver.database.query.conditions.AttributeCondition) GregorianCalendar(java.util.GregorianCalendar) SecureRandom(java.security.SecureRandom) SVersion(org.bimserver.interfaces.objects.SVersion) PluginDescriptor(org.bimserver.models.store.PluginDescriptor) StringLiteral(org.bimserver.database.query.literals.StringLiteral) ServiceException(org.bimserver.shared.exceptions.ServiceException) DatabaseRestartRequiredException(org.bimserver.database.DatabaseRestartRequiredException) Map(java.util.Map) HashMap(java.util.HashMap) SServicesMap(org.bimserver.shared.meta.SServicesMap) InconsistentModelsException(org.bimserver.database.migrations.InconsistentModelsException) ServicePlugin(org.bimserver.plugins.services.ServicePlugin) User(org.bimserver.models.store.User) JsonQueryObjectModelConverter(org.bimserver.database.queries.om.JsonQueryObjectModelConverter) ResourceFetcher(org.bimserver.plugins.ResourceFetcher) ObjectType(org.bimserver.models.store.ObjectType) ServerSettings(org.bimserver.models.store.ServerSettings) PluginConfiguration(org.bimserver.models.store.PluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) WebModulePluginConfiguration(org.bimserver.models.store.WebModulePluginConfiguration) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) SInternalServicePluginConfiguration(org.bimserver.interfaces.objects.SInternalServicePluginConfiguration) WebModulePlugin(org.bimserver.plugins.web.WebModulePlugin) PluginBundleVersion(org.bimserver.models.store.PluginBundleVersion) SPluginBundleVersion(org.bimserver.interfaces.objects.SPluginBundleVersion) RealtimeReflectorFactoryBuilder(org.bimserver.shared.reflector.RealtimeReflectorFactoryBuilder) Condition(org.bimserver.database.query.conditions.Condition) AttributeCondition(org.bimserver.database.query.conditions.AttributeCondition) Path(java.nio.file.Path) BerkeleyKeyValueStore(org.bimserver.database.berkeley.BerkeleyKeyValueStore) SerializerFactory(org.bimserver.serializers.SerializerFactory) PluginContext(org.bimserver.plugins.PluginContext) MailSystem(org.bimserver.mail.MailSystem) ServerState(org.bimserver.models.store.ServerState) NewDiskCacheManager(org.bimserver.cache.NewDiskCacheManager) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) PluginException(org.bimserver.shared.exceptions.PluginException) QueryException(org.bimserver.database.queries.om.QueryException) InconsistentModelsException(org.bimserver.database.migrations.InconsistentModelsException) BimserverLockConflictException(org.bimserver.database.BimserverLockConflictException) DatabaseRestartRequiredException(org.bimserver.database.DatabaseRestartRequiredException) DatabaseInitException(org.bimserver.database.berkeley.DatabaseInitException) RenderEngineException(org.bimserver.plugins.renderengine.RenderEngineException) QueryException(org.bimserver.database.queries.om.QueryException) InternalServicePluginConfiguration(org.bimserver.models.store.InternalServicePluginConfiguration) SInternalServicePluginConfiguration(org.bimserver.interfaces.objects.SInternalServicePluginConfiguration) Parameter(org.bimserver.models.store.Parameter) PluginSettingsCache(org.bimserver.pluginsettings.PluginSettingsCache) NewDiskCacheManager(org.bimserver.cache.NewDiskCacheManager) DiskCacheManager(org.bimserver.cache.DiskCacheManager) ModelCheckerPlugin(org.bimserver.plugins.modelchecker.ModelCheckerPlugin) ServicePlugin(org.bimserver.plugins.services.ServicePlugin) WebModulePlugin(org.bimserver.plugins.web.WebModulePlugin) Plugin(org.bimserver.plugins.Plugin)

Example 2 with PluginBundleVersion

use of org.bimserver.models.store.PluginBundleVersion in project BIMserver by opensourceBIM.

the class ServiceImpl method checkinInternal.

private SLongCheckinActionState checkinInternal(Long topicId, final Long poid, final String comment, Long deserializerOid, Long fileSize, String fileName, InputStream originalInputStream, Boolean merge, Boolean sync, final DatabaseSession readOnlySession, String username, String userUsername, Project project, Path file, long newServiceId) throws BimserverDatabaseException, IOException, DeserializeException, CannotBeScheduledException, ServiceException {
    DeserializerPluginConfiguration deserializerPluginConfiguration = readOnlySession.get(StorePackage.eINSTANCE.getDeserializerPluginConfiguration(), deserializerOid, OldQuery.getDefault());
    if (deserializerPluginConfiguration == null) {
        throw new UserException("Deserializer with oid " + deserializerOid + " not found");
    } else {
        PluginBundleVersion pluginBundleVersion = deserializerPluginConfiguration.getPluginDescriptor().getPluginBundleVersion();
        Plugin plugin = getBimServer().getPluginManager().getPlugin(deserializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
        if (plugin != null) {
            if (plugin instanceof DeserializerPlugin) {
                DeserializerPlugin deserializerPlugin = (DeserializerPlugin) plugin;
                Deserializer deserializer = deserializerPlugin.createDeserializer(getBimServer().getPluginSettingsCache().getPluginSettings(deserializerOid));
                OutputStream outputStream = Files.newOutputStream(file);
                InputStream inputStream = new MultiplexingInputStream(originalInputStream, outputStream);
                deserializer.init(getBimServer().getDatabase().getMetaDataManager().getPackageMetaData(project.getSchema()));
                IfcModelInterface model = null;
                try {
                    model = deserializer.read(inputStream, fileName, fileSize, null);
                } finally {
                    inputStream.close();
                }
                CheckinDatabaseAction checkinDatabaseAction = new CheckinDatabaseAction(getBimServer(), null, getInternalAccessMethod(), poid, getAuthorization(), model, comment, fileName, merge, newServiceId, topicId);
                LongCheckinAction longAction = new LongCheckinAction(topicId, getBimServer(), username, userUsername, getAuthorization(), checkinDatabaseAction);
                getBimServer().getLongActionManager().start(longAction);
                if (sync) {
                    longAction.waitForCompletion();
                    clearCheckinInProgress(poid);
                }
                ProgressTopic progressTopic = getBimServer().getNotificationsManager().getProgressTopic(topicId);
                return (SLongCheckinActionState) getBimServer().getSConverter().convertToSObject(progressTopic.getLastProgress());
            } else if (plugin instanceof StreamingDeserializerPlugin) {
                StreamingDeserializerPlugin streaminDeserializerPlugin = (StreamingDeserializerPlugin) plugin;
                StreamingDeserializer streamingDeserializer = streaminDeserializerPlugin.createDeserializer(getBimServer().getPluginSettingsCache().getPluginSettings(deserializerPluginConfiguration.getOid()));
                streamingDeserializer.init(getBimServer().getDatabase().getMetaDataManager().getPackageMetaData(project.getSchema()));
                RestartableInputStream restartableInputStream = new RestartableInputStream(originalInputStream, file);
                StreamingCheckinDatabaseAction checkinDatabaseAction = new StreamingCheckinDatabaseAction(getBimServer(), null, getInternalAccessMethod(), poid, getAuthorization(), comment, fileName, restartableInputStream, streamingDeserializer, fileSize, newServiceId, pluginBundleVersion, topicId);
                LongStreamingCheckinAction longAction = new LongStreamingCheckinAction(topicId, getBimServer(), username, userUsername, getAuthorization(), checkinDatabaseAction);
                getBimServer().getLongActionManager().start(longAction);
                ProgressTopic progressTopic = null;
                if (sync) {
                    longAction.waitForCompletion();
                    progressTopic = longAction.getProgressTopic();
                    clearCheckinInProgress(poid);
                    SLongCheckinActionState convertToSObject = (SLongCheckinActionState) getBimServer().getSConverter().convertToSObject(progressTopic.getLastProgress());
                    getBimServer().getLongActionManager().remove(progressTopic.getKey().getId());
                    return convertToSObject;
                } else {
                    return (SLongCheckinActionState) getBimServer().getSConverter().convertToSObject(longAction.getState());
                }
            } else {
                throw new UserException("No (enabled) (streaming) deserializer found with oid " + deserializerOid);
            }
        } else {
            throw new UserException("No (enabled) (streaming) deserializer found with oid " + deserializerOid);
        }
    }
}
Also used : MultiplexingInputStream(org.bimserver.utils.MultiplexingInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) MultiplexingInputStream(org.bimserver.utils.MultiplexingInputStream) InputStream(java.io.InputStream) IfcModelInterface(org.bimserver.emf.IfcModelInterface) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) StreamingDeserializerPlugin(org.bimserver.plugins.deserializers.StreamingDeserializerPlugin) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) SLongCheckinActionState(org.bimserver.interfaces.objects.SLongCheckinActionState) CheckinDatabaseAction(org.bimserver.database.actions.CheckinDatabaseAction) StreamingCheckinDatabaseAction(org.bimserver.database.actions.StreamingCheckinDatabaseAction) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) DeserializerPluginConfiguration(org.bimserver.models.store.DeserializerPluginConfiguration) StreamingDeserializer(org.bimserver.plugins.deserializers.StreamingDeserializer) ProgressTopic(org.bimserver.notifications.ProgressTopic) Deserializer(org.bimserver.plugins.deserializers.Deserializer) StreamingDeserializer(org.bimserver.plugins.deserializers.StreamingDeserializer) LongStreamingCheckinAction(org.bimserver.longaction.LongStreamingCheckinAction) StreamingDeserializerPlugin(org.bimserver.plugins.deserializers.StreamingDeserializerPlugin) LongCheckinAction(org.bimserver.longaction.LongCheckinAction) UserException(org.bimserver.shared.exceptions.UserException) PluginBundleVersion(org.bimserver.models.store.PluginBundleVersion) StreamingCheckinDatabaseAction(org.bimserver.database.actions.StreamingCheckinDatabaseAction) StreamingSerializerPlugin(org.bimserver.plugins.serializers.StreamingSerializerPlugin) QueryEnginePlugin(org.bimserver.plugins.queryengine.QueryEnginePlugin) MessagingSerializerPlugin(org.bimserver.plugins.serializers.MessagingSerializerPlugin) StreamingDeserializerPlugin(org.bimserver.plugins.deserializers.StreamingDeserializerPlugin) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) MessagingStreamingSerializerPlugin(org.bimserver.plugins.serializers.MessagingStreamingSerializerPlugin) SerializerPlugin(org.bimserver.plugins.serializers.SerializerPlugin) Plugin(org.bimserver.plugins.Plugin)

Example 3 with PluginBundleVersion

use of org.bimserver.models.store.PluginBundleVersion in project BIMserver by opensourceBIM.

the class GetInstalledPluginBundles method execute.

@Override
public List<SPluginBundle> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
    List<SPluginBundle> result = Collections.synchronizedList(new ArrayList<>());
    bimserverVersion = new DefaultArtifactVersion(bimServer.getVersionChecker().getLocalVersion().getFullString());
    GitHubPluginRepository repository = new GitHubPluginRepository(bimServer.getMavenPluginRepository(), bimServer.getServerSettingsCache().getServerSettings().getServiceRepositoryUrl());
    Map<PluginBundleIdentifier, PluginLocation<?>> repositoryKnownLocation = new HashMap<>();
    for (PluginLocation<?> pluginLocation : repository.listPluginLocations()) {
        repositoryKnownLocation.put(pluginLocation.getPluginIdentifier(), pluginLocation);
    }
    ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(4, 32, 1L, TimeUnit.HOURS, new ArrayBlockingQueue<>(100));
    for (PluginBundle currentlyInstalledPluginBundle : bimServer.getPluginBundleManager().getPluginBundles()) {
        SPluginBundleVersion installedVersion = currentlyInstalledPluginBundle.getPluginBundleVersion();
        for (PluginBundleVersion pluginBundleVersion : getDatabaseSession().getAll(PluginBundleVersion.class)) {
            if (pluginBundleVersion.getArtifactId().equals(installedVersion.getArtifactId()) && pluginBundleVersion.getGroupId().equals(installedVersion.getGroupId()) && pluginBundleVersion.getVersion().equals(installedVersion.getVersion())) {
                installedVersion.setOid(pluginBundleVersion.getOid());
            }
        }
        PluginBundleIdentifier pluginBundleIdentifier = new PluginBundleIdentifier(installedVersion.getGroupId(), installedVersion.getArtifactId());
        PluginLocation<?> pluginLocation = repositoryKnownLocation.get(pluginBundleIdentifier);
        threadPoolExecutor.submit(new Runnable() {

            @Override
            public void run() {
                SPluginBundle sPluginBundle = processPluginLocation(pluginLocation, strictVersionChecking, bimserverVersion);
                if (sPluginBundle == null) {
                    // No versions found on repository
                    sPluginBundle = currentlyInstalledPluginBundle.getPluginBundle();
                }
                boolean found = false;
                for (SPluginBundleVersion sPluginBundleVersion : sPluginBundle.getAvailableVersions()) {
                    if (sPluginBundleVersion.getVersion().equals(currentlyInstalledPluginBundle.getPluginBundleVersion().getVersion())) {
                        found = true;
                    }
                }
                if (!found) {
                    // Add the currently installed version if it's not in the list of available plugins
                    sPluginBundle.getAvailableVersions().add(currentlyInstalledPluginBundle.getPluginBundleVersion());
                }
                sPluginBundle.setInstalledVersion(installedVersion);
                Collections.sort(sPluginBundle.getAvailableVersions(), new Comparator<SPluginBundleVersion>() {

                    private List<Integer> split(String in) {
                        List<Integer> result = new ArrayList<>();
                        for (String s : in.split("\\.")) {
                            if (s.endsWith("-SNAPSHOT")) {
                                s = s.substring(0, s.length() - 9);
                            }
                            result.add(Integer.parseInt(s));
                        }
                        return result;
                    }

                    @Override
                    public int compare(SPluginBundleVersion o1, SPluginBundleVersion o2) {
                        // Ideally we would not depend on a specific versioning scheme, but alas
                        String v1 = o1.getVersion();
                        String v2 = o2.getVersion();
                        if (v1.contains(".") && v2.contains(".")) {
                            List<Integer> v1s = split(v1);
                            List<Integer> v2s = split(v2);
                            for (int i = 0; i < v1s.size(); i++) {
                                if (v1s.get(i) == v2s.get(i)) {
                                // Continue
                                } else {
                                    return v2s.get(i) - v1s.get(i);
                                }
                            }
                        } else {
                            // Fall back to string based compare
                            return v1.compareTo(v2);
                        }
                        return 0;
                    }
                });
                result.add(sPluginBundle);
            }
        });
    }
    threadPoolExecutor.shutdown();
    try {
        threadPoolExecutor.awaitTermination(1, TimeUnit.HOURS);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    Collections.sort(result, new Comparator<SPluginBundle>() {

        @Override
        public int compare(SPluginBundle o1, SPluginBundle o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
    return result;
}
Also used : SPluginBundleVersion(org.bimserver.interfaces.objects.SPluginBundleVersion) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Comparator(java.util.Comparator) PluginBundle(org.bimserver.plugins.PluginBundle) SPluginBundle(org.bimserver.interfaces.objects.SPluginBundle) PluginLocation(org.bimserver.plugins.PluginLocation) PluginBundleVersion(org.bimserver.models.store.PluginBundleVersion) SPluginBundleVersion(org.bimserver.interfaces.objects.SPluginBundleVersion) GitHubPluginRepository(org.bimserver.plugins.GitHubPluginRepository) SPluginBundle(org.bimserver.interfaces.objects.SPluginBundle) DefaultArtifactVersion(org.apache.maven.artifact.versioning.DefaultArtifactVersion) PluginBundleIdentifier(org.bimserver.plugins.PluginBundleIdentifier) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Example 4 with PluginBundleVersion

use of org.bimserver.models.store.PluginBundleVersion in project BIMserver by opensourceBIM.

the class BimServer method initDatabaseDependantItems.

private void initDatabaseDependantItems() throws BimserverDatabaseException {
    LOGGER.info("Initializing database dependant logic...");
    long start = System.nanoTime();
    notificationsManager.init();
    getSerializerFactory().init(pluginManager, bimDatabase, this);
    try {
        DatabaseSession session = bimDatabase.createSession(OperationType.POSSIBLY_WRITE);
        try {
            updatePlugins(session);
            session.commit();
        } catch (ServiceException e) {
            LOGGER.error("", e);
        } finally {
            session.close();
        }
        int renderEngineProcesses = getServerSettingsCache().getServerSettings().getRenderEngineProcesses();
        RenderEnginePoolFactory renderEnginePoolFactory = new CommonsPoolingRenderEnginePoolFactory(renderEngineProcesses);
        renderEnginePools = new RenderEnginePools(this, renderEnginePoolFactory);
        session = bimDatabase.createSession(OperationType.POSSIBLY_WRITE);
        // createDatabaseObjects(session);
        ServerSettings serverSettings = serverSettingsCache.getServerSettings();
        for (Entry<PluginContext, WebModulePlugin> entry : pluginManager.getAllWebPlugins(true).entrySet()) {
            WebModulePluginConfiguration webPluginConfiguration = find(serverSettings.getWebModules(), entry.getKey().getIdentifier());
            if (webPluginConfiguration == null) {
                webPluginConfiguration = session.create(WebModulePluginConfiguration.class);
                serverSettings.getWebModules().add(webPluginConfiguration);
                PluginDescriptor pluginDescriptor = getPluginDescriptor(session, entry.getKey().getIdentifier());
                if (pluginDescriptor == null) {
                    throw new BimserverDatabaseException("No plugin descriptor found: " + entry.getKey().getIdentifier());
                }
                genericPluginConversion(entry.getKey(), session, webPluginConfiguration, pluginDescriptor);
            } else {
                if (webPluginConfiguration == serverSettings.getWebModule()) {
                    setDefaultWebModule(entry.getValue());
                }
            }
        }
        // Set the default
        // if (serverSettings.getWebModule() == null) {
        // WebModulePluginConfiguration bimviewsWebModule = findWebModule(serverSettings, "BIM Views");
        // if (bimviewsWebModule != null) {
        // serverSettings.setWebModule(bimviewsWebModule);
        // setDefaultWebModule(pluginManager.getWebModulePlugin(bimviewsWebModule.getPluginDescriptor().getPluginClassName(), true));
        // } else {
        // WebModulePluginConfiguration defaultWebModule = findWebModule(serverSettings, "org.bimserver.defaultwebmodule.DefaultWebModulePlugin");
        // if (defaultWebModule != null) {
        // serverSettings.setWebModule(defaultWebModule);
        // setDefaultWebModule(pluginManager.getWebModulePlugin(defaultWebModule.getPluginDescriptor().getPluginClassName(), true));
        // }
        // }
        // }
        session.store(serverSettings);
        Condition condition = new AttributeCondition(StorePackage.eINSTANCE.getUser_Username(), new StringLiteral("system"));
        User systemUser = session.querySingle(condition, User.class, OldQuery.getDefault());
        ServerStarted serverStarted = session.create(ServerStarted.class);
        serverStarted.setDate(new Date());
        serverStarted.setAccessMethod(AccessMethod.INTERNAL);
        serverStarted.setExecutor(systemUser);
        try {
            session.store(serverStarted);
            session.commit();
        } catch (BimserverLockConflictException e) {
            throw new BimserverDatabaseException(e);
        } catch (ServiceException e) {
            throw new BimserverDatabaseException(e);
        } finally {
            session.close();
        }
        webModules = new HashMap<String, WebModulePlugin>();
        List<WebModulePluginConfiguration> webModuleConfigurations = serverSettingsCache.getServerSettings().getWebModules();
        for (WebModulePluginConfiguration webModulePluginConfiguration : webModuleConfigurations) {
            String contextPath = "";
            for (Parameter parameter : webModulePluginConfiguration.getSettings().getParameters()) {
                if (parameter.getName().equals("contextPath")) {
                    contextPath = ((StringType) parameter.getValue()).getValue();
                }
            }
            String identifier = webModulePluginConfiguration.getPluginDescriptor().getIdentifier();
            webModules.put(contextPath, (WebModulePlugin) pluginManager.getPlugin(identifier, true));
        }
        try (DatabaseSession databaseSession = getDatabase().createSession(OperationType.POSSIBLY_WRITE)) {
            ExtendedDataSchema htmlSchema = (ExtendedDataSchema) databaseSession.querySingle(StorePackage.eINSTANCE.getExtendedDataSchema_Name(), "GEOMETRY_GENERATION_REPORT_HTML_1_1");
            ExtendedDataSchema jsonSchema = (ExtendedDataSchema) databaseSession.querySingle(StorePackage.eINSTANCE.getExtendedDataSchema_Name(), "GEOMETRY_GENERATION_REPORT_JSON_1_1");
            if (htmlSchema == null) {
                htmlSchema = createExtendedDataSchema(databaseSession, "GEOMETRY_GENERATION_REPORT_HTML_1_1", "text/html");
            }
            if (jsonSchema == null) {
                jsonSchema = createExtendedDataSchema(databaseSession, "GEOMETRY_GENERATION_REPORT_JSON_1_1", "application/json");
            }
            databaseSession.commit();
        } catch (ServiceException e) {
            LOGGER.error("", e);
        }
        Integer protocolBuffersPort = getServerSettingsCache().getServerSettings().getProtocolBuffersPort();
        if (protocolBuffersPort >= 1 && protocolBuffersPort <= 65535) {
            try {
                protocolBuffersMetaData = new ProtocolBuffersMetaData();
                protocolBuffersMetaData.load(servicesMap, ProtocolBuffersBimServerClientFactory.class);
                protocolBuffersServer = new ProtocolBuffersServer(protocolBuffersMetaData, serviceFactory, servicesMap, protocolBuffersPort);
                protocolBuffersServer.start();
            } catch (Exception e) {
                LOGGER.error("", e);
            }
        }
        bimServerClientFactory = new DirectBimServerClientFactory<ServiceInterface>(serverSettingsCache.getServerSettings().getSiteAddress(), serviceFactory, servicesMap, pluginManager, metaDataManager);
        pluginManager.setBimServerClientFactory(bimServerClientFactory);
        try (DatabaseSession session2 = bimDatabase.createSession(OperationType.READ_ONLY)) {
            IfcModelInterface pluginBundleVersions = session2.getAllOfType(StorePackage.eINSTANCE.getPluginBundleVersion(), OldQuery.getDefault());
            for (PluginBundleVersion pluginBundleVersion : pluginBundleVersions.getAll(PluginBundleVersion.class)) {
                if (pluginBundleVersion.getType() == PluginBundleType.MAVEN || pluginBundleVersion.getType() == PluginBundleType.LOCAL) {
                    PluginBundleVersionIdentifier pluginBundleVersionIdentifier = new PluginBundleVersionIdentifier(pluginBundleVersion.getGroupId(), pluginBundleVersion.getArtifactId(), pluginBundleVersion.getVersion());
                    IfcModelInterface pluginDescriptors = session2.getAllOfType(StorePackage.eINSTANCE.getPluginDescriptor(), OldQuery.getDefault());
                    List<SPluginInformation> plugins = new ArrayList<>();
                    for (PluginDescriptor pluginDescriptor : pluginDescriptors.getAll(PluginDescriptor.class)) {
                        if (pluginDescriptor.getPluginBundleVersion() == pluginBundleVersion && pluginDescriptor.getEnabled()) {
                            SPluginInformation sPluginInformation = new SPluginInformation();
                            sPluginInformation.setEnabled(true);
                            sPluginInformation.setDescription(pluginDescriptor.getDescription());
                            sPluginInformation.setIdentifier(pluginDescriptor.getIdentifier());
                            sPluginInformation.setInstallForAllUsers(pluginDescriptor.isInstallForNewUsers());
                            sPluginInformation.setInstallForNewUsers(pluginDescriptor.isInstallForNewUsers());
                            sPluginInformation.setName(pluginDescriptor.getName());
                            sPluginInformation.setType(pluginManager.getPluginTypeFromClass(pluginDescriptor.getPluginClassName()));
                            plugins.add(sPluginInformation);
                        }
                    }
                    try {
                        pluginBundleManager.loadFromPluginDir(pluginBundleVersionIdentifier, getSConverter().convertToSObject(pluginBundleVersion), plugins, serverSettingsCache.getServerSettings().isPluginStrictVersionChecking());
                    } catch (Exception e) {
                        LOGGER.error("", e);
                    }
                }
            }
        } catch (Exception e) {
            throw new BimserverDatabaseException(e);
        }
    } catch (BimserverLockConflictException e) {
        throw new BimserverDatabaseException(e);
    // } catch (PluginException e) {
    // throw new BimserverDatabaseException(e);
    } catch (RenderEngineException e) {
        throw new BimserverDatabaseException(e);
    }
    long end = System.nanoTime();
    LOGGER.info("Done initializing database dependant logic (" + ((end - start) / 1000000) + "ms)");
}
Also used : User(org.bimserver.models.store.User) DatabaseSession(org.bimserver.database.DatabaseSession) IfcModelInterface(org.bimserver.emf.IfcModelInterface) ArrayList(java.util.ArrayList) ProtocolBuffersMetaData(org.bimserver.shared.pb.ProtocolBuffersMetaData) PluginBundleVersionIdentifier(org.bimserver.plugins.PluginBundleVersionIdentifier) ServerSettings(org.bimserver.models.store.ServerSettings) CommonsPoolingRenderEnginePoolFactory(org.bimserver.renderengine.pooled.CommonsPoolingRenderEnginePoolFactory) ServiceInterface(org.bimserver.shared.interfaces.ServiceInterface) ExtendedDataSchema(org.bimserver.models.store.ExtendedDataSchema) WebModulePlugin(org.bimserver.plugins.web.WebModulePlugin) PluginBundleVersion(org.bimserver.models.store.PluginBundleVersion) SPluginBundleVersion(org.bimserver.interfaces.objects.SPluginBundleVersion) RenderEngineException(org.bimserver.plugins.renderengine.RenderEngineException) Condition(org.bimserver.database.query.conditions.Condition) AttributeCondition(org.bimserver.database.query.conditions.AttributeCondition) PluginContext(org.bimserver.plugins.PluginContext) WebModulePluginConfiguration(org.bimserver.models.store.WebModulePluginConfiguration) SPluginInformation(org.bimserver.interfaces.objects.SPluginInformation) AttributeCondition(org.bimserver.database.query.conditions.AttributeCondition) RenderEnginePoolFactory(org.bimserver.renderengine.RenderEnginePoolFactory) CommonsPoolingRenderEnginePoolFactory(org.bimserver.renderengine.pooled.CommonsPoolingRenderEnginePoolFactory) Date(java.util.Date) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) PluginException(org.bimserver.shared.exceptions.PluginException) QueryException(org.bimserver.database.queries.om.QueryException) InconsistentModelsException(org.bimserver.database.migrations.InconsistentModelsException) BimserverLockConflictException(org.bimserver.database.BimserverLockConflictException) DatabaseRestartRequiredException(org.bimserver.database.DatabaseRestartRequiredException) DatabaseInitException(org.bimserver.database.berkeley.DatabaseInitException) RenderEngineException(org.bimserver.plugins.renderengine.RenderEngineException) ProtocolBuffersServer(org.bimserver.pb.server.ProtocolBuffersServer) PluginDescriptor(org.bimserver.models.store.PluginDescriptor) ServerStarted(org.bimserver.models.log.ServerStarted) ServiceException(org.bimserver.shared.exceptions.ServiceException) StringLiteral(org.bimserver.database.query.literals.StringLiteral) RenderEnginePools(org.bimserver.renderengine.RenderEnginePools) Parameter(org.bimserver.models.store.Parameter) BimserverLockConflictException(org.bimserver.database.BimserverLockConflictException)

Aggregations

PluginBundleVersion (org.bimserver.models.store.PluginBundleVersion)4 ArrayList (java.util.ArrayList)3 IfcModelInterface (org.bimserver.emf.IfcModelInterface)3 SPluginBundleVersion (org.bimserver.interfaces.objects.SPluginBundleVersion)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 BimserverLockConflictException (org.bimserver.database.BimserverLockConflictException)2 DatabaseRestartRequiredException (org.bimserver.database.DatabaseRestartRequiredException)2 DatabaseSession (org.bimserver.database.DatabaseSession)2 DatabaseInitException (org.bimserver.database.berkeley.DatabaseInitException)2 InconsistentModelsException (org.bimserver.database.migrations.InconsistentModelsException)2 QueryException (org.bimserver.database.queries.om.QueryException)2 AttributeCondition (org.bimserver.database.query.conditions.AttributeCondition)2 Condition (org.bimserver.database.query.conditions.Condition)2 StringLiteral (org.bimserver.database.query.literals.StringLiteral)2 Plugin (org.bimserver.plugins.Plugin)2 PluginBundle (org.bimserver.plugins.PluginBundle)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1