/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.octal.supinbank.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.octal.supinbank.dao.PersonDao;
import net.octal.supinbank.entity.Person;
import net.octal.supinbank.entity.UserRole;
/**
*
* @author octal
*/
@WebServlet(name = "InitializerServlet", loadOnStartup=1)
public class InitializerServlet extends HttpServlet {
@EJB
private PersonDao personDao;
@Override
public void init() throws ServletException {
System.out.println("Initialization");
final List<Person> persons = personDao.getAllUsers();
if (persons.isEmpty()) {
Person p = new Person();
p.setEmail("john.doe@supinbank.com");
/* Password "admin" :) */
p.setPassword("7c87541fd3f3ef5016e12d411900c87a6046a8e8");
p.setFirstName("John");
p.setLastName("Doe");
p.setAddress("5100 Sherbrooke East");
p.setCity("Montreal");
p.setPhone("1-866-373-2738");
p.setRole(UserRole.Advisor);
p.setZipCode("H1V 3R9");
personDao.addUser(p);
}
}
}