@Override
    public CurrentUserBean getInfo() {
        String userId = securityContext.getCurrentUser();

        try {
            CurrentUserBean rval = new CurrentUserBean();
            UserBean user;
            storage.beginTx();
            try {
                user = storage.getUser(userId);
            } finally {
                storage.rollbackTx();
            }
            if (user == null) {
                user = new UserBean();
                user.setUsername(userId);
                if (securityContext.getFullName() != null) {
                    user.setFullName(securityContext.getFullName());
                } else {
                    user.setFullName(userId);
                }
                if (securityContext.getEmail() != null) {
                    user.setEmail(securityContext.getEmail());
                } else {
                    user.setEmail(""); //$NON-NLS-1$
                }
                user.setJoinedOn(new Date());
                storage.beginTx();
                try {
                    storage.createUser(user);
                    userBootstrapper.bootstrapUser(user, storage);
                    storage.commitTx();
                } catch (StorageException e1) {
                    storage.rollbackTx();
                    throw new SystemErrorException(e1);
                }
                rval.initFromUser(user);
                rval.setAdmin(securityContext.isAdmin());
                rval.setPermissions(new HashSet<>());
            } else {
                rval.initFromUser(user);
                Set<PermissionBean> permissions = query.getPermissions(userId);
                rval.setPermissions(permissions);
                rval.setAdmin(securityContext.isAdmin());
            }

            log.debug(String.format("Getting info for user %s", user.getUsername())); //$NON-NLS-1$
            return rval;
        } catch (StorageException e) {
            throw new SystemErrorException(e);
        }
    }
@ Override public CurrentUserBean getInfo ( ) { String userId = securityContext . getCurrentUser ( ) ; try { CurrentUserBean rval = new CurrentUserBean ( ) ; UserBean user ; storage . beginTx ( ) ; try { user = storage . getUser ( userId ) ; } finally { storage . rollbackTx ( ) ; } if ( user == null ) { user = new UserBean ( ) ; user . setUsername ( userId ) ; if ( securityContext . getFullName ( ) != null ) { user . setFullName ( securityContext . getFullName ( ) ) ; } else { user . setFullName ( userId ) ; } if ( securityContext . getEmail ( ) != null ) { user . setEmail ( securityContext . getEmail ( ) ) ; } else { user . setEmail ( "" ) ; } user . setJoinedOn ( new Date ( ) ) ; storage . beginTx ( ) ; try { storage . createUser ( user ) ; userBootstrapper . bootstrapUser ( user , storage ) ; storage . commitTx ( ) ; } catch ( StorageException e1 ) { storage . rollbackTx ( ) ; throw new SystemErrorException ( e1 ) ; } rval . initFromUser ( user ) ; rval . setAdmin ( securityContext . isAdmin ( ) ) ; rval . setPermissions ( new HashSet < > ( ) ) ; } else { rval . initFromUser ( user ) ; Set < PermissionBean > permissions = query . getPermissions ( userId ) ; rval . setPermissions ( permissions ) ; rval . setAdmin ( securityContext . isAdmin ( ) ) ; } log . debug ( String . format ( "Getting info for user %s" , user . getUsername ( ) ) ) ; return rval ; } catch ( StorageException e ) { throw new SystemErrorException ( e ) ; } }
@see io.apiman.manager.api.rest.contract.ICurrentUserResource#getInfo()