Search in sources :

Example 51 with UsernamePasswordAuthenticationInfo

use of org.bimserver.shared.UsernamePasswordAuthenticationInfo 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 52 with UsernamePasswordAuthenticationInfo

use of org.bimserver.shared.UsernamePasswordAuthenticationInfo 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 53 with UsernamePasswordAuthenticationInfo

use of org.bimserver.shared.UsernamePasswordAuthenticationInfo in project BIMserver by opensourceBIM.

the class LocalDevSetup method setupProtocolBuffers.

public static final BimServerClientInterface setupProtocolBuffers(String address) {
    Path home = Paths.get("home");
    Path tmp = home.resolve("tmp");
    MetaDataManager metaDataManager = new MetaDataManager(tmp);
    try (BimServerClientFactory factory = new ProtocolBuffersBimServerClientFactory(address, 8000, 8000, null, metaDataManager, new SServicesMap())) {
        PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(home);
        pluginManager.setMetaDataManager(metaDataManager);
        return factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
    } catch (PluginException e) {
        LOGGER.error("", e);
    } catch (ServiceException e) {
        LOGGER.error("", e);
    } catch (ChannelConnectionException e) {
        LOGGER.error("", e);
    } catch (BimServerClientException e) {
        LOGGER.error("", e);
    } catch (Exception e) {
        LOGGER.error("", e);
    }
    return null;
}
Also used : Path(java.nio.file.Path) PluginManager(org.bimserver.plugins.PluginManager) SServicesMap(org.bimserver.shared.meta.SServicesMap) ServiceException(org.bimserver.shared.exceptions.ServiceException) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) PluginException(org.bimserver.shared.exceptions.PluginException) MetaDataManager(org.bimserver.emf.MetaDataManager) ProtocolBuffersBimServerClientFactory(org.bimserver.client.protocolbuffers.ProtocolBuffersBimServerClientFactory) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) ProtocolBuffersBimServerClientFactory(org.bimserver.client.protocolbuffers.ProtocolBuffersBimServerClientFactory) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) BimServerClientFactory(org.bimserver.shared.BimServerClientFactory) SoapBimServerClientFactory(org.bimserver.client.soap.SoapBimServerClientFactory) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) PluginException(org.bimserver.shared.exceptions.PluginException) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException)

Example 54 with UsernamePasswordAuthenticationInfo

use of org.bimserver.shared.UsernamePasswordAuthenticationInfo in project BIMserver by opensourceBIM.

the class LocalDevSetup method setupJson.

/**
 * @param address
 * @return
 */
@SuppressWarnings("resource")
public static final BimServerClientInterface setupJson(String address) {
    try {
        Path home = Paths.get("home");
        if (!Files.isDirectory(home)) {
            Files.createDirectory(home);
        }
        Path tmp = home.resolve("tmp");
        if (!Files.isDirectory(tmp)) {
            Files.createDirectory(tmp);
        }
        MavenPluginRepository mavenPluginRepository = new MavenPluginRepository(home.resolve("maven"));
        PluginManager pluginManager = new PluginManager(tmp, home.resolve("plugins"), mavenPluginRepository, System.getProperty("java.class.path"), null, null, null);
        pluginManager.loadAllPluginsFromEclipseWorkspace(Paths.get("../"), true);
        MetaDataManager metaDataManager = new MetaDataManager(tmp);
        pluginManager.setMetaDataManager(metaDataManager);
        metaDataManager.init();
        pluginManager.initAllLoadedPlugins();
        BimServerClientFactory factory = new JsonBimServerClientFactory(metaDataManager, address);
        return factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
    } catch (PluginException e) {
        LOGGER.error("", e);
    } catch (ServiceException e) {
        LOGGER.error("", e);
    } catch (ChannelConnectionException e) {
        LOGGER.error("", e);
    } catch (IOException e) {
        LOGGER.error("", e);
    } catch (BimServerClientException e) {
        LOGGER.error("", e);
    }
    return null;
}
Also used : Path(java.nio.file.Path) PluginManager(org.bimserver.plugins.PluginManager) ServiceException(org.bimserver.shared.exceptions.ServiceException) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) MavenPluginRepository(org.bimserver.plugins.MavenPluginRepository) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) PluginException(org.bimserver.shared.exceptions.PluginException) MetaDataManager(org.bimserver.emf.MetaDataManager) IOException(java.io.IOException) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) ProtocolBuffersBimServerClientFactory(org.bimserver.client.protocolbuffers.ProtocolBuffersBimServerClientFactory) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) BimServerClientFactory(org.bimserver.shared.BimServerClientFactory) SoapBimServerClientFactory(org.bimserver.client.soap.SoapBimServerClientFactory)

Example 55 with UsernamePasswordAuthenticationInfo

use of org.bimserver.shared.UsernamePasswordAuthenticationInfo in project BIMserver by opensourceBIM.

the class LocalDevSetup method setupSoap.

public static final BimServerClientInterface setupSoap(String address) {
    try {
        Path home = Paths.get("home");
        Path tmp = home.resolve("tmp");
        PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(home);
        MetaDataManager metaDataManager = new MetaDataManager(tmp);
        pluginManager.setMetaDataManager(metaDataManager);
        try (BimServerClientFactory factory = new SoapBimServerClientFactory(metaDataManager, address)) {
            return factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        } catch (Exception e) {
            LOGGER.error("", e);
        }
    } catch (PluginException e) {
        LOGGER.error("", e);
    }
    return null;
}
Also used : Path(java.nio.file.Path) PluginManager(org.bimserver.plugins.PluginManager) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) PluginException(org.bimserver.shared.exceptions.PluginException) SoapBimServerClientFactory(org.bimserver.client.soap.SoapBimServerClientFactory) MetaDataManager(org.bimserver.emf.MetaDataManager) ProtocolBuffersBimServerClientFactory(org.bimserver.client.protocolbuffers.ProtocolBuffersBimServerClientFactory) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) BimServerClientFactory(org.bimserver.shared.BimServerClientFactory) SoapBimServerClientFactory(org.bimserver.client.soap.SoapBimServerClientFactory) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) PluginException(org.bimserver.shared.exceptions.PluginException) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException)

Aggregations

UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)55 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)46 SProject (org.bimserver.interfaces.objects.SProject)45 Test (org.junit.Test)41 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)27 URL (java.net.URL)20 LowLevelInterface (org.bimserver.shared.interfaces.LowLevelInterface)19 IfcModelInterface (org.bimserver.emf.IfcModelInterface)17 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)15 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)11 Path (java.nio.file.Path)10 IOException (java.io.IOException)9 ChannelConnectionException (org.bimserver.shared.ChannelConnectionException)9 BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)9 ServiceException (org.bimserver.shared.exceptions.ServiceException)9 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)8 BimServerClientFactory (org.bimserver.shared.BimServerClientFactory)7 UserException (org.bimserver.shared.exceptions.UserException)6 IfcPropertySingleValue (org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue)5 File (java.io.File)4