Search in sources :

Example 31 with PublicInterfaceNotFoundException

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

the class TestNewQueryViaClient method start.

private void start() {
    try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
        BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        String projectName = "Test " + new Random().nextInt();
        SProject project = client.getServiceInterface().addProject(projectName, "ifc2x3tc1");
        SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
        client.checkin(project.getOid(), "Test Model", deserializer.getOid(), false, Flow.SYNC, Paths.get("C:/Git/TestFiles/TestData/data/AC11-FZK-Haus-IFC.ifc"));
        project = client.getServiceInterface().getProjectByPoid(project.getOid());
        System.out.println(project.getName());
        ClientIfcModel model = client.getModel(project, project.getLastRevisionId(), false, false);
        Query query = new Query(model.getPackageMetaData());
        QueryPart queryPart = query.createQueryPart();
        queryPart.addType(Ifc2x3tc1Package.eINSTANCE.getIfcWall(), true);
        for (IfcWall ifcWall : model.getAllWithSubTypes(IfcWall.class)) {
            System.out.println(ifcWall.getGlobalId());
        }
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (ChannelConnectionException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (BimServerClientException e) {
        e.printStackTrace();
    } catch (Exception e1) {
        e1.printStackTrace();
    }
}
Also used : IfcWall(org.bimserver.models.ifc2x3tc1.IfcWall) ClientIfcModel(org.bimserver.client.ClientIfcModel) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) Query(org.bimserver.database.queries.om.Query) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) QueryPart(org.bimserver.database.queries.om.QueryPart) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) IOException(java.io.IOException) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) BimServerClient(org.bimserver.client.BimServerClient) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) Random(java.util.Random) ServiceException(org.bimserver.shared.exceptions.ServiceException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)

Example 32 with PublicInterfaceNotFoundException

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

the class TestNotification method main.

@SuppressWarnings("unused")
public static void main(String[] args) {
    try {
        BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
        // SProject newProject = client.getServiceInterface().addProject("test" + Math.random());
        // SDeserializerPluginConfiguration deserializerByName = client.getServiceInterface().getDeserializerByName("IfcStepDeserializer");
        // client.checkin(newProject.getOid(), "test", deserializerByName.getOid(), false, true, new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc"));
        // newProject = client.getServiceInterface().getProjectByPoid(newProject.getOid());
        SProject project = client.getServiceInterface().getProjectByPoid(458753L);
        SSerializerPluginConfiguration geometrySerializer = client.getServiceInterface().getSerializerByName("JsonGeometrySerializer");
        for (int i = 0; i < 100; i++) {
        // final CountDownLatch countDownLatch = new CountDownLatch(1);
        // final Long downloadByTypes = client.getServiceInterface().downloadByTypes(Collections.singleton(project.getLastRevisionId()), "ifc2x3tc1", Collections.singleton("IfcWindow"), geometrySerializer.getOid(), true, false, false, false);
        // final ProgressHandler progressHandler = new ProgressHandler() {
        // @Override
        // public void progress(SLongActionState state) {
        // if (state.getProgress() == 100) {
        // countDownLatch.countDown();
        // }
        // }
        // };
        // client.getNotificationsManager().registerProgressHandler(downloadByTypes, progressHandler);
        // try {
        // countDownLatch.await(20, TimeUnit.SECONDS);
        // client.getNotificationsManager().unregisterProgressHandler(downloadByTypes, progressHandler);
        // } catch (InterruptedException e) {
        // e.printStackTrace();
        // }
        }
        client.disconnect();
        System.out.println("Done");
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        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) SProject(org.bimserver.interfaces.objects.SProject)

Example 33 with PublicInterfaceNotFoundException

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

the class FileLoader method load.

private void load(Path dir) {
    // JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://sandbox.bimserver.org");
    try {
        final BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
        ExecutorService executorService = new ThreadPoolExecutor(1, 1, 1, TimeUnit.HOURS, new ArrayBlockingQueue<Runnable>(200));
        for (final Path file : PathUtils.list(dir)) {
            executorService.submit(new Runnable() {

                @Override
                public void run() {
                    System.out.println(file.getFileName());
                    SProject project;
                    try {
                        project = client.getServiceInterface().addProject(file.getFileName().toString(), "ifc2x3tc1");
                        SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
                        client.checkin(project.getOid(), file.getFileName().toString(), deserializer.getOid(), false, Flow.SYNC, file);
                    } catch (ServerException e) {
                        e.printStackTrace();
                    } catch (UserException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    } catch (PublicInterfaceNotFoundException e) {
                        e.printStackTrace();
                    }
                }
            });
        }
        executorService.awaitTermination(1, TimeUnit.HOURS);
        System.out.println("Done");
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) ServerException(org.bimserver.shared.exceptions.ServerException) IOException(java.io.IOException) SProject(org.bimserver.interfaces.objects.SProject) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) ExecutorService(java.util.concurrent.ExecutorService) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) UserException(org.bimserver.shared.exceptions.UserException)

