use of net.geoprism.registry.UserInfo in project geoprism-registry by terraframe.
the class UserInfoPatch method doIt.
@Transaction
private void doIt() {
UserInfoQuery query = new UserInfoQuery(new QueryFactory());
try (OIterator<? extends UserInfo> it = query.getIterator()) {
while (it.hasNext()) {
UserInfo info = it.next();
info.appLock();
info.apply();
}
}
// Ensure all geoprism users have a user info
GeoprismUserQuery gQuery = new GeoprismUserQuery(new QueryFactory());
try (OIterator<? extends GeoprismUser> it = gQuery.getIterator()) {
while (it.hasNext()) {
GeoprismUser user = it.next();
UserInfo info = UserInfo.getByUser(user);
if (info == null) {
info = new UserInfo();
info.setGeoprismUser(user);
info.apply();
}
}
}
}
use of net.geoprism.registry.UserInfo in project geoprism-registry by terraframe.
the class RegistrySessionService method getActor.
@Transaction
private static synchronized SingleActorDAOIF getActor(OauthServer server, String username) throws JSONException {
UsersQuery query = new UsersQuery(new QueryFactory());
query.WHERE(query.getUsername().EQ(username));
OIterator<? extends Users> it = query.getIterator();
try {
if (it.hasNext()) {
UserDAO user = (UserDAO) BusinessFacade.getEntityDAO(it.next());
try {
GeoprismUser geoprismUser = GeoprismUser.getByUsername(user.getUsername());
UserInfo userInfo = UserInfo.getByUser(geoprismUser);
ExternalSystem system = ExternalSystem.get(userInfo.getExternalSystemOid());
if (system instanceof DHIS2ExternalSystem) {
DHIS2ExternalSystem dhis2System = (DHIS2ExternalSystem) system;
if (dhis2System.getOauthServerOid().equals(server.getOid())) {
return user;
}
}
} catch (Throwable t) {
logger.error("Encountered an unexpected error while logging user in.", t);
}
UserNotOuathEnabledException ex = new UserNotOuathEnabledException();
ex.setUsername(user.getUsername());
ex.setOauthServer(server.getDisplayLabel().getValue());
throw ex;
} else {
UserNotFoundException ex = new UserNotFoundException();
ex.setUsername(username);
throw ex;
}
} finally {
it.close();
}
}
use of net.geoprism.registry.UserInfo in project geoprism-registry by terraframe.
the class AccountServiceControllerTest method deleteUser.
public void deleteUser(String username) {
GeoprismUserQuery query = new GeoprismUserQuery(new QueryFactory());
query.WHERE(query.getUsername().EQ(username));
OIterator<? extends GeoprismUser> it = query.getIterator();
try {
if (it.hasNext()) {
GeoprismUser user = it.next();
UserInfo info = UserInfo.getByUser(user);
if (info != null) {
info.delete();
}
user.delete();
}
} finally {
it.close();
}
}
Aggregations