@Override public String getEventDescription() { return "disabling user: " + getId(); }
/** * {@inheritDoc} */ @Override public UserAccount enableUser(EnableUserCmd cmd) { return _regionMgr.enableUser(cmd.getId()); }
/** * TODO: this should be done through a validator. for now replicating the validation logic in create account and user */ private void validateParams() { if(StringUtils.isEmpty(getPassword())) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Empty passwords are not allowed"); } } }
@Override public void execute() { CallContext.current().setEventDetails("UserId: " + getId()); boolean result = _regionService.deleteUser(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete user"); } } }
@Override public void execute() { UserAccount user = _accountService.lockUser(getId()); if (user != null) { UserResponse response = _responseGenerator.createUserResponse(user); response.setResponseName(getCommandName()); this.setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to lock user"); } } }
/** * Searches for a user with the given userId. If no user is found we throw an {@link InvalidParameterValueException}. */ protected UserVO retrieveAndValidateUser(UpdateUserCmd updateUserCmd) { Long userId = updateUserCmd.getId(); UserVO user = _userDao.getUser(userId); if (user == null) { throw new InvalidParameterValueException("Unable to find user with id: " + userId); } return user; }
@Override public void execute() { ListResponse<UserResponse> response = _queryService.searchForUsers(this); response.setResponseName(getCommandName()); this.setResponseObject(response); } }
@Override public long getEntityOwnerId() { User user = _entityMgr.findById(User.class, getId()); if (user != null) { return user.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public long getEntityOwnerId() { User user = _entityMgr.findById(User.class, getId()); if (user != null) { return user.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
public long getEntityOwnerId(){ User user = _entityMgr.findById(User.class, getID()); if(user != null){ return user.getAccountId(); } else return Account.ACCOUNT_ID_SYSTEM; } public void execute(){
@Override public long getEntityOwnerId() { User user = _entityMgr.findById(User.class, getId()); if (user != null) { return user.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
public void execute(){ Map<String, String> keys = _accountService.getKeys(this); RegisterResponse response = new RegisterResponse(); if(keys != null){ response.setApiKey(keys.get("apikey")); response.setSecretKey(keys.get("secretkey")); } response.setObjectName("userkeys"); response.setResponseName(getCommandName()); this.setResponseObject(response); } }
@Override public void execute() { String[] keys = _accountService.createApiKeyAndSecretKey(this); RegisterResponse response = new RegisterResponse(); if (keys != null) { response.setApiKey(keys[0]); response.setSecretKey(keys[1]); } response.setObjectName("userkeys"); response.setResponseName(getCommandName()); this.setResponseObject(response); } }
@Override public long getEntityOwnerId() { User user = _entityMgr.findById(User.class, getId()); if (user != null) { return user.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
/** * Validates the user 'lastName' if provided. The 'lastName' cannot be blank (when provided). * <ul> * <li> If the 'lastName' is not provided, we do not update it (setting to null) in the User POJO. * <li> If the 'lastName' is blank, we throw an {@link InvalidParameterValueException}. * </ul> */ protected void validateAndUpdateLastNameIfNeeded(UpdateUserCmd updateUserCmd, UserVO user) { String lastName = updateUserCmd.getLastname(); if (lastName != null) { if (StringUtils.isBlank(lastName)) { throw new InvalidParameterValueException("Lastname cannot be empty."); } user.setLastname(lastName); } }
/** * Validates the user 'firstName' if provided. The 'firstName' cannot be blank (when provided). * <ul> * <li> If the 'firstName' is not provided, we do not update it (setting to null) in the User POJO. * <li> If the 'firstName' is blank, we throw an {@link InvalidParameterValueException}. * </ul> */ protected void validateAndUpdateFirstNameIfNeeded(UpdateUserCmd updateUserCmd, UserVO user) { String firstName = updateUserCmd.getFirstname(); if (firstName != null) { if (StringUtils.isBlank(firstName)) { throw new InvalidParameterValueException("Firstname cannot be empty."); } user.setFirstname(firstName); } }
/** * {@inheritDoc} */ @Override public UserAccount disableUser(DisableUserCmd cmd) { return _regionMgr.disableUser(cmd.getId()); }
@Override public long getEntityOwnerId() { User user = _entityMgr.findById(User.class, getId()); if (user != null) { return user.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public long getEntityOwnerId() { User user = _entityMgr.findById(User.class, getId()); if (user != null) { return user.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public long getEntityOwnerId() { User user = _entityMgr.findById(User.class, getId()); if (user != null) { return user.getAccountId(); } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }