use of org.bimserver.shared.UsernamePasswordAuthenticationInfo in project BIMserver by opensourceBIM.
the class TriggerImportDataRemote method main.
public static void main(String[] args) {
/*
* Args:
* 0: Address of new server
* 1: Username
* 2: Password
* 3: Address of old server
* 4: Local path to incoming folder of old server, this local path has to be available on the new server, so you have to copy it from the old server
*/
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 (JsonBimServerClientFactory factory = new JsonBimServerClientFactory(metaDataManager, args[0])) {
BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo(args[1], args[2]));
client.getServiceInterface().importData(args[3], args[1], args[2], args[4]);
} catch (Exception e) {
e.printStackTrace();
}
} catch (PluginException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
}
}
use of org.bimserver.shared.UsernamePasswordAuthenticationInfo in project BIMserver by opensourceBIM.
the class TestIfcEngineEmbedded method main.
public static void main(String[] args) {
// Create a config
BimServerConfig config = new BimServerConfig();
Path home = Paths.get("home");
// Remove the home dir if it's there
if (WIPE_HOMEDIR) {
try {
PathUtils.removeDirectoryWithContent(home);
} catch (IOException e) {
e.printStackTrace();
}
}
config.setHomeDir(home);
config.setStartEmbeddedWebServer(true);
config.setPort(8080);
config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../")));
config.setClassPath(System.getProperty("java.class.path"));
// Create a BIMserver
BimServer bimServer = new BimServer(config);
BimServerClientInterface client = null;
try {
// Load plugins
Path[] pluginDirs = new Path[] {// TODO: Set these up yourself...
};
LocalDevPluginLoader.loadPlugins(bimServer.getPluginManager(), pluginDirs);
// Start it
bimServer.start();
// Get a client, not using any protocol (direct connection)
client = bimServer.getBimServerClientFactory().create();
// Setup the server
if (bimServer.getServerInfo().getServerState() == ServerState.NOT_SETUP) {
client.getAdminInterface().setup("http://localhost:8080", "Administrator", "admin@bimserver.org", "admin", null, null, null);
}
// Authenticate
client.setAuthentication(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// Iterate over the IfcEngines and see if there is one matching the classname specified above
boolean engineFound = false;
for (SRenderEnginePluginConfiguration conf : client.getPluginInterface().getAllRenderEngines(false)) {
SPluginDescriptor pluginDescriptor = client.getPluginInterface().getPluginDescriptor(conf.getPluginDescriptorId());
if (RENDER_ENGINE.equals(pluginDescriptor.getPluginClassName())) {
client.getPluginInterface().setDefaultRenderEngine(conf.getOid());
engineFound = true;
LOGGER.info("Using " + conf.getName());
break;
}
}
if (!engineFound) {
throw new RenderEngineException("No IfcEnginePlugin found with name " + RENDER_ENGINE);
}
// Get a deserializer
SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", -1L);
if (deserializer == null) {
throw new Exception("No deserializer found for IFC-SPF. Make sure plugin directories are correctly configured");
}
Thread[] threads = new Thread[TEST_FILES.length];
AddProjectCheckinDownloadAction[] contexts = new AddProjectCheckinDownloadAction[TEST_FILES.length];
for (int i = 0; i < TEST_FILES.length; ++i) {
(threads[i] = new Thread(contexts[i] = new AddProjectCheckinDownloadAction(bimServer, TEST_FILES[i]))).start();
}
for (int i = 0; i < TEST_FILES.length; ++i) {
threads[i].join();
}
for (int i = 0; i < TEST_FILES.length; ++i) {
contexts[i].verify();
}
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
} finally {
try {
client.disconnect();
} catch (Throwable t) {
}
try {
bimServer.stop();
} catch (Throwable t) {
}
}
}
use of org.bimserver.shared.UsernamePasswordAuthenticationInfo in project BIMserver by opensourceBIM.
the class TestListWalls method test.
@Test
public void test() {
try {
// Create a new BimServerClient with authentication
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// Create a new project
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Get the appropriate deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
// Checkin the file
bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/Jesse.1.ifc"));
// Refresh project info
newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), true, false);
model.getAllWithSubTypes(IfcWallStandardCase.class);
} catch (Throwable e) {
e.printStackTrace();
if (e instanceof AssertionError) {
throw (AssertionError) e;
}
fail(e.getMessage());
}
}
use of org.bimserver.shared.UsernamePasswordAuthenticationInfo in project BIMserver by opensourceBIM.
the class TestLoadCompleteModel method start.
@Test
public void start() {
try {
// New client
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// Create a project
SProject project = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Look for a deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
// Checkin file
bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
// Refresh project
project = bimServerClient.getServiceInterface().getProjectByPoid(project.getOid());
// Load model without lazy loading (complete model at once)
IfcModelInterface model = bimServerClient.getModel(project, project.getLastRevisionId(), false, true);
// Change the window names
for (IfcWindow window : model.getAllWithSubTypes(IfcWindow.class)) {
window.setName(window.getName() + " Changed");
}
long newRoid = model.commit("Changed window names");
IfcModelInterface newModel = bimServerClient.getModel(project, newRoid, true, false);
List<IfcWindow> windows = newModel.getAllWithSubTypes(Ifc2x3tc1Package.eINSTANCE.getIfcWindow());
for (IfcWindow window : windows) {
assertTrue(window.getName().endsWith(" Changed"));
}
} catch (Exception e) {
fail(e.getMessage());
}
}
use of org.bimserver.shared.UsernamePasswordAuthenticationInfo in project BIMserver by opensourceBIM.
the class TestMoveObject method test.
@Test
public void test() {
try {
// Create a new BimServerClient with authentication
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// Create a new project
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Get the appropriate deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
// Checkin the file
bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
// Refresh project info
newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), true, true);
for (IfcFurnishingElement ifcFurnishingElement : model.getAllWithSubTypes(IfcFurnishingElement.class)) {
IfcObjectPlacement objectPlacement = ifcFurnishingElement.getObjectPlacement();
if (objectPlacement != null && objectPlacement instanceof IfcLocalPlacement) {
IfcLocalPlacement localPlacement = (IfcLocalPlacement) objectPlacement;
IfcAxis2Placement relativePlacement = localPlacement.getRelativePlacement();
if (relativePlacement != null) {
if (relativePlacement instanceof IfcAxis2Placement3D) {
IfcAxis2Placement3D axis2Placement3D = (IfcAxis2Placement3D) relativePlacement;
IfcCartesianPoint location = axis2Placement3D.getLocation();
double newValue = location.getCoordinates().get(2) + 50;
System.out.println("Changing z value of " + ifcFurnishingElement.getName() + " from " + location.getCoordinates().get(2) + " to " + newValue);
location.getCoordinates().set(2, newValue);
}
}
}
}
long newRoid = model.commit("Moved all furniture 50 meters up");
SSerializerPluginConfiguration ifcSerializer = bimServerClient.getServiceInterface().getSerializerByContentType("application/ifc");
bimServerClient.download(newRoid, ifcSerializer.getOid(), Paths.get("movedf.ifc"));
} catch (Throwable e) {
e.printStackTrace();
if (e instanceof AssertionError) {
throw (AssertionError) e;
}
fail(e.getMessage());
}
}
Aggregations