Search in sources :

Example 1 with BimServerClientException

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

the class BimServerImporter method start.

public void start() {
    try (BimServerClientFactory factory = new JsonBimServerClientFactory(bimServer.getMetaDataManager(), address)) {
        LOGGER.info("Importing...");
        remoteClient = factory.create(new UsernamePasswordAuthenticationInfo(username, password));
        final BimDatabase database = bimServer.getDatabase();
        DatabaseSession databaseSession = database.createSession();
        try {
            LOGGER.info("Users...");
            for (SUser user : remoteClient.getServiceInterface().getAllUsers()) {
                createUser(databaseSession, user.getOid());
            }
            LOGGER.info("Projects...");
            for (SProject project : remoteClient.getServiceInterface().getAllProjects(false, false)) {
                createProject(databaseSession, project.getOid());
            }
            LOGGER.info("Done");
            databaseSession.commit();
        } catch (BimserverDatabaseException e) {
            LOGGER.error("", e);
        } finally {
            databaseSession.close();
        }
        final BimServerClientInterface client = bimServer.getBimServerClientFactory().create(new UsernamePasswordAuthenticationInfo(username, password));
        // for (SRenderEnginePluginConfiguration renderEnginePluginConfiguration : client.getPluginInterface().getAllRenderEngines(true)) {
        // if (renderEnginePluginConfiguration.getName().equals("IFC Engine DLL")) {
        // client.getPluginInterface().setDefaultRenderEngine(renderEnginePluginConfiguration.getOid());
        // }
        // }
        Path incoming = Paths.get(path);
        final Map<GregorianCalendar, Key> comments = new TreeMap<>();
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss");
        for (SProject project : remoteClient.getServiceInterface().getAllProjects(false, false)) {
            for (SRevision revision : remoteClient.getServiceInterface().getAllRevisionsOfProject(project.getOid())) {
                GregorianCalendar gregorianCalendar = new GregorianCalendar();
                gregorianCalendar.setTime(revision.getDate());
                if (!revision.getComment().startsWith("generated for")) {
                    User user = users.get(revision.getUserId());
                    Path userFolder = incoming.resolve(user.getUsername());
                    boolean found = false;
                    for (Path file : PathUtils.list(userFolder)) {
                        if (file.getFileName().toString().endsWith(revision.getComment())) {
                            String dateStr = file.getFileName().toString().substring(0, 19);
                            Date parse = dateFormat.parse(dateStr);
                            GregorianCalendar fileDate = new GregorianCalendar();
                            fileDate.setTime(parse);
                            long millisDiff = Math.abs(fileDate.getTimeInMillis() - revision.getDate().getTime());
                            if (millisDiff > 1000 * 60 * 120) {
                                // 120 minutes
                                continue;
                            }
                            if (revision.getOid() == project.getLastRevisionId()) {
                                comments.put(gregorianCalendar, new Key(file, project.getOid(), revision.getComment(), revision.getDate(), revision.getUserId()));
                            }
                            found = true;
                            break;
                        }
                    }
                    if (!found) {
                        LOGGER.info("Not found: " + revision.getComment());
                    }
                }
            }
        }
        ExecutorService executorService = new ThreadPoolExecutor(1, 1, 1, TimeUnit.DAYS, new ArrayBlockingQueue<Runnable>(1000));
        for (final GregorianCalendar gregorianCalendar : comments.keySet()) {
            executorService.submit(new Runnable() {

                @Override
                public void run() {
                    Key key = comments.get(gregorianCalendar);
                    LOGGER.info("Checking in: " + key.file.getFileName().toString() + " " + Formatters.bytesToString(key.file.toFile().length()));
                    Project sProject = projects.get(key.poid);
                    try {
                        SDeserializerPluginConfiguration desserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", sProject.getOid());
                        client.checkin(sProject.getOid(), key.comment, desserializer.getOid(), false, Flow.SYNC, key.file);
                        SProject updatedProject = client.getServiceInterface().getProjectByPoid(sProject.getOid());
                        DatabaseSession databaseSession = database.createSession();
                        try {
                            LOGGER.info("Done");
                            Project project = databaseSession.get(updatedProject.getOid(), OldQuery.getDefault());
                            Revision revision = project.getLastRevision();
                            User user = (User) databaseSession.get(users.get(key.userId).getOid(), OldQuery.getDefault());
                            for (Revision otherRevision : revision.getConcreteRevisions().get(0).getRevisions()) {
                                otherRevision.load();
                                otherRevision.setDate(key.date);
                                otherRevision.setComment(otherRevision.getComment().replace("Administrator", user.getName()));
                                databaseSession.store(otherRevision);
                            }
                            DateFormat m = new SimpleDateFormat("dd-MM-yyyy");
                            LOGGER.info("Setting date to " + m.format(key.date));
                            revision.setUser(user);
                            revision.setDate(key.date);
                            databaseSession.store(revision);
                            databaseSession.commit();
                        } catch (BimserverDatabaseException | ServiceException e) {
                            LOGGER.error("", e);
                        } finally {
                            databaseSession.close();
                        }
                    } catch (IOException | UserException | ServerException | PublicInterfaceNotFoundException e) {
                        LOGGER.error("", e);
                    }
                }
            });
        }
        executorService.shutdown();
    } catch (ServiceException e) {
        LOGGER.error("", e);
    } catch (ChannelConnectionException e) {
        LOGGER.error("", e);
    } catch (PublicInterfaceNotFoundException e) {
        LOGGER.error("", e);
    } catch (ParseException e) {
        LOGGER.error("", e);
    } catch (IOException e) {
        LOGGER.error("", e);
    } catch (BimServerClientException e1) {
        LOGGER.error("", e1);
    } catch (Exception e2) {
        LOGGER.error("", e2);
    }
}
Also used : User(org.bimserver.models.store.User) SUser(org.bimserver.interfaces.objects.SUser) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) DatabaseSession(org.bimserver.database.DatabaseSession) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) SUser(org.bimserver.interfaces.objects.SUser) SProject(org.bimserver.interfaces.objects.SProject) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) BimServerClientFactory(org.bimserver.shared.BimServerClientFactory) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) Path(java.nio.file.Path) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) GregorianCalendar(java.util.GregorianCalendar) IOException(java.io.IOException) TreeMap(java.util.TreeMap) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) Date(java.util.Date) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) ServiceException(org.bimserver.shared.exceptions.ServiceException) ParseException(java.text.ParseException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) IOException(java.io.IOException) UserException(org.bimserver.shared.exceptions.UserException) ServerException(org.bimserver.shared.exceptions.ServerException) SRevision(org.bimserver.interfaces.objects.SRevision) Project(org.bimserver.models.store.Project) SProject(org.bimserver.interfaces.objects.SProject) Revision(org.bimserver.models.store.Revision) SRevision(org.bimserver.interfaces.objects.SRevision) ServiceException(org.bimserver.shared.exceptions.ServiceException) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) ExecutorService(java.util.concurrent.ExecutorService) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ParseException(java.text.ParseException) BimDatabase(org.bimserver.database.BimDatabase) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with BimServerClientException

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

