Search in sources :

Example 1 with UserInfo

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();
            }
        }
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) GeoprismUserQuery(net.geoprism.GeoprismUserQuery) UserInfo(net.geoprism.registry.UserInfo) GeoprismUser(net.geoprism.GeoprismUser) UserInfoQuery(net.geoprism.registry.UserInfoQuery) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 2 with UserInfo

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();
    }
}
Also used : UserNotFoundException(net.geoprism.registry.session.UserNotFoundException) UserNotOuathEnabledException(net.geoprism.registry.session.UserNotOuathEnabledException) QueryFactory(com.runwaysdk.query.QueryFactory) UserDAO(com.runwaysdk.business.rbac.UserDAO) DHIS2ExternalSystem(net.geoprism.registry.graph.DHIS2ExternalSystem) UsersQuery(com.runwaysdk.system.UsersQuery) DHIS2ExternalSystem(net.geoprism.registry.graph.DHIS2ExternalSystem) ExternalSystem(net.geoprism.registry.graph.ExternalSystem) GeoprismUser(net.geoprism.GeoprismUser) UserInfo(net.geoprism.registry.UserInfo) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 3 with UserInfo

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();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) GeoprismUserQuery(net.geoprism.GeoprismUserQuery) GeoprismUser(net.geoprism.GeoprismUser) UserInfo(net.geoprism.registry.UserInfo)

Aggregations

QueryFactory (com.runwaysdk.query.QueryFactory)3 GeoprismUser (net.geoprism.GeoprismUser)3 UserInfo (net.geoprism.registry.UserInfo)3 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)2 GeoprismUserQuery (net.geoprism.GeoprismUserQuery)2 UserDAO (com.runwaysdk.business.rbac.UserDAO)1 UsersQuery (com.runwaysdk.system.UsersQuery)1 UserInfoQuery (net.geoprism.registry.UserInfoQuery)1 DHIS2ExternalSystem (net.geoprism.registry.graph.DHIS2ExternalSystem)1 ExternalSystem (net.geoprism.registry.graph.ExternalSystem)1 UserNotFoundException (net.geoprism.registry.session.UserNotFoundException)1 UserNotOuathEnabledException (net.geoprism.registry.session.UserNotOuathEnabledException)1