Search in sources :

Example 11 with PluginException

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

the class TestGen method start.

private void start(String[] args) {
    try {
        PluginManagerInterface pluginManager = LocalDevSetup.setupPluginManager(args);
        DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true);
        Deserializer deserializer = deserializerPlugin.createDeserializer(null);
        deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
        RenderEnginePlugin renderEnginePlugin = pluginManager.getRenderEnginePlugin("org.bimserver.ifcengine.JvmRenderEnginePlugin", true);
        RenderEngine renderEngine = renderEnginePlugin.createRenderEngine(null, "ifc2x3tc1");
        renderEngine.init();
        Path path = Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc");
        RenderEngineModel renderEngineModel = renderEngine.openModel(new FileInputStream(path.toFile()), Files.size(path));
        RenderEngineSettings settings = new RenderEngineSettings();
        settings.setPrecision(Precision.SINGLE);
        settings.setIndexFormat(IndexFormat.AUTO_DETECT);
        settings.setGenerateNormals(true);
        settings.setGenerateTriangles(true);
        settings.setGenerateWireFrame(false);
        renderEngineModel.setSettings(settings);
        renderEngineModel.generateGeneralGeometry();
        renderEngineModel.close();
        renderEngine.close();
        long start = System.nanoTime();
        long end = System.nanoTime();
        System.out.println(((end - start) / 1000000) + " ms");
    } catch (PluginException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) PluginException(org.bimserver.shared.exceptions.PluginException) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) FileNotFoundException(java.io.FileNotFoundException) RenderEnginePlugin(org.bimserver.plugins.renderengine.RenderEnginePlugin) IOException(java.io.IOException) RenderEngineModel(org.bimserver.plugins.renderengine.RenderEngineModel) FileInputStream(java.io.FileInputStream) PluginManagerInterface(org.bimserver.plugins.PluginManagerInterface) Deserializer(org.bimserver.plugins.deserializers.Deserializer) RenderEngineSettings(org.bimserver.plugins.renderengine.RenderEngineSettings) RenderEngine(org.bimserver.plugins.renderengine.RenderEngine)

Example 12 with PluginException

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

the class TestInOut method start.

private void start(String[] args) {
    BimServerConfig config = new BimServerConfig();
    Path homeDir = Paths.get("home");
    try {
        if (Files.isDirectory(homeDir)) {
            PathUtils.removeDirectoryWithContent(homeDir);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    config.setClassPath(System.getProperty("java.class.path"));
    config.setHomeDir(homeDir);
    config.setPort(8080);
    config.setStartEmbeddedWebServer(true);
    config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../")));
    BimServer bimServer = new BimServer(config);
    try {
        LocalDevPluginLoader.loadPlugins(bimServer.getPluginManager(), new OptionsParser(args).getPluginDirectories());
        bimServer.start();
        if (bimServer.getServerInfo().getServerState() == ServerState.NOT_SETUP) {
            AdminInterface adminInterface = bimServer.getServiceFactory().get(new SystemAuthorization(1, TimeUnit.HOURS), AccessMethod.INTERNAL).get(AdminInterface.class);
            adminInterface.setup("http://localhost:8080", "Administrator", "admin@bimserver.org", "admin", null, null, null);
            SettingsInterface settingsInterface = bimServer.getServiceFactory().get(new SystemAuthorization(1, TimeUnit.HOURS), AccessMethod.INTERNAL).get(SettingsInterface.class);
            settingsInterface.setCacheOutputFiles(false);
        }
        BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
        SProject project = client.getServiceInterface().addProject("test", "ifc2x3tc1");
        SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
        Path inputFile = Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc");
        client.checkin(project.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, inputFile);
        project = client.getServiceInterface().getProjectByPoid(project.getOid());
        SSerializerPluginConfiguration serializer = client.getServiceInterface().getSerializerByContentType("application/ifc");
        Path outputFile = Paths.get("output.ifc");
        client.download(project.getLastRevisionId(), serializer.getOid(), outputFile);
        Diff diff = new Diff(false, false, false, inputFile, outputFile);
        diff.start();
    } catch (ServerException e) {
        e.printStackTrace();
    } catch (DatabaseInitException e) {
        e.printStackTrace();
    } catch (BimserverDatabaseException e) {
        e.printStackTrace();
    } catch (PluginException e) {
        e.printStackTrace();
    } catch (DatabaseRestartRequiredException e) {
        e.printStackTrace();
    } catch (UserException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    } catch (CompareException e) {
        e.printStackTrace();
    } catch (BimServerClientException e) {
        e.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) ServerException(org.bimserver.shared.exceptions.ServerException) Diff(org.bimserver.tests.diff.Diff) BimServer(org.bimserver.BimServer) PluginException(org.bimserver.shared.exceptions.PluginException) IOException(java.io.IOException) SystemAuthorization(org.bimserver.webservices.authorization.SystemAuthorization) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) BimServerConfig(org.bimserver.BimServerConfig) OptionsParser(org.bimserver.plugins.OptionsParser) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) LocalDevelopmentResourceFetcher(org.bimserver.shared.LocalDevelopmentResourceFetcher) AdminInterface(org.bimserver.shared.interfaces.AdminInterface) DatabaseInitException(org.bimserver.database.berkeley.DatabaseInitException) SettingsInterface(org.bimserver.shared.interfaces.SettingsInterface) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) DatabaseRestartRequiredException(org.bimserver.database.DatabaseRestartRequiredException) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) UserException(org.bimserver.shared.exceptions.UserException) CompareException(org.bimserver.tests.diff.CompareException)

