CS636 Homework 3 Page Flow for pizza, API Design, Java Exceptions, Music Project

1. Web servers. Everyone knows that each website has a web server. This is the web server running on port 80, the default port for web service, on some host (computer) at that site, but in fact a web server can run on any port. Each Internet host has a large set of ports, and each port can be used by a server (not just a web server, also an email server, ssh server, etc.)

a. Our students may post material on the web by placing it in a public_html subdirectory of their home directory. Put an test.html there to say hello. To see it, browse to http:// www.cs.umb.edu:/~username/test.html. Add a link to your test.html that links to our class web page at www.cs.umb.edu/cs636.  Try it out, i.e., browse to your test.html and then click the link. What server served your page (specifically, what is the server's hostname)?  Report on success or problems, and leave the test.html in your public_html directory.

b. Also put your HTML form file from homework 2 in your public_html as form.html and browse to it. We still can't pick up the submitted user input from the form, but you should be able to see the form itself. Report your URL for accessing this page.

c. For problem 2, I have a tomcat web server running on port 9002. Unlike the departmental web server, this web server can execute Java code. It is hosting pizza3, the web-UI version of the pizza project, with home page at pe07.cs.umb.edu:9002/welcome.html.  Since this port is blocked by the firewall, you can't access it from home without a tunnel. For now, access this site from pe07 itself using lynx, the line-oriented browser available on pe07 (and many other Linux systems). On pe07, try lynx localhost:9002/welcome.html, (or pe07.cs.umb.edu:9002/welcome.html) accept the cookie, and see the text representation of the home page depicted below for problem 2. You can move around the page with the up and down arrows, and follow a link with the enter key. Even order a pizza. Use the q command to exit from lynx. Add to your test.html in ~/public_html a link to the pizza3 welcome page served by tomcat showing as pizza3, and use lynx on pe07 to display it, and follow the link. Also try it using lynx on users.cs.umb.edu (also inside the firewall). Report success or problems, and the final text of your test.html. In problem 2, you will be accessing this tomcat website from home using a tunnel and an ordinary browser.

2. Page flows--UI analysis. Read about the Pizza Project, and the discussion in classes 4-7. This is the running example for the course, and is available as a client-server app "pizza1". The last version, "pizza3", is the final web app. The deployed version of pizza3 is now available as at http://pe07.cs.umb.edu:9002, but we can access this directly only from inside the cs.umb.edu network. To access it from home, add a tunnel from local port 9002 to this port 9002 on pe07.cs.umb.edu, following the pattern of the Oracle tunnel.

Once your new tunnel is set up, browse to localhost:9002/welcome.html and you should see pizza shop home page: (the port in this picture is 11600, but I'm actually using 9002 this term).

pizza3 home page

BTW, the icon with the check mark on it, to the right of the browser address bar, is the Chrome extension "Check My Links", very handy way to check a webpage for broken links.

a. For each page you reach starting from the "Home”, do the following. Start from the top link, so that the result is easy to grade.
  i. Record the URL displayed by your browser. Note that they all start with http://localhost:9002/, so you can just record the part after this start.
  ii. Record how you got the next page to show from this page: click on a link?  click on a button? Anything else? Also, don't use the links you see on the page shown above (Home, Admin Service, etc.) until you've exhausted more local links, so your exploration goes: everything accessible from "Admin Service", everything accessible from "Student Service", etc. Note: For this exercise, don't use the "back" button of  your browser. A well-designed dynamic web site provides enough links so that the user can get around comfortably without using the back button.  Handling the back button (and forward button) properly in a dynamic web site is an advanced topic.
b. Draw a graph of the pages you navigated, with arrows showing use of links or buttons to get from one page to another. There are 10 pages in this pizza app: Home, Admin Home, Manage Toppings, Manage Sizes, Manage Orders, Manage Days, Student Welcome, Pizza Order Form, List Variables, and Logout, so there should be 10 nodes in your graph, with arrows between them as appropriate. You don't need to show links that express that "Home" is accessible from all pages, and similarly other every-page links, just the links that show the user navigation paths.

3. API Design. The service API defines the actions that the application can do. See class 8 for discussion of how we want each method in the service API to be self-contained in the sense that all the domain data needed for the action of the method is provided in the method's arguments.

a. Design a method header (no implementation) to provide a new action for the pizza project to report on (i.e. provide data on) all toppings currently in use in PREPARING orders (i.e., in the oven). If a topping is in use by more than one order, that should be clear from the result, either by a count or by repeated items returned. What source file should have this method?

b. Design a method header (no implementation) to provide a new action for the pizza project allowing a student to change the room number on all their orders that are currently in PREPARING or BAKED status.

c. The method you designed in b. clearly requires new support in the DAO API, since the "real" orders reside in the database. Design a new method (no implementation) for PizzaOrderDAO to do this.

4. Java Exceptions. Review exceptions in your Java text. Look at the exceptions in pizza1:

a. If the SQL in AdminDAO.advanceDay throws a SQLException, where is it caught?    What happens to that exception next?  Where is the ensuing thrown exception caught?  What is printed out in this case?

b. Make the scenario of part a happen by changing current_day to current_dayx in the SQL update statement.  Run SystemTest on all three databases (runOnOracle SystemTest, etc.) and record the exception report from each of the three.  You will see that the databases report errors with different messages and sometimes different information included in the message, so sometimes it’s worth while to run on more than one database to try to figure out what’s wrong.

5. Music1-setup.

a. Install the supplied music1-setup project and copy it to music1, for further development.

b. Use music1-setup’s database directory's utilities to load all three databases. Report on what commands you used and success or problems. 

c. Use music1-setup’s pom.xml to build the project and then run the SystemTest on all three databases. Report your commands and success or problems. Note that the output from SystemTest will be skeletal, with not much content yet, but it shouldn't crash.

d. Set up an eclipse projects for music1-setup and music1, and compare music1-setup/pom.xml to pizza1/pom.xml, by selecting one in Project Explorer, then hold down control and select the other, then right-click and Compare With>Each Other.  In your paper, describe the differences.  Note that this technique will be helpful to track your changes from music1-setup to music1. You can even compare complete projects with eclipse (but not Netbeans).

6. Music DB SQL.  Write queries as follows and show the queries and their output (after the inserts of d. are done) in your hw paper. Each part except d should be answered with one SQL query. You can use eclipse Database Development tools to try out the queries, or write a .sql file and use runH2Script or  runMysqlScript, etc. Or if you want, login to pe07 and use the sqlplus tool or the mysql program (but there is no such interactive tool for H2, but you could make up a file of queries and use runH2Script). Note that many tables are empty after using createdb.sql. You can load some sample rows into table downloads with the provided load_downloads*.sql.

For queries, report the SQL and results, if any.

a. Find all users (user_id's) with email addresses ending with "gmail.com".

b. Find all lineitems of invoice 2 and list their product id and quantity.

c. List all the downloads (product id, filename, and date) for the user with email andi@murach.com.

d. There are no invoices in the tables in the original load, making it hard to test queries involving invoices.  Fix this problem by inserting an invoice with id =2 (dated 9/2/10, for user 2) with lineitems for products with product codes pf01 and jr01.  Show the three insert statements in your hw paper.

e. List all invoice ids and invoice dates for the user with email andi@murach.com.

f. Find all product ids purchased by the user with email andi@murach.com (i.e., find the lineitems)

g. Find all products (product codes) where a download preceded a purchase. Avoid duplicates in the result.

h. Find the downloaded file (.mp3 filename) that was downloaded the highest number of times.

i. Report on the number of downloads (total over all files for that CD) by CD product code, since August 1, 2009.