├── src ├── conf │ └── MANIFEST.MF └── java │ ├── displaytag.properties │ ├── bca │ └── fts │ │ ├── util │ │ ├── SessionListener.java │ │ ├── ApplicationtListener.java │ │ ├── PasswordValidator.java │ │ ├── AdminAccountFilter.java │ │ ├── AdminFilter.java │ │ ├── BranchFilter.java │ │ ├── DatabaseConnector.java │ │ └── DateValidator.java │ │ ├── model │ │ ├── AdminBean.java │ │ ├── UserBean.java │ │ ├── BranchBean.java │ │ ├── SendFileBean.java │ │ ├── ClosedFileBean.java │ │ ├── ProcessingFileBean.java │ │ ├── IncomingFileBean.java │ │ ├── TrackFileBean.java │ │ └── FileBean.java │ │ ├── controller │ │ ├── NotificationServlet.java │ │ ├── IDServlet.java │ │ ├── LogoutServlet.java │ │ ├── LoadFileType.java │ │ ├── ListRegFilesBranch.java │ │ ├── GetFileRecord.java │ │ ├── AdminRegisFiles.java │ │ ├── LoadFileTypeBranch.java │ │ ├── BranchAutocomplete.java │ │ ├── AdminAutocomplete.java │ │ ├── DeleteFileType.java │ │ ├── ViewSentFiles.java │ │ ├── AdminPendingFiles.java │ │ ├── AdminRejectFiles.java │ │ ├── AdminCloseFiles.java │ │ ├── AdminProcessFiles.java │ │ ├── BranchRecordsAdmin.java │ │ ├── RecieveFileServlet.java │ │ ├── AddFileTypeServlet.java │ │ ├── UpdateBranchServlet.java │ │ ├── LoadIncomingFiles.java │ │ ├── AdminLoginServlet.java │ │ ├── DeleteBranchServlet.java │ │ ├── ChangeFileStatus.java │ │ ├── AddFileServlet.java │ │ ├── AdminRegistration.java │ │ ├── RejectFileServlet.java │ │ ├── UpdateFileRecord.java │ │ ├── BranchLoginServlet.java │ │ ├── DispatchFileServlet.java │ │ └── BranchPassChange.java │ │ └── dao │ │ ├── IDDao.java │ │ ├── NotificationDao.java │ │ └── BranchLoginCheckDao.java │ └── log4j.properties ├── dist └── FTS.war ├── web ├── img │ ├── find.png │ ├── fts.jpeg │ ├── help.png │ ├── keys.png │ ├── lock_open.png │ ├── ico_file_csv.png │ ├── ico_file_pdf.png │ ├── ico_file_rtf.png │ ├── ico_file_xml.png │ └── ico_file_excel.png ├── branch │ ├── navGeneral.html │ ├── navSearch.html │ ├── messageToBranch.jsp │ ├── trackFile.jsp │ ├── welcomeBranch.jsp │ ├── passChange.jsp │ ├── fileRegister.jsp │ └── sentFiles.jsp ├── admin │ ├── pages │ │ ├── navGeneral.html │ │ ├── navSearch.html │ │ ├── navReport.html │ │ ├── welcomeAdmin.jsp │ │ ├── trackFile.jsp │ │ ├── reportsAdmin.jsp │ │ ├── pendingFiles.jsp │ │ ├── branchList.jsp │ │ ├── rejectedFiles.jsp │ │ ├── closedFiles.jsp │ │ ├── processingFiles.jsp │ │ ├── changePassword.jsp │ │ ├── branchRegister.jsp │ │ ├── addFileType.jsp │ │ └── showBranchRecord.jsp │ ├── index.jsp │ └── install.jsp ├── header.html ├── formNotice.html ├── META-INF │ └── context.xml ├── js │ ├── adminAjax.js │ └── branchAjax.js ├── css │ ├── print.css │ ├── displaytag.css │ └── style.css ├── 404error.jsp ├── WEB-INF │ └── tags │ │ └── showFileData.tag ├── 500error.jsp └── index.jsp ├── snapshots ├── pic1.jpg ├── pic2.jpg ├── pic3.jpg └── pic4.jpg ├── nbproject ├── private │ ├── private.properties │ └── private.xml ├── genfiles.properties ├── ant-deploy.xml └── project.xml └── README.md /src/conf/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | 3 | -------------------------------------------------------------------------------- /dist/FTS.war: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyandeep/File-Tracking-System/HEAD/dist/FTS.war -------------------------------------------------------------------------------- /web/img/find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyandeep/File-Tracking-System/HEAD/web/img/find.png -------------------------------------------------------------------------------- /web/img/fts.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyandeep/File-Tracking-System/HEAD/web/img/fts.jpeg -------------------------------------------------------------------------------- /web/img/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyandeep/File-Tracking-System/HEAD/web/img/help.png -------------------------------------------------------------------------------- /web/img/keys.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyandeep/File-Tracking-System/HEAD/web/img/keys.png -------------------------------------------------------------------------------- /snapshots/pic1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyandeep/File-Tracking-System/HEAD/snapshots/pic1.jpg -------------------------------------------------------------------------------- /snapshots/pic2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyandeep/File-Tracking-System/HEAD/snapshots/pic2.jpg -------------------------------------------------------------------------------- /snapshots/pic3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyandeep/File-Tracking-System/HEAD/snapshots/pic3.jpg -------------------------------------------------------------------------------- /snapshots/pic4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyandeep/File-Tracking-System/HEAD/snapshots/pic4.jpg -------------------------------------------------------------------------------- /web/img/lock_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyandeep/File-Tracking-System/HEAD/web/img/lock_open.png -------------------------------------------------------------------------------- /web/img/ico_file_csv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyandeep/File-Tracking-System/HEAD/web/img/ico_file_csv.png -------------------------------------------------------------------------------- /web/img/ico_file_pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyandeep/File-Tracking-System/HEAD/web/img/ico_file_pdf.png -------------------------------------------------------------------------------- /web/img/ico_file_rtf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyandeep/File-Tracking-System/HEAD/web/img/ico_file_rtf.png -------------------------------------------------------------------------------- /web/img/ico_file_xml.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyandeep/File-Tracking-System/HEAD/web/img/ico_file_xml.png -------------------------------------------------------------------------------- /web/img/ico_file_excel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyandeep/File-Tracking-System/HEAD/web/img/ico_file_excel.png -------------------------------------------------------------------------------- /web/branch/navGeneral.html: -------------------------------------------------------------------------------- 1 |
2 | | Back to My Account 3 | 4 |
5 |
6 | 7 | -------------------------------------------------------------------------------- /web/admin/pages/navGeneral.html: -------------------------------------------------------------------------------- 1 |
2 | | Back to My Account 3 | 4 |
5 |
6 | 7 | -------------------------------------------------------------------------------- /web/header.html: -------------------------------------------------------------------------------- 1 |
2 | file_tracking_system 3 |

4 | FILE TRACKING SYSTEM 5 |

6 |
7 | 8 | -------------------------------------------------------------------------------- /web/branch/navSearch.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | | Back to Search-a-file 4 | | Back to My Account 5 |
6 | 7 |
8 | 9 | -------------------------------------------------------------------------------- /web/admin/pages/navSearch.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | | Back to Search-a-file 4 | | Back to My Account 5 |
6 | 7 |
8 | 9 | -------------------------------------------------------------------------------- /web/formNotice.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

4 | N.B. : A form field with '*' is mandatary. It needs to filled up before submitting the form. 5 |

6 |
-------------------------------------------------------------------------------- /web/admin/pages/navReport.html: -------------------------------------------------------------------------------- 1 |
2 | Print this page 3 | | Back to Admin-reports 4 | | Back to My Account 5 | 6 |
7 | 8 |
9 | 10 | -------------------------------------------------------------------------------- /nbproject/private/private.properties: -------------------------------------------------------------------------------- 1 | deploy.ant.properties.file=/home/zyandeep/.netbeans/8.0.2/tomcat70.properties 2 | j2ee.server.home=/home/zyandeep/Tomcat 3 | j2ee.server.instance=tomcat70:home=/home/zyandeep/Tomcat/ 4 | javac.debug=true 5 | javadoc.preview=true 6 | selected.browser=default 7 | user.properties.file=/home/zyandeep/.netbeans/8.0.2/build.properties 8 | -------------------------------------------------------------------------------- /nbproject/private/private.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/java/displaytag.properties: -------------------------------------------------------------------------------- 1 | export.types=csv excel xml pdf rtf 2 | export.excel=true 3 | export.csv=true 4 | export.xml=true 5 | export.pdf=true 6 | export.rtf=true 7 | export.amount=page 8 | export.excel.class=org.displaytag.export.excel.DefaultHssfExportView 9 | export.pdf.class=org.displaytag.export.DefaultPdfExportView 10 | export.rtf.class=org.displaytag.export.DefaultRtfExportView -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # File Tracking System 2 | 3 | FTS is a JAVA EE web application that keeps track of all the files that move 4 | around different offices/departments of an organisation until they reach their 5 | destination. Every department needs to register the arrival and departure of files. 6 | When anyone searches for a file in FTS, it then displays the track of the file’s 7 | movement in a graphical format. 8 | -------------------------------------------------------------------------------- /src/java/bca/fts/util/SessionListener.java: -------------------------------------------------------------------------------- 1 | package bca.fts.util; 2 | 3 | import javax.servlet.http.*; 4 | 5 | public class SessionListener implements HttpSessionListener { 6 | 7 | @Override 8 | public void sessionCreated(HttpSessionEvent se) { 9 | 10 | } 11 | 12 | @Override 13 | public void sessionDestroyed(HttpSessionEvent se) { 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /web/META-INF/context.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | -------------------------------------------------------------------------------- /nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=8fdf960b 2 | build.xml.script.CRC32=d899ffd8 3 | build.xml.stylesheet.CRC32=651128d4@1.68.1.1 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=8fdf960b 7 | nbproject/build-impl.xml.script.CRC32=df280004 8 | nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.68.1.1 9 | -------------------------------------------------------------------------------- /src/java/bca/fts/model/AdminBean.java: -------------------------------------------------------------------------------- 1 | // this bean represents the admin 2 | 3 | package bca.fts.model; 4 | 5 | public class AdminBean { 6 | 7 | private String userName = null; 8 | private String password = null; 9 | 10 | public String getUserName() { 11 | return userName; 12 | } 13 | 14 | public String getPassword() { 15 | return password; 16 | } 17 | 18 | public void setPassword(String password) { 19 | this.password = password; 20 | } 21 | 22 | public void setUserName(String userName) { 23 | this.userName = userName; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/java/bca/fts/model/UserBean.java: -------------------------------------------------------------------------------- 1 | // this bean represents a branch user 2 | 3 | package bca.fts.model; 4 | 5 | public class UserBean { 6 | 7 | private String userName = null; 8 | private String password = null; 9 | 10 | public UserBean() { 11 | userName = " "; 12 | password = " "; 13 | } 14 | 15 | public String getUserName() { 16 | return userName; 17 | } 18 | 19 | public String getPassword() { 20 | return password; 21 | } 22 | 23 | public void setPassword(String password) { 24 | this.password = password; 25 | } 26 | 27 | public void setUserName(String userName) { 28 | this.userName = userName; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /web/js/adminAjax.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function () { 2 | 3 | // fire an AJAX request for autocomplete file names 4 | $('#name').autocomplete({ 5 | autoFocus: true, 6 | source: function (request, response) { 7 | $.ajax({ 8 | url: '/FTS/admin/pages/nameSuggesstion.do', 9 | data: {term: request.term}, 10 | dataType: 'json', 11 | cache: false, 12 | success: function (data) { 13 | response(data); 14 | }, 15 | error: function (jqXHR, textStatus, errorThrown) { 16 | alert("Error in the Database connection!"); 17 | } 18 | 19 | }); 20 | } 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /web/js/branchAjax.js: -------------------------------------------------------------------------------- 1 | // fire an AJAX request for autocomplete file names 2 | var ajaxCall = function () { 3 | 4 | $('#name').autocomplete({ 5 | autoFocus: true, 6 | source: function (request, response) { 7 | $.ajax({ 8 | url: '/FTS/branch/nameSuggestion.do', 9 | data: {term: request.term}, 10 | dataType: 'json', 11 | cache: false, 12 | success: function (data) { 13 | response(data); 14 | }, 15 | error: function (jqXHR, textStatus, errorThrown) { 16 | alert("Error in the Database connection!"); 17 | } 18 | 19 | }); 20 | } 21 | }); 22 | }; 23 | 24 | // call this function when the DOM is ready 25 | $(document).ready(ajaxCall); 26 | 27 | 28 | -------------------------------------------------------------------------------- /web/css/print.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 14px; 3 | font-family: Georgia, "Times New Roman", Times, serif; 4 | background-color: white; 5 | } 6 | 7 | #nav, .pagebanner, .pagelinks, .exportlinks{ 8 | display: none; 9 | } 10 | 11 | 12 | #printData { 13 | width: 100%; 14 | margin: 0; 15 | float: none; 16 | } 17 | 18 | table, th, td { 19 | border: 1px solid #cccccc; 20 | border-collapse: collapse; 21 | padding: 3px; 22 | text-align: center; 23 | } 24 | 25 | table { 26 | width: 100%; 27 | } 28 | 29 | th { 30 | border-bottom: 2px solid black; 31 | } 32 | 33 | caption { 34 | padding-bottom: 7px; 35 | font-size: 17px; 36 | font-weight: bold; 37 | text-align: center; 38 | } 39 | 40 | /* for printers */ 41 | @media print 42 | { 43 | #noPrint { 44 | display: none; 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /src/java/bca/fts/util/ApplicationtListener.java: -------------------------------------------------------------------------------- 1 | package bca.fts.util; 2 | 3 | import javax.servlet.*; 4 | import org.apache.log4j.*; 5 | import bca.fts.dao.AdminLoginCheckDao; 6 | 7 | public class ApplicationtListener implements ServletContextListener { 8 | 9 | // the logger object 10 | private static final Logger logger = Logger.getLogger(ApplicationtListener.class); 11 | 12 | @Override 13 | public void contextInitialized(ServletContextEvent event) { 14 | logger.info("FTS has been started."); 15 | 16 | ServletContext sc = event.getServletContext(); 17 | 18 | // verify the admin account 19 | sc.setAttribute("adminAccount", AdminLoginCheckDao.checkAdminAcc()); 20 | } 21 | 22 | @Override 23 | public void contextDestroyed(ServletContextEvent event) { 24 | logger.info("FTS has been stoped."); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/NotificationServlet.java: -------------------------------------------------------------------------------- 1 | // this servlet keeps track whether the user respond to the notification or not 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | 8 | public class NotificationServlet extends HttpServlet { 9 | 10 | @Override 11 | public void doGet(HttpServletRequest request, HttpServletResponse response) 12 | throws ServletException, IOException { 13 | 14 | doPost(request, response); 15 | } 16 | 17 | @Override 18 | public void doPost(HttpServletRequest request, HttpServletResponse response) 19 | throws ServletException, IOException { 20 | 21 | request.getSession(false).setAttribute("inbox", true); 22 | 23 | request.getRequestDispatcher("loadIncomings.do").forward(request, response); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/IDServlet.java: -------------------------------------------------------------------------------- 1 | // this servlet is responsible for retriving the auto-increment ID for a new branch 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | 8 | import bca.fts.dao.IDDao; 9 | 10 | public class IDServlet extends HttpServlet { 11 | 12 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 13 | throws ServletException, IOException { 14 | 15 | int id = IDDao.getLastID(); 16 | 17 | // check the database-related error 18 | if (id == -1) { 19 | request.setAttribute("errorMessage", "Error has occured in the database operation!"); 20 | request.getRequestDispatcher("welcomeAdmin.jsp").forward(request, response); 21 | } else { 22 | request.setAttribute("branchID", ++id); 23 | request.getRequestDispatcher("branchRegister.jsp").forward(request, response); 24 | } 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/java/bca/fts/model/BranchBean.java: -------------------------------------------------------------------------------- 1 | // this bean represents a branch 2 | 3 | package bca.fts.model; 4 | 5 | public class BranchBean { 6 | 7 | private int id = 0; 8 | private String officeName = null; 9 | private String headName = null; 10 | private String username = null; 11 | private String password = null; 12 | 13 | 14 | public void setHeadName(String headName) { 15 | this.headName = headName; 16 | } 17 | 18 | public void setOfficeName(String officeName) { 19 | this.officeName = officeName; 20 | } 21 | 22 | public void setPassword(String password) { 23 | this.password = password; 24 | } 25 | 26 | public void setUsername(String username) { 27 | this.username = username; 28 | } 29 | 30 | public void setId(int id) { 31 | this.id = id; 32 | } 33 | 34 | 35 | public int getId() { 36 | return id; 37 | } 38 | 39 | public String getHeadName() { 40 | return headName; 41 | } 42 | 43 | public String getOfficeName() { 44 | return officeName; 45 | } 46 | 47 | public String getPassword() { 48 | return password; 49 | } 50 | 51 | public String getUsername() { 52 | return username; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/java/log4j.properties: -------------------------------------------------------------------------------- 1 | # defining the root logger with two appender 2 | log4j.rootLogger=INFO, infoApp, errorApp 3 | 4 | # Configuration of the infoApp appender. It will log at log level INFO and WARN 5 | 6 | log4j.appender.infoApp=org.apache.log4j.DailyRollingFileAppender 7 | log4j.appender.infoApp.File=FTS/info_log.log 8 | log4j.appender.infoApp.Threshold=INFO 9 | log4j.appender.infoApp.DatePattern='.' yyyy-MM-dd 10 | 11 | # a filter is used to filtering out ERROR and FATAL 12 | log4j.appender.infoApp.filter.a=org.apache.log4j.varia.LevelRangeFilter 13 | log4j.appender.infoApp.filter.a.LevelMin=INFO 14 | log4j.appender.infoApp.filter.a.LevelMax=WARN 15 | log4j.appender.infoApp.filter.a.AcceptOnMatch=true 16 | 17 | log4j.appender.infoApp.layout=org.apache.log4j.PatternLayout 18 | log4j.appender.infoApp.layout.ConversionPattern=%d{dd-MM-yyyy, HH:mm:ss} %p %C.%M:%L :: %m%n 19 | 20 | 21 | # Configuration of the errorApp appender. It will log at log level ERROR and FATAL 22 | 23 | log4j.appender.errorApp=org.apache.log4j.DailyRollingFileAppender 24 | log4j.appender.errorApp.Threshold=ERROR 25 | log4j.appender.errorApp.File=FTS/debug_log.log 26 | log4j.appender.errorApp.DatePattern='.' yyyy-MM-dd 27 | log4j.appender.errorApp.layout=org.apache.log4j.PatternLayout 28 | log4j.appender.errorApp.layout.ConversionPattern=%d{dd-MM-yyyy HH:mm:ss} %p %C.%M:%L :: %m%n 29 | -------------------------------------------------------------------------------- /src/java/bca/fts/dao/IDDao.java: -------------------------------------------------------------------------------- 1 | // this class gives the last ID of the table 'branchdetails' 2 | package bca.fts.dao; 3 | 4 | import java.sql.*; 5 | import org.apache.log4j.*; 6 | 7 | import bca.fts.util.*; 8 | 9 | public class IDDao { 10 | 11 | // the logger object 12 | private static final Logger logger = Logger.getLogger(IDDao.class); 13 | 14 | public static int getLastID() { 15 | 16 | Connection con = null; 17 | Statement st = null; 18 | ResultSet rs = null; 19 | 20 | int lastID = 0; 21 | 22 | String sql = "SELECT MAX(id) FROM branchdetails"; 23 | 24 | try { 25 | con = DatabaseConnector.getConnection(); 26 | st = con.createStatement(); 27 | rs = st.executeQuery(sql); 28 | 29 | if (rs.next()) { 30 | lastID = rs.getInt(1); 31 | } 32 | 33 | } catch (Exception e) { 34 | logger.error(e); 35 | 36 | lastID = -1; // database error 37 | } finally { 38 | 39 | // cleane up database resources 40 | DatabaseConnector.closeResultSet(rs); 41 | DatabaseConnector.closeStatement(st); 42 | DatabaseConnector.freeConncetion(con); 43 | } 44 | 45 | return lastID; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/java/bca/fts/util/PasswordValidator.java: -------------------------------------------------------------------------------- 1 | // this class will validate a given password 2 | package bca.fts.util; 3 | 4 | import java.util.regex.*; 5 | 6 | public class PasswordValidator { 7 | 8 | public static String validatePassword(String pass) { 9 | 10 | String message = ""; 11 | String alphabate = "[a-zA-z]+"; 12 | String digit = "\\d+"; 13 | String special = "[^a-zA-Z0-9]+"; 14 | 15 | Pattern digitPattern = Pattern.compile(digit); 16 | Pattern specPattern = Pattern.compile(special); 17 | Pattern alphaPattern = Pattern.compile(alphabate); 18 | 19 | if (pass.length() < 8) { 20 | message = "Password is less then 8 characters"; 21 | return message; 22 | } 23 | 24 | // check for digits 25 | if (digitPattern.matcher(pass).find() == false) { 26 | message = "Password does not contain a digit"; 27 | return message; 28 | } 29 | 30 | // check for special character 31 | if (specPattern.matcher(pass).find() == false) { 32 | message = "Password does not contain a special character"; 33 | return message; 34 | } 35 | 36 | // check for alphabates 37 | if (alphaPattern.matcher(pass).find() == false) { 38 | message = "Password does not contain an alphabate"; 39 | return message; 40 | } 41 | 42 | return message; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /web/branch/messageToBranch.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Successful File Registration 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 |
22 | | Add another file 23 | | Back to My Account 24 |
25 |
26 | 27 |
28 | 29 |
30 |
31 | 32 |

