Retrieve a user by its ID, and create a new one if requested.

@return An existing or created user. May be {@code null} if a user does not exist and
{@code create} is false.
5319
private static @Nullable
    User getOrCreateById(@Nonnull String id, @Nonnull String fullName, boolean create) {
        User u = AllUsers.get(id);
        if (u == null && (create || UserIdMapper.getInstance().isMapped(id))) {
            u = new User(id, fullName);
            AllUsers.put(id, u);
            if (!id.equals(fullName) && !UserIdMapper.getInstance().isMapped(id)) {
                try {
                    u.save();
                } catch (IOException x) {
                    LOGGER.log(Level.WARNING, "Failed to save user configuration for " + id, x);
                }
            }
        }
        return u;
    }
770267
public User getUser() {
        ClientResource resource = new ClientResource(Route.ME.url());
        resource.setChallengeResponse(this.auth.toChallenge());

        try {
            Representation repr = resource.get();
            return mapper.readValue(repr.getText(), User.class);
        } catch (IOException ex) {
            LEX4JLogger.log(Level.WARNING, "Could not retrieve user (me) correctly!");
            return null;
        }
    }
387449
@Nullable
  public StitchUserT getUser() {
    authLock.readLock().lock();
    try {
      return activeUser;
    } finally {
      authLock.readLock().unlock();
    }
  }
1092478
@Override
    public final T get() {
        if (obj == null) {
            synchronized (lock) {
                if (obj == null) {
                    obj = create();
                }
            }
        }
        return obj;
    }
247478
public User getActiveUser() {
        SharedPreferences prefs = getStorage();
        if (prefs.contains("uuid") && prefs.contains("name")) {
            return new User(
                    prefs.getString("app_name", ""),
                    prefs.getString("name", ""),
                    prefs.getString("uuid", ""),
                    null);
        } else {
            return null;
        }
    }
1228369
public boolean isExistingID() {
        try {
            String userId= getPost().getString(Defines.Jsonkey.Identity.getKey());
            return (userId != null && userId.equals(prefHelper_.getIdentity()));
        } catch (JSONException e) {
            e.printStackTrace();
            return false;
        }

    }
5652
private String getUserFromUniqueID(String id) {
        if (id == null) {
            return "";
        }
        id = id.trim();
        int realmDelimiterIndex = id.indexOf("/");
        if (realmDelimiterIndex < 0) {
            return "";
        } else {
            return id.substring(realmDelimiterIndex + 1);
        }
    }
1111460
public User createUser(final User user) throws UnauthorizedException {
        User requestingUser = getCurrentUser();
        if (requestingUser != null && !requestingUser.isAdmin()) {
            throw new UnauthorizedException("Only admins can create new accounts!");
        }
        tt.execute(new TransactionCallbackWithoutResult() {
            public void doInTransactionWithoutResult(TransactionStatus status) {
                boolean success = false;
                try {
                    PasswordEncoder encoder = new ShaPasswordEncoder();
                    String hashedPass = encoder.encodePassword(user.getPassword(), null);
                    user.setId(insert(
                            "INSERT INTO Users (username, password, enabled) "
                            + "VALUES (?, ?, ?)", user.getName(),
                            hashedPass, user.isEnabled()));
                    addAuthority(user.getName(), ROLE_USER);
                    if (user.isAdmin()) {
                        addAuthority(user.getName(), ROLE_ADMIN);
                    }
                    success = true;
                } finally {
                    if (!success) {
                        status.setRollbackOnly();
                    }
                }
            }
        });
        return user;
    }
727000
public static String createUniqueIdentifier() {
		String id;
		do {
			id = UUID.randomUUID().toString();
		} while (getSREFromId(id) != null);
		return id;
	}
963718
public Entity newEntity(QualifiedName id) {
	Entity res = of.createEntity();
	res.setId(id);
	return res;
    }
210870
public static function create($id = null)
    {
        if ( empty($id) )
        {
            $id = md5(__METHOD__) . count(self::$instances); 
        }
        if ( empty(self::$instances[$id]) )
        {
            self::$instances[$id] = new self();  
        }
        return self::$instances[$id];
    }
595901
public UserHousingComplexUnit instantiateForInsert() {
		UserHousingComplexUnit entity = new UserHousingComplexUnit();
		entity.setIsDeleted(Boolean.FALSE);
		return entity;
    }
1314067
@Override
    public User createUser(String username, String password)
            throws AuthenticationException {
        String user = file_store.getProperty(username);
        if (user != null) {
            throw new AuthenticationException("User '" + username
                    + "' already exists.");
        }
        // Encrypt the new password
        String ePwd = encryptPassword(password);
        file_store.put(username, ePwd);
        try {
            saveUsers();
        } catch (IOException e) {
            throw new AuthenticationException("Error changing password: ", e);
        }

        return getUser(username);
    }
981920
def get_or_create_person(self, row):
        
        person, created = entity.Person.objects.get_or_create(
            first_name=row["first"], last_name=row["last"]
        )

        return person
149047
public Response createUser(UserEntity userEntity) {
		return restClient.post("users", userEntity, new HashMap<String, String>());
	}
769129
public static  UUID getOrCreateUserToken() {
        UUID userToken;
        if (Request.getPerThreadRequestData().getRequestId() != null) {
            try {
                userToken = UUID.fromString(Request.getPerThreadRequestData().getRequestId());
            } catch (final IllegalArgumentException ignored) {
                userToken = UUIDs.randomUUID();
            }
        } else {
            userToken = UUIDs.randomUUID();
        }
        return userToken;
    }
904576
def created_by(self):
        
        if self.api and self.created_by_id:
            return self.api._get_user(self.created_by_id)