/** * Adds the robot to the account store and notifies the listeners. */ private RobotAccountData registerRobot(ParticipantId robotId, String location) throws RobotRegistrationException, PersistenceException { String robotLocation = computeValidateRobotUrl(location); RobotAccountData robotAccount = new RobotAccountDataImpl(robotId, robotLocation, tokenGenerator.generateToken(TOKEN_LENGTH), null, true); accountStore.putAccount(robotAccount); for (Listener listener : listeners) { listener.onRegistrationSuccess(robotAccount); } return robotAccount; }
/** * Removes the robot account and notifies the listeners. * @param existingAccount the account to remove * @throws PersistenceException if the persistence layer reports an error. */ private void removeRobotAccount(RobotAccountData existingAccount) throws PersistenceException { accountStore.removeAccount(existingAccount.getId()); for (Listener listener : listeners) { listener.onUnregistrationSuccess(existingAccount); } }