use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.
the class ServiceImpl method branchToNewProject.
@Override
public Long branchToNewProject(Long roid, String projectName, String comment, Boolean sync) throws UserException, ServerException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
BranchToNewProjectDatabaseAction action = new BranchToNewProjectDatabaseAction(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();
LongBranchAction longAction = new LongBranchAction(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();
}
}
use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.
the class ServiceImpl method addExtendedDataToRevision.
@Override
public void addExtendedDataToRevision(Long roid, SExtendedData extendedData) throws ServerException, UserException {
requireAuthenticationAndRunningServer();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
ExtendedData convert = getBimServer().getSConverter().convertFromSObject(extendedData, session.create(ExtendedData.class), session);
session.executeAndCommitAction(new AddExtendedDataToRevisionDatabaseAction(getBimServer(), session, getInternalAccessMethod(), roid, getAuthorization(), convert));
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.
the class ServiceImpl method getExtendedDataSchemaById.
@Override
public SExtendedDataSchema getExtendedDataSchemaById(Long oid) throws ServerException, UserException {
requireAuthenticationAndRunningServer();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
return getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(new GetExtendedDataSchemaByIdDatabaseAction(session, getInternalAccessMethod(), oid)));
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
return null;
}
use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.
the class ServiceImpl method getAllUsers.
@Override
public List<SUser> getAllUsers() throws ServerException, UserException {
if (getBimServer().getServerSettingsCache().getServerSettings().getHideUserListForNonAdmin()) {
if (getCurrentUser().getUserType() != SUserType.ADMIN) {
throw new UserException("Admin rights required to list users");
}
}
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
BimDatabaseAction<Set<User>> action = new GetAllUsersDatabaseAction(session, getInternalAccessMethod(), getAuthorization());
List<SUser> convertToSListUser = getBimServer().getSConverter().convertToSListUser(session.executeAndCommitAction(action));
Collections.sort(convertToSListUser, new SUserComparator());
return convertToSListUser;
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.shared.exceptions.UserException in project BIMserver by opensourceBIM.
the class ServiceImpl method updateModelChecker.
@Override
public void updateModelChecker(SModelCheckerInstance modelCheckerInstance) throws UserException, ServerException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
BimDatabaseAction<Void> action = new UpdateModelCheckerDatabaseAction(getBimServer(), session, getInternalAccessMethod(), getBimServer().getSConverter().convertFromSObject(modelCheckerInstance, session));
session.executeAndCommitAction(action);
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
}
Aggregations