Commit d483e084 by Patryk Czarnik

Przeniesienie definicji wyjątków z baza do model

parent 9b21b755
...@@ -6,6 +6,8 @@ import java.sql.SQLException; ...@@ -6,6 +6,8 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import sklep.exn.DBException;
import sklep.exn.RecordNotFound;
import sklep.model.Customer; import sklep.model.Customer;
public class CustomerDAO { public class CustomerDAO {
......
...@@ -5,6 +5,8 @@ import java.sql.DriverManager; ...@@ -5,6 +5,8 @@ import java.sql.DriverManager;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Properties; import java.util.Properties;
import sklep.exn.DBException;
public class DBConnection implements AutoCloseable { public class DBConnection implements AutoCloseable {
private Connection sqlConnection; private Connection sqlConnection;
......
...@@ -6,6 +6,8 @@ import java.io.IOException; ...@@ -6,6 +6,8 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Properties; import java.util.Properties;
import sklep.exn.DBException;
public class DBSettings { public class DBSettings {
public static final String DB_SETTINGS_SYSTEM_PROPERTY = "sklep.db_settings_location"; public static final String DB_SETTINGS_SYSTEM_PROPERTY = "sklep.db_settings_location";
private static final String INTERNAL_DEFAULT_PROPERTIES = "/sklep.properties"; private static final String INTERNAL_DEFAULT_PROPERTIES = "/sklep.properties";
......
...@@ -6,6 +6,8 @@ import java.sql.SQLException; ...@@ -6,6 +6,8 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import sklep.exn.DBException;
import sklep.exn.RecordNotFound;
import sklep.model.Order; import sklep.model.Order;
import sklep.model.OrderProduct; import sklep.model.OrderProduct;
......
...@@ -7,6 +7,8 @@ import java.sql.SQLException; ...@@ -7,6 +7,8 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import sklep.exn.DBException;
import sklep.exn.RecordNotFound;
import sklep.model.Product; import sklep.model.Product;
/* DAO - Data Access Object(s) /* DAO - Data Access Object(s)
......
...@@ -2,6 +2,7 @@ package sklep.db; ...@@ -2,6 +2,7 @@ package sklep.db;
import java.util.List; import java.util.List;
import sklep.exn.DBException;
import sklep.model.Product; import sklep.model.Product;
public class ZwyklyOdczyt_DAO { public class ZwyklyOdczyt_DAO {
......
...@@ -8,9 +8,9 @@ import java.nio.file.Path; ...@@ -8,9 +8,9 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import sklep.db.DBException;
import sklep.db.DBSettings; import sklep.db.DBSettings;
import sklep.db.RecordNotFound; import sklep.exn.DBException;
import sklep.exn.RecordNotFound;
public class PhotoUtil { public class PhotoUtil {
......
package sklep.db; package sklep.exn;
public class DBException extends SklepException { public class DBException extends SklepException {
......
package sklep.db; package sklep.exn;
public class RecordNotFound extends SklepException { public class RecordNotFound extends SklepException {
......
package sklep.db; package sklep.exn;
public class SklepException extends Exception { public class SklepException extends Exception {
......
...@@ -15,8 +15,8 @@ import jakarta.ws.rs.core.Response; ...@@ -15,8 +15,8 @@ import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriBuilder; import jakarta.ws.rs.core.UriBuilder;
import sklep.db.CustomerDAO; import sklep.db.CustomerDAO;
import sklep.db.DBConnection; import sklep.db.DBConnection;
import sklep.db.DBException; import sklep.exn.DBException;
import sklep.db.RecordNotFound; import sklep.exn.RecordNotFound;
import sklep.model.Customer; import sklep.model.Customer;
@RequestScoped @RequestScoped
......
...@@ -14,9 +14,9 @@ import jakarta.ws.rs.core.Response.Status; ...@@ -14,9 +14,9 @@ import jakarta.ws.rs.core.Response.Status;
import jakarta.ws.rs.core.UriBuilder; import jakarta.ws.rs.core.UriBuilder;
import sklep.db.CustomerDAO; import sklep.db.CustomerDAO;
import sklep.db.DBConnection; import sklep.db.DBConnection;
import sklep.db.DBException;
import sklep.db.OrderDAO; import sklep.db.OrderDAO;
import sklep.db.RecordNotFound; import sklep.exn.DBException;
import sklep.exn.RecordNotFound;
import sklep.model.Customer; import sklep.model.Customer;
import sklep.model.Order; import sklep.model.Order;
......
...@@ -6,9 +6,9 @@ import jakarta.ws.rs.PathParam; ...@@ -6,9 +6,9 @@ import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import sklep.db.DBConnection; import sklep.db.DBConnection;
import sklep.db.DBException;
import sklep.db.ProductDAO; import sklep.db.ProductDAO;
import sklep.db.RecordNotFound; import sklep.exn.DBException;
import sklep.exn.RecordNotFound;
import sklep.model.Product; import sklep.model.Product;
import sklep.model.ProductList; import sklep.model.ProductList;
......
...@@ -15,9 +15,9 @@ import jakarta.ws.rs.Produces; ...@@ -15,9 +15,9 @@ import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriBuilder; import jakarta.ws.rs.core.UriBuilder;
import sklep.db.DBConnection; import sklep.db.DBConnection;
import sklep.db.DBException;
import sklep.db.ProductDAO; import sklep.db.ProductDAO;
import sklep.db.RecordNotFound; import sklep.exn.DBException;
import sklep.exn.RecordNotFound;
import sklep.model.Product; import sklep.model.Product;
import sklep.model.ProductList; import sklep.model.ProductList;
import sklep.photo.PhotoUtil; import sklep.photo.PhotoUtil;
......
...@@ -12,9 +12,9 @@ import jakarta.ws.rs.Path; ...@@ -12,9 +12,9 @@ import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam; import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import sklep.db.DBConnection; import sklep.db.DBConnection;
import sklep.db.DBException;
import sklep.db.ProductDAO; import sklep.db.ProductDAO;
import sklep.db.RecordNotFound; import sklep.exn.DBException;
import sklep.exn.RecordNotFound;
import sklep.model.Product; import sklep.model.Product;
import sklep.photo.PhotoUtil; import sklep.photo.PhotoUtil;
......
...@@ -12,9 +12,9 @@ import jakarta.ws.rs.Path; ...@@ -12,9 +12,9 @@ import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam; import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces; import jakarta.ws.rs.Produces;
import sklep.db.DBConnection; import sklep.db.DBConnection;
import sklep.db.DBException;
import sklep.db.ProductDAO; import sklep.db.ProductDAO;
import sklep.db.RecordNotFound; import sklep.exn.DBException;
import sklep.exn.RecordNotFound;
import sklep.model.Product; import sklep.model.Product;
import sklep.model.ProductList; import sklep.model.ProductList;
import sklep.photo.PhotoUtil; import sklep.photo.PhotoUtil;
......
...@@ -3,7 +3,7 @@ package sklep.rest.ext; ...@@ -3,7 +3,7 @@ package sklep.rest.ext;
import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper; import jakarta.ws.rs.ext.ExceptionMapper;
import jakarta.ws.rs.ext.Provider; import jakarta.ws.rs.ext.Provider;
import sklep.db.RecordNotFound; import sklep.exn.RecordNotFound;
@Provider @Provider
public class RecordNotFoundMapper implements ExceptionMapper<RecordNotFound> { public class RecordNotFoundMapper implements ExceptionMapper<RecordNotFound> {
......
...@@ -4,7 +4,7 @@ import jakarta.ws.rs.core.Response; ...@@ -4,7 +4,7 @@ import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Response.Status; import jakarta.ws.rs.core.Response.Status;
import jakarta.ws.rs.ext.ExceptionMapper; import jakarta.ws.rs.ext.ExceptionMapper;
import jakarta.ws.rs.ext.Provider; import jakarta.ws.rs.ext.Provider;
import sklep.db.SklepException; import sklep.exn.SklepException;
@Provider @Provider
public class SklepExceptionMapper implements ExceptionMapper<SklepException> { public class SklepExceptionMapper implements ExceptionMapper<SklepException> {
......
...@@ -11,9 +11,9 @@ import jakarta.servlet.http.HttpServletRequest; ...@@ -11,9 +11,9 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import sklep.db.DBConnection; import sklep.db.DBConnection;
import sklep.db.DBException;
import sklep.db.ProductDAO; import sklep.db.ProductDAO;
import sklep.db.RecordNotFound; import sklep.exn.DBException;
import sklep.exn.RecordNotFound;
import sklep.model.Product; import sklep.model.Product;
@WebServlet("/edit_product") @WebServlet("/edit_product")
......
...@@ -4,8 +4,8 @@ import java.math.BigDecimal; ...@@ -4,8 +4,8 @@ import java.math.BigDecimal;
import java.util.List; import java.util.List;
import sklep.db.DBConnection; import sklep.db.DBConnection;
import sklep.db.DBException;
import sklep.db.ProductDAO; import sklep.db.ProductDAO;
import sklep.exn.DBException;
import sklep.model.Product; import sklep.model.Product;
public class ProductBean { public class ProductBean {
......
...@@ -10,8 +10,8 @@ import jakarta.servlet.http.HttpServlet; ...@@ -10,8 +10,8 @@ import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import sklep.db.DBConnection; import sklep.db.DBConnection;
import sklep.db.DBException;
import sklep.db.ProductDAO; import sklep.db.ProductDAO;
import sklep.exn.DBException;
import sklep.model.Product; import sklep.model.Product;
@WebServlet("/products1") @WebServlet("/products1")
......
...@@ -10,8 +10,8 @@ import jakarta.servlet.http.HttpServlet; ...@@ -10,8 +10,8 @@ import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import sklep.db.DBConnection; import sklep.db.DBConnection;
import sklep.db.DBException;
import sklep.db.ProductDAO; import sklep.db.ProductDAO;
import sklep.exn.DBException;
import sklep.model.Product; import sklep.model.Product;
@WebServlet("/products2") @WebServlet("/products2")
......
...@@ -6,8 +6,8 @@ import java.util.List; ...@@ -6,8 +6,8 @@ import java.util.List;
import jakarta.jws.WebParam; import jakarta.jws.WebParam;
import jakarta.jws.WebResult; import jakarta.jws.WebResult;
import jakarta.jws.WebService; import jakarta.jws.WebService;
import sklep.db.DBException; import sklep.exn.DBException;
import sklep.db.RecordNotFound; import sklep.exn.RecordNotFound;
import sklep.model.Customer; import sklep.model.Customer;
import sklep.model.Order; import sklep.model.Order;
import sklep.model.Product; import sklep.model.Product;
......
...@@ -2,7 +2,7 @@ package sklep.klient; ...@@ -2,7 +2,7 @@ package sklep.klient;
import java.util.List; import java.util.List;
import sklep.db.DBException; import sklep.exn.DBException;
import sklep.model.Product; import sklep.model.Product;
import sklep.soap.Sklep; import sklep.soap.Sklep;
......
...@@ -7,10 +7,10 @@ import jakarta.jws.WebService; ...@@ -7,10 +7,10 @@ import jakarta.jws.WebService;
import jakarta.xml.ws.soap.MTOM; import jakarta.xml.ws.soap.MTOM;
import sklep.db.CustomerDAO; import sklep.db.CustomerDAO;
import sklep.db.DBConnection; import sklep.db.DBConnection;
import sklep.db.DBException;
import sklep.db.OrderDAO; import sklep.db.OrderDAO;
import sklep.db.ProductDAO; import sklep.db.ProductDAO;
import sklep.db.RecordNotFound; import sklep.exn.DBException;
import sklep.exn.RecordNotFound;
import sklep.model.Customer; import sklep.model.Customer;
import sklep.model.Order; import sklep.model.Order;
import sklep.model.Product; import sklep.model.Product;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment