// Path: src/main/java/org/nextrtc/examples/videochat_with_rest/service/RegisterUserService.java
// @Service
// @Transactional
// public class RegisterUserService {
// 
//     private static final Logger log = Logger.getLogger(RegisterUserService.class);
//     @Autowired
//     private UserRepository userRepository;
// 
//     @Autowired
//     private PasswordEncoder encoder;
// 
//     public String generateConfirmationKey() {
//     	return UUID.randomUUID().toString();
//     }
//     
//     public void register(String username, String password, String email, String confirmationKey) {
//         if (userRepository.findByUsername(username).isPresent()) {
//             throw new RuntimeException("user exists!");
//         }
//         if (userRepository.findByEmail(email).isPresent()) {
//             throw new RuntimeException("email is occupied!");
//         }
// 
//         User user = new User(username, encoder.encode(password), email, confirmationKey);
// 
//         //TODO: send email
// 
//         userRepository.save(user);
//     }
// 
//     public void register(String name, String email, String providerId) {
//         if (!userRepository.findByAuthProviderId(providerId).isPresent()) {
//             userRepository.save(new User(name, email, providerId));
//         }
//     }
// }


import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.nextrtc.examples.videochat_with_rest.service.RegisterUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
package org.nextrtc.examples.videochat_with_rest.controller;


@RestController
@RequestMapping("/action")
public class RegisterController {

    @Autowired
// Path: src/main/java/org/nextrtc/examples/videochat_with_rest/service/RegisterUserService.java
// @Service
// @Transactional
// public class RegisterUserService {
// 
//     private static final Logger log = Logger.getLogger(RegisterUserService.class);
//     @Autowired
//     private UserRepository userRepository;
// 
//     @Autowired
//     private PasswordEncoder encoder;
// 
//     public String generateConfirmationKey() {
//     	return UUID.randomUUID().toString();
//     }
//     
//     public void register(String username, String password, String email, String confirmationKey) {
//         if (userRepository.findByUsername(username).isPresent()) {
//             throw new RuntimeException("user exists!");
//         }
//         if (userRepository.findByEmail(email).isPresent()) {
//             throw new RuntimeException("email is occupied!");
//         }
// 
//         User user = new User(username, encoder.encode(password), email, confirmationKey);
// 
//         //TODO: send email
// 
//         userRepository.save(user);
//     }
// 
//     public void register(String name, String email, String providerId) {
//         if (!userRepository.findByAuthProviderId(providerId).isPresent()) {
//             userRepository.save(new User(name, email, providerId));
//         }
//     }
// }


// Path: src/main/java/org/nextrtc/examples/videochat_with_rest/controller/RegisterController.java
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.nextrtc.examples.videochat_with_rest.service.RegisterUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

package org.nextrtc.examples.videochat_with_rest.controller;


@RestController
@RequestMapping("/action")
public class RegisterController {

    @Autowired
    private RegisterUserService service;