Skip to content

Instantly share code, notes, and snippets.

@Prologic200
Created February 1, 2016 18:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Prologic200/dbb0d1602bfd721bbce1 to your computer and use it in GitHub Desktop.
Save Prologic200/dbb0d1602bfd721bbce1 to your computer and use it in GitHub Desktop.
Coupon Project
package beans;
public class ErrorMessage {
private String error;
public ErrorMessage() {
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
@Override
public String toString() {
return "ErrorMessage [error=" + error + "]";
}
public ErrorMessage(String error) {
super();
this.error = error;
}
}
package beans;
public class Message {
private String text;
public Message() {
}
public Message(String text) {
this.text = text;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
@Override
public String toString() {
return "Message [text=" + text + "]";
}
}
package beans;
public class MessageException extends Exception {
private static final long serialVersionUID = -2079740207471716823L;
public MessageException() {
}
public MessageException(String message) {
super(message);
}
public MessageException(Throwable cause) {
super(cause);
}
public MessageException(String message, Throwable cause) {
super(message, cause);
}
}
package service;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import beans.Message;
import beans.MessageException;
import loginsystem.CouponSystem;
import facade.AdminFacade;
import facade.ClientType;
import javabeans.Company;
import javabeans.Customer;
@Path("/Admin")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class AdminResource {
public static final String Admin_Facade = "facade";
@GET
@Path("/loginAdmin/{username}/{password}")
public Message login(@PathParam("username") String name, @PathParam("password") String password,
@Context HttpServletRequest request) throws MessageException {
/**
* Checking name and password for propriety
*/
try {
String message = null;
HttpSession session = request.getSession(true);
if ((name == null || name.trim().isEmpty() || name.length() <= 3)
&& (password == null || password.trim().isEmpty() || password.length() <= 3)) {
throw new MessageException("Illegal name or password");
}
/**
* Creates new AdminFacade and return Json message, otherwise throws
* exception in login fail.
*/
CouponSystem system = CouponSystem.getInstance();
system.login(name, password, ClientType.ADMIN);
AdminFacade af = new AdminFacade();
session.setAttribute(Admin_Facade, af);
message = "Login succesfull";
return new Message(message);
} catch (Exception e) {
throw new MessageException("Login failed. Possibly wrong user/password. Try again");
}
}
@POST
@Path("/CreateCompany")
public Message createCompany(Company Company, @Context HttpServletRequest request) throws MessageException {
try {
String message = null;
HttpSession session = request.getSession(false);
AdminFacade af = ((AdminFacade) session.getAttribute(Admin_Facade));
af.createcompany(Company);
message = "Company created succesfully";
return new Message(message);
} catch (Exception e) {
throw new MessageException("Creating new company failed. Possibly ID exists. Try again or call us");
}
}
@DELETE
@Path("/RemoveCompany/{compId}")
public Message removeCompany(@PathParam("compId") Long compId, @Context HttpServletRequest request)
throws MessageException {
HttpSession session = request.getSession(false);
String message = null;
/**
* Removing company, saving changes in DB and sends Json message.
* otherwise throwing exception
*/
try {
Company company = new Company(compId, "*******", "***", "***");
AdminFacade af = ((AdminFacade) session.getAttribute(Admin_Facade));
af.removeCompany(company);
message = "Company removed succesfully";
return new Message(message);
} catch (Exception e) {
throw new MessageException("Company did not removed. Possibly ID doesn't exists. Please try again or call us");
}
}
@PUT
@Path("/UpdateCompany")
public Message udpateCompany(Company Company, @Context HttpServletRequest request) throws MessageException {
try {
HttpSession session = request.getSession(false);
String message = null;
AdminFacade af = ((AdminFacade) session.getAttribute(Admin_Facade));
af.updateCompany(Company);
message = "Company updated succesfully";
return new Message(message);
} catch (Exception e) {
throw new MessageException("Company did not updated. Possibly ID doesn't exists. Please try again or call us");
}
}
@GET
@Path("/GetAllCompanies")
public Collection<Company> getAllCompanies(@Context HttpServletRequest request) throws MessageException {
/**
* Executes collection company and sends it as Json message. otherwise
* throwing exception
*/
try {
HttpSession session = request.getSession(false);
AdminFacade af = ((AdminFacade) session.getAttribute(Admin_Facade));
Collection<Company> coll = af.getAllCompanies();
return coll;
} catch (Exception e) {
throw new MessageException("List of companies failed. Try again or call us");
}
}
@GET
@Path("/ShowCompany/{compId}")
public Company showCompany(@PathParam("compId") Long compId, @Context HttpServletRequest request)
throws MessageException {
HttpSession session = request.getSession(false);
/**
* Executes company and sends it as Json message. otherwise throwing
* exception
*/
try {
AdminFacade af = ((AdminFacade) session.getAttribute(Admin_Facade));
Company company = af.getCompany(compId);
return company;
} catch (Exception e) {
throw new MessageException("Company show was unsuccsessfull. "
+ "Possibly ID doesn't exists. Please try again or call us");
}
}
@POST
@Path("CreateCustomer")
public Message createCustomer(Customer customer, @Context HttpServletRequest request)
throws MessageException {
try {
HttpSession session = request.getSession(false);
String message = null;
AdminFacade af = ((AdminFacade) session.getAttribute(Admin_Facade));
af.createCustomer(customer);
message = "Customer created and saved in data base";
return new Message(message);
} catch (Exception e) {
throw new MessageException("Customer creating failed. Possibly ID exists. Please try again or call us");
}
}
@DELETE
@Path("/RemoveCustomer/{custId}")
public Message removeCustomer(@PathParam("custId") Long custId, @Context HttpServletRequest request)
throws MessageException {
HttpSession session = request.getSession(false);
String message = null;
/**
* Removing customer, saving changes in DB and sends Json message.
* otherwise throwing exception
*/
try {
Customer customer = new Customer(custId, "*******", "***");
AdminFacade af = ((AdminFacade) session.getAttribute(Admin_Facade));
af.removeCustomer(customer);
message = "Customer removed removed succesfully";
return new Message(message);
} catch (Exception e) {
throw new MessageException("Customer did not removed. Please try again or call us");
}
}
@PUT
@Path("/UpdateCustomer")
public Message udpateCustomer(Customer customer, @Context HttpServletRequest request) throws MessageException {
try {
HttpSession session = request.getSession(false);
String message = null;
AdminFacade af = ((AdminFacade) session.getAttribute(Admin_Facade));
af.updateCustomer(customer);
message = "Customer updated succesfully";
return new Message(message);
} catch (Exception e) {
throw new MessageException("Company did not updated. Please try again or call us");
}
}
@GET
@Path("/GetAllCustomers")
public Collection<Customer> getAllCustomers(@Context HttpServletRequest request) throws MessageException {
/**
* Creating customer collection and sends it as Json message. otherwise
* throwing exception
*/
HttpSession session = request.getSession(false);
try {
AdminFacade af = ((AdminFacade) session.getAttribute(Admin_Facade));
Collection<Customer> coll = af.getAllCustomer();
return coll;
} catch (Exception e) {
throw new MessageException("Table customer failed. Try again or call us");
}
}
@GET
@Path("/ShowCustomer/{custId}")
public Customer showCustomer(@PathParam("custId") Long custId, @Context HttpServletRequest request)
throws MessageException {
HttpSession session = request.getSession(false);
try {
AdminFacade af = ((AdminFacade) session.getAttribute(Admin_Facade));
Customer customer = af.getCustomer(custId);
return customer;
} catch (Exception e) {
throw new MessageException("Customer show failed. Please try again or call us");
}
}
@GET
@Path("/Logout")
public Message logout (@Context HttpServletRequest request) throws MessageException {
HttpSession session = request.getSession(false);
session.invalidate();
String message = "You successfull logged out";
return new Message(message);
}
}
package service;
import java.sql.Date;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import beans.Message;
import beans.MessageException;
import loginsystem.CouponSystem;
import facade.ClientType;
import facade.CompanyFacade;
import javabeans.Coupon;
import javabeans.CouponType;
@Path("/Company")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class CompanyResourse {
public static final String Company_Facade = "facade";
@GET
@Path("/loginCompany/{username}/{password}")
public Message login(@PathParam("username") String name, @PathParam("password") String password,
@Context HttpServletRequest request) throws MessageException {
/**
* Checking name and password for propriety
*/
String message = null;
HttpSession session = request.getSession(true);
if ((name == null || name.trim().isEmpty()) && (password == null || password.trim().isEmpty())) {
throw new MessageException("Illegal name or password");
}
/**
* Creates new CompanyFacade and return Json message, otherwise throws exception in login fail.
*/
try {
CouponSystem system = CouponSystem.getInstance();
system.login(name, password,ClientType.COMPANY);
long companyId = system.getCompanyID();
CompanyFacade cf = new CompanyFacade(companyId);
session.setAttribute(Company_Facade, cf);
message = "Login succesfull";
return new Message(message);
} catch (Exception e) {
throw new MessageException("Login failed. Possibly wrong user/password. Try again");
}
}
@POST
@Path("/AddCoupon")
public Message createCoupon (Coupon Coupon, @Context HttpServletRequest request)
throws MessageException {
try {
String message = null;
HttpSession session = request.getSession(false);
CompanyFacade cf = (CompanyFacade) session.getAttribute(Company_Facade);
cf.creatCoupon(cf.getCompanyID(), Coupon);
message = "Coupon bought";
return new Message(message);
} catch (Exception e) {
throw new MessageException("Coupon creating failed. "
+ "Possibly title exists, start date expired, or end date before start date. Try again or call us");
}
}
@SuppressWarnings("deprecation")
@DELETE
@Path("/RemoveCoupon/{CoupId}")
public Message removeCoupon (@PathParam("CoupId") Long CoupId, @Context HttpServletRequest request)
throws MessageException{
/**
* Checking coupon entries for propriety
*/
HttpSession session = request.getSession(false);
String message = null;
if (CoupId == null) {
throw new MessageException("Illegal input. Try again");
}
/**
* Removing coupon from DB and sends Json message. otherwise throwing exception
*/
try {
Coupon c = new Coupon(CoupId, "", new Date(1, 1, 1), new Date(1, 1, 1), 0, CouponType.CAMPING, "", 0,"");
CompanyFacade cf = (CompanyFacade) session.getAttribute(Company_Facade);
cf.removeCoupon(c);
message = "Coupon removed from data base";
return new Message(message);
} catch (Exception e) {
throw new MessageException("Coupon did not removed. Possibly ID doesn't exists. Try again or call us.");
}
}
@PUT
@Path("/UpdateCoupon")
public Coupon updateCoupon (Coupon Coupon, @Context HttpServletRequest request)
throws MessageException{
try {
HttpSession session = request.getSession(false);
CompanyFacade cf = (CompanyFacade) session.getAttribute(Company_Facade);
Collection<Coupon> coll = cf.getAllCoupon(cf.getCompanyID());
for (Coupon coupon : coll) {
if (coupon.getId() == Coupon.getId()) {
cf.updateCoupon(Coupon);
return Coupon;
}else{
throw new MessageException("Coupon doesn't exists");
}
}
} catch (Exception e) {
throw new MessageException("Coupon did not updated. Try again or call us");
}
throw new MessageException("Coupon did not updated. Try again or call us");
}
@GET
@Path("/CouponDetails/{CoupId}")
public Coupon detailsCoupon (@PathParam("CoupId") Long CoupId, @Context HttpServletRequest request)
throws MessageException{
try {
HttpSession session = request.getSession(false);
CompanyFacade cf = (CompanyFacade) session.getAttribute(Company_Facade);
Collection<Coupon> coll = cf.getAllCoupon(cf.getCompanyID());
for (Coupon coupon : coll) {
if (coupon.getId() == CoupId) {
Coupon coupon2 = cf.getCoupon(CoupId);
return coupon2;
} else{
throw new MessageException("ID doesn't exists") ;
}
}
} catch (Exception e) {
throw new MessageException("Data base error. Possibly ID doesn't exists. Try again or call us");
}
throw new MessageException("Data base error. Possibly ID doesn't exists. Try again or call us");
}
@GET
@Path("/GetAllCoupons")
public Collection<Coupon> getAllCoupon (@Context HttpServletRequest request)
throws MessageException{
HttpSession session = request.getSession(false);
/**
* Creating list of coupons, saving changes in DB and sends Json collection. otherwise throwing exception
*/
try {
CompanyFacade cf = (CompanyFacade) session.getAttribute(Company_Facade);
Collection<Coupon> coll = cf.getAllCoupon(cf.getCompanyID());
return coll;
} catch (Exception e) {
throw new MessageException("Coupon list failed or empty. Try again or call us");
}
}
@GET
@Path("/GetCouponsByType/{type}")
public Collection<Coupon> getCouponsByType (@PathParam("type") String type, @Context HttpServletRequest request)
throws MessageException{
/**
* Checking coupon entries for propriety
*/
HttpSession session = request.getSession(false);
if (type == null) {
throw new MessageException("Illegal input. Try again");
}
/**
* Creating list of coupons, saving changes in DB and sends Json collection. otherwise throwing exception
*/
try {
CouponType typeEnum = CouponType.valueOf(type);
CompanyFacade cf = (CompanyFacade) session.getAttribute(Company_Facade);
Collection<Coupon> c = cf.getCouponByType(cf.getCompanyID(), typeEnum);
return c;
} catch (Exception e) {
throw new MessageException("Coupon list failed or empty. Try again or call us");
}
}
@GET
@Path("/GetCouponsByDate/{date}")
public Collection<Coupon> getCouponsByDate (@PathParam("date") Date date, @Context HttpServletRequest request)
throws MessageException{
/**
* Checking coupon entries for propriety
*/
HttpSession session = request.getSession(false);
if (date == null) {
throw new MessageException("Illegal input. Try again");
}
/**
* Creating list of coupons, saving changes in DB and sends Json collection. otherwise throwing exception
*/
try {
CompanyFacade cf = (CompanyFacade) session.getAttribute(Company_Facade);
Collection<Coupon> c = cf.getCouponByDate(cf.getCompanyID(), date);
return c;
} catch (Exception e) {
throw new MessageException("Coupon list failed. Try again or call us");
}
}
@GET
@Path("/GetCouponsByPrice/{price}")
public Collection<Coupon> getCouponsByPrice (@PathParam("price") Long price, @Context HttpServletRequest request)
throws MessageException{
/**
* Checking coupon entries for propriety
*/
HttpSession session = request.getSession(false);
if (price == null) {
throw new MessageException("Illegal input. Try again");
}
/**
* Creating list of coupons, saving changes in DB and sends Json collection. otherwise throwing exception
*/
try {
CompanyFacade cf = (CompanyFacade) session.getAttribute(Company_Facade);
Collection<Coupon> c = cf.getCouponByPrice(cf.getCompanyID(), price);
return c;
} catch (Exception e) {
throw new MessageException("Coupon list failed. Try again or call us");
}
}
@GET
@Path("/Logout")
public Message logout (@Context HttpServletRequest request) throws MessageException {
HttpSession session = request.getSession(false);
session.invalidate();
String message = "You successfull logged out";
return new Message(message);
}
}
package service;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import beans.Message;
import beans.MessageException;
import dao.CouponDBDAO;
import loginsystem.CouponSystem;
import facade.ClientType;
import facade.CustomerFacade;
import javabeans.Coupon;
import javabeans.CouponType;
@Path("/Customer")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class CustomerResourse {
public static final String Customer_Facade = "facade";
@GET
@Path("/loginCustomer/{username}/{password}")
public Message login(@PathParam("username") String name, @PathParam("password") String password,
@Context HttpServletRequest request) throws MessageException {
/**
* Checking name and password for propriety
*/
String message = null;
HttpSession session = request.getSession(true);
if ((name == null || name.trim().isEmpty()) && (password == null || password.trim().isEmpty())) {
throw new MessageException("Illegal name or password");
}
/**
* Creates new CustomerFacade and return Json message, otherwise throws
* exception in login fail.
*/
try {
CouponSystem system = CouponSystem.getInstance();
system.login(name,password,ClientType.CUSTOMER);
Long custId = system.getCustomerID();
String CustomerId = Long.toString(custId);
session.setAttribute("CustomerId", CustomerId);
CustomerFacade cf = new CustomerFacade(custId);
session.setAttribute(Customer_Facade, cf);
message = "Login succesfull";
return new Message(message);
} catch (Exception e) {
throw new MessageException("Login failed. Possibly wrong user/password. Try again");
}
}
@POST
@Path("/purchaseCoup/{CoupId}")
public Message purchaseCoupon(@PathParam("CoupId") Long CoupId, @Context HttpServletRequest request) throws MessageException {
try {
String message = null;
HttpSession session = request.getSession(false);
CouponDBDAO coupdb = new CouponDBDAO();
Coupon c = coupdb.getCoupon(CoupId);
CustomerFacade custF = ((CustomerFacade) session.getAttribute(Customer_Facade));
custF.purchaseCoupon(c);
message = "Coupon purchased";
return new Message(message);
} catch (Exception e) {
throw new MessageException("Coupon ID doesn't exists or another program problem. Try again or call us");
}
}
@GET
@Path("/GetAllPurchasedCoup")
public Collection<Coupon> GetAllPurchasedCoup(@Context HttpServletRequest request) throws MessageException {
try {
HttpSession session = request.getSession(false);
Collection<Coupon> coll = null;
CustomerFacade custF = ((CustomerFacade) session.getAttribute(Customer_Facade));
coll = custF.getPurchaseCoupon();
return coll;
} catch (Exception e) {
throw new MessageException("Coupon list failed. Try again or call us");
}
}
@GET
@Path("/GetAllPurchasedCoupByType/{type}")
public Collection<Coupon> GetAllPurchasedCoupByType(@PathParam("type") String type,
@Context HttpServletRequest request) throws MessageException {
try {
HttpSession session = request.getSession(false);
long idCustomer = Long.parseLong( (String) session.getAttribute("CustomerId"));
Collection<Coupon> coll = null;
CustomerFacade custF = (CustomerFacade) session.getAttribute(Customer_Facade);
CouponType typeEnum = CouponType.valueOf(type);
coll = custF.getPurchaseCouponByType(idCustomer, typeEnum);
return coll;
} catch (Exception e) {
throw new MessageException("Coupon list failed. Try again or call us");
}
}
@GET
@Path("/GetAllPurchasedCoupByPrice/{price}")
public Collection<Coupon> GetAllPurchasedCoupByPrice(@PathParam("price") Double price,
@Context HttpServletRequest request) throws MessageException {
try {
HttpSession session = request.getSession(false);
long idCustomer = Long.parseLong( (String) session.getAttribute("CustomerId"));
Collection<Coupon> coll = null;
CustomerFacade custF = ((CustomerFacade) session.getAttribute(Customer_Facade));
coll = custF.getPurchaseCouponByPrice(idCustomer, price) ;
return coll;
} catch (Exception e) {
throw new MessageException("Coupon list failed. Try again or call us");
}
}
@GET
@Path("/AllExistCoupons")
public Collection<Coupon> purchaseCoupon(@Context HttpServletRequest request) throws MessageException {
try {
CouponDBDAO coupdb = new CouponDBDAO();
Collection<Coupon> coll = coupdb.getCoupons();
return coll;
} catch (Exception e) {
throw new MessageException("Coupon Table error. Try again or call us");
}
}
@GET
@Path("/Logout")
public Message logout (@Context HttpServletRequest request) throws MessageException {
HttpSession session = request.getSession(false);
session.invalidate();
String message = "You successfull logged out";
return new Message(message);
}
}
package service;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import web.provider.MessageErrorProvider;
@ApplicationPath("/rest")
public class ProjectApplication extends Application {
/**
* Definition of jdbc driver
*/
static {
try {
Class.forName("org.apache.derby.jdbc.ClientDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
/**
* definition of class singletons
* @see javax.ws.rs.core.Application#getSingletons()
*/
@Override
public Set<Object> getSingletons() {
Set<Object> singletons = new HashSet<>();
singletons.add(new AdminResource());
singletons.add(new CompanyResourse());
singletons.add(new CustomerResourse());
singletons.add(new MessageErrorProvider());
return singletons;
}
}
package web.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.ws.rs.core.MediaType;
import facade.AdminFacade;
import facade.CompanyFacade;
import facade.CustomerFacade;
import service.AdminResource;
import service.CompanyResourse;
import service.CustomerResourse;
@WebFilter("/rest/*")
public class SessionFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
// pre processing
String url = ((HttpServletRequest) request).getRequestURI();
HttpSession session = ((HttpServletRequest) request).getSession(false);
if (url.startsWith("/Project/rest/Admin/loginAdmin")
|| url.startsWith("/Project/rest/Company/loginCompany")
|| url.startsWith("/Project/rest/Customer/loginCustomer")) {
// pass the request along the filter chain
// post processing
chain.doFilter(request, response);
return;
} else if (session == null) {
HttpServletResponse res = (HttpServletResponse) response;
res.getWriter().println("{\"error\":\"you are not logged in\"}");
res.setContentType(MediaType.APPLICATION_JSON);
res.setStatus(500);
return;
} else if (url.startsWith("/Project/rest/Admin")) {
// url admin/coompany/cust
AdminFacade af = ((AdminFacade) session.getAttribute(AdminResource.Admin_Facade));
if (af != null){
chain.doFilter(request, response);
return;
}
} else if (url.startsWith("/Project/rest/Company")) {
CompanyFacade cf = (CompanyFacade) session.getAttribute(CompanyResourse.Company_Facade);
if (cf != null){
chain.doFilter(request, response);
return;
}
} else if (url.startsWith("/Project/rest/Customer")) {
CustomerFacade custF = ((CustomerFacade) session.getAttribute(CustomerResourse.Customer_Facade));
if (custF != null){
chain.doFilter(request, response);
return;
}
} else {
HttpServletResponse res = (HttpServletResponse) response;
res.getWriter().println("{\"error\":\"you are not logged in\"}");
res.setContentType(MediaType.APPLICATION_JSON);
res.setStatus(500);
return;
}
}
// if (session == null || af == null || cf == null || custF ==
// null) {
// System.out.println("Try login again. Redirecting browser to
// login");
// ((HttpServletResponse) response).sendRedirect("index.html");
// return;
@Override
public void destroy() {
}
@Override
public void init(FilterConfig arg0) throws ServletException {
}
}
package web.provider;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import beans.ErrorMessage;
@Provider
public class MessageErrorProvider implements ExceptionMapper<Exception> {
@Override
public Response toResponse(Exception e) {
return Response.serverError().entity(new ErrorMessage(e.getMessage())).build();
}
}
@Prologic200
Copy link
Author

Web side project (Tomcat server, ErrorProvider, CyberFilter, RESTfull Web Services, JSON).
There are HTML, CSS, JavaScript (Anqular) involved but hided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment