diff --git a/modules/pizza-service-alex-n/pom.xml b/modules/pizza-service-alex-n/pom.xml index 98dece5..664bd81 100644 --- a/modules/pizza-service-alex-n/pom.xml +++ b/modules/pizza-service-alex-n/pom.xml @@ -4,6 +4,7 @@ com.hillel.elementary.java-geeks pizza-service-alex-n 0.0.1 + war @@ -45,6 +46,17 @@ slf4j-api 1.7.25 + + javax.servlet + javax.servlet-api + 4.0.1 + provided + + + javax.servlet + jstl + 1.2 + diff --git a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/Runner.java b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/Runner.java index 8a19fb0..aea0d27 100644 --- a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/Runner.java +++ b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/Runner.java @@ -12,7 +12,7 @@ private Runner() { public static void main(String[] args) { - Context context = new DefaultPizzaServiceContext(new PizzaServiceConfig()); + Context context = DefaultPizzaServiceContext.getInstance(new PizzaServiceConfig()); Controller controller = context.getBean("controller"); controller.runUserInterface(); } diff --git a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/configs/DefaultPizzaServiceContext.java b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/configs/DefaultPizzaServiceContext.java index 97da4f8..d50c747 100644 --- a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/configs/DefaultPizzaServiceContext.java +++ b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/configs/DefaultPizzaServiceContext.java @@ -15,13 +15,27 @@ public class DefaultPizzaServiceContext implements Context { private static final Logger LOGGER = LoggerFactory.getLogger(DefaultPizzaServiceContext.class); - private final Config config; + private Config config; private Map beans = new HashMap<>(); + private static Context context; - public DefaultPizzaServiceContext(Config config) { + private DefaultPizzaServiceContext(Config config) { this.config = config; } + public static Context getInstance(Config config) { + if (context == null) { + synchronized (DefaultPizzaServiceContext.class) { + if (context == null) { + context = new DefaultPizzaServiceContext(config); + } + return context; + } + } else { + return context; + } + } + @Override public T getBean(String beanName) { if (beanName == null || beanName.isEmpty()) { @@ -70,7 +84,7 @@ private Object createNewBean(String beanName) { try { return constructor.newInstance(constructorArguments); - } catch (Exception e){ + } catch (Exception e) { LOGGER.error("Can't create instance of bean " + e); throw new AppInitialisationException(e.getMessage()); } diff --git a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/domain/Customer.java b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/domain/Customer.java index d18e4a1..68b4e44 100644 --- a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/domain/Customer.java +++ b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/domain/Customer.java @@ -5,14 +5,29 @@ public class Customer { private Long id; private String name; + private String password; + private String phone; + + public Customer(String name) { + this.name = name; + } public Customer(Long id, String name) { this.id = id; this.name = name; } - public Customer(String name) { + public Customer(Long id, String name, String password, String phone) { + this.id = id; + this.name = name; + this.password = password; + this.phone = phone; + } + + public Customer(String name, String password, String phone) { this.name = name; + this.password = password; + this.phone = phone; } public Long getId() { @@ -23,6 +38,15 @@ public String getName() { return name; } + + public String getPassword() { + return password; + } + + public String getPhone() { + return phone; + } + @Override public String toString() { return "Customer{" + diff --git a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/repositories/CustomerRepo.java b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/repositories/CustomerRepo.java index d7c1c43..79d4702 100644 --- a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/repositories/CustomerRepo.java +++ b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/repositories/CustomerRepo.java @@ -9,4 +9,6 @@ public interface CustomerRepo { Customer save(Customer customer); Collection getAll(); + + Customer getCustomerByName(String name); } diff --git a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/repositories/InMemCustomerRepo.java b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/repositories/InMemCustomerRepo.java index a59ae39..1d7851d 100644 --- a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/repositories/InMemCustomerRepo.java +++ b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/repositories/InMemCustomerRepo.java @@ -15,7 +15,7 @@ public class InMemCustomerRepo implements CustomerRepo { @Override public Customer save(Customer customer) { - Customer savedCustomer = new Customer(counter, customer.getName()); + Customer savedCustomer = new Customer(counter, customer.getName(), customer.getPassword(), customer.getPhone()); customers.put(counter, savedCustomer); counter++; return savedCustomer; @@ -25,4 +25,14 @@ public Customer save(Customer customer) { public Collection getAll() { return customers.values(); } + + @Override + public Customer getCustomerByName(String name) { + for (Customer customer : customers.values()) { + if (customer.getName().equals(name)){ + return customer; + } + } + return null; + } } diff --git a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/services/CustomerService.java b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/services/CustomerService.java index 685d579..b21cacf 100644 --- a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/services/CustomerService.java +++ b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/services/CustomerService.java @@ -8,7 +8,11 @@ public interface CustomerService { Customer registerCustomer(Customer customer); + Customer registerCustomer(String customerName, String pass, String phone); + Customer registerCustomer(String customerName); Collection getAllCustomers(); + + Customer signIn(String name, String pass); } diff --git a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/services/DefaultCustomerService.java b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/services/DefaultCustomerService.java index 3dfd4e6..1e63c11 100644 --- a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/services/DefaultCustomerService.java +++ b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/services/DefaultCustomerService.java @@ -3,6 +3,7 @@ import com.hillel.elementary.java_geeks.configs.anotations.Component; import com.hillel.elementary.java_geeks.domain.Customer; import com.hillel.elementary.java_geeks.repositories.CustomerRepo; +import org.apache.commons.codec.digest.DigestUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,6 +39,26 @@ public Customer registerCustomer(Customer customer) { return customerRepo.save(customer); } + @Override + public Customer registerCustomer(String customerName, String pass, String phone) { + if (customerName == null || + customerName.isEmpty() || + pass == null || + pass.isEmpty() || + phone == null || + phone.isEmpty()) { + String msg = "Can not create and save customer name:" + customerName + ",pass:" + pass + ",phone:" + phone; + LOGGER.error(msg); + return null; + } else { + if (customerRepo.getCustomerByName(customerName) != null) { + return null; + } else { + return customerRepo.save(new Customer(customerName, DigestUtils.md5Hex(pass), phone)); + } + } + } + @Override public Customer registerCustomer(String customerName) { if (customerName == null || customerName.isEmpty() || customerName.trim().isEmpty()) { @@ -52,4 +73,22 @@ public Customer registerCustomer(String customerName) { public Collection getAllCustomers() { return customerRepo.getAll(); } + + + @Override + public Customer signIn(String name, String pass) { + if (name == null || pass == null || name.isEmpty() || pass.isEmpty()) { + String msg = "can't sign in user with name:" + name + ", pass:" + pass; + LOGGER.error(msg); + return null; + } else { + Customer customer = customerRepo.getCustomerByName(name); + if (customer == null) { + return null; + } else if (customer.getPassword().equals(DigestUtils.md5Hex(pass))) { + return customer; + } + } + return null; + } } diff --git a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/utils/CookieParser.java b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/utils/CookieParser.java new file mode 100644 index 0000000..eb789fd --- /dev/null +++ b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/utils/CookieParser.java @@ -0,0 +1,21 @@ +package com.hillel.elementary.java_geeks.utils; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; + +public class CookieParser { + + private CookieParser() { + } + + public static String getCookieValue(String cookieName, HttpServletRequest req){ + if (req.getCookies() != null) { + for (Cookie cookie : req.getCookies()) { + if (cookie.getName().equals(cookieName)) { + return cookie.getValue(); + } + } + } + return null; + } +} diff --git a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/utils/Sessions.java b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/utils/Sessions.java new file mode 100644 index 0000000..0bbcf64 --- /dev/null +++ b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/utils/Sessions.java @@ -0,0 +1,40 @@ +package com.hillel.elementary.java_geeks.utils; + +import com.hillel.elementary.java_geeks.domain.Pizza; + +import javax.servlet.http.HttpSession; +import java.util.ArrayList; + +public class Sessions { + + private Sessions() { + } + + public static ArrayList getPizzasList(HttpSession session, String attrName) { + Object attribute = session.getAttribute(attrName); + if (attribute != null) { + return (ArrayList) attribute; + } + return null; + } + + public static void addPizzaToSessionOrder(HttpSession session, String attrName, Pizza pizza) { + Object attribute = session.getAttribute(attrName); + ArrayList pizzas; + if (attribute != null) { + pizzas = (ArrayList) attribute; + } else { + pizzas = new ArrayList<>(); + } + pizzas.add(pizza); + session.setAttribute(attrName, pizzas); + } + + public static int getSessionOrderPizzasCount(HttpSession session, String attrName) { + Object attribute = session.getAttribute(attrName); + if (attribute != null) { + return ((ArrayList) attribute).size(); + } + return 0; + } +} diff --git a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/web/HomePageServlet.java b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/web/HomePageServlet.java new file mode 100644 index 0000000..bc51de0 --- /dev/null +++ b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/web/HomePageServlet.java @@ -0,0 +1,47 @@ +package com.hillel.elementary.java_geeks.web; + +import com.hillel.elementary.java_geeks.configs.Context; +import com.hillel.elementary.java_geeks.configs.DefaultPizzaServiceContext; +import com.hillel.elementary.java_geeks.configs.PizzaServiceConfig; +import com.hillel.elementary.java_geeks.services.PizzaService; +import com.hillel.elementary.java_geeks.utils.Sessions; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class HomePageServlet extends HttpServlet { + + private PizzaService pizzaService; + private static final String ATTR_NAME = "orderedPizza"; + + @Override + public void init() { + Context context = DefaultPizzaServiceContext.getInstance(new PizzaServiceConfig()); + pizzaService = context.getBean("pizzaService"); + } + + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + req.setAttribute("pizzas", pizzaService.getAllPizzas()); + req.getRequestDispatcher("home.jsp").forward(req, resp); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + if (req.getParameter("add-btn") != null) { + String pizzaId = req.getParameter("pizzaId"); + if (pizzaId != null) { + Sessions.addPizzaToSessionOrder(req.getSession(), + ATTR_NAME, + pizzaService.getPizzaById(Integer.parseInt(pizzaId))); + } + } + req.setAttribute("pizzas", pizzaService.getAllPizzas()); + req.getRequestDispatcher("home.jsp").forward(req, resp); + } + +} diff --git a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/web/OrderServlet.java b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/web/OrderServlet.java new file mode 100644 index 0000000..471017b --- /dev/null +++ b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/web/OrderServlet.java @@ -0,0 +1,57 @@ +package com.hillel.elementary.java_geeks.web; + +import com.hillel.elementary.java_geeks.configs.Context; +import com.hillel.elementary.java_geeks.configs.DefaultPizzaServiceContext; +import com.hillel.elementary.java_geeks.configs.PizzaServiceConfig; +import com.hillel.elementary.java_geeks.domain.Pizza; +import com.hillel.elementary.java_geeks.services.OrderService; +import com.hillel.elementary.java_geeks.services.PizzaService; +import com.hillel.elementary.java_geeks.utils.Sessions; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; + + +public class OrderServlet extends HttpServlet { + + private static final String ATTR_NAME = "orderedPizza"; + private OrderService orderService; + private PizzaService pizzaService; + + @Override + public void init() throws ServletException { + Context context = DefaultPizzaServiceContext.getInstance(new PizzaServiceConfig()); + pizzaService = context.getBean("pizzaService"); + orderService = context.getBean("orderService"); + } + + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + List pizzas = Sessions.getPizzasList(req.getSession(), ATTR_NAME); + if (pizzas != null) { + req.setAttribute("pizzas", pizzas); + req.setAttribute("count", pizzas.size()); + } + req.getRequestDispatcher("order.jsp").forward(req, resp); + } + + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + String userBtnValue = req.getParameter("usr-data-btn"); + if (userBtnValue != null) { + if (userBtnValue.equals("delete all")) { + req.getSession().removeAttribute(ATTR_NAME); + } else if (userBtnValue.equals("create")) { + String name = req.getParameter("name"); + //todo + } + } + req.getRequestDispatcher("order.jsp").forward(req, resp); + } +} diff --git a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/web/RegistrationServlet.java b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/web/RegistrationServlet.java new file mode 100644 index 0000000..312255c --- /dev/null +++ b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/web/RegistrationServlet.java @@ -0,0 +1,53 @@ +package com.hillel.elementary.java_geeks.web; + +import com.hillel.elementary.java_geeks.configs.Context; +import com.hillel.elementary.java_geeks.configs.DefaultPizzaServiceContext; +import com.hillel.elementary.java_geeks.configs.PizzaServiceConfig; +import com.hillel.elementary.java_geeks.domain.Customer; +import com.hillel.elementary.java_geeks.services.CustomerService; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class RegistrationServlet extends HttpServlet { + + private CustomerService customerService; + + @Override + public void init() throws ServletException { + Context context = DefaultPizzaServiceContext.getInstance(new PizzaServiceConfig()); + customerService = context.getBean("customerService"); + } + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + req.getRequestDispatcher("registration.jsp").forward(req, resp); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + if (req.getParameter("register") != null) { + String name = req.getParameter("userName"); + String pass = req.getParameter("userPass"); + String phone = req.getParameter("userPhone"); + if (name == null || pass == null || phone == null || name.isEmpty() || pass.isEmpty() || phone.isEmpty()) { + req.setAttribute("errMsg", "you must fill all fields"); + } else { + //todo data validation ? [> 6 chars], [not contains symbols ] ... + Customer customer = customerService.registerCustomer(name, pass, phone); + if (customer == null) { + req.setAttribute("errMsg", "can not create user with such data."); + } else { + req.setAttribute("msg", "UserServlet: " + customer.getName() + ", successfully created"); + req.setAttribute("userName" , ""); + req.setAttribute("userPass", ""); + req.setAttribute("userPhone", ""); + } + } + } + req.getRequestDispatcher("registration.jsp").forward(req, resp); + } +} diff --git a/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/web/UserServlet.java b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/web/UserServlet.java new file mode 100644 index 0000000..79046e3 --- /dev/null +++ b/modules/pizza-service-alex-n/src/main/java/com/hillel/elementary/java_geeks/web/UserServlet.java @@ -0,0 +1,54 @@ +package com.hillel.elementary.java_geeks.web; + +import com.hillel.elementary.java_geeks.configs.Context; +import com.hillel.elementary.java_geeks.configs.DefaultPizzaServiceContext; +import com.hillel.elementary.java_geeks.configs.PizzaServiceConfig; +import com.hillel.elementary.java_geeks.domain.Customer; +import com.hillel.elementary.java_geeks.services.CustomerService; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class UserServlet extends HttpServlet { + + private CustomerService customerService; + + @Override + public void init() throws ServletException { + Context context = DefaultPizzaServiceContext.getInstance(new PizzaServiceConfig()); + customerService = context.getBean("customerService"); + } + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + req.getRequestDispatcher("user.jsp").forward(req, resp); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + + //if button exit was pressed + if (req.getParameter("exit") != null) { + req.getSession().invalidate(); + } + //if button sign in was pressed + if (req.getParameter("signIn") != null) { + String name = req.getParameter("userName"); + String pass = req.getParameter("userPass"); + if (name == null || pass == null || name.isEmpty() || pass.isEmpty()) { + req.setAttribute("errMsg", "Wrong data. Try Again"); + } else { + Customer customer = customerService.signIn(name, pass); + if (customer == null) { + req.setAttribute("errMsg", "Wrong name or password. Try again"); + } else { + req.getSession().setAttribute("customer" , customer); + } + } + } + req.getRequestDispatcher("user.jsp").forward(req, resp); + } +} diff --git a/modules/pizza-service-alex-n/src/main/webapp/WEB-INF/web.xml b/modules/pizza-service-alex-n/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..0dad726 --- /dev/null +++ b/modules/pizza-service-alex-n/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,52 @@ + + + + java.lang.Throwable + /error.html + + + javax.servlet.ServletException + /error.html + + + 404 + /error.html + + + + + homePage + com.hillel.elementary.java_geeks.web.HomePageServlet + + + order + com.hillel.elementary.java_geeks.web.OrderServlet + + + user + com.hillel.elementary.java_geeks.web.UserServlet + + + registration + com.hillel.elementary.java_geeks.web.RegistrationServlet + + + + + homePage + /index.html + + + order + /order + + + user + /user + + + registration + /registration + + + \ No newline at end of file diff --git a/modules/pizza-service-alex-n/src/main/webapp/css/style.css b/modules/pizza-service-alex-n/src/main/webapp/css/style.css new file mode 100644 index 0000000..a892916 --- /dev/null +++ b/modules/pizza-service-alex-n/src/main/webapp/css/style.css @@ -0,0 +1,275 @@ +* { + margin: 0; + padding: 0; +} + +ul { + list-style: none; +} + +p { + margin: 2px; + font: bold 20px Arial; + color: #ffffff; + text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5); +} + +html, body { + height: 100%; +} + +body { + background: linear-gradient(20deg, #fab501 79%, + rgb(60, 166, 71) 79.1%, + rgb(60, 166, 71) 86%, + rgb(255, 255, 255) 86.1%, + rgb(255, 255, 255) 93%, + rgb(233, 60, 80) 93.1%, + rgb(233, 60, 80) 100% + ) no-repeat fixed; + height: 100%; +} + +h1 { + text-align: center; + width: 100%; + font: bold 70px Arial; + color: #ffffff; + margin: 20px 0 20px 0; + text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.71); +} + +h2 { + text-align: center; + width: 100%; + font: bold 25px Arial; + color: #ffffff; + margin: 20px 0 20px 0; + text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.71); +} + +nav { + color: #ffffff; + text-align: center; + float: top; + font: bold 20px Arial; + text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6); +} + +nav li { + color: #fff; + margin: 10px 10px 0 10px; + display: inline; +} + +div { + display: inline-block; +} + +form { + display: inline; +} + +footer { + height: 50px; + text-align: center; + width: 100%; + font: bold 15px Arial; + color: #ffffff; + padding: 15px; + margin: 20px 0 0 0; + text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3); + background: #eeaa01; + display: block; + vertical-align: baseline; +} + +.nav-btn { + background-color: transparent; + border: none; + display: inline-block; + cursor: pointer; + color: #ffffff; + font-family: Arial, serif; + font-size: 30px; + font-weight: bold; + text-decoration: none; + text-shadow: 1px 1px 2px #000000; + backface-visibility: hidden; +} + +.nav-btn:hover { + color: #e93c50; +} + +.grid-wrapper { + width: 1300px; + margin: 0 auto; + display: grid; + grid-template-columns: repeat(3, 1fr); + grid-gap: 1rem; +} + +.grid-item { + display: flex; + justify-content: center; + align-items: center; +} + +.pizza-img { + float: left; + height: 150px; + width: 150px; + margin: 5px; +} + +.pizza-div { + font: bold 20px Arial; + color: #ffffff; + margin: 10px; + display: table; +} + +.pizza-info { + display: table-cell; + vertical-align: middle; +} + + +/*button*/ +.slide-btn { + margin: 2px; + text-align: center; +} + +.slide-btn { + width: 200px; + font-size: 16px; + font-weight: 600; + color: #fff; + cursor: pointer; + height: 55px; + text-align: center; + border: none; + background-size: 300% 100%; + + border-radius: 1px; + moz-transition: all .4s ease-in-out; + -o-transition: all .4s ease-in-out; + -webkit-transition: all .4s ease-in-out; + transition: all .4s ease-in-out; +} + +.slide-btn:hover { + background-position: 100% 0; + moz-transition: all .4s ease-in-out; + -o-transition: all .4s ease-in-out; + -webkit-transition: all .4s ease-in-out; + transition: all .4s ease-in-out; +} + +.slide-btn:focus { + outline: none; +} + +.add-btn { + background-image: linear-gradient(to right, #e93c50 48%, #ffffff 48.1%, #ffffff 52%, #3ca647 52.1%); +} + +.dlt-btn { + background-image: linear-gradient(to right, #e93c50 48%, #ffffff 48.1%, #ffffff 52%, #a72a3c 52.1%); +} + +.create-btn { + background-image: linear-gradient(to right, #3ca647 48%, #ffffff 48.1%, #ffffff 52%, #32823c 52.1%); +} + +/*buttons*/ + +.aligner{ + text-align: center; +} + +.user-name { + display: inline-block; + color: #ffffff; + font-family: Arial, serif; + font-size: 30px; + font-weight: bold; + text-decoration: none; + text-shadow: 1px 1px 2px #000000; + margin: 2px; + padding: 5px; +} + +.order-counter { + background-color: #e93c50; + border-radius: 100%; + margin: 2px; + padding: 5px; +} + +.order-list { + text-align: center; + width: 100%; + font: bold 15px Arial; + color: #ffffff; + text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5); +} + +.usr-field { + width: 600px; + margin: 7px 2px 5px 2px; + border: 1px solid #ffffff; + padding-left: 20px; + padding-top: 10px; + padding-bottom: 10px; + border-radius: 4px; + +} + +.user-data { + display: block; + width: 600px; + height: auto; + margin: auto; +} + +.usr-data-btns { + display: block; + text-align: right; + margin: 5px -2px 5px 0px; +} + +.content { + display: block; + padding: 20px; + min-height: 100%; + margin: 0 auto -50px; +} + +.push { + height: 50px; +} + +.error { + color: #ff0100; +} + +a.ref-btn { + padding: 19.5px 0 19.5px 0; + height: 16px; + font: bold 16px Arial; + display: inline-block; + vertical-align: bottom; + text-decoration: none; + display: inline-block; +} + +.exit-div { + text-align: center; + display: block; + width: 600px; + height: auto; + margin: auto; +} \ No newline at end of file diff --git a/modules/pizza-service-alex-n/src/main/webapp/error.html b/modules/pizza-service-alex-n/src/main/webapp/error.html new file mode 100644 index 0000000..b02a2ab --- /dev/null +++ b/modules/pizza-service-alex-n/src/main/webapp/error.html @@ -0,0 +1,15 @@ + + + + + oops + + +

+ Oops ... Something is wrong! +

+

+ We are informed about this, and will fix this soon. +

+ + diff --git a/modules/pizza-service-alex-n/src/main/webapp/footer.jsp b/modules/pizza-service-alex-n/src/main/webapp/footer.jsp new file mode 100644 index 0000000..aa8eaed --- /dev/null +++ b/modules/pizza-service-alex-n/src/main/webapp/footer.jsp @@ -0,0 +1,7 @@ + diff --git a/modules/pizza-service-alex-n/src/main/webapp/header.jsp b/modules/pizza-service-alex-n/src/main/webapp/header.jsp new file mode 100644 index 0000000..3a67fe1 --- /dev/null +++ b/modules/pizza-service-alex-n/src/main/webapp/header.jsp @@ -0,0 +1,36 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> + +
+

We have PIZZA! Order it right now!

+ +
+
diff --git a/modules/pizza-service-alex-n/src/main/webapp/home.jsp b/modules/pizza-service-alex-n/src/main/webapp/home.jsp new file mode 100644 index 0000000..a58957f --- /dev/null +++ b/modules/pizza-service-alex-n/src/main/webapp/home.jsp @@ -0,0 +1,35 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Pizza + + + +
+ + +
+ +
+
+
+ pizza +
+

pizza: ${pizza.name}

+

type: ${pizza.pizzaType}

+

price: ${pizza.price}

+ + +
+
+
+
+
+
+
+
+ + + diff --git a/modules/pizza-service-alex-n/src/main/webapp/img/mmm.png b/modules/pizza-service-alex-n/src/main/webapp/img/mmm.png new file mode 100644 index 0000000..196aa45 Binary files /dev/null and b/modules/pizza-service-alex-n/src/main/webapp/img/mmm.png differ diff --git a/modules/pizza-service-alex-n/src/main/webapp/order.jsp b/modules/pizza-service-alex-n/src/main/webapp/order.jsp new file mode 100644 index 0000000..4b91e6d --- /dev/null +++ b/modules/pizza-service-alex-n/src/main/webapp/order.jsp @@ -0,0 +1,59 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> + + + + order + + + +
+ + + +

There are ${fn:length(sessionScope.get('orderedPizza'))} pizzas in your order.

+
+ +

There is ${fn:length(sessionScope.get('orderedPizza'))} pizza in your order.

+
+ +

There are no pizza in your order. You can add it on home page.

+
+
+ +
    +
    + +
  • Pizza name: ${pizza.name} - type: ${pizza.pizzaType} - price: ${pizza.price}
  • +
    +
    +
+ +
+
+ +

You need to register or sign in to make orders. Press button below to get to sign in/registration + page

+ +
+ +
+ + +
+
+
+
+ +
+
+
+ + + diff --git a/modules/pizza-service-alex-n/src/main/webapp/registration.jsp b/modules/pizza-service-alex-n/src/main/webapp/registration.jsp new file mode 100644 index 0000000..ef0ec16 --- /dev/null +++ b/modules/pizza-service-alex-n/src/main/webapp/registration.jsp @@ -0,0 +1,32 @@ +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + registration + + + +
+ + +
+
+

${errMsg}

+

${msg}

+

New user registration

+

User name:

+ +

Password:

+ +

Phone:

+ +
+ +
+
+
+ +
+
+ + + diff --git a/modules/pizza-service-alex-n/src/main/webapp/user.jsp b/modules/pizza-service-alex-n/src/main/webapp/user.jsp new file mode 100644 index 0000000..2ee8567 --- /dev/null +++ b/modules/pizza-service-alex-n/src/main/webapp/user.jsp @@ -0,0 +1,41 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + registration + + + +
+ + +
+

You entered like: ${sessionScope.get('customer').name}

+
+
+ +
+
+
+
+ +
+
+

${errMsg}

+

User name:

+ +

Password:

+ + +
+
+
+
+
+ + + diff --git a/pom.xml b/pom.xml index e8148d9..bc2031b 100644 --- a/pom.xml +++ b/pom.xml @@ -185,6 +185,11 @@ ${mockito.version} test + + commons-codec + commons-codec + 1.9 +