33 | 34 | File NO:   ${ requestScope.fileBean.no}
35 | File Name:   ${ requestScope.fileBean["name"] }


36 | 37 | -- has been registered successfully.

38 | The corresponding file ID is: ${ requestScope.fileBean.id } 39 |
40 |

41 | 42 |
43 | 44 |
45 | 46 |
47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/java/bca/fts/dao/NotificationDao.java: -------------------------------------------------------------------------------- 1 | package bca.fts.dao; 2 | 3 | import java.sql.*; 4 | import org.apache.log4j.*; 5 | 6 | import bca.fts.util.*; 7 | 8 | public class NotificationDao { 9 | 10 | // the logger object 11 | private static final Logger logger = Logger.getLogger(NotificationDao.class); 12 | 13 | // this method counts the no of files to display as notification 14 | public static int giveNotification(String branch) { 15 | 16 | Connection con = null; 17 | PreparedStatement ps = null; 18 | ResultSet res = null; 19 | 20 | int newFiles = 0; 21 | 22 | String sql = "SELECT COUNT(*) FROM files WHERE curLoc = ? AND ( status=\"PENDING\" OR status=\"REJECTED\")"; 23 | 24 | try { 25 | con = DatabaseConnector.getConnection(); 26 | ps = con.prepareStatement(sql); 27 | 28 | ps.setString(1, branch); 29 | 30 | res = ps.executeQuery(); 31 | 32 | // get the no of incoming files 33 | if (res.next()) { 34 | newFiles = res.getInt(1); 35 | } 36 | 37 | } catch (Exception e) { 38 | logger.error(e); 39 | 40 | newFiles = -1; // database error 41 | } finally { 42 | 43 | // clean up database resources 44 | DatabaseConnector.closeResultSet(res); 45 | DatabaseConnector.closePreStatement(ps); 46 | DatabaseConnector.freeConncetion(con); 47 | } 48 | 49 | return newFiles; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/LogoutServlet.java: -------------------------------------------------------------------------------- 1 | // this servlet logs a user out of his/her account 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import org.apache.log4j.*; 8 | 9 | import bca.fts.model.*; 10 | 11 | public class LogoutServlet extends HttpServlet { 12 | 13 | // the logger object 14 | private static final Logger logger = Logger.getLogger(LogoutServlet.class); 15 | 16 | @Override 17 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 18 | throws ServletException, IOException { 19 | 20 | doPost(request, response); 21 | } 22 | 23 | @Override 24 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 25 | throws ServletException, IOException { 26 | 27 | HttpSession session = request.getSession(false); 28 | AdminBean admin = (AdminBean) session.getAttribute("admin"); 29 | BranchBean branch = (BranchBean) session.getAttribute("branch"); 30 | 31 | String user = null; 32 | 33 | if (admin == null) { 34 | 35 | // this session is for branch 36 | user = branch.getOfficeName(); 37 | } else { 38 | 39 | // this session is for admin 40 | user = admin.getUserName(); 41 | } 42 | 43 | // destroy it 44 | session.invalidate(); 45 | 46 | logger.info(user + " successfully logged out"); 47 | 48 | response.sendRedirect("/FTS/"); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /web/404error.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 404 Error 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |
21 |

HTTP 404 Error: Page Not Found!

22 | 23 |

24 | We are really sorry, But the page or resource you are looking for cannot not be found. 25 |

26 |
27 |
28 | 29 |

30 | 31 | 32 | 33 | 34 | Go Back to Home 35 | 36 | 37 | 38 | Go Back to Home 39 | 40 | 41 | 42 | Go Back to Home page 43 | 44 | 45 | 46 | 47 |

48 |
49 | 50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/LoadFileType.java: -------------------------------------------------------------------------------- 1 | // this servlet is responsible for displaying all the registered file-types 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import java.util.ArrayList; 8 | 9 | import bca.fts.dao.*; 10 | import bca.fts.model.*; 11 | 12 | public class LoadFileType extends HttpServlet { 13 | 14 | @Override 15 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 16 | throws ServletException, IOException { 17 | 18 | doPost(request, response); 19 | } 20 | 21 | @Override 22 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 23 | throws ServletException, IOException { 24 | 25 | ArrayList fileTypes = null; 26 | 27 | fileTypes = AdminReportsDao.giveFileTypes(); 28 | 29 | if (fileTypes == null) { 30 | 31 | // database-error occured 32 | request.setAttribute("errorMessage", "Error has occured in the database operation!"); 33 | request.getRequestDispatcher("welcomeAdmin.jsp").forward(request, response); 34 | } else if (fileTypes.isEmpty()) { 35 | 36 | request.setAttribute("message", "You've not registered any file type yet"); 37 | request.getRequestDispatcher("addFileType.jsp").forward(request, response); 38 | 39 | } else { 40 | 41 | // set the file-type in the session 42 | HttpSession session = request.getSession(false); 43 | session.setAttribute("fileType", fileTypes); 44 | 45 | request.getRequestDispatcher("addFileType.jsp").forward(request, response); 46 | } 47 | 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /web/WEB-INF/tags/showFileData.tag: -------------------------------------------------------------------------------- 1 | <%@tag description="Displays file-track record" pageEncoding="UTF-8"%> 2 | <%@tag import="java.util.Arrays" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | <% 18 | 19 | String[] dates = (String[]) request.getAttribute("dates"); 20 | String[] path = (String[]) request.getAttribute("path"); 21 | String[] rDates = ( String[] ) request.getAttribute( "rDates"); 22 | 23 | String recieveDates = "Not recieved yet"; 24 | 25 | // While displaying "recieve dates", elements should be counted from index[1] 26 | 27 | for ( int i = 0; i < dates.length; i++ ) { 28 | 29 | %> 30 | 31 | 32 | 33 | 34 | 35 | 49 | 50 | 51 | 52 | <% 53 | } 54 | %> 55 | 56 | 57 | 58 |
SENDER BRANCH DATE-OF-SEND FORWARD-TO-BRANCH DATE-OF-RECEIVE
<%= path[i] %> <%= dates[i] %> <%= path[i + 1] %> 36 | 37 | 38 | if( i + 1 == rDates.length ) { 39 | recieveDates = "Not recieved yet"; 40 | } 41 | else { 42 | recieveDates = rDates[ i + 1 ]; 43 | } 44 | 45 | 46 | <%= recieveDates %> 47 | 48 |
-------------------------------------------------------------------------------- /web/admin/pages/welcomeAdmin.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Admin Welcome Page 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 32 | 33 |
34 |

Welcome Admin-  

35 |
36 | 37 |

38 | ${requestScope.message} 39 | ${requestScope.errorMessage} 40 |

41 |
42 | 43 |
44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/ListRegFilesBranch.java: -------------------------------------------------------------------------------- 1 | // this servlet giver the list of registered files of a particular branch 2 | package bca.fts.controller; 3 | 4 | import java.util.ArrayList; 5 | import java.io.*; 6 | import javax.servlet.*; 7 | import javax.servlet.http.*; 8 | import org.apache.log4j.*; 9 | 10 | import bca.fts.dao.*; 11 | import bca.fts.model.*; 12 | 13 | public class ListRegFilesBranch extends HttpServlet { 14 | 15 | // the logger object 16 | private static final Logger logger = Logger.getLogger(ListRegFilesBranch.class); 17 | 18 | @Override 19 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 20 | throws ServletException, IOException { 21 | 22 | doPost(request, response); 23 | } 24 | 25 | @Override 26 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 27 | throws ServletException, IOException { 28 | 29 | HttpSession session = request.getSession(false); 30 | BranchBean branch = (BranchBean) session.getAttribute("branch"); 31 | String user = branch.getUsername(); 32 | 33 | ArrayList files = null; 34 | 35 | logger.info(user + " viewed the registered file list"); 36 | 37 | // call "dao" to give the list of files and branches where files can be dispatched 38 | files = BranchReportDao.giveFiles(branch.getOfficeName()); 39 | 40 | if (files != null) { 41 | 42 | session.setAttribute("registeredFiles", files); 43 | request.getRequestDispatcher("regFileList.jsp").forward(request, response); 44 | 45 | } else { 46 | request.setAttribute("errorMessage", "No file found"); 47 | request.getRequestDispatcher("welcomeBranch.jsp").forward(request, response); 48 | } 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/GetFileRecord.java: -------------------------------------------------------------------------------- 1 | // this servlet fetch the data of the file to be updated and display it via view-fileEdit.jsp 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | 8 | import bca.fts.model.*; 9 | import bca.fts.dao.*; 10 | 11 | public class GetFileRecord extends HttpServlet { 12 | 13 | @Override 14 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) 15 | throws ServletException, IOException { 16 | doPost(req, resp); 17 | } 18 | 19 | @Override 20 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 21 | throws ServletException, IOException { 22 | 23 | String id = request.getParameter("id"); 24 | FileBean file = null; 25 | String errMessage = ""; 26 | int fileID = 0; 27 | 28 | if (id == null || id.isEmpty()) { 29 | file = null; 30 | } else { 31 | 32 | fileID = Integer.valueOf(id.trim()); 33 | 34 | file = FileDao.giveFileRecord(fileID); 35 | } 36 | 37 | //check if file record is found or not 38 | if (file != null) { 39 | 40 | // set the fileBean in session, instead of request scope, so that if user submits wrong data, data can still 41 | // be retrieved form the session 42 | HttpSession session = request.getSession(false); 43 | session.setAttribute("fileBean", file); 44 | 45 | request.getRequestDispatcher("loadFileType.do?page=fileEdit.jsp").forward(request, response); 46 | 47 | } else { 48 | 49 | request.setAttribute("errorMessage", "Record couldn't be retrieved"); 50 | request.getRequestDispatcher("listRegFiles.do").forward(request, response); 51 | } 52 | 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /web/500error.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 500 Error 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |
21 |

HTTP 500 Error: Internal Server Error!

22 | 23 |

24 | The server encountered an error while fulfilling your request. Please contact the webmaster.
25 | We are really sorry for the inconvenience. 26 |

27 | 28 |

29 | Error message form the server: ${ pageContext.exception }
30 |

31 |
32 |
33 | 34 |

35 | 36 | 37 | 38 | 39 | Go Back to Home 40 | 41 | 42 | 43 | Go Back to Home 44 | 45 | 46 | 47 | Go Back to Home page 48 | 49 | 50 | 51 | 52 |

53 | 54 |
55 |
56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/java/bca/fts/util/AdminAccountFilter.java: -------------------------------------------------------------------------------- 1 | package bca.fts.util; 2 | 3 | import java.io.*; 4 | import javax.servlet.*; 5 | import javax.servlet.http.*; 6 | 7 | public class AdminAccountFilter implements Filter { 8 | 9 | private FilterConfig filterConfig = null; 10 | 11 | @Override 12 | public void init(FilterConfig filterConfig) throws ServletException { 13 | 14 | this.filterConfig = filterConfig; 15 | } 16 | 17 | @Override 18 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 19 | throws IOException, ServletException { 20 | 21 | HttpServletResponse res = (HttpServletResponse) response; 22 | HttpServletRequest req = (HttpServletRequest) request; 23 | 24 | ServletContext sc = filterConfig.getServletContext(); 25 | int adminAccount = (Integer) sc.getAttribute("adminAccount"); 26 | 27 | if (adminAccount == -1) { // database error occured 28 | 29 | // forward request to the app's home page 30 | res.sendRedirect("/FTS/index.jsp"); 31 | } else if (adminAccount == 1 && req.getRequestURI().contains("install.jsp")) { 32 | 33 | // forward request to the install.jsp 34 | res.sendRedirect("/FTS/admin/index.jsp"); 35 | } else if (adminAccount == 1) { 36 | 37 | // forward request to the index.jsp 38 | chain.doFilter(request, response); 39 | } else if (adminAccount == 0 && req.getRequestURI().contains("createAcc.do")) { 40 | 41 | // forward request to the index.jsp 42 | chain.doFilter(request, response); 43 | } else { 44 | // forward request to the install.jsp 45 | req.getRequestDispatcher("install.jsp").forward(req, res); 46 | } 47 | 48 | } 49 | 50 | @Override 51 | public void destroy() { 52 | 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/AdminRegisFiles.java: -------------------------------------------------------------------------------- 1 | // this servlet is responsible for loading all registered files 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import java.util.ArrayList; 8 | import org.apache.log4j.*; 9 | 10 | import bca.fts.model.*; 11 | import bca.fts.dao.*; 12 | 13 | public class AdminRegisFiles extends HttpServlet { 14 | 15 | // the logger object 16 | private static final Logger logger = Logger.getLogger(AdminRegisFiles.class); 17 | 18 | @Override 19 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 20 | throws ServletException, IOException { 21 | 22 | doPost(request, response); 23 | } 24 | 25 | @Override 26 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 27 | throws ServletException, IOException { 28 | 29 | HttpSession session = request.getSession(false); 30 | AdminBean bean = (AdminBean) session.getAttribute("admin"); 31 | String user = bean.getUserName(); 32 | 33 | logger.info(user + " viewed the registered file report"); 34 | 35 | ArrayList files = AdminReportsDao.giveRegisteredFiles(); 36 | 37 | if (files == null) { 38 | 39 | request.setAttribute("errorMessage", "Error has occured in the database operation!"); 40 | request.getRequestDispatcher("reportsAdmin.jsp").forward(request, response); 41 | } else if (files.isEmpty()) { 42 | 43 | request.setAttribute("errorMessage", "No file found"); 44 | request.getRequestDispatcher("reportsAdmin.jsp").forward(request, response); 45 | } else { 46 | 47 | session.setAttribute("registeredFiles", files); 48 | request.getRequestDispatcher("registeredFiles.jsp").forward(request, response); 49 | } 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /web/branch/trackFile.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Track File Page 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 |
22 | 23 |
24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
26 | 27 | search file Choose your option.. 28 | 29 |
Track file by file ID
Track file by file no
Track file by file name
Track file by date of send
Track file by date of receive
47 | 48 |
49 | 50 |
51 | 52 |
53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/java/bca/fts/util/AdminFilter.java: -------------------------------------------------------------------------------- 1 | // this filter is responsible for admin Authorisation 2 | package bca.fts.util; 3 | 4 | import java.io.IOException; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import org.apache.log4j.*; 8 | 9 | public class AdminFilter implements Filter { 10 | 11 | // the logger object 12 | private static final Logger logger = Logger.getLogger(AdminFilter.class); 13 | 14 | private FilterConfig filterConfig = null; 15 | 16 | @Override 17 | public void init(FilterConfig filterConfig) throws ServletException { 18 | 19 | this.filterConfig = filterConfig; 20 | } 21 | 22 | @Override 23 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 24 | throws IOException, ServletException { 25 | 26 | HttpServletResponse res = (HttpServletResponse) response; 27 | HttpServletRequest req = (HttpServletRequest) request; 28 | 29 | HttpSession session = req.getSession(false); // give exsisting session, don't create one 30 | 31 | if (session == null) { 32 | 33 | logger.warn("unauthorised attempt to access the secure admin resource has been denied"); 34 | 35 | res.sendRedirect("/FTS/"); 36 | 37 | } else if (session.getAttribute("admin") == null) { 38 | 39 | logger.warn("unauthorised attempt to access the secure admin resource has been denied"); 40 | 41 | session.invalidate(); // invalidate the current session 42 | res.sendRedirect("/FTS/"); 43 | } else { 44 | 45 | // tell the browser not to cache the secure pages 46 | res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // for HTTP 1.1 47 | res.setHeader("Pragma", "no-cache"); // for HTTP 1.0. 48 | res.setDateHeader("Expires", 0); // Proxies. 49 | 50 | // forward request to the next resource( html/jsp/servlet ) 51 | chain.doFilter(request, response); 52 | } 53 | 54 | } 55 | 56 | @Override 57 | public void destroy() { 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/LoadFileTypeBranch.java: -------------------------------------------------------------------------------- 1 | // this servlet is responsible for displaying all the registered file-types 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import java.util.ArrayList; 8 | 9 | import bca.fts.dao.*; 10 | 11 | public class LoadFileTypeBranch extends HttpServlet { 12 | 13 | @Override 14 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 15 | throws ServletException, IOException { 16 | 17 | doPost(request, response); 18 | } 19 | 20 | @Override 21 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 22 | throws ServletException, IOException { 23 | 24 | String page = request.getParameter("page"); 25 | 26 | ArrayList fileTypes = null; 27 | 28 | fileTypes = AdminReportsDao.giveFileTypes(); 29 | 30 | if (fileTypes == null) { 31 | 32 | // database-error occured 33 | request.setAttribute("errorMessage", "Error has occured in the database operation!"); 34 | 35 | if (page == null) { 36 | request.getRequestDispatcher("welcomeBranch.jsp").forward(request, response); 37 | } else { 38 | request.getRequestDispatcher("regFileList.jsp").forward(request, response); 39 | } 40 | } else if (fileTypes.isEmpty()) { 41 | 42 | request.setAttribute("message", "No file type has been registered yet. Contact the Admin"); 43 | request.getRequestDispatcher("welcomeBranch.jsp").forward(request, response); 44 | 45 | } else { 46 | 47 | // give the existing session, don't create one 48 | HttpSession session = request.getSession(false); 49 | session.setAttribute("fileType", fileTypes); 50 | 51 | if (page == null) { 52 | request.getRequestDispatcher("fileRegister.jsp").forward(request, response); 53 | } else { 54 | request.getRequestDispatcher(page).forward(request, response); 55 | } 56 | 57 | } 58 | 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/java/bca/fts/util/BranchFilter.java: -------------------------------------------------------------------------------- 1 | // this filter is responsible for branch Authorisation 2 | package bca.fts.util; 3 | 4 | import java.io.IOException; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import org.apache.log4j.*; 8 | 9 | public class BranchFilter implements Filter { 10 | 11 | // the logger object 12 | private static final Logger logger = Logger.getLogger(BranchFilter.class); 13 | 14 | private FilterConfig filterConfig = null; 15 | 16 | @Override 17 | public void init(FilterConfig filterConfig) throws ServletException { 18 | 19 | this.filterConfig = filterConfig; 20 | } 21 | 22 | @Override 23 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 24 | throws IOException, ServletException { 25 | 26 | HttpServletResponse res = (HttpServletResponse) response; 27 | HttpServletRequest req = (HttpServletRequest) request; 28 | 29 | HttpSession session = req.getSession(false); // give exsisting session, don't create one 30 | 31 | if (session == null) { 32 | 33 | logger.warn("unauthorised attempt to access the secure branch resource has been denied"); 34 | 35 | // for the RequestDispatcher, "/" means context path of the web app 36 | res.sendRedirect("/FTS/"); 37 | 38 | } else if (session.getAttribute("branch") == null) { 39 | 40 | logger.warn("unauthorised attempt to access the secure branch resource has been denied"); 41 | 42 | session.invalidate(); 43 | res.sendRedirect("/FTS/"); 44 | } else { 45 | 46 | // tell the browser not to cache the secure pages 47 | res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // for HTTP 1.1. 48 | res.setHeader("Pragma", "no-cache"); // for old HTTP 1.0. 49 | res.setDateHeader("Expires", 0); // Proxies. 50 | 51 | // forward request to the next resource( html/jsp/servlet ) 52 | chain.doFilter(request, response); 53 | } 54 | 55 | } 56 | 57 | @Override 58 | public void destroy() { 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/BranchAutocomplete.java: -------------------------------------------------------------------------------- 1 | // this servlet is responsible for handling AJAX request and send back filenames as response 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.ServletException; 6 | import javax.servlet.http.*; 7 | import java.util.ArrayList; 8 | 9 | import com.google.gson.*; 10 | import bca.fts.dao.FileDao; 11 | 12 | public class BranchAutocomplete extends HttpServlet { 13 | 14 | @Override 15 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 16 | throws ServletException, IOException { 17 | 18 | doPost(request, response); 19 | } 20 | 21 | @Override 22 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 23 | throws ServletException, IOException { 24 | 25 | String keyword = request.getParameter("term"); 26 | ArrayList fileNames = null; 27 | 28 | // check for null values, illigal access 29 | if (keyword == null) { 30 | request.getRequestDispatcher("welcomeBranch.jsp").forward(request, response); 31 | } else { 32 | if (keyword.equals("%") || keyword.equals("_")) { 33 | 34 | // just return null 35 | String searchList = new Gson().toJson(fileNames); 36 | 37 | response.setContentType("application/json"); 38 | 39 | PrintWriter out = response.getWriter(); 40 | out.write(searchList); 41 | } else { 42 | // get the filenames from DAO 43 | fileNames = FileDao.autocompleteFileName(keyword); 44 | 45 | // database related error so don't send json data and let the browser to show the alert box 46 | if (fileNames == null) { 47 | return; 48 | } 49 | 50 | // convert the String array to JSON format 51 | String searchList = new Gson().toJson(fileNames); 52 | 53 | response.setContentType("application/json"); 54 | 55 | PrintWriter out = response.getWriter(); 56 | out.write(searchList); 57 | } 58 | } 59 | 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/AdminAutocomplete.java: -------------------------------------------------------------------------------- 1 | // this servlet is responsible for handling AJAX request and send back filenames as response 2 | package bca.fts.controller; 3 | 4 | import bca.fts.dao.FileDao; 5 | import com.google.gson.Gson; 6 | import java.io.*; 7 | import java.util.ArrayList; 8 | import javax.servlet.ServletException; 9 | import javax.servlet.http.*; 10 | 11 | public class AdminAutocomplete extends HttpServlet { 12 | 13 | @Override 14 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 15 | throws ServletException, IOException { 16 | 17 | doPost(request, response); 18 | } 19 | 20 | @Override 21 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 22 | throws ServletException, IOException { 23 | 24 | String keyword = request.getParameter("term"); 25 | 26 | // check for null values, illigal access 27 | if (keyword == null) { 28 | request.getRequestDispatcher("welcomeAdmin.jsp").forward(request, response); 29 | } else { 30 | ArrayList fileNames = null; 31 | 32 | if (keyword.equals("%") || keyword.equals("_")) { 33 | 34 | // just return null 35 | String searchList = new Gson().toJson(fileNames); 36 | 37 | response.setContentType("application/json"); 38 | 39 | PrintWriter out = response.getWriter(); 40 | out.write(searchList); 41 | } else { 42 | // get the filenames from DAO 43 | fileNames = FileDao.autocompleteFileName(keyword); 44 | 45 | // database related error so don't send json data and let the browser to show the alert box 46 | if (fileNames == null) { 47 | return; 48 | } 49 | 50 | // convert the String array to JSON format 51 | String searchList = new Gson().toJson(fileNames); 52 | 53 | response.setContentType("application/json"); 54 | 55 | PrintWriter out = response.getWriter(); 56 | out.write(searchList); 57 | } 58 | } 59 | 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/DeleteFileType.java: -------------------------------------------------------------------------------- 1 | //this servlet delete a file-type to the database 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import org.apache.log4j.*; 8 | 9 | import bca.fts.dao.*; 10 | import bca.fts.model.AdminBean; 11 | 12 | public class DeleteFileType extends HttpServlet { 13 | 14 | private static final Logger logger = Logger.getLogger(DeleteFileType.class); 15 | 16 | @Override 17 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) 18 | throws ServletException, IOException { 19 | doPost(req, resp); 20 | } 21 | 22 | @Override 23 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 24 | throws ServletException, IOException { 25 | 26 | HttpSession session = request.getSession(false); 27 | AdminBean bean = (AdminBean) session.getAttribute("admin"); 28 | String user = bean.getUserName(); 29 | 30 | String fileType = request.getParameter("fileType"); 31 | int row = 0; 32 | 33 | // illigal access 34 | if (fileType == null) { 35 | request.getRequestDispatcher("welcomeAdmin.jsp").forward(request, response); 36 | } else { 37 | 38 | row = FileDao.deleteFileType(fileType.trim()); 39 | 40 | // redirect the requset to the appropiate page 41 | if (row == 1) { 42 | logger.info(user + " deleted file type " + fileType); 43 | 44 | request.setAttribute("message", "File-type " + fileType + " has been successfully deleted"); 45 | request.getRequestDispatcher("loadFileTypes.do").forward(request, response); 46 | } else if (row == 0) { 47 | 48 | request.setAttribute("errorMessage", "File type " + fileType + " couldn't be deleted"); 49 | request.getRequestDispatcher("addFileType.jsp").forward(request, response); 50 | } else { 51 | request.setAttribute("errorMessage", "Error has occured in the databse operation!"); 52 | request.getRequestDispatcher("addFileType.jsp").forward(request, response); 53 | } 54 | 55 | } 56 | 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /web/admin/pages/trackFile.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Track File Page 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 |
23 | 24 |
25 | 26 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 |
27 | 28 | search file Choose your option.. 29 | 30 |
Track file by file ID
Track file by file no
Track file by file name
Track file by file-status
Track file by branch
Track file by date of send
Track file by date of receive
54 | 55 |
56 | 57 |
58 | 59 |
60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/java/bca/fts/util/DatabaseConnector.java: -------------------------------------------------------------------------------- 1 | // this class implements Java's Conncetion Pulling 2 | // to SPEED UP Database OPERATIONS 3 | // DATE: 18-02-2015 4 | package bca.fts.util; 5 | 6 | import java.sql.*; 7 | import javax.sql.DataSource; 8 | import javax.naming.InitialContext; 9 | import org.apache.log4j.*; 10 | 11 | public class DatabaseConnector { 12 | 13 | private static InitialContext ic = null; 14 | private static DataSource ds = null; 15 | 16 | // the logger object 17 | private static Logger logger = Logger.getLogger(DatabaseConnector.class); 18 | 19 | // this method will be called only once 20 | private static void initMethod() { 21 | 22 | try { 23 | ic = new InitialContext(); 24 | ds = (DataSource) ic.lookup("java:/comp/env/jdbc/file_tracking"); 25 | } catch (Exception e) { 26 | logger.fatal(e, e); 27 | } 28 | } 29 | 30 | public static Connection getConnection() { 31 | 32 | Connection con = null; 33 | 34 | if (ic == null || ds == null) { 35 | initMethod(); 36 | } 37 | 38 | try { 39 | con = ds.getConnection(); 40 | } catch (Exception e) { 41 | logger.fatal(e, e); 42 | } 43 | 44 | return con; 45 | } 46 | 47 | public static void freeConncetion(Connection con) { 48 | try { 49 | if (con != null) { 50 | con.close(); 51 | } 52 | } catch (Exception e) { 53 | logger.fatal(e, e); 54 | } 55 | } 56 | 57 | public static void closeResultSet(ResultSet res) { 58 | try { 59 | if (res != null) { 60 | res.close(); 61 | } 62 | } catch (Exception e) { 63 | logger.fatal(e, e); 64 | } 65 | } 66 | 67 | public static void closeStatement(Statement st) { 68 | try { 69 | if (st != null) { 70 | st.close(); 71 | } 72 | } catch (Exception e) { 73 | logger.fatal(e, e); 74 | } 75 | } 76 | 77 | public static void closePreStatement(PreparedStatement pst) { 78 | try { 79 | if (pst != null) { 80 | pst.close(); 81 | } 82 | } catch (Exception e) { 83 | logger.fatal(e, e); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /web/branch/welcomeBranch.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Branch Welcome Page 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 32 | 33 |
34 |

Welcome User-  

35 | 36 |

Login from Branch-  

37 | 38 |

39 |
40 | <%-- for displaying notification --%> 41 | 42 | ${ sessionScope.notification } 43 | 44 |

45 | 46 |

47 | <%-- for success and error message --%> 48 | ${requestScope.message} 49 | ${requestScope.errorMessage} 50 |

51 |
52 | 53 |
54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/ViewSentFiles.java: -------------------------------------------------------------------------------- 1 | // this servlet gives the list of sent files of a branch with there current status 2 | package bca.fts.controller; 3 | 4 | import java.util.ArrayList; 5 | import java.io.*; 6 | import javax.servlet.*; 7 | import javax.servlet.http.*; 8 | import org.apache.log4j.*; 9 | 10 | import bca.fts.dao.*; 11 | import bca.fts.model.*; 12 | import java.util.Collections; 13 | import java.util.Comparator; 14 | 15 | public class ViewSentFiles extends HttpServlet { 16 | 17 | // the logger object 18 | private static final Logger logger = Logger.getLogger(ViewSentFiles.class); 19 | 20 | @Override 21 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) 22 | throws ServletException, IOException { 23 | 24 | doPost(req, resp); 25 | } 26 | 27 | @Override 28 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 29 | throws ServletException, IOException { 30 | 31 | HttpSession session = request.getSession(false); 32 | BranchBean branch = (BranchBean) session.getAttribute("branch"); 33 | String user = branch.getUsername(); 34 | 35 | ArrayList files = null; 36 | 37 | logger.info(user + " viewed the sent file list"); 38 | 39 | // get the lits of sent files from "dao" 40 | files = BranchReportDao.giveSentFiles(branch.getOfficeName()); 41 | 42 | if (files != null) { 43 | 44 | // sort the list first in Ascending order based on the date of date-of-send; 45 | Collections.sort(files, new Comparator() { 46 | 47 | @Override 48 | public int compare(FileBean o1, FileBean o2) { 49 | return o1.getDate().compareTo(o2.getDate()); 50 | } 51 | }); 52 | 53 | // sort the list first in Ascending order; 54 | Collections.reverse(files); 55 | 56 | session.setAttribute("sentFiles", files); 57 | request.getRequestDispatcher("sentFiles.jsp").forward(request, response); 58 | 59 | } else { 60 | request.setAttribute("errorMessage", "No file found"); 61 | request.getRequestDispatcher("welcomeBranch.jsp").forward(request, response); 62 | } 63 | 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/AdminPendingFiles.java: -------------------------------------------------------------------------------- 1 | // this servlet is responsible for loading all pending files 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import java.util.*; 8 | import org.apache.log4j.*; 9 | 10 | import bca.fts.model.*; 11 | import bca.fts.dao.*; 12 | 13 | public class AdminPendingFiles extends HttpServlet { 14 | 15 | // the logger object 16 | private static final Logger logger = Logger.getLogger(AdminPendingFiles.class); 17 | 18 | @Override 19 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 20 | throws ServletException, IOException { 21 | 22 | doPost(request, response); 23 | } 24 | 25 | @Override 26 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 27 | throws ServletException, IOException { 28 | 29 | HttpSession session = request.getSession(false); 30 | AdminBean bean = (AdminBean) session.getAttribute("admin"); 31 | String user = bean.getUserName(); 32 | 33 | logger.info(user + " viewed the pending file report"); 34 | 35 | ArrayList files = AdminReportsDao.givePendingFiles(); 36 | 37 | if (files == null) { 38 | 39 | request.setAttribute("errorMessage", "Error has occured in the database operation!"); 40 | request.getRequestDispatcher("reportsAdmin.jsp").forward(request, response); 41 | } else if (files.isEmpty()) { 42 | 43 | request.setAttribute("errorMessage", "No file found"); 44 | request.getRequestDispatcher("reportsAdmin.jsp").forward(request, response); 45 | } else { 46 | 47 | // sort the list first in Ascending order based on the date of date-of-send; 48 | Collections.sort(files, new Comparator() { 49 | 50 | @Override 51 | public int compare(FileBean o1, FileBean o2) { 52 | return o1.getDate().compareTo(o2.getDate()); 53 | } 54 | }); 55 | 56 | // sort the list first in Ascending order; 57 | Collections.reverse(files); 58 | 59 | session.setAttribute("pendingFiles", files); 60 | request.getRequestDispatcher("pendingFiles.jsp").forward(request, response); 61 | } 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/java/bca/fts/model/SendFileBean.java: -------------------------------------------------------------------------------- 1 | // this bean represents a sent file 2 | 3 | package bca.fts.model; 4 | 5 | import java.text.SimpleDateFormat; 6 | import java.util.Date; 7 | import org.apache.log4j.Logger; 8 | 9 | public class SendFileBean { 10 | 11 | // the logger object 12 | private static final Logger logger = Logger.getLogger(SendFileBean.class); 13 | 14 | private int fileId = 0; 15 | private String senderBranch = null; 16 | private String forwardBranch = null; 17 | private String dateOfSend = null; 18 | private String timeOfSend = null; 19 | private String remark = null; 20 | 21 | // for sorting 22 | private Date date = null; 23 | 24 | // all the "getter" methods 25 | 26 | public Date getDate() { 27 | return date; 28 | } 29 | 30 | public String getTimeOfSend() { 31 | return timeOfSend; 32 | } 33 | 34 | public String getRemark() { 35 | return remark; 36 | } 37 | 38 | public int getFileId() { 39 | return fileId; 40 | } 41 | 42 | public String getSenderBranch() { 43 | return senderBranch; 44 | } 45 | 46 | public String getForwardBranch() { 47 | return forwardBranch; 48 | } 49 | 50 | public String getDateOfSend() { 51 | return dateOfSend; 52 | } 53 | 54 | 55 | // all the "setter" methods 56 | public void setDate() { 57 | SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy 'at' hh:mm:ss a"); 58 | 59 | try { 60 | 61 | this.date = formatter.parse(this.dateOfSend); 62 | } 63 | catch (Exception e) { 64 | logger.error(e); 65 | } 66 | } 67 | 68 | public void setTimeOfSend( String timeOfSend ) { 69 | this.timeOfSend = timeOfSend; 70 | } 71 | 72 | public void setFileId(int fileId) { 73 | this.fileId = fileId; 74 | } 75 | 76 | public void setSenderBranch(String senderBranch) { 77 | this.senderBranch = senderBranch; 78 | } 79 | 80 | public void setDateOfSend(String dateOfSend) { 81 | this.dateOfSend = dateOfSend; 82 | } 83 | 84 | public void setForwardBranch( String forwardBranch ) { 85 | this.forwardBranch = forwardBranch; 86 | } 87 | 88 | public void setRemark(String remark) { 89 | this.remark = remark; 90 | } 91 | 92 | } -------------------------------------------------------------------------------- /web/admin/pages/reportsAdmin.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Admin Reports Page 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 |
22 | 23 |
${ requestScope.errorMessage }
24 |
25 | 26 |

Generating Reports for Admin...

27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
View The Report Of
List of Registered Files
List of Pending Files
List of Rejected Files
List of Processing Files
List of Closed Files
60 | 61 | 62 |
63 | 64 | 65 | 66 |
67 | 68 |
69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /web/admin/index.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | <%-- Don't create session for this page, let the session to create after successful login --%> 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Admin Login Page 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 |
24 | 25 |
${requestScope.message}
26 |
${requestScope.errorMessage}
27 | 28 |
29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 50 | 51 | 52 | 53 |
Administrator Login Panel
Username:    
  
Password:    
Login 48 | 49 | Login
54 |
55 | 56 |
57 | 58 |
59 | 60 | 61 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/AdminRejectFiles.java: -------------------------------------------------------------------------------- 1 | // this servlet is responsible for loading all rejected files 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import java.util.ArrayList; 8 | import org.apache.log4j.*; 9 | 10 | import bca.fts.model.*; 11 | import bca.fts.dao.*; 12 | import java.util.Collections; 13 | import java.util.Comparator; 14 | 15 | public class AdminRejectFiles extends HttpServlet { 16 | 17 | // the logger object 18 | private static final Logger logger = Logger.getLogger(AdminRejectFiles.class); 19 | 20 | @Override 21 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 22 | throws ServletException, IOException { 23 | 24 | doPost(request, response); 25 | } 26 | 27 | @Override 28 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 29 | throws ServletException, IOException { 30 | 31 | HttpSession session = request.getSession(false); 32 | AdminBean bean = (AdminBean) session.getAttribute("admin"); 33 | String user = bean.getUserName(); 34 | 35 | logger.info(user + " viewed the rejected file report"); 36 | 37 | ArrayList files = AdminReportsDao.giveRejectedFiles(); 38 | 39 | if (files == null) { 40 | 41 | request.setAttribute("errorMessage", "Error has occured in the database operation!"); 42 | request.getRequestDispatcher("reportsAdmin.jsp").forward(request, response); 43 | } else if (files.isEmpty()) { 44 | 45 | request.setAttribute("errorMessage", "No file found"); 46 | request.getRequestDispatcher("reportsAdmin.jsp").forward(request, response); 47 | } else { 48 | 49 | // sort the list first in Ascending order based on the date of date-of-send; 50 | Collections.sort(files, new Comparator() { 51 | 52 | @Override 53 | public int compare(FileBean o1, FileBean o2) { 54 | return o1.getDate().compareTo(o2.getDate()); 55 | } 56 | }); 57 | 58 | // sort the list first in Ascending order; 59 | Collections.reverse(files); 60 | 61 | session.setAttribute("rejectedFiles", files); 62 | request.getRequestDispatcher("rejectedFiles.jsp").forward(request, response); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /web/index.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | 4 | <%--- Don't create session for this page, let the session to create after successful login ---%> 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | File Tracking System 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 |
26 | 27 |
${ requestScope.errorMessage}
28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 55 | 56 |
Branch Login Panel
Username:   
  
Password:   
  
51 | 52 |      53 | 54 |
57 | 58 |
59 |
60 | 61 |
62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/AdminCloseFiles.java: -------------------------------------------------------------------------------- 1 | // this servlet is responsible for loading all closed files 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import java.util.ArrayList; 8 | import org.apache.log4j.*; 9 | 10 | import bca.fts.model.*; 11 | import bca.fts.dao.*; 12 | import java.util.Collections; 13 | import java.util.Comparator; 14 | 15 | public class AdminCloseFiles extends HttpServlet { 16 | 17 | // the logger object 18 | private static final Logger logger = Logger.getLogger(AdminCloseFiles.class); 19 | 20 | @Override 21 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 22 | throws ServletException, IOException { 23 | 24 | doPost(request, response); 25 | } 26 | 27 | @Override 28 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 29 | throws ServletException, IOException { 30 | 31 | HttpSession session = request.getSession(false); 32 | AdminBean bean = (AdminBean) session.getAttribute("admin"); 33 | String user = bean.getUserName(); 34 | 35 | logger.info(user + " viewed the closed file report"); 36 | 37 | ArrayList files = AdminReportsDao.giveClosedFiles(); 38 | 39 | if (files == null) { 40 | 41 | request.setAttribute("errorMessage", "Error has occured in the database operation!"); 42 | request.getRequestDispatcher("reportsAdmin.jsp").forward(request, response); 43 | } else if (files.isEmpty()) { 44 | 45 | request.setAttribute("errorMessage", "No file found"); 46 | request.getRequestDispatcher("reportsAdmin.jsp").forward(request, response); 47 | } else { 48 | 49 | // sort the list first in Ascending order based on the date of date-of-send; 50 | Collections.sort(files, new Comparator() { 51 | 52 | @Override 53 | public int compare(ClosedFileBean o1, ClosedFileBean o2) { 54 | return o1.getDate().compareTo(o2.getDate()); 55 | } 56 | }); 57 | 58 | // sort the list first in Ascending order; 59 | Collections.reverse(files); 60 | 61 | session.setAttribute("closeFiles", files); 62 | request.getRequestDispatcher("closedFiles.jsp").forward(request, response); 63 | } 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/AdminProcessFiles.java: -------------------------------------------------------------------------------- 1 | // this servlet is responsible for loading all processing files 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import java.util.ArrayList; 8 | import org.apache.log4j.*; 9 | 10 | import bca.fts.model.*; 11 | import bca.fts.dao.*; 12 | import java.util.Collections; 13 | import java.util.Comparator; 14 | 15 | public class AdminProcessFiles extends HttpServlet { 16 | 17 | // the logger object 18 | private static final Logger logger = Logger.getLogger(AdminProcessFiles.class); 19 | 20 | @Override 21 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 22 | throws ServletException, IOException { 23 | 24 | doPost(request, response); 25 | } 26 | 27 | @Override 28 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 29 | throws ServletException, IOException { 30 | 31 | HttpSession session = request.getSession(false); 32 | AdminBean bean = (AdminBean) session.getAttribute("admin"); 33 | String user = bean.getUserName(); 34 | 35 | logger.info(user + " viewed the processing file report"); 36 | 37 | ArrayList files = AdminReportsDao.giveProcessingFiles(); 38 | 39 | if (files == null) { 40 | 41 | request.setAttribute("errorMessage", "Error has occured in the database operation!"); 42 | request.getRequestDispatcher("reportsAdmin.jsp").forward(request, response); 43 | } else if (files.isEmpty()) { 44 | 45 | request.setAttribute("errorMessage", "No file found"); 46 | request.getRequestDispatcher("reportsAdmin.jsp").forward(request, response); 47 | } else { 48 | 49 | // sort the list first in Ascending order based on the date of date-of-send; 50 | Collections.sort(files, new Comparator() { 51 | 52 | @Override 53 | public int compare(ProcessingFileBean o1, ProcessingFileBean o2) { 54 | return o1.getDate().compareTo(o2.getDate()); 55 | } 56 | }); 57 | 58 | // the sort the list in decending order; 59 | Collections.reverse(files); 60 | 61 | session.setAttribute("processingFiles", files); 62 | request.getRequestDispatcher("processingFiles.jsp").forward(request, response); 63 | } 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /web/admin/pages/pendingFiles.jsp: -------------------------------------------------------------------------------- 1 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%@taglib uri="http://displaytag.sf.net" prefix="display" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Pending Files Page 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 |
30 | 31 |
32 | 33 | 34 | List of Pending Files... 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 |
53 | 54 |
55 | 56 |
57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/BranchRecordsAdmin.java: -------------------------------------------------------------------------------- 1 | // this servlet loads a list of registered branch records and sends it to the appropiate VIEW 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import java.util.ArrayList; 8 | import org.apache.log4j.*; 9 | 10 | import bca.fts.dao.*; 11 | import bca.fts.model.*; 12 | 13 | public class BranchRecordsAdmin extends HttpServlet { 14 | 15 | // the logger object 16 | private static final Logger logger = Logger.getLogger(BranchRecordsAdmin.class); 17 | 18 | @Override 19 | public void doGet(HttpServletRequest request, HttpServletResponse response) 20 | throws ServletException, IOException { 21 | 22 | doPost(request, response); 23 | } 24 | 25 | @Override 26 | public void doPost(HttpServletRequest request, HttpServletResponse response) 27 | throws ServletException, IOException { 28 | 29 | HttpSession session = request.getSession(false); 30 | AdminBean bean = (AdminBean) session.getAttribute("admin"); 31 | String user = bean.getUserName(); 32 | 33 | String bName = request.getParameter("bName"); 34 | 35 | logger.info(user + " viewed registered branch records"); 36 | 37 | // get the branch records and set it to the session 38 | ArrayList branchRecords = AdminReportsDao.giveBranches(); 39 | 40 | if (branchRecords == null) { 41 | 42 | request.setAttribute("errorMessage", "Error has occured in the database operation!"); 43 | request.getRequestDispatcher("welcomeAdmin.jsp").forward(request, response); 44 | } 45 | if (branchRecords.isEmpty()) { 46 | 47 | request.setAttribute("errorMessage", "No branch has been registered yet"); 48 | request.getRequestDispatcher("welcomeAdmin.jsp").forward(request, response); 49 | } else { 50 | session.setAttribute("branchRecords", branchRecords); 51 | 52 | // verify if "branchNames" need to be update 53 | if (bName != null) { 54 | 55 | ArrayList branchNames = new ArrayList(); 56 | 57 | // iterate over the branch-records to collect the branch names 58 | for (BranchBean b : branchRecords) { 59 | branchNames.add(b.getOfficeName()); 60 | } 61 | 62 | session.setAttribute("branchNames", branchNames); 63 | } 64 | 65 | request.getRequestDispatcher("branchList.jsp").forward(request, response); 66 | } 67 | 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /web/css/displaytag.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 14px; 3 | font-family: Consolas, "Courier New", Times, serif; 4 | background-color: white; 5 | } 6 | 7 | table { 8 | border: 1px solid #666; 9 | width: 100%; 10 | margin: 20px 0 20px 0 !important; 11 | } 12 | 13 | th,td { 14 | padding: 2px 4px 2px 4px !important; 15 | text-align: center; 16 | vertical-align: top; 17 | } 18 | 19 | thead tr { 20 | background-color: #fc0; 21 | } 22 | 23 | th.sorted { 24 | background-color: orange; 25 | } 26 | 27 | th a,th a:visited { 28 | color: black; 29 | } 30 | 31 | th a:hover { 32 | text-decoration: underline; 33 | color: black; 34 | } 35 | 36 | th.sorted a,th.sortable a { 37 | background-position: right; 38 | display: block; 39 | width: 100%; 40 | } 41 | 42 | tr.odd { 43 | background-color: #fff 44 | } 45 | 46 | tr.tableRowEven,tr.even { 47 | background-color: #fea 48 | } 49 | 50 | div.exportlinks { 51 | background-color: #eee; 52 | border: 1px dotted #999; 53 | padding: 2px 4px 2px 4px; 54 | margin: 2px 0 10px 0; 55 | width: 79%; 56 | } 57 | 58 | span.export { 59 | padding: 0 4px 1px 20px; 60 | display: inline; 61 | display: inline-block; 62 | cursor: pointer; 63 | } 64 | 65 | span.excel { 66 | background-image: url(../img/ico_file_excel.png); 67 | } 68 | 69 | span.csv { 70 | background-image: url(../img/ico_file_csv.png); 71 | } 72 | 73 | span.xml { 74 | background-image: url(../img/ico_file_xml.png); 75 | } 76 | 77 | span.pdf { 78 | background-image: url(../img/ico_file_pdf.png); 79 | } 80 | 81 | span.rtf { 82 | background-image: url(../img/ico_file_rtf.png); 83 | } 84 | 85 | span.pagebanner { 86 | background-color: #eee; 87 | border: 1px dotted #999; 88 | padding: 2px 4px 2px 4px; 89 | width: 79%; 90 | margin-top: 10px; 91 | display: block; 92 | border-bottom: none; 93 | } 94 | 95 | span.pagelinks { 96 | background-color: #eee; 97 | border: 1px dotted #999; 98 | padding: 2px 4px 2px 4px; 99 | width: 79%; 100 | display: block; 101 | border-top: none; 102 | margin-bottom: -5px; 103 | } 104 | 105 | tr:hover { 106 | background: #eeeeff 107 | } 108 | 109 | caption { 110 | padding-bottom: 7px; 111 | font-size: 16px; 112 | font-weight: bold; 113 | text-align: center; 114 | } 115 | 116 | img { 117 | border: none; 118 | } 119 | 120 | span { 121 | background-repeat: no-repeat; 122 | } 123 | 124 | a:link {text-decoration:none;} 125 | a:visited {text-decoration:none;} 126 | a:hover {text-decoration:underline;} 127 | a:active {text-decoration:underline;} 128 | -------------------------------------------------------------------------------- /web/admin/pages/branchList.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@taglib uri="http://displaytag.sf.net" prefix="display" %> 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Branch Report Page 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
32 | 33 |
34 | 35 | 36 | 37 | List of Registered Branch... 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
46 | 47 | 48 |
49 | 50 |
51 | 52 | 53 |
54 | 55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /nbproject/ant-deploy.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/RecieveFileServlet.java: -------------------------------------------------------------------------------- 1 | // this servlet is responsible for recieving a file and changing its status to "PROCESSING" 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import java.util.ArrayList; 8 | import org.apache.log4j.*; 9 | 10 | import bca.fts.dao.*; 11 | import bca.fts.model.BranchBean; 12 | import bca.fts.model.IncomingFileBean; 13 | 14 | public class RecieveFileServlet extends HttpServlet { 15 | 16 | // the logger object 17 | private static final Logger logger = Logger.getLogger(RecieveFileServlet.class); 18 | 19 | @Override 20 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 21 | throws ServletException, IOException { 22 | 23 | doPost(request, response); 24 | } 25 | 26 | @Override 27 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 28 | throws ServletException, IOException { 29 | 30 | HttpSession session = request.getSession(false); 31 | BranchBean branch = (BranchBean) session.getAttribute("branch"); 32 | String user = branch.getUsername(); 33 | 34 | String id = request.getParameter("id"); 35 | 36 | // illigal access 37 | if (id == null) { 38 | request.getRequestDispatcher("welcomeBranch.jsp").forward(request, response); 39 | } else { 40 | int fileID = Integer.valueOf(id.trim()); 41 | 42 | int result = 0; 43 | 44 | // get the incoming files list from session and make that receive_file_status = true 45 | ArrayList files = (ArrayList) session.getAttribute("incomingFiles"); 46 | 47 | for (IncomingFileBean file : files) { 48 | 49 | if (file.getId() == fileID) { 50 | file.setFileRecieved(true); 51 | 52 | break; 53 | } 54 | 55 | } 56 | 57 | // change the file's status in Database 58 | result = FileDao.changeFileStatus(fileID, "PROCESSING"); 59 | 60 | // check whether the file is recieved successfully or not 61 | if (result == 1) { 62 | logger.info(user + " recieved file having ID " + id); 63 | 64 | request.getRequestDispatcher("branchInbox.jsp").forward(request, response); 65 | } else { 66 | 67 | request.setAttribute("errorMessage", "File couldn't be recieved successfully"); 68 | request.getRequestDispatcher("branchInbox.jsp").forward(request, response); 69 | } 70 | } 71 | 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/java/bca/fts/util/DateValidator.java: -------------------------------------------------------------------------------- 1 | // this class will validate a given date 2 | package bca.fts.util; 3 | 4 | import java.text.SimpleDateFormat; 5 | import java.util.Date; 6 | import org.apache.log4j.*; 7 | 8 | public class DateValidator { 9 | 10 | // the logger object 11 | private static final Logger logger = Logger.getLogger(DateValidator.class); 12 | 13 | // this method wii validate a date 14 | public static boolean validateDate(String date) { 15 | 16 | String[] tokens = null; 17 | int day = 0, month = 0, year = 0; 18 | 19 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); 20 | int currentYear = Integer.valueOf(sdf.format(new Date())); 21 | 22 | boolean result = false; 23 | 24 | if (date.isEmpty() == false) { 25 | 26 | if (date.length() == 10) { 27 | 28 | tokens = date.split("[-]"); 29 | 30 | if (tokens.length == 3 && tokens[0].length() == 2 && tokens[1].length() == 2 && tokens[2].length() == 4) { 31 | 32 | // convert the strings to number 33 | try { 34 | day = Integer.valueOf(tokens[0]); 35 | month = Integer.valueOf(tokens[1]); 36 | year = Integer.valueOf(tokens[2]); 37 | 38 | if ((day >= 1 && day <= 31) && (month >= 1 && month <= 12) && (year > 1960 && year <= currentYear)) { 39 | 40 | // check for february 41 | if (month == 2) { 42 | 43 | if ((year % 4 == 0) && day <= 29) { 44 | result = true; 45 | } else if ((year % 4 != 0) && day <= 28) { 46 | result = true; 47 | } 48 | 49 | } // check for 30-days months 50 | else if ((month == 4 || month == 6 || month == 9 || month == 11) && day <= 30) { 51 | result = true; 52 | } // check for 31-days months 53 | else if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 54 | || month == 10 || month == 12) { 55 | 56 | result = true; 57 | } 58 | 59 | } 60 | } catch (NumberFormatException e) { 61 | logger.error(e); 62 | 63 | result = false; 64 | } 65 | } 66 | } 67 | 68 | } 69 | 70 | return result; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /web/admin/pages/rejectedFiles.jsp: -------------------------------------------------------------------------------- 1 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%@taglib uri="http://displaytag.sf.net" prefix="display" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Rejected Files Page 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 |
30 | 31 |
32 | 33 | 34 | 35 | List of Rejected Files... 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
55 | 56 |
57 | 58 |
59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /web/admin/pages/closedFiles.jsp: -------------------------------------------------------------------------------- 1 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%@taglib uri="http://displaytag.sf.net" prefix="display" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Closed Files Page 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 |
30 | 31 |
32 | 33 | 34 | List of Closed Files... 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 |
56 | 57 |
58 | 59 |
60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/java/bca/fts/model/ClosedFileBean.java: -------------------------------------------------------------------------------- 1 | // this bean represents a closed file 2 | 3 | package bca.fts.model; 4 | 5 | import java.text.SimpleDateFormat; 6 | import java.util.Date; 7 | import org.apache.log4j.Logger; 8 | 9 | public class ClosedFileBean { 10 | 11 | // the logger object 12 | private static final Logger logger = Logger.getLogger(ClosedFileBean.class); 13 | 14 | private int id = 0; 15 | private String no = null; 16 | private String name = null; 17 | private String type = null; 18 | private String owner = null; 19 | private String dateOfSend = null; 20 | private String curLoc = null; 21 | private String dateOfClose = null; 22 | 23 | // for pendind, rejected file sorting 24 | private Date date = null; 25 | 26 | 27 | // all the "SETTER" methods 28 | 29 | public void setDate() { 30 | SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy 'at' hh:mm:ss a"); 31 | 32 | try { 33 | 34 | this.date = formatter.parse(this.dateOfClose); 35 | } 36 | catch (Exception e) { 37 | logger.error(e); 38 | } 39 | } 40 | 41 | public void setOwner(String owner) { 42 | this.owner = owner; 43 | } 44 | 45 | public void setId(int id) { 46 | this.id = id; 47 | } 48 | 49 | public void setNo(String no) { 50 | this.no = no; 51 | } 52 | 53 | public void setName(String name) { 54 | this.name = name; 55 | } 56 | 57 | public void setType(String type) { 58 | this.type = type; 59 | } 60 | 61 | public void setDateOfSend(String dateOfSend) { 62 | this.dateOfSend = dateOfSend; 63 | } 64 | 65 | public void setCurLoc(String curLoc) { 66 | this.curLoc = curLoc; 67 | } 68 | 69 | public void setDateOClose(String dateOfClose) { 70 | this.dateOfClose = dateOfClose; 71 | } 72 | 73 | 74 | // all the "GETTER" methods 75 | 76 | public Date getDate() { 77 | return date; 78 | } 79 | 80 | public String getOwner() { 81 | return owner; 82 | } 83 | 84 | public int getId() { 85 | return id; 86 | } 87 | 88 | public String getNo() { 89 | return no; 90 | } 91 | 92 | public String getName() { 93 | return name; 94 | } 95 | 96 | public String getType() { 97 | return type; 98 | } 99 | 100 | 101 | public String getDateOfSend() { 102 | return dateOfSend; 103 | } 104 | 105 | public String getCurLoc() { 106 | return curLoc; 107 | } 108 | 109 | public String getDateOfClose() { 110 | return dateOfClose; 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /web/admin/pages/processingFiles.jsp: -------------------------------------------------------------------------------- 1 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 2 | <%@taglib uri="http://displaytag.sf.net" prefix="display" %> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Processing Files Page 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 |
30 | 31 |
32 | 33 | 34 | 35 | List of Processing Files... 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/java/bca/fts/dao/BranchLoginCheckDao.java: -------------------------------------------------------------------------------- 1 | package bca.fts.dao; 2 | 3 | import bca.fts.model.*; 4 | import bca.fts.util.*; 5 | import java.sql.*; 6 | import org.apache.log4j.*; 7 | 8 | public class BranchLoginCheckDao { 9 | 10 | // the logger object 11 | private static final Logger logger = Logger.getLogger(BranchLoginCheckDao.class); 12 | 13 | public static BranchBean authenticate(String username, String password) { 14 | 15 | Connection con = null; 16 | ResultSet res = null; 17 | PreparedStatement ps = null; 18 | 19 | String sql = "SELECT * FROM branchdetails WHERE username=? AND password=?"; 20 | BranchBean branch = null; 21 | 22 | try { 23 | con = DatabaseConnector.getConnection(); 24 | ps = con.prepareStatement(sql); 25 | 26 | ps.setString(1, username); 27 | ps.setString(2, password); 28 | 29 | res = ps.executeQuery(); 30 | 31 | // save the branch info in a bean, don't load the password 32 | if (res.next()) { 33 | branch = new BranchBean(); 34 | 35 | branch.setId(res.getInt(1)); 36 | branch.setOfficeName(res.getString(2)); 37 | branch.setHeadName(res.getString(3)); 38 | branch.setUsername(res.getString(4)); 39 | } else { 40 | 41 | // no registered branch; empty branch bean 42 | branch = new BranchBean(); 43 | } 44 | 45 | } catch (Exception e) { 46 | logger.error(e); 47 | 48 | // error occured 49 | branch = null; 50 | } finally { 51 | 52 | // clean up database resources 53 | DatabaseConnector.closeResultSet(res); 54 | DatabaseConnector.closePreStatement(ps); 55 | DatabaseConnector.freeConncetion(con); 56 | } 57 | 58 | return branch; 59 | } 60 | 61 | // change branch account password 62 | public static int changePassword(String username, String newPass) { 63 | 64 | Connection con = null; 65 | PreparedStatement ps = null; 66 | 67 | String sql = "UPDATE branchdetails SET password = ? WHERE username = ?"; 68 | int row = 0; 69 | 70 | try { 71 | con = DatabaseConnector.getConnection(); 72 | ps = con.prepareStatement(sql); 73 | 74 | ps.setString(1, newPass); 75 | ps.setString(2, username); 76 | 77 | row = ps.executeUpdate(); 78 | } catch (Exception e) { 79 | logger.error(e); 80 | 81 | row = -1; // error while updating 82 | } finally { 83 | 84 | DatabaseConnector.closePreStatement(ps); 85 | DatabaseConnector.freeConncetion(con); 86 | } 87 | 88 | return row; 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /web/admin/install.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | <%-- Don't create session for this page, let the session to create after successful login --%> 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Admin Registration Page 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 |
27 | 28 |

29 | Password must be of at least 8 characters, must contain at least one alphabet, one digit and one special character 30 |

31 |
32 | 33 |
${requestScope.errorMessage}
34 | 35 |
36 |
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 58 | 61 | 62 | 63 |
Create The Administrator Account...
Username:    
Password:    
Confirm Password:    
56 | 57 | 59 | 60 |
64 | 65 |
66 | 67 |
68 | 69 |
70 | 71 |
72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /web/admin/pages/changePassword.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | 4 | 5 | 6 | 7 | 8 | Admin Password Change Page 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 |
24 | 25 |

26 | Password must be of at least 8 characters, must contain at least one alphabet, one digit and one special character 27 |

28 |
29 | 30 |
${requestScope.errorMessage}
31 | 32 |
33 | 34 |
35 | 36 | 37 | 38 | 39 | 40 | 41 | 44 | 45 | 46 | 47 | 50 | 51 | 52 | 53 | 56 | 57 | 58 | 59 | 63 | 64 | 65 |
Change Admin Password
Enter Old Password: 42 |    43 |
Enter New Password: 48 |    49 |
Confirm New Password: 54 |    55 |
60 |   61 | 62 |
66 | 67 |
68 | 69 |
70 | 71 |
72 | 73 |
74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /web/branch/passChange.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Branch Password Change Page 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 |
25 | 26 |

27 | Password must be of at least 8 characters, must contain at least one alphabet, one digit and one special character 28 |

29 |
30 | 31 |
${requestScope.errorMessage}
32 | 33 |
34 | 35 |
36 | 37 | 38 | 39 | 40 | 41 | 42 | 45 | 46 | 47 | 48 | 51 | 52 | 53 | 54 | 57 | 58 | 59 | 60 | 64 | 65 | 66 |
Change Branch Password
Enter Old Password: 43 |    44 |
Enter New Password: 49 |    50 |
Confirm New Password: 55 |    56 |
61 |   62 | 63 |
67 | 68 |
69 | 70 |
71 |
72 | 73 |
74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/AddFileTypeServlet.java: -------------------------------------------------------------------------------- 1 | // this servlet adds a file-type to the database 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import org.apache.log4j.*; 8 | 9 | import bca.fts.dao.*; 10 | import bca.fts.model.AdminBean; 11 | 12 | public class AddFileTypeServlet extends HttpServlet { 13 | 14 | // the logger object 15 | private static final Logger logger = Logger.getLogger(AddFileTypeServlet.class); 16 | 17 | @Override 18 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) 19 | throws ServletException, IOException { 20 | doPost(req, resp); 21 | } 22 | 23 | @Override 24 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 25 | throws ServletException, IOException { 26 | 27 | HttpSession session = request.getSession(false); 28 | AdminBean bean = (AdminBean) session.getAttribute("admin"); 29 | String user = bean.getUserName(); 30 | 31 | String fileType = request.getParameter("fileType"); 32 | 33 | int row = 0; // row != 1 means error 34 | 35 | // check for null values, illigal access 36 | if (fileType == null) { 37 | request.getRequestDispatcher("welcomeAdmin.jsp").forward(request, response); 38 | } else { 39 | if (fileType.isEmpty()) { 40 | 41 | request.setAttribute("errorMessage", "Empty file type"); 42 | request.getRequestDispatcher("addFileType.jsp").forward(request, response); 43 | } // check if the file type is already registered 44 | else if (FileDao.checkUniqueFiletype(fileType.trim())) { 45 | 46 | request.setAttribute("errorMessage", "File type " + fileType + " is already registered"); 47 | request.getRequestDispatcher("addFileType.jsp").forward(request, response); 48 | } else { 49 | 50 | row = FileDao.addFileType(fileType.trim()); 51 | 52 | // redirect the requset to the appropiate page 53 | if (row == 1) { 54 | logger.info(user + " registered file type " + fileType); 55 | 56 | request.setAttribute("message", "File-type " + fileType + " has been successfully registered"); 57 | request.getRequestDispatcher("loadFileTypes.do").forward(request, response); 58 | } else if (row == 0) { 59 | 60 | request.setAttribute("errorMessage", "File-type couldn't be registered"); 61 | request.getRequestDispatcher("addFileType.jsp").forward(request, response); 62 | } else { 63 | 64 | request.setAttribute("errorMessage", "Error has occured in the databse operation!"); 65 | request.getRequestDispatcher("addFileType.jsp").forward(request, response); 66 | } 67 | 68 | } 69 | } 70 | 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/UpdateBranchServlet.java: -------------------------------------------------------------------------------- 1 | // this servlet gives the specific branch to the view which is needed to be updated 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import java.util.*; 8 | import org.apache.log4j.*; 9 | 10 | import bca.fts.model.*; 11 | 12 | public class UpdateBranchServlet extends HttpServlet { 13 | 14 | // the logger object 15 | private static final Logger logger = Logger.getLogger(UpdateBranchServlet.class); 16 | 17 | @Override 18 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) 19 | throws ServletException, IOException { 20 | doPost(req, resp); 21 | } 22 | 23 | @Override 24 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 25 | throws ServletException, IOException { 26 | 27 | HttpSession session = request.getSession(false); 28 | AdminBean bean = (AdminBean) session.getAttribute("admin"); 29 | String user = bean.getUserName(); 30 | 31 | String id = request.getParameter("id"); 32 | 33 | // illigal access 34 | if (id == null) { 35 | request.getRequestDispatcher("welcomeAdmin.jsp").forward(request, response); 36 | } else { 37 | BranchBean branch = null; 38 | int branchID = 0; 39 | 40 | ArrayList branchRecords = (ArrayList) session.getAttribute("branchRecords"); 41 | 42 | try { 43 | branchID = Integer.valueOf(id.trim()); 44 | 45 | // now get the particular branch record from the session 46 | Iterator i = branchRecords.iterator(); 47 | 48 | while (i.hasNext()) { 49 | branch = (BranchBean) i.next(); 50 | 51 | if (branchID == branch.getId()) { 52 | break; 53 | } 54 | } 55 | } catch (NumberFormatException e) { 56 | logger.error(e); 57 | 58 | // error occured 59 | branch = null; 60 | } 61 | 62 | // check if branch record is found or not 63 | if (branch != null) { 64 | 65 | // set the branch in session and show it via view 66 | /* branch bean is set in session, instead of request, so that if user enters wrong data in the showBranchRecord page 67 | the branch record still can be retrieved form the session 68 | */ 69 | session.setAttribute("branchBean", branch); 70 | request.getRequestDispatcher("showBranchRecord.jsp").forward(request, response); 71 | 72 | } else { 73 | 74 | request.setAttribute("errorMessage", "Record couldn't be retrieved"); 75 | request.getRequestDispatcher("branchList.jsp").forward(request, response); 76 | } 77 | 78 | } 79 | 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/java/bca/fts/model/ProcessingFileBean.java: -------------------------------------------------------------------------------- 1 | // this bean represents a processing file 2 | 3 | package bca.fts.model; 4 | 5 | import java.text.SimpleDateFormat; 6 | import java.util.Date; 7 | import org.apache.log4j.Logger; 8 | 9 | public class ProcessingFileBean { 10 | 11 | private static final Logger logger = Logger.getLogger(ProcessingFileBean.class); 12 | 13 | private int id = 0; 14 | private String no = null; 15 | private String name = null; 16 | private String type = null; 17 | private String sender = null; 18 | private String dateOfSend = null; 19 | private String curLoc = null; 20 | private String dateOfRecieve = null; 21 | private String owner = null; 22 | 23 | // for pendind, rejected file sorting 24 | private Date date = null; 25 | 26 | 27 | // all the "SETTER" methods 28 | public void setDate() { 29 | SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy 'at' hh:mm:ss a"); 30 | 31 | try { 32 | 33 | this.date = formatter.parse(this.dateOfRecieve); 34 | } 35 | catch (Exception e) { 36 | logger.error(e); 37 | } 38 | } 39 | 40 | public void setOwner(String owner) { 41 | this.owner = owner; 42 | } 43 | 44 | public void setId(int id) { 45 | this.id = id; 46 | } 47 | 48 | public void setNo(String no) { 49 | this.no = no; 50 | } 51 | 52 | public void setName(String name) { 53 | this.name = name; 54 | } 55 | 56 | public void setType(String type) { 57 | this.type = type; 58 | } 59 | 60 | public void setSender(String sender) { 61 | this.sender = sender; 62 | } 63 | 64 | public void setDateOfSend(String dateOfSend) { 65 | this.dateOfSend = dateOfSend; 66 | } 67 | 68 | public void setCurLoc(String curLoc) { 69 | this.curLoc = curLoc; 70 | } 71 | 72 | public void setDateOfRecieve(String dateOfRecieve) { 73 | this.dateOfRecieve = dateOfRecieve; 74 | } 75 | 76 | 77 | 78 | // all the "GETTER" methods 79 | 80 | public Date getDate() { 81 | return date; 82 | } 83 | 84 | public String getOwner() { 85 | return owner; 86 | } 87 | 88 | public int getId() { 89 | return id; 90 | } 91 | 92 | public String getNo() { 93 | return no; 94 | } 95 | 96 | public String getName() { 97 | return name; 98 | } 99 | 100 | public String getType() { 101 | return type; 102 | } 103 | 104 | public String getSender() { 105 | return sender; 106 | } 107 | 108 | public String getDateOfSend() { 109 | return dateOfSend; 110 | } 111 | 112 | public String getCurLoc() { 113 | return curLoc; 114 | } 115 | 116 | public String getDateOfRecieve() { 117 | return dateOfRecieve; 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/LoadIncomingFiles.java: -------------------------------------------------------------------------------- 1 | // this servlet is responsible for displaying new incoming files to a branch 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import java.util.ArrayList; 8 | import org.apache.log4j.*; 9 | import java.util.*; 10 | 11 | import bca.fts.dao.*; 12 | import bca.fts.model.*; 13 | 14 | public class LoadIncomingFiles extends HttpServlet { 15 | 16 | // the logger object 17 | private static final Logger logger = Logger.getLogger(LoadIncomingFiles.class); 18 | 19 | @Override 20 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 21 | throws ServletException, IOException { 22 | 23 | doPost(request, response); 24 | } 25 | 26 | @Override 27 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 28 | throws ServletException, IOException { 29 | 30 | HttpSession session = request.getSession(false); 31 | BranchBean branch = (BranchBean) session.getAttribute("branch"); 32 | String user = branch.getUsername(); 33 | 34 | logger.info(user + " checked the inbox"); 35 | 36 | ArrayList files = null; 37 | files = BranchReportDao.giveIncomingFiles(branch.getOfficeName()); 38 | 39 | if (files == null) { 40 | 41 | // database-error occured 42 | request.setAttribute("errorMessage", "Error has occured in the database operation!"); 43 | request.getRequestDispatcher("welcomeBranch.jsp").forward(request, response); 44 | } else if (files.isEmpty()) { 45 | 46 | // so that the "Inbox view" knows there is no files to display in the inbox 47 | session.setAttribute("incomingFiles", null); 48 | 49 | // so that, the "action message" of the last file is shown in the Inbox 50 | if (request.getAttribute("message") != null || request.getAttribute("errorMessage") != null) { 51 | request.getRequestDispatcher("branchInbox.jsp").forward(request, response); 52 | } else { 53 | request.setAttribute("errorMessage", "No incoming file found"); 54 | request.getRequestDispatcher("welcomeBranch.jsp").forward(request, response); 55 | } 56 | 57 | } else { 58 | 59 | // get the list of branches and set them in session scope, instead of request scope, so that data 60 | // should be available during various "Recieve file" requests. 61 | // sort the list first in Ascending order based on the date of date-of-send; 62 | Collections.sort(files, new Comparator() { 63 | 64 | @Override 65 | public int compare(IncomingFileBean o1, IncomingFileBean o2) { 66 | return o1.getDate().compareTo(o2.getDate()); 67 | } 68 | }); 69 | 70 | // sort the list first in Ascending order; 71 | Collections.reverse(files); 72 | 73 | session.setAttribute("incomingFiles", files); 74 | request.getRequestDispatcher("branchInbox.jsp").forward(request, response); 75 | } 76 | 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /web/branch/fileRegister.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | File Registration Page 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 |
24 | 25 |
${requestScope.errorMessage}
26 | 27 |
28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 64 | 65 | 66 | 67 |
Register New File
*File No:  
*File Name:  
*File Type: 44 | 52 |
Description:  
61 |     62 | 63 |
68 |
69 | 70 |
71 | 72 | 73 | 74 |
75 | 76 |
77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/AdminLoginServlet.java: -------------------------------------------------------------------------------- 1 | // this servlet validate the ADMIN Login credentials 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import org.apache.commons.codec.digest.DigestUtils; 8 | import org.apache.log4j.*; 9 | 10 | import bca.fts.model.*; 11 | import bca.fts.dao.*; 12 | import java.util.ArrayList; 13 | 14 | public class AdminLoginServlet extends HttpServlet { 15 | 16 | // the logger object 17 | private static final Logger logger = Logger.getLogger(AdminLoginServlet.class); 18 | 19 | @Override 20 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 21 | doPost(req, resp); 22 | } 23 | 24 | @Override 25 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 26 | throws ServletException, IOException { 27 | 28 | String username = request.getParameter("username"); 29 | String password = request.getParameter("password"); 30 | String errMsg = ""; 31 | int result = 0; 32 | AdminBean admin = null; 33 | 34 | logger.info(username + " attempted to log in"); 35 | 36 | if (username == null || password == null) { 37 | errMsg = " "; 38 | result = 0; 39 | } else if (username.isEmpty() || password.isEmpty()) { 40 | errMsg = "Username and password can't be empty"; 41 | result = 0; 42 | } else { 43 | admin = new AdminBean(); 44 | admin.setUserName(username.trim()); 45 | 46 | // convert the text to md5 digest 47 | admin.setPassword(DigestUtils.md5Hex(password)); 48 | 49 | result = AdminLoginCheckDao.authenticate(admin); 50 | 51 | // don't store the admin password in the session 52 | admin.setPassword(null); 53 | } 54 | 55 | if (result == 1) { 56 | 57 | logger.info(username + " successfully logged in"); 58 | 59 | // create the session and set the admin bean in the session 60 | HttpSession ses = request.getSession(true); 61 | ses.setAttribute("admin", admin); 62 | 63 | // get the branch names and set them in the session 64 | ArrayList branchNames = BranchDao.giveBranchNames(); 65 | 66 | if (branchNames != null) { 67 | ses.setAttribute("branchNames", branchNames); 68 | } else { 69 | request.setAttribute("errorMessage", "Error has occured the database operation!"); 70 | } 71 | 72 | response.sendRedirect("/FTS/admin/pages/welcomeAdmin.jsp"); 73 | } else if (result == 0) { 74 | 75 | logger.warn("invalid login attempt by user " + username); 76 | 77 | if (errMsg.isEmpty()) { 78 | errMsg = "Sorry, username and/or password might be incorrect"; 79 | } 80 | 81 | request.setAttribute("errorMessage", errMsg); 82 | request.getRequestDispatcher("index.jsp").forward(request, response); 83 | } else { 84 | request.setAttribute("errorMessage", "Error has occured in the database operation!"); 85 | request.getRequestDispatcher("index.jsp").forward(request, response); 86 | } 87 | 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /web/branch/sentFiles.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 3 | <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 4 | <%@taglib uri="http://displaytag.sf.net" prefix="display" %> 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | View Sent File Page 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | List of Sent Files... 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | at 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | at 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | at 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | at 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |
78 | 79 |
80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/DeleteBranchServlet.java: -------------------------------------------------------------------------------- 1 | // this servlet takes the ID of the branch and delete it throug BranchDao 2 | package bca.fts.controller; 3 | 4 | import bca.fts.dao.AdminReportsDao; 5 | import java.io.*; 6 | import javax.servlet.*; 7 | import javax.servlet.http.*; 8 | import java.util.ArrayList; 9 | import org.apache.log4j.*; 10 | 11 | import bca.fts.dao.BranchDao; 12 | import bca.fts.model.AdminBean; 13 | import bca.fts.model.BranchBean; 14 | 15 | public class DeleteBranchServlet extends HttpServlet { 16 | 17 | // the logger object 18 | private static final Logger logger = Logger.getLogger(DeleteBranchServlet.class); 19 | 20 | @Override 21 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) 22 | throws ServletException, IOException { 23 | doPost(req, resp); 24 | } 25 | 26 | @Override 27 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 28 | throws ServletException, IOException { 29 | 30 | HttpSession session = request.getSession(false); 31 | AdminBean bean = (AdminBean) session.getAttribute("admin"); 32 | String user = bean.getUserName(); 33 | 34 | String id = request.getParameter("id"); 35 | int row = 0; 36 | String errMessage = ""; 37 | 38 | if (id == null) { 39 | request.getRequestDispatcher("welcomeAdmin.jsp").forward(request, response); 40 | } else { 41 | row = BranchDao.deleteBranch(Integer.valueOf(id)); 42 | 43 | // check if branch record is deleted or not 44 | if (row == 1) { 45 | 46 | logger.info(user + " deleted the branch with ID " + id); 47 | 48 | String message = "Branch ID: " + id + " has been deleted successfully"; 49 | 50 | // load the new branch records from the database 51 | ArrayList branchRecords = AdminReportsDao.giveBranches(); 52 | ArrayList branchNames = new ArrayList(); 53 | 54 | if (branchRecords != null) { 55 | 56 | // iterate over the branch-records to collect the branch names 57 | for (BranchBean b : branchRecords) { 58 | branchNames.add(b.getOfficeName()); 59 | } 60 | 61 | session.setAttribute("branchRecords", branchRecords); 62 | session.setAttribute("branchNames", branchNames); 63 | 64 | request.setAttribute("message", message); 65 | request.getRequestDispatcher("branchList.jsp").forward(request, response); 66 | } else { 67 | request.setAttribute("errorMessage", "Error has occured the database operation!"); 68 | request.getRequestDispatcher("branchList.jsp").forward(request, response); 69 | } 70 | 71 | } else { 72 | // record not found, so error meassage 73 | 74 | if (errMessage.isEmpty()) { 75 | errMessage = "Branch couldn't be deleted"; 76 | } 77 | 78 | request.setAttribute("errorMessage", errMessage); 79 | request.getRequestDispatcher("branchList.jsp").forward(request, response); 80 | } 81 | } 82 | 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/ChangeFileStatus.java: -------------------------------------------------------------------------------- 1 | // this servlet is responsible for changing the status of a file 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import org.apache.log4j.*; 8 | 9 | import bca.fts.dao.*; 10 | import bca.fts.model.BranchBean; 11 | 12 | public class ChangeFileStatus extends HttpServlet { 13 | 14 | // the logger object 15 | private static final Logger logger = Logger.getLogger(ChangeFileStatus.class); 16 | 17 | @Override 18 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 19 | throws ServletException, IOException { 20 | 21 | doPost(request, response); 22 | } 23 | 24 | @Override 25 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 26 | throws ServletException, IOException { 27 | 28 | HttpSession session = request.getSession(false); 29 | BranchBean branch = (BranchBean) session.getAttribute("branch"); 30 | String user = branch.getUsername(); 31 | 32 | String id = request.getParameter("id"); 33 | String status = request.getParameter("fileStatus"); 34 | String page = request.getParameter("page"); 35 | 36 | int result = 0; 37 | String errMeesage = ""; 38 | 39 | // check for null values, illigal access 40 | if (id == null) { 41 | request.getRequestDispatcher("welcomeBranch.jsp").forward(request, response); 42 | } else { 43 | if (status == null) { 44 | errMeesage = "Select the file status!"; 45 | 46 | //for the own sake of satisfaction!!!! 47 | result = 0; 48 | } else { 49 | result = FileDao.changeFileStatus(Integer.valueOf(id), status); 50 | } 51 | 52 | // check whether the file status is chamged or not 53 | if (result == 1) { 54 | 55 | logger.info(user + " changed file status to " + status + " of file ID " + id); 56 | 57 | // determine to which the request is need to forward 58 | if (page == null) { 59 | 60 | request.setAttribute("message", "File status has been successfully chanded to " + status); 61 | request.getRequestDispatcher("listRegFiles.do").forward(request, response); 62 | } else { 63 | 64 | request.setAttribute("message", "File ID " + id + " has been successfully CLOSED"); 65 | request.getRequestDispatcher("loadIncomings.do").forward(request, response); 66 | } 67 | 68 | } else { 69 | 70 | if (page == null) { 71 | 72 | if (errMeesage.isEmpty()) { 73 | errMeesage = "File status could't be changed to " + status; 74 | } 75 | 76 | request.setAttribute("errorMessage", errMeesage); 77 | request.getRequestDispatcher("listRegFiles.do").forward(request, response); 78 | } else { 79 | 80 | request.setAttribute("message", "File couldn't be closed"); 81 | request.getRequestDispatcher("loadIncomings.do").forward(request, response); 82 | } 83 | 84 | } 85 | } 86 | 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/java/bca/fts/model/IncomingFileBean.java: -------------------------------------------------------------------------------- 1 | // this bean represents a incoming file 2 | package bca.fts.model; 3 | 4 | import java.util.Date; 5 | import java.text.SimpleDateFormat; 6 | import org.apache.log4j.*; 7 | 8 | public class IncomingFileBean { 9 | 10 | // the logger object 11 | private static final Logger logger = Logger.getLogger(IncomingFileBean.class); 12 | 13 | private int id = 0; 14 | private String no = null; 15 | private String name = null; 16 | private String type = null; 17 | private String status = null; 18 | private String dateOfSend = null; 19 | private String sender = null; 20 | private String remark = null; 21 | 22 | // these two variables are required in "branchList" that is shown in the "Forward" drop-down list 23 | private String owner = null; 24 | private String curLoc = null; 25 | 26 | // to make sure whether a file has been recieved or not 27 | private boolean fileRecieved = false; 28 | 29 | // for sorting 30 | private Date date = null; 31 | 32 | // all the "SETTER" method 33 | public void setDate() { 34 | SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy 'at' hh:mm:ss a"); 35 | 36 | try { 37 | 38 | this.date = formatter.parse(this.dateOfSend); 39 | } 40 | catch (Exception e) { 41 | logger.error(e); 42 | } 43 | } 44 | 45 | 46 | public void setFileRecieved(boolean fileRecieved) { 47 | this.fileRecieved = fileRecieved; 48 | } 49 | 50 | public void setId(int id) { 51 | this.id = id; 52 | } 53 | 54 | public void setNo(String no) { 55 | this.no = no; 56 | } 57 | 58 | public void setName(String name) { 59 | this.name = name; 60 | } 61 | 62 | public void setType(String type) { 63 | this.type = type; 64 | } 65 | 66 | public void setDateOfSend(String dateOfSend) { 67 | this.dateOfSend = dateOfSend; 68 | } 69 | 70 | public void setOwner(String owner) { 71 | this.owner = owner; 72 | } 73 | 74 | public void setSender(String sender) { 75 | this.sender = sender; 76 | } 77 | 78 | public void setStatus(String status) { 79 | this.status = status; 80 | } 81 | 82 | public void setCurLoc(String curLoc) { 83 | this.curLoc = curLoc; 84 | } 85 | 86 | public void setRemark(String remark) { 87 | this.remark = remark; 88 | } 89 | 90 | // all the "GETTER" method 91 | public Date getDate() { 92 | return date; 93 | } 94 | 95 | public boolean isFileRecieved() { 96 | return fileRecieved; 97 | } 98 | 99 | public int getId() { 100 | return id; 101 | } 102 | 103 | public String getDateOfSend() { 104 | return dateOfSend; 105 | } 106 | 107 | public String getName() { 108 | return name; 109 | } 110 | 111 | public String getNo() { 112 | return no; 113 | } 114 | 115 | public String getOwner() { 116 | return owner; 117 | } 118 | 119 | public String getSender() { 120 | return sender; 121 | } 122 | 123 | public String getStatus() { 124 | return status; 125 | } 126 | 127 | public String getType() { 128 | return type; 129 | } 130 | 131 | public String getCurLoc() { 132 | return curLoc; 133 | } 134 | 135 | public String getRemark() { 136 | return remark; 137 | } 138 | 139 | } 140 | -------------------------------------------------------------------------------- /web/admin/pages/branchRegister.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | 3 | 4 | 5 | 6 | 7 | 8 | Branch Registration Page 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 |
24 | 25 |
${requestScope.errMessage}
26 | 27 |
28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 64 | 65 | 66 | 67 |
Register New Branch
Branch ID:  
* Branch Name:  
* Head/In-charge Name:  
* Username:   
* Password:   
* Confirm Password:   
61 |     62 | 63 |
68 | 69 |
70 | 71 |
72 | 73 | 74 | 75 |

76 | : Password must be of at least 8 characters, must contain at least one alphabet, one digit and one special character 77 |

78 | 79 |
80 | 81 |
82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/AddFileServlet.java: -------------------------------------------------------------------------------- 1 | // this servlet adds a file record to the database 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | import org.apache.log4j.*; 10 | 11 | import bca.fts.model.*; 12 | import bca.fts.dao.*; 13 | 14 | public class AddFileServlet extends HttpServlet { 15 | 16 | // the logger object 17 | private static final Logger logger = Logger.getLogger(AddFileServlet.class); 18 | 19 | @Override 20 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) 21 | throws ServletException, IOException { 22 | doPost(req, resp); 23 | } 24 | 25 | @Override 26 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 27 | throws ServletException, IOException { 28 | 29 | HttpSession session = request.getSession(false); 30 | BranchBean branch = (BranchBean) session.getAttribute("branch"); 31 | String user = branch.getUsername(); 32 | 33 | String fileNo = request.getParameter("fileNo"); 34 | String fileName = request.getParameter("fileName"); 35 | String fileType = request.getParameter("fileType"); 36 | String des = request.getParameter("description"); 37 | 38 | int row = 0; // row != 1 means error 39 | String errMessage = ""; 40 | FileBean file = null; 41 | 42 | // check for null values, illigal access 43 | if (fileNo == null || fileName == null || fileType == null || des == null) { 44 | request.getRequestDispatcher("welcomeBranch.jsp").forward(request, response); 45 | } else { 46 | if (fileNo.isEmpty() || fileName.isEmpty() || fileType.isEmpty()) { 47 | 48 | errMessage = "Form fileds can't be empty"; 49 | } else { 50 | file = new FileBean(); 51 | 52 | file.setNo(fileNo.trim()); 53 | file.setName(fileName.trim()); 54 | file.setType(fileType.trim()); 55 | file.setDescription(des.trim()); 56 | file.setOwner(branch.getOfficeName()); 57 | 58 | // get recieve date 59 | SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); 60 | Date today = new Date(); 61 | file.setDateOfRecieve(sdf.format(today)); 62 | 63 | // get recieve time 64 | sdf = new SimpleDateFormat("hh:mm:ss a"); 65 | file.setTimeOfRecieve(sdf.format(today)); 66 | 67 | row = FileDao.addFile(file); 68 | } 69 | 70 | // redirect the requset to the appropiate page 71 | if (row == 1) { 72 | 73 | logger.info(user + " registered file " + fileName + " no " + fileNo); 74 | 75 | request.setAttribute("fileBean", file); 76 | request.getRequestDispatcher("messageToBranch.jsp").forward(request, response); 77 | } else if (row == 0) { 78 | 79 | if (errMessage.isEmpty()) { 80 | errMessage = "File couldn't be registered"; 81 | } 82 | 83 | request.setAttribute("errorMessage", errMessage); 84 | request.getRequestDispatcher("fileRegister.jsp").forward(request, response); 85 | } else { 86 | request.setAttribute("errorMessage", "Error has occured in the databse operation!"); 87 | request.getRequestDispatcher("fileRegister.jsp").forward(request, response); 88 | } 89 | } 90 | 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /web/admin/pages/addFileType.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 3 | 4 | 5 | 6 | 7 | 8 | 9 | Add New File Type 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 |
26 | 27 |
${requestScope.errorMessage}
28 |
${requestScope.message}
29 | 30 |
31 |
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
Register File type
Enter a File-type:
47 |
48 |
49 |
50 |
51 | 52 |
53 | 54 | 55 | 56 |
57 | 58 | 59 | 60 | 61 | 62 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 |
Registered File-Type(s): 63 | 71 |
82 | 83 |
84 | 85 |
86 | 87 |
88 | 89 |
90 | 91 |
92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /web/css/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | margin: 0px; 3 | padding: 0px; 4 | } 5 | 6 | h1, h2, h3, h4 { 7 | padding: 5px; 8 | } 9 | 10 | .errorPage { 11 | padding: 50px; 12 | margin-left: 150px; 13 | margin-top: 50px; 14 | width: 60%; 15 | border: 2px solid #ccc; 16 | background-color: #e2f3b8; 17 | } 18 | 19 | .errorPage h2 { 20 | color: red; 21 | } 22 | 23 | .point { 24 | color: red; 25 | } 26 | 27 | .errMessage { 28 | color: red; 29 | } 30 | 31 | .message { 32 | color: green; 33 | } 34 | 35 | .notice p { 36 | padding: 10px; 37 | } 38 | 39 | .header { 40 | background-color: #e2f3b8; 41 | } 42 | 43 | .header img { 44 | float: left; 45 | height: 80px; 46 | width: 110px; 47 | padding-left: 5px; 48 | padding-right: 5px; 49 | margin-right: 20px; 50 | } 51 | 52 | .header h1 { 53 | line-height: 70px; 54 | } 55 | 56 | body { 57 | font-size: 14px; 58 | font-family: Consolas, Verdana, Times, serif; 59 | background-color:white; 60 | } 61 | 62 | input, textarea, select { 63 | font-family: Consolas, "Courier New", Times, serif; 64 | background-color:white; 65 | } 66 | 67 | select { 68 | padding: 3px; 69 | box-sizing: border-box; 70 | } 71 | 72 | input, textarea { 73 | padding: 4px; 74 | width: 100%; 75 | display: block; 76 | box-sizing: border-box; 77 | } 78 | 79 | input[type="submit"], input[type="reset"] { 80 | width: auto; 81 | display: inline; 82 | border: 1px solid #ccc; 83 | background-color: #e2f3b8; 84 | color: black; 85 | } 86 | 87 | .container { 88 | width: 100%; 89 | } 90 | 91 | .form caption { 92 | padding-bottom: 10px; 93 | font-size: 17px; 94 | font-weight:bold; 95 | text-align: center; 96 | } 97 | 98 | .loginForm caption { 99 | padding-bottom: 20px; 100 | font-size: 17px; 101 | font-weight:bold; 102 | text-align: center; 103 | } 104 | 105 | .loginForm { 106 | margin: 20px; 107 | } 108 | 109 | .form { 110 | margin: 10px; 111 | } 112 | 113 | .form input[type="submit"], .form input[type="reset"] { 114 | margin-top: 8px; 115 | } 116 | 117 | .navigation { 118 | padding: 5px; 119 | margin-top: 10px; 120 | margin-left: 10px; 121 | background-color: #e2f3b8; 122 | width: 16%; 123 | height: 100%; 124 | float: left; 125 | margin-right: 50px; 126 | } 127 | 128 | .navigation ul { 129 | padding-top: 8px; 130 | padding-left: 8px; 131 | padding-bottom: 20px; 132 | list-style-type: none; 133 | } 134 | 135 | .navigation ul li { 136 | padding: 3px; 137 | } 138 | 139 | .content { 140 | margin: 20px; 141 | text-align:justify; 142 | } 143 | 144 | a:link {text-decoration:none;} 145 | a:visited {text-decoration:none;} 146 | a:hover {text-decoration:underline;} 147 | a:active {text-decoration:underline;} 148 | 149 | 150 | 151 | #nav { 152 | display: none; 153 | } 154 | 155 | 156 | #printData { 157 | width: 100%; 158 | margin: 0; 159 | float: none; 160 | } 161 | 162 | hr { 163 | margin-top: 5px; 164 | color: #e6e6e6; 165 | } 166 | 167 | .fileTrackData { 168 | text-align: justify; 169 | } 170 | 171 | .fileTrackData table, .fileTrackData th, .fileTrackData td { 172 | border: 1px solid #cccccc; 173 | border-collapse: collapse; 174 | padding: 3px; 175 | text-align: center; 176 | } 177 | 178 | .fileTrackData table { 179 | width: 80%; 180 | } 181 | 182 | .fileTrackData tr:hover { 183 | background: #eeeeff 184 | } 185 | 186 | .fileTrackData th { 187 | border-bottom: 2px solid black; 188 | } 189 | 190 | /* for printers */ 191 | @media print 192 | { 193 | #noPrint { 194 | display: none; 195 | } 196 | 197 | } -------------------------------------------------------------------------------- /src/java/bca/fts/controller/AdminRegistration.java: -------------------------------------------------------------------------------- 1 | // this servlet is responsible for creating the admin account 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import org.apache.log4j.*; 8 | import org.apache.commons.codec.digest.DigestUtils; 9 | 10 | import bca.fts.util.PasswordValidator; 11 | import bca.fts.dao.AdminLoginCheckDao; 12 | 13 | public class AdminRegistration extends HttpServlet { 14 | 15 | // the logger object 16 | private static final Logger logger = Logger.getLogger(AdminRegistration.class); 17 | 18 | @Override 19 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 20 | throws ServletException, IOException { 21 | 22 | doPost(request, response); 23 | } 24 | 25 | @Override 26 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 27 | throws ServletException, IOException { 28 | 29 | String username = request.getParameter("username"); 30 | String password = request.getParameter("password"); 31 | String confPass = request.getParameter("confPass"); 32 | 33 | int row = 0; 34 | 35 | // check for null values, illigal access 36 | if (username == null || password == null || confPass == null) { 37 | response.sendRedirect("/FTS/admin/"); 38 | } else { 39 | if (username.isEmpty() || password.isEmpty() || confPass.isEmpty()) { 40 | 41 | request.setAttribute("errorMessage", "You need to fill up all the form data"); 42 | request.getRequestDispatcher("install.jsp").forward(request, response); 43 | } else { 44 | 45 | // verify the given password 46 | String result = PasswordValidator.validatePassword(password); 47 | 48 | if (result.isEmpty() && password.equals(confPass)) { 49 | 50 | // register the admin 51 | row = AdminLoginCheckDao.regisAdmin(username.trim(), DigestUtils.md5Hex(password)); 52 | 53 | if (row == 1) { 54 | 55 | logger.info("admin account has been created by user " + username); 56 | 57 | // tell the app context about admin registration 58 | getServletContext().setAttribute("adminAccount", 1); 59 | 60 | request.setAttribute("message", "Admin account has been created. You can now log in"); 61 | request.getRequestDispatcher("index.jsp").forward(request, response); 62 | } else { 63 | String errMsg = " "; 64 | 65 | if (row == -1) { 66 | errMsg = "Error has occured in the database operation!"; 67 | } else { 68 | errMsg = "Admin account couldn't be created"; 69 | } 70 | 71 | request.setAttribute("errorMessage", errMsg); 72 | request.getRequestDispatcher("install.jsp").forward(request, response); 73 | 74 | } 75 | } else if (result.isEmpty() == false) { 76 | 77 | request.setAttribute("errorMessage", result); 78 | request.getRequestDispatcher("install.jsp").forward(request, response); 79 | } else { 80 | 81 | request.setAttribute("errorMessage", "Password and confirm password must be matched"); 82 | request.getRequestDispatcher("install.jsp").forward(request, response); 83 | } 84 | 85 | } 86 | } 87 | 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/RejectFileServlet.java: -------------------------------------------------------------------------------- 1 | // this servlet is responsible for "REJECT FILE" action 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import java.text.SimpleDateFormat; 8 | import java.util.*; 9 | import org.apache.log4j.*; 10 | 11 | import bca.fts.dao.*; 12 | import bca.fts.model.*; 13 | 14 | public class RejectFileServlet extends HttpServlet { 15 | 16 | // the logger object 17 | private static final Logger logger = Logger.getLogger(RejectFileServlet.class); 18 | 19 | @Override 20 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 21 | throws ServletException, IOException { 22 | 23 | doPost(request, response); 24 | } 25 | 26 | @Override 27 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 28 | throws ServletException, IOException { 29 | 30 | HttpSession session = request.getSession(false); 31 | BranchBean branch = (BranchBean) session.getAttribute("branch"); 32 | String user = branch.getUsername(); 33 | 34 | String causeOfReject = request.getParameter("textArea"); 35 | String id = request.getParameter("id"); 36 | 37 | String errMsg = ""; 38 | int result = 0, fileID = 0; 39 | 40 | // illigal access 41 | if (id == null || causeOfReject == null) { 42 | request.getRequestDispatcher("welcomeBranch.jsp").forward(request, response); 43 | } // when a branch rejects a file it must give its reason 44 | else if (causeOfReject.isEmpty()) { 45 | request.setAttribute("errorMessage", "You must give the cause of rejection"); 46 | request.getRequestDispatcher("branchInbox.jsp").forward(request, response); 47 | } else { 48 | 49 | fileID = Integer.valueOf(id.trim()); 50 | 51 | ArrayList files = (ArrayList) session.getAttribute("incomingFiles"); 52 | IncomingFileBean f = null; 53 | 54 | // get the Itrator of "files" 55 | Iterator it = files.iterator(); 56 | 57 | while (it.hasNext()) { 58 | f = (IncomingFileBean) it.next(); 59 | 60 | if (f.getId() == fileID) { 61 | break; 62 | } 63 | } 64 | 65 | // get the system's date 66 | Date today = new Date(); 67 | 68 | SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); 69 | String dateOfSend = sdf.format(today); 70 | 71 | // get the system's time 72 | sdf = new SimpleDateFormat("hh:mm:ss a"); 73 | String timeOfSend = sdf.format(today); 74 | 75 | SendFileBean bean = new SendFileBean(); 76 | bean.setFileId(fileID); 77 | bean.setDateOfSend(dateOfSend); 78 | bean.setSenderBranch(f.getCurLoc()); 79 | bean.setForwardBranch(f.getSender()); 80 | bean.setRemark(causeOfReject.trim()); 81 | bean.setTimeOfSend(timeOfSend); 82 | 83 | result = FileDao.rejectFile(bean); 84 | 85 | if (result == 1) { 86 | logger.info(user + " rejected file having ID " + id); 87 | 88 | request.setAttribute("message", "File ID: " + id + " hase been rejected successfully"); 89 | request.getRequestDispatcher("loadIncomings.do").forward(request, response); 90 | } else { 91 | request.setAttribute("errorMessage", "File couldn't be rejected"); 92 | request.getRequestDispatcher("branchInbox.jsp").forward(request, response); 93 | } 94 | } 95 | 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/UpdateFileRecord.java: -------------------------------------------------------------------------------- 1 | // this servlet updates a file record with newly entered data 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import org.apache.log4j.*; 8 | 9 | import bca.fts.dao.*; 10 | import bca.fts.model.*; 11 | 12 | public class UpdateFileRecord extends HttpServlet { 13 | 14 | // the logger object 15 | private static final Logger logger = Logger.getLogger(UpdateFileRecord.class); 16 | 17 | @Override 18 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 19 | throws ServletException, IOException { 20 | 21 | doPost(request, response); 22 | } 23 | 24 | @Override 25 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 26 | throws ServletException, IOException { 27 | 28 | HttpSession session = request.getSession(false); 29 | BranchBean branch = (BranchBean) session.getAttribute("branch"); 30 | String user = branch.getUsername(); 31 | 32 | String id = request.getParameter("id"); 33 | String no = request.getParameter("no"); 34 | String name = request.getParameter("name"); 35 | String type = request.getParameter("type"); 36 | String desc = request.getParameter("description"); 37 | 38 | String errMessage = " "; 39 | int row = 0; 40 | 41 | // illigal access 42 | if (id == null || no == null || name == null || type == null || desc == null) { 43 | request.getRequestDispatcher("welcomeBranch.jsp").forward(request, response); 44 | } else { 45 | FileBean newFile = null; 46 | FileBean oldFile = (FileBean) session.getAttribute("fileBean"); 47 | 48 | // trim the data 49 | id = id.trim(); 50 | no = no.trim(); 51 | name = name.trim(); 52 | type = type.trim(); 53 | desc = desc.trim(); 54 | 55 | if (no.isEmpty() || name.isEmpty() || type.isEmpty()) { 56 | errMessage = "Empty file-record data"; 57 | 58 | row = 0; 59 | } // check if no data was modified 60 | else if (oldFile.getNo().equals(no) && oldFile.getName().equals(name) && oldFile.getType().equals(type) 61 | && oldFile.getDescription().equals(desc)) { 62 | 63 | errMessage = "You didn't modify any data"; 64 | 65 | row = 0; 66 | } else { 67 | // create the branch bean 68 | newFile = new FileBean(); 69 | 70 | newFile.setId(Integer.valueOf(id)); // "id" can't be edit. RIGHT??? 71 | newFile.setNo(no); 72 | newFile.setName(name); 73 | newFile.setType(type); 74 | newFile.setDescription(desc); 75 | 76 | row = FileDao.updateFile(newFile); 77 | 78 | // set the error message if update fails 79 | if (row != 1) { 80 | errMessage = "File having " + id + " could not be updated"; 81 | } 82 | } 83 | 84 | if (row == 1) { 85 | 86 | logger.info(user + " updated file record having ID " + id); 87 | 88 | request.setAttribute("message", "File ID- " + id + " has been updated successfully"); 89 | request.getRequestDispatcher("listRegFiles.do").forward(request, response); 90 | } else { 91 | request.setAttribute("errorMessage", errMessage); 92 | request.getRequestDispatcher("fileEdit.jsp").forward(request, response); 93 | } 94 | 95 | } 96 | 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.web.project 4 | 5 | 6 | FTS 7 | 1.6.5 8 | 9 | 10 | ${libs.MySQLDriver.classpath} 11 | WEB-INF/lib 12 | 13 | 14 | ${libs.jstl.classpath} 15 | WEB-INF/lib 16 | 17 | 18 | ${file.reference.commons-beanutils-1.7.0.jar} 19 | WEB-INF/lib 20 | 21 | 22 | ${file.reference.commons-codec-1.5.jar} 23 | WEB-INF/lib 24 | 25 | 26 | ${file.reference.commons-collections-3.1.jar} 27 | WEB-INF/lib 28 | 29 | 30 | ${file.reference.commons-lang-2.3.jar} 31 | WEB-INF/lib 32 | 33 | 34 | ${file.reference.displaytag-1.2.jar} 35 | WEB-INF/lib 36 | 37 | 38 | ${file.reference.displaytag-export-poi-1.2.jar} 39 | WEB-INF/lib 40 | 41 | 42 | ${file.reference.displaytag-portlet-1.2.jar} 43 | WEB-INF/lib 44 | 45 | 46 | ${file.reference.gson-2.2.2.jar} 47 | WEB-INF/lib 48 | 49 | 50 | ${file.reference.itext-1.3.jar} 51 | WEB-INF/lib 52 | 53 | 54 | ${file.reference.jcl104-over-slf4j-1.4.2.jar} 55 | WEB-INF/lib 56 | 57 | 58 | ${file.reference.log4j-1.2.17.jar} 59 | WEB-INF/lib 60 | 61 | 62 | ${file.reference.poi-3.2-FINAL.jar} 63 | WEB-INF/lib 64 | 65 | 66 | ${file.reference.slf4j-api-1.4.2.jar} 67 | WEB-INF/lib 68 | 69 | 70 | ${file.reference.slf4j-log4j12-1.4.2.jar} 71 | WEB-INF/lib 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/BranchLoginServlet.java: -------------------------------------------------------------------------------- 1 | // this servlet checks the branch login credentials and also create notification 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import org.apache.commons.codec.digest.DigestUtils; 8 | import org.apache.log4j.*; 9 | 10 | import bca.fts.model.*; 11 | import bca.fts.dao.*; 12 | import java.util.ArrayList; 13 | 14 | public class BranchLoginServlet extends HttpServlet { 15 | 16 | // the logger object 17 | private static final Logger logger = Logger.getLogger(BranchLoginServlet.class); 18 | 19 | @Override 20 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 21 | 22 | doPost(request, response); 23 | } 24 | 25 | @Override 26 | protected void doPost(HttpServletRequest request, HttpServletResponse response) 27 | throws ServletException, IOException { 28 | 29 | String username = request.getParameter("username"); 30 | String password = request.getParameter("password"); 31 | 32 | BranchBean branch = null; 33 | String errMessage = ""; 34 | 35 | int newFiles = 0; // to give the branch notifications for newcoming files 36 | 37 | logger.info(username + " attempted to log in"); 38 | 39 | // check for null values, illigal access 40 | if (username == null || password == null) { 41 | errMessage = " "; 42 | } else if (username.isEmpty() || password.isEmpty()) { 43 | errMessage = "Username and password can't be empty"; 44 | } else { 45 | 46 | // create the md5 digest form the given password 47 | branch = BranchLoginCheckDao.authenticate(username.trim(), DigestUtils.md5Hex(password)); 48 | } 49 | 50 | // send the request to the appropiate page 51 | if (branch == null) { // either db error or empty data 52 | 53 | // database error 54 | if (errMessage.isEmpty()) { 55 | errMessage = "Error has occured in the database operation!"; 56 | } 57 | 58 | request.setAttribute("errorMessage", errMessage); 59 | request.getRequestDispatcher("index.jsp").forward(request, response); 60 | } else if (branch.getOfficeName() == null) { // empty bean, invalid login 61 | 62 | logger.warn("invalid login attempt by user " + username); 63 | 64 | request.setAttribute("errorMessage", "Sorry, username and/or password might be incorrect"); 65 | request.getRequestDispatcher("index.jsp").forward(request, response); 66 | } else { 67 | // successfull login 68 | logger.info(username + " successfully logged in"); 69 | 70 | // create the session and set the admin bean in the session 71 | HttpSession session = request.getSession(true); 72 | session.setAttribute("branch", branch); 73 | 74 | // give notification to the branch if new files are comming 75 | newFiles = NotificationDao.giveNotification(branch.getOfficeName()); 76 | 77 | if (newFiles > 0) { 78 | 79 | if (newFiles == 1) { 80 | session.setAttribute("notification", "You have " + newFiles + " file for processing"); 81 | } else { 82 | session.setAttribute("notification", "You have " + newFiles + " files for processing"); 83 | } 84 | } 85 | 86 | // load the branch names and set them in the session 87 | ArrayList branchNames = BranchDao.giveBranchNames(); 88 | 89 | if (branchNames != null) { 90 | session.setAttribute("branchList", branchNames); 91 | } else { 92 | request.setAttribute("errorMessage", "Error has occured in the database operation!"); 93 | } 94 | 95 | response.sendRedirect("/FTS/branch/welcomeBranch.jsp"); 96 | } 97 | 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /web/admin/pages/showBranchRecord.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" pageEncoding="UTF-8"%> 2 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Branch Update Page 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 29 | 30 |
31 | 32 |
${requestScope.errorMessage}
33 | 34 |
35 | 36 |
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 71 | 72 | 73 | 74 |
Update branch record for
Branch ID:  
* Branch Name:   " size="30"/>
* Head/In-charge Name:   " size="30"/>
* Username:    " size="30"/>
* New Password:   
* Confirm New Password:   
68 |     69 | 70 |
75 | 76 |
77 | 78 |
79 | 80 | 81 | 82 |

83 | : Password must be of at least 8 characters, must contain at least one alphabet, one digit and one special character 84 |

85 | 86 |
87 | 88 |
89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/DispatchFileServlet.java: -------------------------------------------------------------------------------- 1 | // this servlet takes care of dispatchning a file from one branch to another 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import java.util.Date; 8 | import java.text.SimpleDateFormat; 9 | import org.apache.log4j.*; 10 | 11 | import bca.fts.dao.*; 12 | import bca.fts.model.*; 13 | 14 | public class DispatchFileServlet extends HttpServlet { 15 | 16 | // the logger object 17 | private static final Logger logger = Logger.getLogger(DispatchFileServlet.class); 18 | 19 | @Override 20 | public void doGet(HttpServletRequest request, HttpServletResponse response) 21 | throws ServletException, IOException { 22 | 23 | doPost(request, response); 24 | } 25 | 26 | @Override 27 | public void doPost(HttpServletRequest request, HttpServletResponse response) 28 | throws ServletException, IOException { 29 | 30 | HttpSession session = request.getSession(false); 31 | BranchBean branch = (BranchBean) session.getAttribute("branch"); 32 | String user = branch.getUsername(); 33 | 34 | String id = request.getParameter("id"); 35 | String forwardBranch = request.getParameter("branchToForward"); 36 | String page = request.getParameter("page"); 37 | 38 | int row = 0, fileID = 0; 39 | String errMessage = ""; 40 | 41 | // illigal access 42 | if (id == null && forwardBranch == null) { 43 | request.getRequestDispatcher("welcomeBranch.jsp").forward(request, response); 44 | } else { 45 | 46 | if (forwardBranch == null) { 47 | errMessage = "Please select a branch"; 48 | 49 | row = 0; 50 | } else { 51 | fileID = Integer.valueOf(id.trim()); //shouldn't throw an exception. Right?? 52 | 53 | // get the system's date 54 | Date today = new Date(); 55 | 56 | SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); 57 | String dateOfSend = sdf.format(today); 58 | 59 | // get the system's time 60 | sdf = new SimpleDateFormat("hh:mm:ss a"); 61 | String timeOfSend = sdf.format(today); 62 | 63 | SendFileBean bean = new SendFileBean(); 64 | bean.setFileId(fileID); 65 | bean.setSenderBranch(branch.getOfficeName()); 66 | bean.setForwardBranch(forwardBranch.trim()); 67 | bean.setDateOfSend(dateOfSend); 68 | bean.setTimeOfSend(timeOfSend); 69 | 70 | row = FileDao.sendFile(bean); 71 | } 72 | 73 | // check whether file successfully forwarded or not 74 | if (row == 1) { 75 | 76 | logger.info(user + " sent file having ID " + id + " to branch " + forwardBranch); 77 | 78 | request.setAttribute("message", "File with ID- " + id + " has been successfully forwarded to " + forwardBranch); 79 | 80 | // determine to which the request is need to forward 81 | if (page == null) { 82 | request.getRequestDispatcher("listRegFiles.do").forward(request, response); 83 | } else { 84 | request.getRequestDispatcher("loadIncomings.do").forward(request, response); 85 | } 86 | 87 | } else { 88 | 89 | if (errMessage.isEmpty()) { 90 | errMessage = "File couldn't be forwarded"; 91 | } 92 | 93 | request.setAttribute("errorMessage", errMessage); 94 | 95 | // determine to which VIEW the request is need to forward 96 | if (page == null) { 97 | request.getRequestDispatcher("listRegFiles.do").forward(request, response); 98 | } else { 99 | request.getRequestDispatcher("branchInbox.jsp").forward(request, response); 100 | } 101 | 102 | } 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/java/bca/fts/model/TrackFileBean.java: -------------------------------------------------------------------------------- 1 | // this bean represents data that is needed to track a file 2 | 3 | package bca.fts.model; 4 | 5 | public class TrackFileBean { 6 | 7 | private int id = 0; 8 | private String no = null; 9 | private String name = null; 10 | private String owner = null; 11 | private String status = null; 12 | private String curLoc = null; 13 | private String sender = null; // for 'REJECTED' files 14 | private String dateOfClose = null; 15 | private String dateOfCreation = null; // need to be created form "recieveDates" and "recieveTimes" 16 | private String recieveDates = null; 17 | private String recieveTimes = null; 18 | private String path = null; 19 | private String sendDates = null; 20 | private String sendTimes = null; 21 | private String dateOfSend = null; // uses while a is to track a file with its "DoS" 22 | private String dateOfReceive = null; // uses while a is to track a file with its "DoR" 23 | 24 | 25 | public void setDateOfReceive(String dateOfReceive) { 26 | this.dateOfReceive = dateOfReceive; 27 | } 28 | 29 | public void setDateOfSend(String dateOfSend) { 30 | this.dateOfSend = dateOfSend; 31 | } 32 | 33 | public void setPath(String path) { 34 | this.path = path; 35 | } 36 | 37 | public void setSendDates(String sendDates) { 38 | this.sendDates = sendDates; 39 | } 40 | 41 | public void setSendTimes(String sendTimes) { 42 | this.sendTimes = sendTimes; 43 | } 44 | 45 | public void setRecieveTimes(String recieveTimes) { 46 | this.recieveTimes = recieveTimes; 47 | } 48 | 49 | public void setRecieveDates(String recieveDates) { 50 | this.recieveDates = recieveDates; 51 | } 52 | 53 | public void setDateOfCreation(String dateOfCreation) { 54 | this.dateOfCreation = dateOfCreation; 55 | } 56 | 57 | public void setId(int id) { 58 | this.id = id; 59 | } 60 | 61 | public void setNo(String no) { 62 | this.no = no; 63 | } 64 | 65 | public void setName(String name) { 66 | this.name = name; 67 | } 68 | 69 | public void setOwner(String owner) { 70 | this.owner = owner; 71 | } 72 | 73 | public void setCurLoc(String curLoc) { 74 | this.curLoc = curLoc; 75 | } 76 | 77 | public void setDateOfClose(String dateOfClose) { 78 | this.dateOfClose = dateOfClose; 79 | } 80 | 81 | public void setSender(String sender) { 82 | this.sender = sender; 83 | } 84 | 85 | public void setStatus(String status) { 86 | this.status = status; 87 | } 88 | 89 | 90 | 91 | 92 | public String getDateOfReceive() { 93 | return dateOfReceive; 94 | } 95 | 96 | public String getDateOfSend() { 97 | return dateOfSend; 98 | } 99 | 100 | public String getPath() { 101 | return path; 102 | } 103 | 104 | public String getSendDates() { 105 | return sendDates; 106 | } 107 | 108 | public String getSendTimes() { 109 | return sendTimes; 110 | } 111 | 112 | public String getRecieveDates() { 113 | return recieveDates; 114 | } 115 | 116 | public String getRecieveTimes() { 117 | return recieveTimes; 118 | } 119 | 120 | public String getDateOfCreation() { 121 | return dateOfCreation; 122 | } 123 | 124 | public String getCurLoc() { 125 | return curLoc; 126 | } 127 | 128 | public String getDateOfClose() { 129 | return dateOfClose; 130 | } 131 | 132 | public int getId() { 133 | return id; 134 | } 135 | 136 | public String getName() { 137 | return name; 138 | } 139 | 140 | public String getNo() { 141 | return no; 142 | } 143 | 144 | public String getOwner() { 145 | return owner; 146 | } 147 | 148 | public String getSender() { 149 | return sender; 150 | } 151 | 152 | public String getStatus() { 153 | return status; 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /src/java/bca/fts/controller/BranchPassChange.java: -------------------------------------------------------------------------------- 1 | // this servlet is responsible for changing a branch account password 2 | package bca.fts.controller; 3 | 4 | import java.io.*; 5 | import javax.servlet.*; 6 | import javax.servlet.http.*; 7 | import org.apache.commons.codec.digest.DigestUtils; 8 | import org.apache.log4j.*; 9 | 10 | import bca.fts.dao.*; 11 | import bca.fts.model.*; 12 | import bca.fts.util.PasswordValidator; 13 | 14 | public class BranchPassChange extends HttpServlet { 15 | 16 | // the logger object 17 | private static final Logger logger = Logger.getLogger(BranchPassChange.class); 18 | 19 | @Override 20 | public void doGet(HttpServletRequest request, HttpServletResponse response) 21 | throws ServletException, IOException { 22 | 23 | doPost(request, response); 24 | } 25 | 26 | @Override 27 | public void doPost(HttpServletRequest request, HttpServletResponse response) 28 | throws ServletException, IOException { 29 | 30 | HttpSession session = request.getSession(false); 31 | BranchBean branch = (BranchBean) session.getAttribute("branch"); 32 | String user = branch.getUsername(); 33 | 34 | String oldPass = request.getParameter("oldPass"); 35 | String newPass = request.getParameter("newPass"); 36 | String confPass = request.getParameter("confPass"); 37 | 38 | int result = 0; 39 | 40 | // check for null values, illigal access 41 | if (oldPass == null || newPass == null || confPass == null) { 42 | request.getRequestDispatcher("welcomeBranch.jsp").forward(request, response); 43 | } else { 44 | // just return to the "VIEW" if empty form 45 | if (oldPass.isEmpty() || newPass.isEmpty() || confPass.isEmpty()) { 46 | 47 | request.setAttribute("errorMessage", "Form fileds can't be empty"); 48 | request.getRequestDispatcher("passChange.jsp").forward(request, response); 49 | } else { 50 | 51 | // query the database via "DAO" 52 | branch = BranchLoginCheckDao.authenticate(user, DigestUtils.md5Hex(oldPass)); 53 | String passError = PasswordValidator.validatePassword(newPass); 54 | 55 | // verify the old password 56 | if (branch == null || branch.getOfficeName() == null) { 57 | 58 | if (branch == null) { 59 | request.setAttribute("errorMessage", "Error has occured in the database operation!"); 60 | } else { 61 | request.setAttribute("errorMessage", "Old password didn't match"); 62 | } 63 | 64 | request.getRequestDispatcher("passChange.jsp").forward(request, response); 65 | } // verify the new password 66 | else if (passError.isEmpty() == false) { 67 | 68 | request.setAttribute("errorMessage", passError); 69 | request.getRequestDispatcher("passChange.jsp").forward(request, response); 70 | } // confirm the new password 71 | else if (newPass.equals(confPass) == false) { 72 | 73 | request.setAttribute("errorMessage", "New and confirm passwords didn't match"); 74 | request.getRequestDispatcher("passChange.jsp").forward(request, response); 75 | } // every thing is fine, change the password 76 | else { 77 | result = BranchLoginCheckDao.changePassword(user, DigestUtils.md5Hex(newPass)); 78 | 79 | if (result == 1) { 80 | logger.info(user + " changed the password"); 81 | 82 | request.setAttribute("message", "Password has been changed succefully"); 83 | request.getRequestDispatcher("welcomeBranch.jsp").forward(request, response); 84 | } else if (result == 0) { 85 | request.setAttribute("errorMessage", "Password couldn't be changed"); 86 | request.getRequestDispatcher("passChange.jsp").forward(request, response); 87 | } else { 88 | request.setAttribute("errorMessage", "Error has occured in the database operation!"); 89 | request.getRequestDispatcher("passChange.jsp").forward(request, response); 90 | } 91 | } 92 | 93 | } 94 | } 95 | 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/java/bca/fts/model/FileBean.java: -------------------------------------------------------------------------------- 1 | // this bean represents a file object 2 | 3 | package bca.fts.model; 4 | 5 | import java.text.SimpleDateFormat; 6 | import java.util.Date; 7 | import org.apache.log4j.Logger; 8 | 9 | public class FileBean { 10 | 11 | // the logger object 12 | private static final Logger logger = Logger.getLogger(FileBean.class); 13 | 14 | private int id = 0; 15 | private String no = null; 16 | private String name = null; 17 | private String type = null; 18 | private String description = null; 19 | private String owner = null; 20 | private String status = null; 21 | private String forwardBranch = null; 22 | private String dateOfSend = null; 23 | private String timeOfSend = null; 24 | private String curLoc = null; 25 | private String sender = null; 26 | private String remark = null; 27 | private String dateOfRecieve = null; 28 | private String timeOfRecieve = null; 29 | 30 | // for pendind, rejected file sorting 31 | private Date date = null; 32 | 33 | // ALL THE "SETTER" METHODS 34 | 35 | public void setDate() { 36 | SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy 'at' hh:mm:ss a"); 37 | 38 | try { 39 | 40 | this.date = formatter.parse(this.dateOfSend); 41 | } 42 | catch (Exception e) { 43 | logger.error(e); 44 | } 45 | } 46 | 47 | 48 | public void setTimeOfSend(String timeOfSend) { 49 | this.timeOfSend = timeOfSend; 50 | } 51 | 52 | public void setTimeOfRecieve(String timeOfRecieve) { 53 | this.timeOfRecieve = timeOfRecieve; 54 | } 55 | 56 | public void setDateOfRecieve(String dateOfRecieve) { 57 | this.dateOfRecieve = dateOfRecieve; 58 | } 59 | 60 | public void setId(int id) { 61 | this.id = id; 62 | } 63 | 64 | public void setDescription(String description) { 65 | this.description = description; 66 | } 67 | 68 | public void setName(String name) { 69 | this.name = name; 70 | } 71 | 72 | public void setType(String type) { 73 | this.type = type; 74 | } 75 | 76 | public void setNo(String no) { 77 | this.no = no; 78 | } 79 | 80 | public void setOwner(String owner) { 81 | this.owner = owner; 82 | } 83 | 84 | public void setStatus(String status) { 85 | this.status = status; 86 | } 87 | 88 | public void setForwardBranch(String forwardBranch) { 89 | this.forwardBranch = forwardBranch; 90 | } 91 | 92 | public void setDateOfSend(String dateOfSend) { 93 | this.dateOfSend = dateOfSend; 94 | } 95 | 96 | public void setCurLoc(String curLoc) { 97 | this.curLoc = curLoc; 98 | } 99 | 100 | public void setSender(String sender) { 101 | this.sender = sender; 102 | } 103 | 104 | public void setRemark(String remark) { 105 | this.remark = remark; 106 | } 107 | 108 | 109 | 110 | // ALL THE "GETTER" METHODS 111 | public Date getDate() { 112 | return date; 113 | } 114 | 115 | public String getTimeOfSend() { 116 | return timeOfSend; 117 | } 118 | 119 | public String getTimeOfRecieve() { 120 | return timeOfRecieve; 121 | } 122 | 123 | public String getDateOfRecieve() { 124 | return dateOfRecieve; 125 | } 126 | 127 | public String getStatus() { 128 | return status; 129 | } 130 | 131 | public String getOwner() { 132 | return owner; 133 | } 134 | 135 | public String getNo() { 136 | return no; 137 | } 138 | 139 | public int getId() { 140 | return id; 141 | } 142 | 143 | public String getName() { 144 | return name; 145 | } 146 | 147 | public String getType() { 148 | return type; 149 | } 150 | 151 | public String getDescription() { 152 | return description; 153 | } 154 | 155 | public String getDateOfSend() { 156 | return dateOfSend; 157 | } 158 | 159 | public String getForwardBranch() { 160 | return forwardBranch; 161 | } 162 | 163 | public String getCurLoc() { 164 | return curLoc; 165 | } 166 | 167 | public String getSender() { 168 | return sender; 169 | } 170 | 171 | public String getRemark() { 172 | return remark; 173 | } 174 | 175 | } 176 | --------------------------------------------------------------------------------