如何使用Java为用户将IFC文件签入BIMserver

时间:2018-06-20 05:50:53

标签: java ifc bim

以下代码是Opensource BIMserver的Java客户端的一部分。

JsonBimServerClientFactory factory = new JsonBimServerClientFactory("");
BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("exple@dd.com", "poiuy"));
String randomName = "yu" + new Random().nextLong();

// Create a new project with a random name
SProject project = client.getServiceInterface().addProject(randomName, "ifc2x3tc1");
long poid = project.getOid();
String comment = "";

// This method is an easy way to find a compatible deserializer for the combination of
// the "ifc" file extension and this project. You can also get a specific deserializer
// if you want to.
SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", poid);

// Make sure you change this to a path to a local IFC file
String absolutePathOfFile = servletContext.getRealPath("/") + "resources/images/IFC/stickfile.ifc";

java.nio.file.Path demoIfcFile = Paths.get(absolutePathOfFile);
// Here we actually checkin the IFC file.

如果用户属于“管理员”类型,但不适用于“用户”类型的用户,则以上代码可用于检入IFC文件。那么如何为没有管理员权限的用户签入IFC文件呢?

1 个答案:

答案 0 :(得分:0)

“用户”类型的用户无法创建项目。如果创建的用户类型为“管理员”,则必须使用

授予该项目“用户”类型的用户权限
client.getServiceInterface().addUserToProject(userOid, projectOid)

addProject调用中,代码可能已经失败。请使用stacktrace和服务调用返回的错误消息进行确认。