Search in sources :

Example 46 with PublicInterfaceNotFoundException

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

the class TestSceneJsDownload method start.

private void start() {
    try {
        BimServerClientInterface bimServerClient = LocalDevSetup.setupJson("http://localhost:8080");
        bimServerClient.getAuthInterface().login("admin@bimserver.org", "admin");
        SSerializerPluginConfiguration serializerByContentType = bimServerClient.getServiceInterface().getSerializerByContentType("application/json");
        List<SProject> projects = bimServerClient.getServiceInterface().getProjectsByName("test");
        if (!projects.isEmpty()) {
            SProject project = projects.get(0);
            if (project.getLastRevisionId() != -1) {
                long start = System.nanoTime();
                Long download = bimServerClient.getServiceInterface().download(Collections.singleton(project.getLastRevisionId()), DefaultQueries.allAsString(), serializerByContentType.getOid(), true);
                System.out.println(((System.nanoTime() - start) / 1000000) + " ms");
                start = System.nanoTime();
                InputStream inputStream = bimServerClient.getDownloadData(download);
                FileOutputStream fileOutputStream = new FileOutputStream(Paths.get("test.json").toFile());
                IOUtils.copy(inputStream, fileOutputStream);
                fileOutputStream.close();
                System.out.println(((System.nanoTime() - start) / 1000000) + " ms");
            }
        }
    } catch (ServerException e) {
        e.printStackTrace();
    } catch (UserException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    }
}
Also used : ServerException(org.bimserver.shared.exceptions.ServerException) InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) SProject(org.bimserver.interfaces.objects.SProject) FileOutputStream(java.io.FileOutputStream) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) UserException(org.bimserver.shared.exceptions.UserException)

Aggregations

PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)46 IOException (java.io.IOException)27 SProject (org.bimserver.interfaces.objects.SProject)24 ServerException (org.bimserver.shared.exceptions.ServerException)24 UserException (org.bimserver.shared.exceptions.UserException)24 ServiceException (org.bimserver.shared.exceptions.ServiceException)23 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)22 BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)15 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)14 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)10 Path (java.nio.file.Path)9 ChannelConnectionException (org.bimserver.shared.ChannelConnectionException)8 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)8 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)7 InputStream (java.io.InputStream)6 IfcModelInterfaceException (org.bimserver.emf.IfcModelInterfaceException)6 InputStreamReader (java.io.InputStreamReader)4 IfcModelInterface (org.bimserver.emf.IfcModelInterface)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3