use of org.bimserver.shared.BimServerClientFactory in project BIMserver by opensourceBIM.
the class ServiceImpl method getServiceDescriptor.
@Override
public SServiceDescriptor getServiceDescriptor(String baseUrl, String serviceIdentifier) throws ServerException, UserException {
requireRealUserAuthentication();
try {
try (BimServerClientFactory factory = new JsonBimServerClientFactory(baseUrl, getBimServer().getServicesMap(), getBimServer().getJsonSocketReflectorFactory(), getBimServer().getReflectorFactory(), getBimServer().getMetaDataManager())) {
BimServerClientInterface client = factory.create();
SServiceDescriptor service = client.getRemoteServiceInterface().getService(serviceIdentifier);
if (service == null) {
throw new UserException("No service found with identifier " + serviceIdentifier);
}
service.setUrl(baseUrl);
return service;
}
} catch (Exception e) {
return handleException(e);
}
}
use of org.bimserver.shared.BimServerClientFactory in project BIMserver by opensourceBIM.
the class TestMultiple method main.
public static void main(String[] args) throws InterruptedException {
try (BimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
BimServerClientInterface client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 2, 1, TimeUnit.DAYS, new ArrayBlockingQueue<>(2));
for (int i = 0; i < 2; i++) {
executor.submit(new Runnable() {
@Override
public void run() {
try {
SProject project = client.getServiceInterface().addProject("P" + new Random().nextInt(), "ifc2x3tc1");
SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
client.checkin(project.getOid(), "Test", deserializer.getOid(), false, Flow.ASYNC, Paths.get("C:\\Git\\TestFiles\\TestData\\data\\HITOS_070308.ifc"));
} catch (ServerException e) {
e.printStackTrace();
} catch (UserException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
executor.shutdown();
executor.awaitTermination(1, TimeUnit.HOURS);
} catch (BimServerClientException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
} catch (ChannelConnectionException e) {
e.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
}
}
use of org.bimserver.shared.BimServerClientFactory 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;
}
use of org.bimserver.shared.BimServerClientFactory 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;
}
use of org.bimserver.shared.BimServerClientFactory 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;
}
Aggregations