use of org.bimserver.database.actions.CloneToNewProjectDatabaseAction in project BIMserver by opensourceBIM.
the class ServiceImpl method clone.
@Override
public Long clone(Long roid, String projectName, String comment, Boolean sync) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.POSSIBLY_WRITE);
try {
CloneToNewProjectDatabaseAction action = new CloneToNewProjectDatabaseAction(session, getInternalAccessMethod(), getBimServer(), getAuthorization(), roid, projectName, comment);
User user = (User) session.get(StorePackage.eINSTANCE.getUser(), getAuthorization().getUoid(), OldQuery.getDefault());
String username = user.getName();
String userUsername = user.getUsername();
LongCopyAction longAction = new LongCopyAction(getBimServer(), username, userUsername, getAuthorization(), action);
getBimServer().getLongActionManager().start(longAction);
if (sync) {
longAction.waitForCompletion();
}
return longAction.getProgressTopic().getKey().getId();
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
Aggregations