Search in sources :

Example 41 with ServiceException

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

the class TestBigFilesRemote method start.

private void start(String[] args) {
    String address = args[0];
    String username = args[1];
    String password = args[2];
    String basepath = args[3];
    System.out.println("Address: " + address);
    System.out.println("Username: " + username);
    System.out.println("Password: " + password);
    System.out.println("Basepath: " + basepath);
    try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory(null, address)) {
        BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo(args[1], args[2]));
        String[] fileNames = new String[] { "4NC Whole Model.ifc", "1006 General withIFC_exportLayerCombos.ifc", "12001_17 MOS_AC17SpecialBigVersion.ifc", "12510_MASTER_Drofus_Test.ifc", "BondBryan10-134 (06) Proposed Site-1.ifc", "HLM_39090_12259 University of Sheffield NEB  [PR-BIM-01-bhelberg].ifc" };
        DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");
        for (String fileName : fileNames) {
            String projectName = fileName.substring(0, fileName.lastIndexOf(".ifc"));
            List<SProject> projectsByName = client.getServiceInterface().getProjectsByName(projectName);
            SProject project = null;
            if (projectsByName.size() == 1) {
                project = projectsByName.get(0);
            } else {
                System.out.println("Creating project " + fileName);
                project = client.getServiceInterface().addProject(projectName, "ifc2x3tc1");
            }
            SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
            System.out.println(dateFormat.format(new Date()));
            SDatabaseInformation databaseInformation = client.getAdminInterface().getDatabaseInformation();
            System.out.println("Database size: " + Formatters.bytesToString(databaseInformation.getDatabaseSizeInBytes()) + " (" + databaseInformation.getDatabaseSizeInBytes() + ")");
            SJavaInfo javaInfo = client.getAdminInterface().getJavaInfo();
            System.out.println("Used: " + Formatters.bytesToString(javaInfo.getHeapUsed()) + ", Free: " + Formatters.bytesToString(javaInfo.getHeapFree()) + ", Max: " + Formatters.bytesToString(javaInfo.getHeapMax()) + ", Total: " + Formatters.bytesToString(javaInfo.getHeapTotal()));
            String downloadUrl = basepath + UrlEscapers.urlPathSegmentEscaper().escape(fileName);
            System.out.println("Download URL: " + downloadUrl);
            client.getServiceInterface().checkinFromUrlSync(project.getOid(), fileName, deserializer.getOid(), fileName, downloadUrl, false);
            System.out.println("Done checking in " + fileName);
        }
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (ChannelConnectionException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (BimServerClientException e) {
        e.printStackTrace();
    } catch (Exception e1) {
        e1.printStackTrace();
    }
}
Also used : SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) SDatabaseInformation(org.bimserver.interfaces.objects.SDatabaseInformation) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) BimServerClient(org.bimserver.client.BimServerClient) Date(java.util.Date) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) ServiceException(org.bimserver.shared.exceptions.ServiceException) ServiceException(org.bimserver.shared.exceptions.ServiceException) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) SJavaInfo(org.bimserver.interfaces.objects.SJavaInfo) SimpleDateFormat(java.text.SimpleDateFormat)

Example 42 with ServiceException

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

the class TestChangeWrappedValue method start.