the class ImportLargeProject method main.

public static void main(String[] args) {
    BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
    try {
        Path baseFolder = Paths.get("C:\\Users\\Ruben de Laat\\Documents\\ttt");
        ServiceInterface serviceInterface = client.getServiceInterface();
        SProject mainProject = serviceInterface.addProject("Tekla Demo Model", "ifc2x3tc1");
        SProject architectural = serviceInterface.addProjectAsSubProject("Architectural", mainProject.getOid(), "ifc2x3tc1");
        SProject teklaHouseArchitectural = serviceInterface.addProjectAsSubProject("Tekla House Architectural", architectural.getOid(), "ifc2x3tc1");
        SProject structuralSteal = serviceInterface.addProjectAsSubProject("Structural Steal", mainProject.getOid(), "ifc2x3tc1");
        SProject teklaHouseStructural = serviceInterface.addProjectAsSubProject("Tekla House Structural", structuralSteal.getOid(), "ifc2x3tc1");
        SProject foundation = serviceInterface.addProjectAsSubProject("Foundation", mainProject.getOid(), "ifc2x3tc1");
        SProject teklaHouseFoundationFootings = serviceInterface.addProjectAsSubProject("Tekla Hose Foundation Footings", foundation.getOid(), "ifc2x3tc1");
        SProject teklaHouseFoundationPiles = serviceInterface.addProjectAsSubProject("Tekla Hose Foundation Piles", foundation.getOid(), "ifc2x3tc1");
        SProject teklaHouseFoundationRebars = serviceInterface.addProjectAsSubProject("Tekla Hose Foundation Rebars", foundation.getOid(), "ifc2x3tc1");
        SProject teklaHouseFoundationEmbedments = serviceInterface.addProjectAsSubProject("Tekla Hose Foundation Embedments", foundation.getOid(), "ifc2x3tc1");
        SProject cipConcreteContractor = serviceInterface.addProjectAsSubProject("CIP Concrete Contractor", mainProject.getOid(), "ifc2x3tc1");
        serviceInterface.addProjectAsSubProject("Tekla House CIP Pours", cipConcreteContractor.getOid(), "ifc2x3tc1");
        SProject teklaHouseCIPRebars = serviceInterface.addProjectAsSubProject("Tekla House CIP Rebars", cipConcreteContractor.getOid(), "ifc2x3tc1");
        SProject teklaHouseCIPColumns = serviceInterface.addProjectAsSubProject("Tekla House CIP Columns", cipConcreteContractor.getOid(), "ifc2x3tc1");
        SProject formWork = serviceInterface.addProjectAsSubProject("Formwork", mainProject.getOid(), "ifc2x3tc1");
        serviceInterface.addProjectAsSubProject("Column Formwork", formWork.getOid(), "ifc2x3tc1");
        SProject precast = serviceInterface.addProjectAsSubProject("Precast", mainProject.getOid(), "ifc2x3tc1");
        SProject teklaHousePrecastRebars = serviceInterface.addProjectAsSubProject("Tekla House Precast Rebars", precast.getOid(), "ifc2x3tc1");
        SProject teklaHousePrecastConcrete = serviceInterface.addProjectAsSubProject("Tekla House Precast Concrete", precast.getOid(), "ifc2x3tc1");
        SProject mep = serviceInterface.addProjectAsSubProject("MEP", mainProject.getOid(), "ifc2x3tc1");
        SProject teklaHouseMEPGround = serviceInterface.addProjectAsSubProject("Teklas House MEP, Ground", mep.getOid(), "ifc2x3tc1");
        SProject teklaHouseMEP1 = serviceInterface.addProjectAsSubProject("Tekla House MEP, 1st", mep.getOid(), "ifc2x3tc1");
        SProject teklaHouseMEP2 = serviceInterface.addProjectAsSubProject("Tekla House MEP, 2nd", mep.getOid(), "ifc2x3tc1");
        SProject teklaHouseMEP3 = serviceInterface.addProjectAsSubProject("Tekla House MEP, 3rd", mep.getOid(), "ifc2x3tc1");
        SProject teklaHouseMEPRoof = serviceInterface.addProjectAsSubProject("Tekla House MEP, Roof", mep.getOid(), "ifc2x3tc1");
        SProject site = serviceInterface.addProjectAsSubProject("Site", mainProject.getOid(), "ifc2x3tc1");
        serviceInterface.addProjectAsSubProject("Site.skp", site.getOid(), "ifc2x3tc1");
        serviceInterface.addProjectAsSubProject("Tower crane", site.getOid(), "ifc2x3tc1");
        serviceInterface.addProjectAsSubProject("Caterpillar", site.getOid(), "ifc2x3tc1");
        serviceInterface.addProjectAsSubProject("Excavator", site.getOid(), "ifc2x3tc1");
        SProject grid = serviceInterface.addProjectAsSubProject("Grid", mainProject.getOid(), "ifc2x3tc1");
        SProject teklaHouseGrids = serviceInterface.addProjectAsSubProject("Tekla House Grids", grid.getOid(), "ifc2x3tc1");
        SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", grid.getOid());
        client.checkin(teklaHouseStructural.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Structural.ifcZIP"));
        client.checkin(teklaHouseGrids.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Grids.ifc"));
        client.checkin(teklaHouseFoundationFootings.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Foundation Footings.ifcZIP"));
        client.checkin(teklaHouseFoundationPiles.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Foundation Piles.ifcZIP"));
        client.checkin(teklaHouseFoundationRebars.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Foundation Rebars.ifcZIP"));
        client.checkin(teklaHouseFoundationEmbedments.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Foundation Embedments.ifcZIP"));
        client.checkin(teklaHousePrecastRebars.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Precast Rebars.ifcZIP"));
        client.checkin(teklaHousePrecastConcrete.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Precast Concrete.ifcZIP"));
        // client.checkin(teklaHouseCIPPours.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder, "Tekla House CIP Pours.ifc"));
        client.checkin(teklaHouseCIPRebars.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House CIP Rebars.ifcZIP"));
        client.checkin(teklaHouseCIPColumns.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House CIP Columns.ifcZIP"));
        client.checkin(teklaHouseArchitectural.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Architectural.ifczip"));
        client.checkin(teklaHouseMEPGround.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House MEP, Ground.ifc"));
        client.checkin(teklaHouseMEP1.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House MEP, 1st.ifc"));
        client.checkin(teklaHouseMEP2.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House MEP, 2nd.ifc"));
        client.checkin(teklaHouseMEP3.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House MEP, 3rd.ifc"));
        client.checkin(teklaHouseMEPRoof.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House MEP, Roof.ifc"));
        mainProject = serviceInterface.getProjectByPoid(mainProject.getOid());
        SSerializerPluginConfiguration serializer = client.getServiceInterface().getSerializerByContentType("application/ifc");
        client.download(mainProject.getLastRevisionId(), serializer.getOid(), Paths.get("output.ifc"));
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (BimServerClientException e) {
        e.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) ServiceException(org.bimserver.shared.exceptions.ServiceException) ServiceInterface(org.bimserver.shared.interfaces.ServiceInterface) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) IOException(java.io.IOException) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException)

Example 3 with BimServerClientException

use of org.bimserver.shared.exceptions.BimServerClientException 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 4 with BimServerClientException

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

the class TestConstantlyDownloading method main.

public static void main(String[] args) {
    long poid = 196609;
    try {
        BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
        for (int i = 0; i < 200; i++) {
            SProject project = client.getServiceInterface().getProjectByPoid(poid);
            long roid = project.getLastRevisionId();
            SSerializerPluginConfiguration serializer = client.getPluginInterface().getSerializerByPluginClassName("org.bimserver.geometry.json.JsonGeometrySerializerPlugin");
            System.out.println(i);
            client.download(roid, serializer.getOid(), new ByteArrayOutputStream());
        }
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (BimServerClientException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : ServiceException(org.bimserver.shared.exceptions.ServiceException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException)

Example 5 with BimServerClientException

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

the class TestInstall method main.

public static void main(String[] args) {
    ArrayList<String> pluginList = new ArrayList<>();
    pluginList.add("C:/plugins/ifcplugins-0.0.15.jar");
    try (BimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
        BimServerClientInterface client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        for (String each : pluginList) {
            try {
                DataSource fds = new FileDataSource(new File(each));
                DataHandler handler = new DataHandler(fds);
                client.getPluginInterface().installPluginBundleFromFile(handler, true, true);
                System.out.println("Plugin " + each + " successfully installed !");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    } catch (BimServerClientException e1) {
        e1.printStackTrace();
    } catch (ServiceException e1) {
        e1.printStackTrace();
    } catch (ChannelConnectionException e1) {
        e1.printStackTrace();
    } catch (Exception e2) {
        e2.printStackTrace();
    }
}
Also used : ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) ArrayList(java.util.ArrayList) DataHandler(javax.activation.DataHandler) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) BimServerClientFactory(org.bimserver.shared.BimServerClientFactory) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) ServiceException(org.bimserver.shared.exceptions.ServiceException) FileDataSource(org.bimserver.utils.FileDataSource) DataSource(javax.activation.DataSource) ServiceException(org.bimserver.shared.exceptions.ServiceException) FileDataSource(org.bimserver.utils.FileDataSource) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) File(java.io.File)

Aggregations

BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)19 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)15 IOException (java.io.IOException)12 SProject (org.bimserver.interfaces.objects.SProject)12 ServiceException (org.bimserver.shared.exceptions.ServiceException)11 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)10 ServerException (org.bimserver.shared.exceptions.ServerException)10 UserException (org.bimserver.shared.exceptions.UserException)10 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)8 ChannelConnectionException (org.bimserver.shared.ChannelConnectionException)8 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)8 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)7 Path (java.nio.file.Path)6 BimServerClientFactory (org.bimserver.shared.BimServerClientFactory)5 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Date (java.util.Date)3 IfcModelInterface (org.bimserver.emf.IfcModelInterface)3 PluginException (org.bimserver.shared.exceptions.PluginException)3