Search in sources :

Example 36 with PluginException

use of org.bimserver.shared.exceptions.PluginException in project BIMserver by opensourceBIM.

the class BimServer method initDatabaseDependantItems.

private void initDatabaseDependantItems() throws BimserverDatabaseException {
    notificationsManager.init();
    getSerializerFactory().init(pluginManager, bimDatabase, this);
    try {
        DatabaseSession session = bimDatabase.createSession();
        try {
            updatePlugins(session);
            session.commit();
        } catch (ServiceException e) {
            LOGGER.error("", e);
        } finally {
            session.close();
        }
        session = bimDatabase.createSession();
        // 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>();
        DatabaseSession ses = bimDatabase.createSession();
        try {
            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));
            }
        // if (serverSettingsCache.getServerSettings().getWebModule() !=
        // null) {
        // defaultWebModule = (WebModulePlugin)
        // pluginManager.getPlugin(serverSettingsCache.getServerSettings().getWebModule().getPluginDescriptor().getPluginClassName(),
        // true);
        // }
        } finally {
            ses.close();
        }
        Integer protocolBuffersPort = getServerSettingsCache().getServerSettings().getProtocolBuffersPort();
        if (protocolBuffersPort >= 1 && protocolBuffersPort <= 65535) {
            try {
                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()) {
            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 {
                        pluginManager.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);
    }
}
Also used : User(org.bimserver.models.store.User) DatabaseSession(org.bimserver.database.DatabaseSession) IfcModelInterface(org.bimserver.emf.IfcModelInterface) ArrayList(java.util.ArrayList) PluginBundleVersionIdentifier(org.bimserver.plugins.PluginBundleVersionIdentifier) ServerSettings(org.bimserver.models.store.ServerSettings) ServiceInterface(org.bimserver.shared.interfaces.ServiceInterface) WebModulePlugin(org.bimserver.plugins.web.WebModulePlugin) PluginBundleVersion(org.bimserver.models.store.PluginBundleVersion) SPluginBundleVersion(org.bimserver.interfaces.objects.SPluginBundleVersion) 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) 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) InconsistentModelsException(org.bimserver.database.migrations.InconsistentModelsException) BimserverLockConflictException(org.bimserver.database.BimserverLockConflictException) DatabaseRestartRequiredException(org.bimserver.database.DatabaseRestartRequiredException) DatabaseInitException(org.bimserver.database.berkeley.DatabaseInitException) 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) Parameter(org.bimserver.models.store.Parameter) BimserverLockConflictException(org.bimserver.database.BimserverLockConflictException)

Example 37 with PluginException

use of org.bimserver.shared.exceptions.PluginException in project GltfSerializers by opensourceBIM.

the class BinaryGltfSerializerPlugin method init.

@Override
public void init(PluginContext pluginContext) throws PluginException {
    Path vertexColorFragmentShaderPath = pluginContext.getRootPath().resolve("shaders/fragmentcolor.shader");
    Path vertexColorVertexShaderPath = pluginContext.getRootPath().resolve("shaders/vertexcolor.shader");
    Path materialColorFragmentShaderPath = pluginContext.getRootPath().resolve("shaders/fragmentmaterial.shader");
    Path materialColorVertexShaderPath = pluginContext.getRootPath().resolve("shaders/vertexmaterial.shader");
    try {
        vertexColorFragmentShaderBytes = Files.readAllBytes(vertexColorFragmentShaderPath);
        vertexColorVertexShaderBytes = Files.readAllBytes(vertexColorVertexShaderPath);
        materialColorFragmentShaderBytes = Files.readAllBytes(materialColorFragmentShaderPath);
        materialColorVertexShaderBytes = Files.readAllBytes(materialColorVertexShaderPath);
    } catch (IOException e) {
        throw new PluginException(e);
    }
}
Also used : Path(java.nio.file.Path) PluginException(org.bimserver.shared.exceptions.PluginException) IOException(java.io.IOException)

Example 38 with PluginException

use of org.bimserver.shared.exceptions.PluginException in project GltfSerializers by opensourceBIM.

the class BinaryGltfSerializerPlugin2 method init.

@Override
public void init(PluginContext pluginContext) throws PluginException {
    Path vertexColorFragmentShaderPath = pluginContext.getRootPath().resolve("shaders/fragmentcolor.shader");
    Path vertexColorVertexShaderPath = pluginContext.getRootPath().resolve("shaders/vertexcolor.shader");
    Path materialColorFragmentShaderPath = pluginContext.getRootPath().resolve("shaders/fragmentmaterial.shader");
    Path materialColorVertexShaderPath = pluginContext.getRootPath().resolve("shaders/vertexmaterial.shader");
    try {
        vertexColorFragmentShaderBytes = Files.readAllBytes(vertexColorFragmentShaderPath);
        vertexColorVertexShaderBytes = Files.readAllBytes(vertexColorVertexShaderPath);
        materialColorFragmentShaderBytes = Files.readAllBytes(materialColorFragmentShaderPath);
        materialColorVertexShaderBytes = Files.readAllBytes(materialColorVertexShaderPath);
    } catch (IOException e) {
        throw new PluginException(e);
    }
}
Also used : Path(java.nio.file.Path) PluginException(org.bimserver.shared.exceptions.PluginException) IOException(java.io.IOException)

Aggregations

PluginException (org.bimserver.shared.exceptions.PluginException)38 IOException (java.io.IOException)26 Path (java.nio.file.Path)19 ServiceException (org.bimserver.shared.exceptions.ServiceException)12 FileNotFoundException (java.io.FileNotFoundException)11 PluginManager (org.bimserver.plugins.PluginManager)10 DeserializerPlugin (org.bimserver.plugins.deserializers.DeserializerPlugin)10 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)9 UserException (org.bimserver.shared.exceptions.UserException)9 IfcModelInterface (org.bimserver.emf.IfcModelInterface)8 ChannelConnectionException (org.bimserver.shared.ChannelConnectionException)8 DatabaseRestartRequiredException (org.bimserver.database.DatabaseRestartRequiredException)7 DatabaseInitException (org.bimserver.database.berkeley.DatabaseInitException)7 XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)7 Model (org.apache.maven.model.Model)6 MavenXpp3Reader (org.apache.maven.model.io.xpp3.MavenXpp3Reader)6 MetaDataManager (org.bimserver.emf.MetaDataManager)6 SPluginBundle (org.bimserver.interfaces.objects.SPluginBundle)6 SPluginInformation (org.bimserver.interfaces.objects.SPluginInformation)6 ServerException (org.bimserver.shared.exceptions.ServerException)6