Search in sources :

Example 1 with DirectBimServerClientFactory

use of org.bimserver.client.DirectBimServerClientFactory in project BIMserver by opensourceBIM.

the class AllTests method setup.

private static void setup() {
    // Create a config
    Path home = Paths.get("tmptestdata/home-" + new Random().nextInt(1000000000));
    // Remove the home dir if it's there
    if (Files.exists(home)) {
        try {
            PathUtils.removeDirectoryWithContent(home);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    BimServerConfig config = new BimServerConfig();
    config.setHomeDir(home);
    config.setStartEmbeddedWebServer(true);
    config.setPort(7010);
    config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../")));
    config.setClassPath(System.getProperty("java.class.path"));
    bimServer = new BimServer(config);
    try {
        bimServer.setEmbeddedWebServer(new EmbeddedWebServer(bimServer, null, false));
        // CHANGE THESE TO MATCH YOUR CONFIGURATION
        // Path[] pluginDirectories = new Path[]{Paths.get("C:\\Git\\IfcPlugins\\IfcPlugins"), Paths.get("C:\\Git\\IfcOpenShell-BIMserver-plugin")};
        // Start it
        bimServer.start();
        // Load plugins
        // LocalDevPluginLoader.loadPlugins(bimServer.getPluginManager(), pluginDirectories);
        // Get a client, not using any protocol (direct connection)
        BimServerClientInterface client = bimServer.getBimServerClientFactory().create();
        // Setup the server
        client.getAdminInterface().setup("http://localhost:7010", "Test Name", "Test Description", "noicon", "Administrator", "admin@bimserver.org", "admin");
        ServiceMap serviceMap = bimServer.getServiceFactory().get(new SystemAuthorization(1, TimeUnit.HOURS), AccessMethod.INTERNAL);
        serviceMap.getSettingsInterface().setCacheOutputFiles(false);
        ((DirectBimServerClientFactory) bimServer.getBimServerClientFactory()).setBaseAddress("http://localhost:7010");
        client.disconnect();
        client = bimServer.getBimServerClientFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        String pluginsString = System.getProperty("plugins");
        if (pluginsString != null) {
            String[] plugins = pluginsString.split(";");
            Path[] paths = new Path[plugins.length];
            int i = 0;
            for (String p : plugins) {
                paths[i++] = Paths.get(p);
            }
            LocalDevPluginLoader.loadPlugins(bimServer.getPluginBundleManager(), paths);
        } else {
            LoggerFactory.getLogger(AllTests.class).info("Installing plugins");
            client.getPluginInterface().installPluginBundle("https://repo1.maven.org/maven2/", "org.opensourcebim", "ifcplugins", null, null);
            client.getPluginInterface().installPluginBundle("https://repo1.maven.org/maven2/", "org.opensourcebim", "binaryserializers", null, null);
            client.getPluginInterface().installPluginBundle("https://repo1.maven.org/maven2/", "org.opensourcebim", "ifcopenshellplugin", null, null);
        }
        client.disconnect();
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : Path(java.nio.file.Path) ServiceMap(org.bimserver.webservices.ServiceMap) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) BimServer(org.bimserver.BimServer) IOException(java.io.IOException) SystemAuthorization(org.bimserver.webservices.authorization.SystemAuthorization) BimServerConfig(org.bimserver.BimServerConfig) LocalDevelopmentResourceFetcher(org.bimserver.shared.LocalDevelopmentResourceFetcher) EmbeddedWebServer(org.bimserver.EmbeddedWebServer) IOException(java.io.IOException) Random(java.util.Random) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) DirectBimServerClientFactory(org.bimserver.client.DirectBimServerClientFactory)

Aggregations

IOException (java.io.IOException)1 Path (java.nio.file.Path)1 Random (java.util.Random)1 BimServer (org.bimserver.BimServer)1 BimServerConfig (org.bimserver.BimServerConfig)1 EmbeddedWebServer (org.bimserver.EmbeddedWebServer)1 DirectBimServerClientFactory (org.bimserver.client.DirectBimServerClientFactory)1 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)1 LocalDevelopmentResourceFetcher (org.bimserver.shared.LocalDevelopmentResourceFetcher)1 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)1 ServiceMap (org.bimserver.webservices.ServiceMap)1 SystemAuthorization (org.bimserver.webservices.authorization.SystemAuthorization)1