Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Bookmark Backup Final Document Raymond Frey Dr. Bi December 3, 2010 Submitted in partial fulfillment of the requirements of CMPS 490 – Computer Projects Final Document for Bmark Backup Page ii Table of Contents Table of Contents .......................................................................................................................... ii 1. Introduction ..............................................................................................................................1 1.1 Purpose ........................................................................................................................................ 1 1.2 Project Scope ............................................................................................................................... 1 1.3 Glossary ....................................................................................................................................... 2 1.4 Overview ..................................................................................................................................... 2 1.4.1 Requirements Document ......................................................................................................... 2 1.4.2 System Design Document ..................................................................................................... 13 1.4.3 Testing Document ................................................................................................................. 25 1.4.4 User Manual .......................................................................................................................... 32 2. System Status ..........................................................................................................................35 2.1 Work Accomplished .................................................................................................................. 35 2.2 Maintenance Concerns .............................................................................................................. 35 2.2.1 Known Problems ................................................................................................................... 35 2.2.2 Expected Evolution ............................................................................................................... 35 3. Appendix ................................................................................................................................36 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 createAccount ............................................................................................................................ 36 createPostgresTable ................................................................................................................... 36 Directory.java ............................................................................................................................ 37 FTP.java..................................................................................................................................... 38 GlobalDataStore.java ................................................................................................................. 39 Home.java .................................................................................................................................. 39 Login.java .................................................................................................................................. 41 LoginWindow.java .................................................................................................................... 42 NewUserLogin.java ................................................................................................................... 44 Sqlite.java .................................................................................................................................. 46 UpdateBookmarks.java.............................................................................................................. 49 Final Document for Bmark Backup Page 1 1. Introduction 1.1 Purpose The purpose of this document is to present a final systems report on the Testing Assistant for Regression Testing. It is also a compilation of all documentation that has been written for this project. The audience for this document is any person who may be involved with the maintenance of the Testing Assistant. 1.2 Project Scope This software is created to provide and easy way of sharing bookmarks between multiple devices. The Android Application market has millions of customers and thousands of new customers every day. There is not currently a product that offers to synchronize bookmarks with Firefox. Only Google Chrome is supported at this point. Many users have the need to store their bookmarks in a remote location and retrieve them later. This program would allow for the downloaded of bookmarks to the clients bookmark tab in their browser. The Java Application would be able to be obtained from a web address at the time of release. Consiquently the Android Application would be able to be retrieved using the Android MarketPlace via the Android Operating System. The application is designed to be simple to install and simple to run. The user only needs a few clicks to get the program up and running. The background of the program is designed to gather the bookmarks and upload them to a server. Easy of use is the main focus of this program. The fewer clicks a user has to perform the easier the system will be to use. Final Document for Bmark Backup Page 2 1.3 Glossary FTP Server Database Database Management System PostgreSQL SQL SQLite A file server used to host the SQLite files An organized collection of data. Also known as a DBMS. This is a program/suite used to manage a database and run operations on this database as indicated by the end user of the system. A Database Management System that is free open source. The system makes use of SQL to query the database and returns the results to the server as requested. Structured Query Language – A widely used computer language to create, edit, and retrieve data from a database. A Database Management System that is free and open source. It is run on a local machine and is for storing local information into a database. 1.4 Overview 1.4.1 Requirements Document 1. Introduction 1.1 Purpose The purpose of this document is to provide a description of the features and funtionality that will be provided in the system. The scope and enviroment of this system will be provided in the document. The user will be able to use this document to view the use case situations. The goal of this document is to outline the system in simple and easy to understand terms and to show the functionality of the system. 1.2 Project Scope This software is created to provide and easy way of sharing bookmarks between multiple devices. The Android Application market has millions of customers and thousands of new customers every day. There is not currently a product that offers to synchronize bookmarks with Firefox. Only Google Chrome is supported at this point. Many users have the need to store their bookmarks in a Final Document for Bmark Backup Page 3 remote location and retrieve them later. This program would allow for the downloaded of bookmarks to the clients bookmark tab in their browser. The Java Application would be able to be obtained from a web address at the time of release. Consequently the Android Application would be able to be retrieved using the Android MarketPlace via the Android Operating System. The application is designed to be simple to install and simple to run. The user only needs a few clicks to get the program up and running. The background of the program is designed to gather the bookmarks and upload them to a server. Easy of use is the main focus of this program. The fewer clicks a user has to perform the easier the system will be to use. 1.3 References Frey, Raymond. “Bookmark Backup Extended Abstract.” University of Scranton. 27 August 2010. Frey, Raymond. “Bookmark Backup Justification and Feasibility.” University of Scranton. 3 September 2010. 1.4 Glossary FTP Server A file server used to host the SQLite files Database An organized collection of data. Database Management System Also known as a DBMS. This is a program/suite used to manage a database and run operations on this database as indicated by the end user of the system. Final Document for Bmark Backup PostgreSQL Page 4 A Database Management System that is free open source. The system makes use of SQL to query the database and returns the results to the server as requested. SQL Structured Query Language – A widely used computer language to create, edit, and retrieve data from a database. SQLite A Database Management System that is free and open source. It is run on a local machine and is for storing local information into a database. 2. Overall Description 2.1 System Overview Figure 1 - System Environment The System is designed to work with multiple users over multiple platforms. The only parts of the system that are dependent on the number of people are the servers which would have to handle each user. The Java Application and Android application are independent of the number of users. Each user must have the Java Application, but each user does not have to have the Android Application. The Android Application will also have the exact same use cases. The programs are designed to have the same buttons and functions. 2.2 Functional Requirements Functional requirements are services that are going to be provided to the user. The main type of user is the regular user. Administrators are not needed in this system because it should be self sufficient by the regular user/customer Final Document for Bmark Backup 2.2.1 User Use Case #1: Create Account Brief Description: 1. User goes to the New User login screen. 2. The user enters desired Username and Password into form boxes. 3. The user will be redirected to the User Login Screen if successful. 2.2.2 User Use Case #2: Login Brief Description: Enter Username and Password into the Login Screen Click Send User will be presented with the homepage. 2.2.3 User Use Case #3: Logout Brief Description: 1. Click Exit or Switch Users on the Home screen. 2.2.4 User Use Case #4: Manual Update Bookmarks Brief Description: 1. Users Clicks Sync Bookmarks 2. Bookmarks are automatically downloaded and copied to the local bookmark folder. Page 5 Final Document for Bmark Backup Page 6 2.2.5 User Use Case #5: Automatically Update Bookmarks Brief Description: 1. User clicks “Automatically Update Bookmarks” 2. The Bookmarks will be automatically updated at a certain interval. 2.2.6 User Use Case #5: Stop Automatically Update Bookmarks Brief Description: 1. User clicks “Stop Automatic Update Bookmarks” 2. The Bookmarks will not be automatically updated at a certain interval. 2.3 User Interface Specification The users using this system need only minimum computer knowledge. The system is designed to be an easy to use application for anyone that uses the Firefox internet browser and Android Operating system on a mobile device. 2.4 Non-functional Requirements Final Document for Bmark Backup Page 7 This section of the document will cover those requirements that are not the functional requirements of the system. Such requirements are the constraints of the system as it pertains to performance relative to a given system. 2.4.1. Product Non-functional Requirements The performance of the application will rely heavily on the system on which the system is used. Older computers and Android phones may take long in processing the bookmark files and setting the files in the bookmark folder. . The hardware involved includes a database server, CS Dept Server 8 – PostgreSQL DBMS. The server is constantly running and should not be a problem in this application. The server could because full bu the PostgreSQL database only uses one table for login information. The FTP server is more likely to fill because it holds the current file for bookmarks. These files are substantially bigger than the login records. 2.4.2 Process Non-functional Requirements Currently, the system is being developed using the Eclipse IDE. This Application is built with the Java Programming Language. Both Android and the Java Application are constructed using Java. JDBC will be used to interact with the PostgreSQL database server. 2.5 System Evolution Over time the FTP server will fill with users. Some of these users may not want to use the system anymore but their data will remain. A “delete account” feature may be added at a future date to Final Document for Bmark Backup Page 8 allow for accounts to be deleted that meet certain idle time requirements. These accounts require minimum space but depending of the amount of users the server could fill up quickly. 3. Requirements Specification 3.1 External Interface Requirements 3.2 Functional Requirements 3.2.1 User’s Functional Requirements 3.2.1.1 Create “Account” User Use Case Name Priority Create “Account” User Essential TriggerNone Precondition The user is at the “New User” screen Basic Path Click “New User” button on Login screen Alternative Path None Postcondition The user will be able to login to the system Exception Paths None 3.2.1.2 Login Use Case Name Priority Login Essential TriggerNone Precondition The user is at the login page Basic Path Open Java file or Android Application Final Document for Bmark Backup Alternative Path None Postcondition The user will be logged in to the system Exception Paths None 3.2.1.3 Logout Use Case Name Priority Logout Essential TriggerNone Precondition The user is logged into the system Basic Path Click “Exit ” button Alternative Path None Postcondition The user will be logged out of the system Exception Paths None 3.2.1.4 Manual “Update” Bookmarks Use Case Name Priority Manual “Update” Bookmarks Essential TriggerNone Precondition The user is logged into the system Basic Path Click “Manual Update” button Alternative Path None Postcondition The bookmarks will be updated. Exception Paths None Page 9 Final Document for Bmark Backup 3.2.1.5 Automatic “Update” Bookmarks Use Case Name Priority Automatic “Update” Bookmarks Essential TriggerNone Precondition The user is logged into the system Basic Path Click “Automatic Update” button Alternative Path None Postcondition The bookmarks will be updated at the time interval Exception Paths None 3.2.1.5 Stop Automatic “Update” Bookmarks Use Case Name Priority Stop Automatic “Update” Bookmarks Essential TriggerNone Precondition The user is logged into the system Basic Path Click “Stop Automatic Update” button Alternative Path None Postcondition The bookmarks will not be updated at the time interval Exception Paths 3.3 None Detailed Non-functional Requirements Hardware: ● Client computers that have access to the web via the Internet/Network connections Page 10 Final Document for Bmark Backup ● Page 11 Android Phones that have access to Internet/WiFi connections Software: ● The FTP server is platform dependant but is running FreeBSD on server 8. ● PostgreSQL database must be running and currently is on CS Department’s Server 8. ● Client computers must have the newest package of Java Installed. ● Android phones need this application in order to synchronize bookmarks Network interface: ● Internet/Network connectivity will be needed to access the PostgreSQL DBMS. 4. Gantt Chart Activity Complete 11/29 Proposal Status 9/3 12/9 100% A SSSSS 9/17 9/24 10/1 10/22 11/6 Final Document for Bmark Backup Analysis Page 12 95% S Specification 95% S High-level Design 40% S SSS SSSSS System Design 40% S SS SSSSS SSSSS SS Implementation 10% S SSSSS SSSSS SSSSS S SSSSS SSSSS S SSS SSSSS SSSSS Module Testing SSSSS Integration Testing SSSSS SSS SSSSS BSSSS SSSSS SSS SS 0% SSSS 0% SSSSS SS Project Status Symbols S Scheduled A Satisfactory C Caution F Critical Planning/Progress Symbols B Work Before Scheduled Time Final Document for Bmark Backup Page 13 S Scheduled Activity Time A Work After Scheduled Time 1.4.2 System Design Document Chapter 1: Introduction 1.1 Purpose The purpose of this document is to have an overview of the system and to show the implementation of the proposed project. This document is to be used to describe to computer professionals, programmers and developers the architecture and design methods that this system employs. The document shows the relationships among the components and subparts that are used in the system and outlined in the project proposal and requirements document. 1.2 Scope This software is created to provide and easy way of sharing bookmarks between multiple devices. The Android Application market has millions of customers and thousands of new customers every day. There is not currently a product that offers to synchronize bookmarks with Firefox. Only Google Chrome is supported at this point. Many users have the need to store their bookmarks in a remote location and retrieve them later. This program would allow for the downloaded of bookmarks to the clients bookmark tab in their browser. The Java Application would be able to be obtained from a web address at the time of release. Consequently the Android Application would be able to be retrieved using the Android Marketplace via the Android Operating System. The application is designed to be simple to install and simple to run. The user only needs a few clicks to get the program up and running. The Final Document for Bmark Backup Page 14 background of the program is designed to gather the bookmarks and upload them to a server. Ease of use is the main focus of this program. The fewer clicks a user has to perform the easier the system will be to use. 1.3 Glossary Android Operating system created by Google which runs on various models of smart phones from several different service providers. Class In this application, these are objects that share common attributes and methods Database An organized collection of data. Database Management System Also known as a DBMS. This is a program/suite used to manage a database and run operations on this database as indicated by the end user of the system. Java-interface A simple and straight-forward user interface used to interact with the system and underlying database. This is made of a set of interrelated pages that communicate with each other and the web server. PostgreSQL A Database Management System that is free open source. The system makes use of SQL to query the database and returns the results to the server as requested. SQL Structured Query Language – A widely used computer language to create, edit, and retrieve data from a database. 1.4 References Frey, Raymond. “Bookmark Backup Extended Abstract.” Final Document for Bmark Backup Page 15 University of Scranton. 29 August 2010. Frey, Raymond. “Bookmark Backup Justification and Feasibility.” University of Scranton. 2 September 2010. Frey, Raymond. “Bookmark Backup System Requirements Specification.” University of Scranton. 17 September 2010. 1.5 Overview of Document The rest of this document will describe the system design in detail. Chapter 2 contains the deployment diagram of the system, which provides a look at the full system. Chapter 3 describes the architectural design of the system. Chapter 4 details the Data Structure design of the system, which includes the SQL tables in the PostgreSQL database. Chapter 5 provides detailed use case realizations as laid out in the SRS document. Chapter 6 describes the interface design of the system, which includes the Java layout and the Android layout. Finally, Chapter 7 will discuss the Help System design for users that do not understand the program. Chapter 2: Deployment Diagram Figure 1 - Deployment Diagram A user of the system must be on a PC or Android system as indicated in Figure 1. The PC will interact with the web server which happens to be placed on another user PC in this system. Final Document for Bmark Backup Page 16 Each PC is connected to a printer, locally or by network. The web server, Apache Tomcat, contains/hosts the web application to be used via web interface. The web server will access the database management system (DBMS) to access and store data as requested by the users of the system. Chapter 3: Architectural Design Figure 2 - Architectural Design Diagram 3.1 Abstract Specification and Interface Design 3.1.1 Login Name: Login Type: Java Form Description: This form is displayed in one of two setups. The first version of the form is for a Java user using the application from the PC. The second version of the form is for the user that is logging in from the Android System. Each form will allow login to the system with the end result being a redirection to that user’s allowed “system home screen.” Operations: Name: Login () Arguments: Values of “username” and “password” fields. Returns: No return value. Pre-condition: User has completed Account Creation. Final Document for Bmark Backup Page 17 Post-condition: User is presented with Main Menu corresponding to his/her username. Exception: None. 3.1.2 Create Account Name: CreateAccount Type: Java Form Description: This form is displayed in one of two systems. The first version of the form is for a Java user using the application from the PC. The second version of the form is for the user that is logging in from the Android System. Each form will allow Account Creation and will write the user information to the PostgreSQL database under the table “Users”. Operations: Name: NewUserLogin () Arguments: Values of “username” and “password” fields. Returns: Void. Pre-condition: Account does not already exist.. Post-condition: User is presented with Main Menu corresponding to his/her username. Exception: None. 3.1.3 Main Menu Name: Main Menu Type: Java form Description: Final Document for Bmark Backup Page 18 This form is displayed after successful log-in by a user with access to the system. The functions of the program are displayed after the user logs in. Operations: Name: BackupBookmarks () Arguments: path to the places.sqlite file Returns: Void. Pre-condition: A user is logged onto his/her system home screen. Post-condition: The users bookmarks are updated with the server. Exception: None. Name: SwitchUser () Arguments: None Returns: No return value. Pre-condition: A manager is logged onto his/her system home page. Post-condition: User is forwarded to a Java form to input information for another login. Exception: None. Name: Exit () Arguments: None Returns: No return value. Pre-condition: A manager is logged onto his/her system home screen. Post-condition: Program is exited. Exception: None. Final Document for Bmark Backup Page 19 3.1.4 PostgreSQL Name: PostgreSQL Type: Database Management System Description: This is the database management system to be used in implementing this system. The database for this system has the tables/relations listed in the architectural design diagram. Tables will be named according to the Username of the User currently logged in. Tables/Relations: UserAccounts User_bookmarks User_places Chapter 4: Data Structure Design This system will make use of a variety of data structures. Most importantly are the PostgreSQL and SQLite databases. These Databases will hold all of the bookmark information for each user. Each SQLite database will have relevant information uploaded and downloaded from the PostgreSQL database. 4.1 Database Tables/Relations The database tables as presented here are shown as psuedo SQL code used in their actual realization in the databases. The primary key, any unique fields, and foreign keys are indicated after all field names, data types, and modifiers are presented. I have not included the SQLite database for Firefox because the SQL for creation is not publicly available. The stars in the Final Document for Bmark Backup Page 20 bookmark table denotes a variable. Meaning the table will have the value bookmark_*username*, where username is the current user. 4.2.1 Accounts Field Name Username Password Data Type INT Modifier NOT NULL VARCHAR(20) NOT NULL PRIMARY KEY (Username) UNIQUE (UserName) ON UPDATE cascade ON DELETE restrict 4.2.2 Bookmarks_*User_ID* Field Name Data Type Modifier Url VARCHAR(50) NOT NULL Title VARCHAR(20) Flag CHAR(1) PRIMARY KEY (url) Chapter 5: Use Case Realizations 5.1 User NOT NULL Final Document for Bmark Backup Page 21 There is only one type of user in this system. Everyone is treated as a regular user and there is no need for other levels of user types. Figure 3 - Generalized User Case 5.1.1 Login Figure 4 - User Login Use Case Realization 1. The user opens the Java or Android application to the User_Login page. 2. The user then enters “Username” and “Password” into the Java or Android form that is displayed. 3. The user clicks a “Login” button to forward the login request to the next class “Home.java” 4. The GlobalDataStore class saves the form information from the java form to a static variable in GlobalDataStore essentially creating a session. 5. The database is queried to see if there is a tuple match to the information entered on the Java form. 6. If a tuple is found, the user is forward to the Home.java. If a tuple is not found, the user is redirected back to UserLogin.java. 5.1.2 CreateAccount Figure 5 - User Login Use Case Realization 1. The user opens the Java or Android application to the User_Login page. Final Document for Bmark Backup Page 22 2. The user then enters “Username” and “Password” into the Java or Android form that is displayed. 3. The user clicks a “Login” button to forward the login request to the next class “Home.java” 4. The GlobalDataStore class saves the form information from the java form to a static variable in GlobalDataStore essentially creating a session. 5. The database is queried to see if there is a tuple match to the information entered on the Java form. 6. If a tuple is found, the user is forward to the Home.java. If a tuple is not found, the user is redirected back to UserLogin.java. 5.1.3 Logout Figure 6 - User Logout Use Case Realization 1. From the Home.java screen the Switch User/Logout feature can be used 2. The user will simply click on a logout button placed at the top or bottom of the Java form. 3. The logged out user will then be redirected back to the UserLogin.java page. 5.1.4 Update Bookmarks Figure 7 - Update Bookmark Use Case Realization 1. The user will click on the “BackupBookmarks” link at Home.java Final Document for Bmark Backup 2. The bookmarks will be uploaded to the PostgreSQL server 3. A flag will be set for each bookmark coming from its respective system. A bookmark Page 23 coming from Android will be flagged ‘A’. A bookmark coming from Java will be flagged ‘J’. A bookmark that has been retrieved by the destination application will be flagged ‘X’. 4. The bookmarks with flag ‘A’ will be downloaded into the standalone Java system. And bookmarks with flag ‘J’ will be downloaded to the Android System. 5. The Home.java screen will be shown, with a message of completion. Chapter 6: User Interface Design The users who will be using this system are not computer savvy. The interface will be kept simple to accommodate these users. The system’s interface will consist of few Java forms to navigate through. This interface will be presented through a Java application or Android System. These Applications will perform identical tasks and the layout of the screen will also be as close to identical as possible. After log-in, a click of the Backup button will activate a sequence of events to be performed. The user will be oblivious to the behind-the-scene actions. A sample of the Log-in and Home Screen on the Java side is provided below. The user will only notice the notification that the bookmarks are completed stored back in the Firefox database. This setup is very simple and will allow those who are not computer savvy to utilize this system. Chapter 7: Help System Design Final Document for Bmark Backup Page 24 The help system will be limited and simple. All of the forms are self explanatory and the possible area for help would be explaining the purpose of the “Backup” button. For that button, a “Help” link will be placed on the form that will display a help Java Pop-up. Gantt Chart Activity Complete Status 9/2 Proposal 100% A SSSSS Analysis 100% A 9/9 9/23 9/30 10/21 11/5 11/28 12/9 SSS SSSSS Specification 100% A BSSSS High-level Design 95% S System Design 95% S Implementation 50% C Module Testing 5% S Integration Testing 0% S Project Status Symbols S Scheduled A Satisfactory C Caution F Critical Planning/Progress Symbols B Work Before Scheduled Time S Scheduled Activity Time A Work After Scheduled Time SSSSS SSS SSSSS SSSA A SS SSSSS SSSSS SSS SSS SSSSS SSSSS SSSSS SS SSSSS SSSSS SSSS SSS SSSSS SSSSS SSSSS SSS Final Document for Bmark Backup Page 25 1.4.3 Testing Document 1 Introduction 1.1 Purpose The purpose of this document is to overview the testing design to be used for Bookmark Backup. All cases will be tested thoroughly and completely. This program’s sustainably depends on the reliability of its databases and written code. If a user cannot trust this program, it may never be used and improved. The intended audience for this document is the group of developers that will need to modify this software or provide upgrades within the project. They will be able to use this document to realize how this system was design and tested. They can make changes based on the design and have a systematic approach to test each new change. 1.2 Scope This document will cover the aspects of complete testing strategy to be employed with this Bookmark Backup. The testing will focus on the interacting of the databases as well as the correctness of the data in them. The essential part of this program is storing and retrieving the bookmarks correctly. This document will outline the methods that will be used to test each function of this program. Any errors that may be found will be fixed at the testing level of the program which will reduce the errors that may be found when the program is released. 1.3 Glossary Acceptance Testing This is testing using data by the developer Beta Testing This is testing performed by the end user with actual data. Final Document for Bmark Backup Database Page 26 An organized collection of data. Database Management System Also known as a DBMS. This is a program/suite used to manage a database and run operations on this database as indicated by the end user of the system. Java-interface A simple and straight-forward user interface used to interact with the system and underlying database SQL Structured Query Language – A widely used computer language to create, edit, and retrieve data from a database. Unit Testing This is the testing of each application’s features within a module. 1.4 References Frey, Raymond. “Bookmark Backup Extended Abstract.” University of Scranton. 29 August 2010. Frey, Raymond. “Bookmark Backup Justification and Feasibility.” University of Scranton. 2 September 2010. Frey, Raymond. “Bookmark Backup System Requirements Specification.” University of Scranton. 17 September 2010. Frey, Raymond. “Bookmark Backup System System Design.” University of Scranton. 15 October 2010. Final Document for Bmark Backup 2 Page 27 Test Plan The test plan used for this system will be as complete as possible. Every unit in this system is to be tested as completely and thoroughly as time allows. 2.1 Schedules and Resources As the creator of this Java and Android application, I will perform all testing on the system. I will design tests that are appropriate for this system. As testing progresses, I will either correct or record any errors that are found. Once the error is corrected, I will continue testing to ensure other errors were not created. Each use case represents a path in the system. This particular system does not have many paths the user can take, because the work is done behind the scenes. This means I will have to manually add bookmarks to the system and check for errors after each addition. Once again, any errors at this level will be noted and fixed as deemed necessary. Resources needed for testing include putty to access the PostgreSQL database. Any errors in either the Java Application or Android Application will be corrected in Eclipse. After the fixes, the application will be restarted for continued testing. 2.2 Test Recording Tested Item Tester Expected Results Date Tested Final Document for Bmark Backup Page 28 Pass / Fail Figure 1- Sample Test Record .Each item that is tested will be reported in this form, so the developer can determine what items are failing. If multiple items are failing they can be traced back to the source of the problem by analyzing these forms. 2.3 Test Reporting Use Cases Items Tested Items with Errors Retesting Dates Figure 2 – Sample Test Report Each test will be reported, with all of the items tested by the user. Any errors will be reported on this sheet as well as the use case the error was found in. 3 Verification Testing 3.1 Unit Testing Testing of individual units will consist of testing each Application. The Java and Android Applications will be tested separately to ensure each is running without errors. As errors are found in each application they can be address and solved. The results of the testing can be viewed by examining the databases for each system, as well as the intermediary database where all of the Final Document for Bmark Backup Page 29 bookmarks will be stored. The modules are split into a few basic categories for testing. The divisions are “create account”, “login/logout”, and “update bookmarks”. 3.2 Integration testing At this level, modules of the system will be tested thoroughly to ensure proper system implementation. I will create a strategy so each module is tested properly. Each case of the system for both applications will be tested starting with the log-in. Each button and each user case will be thoroughly examined and checked for errors. After these tests are complete, testing of the Home menu will begin. Each time the Back-up button is clicked each of the databases must be checked to ensure each one contains the proper information. 3.2.1 “Create Account” Module Testing The “Create Account” modules within the system have been implemented in very similar ways. This use case will start from the User Login screen which is the first screen presented to the user when the application is opened. Clicking on the Create New User button in this screen will forward the user to a Create New User Screen. Here the user will then test that the module will correctly register the user in the system. Regular expressions will enforce the similarity of user names in the system. Then the user completes module testing by hitting the “finished” button on the Java Form. The user now only has to confirm the addition of user to the database. If the module works correctly, the user will but able to log into the system on the next page. The developer might then access the database through an interface that is not the Java or Android interface being tested. As an example, the developer may login to the database server and run queries on the same data tested to ensure that the database has successfully and correctly added the data set as a record. Final Document for Bmark Backup Page 30 3.2.2 “Login”/“Logout” Module Testing Module testing for login to the system involves the developer/user entering both valid and invalid user credentials at the login screens. Developers must handle this testing and will either receive a failed login message or they will be logged into the Home form of the application. Once the login has been completed successfully by the developer it is considered functional and fully tested. Logout module testing involves signing out using the appropriate logout button. The code should return the user to the login screen. The session should also not be allowed to be hijacked at any time to give users unauthorized access to another account. Any errors that occur during this process must be logged and repaired by the developer. 3.2.3 “Update Bookmarks” Module Testing This module testing strategy involves ensuring that the correct bookmarks are in their correct locations. To back-up the bookmarks each user must have created an account. The account creation process also creates the appropriate bookmark database for the user. Without these tables the user will receive notifications that their bookmarks cannot be backed-up. Every test will be run with real data from the SQLite database which holds the records for each bookmark. Different machines running on different networks will ensure each machine can update its bookmarks with the server. 4 Validation Testing 4.1 Acceptance and Beta Testing Final Document for Bmark Backup Page 31 Acceptance testing will continually be performed by me.. Once the system is implemented, the system will undergo continual testing by me and will also include upgrades by request of users. The users will be asked to provide feedback and I will make changes to the system based on that feedback. I will also have planned features that I would put into the program so I can release the program as a Beta. The Beta will not contain all features but will allow for a greater group of testers. Once I find the beta to be satisfactory I can test new features for the program. This will be a continual process of testing. There is always a way to improve the system, so this beta testing by the user is essential. 5 Gantt Chart Activity Complete Status 9/2 Proposal 100% A SSSSS Analysis 100% A 9/9 9/23 9/30 10/21 11/5 11/28 12/9 SSS SSSSS Specification 100% A BBSSS SSSSS High-level Design 95% S SSS SSSSS SSSS SAAA A System Design 95% S S SSSSS SSSSS SSSA A Implementation 45% C SSS SSSSS SSSSS SSSSS AAA Module Testing 15% S SSSSS SSSSS SSSSS SSCC Integration Testing 5-15% S Project Status Symbols S Scheduled A Satisfactory C Caution F Critical S SSSSS SSSSS SSSSS SC Final Document for Bmark Backup Page 32 Planning/Progress Symbols B Work Before Scheduled Time S Scheduled Activity Time A Work After Scheduled Time 1.4.4 User Manual 1 INTRODUCTION 1.1 Purpose This document is the user manual for the Bookmark Backup system. Since the system has few interactions this document will only need to be referenced for clarification. 1.2 Scope of Project The Bookmark Backup system is developed more Android and computer users that want to copy their bookmarks quickly and easily from their computer to the Android system. Currently the software supports Windows XP and Windows 7. Support for other operating systems is coming soon. 1.3 Glossary Term Definition Android Operating system created by Google which runs on various models of smart phones from several different service providers. Bookmarks Website URL’s stored with other information. Database An organized collection of data. Final Document for Bmark Backup Java Page 33 The native language of the applications 1.4 References Frey, Raymond. “Bookmark Backup Extended Abstract.” University of Scranton. 29 August 2010. Frey, Raymond. “Bookmark Backup Justification and Feasibility.” University of Scranton. 2 September 2010. Frey, Raymond. “Bookmark Backup System Requirements Specification.” University of Scranton. 17 September 2010. Frey, Raymond. “Bookmark Backup System Design.” University of Scranton. 15 October 2010. 1.5 Overview of Document The document will consist of two chapters. The Instruction Manual for users who need to know how the system operates and the Reference Manual for the listing of services and error messages and recovery. 2 INSTRUCTIONAL MANUAL 2.1 Normal System Usage 2.1.1 New User Login When Bookmark Backup is loaded the user will have the option to log in or create a new account. Final Document for Bmark Backup Page 34 2.1.2 New User Login Form This form will allow the user to create a new account. The password fields must match and are case – sensitive. The username field is not case sensitive, meaning; the user name is translated to all lower case letters when processed in the system. 2.1.3 Login Form The user must enter the username and password information into the system. The system will give notification if the connection to the server is successful and the username and password are correct. 2.1.5 Home Screen The Home Screen gives the user the option to “Back-up”, “Switch Users”, or “Exit”. The Back-up button only works if the Firefox internet browser is closed. Currently that is the only way to back up the bookmarks from Firefox. If an error occurs the system will notify the user with a pop-up indicating the type of error . 3 USER REFERENCE MANUAL 3.1 Error Messages and Error Recovery Final Document for Bmark Backup Page 35 Error Message How To Recover From Error Connection Error The system could not make a connection to the database. Try Again at a later time. User name exists The User must use a different user name Bookmark back-up failed The user must close the Firefox database. 2. System Status 2.1 Work Accomplished The Development of the Bookmark Backup has been a great learning experience. I learned vast amounts of information regarding software development and program communication. Although the application is not 100% perfected the system sufficiently provides a working prototype. 2.2 Maintenance Concerns 2.2.1 Known Problems The system does have a few known issues at this time. Currently when the Firefox browser is open, the Firefox database cannot be opened. The Bookmark Backup cannot perform a backup when the Firefox browser is open. 2.2.2 Expected Evolution This system could evolve into a system that can backup bookmarks from various browsers and to various devices. Many systems currently provide similar services, but this system would allow more devices than others. It would be the only system currently to provide multiple browser support and multiple device support. Final Document for Bmark Backup Page 36 3. Appendix Java Code 3.1 createAccount package BmarkBackup.GUI; import import import import java.sql.Connection; java.sql.DriverManager; java.sql.ResultSet; java.sql.Statement; public class createPostgresTable { public static void createTable(String username){ try{ Statement st = null; Connection db = null; Class.forName("org.postgresql.Driver"); String url = "jdbc:postgresql://server8.cs.uofs.edu/"; String dbname = "freyr2"; String usernm = "freyr2"; String passwd = "stt414"; db = DriverManager.getConnection(url + dbname, usernm, passwd); System.out.println("Trying To Create Table\n"); st = db.createStatement(); String createString; createString = "create table " + username + "(url varchar(280) primary key NOT NULL, title varchar(180), android integer, java integer)"; System.out.println(createString); st.executeUpdate(createString); System.out.println("*********Table created!!!!******"); //CREATE TABLE Ray(url varchar(180) primary key NOT NULL, title varchar(180), android integer, java integer); } catch (Exception e) { System.err.println("Got an exception! "); System.err.println(e.getMessage()); } }} 3.2 createPostgresTable package BmarkBackup.GUI; import java.sql.Connection; import java.sql.DriverManager; Final Document for Bmark Backup Page 37 import java.sql.Statement; public class createPostgresTable { public static void createTable(String username){ try{ Statement st = null; Connection db = null; Class.forName("org.postgresql.Driver"); String url = "jdbc:postgresql://server8.cs.uofs.edu/"; String dbname = "freyr2"; String usernm = "freyr2"; String passwd = "stt414"; db = DriverManager.getConnection(url + dbname, usernm, passwd); System.out.println("Trying To Create Table\n"); st = db.createStatement(); String createString; createString = "create table " + username + "(url varchar(280) primary key NOT NULL, title varchar(180), android integer, java integer)"; System.out.println(createString); st.executeUpdate(createString); System.out.println("*********Table created!!!!******"); //CREATE TABLE Ray(url varchar(180) primary key NOT NULL, title varchar(180), android integer, java integer); } catch (Exception e) { System.err.println("Got an exception! "); System.err.println(e.getMessage()); } }} 3.3 Directory.java package BmarkBackup.GUI; import java.io.File; public class Directory { public static String sqliteDirectory(){ String cd = null; String eval; final String sysName = System.getProperty("os.name").toLowerCase(); // cd = System.getProperty("user.home") + "\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles"; if (sysName.contains("windows xp")){ cd = System.getProperty("user.home") + "\\Application Data\\Mozilla\\Firefox\\Profiles"; } else if (sysName.contains("windows 7")){ Final Document for Bmark Backup Page 38 cd = System.getProperty("user.home") + "\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles"; } File folder = new File(cd); File[] listOfFiles = folder.listFiles(); //System.out.println(listOfFiles[0] + "\\places.sqlite"); eval = listOfFiles[0] + "\\places.sqlite"; //System.out.println(eval); eval = eval.replace("\\", "\\\\"); System.out.println(eval); return eval; } } 3.4 FTP.java package BmarkBackup.GUI; import javax.swing.JFrame; import com.enterprisedt.net.ftp.FileTransferClient; public class FTP { // Right now connects and creates a directory based upon the User name FileTransferClient ftp = new FileTransferClient(); public void directoryCreateFTP(String username) { JFrame frame = null; try { // create client ftp = new FileTransferClient(); // set remote host ftp.setRemoteHost("server1.cs.scranton.edu"); ftp.setUserName("freyr2"); ftp.setPassword("R00132548"); // connect to the server ftp.connect(); System.out.println("connected"); ftp.changeDirectory("Project"); // need a way to show a directory exists // Create a directory for each user // Creates the directory only when the account is created. ftp.createDirectory(username); String[] string = ftp.directoryNameList(); for (int i = 0; i < string.length; i++) { System.out.println(string[i]); // Shut down client } ftp.disconnect(); } catch (Exception e) { e.printStackTrace(); Final Document for Bmark Backup Page 39 } } public void UploadDownloadFTP(String Flag) { // Flag passed as Download = Download // Flag pass as Upload = Upload try { ftp.setRemoteHost("server1.cs.scranton.edu"); ftp.setUserName("freyr2"); ftp.setPassword("R00132548"); ftp.connect(); if (Flag == "Download") { // get the bookmark file from the server, and place it on the // local machine } else { // Upload the bookmark file to the server } } catch (Exception e) { e.printStackTrace(); } } } 3.5 GlobalDataStore.java package BmarkBackup.GUI; public class GlobalDataStore { public static String globalNameData = ""; } 3.6 Home.java package BmarkBackup.GUI; import java.awt.BorderLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; Final Document for Bmark Backup Page 40 public class Home implements ActionListener{ JFrame frame; JButton backup, exit, switchuser; public Home(){ //LoginWindow login = new LoginWindow(); frame = new JFrame( "BookmarkBackup Login" ); JPanel top = new JPanel(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); top.setLayout( gbl ); c.insets = new Insets( 5, 7, 5, 7 ); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.gridwidth = 1; top.add( new JLabel( "Welcome, " + GlobalDataStore.globalNameData )); c.gridwidth = GridBagConstraints.REMAINDER; frame.getContentPane().add( top, BorderLayout.NORTH ); JPanel buttons = new JPanel(); backup = new JButton( "Backup Bmarks" ); backup.addActionListener( this ); buttons.add( backup ); exit = new JButton( "Exit" ); exit.addActionListener( this ); buttons.add( exit ); switchuser = new JButton("Switch User"); //top.add( new JLabel ( "Log in as new user: ")); switchuser.addActionListener( this ); buttons.add( switchuser ); frame.getContentPane().add( buttons, BorderLayout.SOUTH ); frame.pack(); frame.setVisible( true ); } @Override public void actionPerformed(ActionEvent e) { if(e.getSource() == switchuser) { frame.setVisible( false ); LoginWindow lin = new LoginWindow(); } if (e.getSource() == exit) { System.exit(0); } if( e.getSource() == backup ) Final Document for Bmark Backup { UpdateBookmarks.insertToPostgreSQL(); UpdateBookmarks.insertToFirefox(); // TODO Auto-generated catch block } }} 3.7 Login.java package BmarkBackup.GUI; import java.sql.*; import javax.swing.JFrame; import javax.swing.JOptionPane; public class Login { JFrame frame; Connection db; Statement st; String Uname; public Login() { } public boolean canLogin( String username, String password ){ try{ Class.forName("org.postgresql.Driver"); String url = "jdbc:postgresql://server8.cs.uofs.edu/"; String dbname = "freyr2"; String usernm = "freyr2"; String passwd = "stt414"; db = DriverManager.getConnection(url + dbname, usernm, passwd); System.out.println("connected\n"); JOptionPane.showMessageDialog( frame, "Connection was Successful!", "Success", JOptionPane.PLAIN_MESSAGE ); Page 41 Final Document for Bmark Backup Page 42 st = db.createStatement(); //If the Username and Password provided by the arguement are not in the Database, then the user cannot log on String sql = "SELECT Login_ID, Password " + "FROM Users " + "WHERE Login_ID = " + "'" + username + "'" + " AND Password = " + "'" + password + "'"; ResultSet rs = st.executeQuery(sql); System.out.println("Statement complete"); rs.next(); System.out.print(rs.getString(1)); System.out.println(rs.getString(2)); rs.close(); st.close(); db.close(); } catch (Exception e) { System.err.println("Got an exception! "); System.err.println(e.getMessage()); return false; } return true; } } 3.8 LoginWindow.java package BmarkBackup.GUI; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class LoginWindow implements ActionListener { JFrame frame; JTextField user; JPasswordField password; String username; JButton ok, cancel, newuser; public LoginWindow() { frame = new JFrame( "BookmarkBackup Login" ); JPanel top = new JPanel(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); top.setLayout( gbl ); Final Document for Bmark Backup c.insets = new Insets( 5, 7, 5, 7 ); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.gridwidth = 1; top.add( new JLabel( "Username: " )); user = new JTextField( 30 ); c.gridwidth = GridBagConstraints.REMAINDER; top.add( user, c ); c.gridwidth = 1; password = new JPasswordField( 30 ); c.gridwidth = GridBagConstraints.REMAINDER; top.add( new JLabel( "Password: ")); top.add( password, c ); c.gridwidth = 1; frame.getContentPane().add( top, BorderLayout.NORTH ); JPanel buttons = new JPanel(); ok = new JButton( "Send" ); ok.addActionListener( this ); buttons.add( ok ); cancel = new JButton( "Cancel" ); cancel.addActionListener( this ); buttons.add( cancel ); newuser = new JButton("New User"); //top.add( new JLabel ( "Log in as new user: ")); newuser.addActionListener( this ); buttons.add( newuser ); frame.getContentPane().add( buttons, BorderLayout.SOUTH ); frame.pack(); frame.setVisible( true ); } @Override public void actionPerformed( ActionEvent e ) { if(e.getSource() == newuser) { frame.setVisible( false ); NewUserLogin nul = new NewUserLogin(); } if (e.getSource() == cancel) { System.exit(0); } if( e.getSource() == ok ) { GlobalDataStore.globalNameData = user.getText(); Page 43 Final Document for Bmark Backup Page 44 Login login = new Login(); if( !login.canLogin( (user.getText()).trim().toLowerCase(), new String( password.getPassword()))) { JOptionPane.showMessageDialog( frame, "There was a problem logging you into BookmarkBackup", "Error", JOptionPane.ERROR_MESSAGE ); } else { frame.setVisible( false ); new Home(); } } } public String getUsername(){ return username; } public static void main( String[] args ) { LoginWindow lw = new LoginWindow(); } } 3.9 NewUserLogin.java package BmarkBackup.GUI; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class NewUserLogin implements ActionListener { JFrame frame; JButton next, cancel, back, finish; CardLayout cardlayout; JTextField username; JPasswordField password1, password2; String panels[] = { "first" }; public NewUserLogin() { frame = new JFrame( "New User Login" ); cardlayout = new CardLayout(); frame.getContentPane().setLayout( cardlayout ); JPanel first = createfirstpanel(); frame.getContentPane().add( first, panels[0] ); frame.pack(); frame.setVisible( true ); } public JPanel createfirstpanel() Final Document for Bmark Backup { JPanel top = new JPanel(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); top.setLayout( gbl ); c.insets = new Insets( 5, 7, 5, 7 ); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.gridwidth = GridBagConstraints.REMAINDER; top.add( new JLabel( "Enter and username and password" ), c); c.gridwidth = 1; top.add( new JLabel( "Username: " )); username = new JTextField( 30 ); c.gridwidth = GridBagConstraints.REMAINDER; top.add( username, c ); c.gridwidth = 1; top.add( new JLabel( "Password: " )); password1 = new JPasswordField( 30 ); c.gridwidth = GridBagConstraints.REMAINDER; top.add( password1, c ); c.gridwidth = 1; top.add( new JLabel( "Confirm Password: " )); password2 = new JPasswordField( 30 ); c.gridwidth = GridBagConstraints.REMAINDER; top.add( password2, c ); JPanel buttons = new JPanel(); back = new JButton( "Back" ); back.addActionListener( this ); buttons.add( back ); finish = new JButton( "Finish" ); finish.addActionListener( this ); buttons.add( finish ); c.gridwidth = GridBagConstraints.REMAINDER; top.add( buttons, c ); return top; } public void actionPerformed( ActionEvent e ) { if (e.getSource() == back){ frame.setVisible( false ); new LoginWindow(); } if (e.getSource() == finish){ new createAccount(username.getText(), password1.getPassword()); if(createAccount.checkLogin() == true){ //Sqlite.createSQLTable(); //createSQLBookmarktables Here // ************************** Page 45 Final Document for Bmark Backup Page 46 // ************************** frame.setVisible( false ); new LoginWindow(); createPostgresTable.createTable(username.getText().toLowerCase()); //Add user name and password to database JOptionPane.showMessageDialog( frame, "Success!", "Success", JOptionPane.PLAIN_MESSAGE ); }else{ JOptionPane.showMessageDialog( frame, "Account Name Already Taken!", "Failure", JOptionPane.PLAIN_MESSAGE ); } } { //create regex to set the password a certain length and username a certain length (no sql injection) String pass1 = new String( password1.getPassword() ); String pass2 = new String( password2.getPassword() ); if( !pass1.equals( pass2 )) { JOptionPane.showMessageDialog( frame, "The passwords did not match", "Error", JOptionPane.ERROR_MESSAGE ); return; } } } public boolean createUser() { return true; } public static void main( String[] args ) { NewUserLogin nul = new NewUserLogin(); } } 3.10 Sqlite.java package BmarkBackup.GUI; import import import import import java.sql.Connection; java.sql.DriverManager; java.sql.ResultSet; java.sql.SQLException; java.sql.Statement; public class Sqlite { Final Document for Bmark Backup Page 47 public static void ConnectSQLite() { //System.out.println("This is full directory" + getFullDirectory()); Connection conn = null; //Connection conn1 = null; ResultSet rs = null; //ResultSet rs1 = null; Statement statement = null; //Statement statement1 = null; InsertBookmark.Insert(); try { Class.forName("org.sqlite.JDBC"); conn = DriverManager.getConnection ("jdbc:sqlite:C:\\Documents and Settings\\Ray\\Application Data\\Mozilla\\Firefox\\Profiles\\i907onda.default\\places.sqlite"); System.out.println("Connected to SQLITE"); statement = conn.createStatement(); rs = statement .executeQuery("SELECT moz_places.url, moz_bookmarks.id, moz_bookmarks.title FROM moz_places, moz_bookmarks WHERE moz_places.id = moz_bookmarks.fk AND moz_bookmarks.parent = 2 AND moz_places.id > 10;"); //statement1 = conn.createStatement(); //rs1 = statement1.executeQuery("select MAX(id) as 'Max' FROM moz_bookmarks;"); //System.out.println("Max id = " + rs.getString("Max")); //rs1.close(); while (rs.next()) { //System.out.println("places id = " + rs.getString("moz_places.id")); System.out.println("id = " + rs.getString("id")); System.out.println("url = "+ rs.getString("url")); System.out.println("title = " + rs.getString("title")); } } catch (Exception e) { e.printStackTrace(); } try { rs.close(); statement.close(); conn.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /*final String useName = System.getProperty("user.name"); final static String sysName = System.getProperty("os.name").toLowerCase(); Final Document for Bmark Backup Page 48 public static String getFoxDirectory (String currentDirectory){ String profileString; String[] File = null; //System.out.println(currentDirectory); File folder = new File(currentDirectory); File[] listOfFiles = folder.listFiles(); System.out.println("This is the list of files " + listOfFiles[0]); profileString = listOfFiles[0].getName(); //System.out.println(profileString); for(int i = 0; i < profileString.length(); i++){ System.out.println("in for loop"); if(profileString.charAt(i) == '\\'){ System.out.println("in if statement"); StringBuffer sb1 = new StringBuffer(profileString); sb1.insert(i-1, "\\\\").toString(); System.out.println(profileString); } } System.out.println(profileString); currentDirectory = profileString; System.out.println(currentDirectory); return currentDirectory; } public static String getFullDirectory () { String cd = null; String fullDirectory = null; if (sysName.contains("windows xp")){ cd = System.getProperty("user.home") + "\\Local Settings\\Application Data\\Mozilla\\Firefox\\Profiles"; fullDirectory = getFoxDirectory(cd); } else if (sysName.contains("windows 7")){ cd = System.getProperty("user.home") + "\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles"; System.out.println(cd); fullDirectory = getFoxDirectory(cd); // else if (sysName.contains("linux")) /* ... */ // else if (sysName.contains("solaris")) /* ... */ //else /* ... */ // // // } return fullDirectory; } /* public static void createSQLTable(){ Connection db; Statement st; Final Document for Bmark Backup Page 49 try{ Class.forName("org.postgresql.Driver"); String url = "jdbc:postgresql://server8.cs.uofs.edu/"; String dbname = "freyr2"; String usernm = "freyr2"; String passwd = "stt414"; db = DriverManager.getConnection(url + dbname, usernm, passwd); System.out.println("connected\n"); st = db.createStatement(); // String sql = "CREATE TABLE Person( // "Login_ID varchar(20) primary key NOT NULL", // Password varchar(20) NOT NULL, // FName varchar(15) NOT NULL, // LName varchar(15) NOT NULL, // DOB date // ); String sql = "CREATE TABLE '" + GlobalDataStore.globalNameData + "'bookmark_string VARCHAR(254) primary key NOT NULL, bookmark_title VARCHAR(50), keyword_id VARCHAR(25)"; //Create Table for bookmarks to be inserted to. //String sql = "INSERT INTO Users VALUES('" + username + "', '" + password + "')"; st.executeUpdate(sql); // ResultSet rs = st.executeQuery(sql); System.out.println("Statement complete"); //rs.close(); st.close(); db.close(); } catch (Exception e) { System.err.println("Got an exception! "); System.err.println(e.getMessage()); }}*/ } 3.11 UpdateBookmarks.java package BmarkBackup.GUI; import import import import import import java.sql.Connection; java.sql.DriverManager; java.sql.PreparedStatement; java.sql.ResultSet; java.sql.SQLException; java.sql.Statement; Final Document for Bmark Backup Page 50 import javax.swing.JFrame; import javax.swing.JOptionPane; @SuppressWarnings("unused") public class UpdateBookmarks { //static String path = null; static String urlArray[]; static String titleArray[]; JFrame frame; static Connection db; static Statement st; String Uname; public static void insertToPostgreSQL(){ ResultSet rs = null; ResultSet count = null; Statement statement = null; Connection conn = null; int NumOfBmarks = 0; String path; path = Directory.sqliteDirectory(); try { Class.forName("org.sqlite.JDBC"); //conn = DriverManager.getConnection //("jdbc:sqlite:C:\\Users\\Ray\\AppData\\Roaming\\Mozilla\\Firefox\\Profil es\\6osrk6he.default\\places.sqlite"); conn = DriverManager.getConnection("jdbc:sqlite:" + path); System.out.println("Connected to SQLITE"); statement = conn.createStatement(); count = statement.executeQuery("select count(*) AS rowcount FROM moz_places, moz_bookmarks WHERE moz_places.id = moz_bookmarks.fk AND moz_bookmarks.parent = 2 AND moz_places.id > 50 AND moz_bookmarks.dateAdded > 0 AND moz_places.url != '' AND moz_places.hidden != 1;"); NumOfBmarks = count.getInt("rowcount"); rs = statement .executeQuery("SELECT moz_places.url, moz_bookmarks.id, moz_bookmarks.title FROM moz_places, moz_bookmarks WHERE moz_places.id = moz_bookmarks.fk AND moz_bookmarks.parent = 2 AND moz_places.id > 50 AND moz_bookmarks.dateAdded > 0 AND moz_places.url != '' AND moz_places.hidden != 1;"); int i = 0; System.out.println("NUMOFBMARKS: " + NumOfBmarks); String [] urlArray = new String[NumOfBmarks]; String[] titleArray = new String[NumOfBmarks]; while (rs.next()) { //System.out.println("places id = " + rs.getString("moz_places.id")); //System.out.println("id = " + rs.getString("id")); Final Document for Bmark Backup Page 51 //System.out.println("url = "+ rs.getString("url")); //System.out.println("title = " + rs.getString("title")); urlArray[i] = rs.getString("url"); titleArray[i] = rs.getString("title"); System.out.println("urlArray = " + (urlArray[i])); System.out.println("titleArray = " +(titleArray[i])); System.out.println(i); i++; } System.out.println("Statement complete"); //rs.close(); statement.close(); conn.close(); //Make PostGres Connection and place array values in. try{ Statement st = null; Connection db = null; Class.forName("org.postgresql.Driver"); String url = "jdbc:postgresql://server8.cs.uofs.edu/"; String dbname = "freyr2"; String usernm = "freyr2"; String passwd = "stt414"; db = DriverManager.getConnection(url + dbname, usernm, passwd); System.out.println("connected to PostGresql User Bookmark Table\n"); st = db.createStatement(); for(int x = 0; x < NumOfBmarks; x++){ System.out.println("****************************************************** *************************"); System.out.println(NumOfBmarks); System.out.println(x); System.out.println(GlobalDataStore.globalNameData.toLowerCase()); System.out.println("urlArray = " + (urlArray[x])); System.out.println("titleArray = " +(titleArray[x])); String sqlD = "DELETE FROM " + GlobalDataStore.globalNameData.toLowerCase() + " WHERE url = '" + urlArray[x] + "' AND title = '" + titleArray[x] + "'"; st.executeUpdate(sqlD); String sql = "INSERT INTO " + GlobalDataStore.globalNameData.toLowerCase() + " VALUES('" + urlArray[x] + "', '" + titleArray[x] + "', 0, 1)"; //String sql = "INSERT INTO ray VALUES('" + urlArray[x] + "', '" + titleArray[x] + "', 0, 1)"; st.executeUpdate(sql); } System.out.println("POSTGRES INSERT COMPLETE"); Final Document for Bmark Backup Page 52 //rs.close(); st.close(); db.close(); } catch (Exception e) { System.err.println("Got an exception! "); System.err.println(e.getMessage()); } } catch (Exception e) { e.printStackTrace(); } try { rs.close(); statement.close(); conn.close(); } catch (SQLException e) { e.printStackTrace(); }} // End PostgreSQL public static void insertToFirefox() { System.out.println("Insert to Firefox method"); Connection conn = null; int maxPlacesID; int maxBookmarkID; ResultSet rs = null; ResultSet count = null; Statement statement = null; Statement statement1 = null; ResultSet urlSet = null; ResultSet titleSet = null; int NumOfBmarks = 0; int j = 0; String path; path = Directory.sqliteDirectory(); int maxPosition; PreparedStatement pStatement = null; final String SQL_BINSERT = "INSERT OR + " VALUES(?, ?, ?, ?, ?, ?, ?, final String SQL_PINSERT = "INSERT OR + " VALUES(?, ?, ?, ?, ?, ?, ?, IGNORE INTO moz_bookmarks" ?, ?, ?)"; IGNORE INTO moz_places" ?, ?, ?)"; //Make PostgreSQL connection and Fill arrays try{ Class.forName("org.postgresql.Driver"); Final Document for Bmark Backup Page 53 String url = "jdbc:postgresql://server8.cs.uofs.edu/"; String dbname = "freyr2"; String usernm = "freyr2"; String passwd = "stt414"; db = DriverManager.getConnection(url + dbname, usernm, passwd); statement = db.createStatement(); statement1 = db.createStatement(); System.out.println("connected to PostGresql User Bookmark Table\n"); count = statement.executeQuery("select count(*) AS rowcount FROM " + GlobalDataStore.globalNameData + ";"); count.next(); System.out.println("statement complete"); NumOfBmarks = count.getInt("rowcount"); System.out.println(NumOfBmarks); String [] urlArray = new String[NumOfBmarks]; String[] titleArray = new String[NumOfBmarks]; urlSet = statement .executeQuery("SELECT url FROM " + GlobalDataStore.globalNameData.toLowerCase()); titleSet = statement1 .executeQuery("SELECT title FROM " + GlobalDataStore.globalNameData.toLowerCase()); System.out.println("Result set gathered"); while (urlSet.next()) { titleSet.next(); System.out.println("in loop"); //System.out.println("places id = " + rs.getString("moz_places.id")); //System.out.println("id = " + rs.getString("id")); System.out.println("url = "+ urlSet.getString("url")); System.out.println("title = " + titleSet.getString("title")); urlArray[j] = urlSet.getString("url"); titleArray[j] = titleSet.getString("title"); j++; System.out.println(j); System.out.println(NumOfBmarks); } System.out.println("close"); urlSet.close(); titleSet.close(); //st.close(); //db.close(); Final Document for Bmark Backup Page 54 // End Postgres************************************************************************ ************************ try { Class.forName("org.sqlite.JDBC"); conn = DriverManager.getConnection ("jdbc:sqlite:" + path); System.out.println("Connected to SQLITE Insert"); statement = conn.createStatement(); System.out.println("connected"); count = statement .executeQuery("SELECT MAX(id) as MaxID FROM moz_bookmarks;"); maxBookmarkID = count.getInt("MaxID") + 1; System.out.println("Max id = " + count.getInt("MaxID")); count = statement .executeQuery("select MAX(id) as MaxPlaces FROM moz_places;"); maxPlacesID = count.getInt("MaxPlaces") + 1; System.out.println("Max places id = " + count.getInt("MaxPlaces")); count = statement .executeQuery("select MAX(position) as MaxPosition FROM moz_bookmarks;"); maxPosition = count.getInt("MaxPosition") + 1; System.out.println("Max position = " + count.getInt("MaxPosition")); for(int i = 0; i < urlArray.length ; i++){ System.out.println("in loop"); pStatement = conn.prepareStatement(SQL_BINSERT); System.out.println("create B-insert"); pStatement.setInt(1, maxBookmarkID); pStatement.setString(2, "1"); pStatement.setInt(3, maxPlacesID); pStatement.setString(4, "2"); pStatement.setInt(5, maxPosition); System.out.println("all strings set B-insert"); pStatement.setString(6, titleArray[i]); pStatement.setString(7, ""); pStatement.setString(8, ""); pStatement.setString(9, "1"); pStatement.setString(10, ""); pStatement.executeUpdate(); pStatement = conn.prepareStatement(SQL_PINSERT); pStatement.setInt(1, maxPlacesID); pStatement.setString(2, urlArray[i]); pStatement.setString(3, titleArray[i]); pStatement.setString(4, ""); Final Document for Bmark Backup Page 55 pStatement.setString(5, ""); pStatement.setInt(6, 0); pStatement.setInt(7, 0); pStatement.setInt(8, 0); pStatement.setInt(9, 0); pStatement.setString(10, ""); pStatement.executeUpdate(); maxBookmarkID++; maxPlacesID++; maxPosition++; System.out.println(i); System.out.println( urlArray[i]); System.out.println( titleArray[i]); } System.out.println("finished"); conn.close(); } catch (Exception e) { e.printStackTrace(); } try { //rs.close(); //statement.close(); conn.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (Exception e) { System.err.println("Got an exception! "); System.err.println(e.getMessage()); e.printStackTrace(); } }}