use of org.bimserver.models.log.GeoTagUpdated 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