Example 34 with PublicInterfaceNotFoundException

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

the class GetLogs method start.

private void start() {
    try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory(null, "[ADD]")) {
        client = factory.create(new UsernamePasswordAuthenticationInfo("[ADD]", "[ADD]"));
        List<SLogAction> logs = client.getAdminInterface().getLogs();
        Path file = Paths.get("log.txt");
        writer = new PrintWriter(file.toFile());
        try {
            for (SLogAction sLogAction : logs) {
                if (sLogAction instanceof SDatabaseCreated) {
                    write(sLogAction, "Database created");
                } else if (sLogAction instanceof SUserAddedToProject) {
                    SUserAddedToProject sUserAddedToProject = (SUserAddedToProject) sLogAction;
                    SProject project = getProject(sUserAddedToProject.getProjectId());
                    SUser user = getUser(sUserAddedToProject.getUserId());
                    write(sLogAction, "User " + user.getUsername() + " added to project " + project.getName());
                } else if (sLogAction instanceof SUserRemovedFromProject) {
                    SUserRemovedFromProject sUserRemovedFromProject = (SUserRemovedFromProject) sLogAction;
                    SProject project = getProject(sUserRemovedFromProject.getProjectId());
                    SUser user = getUser(sUserRemovedFromProject.getUserId());
                    write(sLogAction, "User " + user.getUsername() + " removed from project " + project.getName());
                } else if (sLogAction instanceof SNewUserAdded) {
                    SNewUserAdded sNewUserAdded = (SNewUserAdded) sLogAction;
                    SUser user = getUser(sNewUserAdded.getUserId());
                    write(sLogAction, "User " + user.getUsername() + " created");
                } else if (sLogAction instanceof SNewProjectAdded) {
                    SNewProjectAdded sNewProject = (SNewProjectAdded) sLogAction;
                    SProject project = getProject(sNewProject.getProjectId());
                    write(sLogAction, "Project " + project.getName() + " created");
                } else if (sLogAction instanceof SNewRevisionAdded) {
                    SNewRevisionAdded sNewRevisionAdded = (SNewRevisionAdded) sLogAction;
                    SProject project = getProject(sNewRevisionAdded.getProjectId());
                    SRevision revision = getRevision(sNewRevisionAdded.getRevisionId());
                    write(sLogAction, "Revision " + revision.getId() + " with comment " + revision.getComment() + " added to project " + project.getName());
                } else if (sLogAction instanceof SProjectUpdated) {
                    SProjectUpdated sProjectUpdated = (SProjectUpdated) sLogAction;
                    SProject project = getProject(sProjectUpdated.getProjectId());
                    write(sLogAction, "Project " + project.getName() + " updated");
                } else if (sLogAction instanceof SProjectDeleted) {
                    SProjectDeleted sProjectDeleted = (SProjectDeleted) sLogAction;
                    SProject project = getProject(sProjectDeleted.getProjectId());
                    write(sLogAction, "Project " + project.getName() + " deleted");
                } else if (sLogAction instanceof SUserChanged) {
                    SUserChanged sUserChanged = (SUserChanged) sLogAction;
                    SUser user = getUser(sUserChanged.getUserId());
                    write(sLogAction, "User " + user.getUsername() + " updated");
                } else if (sLogAction instanceof SServerStarted) {
                    write(sLogAction, "Server started");
                } else {
                    write(sLogAction, "NOT IMPL " + sLogAction.getClass().getSimpleName());
                }
            }
        } finally {
            writer.close();
        }
    } catch (ServiceException | ChannelConnectionException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (BimServerClientException e) {
        e.printStackTrace();
    } catch (Exception e1) {
        e1.printStackTrace();
    }
}
Also used : UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) SUser(org.bimserver.interfaces.objects.SUser) FileNotFoundException(java.io.FileNotFoundException) SProject(org.bimserver.interfaces.objects.SProject) SNewUserAdded(org.bimserver.interfaces.objects.SNewUserAdded) SUserChanged(org.bimserver.interfaces.objects.SUserChanged) SDatabaseCreated(org.bimserver.interfaces.objects.SDatabaseCreated) PrintWriter(java.io.PrintWriter) Path(java.nio.file.Path) SUserRemovedFromProject(org.bimserver.interfaces.objects.SUserRemovedFromProject) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) SProjectUpdated(org.bimserver.interfaces.objects.SProjectUpdated) SProjectDeleted(org.bimserver.interfaces.objects.SProjectDeleted) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) ServiceException(org.bimserver.shared.exceptions.ServiceException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) FileNotFoundException(java.io.FileNotFoundException) UserException(org.bimserver.shared.exceptions.UserException) ServerException(org.bimserver.shared.exceptions.ServerException) SUserAddedToProject(org.bimserver.interfaces.objects.SUserAddedToProject) SRevision(org.bimserver.interfaces.objects.SRevision) SNewRevisionAdded(org.bimserver.interfaces.objects.SNewRevisionAdded) ServiceException(org.bimserver.shared.exceptions.ServiceException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) SLogAction(org.bimserver.interfaces.objects.SLogAction) SServerStarted(org.bimserver.interfaces.objects.SServerStarted) SNewProjectAdded(org.bimserver.interfaces.objects.SNewProjectAdded)