Example 13 with PluginException

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

the class GuidHighlighterTester method readModel.

public IfcModelInterface readModel(Path file) {
    PluginManager pluginManager;
    try {
        pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home"));
        DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true);
        Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration());
        deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
        try {
            IfcModelInterface model = DeserializerUtils.readFromFile(deserializer, file);
            return model;
        } catch (Exception e) {
            e.printStackTrace();
        }
    } catch (PluginException e1) {
        e1.printStackTrace();
    }
    return null;
}
Also used : PluginManager(org.bimserver.plugins.PluginManager) Deserializer(org.bimserver.plugins.deserializers.Deserializer) IfcModelInterface(org.bimserver.emf.IfcModelInterface) PluginException(org.bimserver.shared.exceptions.PluginException) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) PluginConfiguration(org.bimserver.plugins.PluginConfiguration) PluginException(org.bimserver.shared.exceptions.PluginException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 14 with PluginException

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

the class IfcRioleringTest method start.

private void start() {
    Path src = TestFile.RIOLERING_TEST.getFile();
    PluginManager pluginManager;
    try {
        pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home"));
        DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true);
        Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration());
        deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
        try {
            model = DeserializerUtils.readFromFile(deserializer, src);
        } catch (Exception e) {
            e.printStackTrace();
        }
        step1();
    } catch (PluginException e1) {
        e1.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) PluginManager(org.bimserver.plugins.PluginManager) Deserializer(org.bimserver.plugins.deserializers.Deserializer) PluginException(org.bimserver.shared.exceptions.PluginException) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) PluginConfiguration(org.bimserver.plugins.PluginConfiguration) PluginException(org.bimserver.shared.exceptions.PluginException)

Example 15 with PluginException

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

the class RenderEnginePools method getRenderEnginePool.

public RenderEnginePool getRenderEnginePool(Schema schema, String className, PluginConfiguration pluginConfiguration) throws PluginException {
    if (pools.containsKey(schema)) {
        Map<String, RenderEnginePool> map = pools.get(schema);
        if (map.containsKey(className)) {
            return map.get(className);
        } else {
            // Maybe this plugin has been installed after startup, let's have a look in the PluginManager
            RenderEnginePlugin renderEnginePlugin = bimServer.getPluginManager().getRenderEnginePlugin(className, true);
            if (renderEnginePlugin == null) {
                throw new PluginException("No render engine found for className " + className);
            } else {
                RenderEnginePool renderEnginePool = renderEnginePoolFactory.newRenderEnginePool(new RenderEngineFactory() {

                    @Override
                    public RenderEngine createRenderEngine() throws RenderEngineException {
                        return renderEnginePlugin.createRenderEngine(pluginConfiguration, schema.name());
                    }
                });
                map.put(className, renderEnginePool);
                return renderEnginePool;
            }
        }
    } else {
        throw new PluginException("No render engine found for schema " + schema);
    }
}
Also used : PluginException(org.bimserver.shared.exceptions.PluginException) RenderEnginePlugin(org.bimserver.plugins.renderengine.RenderEnginePlugin) RenderEngine(org.bimserver.plugins.renderengine.RenderEngine) RenderEngineException(org.bimserver.plugins.renderengine.RenderEngineException)

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