private void start() {
    try {
        BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
        long poid = 2686977;
        long roid = 720899;
        SProject project = client.getServiceInterface().getProjectByPoid(poid);
        IfcModelInterface model = client.getModel(project, roid, true, false);
        for (IfcPropertySingleValue prop : model.getAll(IfcPropertySingleValue.class)) {
            // IfcValue value = ((IfcPropertySingleValue) prop).getNominalValue();
            // if(value instanceof IfcLabel){
            // System.out.println(prop.getOid() + " is " + ((IfcLabel) value).getWrappedValue() );
            // ((IfcLabel) value).setWrappedValue(((IfcLabel) value).getWrappedValue() + " changed");
            // }
            IfcLabel label = model.create(IfcLabel.class);
            label.setWrappedValue("blabla");
            prop.setNominalValue(label);
        }
        model.commit("blaat");
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (BimServerClientException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (IfcModelInterfaceException e) {
        e.printStackTrace();
    }
}
Also used : IfcModelInterfaceException(org.bimserver.emf.IfcModelInterfaceException) IfcPropertySingleValue(org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue) IfcLabel(org.bimserver.models.ifc2x3tc1.IfcLabel) ServiceException(org.bimserver.shared.exceptions.ServiceException) IfcModelInterface(org.bimserver.emf.IfcModelInterface) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException)

Example 43 with ServiceException

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

the class TestDownloadBinaryGeometrySimultanous method start.

private void start() {
    try {
        BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
        final SSerializerPluginConfiguration serializer = client.getServiceInterface().getSerializerByName("BinaryGeometrySerializer");
        SProject project = client.getServiceInterface().getProjectByPoid(131073L);
        for (int i = 0; i < 10; i++) {
            Thread.sleep(200);
            new Runner(client, serializer, project, i).start();
        }
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (InterruptedException 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 44 with ServiceException

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

the class TestManyUsersAndLogin method start.

private void start() {
    try {
        BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
        int nrUsers = 10000;
        long totalTimeAdding = 0;
        List<Long> userIds = new ArrayList<>();
        for (int i = 0; i < nrUsers; i++) {
            long s = System.nanoTime();
            try {
                SUser user = client.getServiceInterface().addUserWithPassword("test" + i + "@bimserver.org", "password", "Test " + i, SUserType.USER, true, "");
                userIds.add(user.getOid());
            } catch (Exception e) {
            }
            long e = System.nanoTime();
            totalTimeAdding += (e - s);
            if (i % 100 == 0) {
                System.out.println((totalTimeAdding / 1000000) + " ms for 100 users");
                totalTimeAdding = 0;
            }
        }
        long totalLoginTime = 0;
        int nrProjects = 10000;
        totalTimeAdding = 0;
        List<Long> projectIds = new ArrayList<>();
        for (int i = 0; i < nrProjects; i++) {
            long s = System.nanoTime();
            try {
                SProject project = client.getServiceInterface().addProject("test" + i, "ifc2x3tc1");
                projectIds.add(project.getOid());
            } catch (Exception e) {
            }
            long e = System.nanoTime();
            totalTimeAdding += (e - s);
            if (i % 100 == 0) {
                System.out.println((totalTimeAdding / 1000000) + " ms for 100 projects");
                totalTimeAdding = 0;
            }
        }
        int nrProjectUserLinks = 100000;
        Random random = new Random();
        totalTimeAdding = 0;
        for (int i = 0; i < nrProjectUserLinks; i++) {
            long s = System.nanoTime();
            client.getServiceInterface().addUserToProject(userIds.get(random.nextInt(userIds.size())), projectIds.get(random.nextInt(projectIds.size())));
            long e = System.nanoTime();
            totalTimeAdding += (e - s);
            if (i % 100 == 0) {
                System.out.println((totalTimeAdding / 1000000) + " ms for 100 projects/user links");
                totalTimeAdding = 0;
            }
        }
        int loginAttempts = 100;
        for (int i = 0; i < loginAttempts; i++) {
            long s = System.nanoTime();
            client.getAuthInterface().login("test" + new Random().nextInt(nrUsers) + "@bimserver.org", "password");
            long e = System.nanoTime();
            totalLoginTime += (e - s);
        }
        System.out.println("Average login time with " + nrUsers + " users in system: " + ((((totalLoginTime / loginAttempts) / 1000000) + " ms")));
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    }
}
Also used : Random(java.util.Random) ServiceException(org.bimserver.shared.exceptions.ServiceException) SUser(org.bimserver.interfaces.objects.SUser) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) ArrayList(java.util.ArrayList) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SProject(org.bimserver.interfaces.objects.SProject) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) ServiceException(org.bimserver.shared.exceptions.ServiceException)

Example 45 with ServiceException

use of org.bimserver.shared.exceptions.ServiceException 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.checkinSync(project.getOid(), "Test Model", deserializer.getOid(), false, 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)

Aggregations

ServiceException (org.bimserver.shared.exceptions.ServiceException)53 IOException (java.io.IOException)21 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)21 SProject (org.bimserver.interfaces.objects.SProject)19 DatabaseSession (org.bimserver.database.DatabaseSession)18 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)17 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)16 User (org.bimserver.models.store.User)13 Project (org.bimserver.models.store.Project)11 BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)11 UserException (org.bimserver.shared.exceptions.UserException)11 Date (java.util.Date)10 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)9 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)9 ChannelConnectionException (org.bimserver.shared.ChannelConnectionException)9 Path (java.nio.file.Path)8 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)8 ServerException (org.bimserver.shared.exceptions.ServerException)8 ArrayList (java.util.ArrayList)6 BimServerClientFactory (org.bimserver.shared.BimServerClientFactory)6