use of org.bimserver.interfaces.SConverter in project BIMserver by opensourceBIM.
the class AddExtendedDataToProjectDatabaseAction method execute.
@Override
public Long execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
super.execute();
User actingUser = getUserByUoid(authorization.getUoid());
Project project = getProjectByPoid(poid);
if (project == null) {
throw new UserException("Project with poid " + poid + " not found");
}
project.getExtendedData().add(getIdEObject());
getDatabaseSession().store(project);
final ExtendedDataAddedToProject extendedDataAddedToProject = getDatabaseSession().create(ExtendedDataAddedToProject.class);
extendedDataAddedToProject.setAccessMethod(getAccessMethod());
extendedDataAddedToProject.setDate(new Date());
extendedDataAddedToProject.setExecutor(actingUser);
extendedDataAddedToProject.setExtendedData(getIdEObject());
extendedDataAddedToProject.setProject(project);
getDatabaseSession().addPostCommitAction(new PostCommitAction() {
@Override
public void execute() throws UserException {
bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(extendedDataAddedToProject));
}
});
return null;
}
use of org.bimserver.interfaces.SConverter in project BIMserver by opensourceBIM.
the class ChangeUserTypeDatabaseAction method execute.
@Override
public Void execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
User actingUser = getUserByUoid(authorization.getUoid());
if (actingUser.getUserType() != UserType.ADMIN) {
throw new UserException("Only admin users can change other user's types");
}
User user = getUserByUoid(uoid);
if (user.getUserType() == UserType.SYSTEM) {
throw new UserException("Type of system user cannot be changed");
}
user.setUserType(UserType.get(userType.getOrdinal()));
final UserChanged userChanged = getDatabaseSession().create(UserChanged.class);
userChanged.setAccessMethod(getAccessMethod());
userChanged.setDate(new Date());
userChanged.setExecutor(actingUser);
userChanged.setUser(user);
getDatabaseSession().addPostCommitAction(new PostCommitAction() {
@Override
public void execute() throws UserException {
bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(userChanged));
}
});
getDatabaseSession().store(user);
return null;
}
use of org.bimserver.interfaces.SConverter in project BIMserver by opensourceBIM.
the class DeleteProjectDatabaseAction method execute.
@Override
public Boolean execute() throws UserException, BimserverDatabaseException, BimserverLockConflictException {
User actingUser = getUserByUoid(authorization.getUoid());
final Project project = getProjectByPoid(poid);
if (actingUser.getUserType() == UserType.ADMIN || (actingUser.getHasRightsOn().contains(project) && bimServer.getServerSettingsCache().getServerSettings().isAllowUsersToCreateTopLevelProjects())) {
delete(project);
final ProjectDeleted projectDeleted = getDatabaseSession().create(ProjectDeleted.class);
projectDeleted.setAccessMethod(getAccessMethod());
projectDeleted.setDate(new Date());
projectDeleted.setExecutor(actingUser);
projectDeleted.setProject(project);
getDatabaseSession().addPostCommitAction(new PostCommitAction() {
@Override
public void execute() throws UserException {
bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(projectDeleted));
}
});
getDatabaseSession().store(project);
return true;
} else {
throw new UserException("No rights to delete this project");
}
}
use of org.bimserver.interfaces.SConverter in project BIMserver by opensourceBIM.
the class RemoveUserFromProjectDatabaseAction method execute.
@Override
public Boolean execute() throws UserException, BimserverDatabaseException, BimserverLockConflictException {
User user = getUserByUoid(uoid);
Project project = getProjectByPoid(poid);
User actingUser = getUserByUoid(authorization.getUoid());
if (authorization.hasRightsOnProject(actingUser, project)) {
if (user.getUserType() == UserType.ADMIN) {
int nrAdmins = 0;
for (User authUser : project.getHasAuthorizedUsers()) {
if (authUser.getUserType() == UserType.ADMIN) {
nrAdmins++;
}
}
if (nrAdmins == 1) {
throw new UserException("User cannot be removed from this project because it is the only admin user with authorization on this project");
}
}
project.getHasAuthorizedUsers().remove(user);
user.getHasRightsOn().remove(project);
final UserRemovedFromProject userRemovedFromProject = getDatabaseSession().create(UserRemovedFromProject.class);
userRemovedFromProject.setDate(new Date());
userRemovedFromProject.setExecutor(actingUser);
userRemovedFromProject.setAccessMethod(getAccessMethod());
userRemovedFromProject.setProject(project);
userRemovedFromProject.setUser(user);
getDatabaseSession().addPostCommitAction(new PostCommitAction() {
@Override
public void execute() throws UserException {
bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(userRemovedFromProject));
}
});
getDatabaseSession().store(user);
getDatabaseSession().store(project);
return true;
} else {
throw new UserException("Insufficient rights to remove user from project");
}
}
use of org.bimserver.interfaces.SConverter in project BIMserver by opensourceBIM.
the class UpdateGeoTagDatabaseAction method execute.
@Override
public Void execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
User actingUser = getUserByUoid(authorization.getUoid());
GeoTag geoTag = (GeoTag) getDatabaseSession().get(StorePackage.eINSTANCE.getGeoTag(), sGeoTag.getOid(), OldQuery.getDefault());
boolean hasRights = false;
for (Project project : geoTag.getProjects()) {
if (authorization.hasRightsOnProject(actingUser, project)) {
hasRights = true;
continue;
}
}
if (hasRights) {
geoTag.setEnabled(sGeoTag.getEnabled());
geoTag.setX(sGeoTag.getX());
geoTag.setY(sGeoTag.getY());
geoTag.setZ(sGeoTag.getZ());
geoTag.setDirectionAngle(sGeoTag.getDirectionAngle());
geoTag.setEpsg(sGeoTag.getEpsg());
final GeoTagUpdated geoTagUpdated = getDatabaseSession().create(GeoTagUpdated.class);
geoTagUpdated.setGeoTag(geoTag);
geoTagUpdated.setAccessMethod(getAccessMethod());
geoTagUpdated.setDate(new Date());
geoTagUpdated.setExecutor(actingUser);
getDatabaseSession().addPostCommitAction(new PostCommitAction() {
@Override
public void execute() throws UserException {
bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(geoTagUpdated));
}
});
getDatabaseSession().store(geoTag);
} else {
throw new UserException("User has no rights on any projects associated with this geotag");
}
return null;
}
Aggregations