Example 35 with PublicInterfaceNotFoundException

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

the class GetLogs method write.

private void write(SLogAction logAction, String text) {
    try {
        SUser user = users.get(logAction.getExecutorId());
        if (user == null) {
            user = client.getServiceInterface().getUserByUoid(logAction.getExecutorId());
            users.put(logAction.getExecutorId(), user);
        }
        writer.println(dateFormat.format(logAction.getDate()) + " " + logAction.getAccessMethod() + " " + (user == null ? "" : user.getUsername()) + ": " + text);
    } catch (ServerException | UserException | PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    }
}
Also used : ServerException(org.bimserver.shared.exceptions.ServerException) SUser(org.bimserver.interfaces.objects.SUser) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) UserException(org.bimserver.shared.exceptions.UserException)

Aggregations

PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)38 SProject (org.bimserver.interfaces.objects.SProject)22 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)20 ServiceException (org.bimserver.shared.exceptions.ServiceException)20 IOException (java.io.IOException)19 ServerException (org.bimserver.shared.exceptions.ServerException)18 UserException (org.bimserver.shared.exceptions.UserException)18 BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)15 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)12 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)10 Path (java.nio.file.Path)9 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)8 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)7 ChannelConnectionException (org.bimserver.shared.ChannelConnectionException)6 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)4 IfcModelInterface (org.bimserver.emf.IfcModelInterface)4 FileNotFoundException (java.io.FileNotFoundException)3 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3