You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2008/06/12 00:14:57 UTC

svn commit: r666872 - in /geronimo/samples/trunk/samples/inventory: inventory-jetty/src/main/plan/ inventory-tomcat/ inventory-tomcat/src/main/plan/ inventory-war/src/main/java/org/apache/geronimo/samples/inventory/dao/ inventory-war/src/main/java/org/...

Author: djencks
Date: Wed Jun 11 15:14:54 2008
New Revision: 666872

URL: http://svn.apache.org/viewvc?rev=666872&view=rev
Log:
general code cleanup, add back db script

Added:
    geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/exception/ItemException.java   (with props)
    geronimo/samples/trunk/samples/inventory/inventory-war/src/main/resources/
    geronimo/samples/trunk/samples/inventory/inventory-war/src/main/resources/InventoryDB.sql
      - copied, changed from r656346, geronimo/samples/trunk/samples/inventory/inventory-ear/src/main/resources/InventoryDB.sql
Removed:
    geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/util/
    geronimo/samples/trunk/samples/inventory/inventory-war/src/main/webapp/WEB-INF/geronimo-web.xml
Modified:
    geronimo/samples/trunk/samples/inventory/inventory-jetty/src/main/plan/plan.xml
    geronimo/samples/trunk/samples/inventory/inventory-tomcat/pom.xml
    geronimo/samples/trunk/samples/inventory/inventory-tomcat/src/main/plan/plan.xml
    geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/dao/ItemDAO.java
    geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/services/InventoryManager.java
    geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/AddItemServlet.java
    geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/IssueingServlet.java
    geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/ReceivingServlet.java
    geronimo/samples/trunk/samples/inventory/inventory-war/src/main/webapp/jsp/issue.jsp
    geronimo/samples/trunk/samples/inventory/inventory-war/src/main/webapp/jsp/recv.jsp
    geronimo/samples/trunk/samples/inventory/inventory-war/src/main/webapp/welcome.jsp

Modified: geronimo/samples/trunk/samples/inventory/inventory-jetty/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/inventory/inventory-jetty/src/main/plan/plan.xml?rev=666872&r1=666871&r2=666872&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/inventory/inventory-jetty/src/main/plan/plan.xml (original)
+++ geronimo/samples/trunk/samples/inventory/inventory-jetty/src/main/plan/plan.xml Wed Jun 11 15:14:54 2008
@@ -28,4 +28,11 @@
         <ref-name>jdbc/InventoryDS</ref-name>
         <resource-link>SampleTxDatasource</resource-link>
     </resource-ref>
+    <gbean name="DBInitialization" class="org.apache.geronimo.connector.DatabaseInitializationGBean">
+        <attribute name="testSQL">select * from item</attribute>
+        <attribute name="path">InventoryDB.sql</attribute>
+        <reference name="DataSource">
+            <name>SampleTxDatasource</name>
+        </reference>
+    </gbean>
 </web-app>
\ No newline at end of file

Modified: geronimo/samples/trunk/samples/inventory/inventory-tomcat/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/inventory/inventory-tomcat/pom.xml?rev=666872&r1=666871&r2=666872&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/inventory/inventory-tomcat/pom.xml (original)
+++ geronimo/samples/trunk/samples/inventory/inventory-tomcat/pom.xml Wed Jun 11 15:14:54 2008
@@ -113,23 +113,23 @@
                         <includeVersion>true</includeVersion>
                     </useMavenDependencies>
                     <category>Sample</category>
-                    <instance>
-                        <plugin-artifact>
-                            <prerequisite>
-                                <id>
-                                    <groupId>org.apache.geronimo.configs</groupId>
-                                    <artifactId>tomcat6</artifactId>
-                                </id>
-                                <resource-type>Web Container</resource-type>
-                                <description>
-                                    This version of the application works with the Geronimo/Tomcat distribution.
-                                    It is not intended to run in the Geronimo/Jetty distribution.
-                                    There is a separate version of the application that works with Jetty.
-                                    Please install the version appropriate to your Geronimo distribution.
-                                </description>
-                            </prerequisite>
-                        </plugin-artifact>
-                    </instance>
+                    <!--<instance>-->
+                        <!--<plugin-artifact>-->
+                            <!--<prerequisite>-->
+                                <!--<id>-->
+                                    <!--<groupId>org.apache.geronimo.configs</groupId>-->
+                                    <!--<artifactId>tomcat6</artifactId>-->
+                                <!--</id>-->
+                                <!--<resource-type>Web Container</resource-type>-->
+                                <!--<description>-->
+                                    <!--This version of the application works with the Geronimo/Tomcat distribution.-->
+                                    <!--It is not intended to run in the Geronimo/Jetty distribution.-->
+                                    <!--There is a separate version of the application that works with Jetty.-->
+                                    <!--Please install the version appropriate to your Geronimo distribution.-->
+                                <!--</description>-->
+                            <!--</prerequisite>-->
+                        <!--</plugin-artifact>-->
+                    <!--</instance>-->
                 </configuration>
             </plugin>
         </plugins>
@@ -138,9 +138,9 @@
     <profiles>
         <profile>
             <id>it</id>
-            <properties>
-                <it-server>tomcat</it-server>
-            </properties>
+            <!--<properties>-->
+                <!--<it-server>tomcat</it-server>-->
+            <!--</properties>-->
             <build>
                 <plugins>
                     <plugin>

Modified: geronimo/samples/trunk/samples/inventory/inventory-tomcat/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/inventory/inventory-tomcat/src/main/plan/plan.xml?rev=666872&r1=666871&r2=666872&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/inventory/inventory-tomcat/src/main/plan/plan.xml (original)
+++ geronimo/samples/trunk/samples/inventory/inventory-tomcat/src/main/plan/plan.xml Wed Jun 11 15:14:54 2008
@@ -28,4 +28,11 @@
         <ref-name>jdbc/InventoryDS</ref-name>
         <resource-link>SampleTxDatasource</resource-link>
     </resource-ref>
+    <gbean name="DBInitialization" class="org.apache.geronimo.connector.DatabaseInitializationGBean">
+        <attribute name="testSQL">select * from item</attribute>
+        <attribute name="path">InventoryDB.sql</attribute>
+        <reference name="DataSource">
+            <name>SampleTxDatasource</name>
+        </reference>
+    </gbean>
 </web-app>
\ No newline at end of file

Modified: geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/dao/ItemDAO.java
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/dao/ItemDAO.java?rev=666872&r1=666871&r2=666872&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/dao/ItemDAO.java (original)
+++ geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/dao/ItemDAO.java Wed Jun 11 15:14:54 2008
@@ -24,156 +24,176 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+
 import org.apache.geronimo.samples.inventory.Item;
-import org.apache.geronimo.samples.inventory.util.DBManager;
+import org.apache.geronimo.samples.inventory.exception.ItemException;
 
 
 public class ItemDAO {
 
-    public List getItems() {
-        ArrayList items = new ArrayList();
+    private final DataSource ds;
 
-        Connection con = DBManager.getConnection();
+    public ItemDAO() throws ItemException {
         try {
+            InitialContext ctx = new InitialContext();
+            ds = (DataSource) ctx.lookup("java:comp/env/jdbc/InventoryDS");
+        } catch (NamingException e) {
+            throw new ItemException(e);
+        }
+    }
 
-            PreparedStatement pStmt = con.prepareStatement("SELECT i.item_id as item_id, i.item_name as item_name, i.description as description, im.quantity as quantity FROM item i, item_master im WHERE im.item_id = i.item_id");
-            ResultSet rs = pStmt.executeQuery();
-            int j = 0;
-            while (rs.next()) {
-                ArrayList item = new ArrayList();
-
-                String itemId = rs.getString("item_id");
-                String itemName = rs.getString("item_name");
-                String description = rs.getString("description");
-                int quantity = rs.getInt("quantity");
-
-                item.add(0, itemId);
-                item.add(1, itemName);
-                item.add(2, description);
-                item.add(3, quantity + "");
+    public List<Item> getItems() throws ItemException {
+        ArrayList<Item> items = new ArrayList<Item>();
 
-                items.add(j, item);
-                j++;
+        try {
+            Connection con = ds.getConnection();
+            try {
 
-            }
-        } catch (SQLException e) {
-            e.printStackTrace();
-        } finally {
-            if (con != null) {
+                PreparedStatement pStmt = con.prepareStatement("SELECT i.item_id as item_id, i.item_name as item_name, i.description as description, im.quantity as quantity FROM item i, item_master im WHERE im.item_id = i.item_id");
                 try {
-                    con.close();
-                } catch (SQLException e) {
-                    e.printStackTrace();
+                    ResultSet rs = pStmt.executeQuery();
+                    try {
+                        while (rs.next()) {
+                            Item item = new Item();
+
+                            item.setItemNo(rs.getString("item_id"));
+                            item.setItemName(rs.getString("item_name"));
+                            item.setDescription(rs.getString("description"));
+                            item.setQuantity(rs.getInt("quantity"));
+
+
+                            items.add(item);
+                        }
+                    } finally {
+                        rs.close();
+                    }
+                } finally {
+                    pStmt.close();
                 }
+
+            } finally {
+                con.close();
             }
+        } catch (SQLException e) {
+            throw new ItemException(e);
         }
 
         return items;
     }
 
-    public int getQOH(String itemNo) {
+    public int getQOH(String itemNo) throws ItemException {
 
         int qoh = 0;
-        Connection con = DBManager.getConnection();
         try {
+            Connection con = ds.getConnection();
+            try {
 
-            PreparedStatement pStmt = con.prepareStatement("SELECT quantity FROM item_master WHERE item_id =? ");
-            pStmt.setString(1, itemNo);
-
-            ResultSet rs = pStmt.executeQuery();
-            while (rs.next()) {
-                qoh = rs.getInt("quantity");
-            }
-        } catch (SQLException e) {
-            e.printStackTrace();
-        } finally {
-            if (con != null) {
+                PreparedStatement pStmt = con.prepareStatement("SELECT quantity FROM item_master WHERE item_id =? ");
                 try {
-                    con.close();
-                } catch (SQLException e) {
-                    e.printStackTrace();
+                    pStmt.setString(1, itemNo);
+
+                    ResultSet rs = pStmt.executeQuery();
+                    try {
+                        if (rs.next()) {
+                            qoh = rs.getInt("quantity");
+                        }
+                    } finally {
+                        rs.close();
+                    }
+                } finally {
+                    pStmt.close();
                 }
+            } finally {
+                con.close();
             }
+        } catch (SQLException e) {
+            throw new ItemException(e);
         }
         return qoh;
     }
 
-    public boolean isItemIdExists(String itemNo) {
+    public boolean isItemIdExists(String itemNo) throws ItemException {
         boolean isExists = false;
-        Connection con = DBManager.getConnection();
         try {
+            Connection con = ds.getConnection();
+            try {
 
-            PreparedStatement pStmt = con.prepareStatement("SELECT item_id FROM item WHERE item_id =? ");
-            pStmt.setString(1, itemNo);
-
-            ResultSet rs = pStmt.executeQuery();
-            if (rs.next()) {
-                isExists = true;
-            }
-        } catch (SQLException e) {
-            e.printStackTrace();
-        } finally {
-            if (con != null) {
+                PreparedStatement pStmt = con.prepareStatement("SELECT item_id FROM item WHERE item_id =? ");
                 try {
-                    con.close();
-                } catch (SQLException e) {
-                    e.printStackTrace();
+                    pStmt.setString(1, itemNo);
+
+                    ResultSet rs = pStmt.executeQuery();
+                    try {
+                        if (rs.next()) {
+                            isExists = true;
+                        }
+                    } finally {
+                        rs.close();
+                    }
+                } finally {
+                    pStmt.close();
                 }
+            } finally {
+                con.close();
             }
+        } catch (SQLException e) {
+            throw new ItemException(e);
         }
         return isExists;
     }
 
-    public void updateQOH(String itemNo, int qoh) {
-        Connection con = DBManager.getConnection();
+    public void updateQOH(String itemNo, int qoh) throws ItemException {
         try {
+            Connection con = ds.getConnection();
+            try {
 
-            PreparedStatement pStmt = con.prepareStatement("UPDATE item_master SET quantity=? WHERE item_id=?");
-            pStmt.setInt(1, qoh);
-            pStmt.setString(2, itemNo);
-
-            pStmt.executeUpdate();
-        } catch (SQLException e) {
-            e.printStackTrace();
-        } finally {
-            if (con != null) {
+                PreparedStatement pStmt = con.prepareStatement("UPDATE item_master SET quantity=? WHERE item_id=?");
                 try {
-                    con.close();
-                } catch (SQLException e) {
-                    e.printStackTrace();
+                    pStmt.setInt(1, qoh);
+                    pStmt.setString(2, itemNo);
+
+                    pStmt.executeUpdate();
+                } finally {
+                    pStmt.close();
                 }
+            } finally {
+                con.close();
             }
+        } catch (SQLException e) {
+            throw new ItemException(e);
         }
-
     }
 
-    public void addItem(Item item) {
-        Connection con = DBManager.getConnection();
+    public void addItem(Item item) throws ItemException {
         try {
+            Connection con = ds.getConnection();
+            try {
 
-            PreparedStatement pStmt = con.prepareStatement("INSERT INTO item VALUES(?, ?, ?)");
-            pStmt.setString(1, item.getItemNo());
-            pStmt.setString(2, item.getItemName());
-            pStmt.setString(3, item.getDescription());
-
-            pStmt.executeUpdate();
-
-            pStmt = con.prepareStatement("INSERT INTO item_master VALUES(?, ?)");
-            pStmt.setString(1, item.getItemNo());
-            pStmt.setInt(2, 0);
-
-            pStmt.executeUpdate();
-
-        } catch (SQLException e) {
-            e.printStackTrace();
-        } finally {
-            if (con != null) {
+                PreparedStatement pStmt = con.prepareStatement("INSERT INTO item VALUES(?, ?, ?)");
                 try {
-                    con.close();
-                } catch (SQLException e) {
-                    e.printStackTrace();
+                    pStmt.setString(1, item.getItemNo());
+                    pStmt.setString(2, item.getItemName());
+                    pStmt.setString(3, item.getDescription());
+
+                    pStmt.executeUpdate();
+
+                    pStmt = con.prepareStatement("INSERT INTO item_master VALUES(?, ?)");
+                    pStmt.setString(1, item.getItemNo());
+                    pStmt.setInt(2, 0);
+
+                    pStmt.executeUpdate();
+                } finally {
+                    pStmt.close();
                 }
+
+            } finally {
+                con.close();
             }
+        } catch (SQLException e) {
+            throw new ItemException(e);
         }
     }
 

Added: geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/exception/ItemException.java
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/exception/ItemException.java?rev=666872&view=auto
==============================================================================
--- geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/exception/ItemException.java (added)
+++ geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/exception/ItemException.java Wed Jun 11 15:14:54 2008
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.samples.inventory.exception;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class ItemException extends Exception {
+    public ItemException() {
+    }
+
+    public ItemException(String s) {
+        super(s);
+    }
+
+    public ItemException(String s, Throwable throwable) {
+        super(s, throwable);
+    }
+
+    public ItemException(Throwable throwable) {
+        super(throwable);
+    }
+}

Propchange: geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/exception/ItemException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/exception/ItemException.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/exception/ItemException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/services/InventoryManager.java
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/services/InventoryManager.java?rev=666872&r1=666871&r2=666872&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/services/InventoryManager.java (original)
+++ geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/services/InventoryManager.java Wed Jun 11 15:14:54 2008
@@ -23,16 +23,17 @@
 import org.apache.geronimo.samples.inventory.dao.ItemDAO;
 import org.apache.geronimo.samples.inventory.exception.DuplicateItemIdException;
 import org.apache.geronimo.samples.inventory.exception.NotSufficientQuantityException;
+import org.apache.geronimo.samples.inventory.exception.ItemException;
 
 
 public class InventoryManager {
 
-    public List getItems() {
+    public List<Item> getItems() throws ItemException {
         ItemDAO dao = new ItemDAO();
         return dao.getItems();
     }
 
-    public void issueItem(String itemNo, int quantity) throws NotSufficientQuantityException {
+    public void issueItem(String itemNo, int quantity) throws NotSufficientQuantityException, ItemException {
         ItemDAO dao = new ItemDAO();
 
         int qoh = dao.getQOH(itemNo);
@@ -42,7 +43,7 @@
         dao.updateQOH(itemNo, (qoh - quantity));
     }
 
-    public void recvItem(String itemNo, int quantity) {
+    public void recvItem(String itemNo, int quantity) throws ItemException {
         ItemDAO dao = new ItemDAO();
 
         int qoh = dao.getQOH(itemNo);
@@ -50,7 +51,7 @@
         dao.updateQOH(itemNo, (qoh + quantity));
     }
 
-    public void addItem(String itemNo, String itemName, String desc) throws DuplicateItemIdException {
+    public void addItem(String itemNo, String itemName, String desc) throws DuplicateItemIdException, ItemException {
         ItemDAO dao = new ItemDAO();
 
         if (dao.isItemIdExists(itemNo)) throw new DuplicateItemIdException();

Modified: geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/AddItemServlet.java
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/AddItemServlet.java?rev=666872&r1=666871&r2=666872&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/AddItemServlet.java (original)
+++ geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/AddItemServlet.java Wed Jun 11 15:14:54 2008
@@ -25,6 +25,7 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.geronimo.samples.inventory.exception.DuplicateItemIdException;
+import org.apache.geronimo.samples.inventory.exception.ItemException;
 import org.apache.geronimo.samples.inventory.services.InventoryManager;
 
 
@@ -52,6 +53,9 @@
             } catch (DuplicateItemIdException e) {
                 req.setAttribute("error", "Duplicate Item Id");
                 getServletContext().getRequestDispatcher("/jsp/error.jsp").forward(req, res);
+            } catch (ItemException e) {
+                req.setAttribute("Internal error", e.getCause().getMessage());
+                getServletContext().getRequestDispatcher("/jsp/error.jsp").forward(req, res);
             }
         } else {
             String error = "";

Modified: geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/IssueingServlet.java
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/IssueingServlet.java?rev=666872&r1=666871&r2=666872&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/IssueingServlet.java (original)
+++ geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/IssueingServlet.java Wed Jun 11 15:14:54 2008
@@ -25,6 +25,7 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.geronimo.samples.inventory.exception.NotSufficientQuantityException;
+import org.apache.geronimo.samples.inventory.exception.ItemException;
 import org.apache.geronimo.samples.inventory.services.InventoryManager;
 
 
@@ -56,6 +57,9 @@
         } catch (NotSufficientQuantityException e) {
             req.setAttribute("error", "Not Sufficient Qunatity to Issue Items");
             getServletContext().getRequestDispatcher("/jsp/error.jsp").forward(req, res);
+        } catch (ItemException e) {
+            req.setAttribute("Internal error", e.getCause().getMessage());
+            getServletContext().getRequestDispatcher("/jsp/error.jsp").forward(req, res);
         }
     }
 

Modified: geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/ReceivingServlet.java
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/ReceivingServlet.java?rev=666872&r1=666871&r2=666872&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/ReceivingServlet.java (original)
+++ geronimo/samples/trunk/samples/inventory/inventory-war/src/main/java/org/apache/geronimo/samples/inventory/web/ReceivingServlet.java Wed Jun 11 15:14:54 2008
@@ -25,6 +25,7 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.geronimo.samples.inventory.services.InventoryManager;
+import org.apache.geronimo.samples.inventory.exception.ItemException;
 
 
 public class ReceivingServlet extends HttpServlet {
@@ -52,6 +53,9 @@
             e.printStackTrace();
             req.setAttribute("error", "Invalid Number Format for Quantity");
             getServletContext().getRequestDispatcher("/jsp/error.jsp").forward(req, res);
+        } catch (ItemException e) {
+            req.setAttribute("Internal error", e.getCause().getMessage());
+            getServletContext().getRequestDispatcher("/jsp/error.jsp").forward(req, res);
         }
 
     }

Copied: geronimo/samples/trunk/samples/inventory/inventory-war/src/main/resources/InventoryDB.sql (from r656346, geronimo/samples/trunk/samples/inventory/inventory-ear/src/main/resources/InventoryDB.sql)
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/inventory/inventory-war/src/main/resources/InventoryDB.sql?p2=geronimo/samples/trunk/samples/inventory/inventory-war/src/main/resources/InventoryDB.sql&p1=geronimo/samples/trunk/samples/inventory/inventory-ear/src/main/resources/InventoryDB.sql&r1=656346&r2=666872&rev=666872&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/inventory/inventory-ear/src/main/resources/InventoryDB.sql (original)
+++ geronimo/samples/trunk/samples/inventory/inventory-war/src/main/resources/InventoryDB.sql Wed Jun 11 15:14:54 2008
@@ -1,19 +1,17 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  See the NOTICE file distributed with
- *  this work for additional information regarding copyright ownership.
- *  The ASF licenses this file to You under the Apache License, Version 2.0
- *  (the "License"); you may not use this file except in compliance with
- *  the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
+--  Licensed to the Apache Software Foundation (ASF) under one or more
+--  contributor license agreements.  See the NOTICE file distributed with
+--  this work for additional information regarding copyright ownership.
+--  The ASF licenses this file to You under the Apache License, Version 2.0
+--  (the "License"); you may not use this file except in compliance with
+--  the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+--  Unless required by applicable law or agreed to in writing, software
+--  distributed under the License is distributed on an "AS IS" BASIS,
+--  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+--  See the License for the specific language governing permissions and
+--  limitations under the License.
 
 CREATE TABLE item(
 	item_id VARCHAR(10) PRIMARY KEY,

Modified: geronimo/samples/trunk/samples/inventory/inventory-war/src/main/webapp/jsp/issue.jsp
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/inventory/inventory-war/src/main/webapp/jsp/issue.jsp?rev=666872&r1=666871&r2=666872&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/inventory/inventory-war/src/main/webapp/jsp/issue.jsp (original)
+++ geronimo/samples/trunk/samples/inventory/inventory-war/src/main/webapp/jsp/issue.jsp Wed Jun 11 15:14:54 2008
@@ -17,6 +17,7 @@
 under the License.
 -->
 <%@ page import="java.util.List" %>
+<%@ page import="org.apache.geronimo.samples.inventory.Item" %>
 
 <HTML>
 <jsp:useBean id="inventoryManager" scope="session" class="org.apache.geronimo.samples.inventory.services.InventoryManager"/>
@@ -32,12 +33,12 @@
                 <TD>
                     <SELECT name="item_no">
                         <%
-                            List itemList = inventoryManager.getItems();
+                            List<Item> itemList = inventoryManager.getItems();
                             for (int i = 0; i < itemList.size(); i++) {
-                                List item = (List) itemList.get(i);
+                                Item item = itemList.get(i);
 
-                                String itemNo = (String) item.get(0);
-                                String itemName = (String) item.get(1);
+                                String itemNo = item.getItemNo();
+                                String itemName = item.getItemName();
                         %>
                         <OPTION value="<%=itemNo%>"><%=itemName%>
                         </OPTION>

Modified: geronimo/samples/trunk/samples/inventory/inventory-war/src/main/webapp/jsp/recv.jsp
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/inventory/inventory-war/src/main/webapp/jsp/recv.jsp?rev=666872&r1=666871&r2=666872&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/inventory/inventory-war/src/main/webapp/jsp/recv.jsp (original)
+++ geronimo/samples/trunk/samples/inventory/inventory-war/src/main/webapp/jsp/recv.jsp Wed Jun 11 15:14:54 2008
@@ -17,13 +17,14 @@
 under the License.
 -->
 <%@ page import="java.util.List" %>
+<%@ page import="org.apache.geronimo.samples.inventory.Item" %>
 
 <HTML>
 <jsp:useBean id="inventoryManager" scope="session" class="org.apache.geronimo.samples.inventory.services.InventoryManager"/>
 <HEAD><TITLE>Receiving</TITLE></HEAD>
 <BODY>
 <div align="center">
-    <H2>Recieving of Goods</H2>
+    <H2>Receiving of Goods</H2>
 
     <FORM method="POST" action="../recv">
         <TABLE bgcolor="cyan">
@@ -32,12 +33,12 @@
                 <TD>
                     <SELECT name="item_no">
                         <%
-                            List itemList = inventoryManager.getItems();
+                            List<Item> itemList = inventoryManager.getItems();
                             for (int i = 0; i < itemList.size(); i++) {
-                                List item = (List) itemList.get(i);
+                                Item item = itemList.get(i);
 
-                                String itemNo = (String) item.get(0);
-                                String itemName = (String) item.get(1);
+                                String itemNo = item.getItemNo();
+                                String itemName = item.getItemName();
                         %>
                         <OPTION value="<%=itemNo%>"><%=itemName%>
                         </OPTION>

Modified: geronimo/samples/trunk/samples/inventory/inventory-war/src/main/webapp/welcome.jsp
URL: http://svn.apache.org/viewvc/geronimo/samples/trunk/samples/inventory/inventory-war/src/main/webapp/welcome.jsp?rev=666872&r1=666871&r2=666872&view=diff
==============================================================================
--- geronimo/samples/trunk/samples/inventory/inventory-war/src/main/webapp/welcome.jsp (original)
+++ geronimo/samples/trunk/samples/inventory/inventory-war/src/main/webapp/welcome.jsp Wed Jun 11 15:14:54 2008
@@ -17,6 +17,8 @@
 under the License.
 -->
 <%@ page import="java.util.List" %>
+<%@ page import="org.apache.geronimo.samples.inventory.Item" %>
+<%@ page import="org.apache.geronimo.samples.inventory.exception.ItemException" %>
 
 
 <HTML>
@@ -24,10 +26,11 @@
 <HEAD><TITLE>Welcome</TITLE></HEAD>
 <BODY>
 <div div=true align="center">
-    <strong><H2>Welcome to the Inventory Contorl System</H2><br><br><br></strong>
+    <strong><H2>Welcome to the Inventory Control System</H2><br><br><br></strong>
 
     <%
-        List itemList = inventoryManager.getItems();
+        try {
+        List<Item> itemList = inventoryManager.getItems();
         if (itemList.size() > 0) {
 
     %>
@@ -40,12 +43,12 @@
         </TR>
         <%
             for (int i = 0; i < itemList.size(); i++) {
-                List item = (List) itemList.get(i);
+                Item item = itemList.get(i);
 
-                String itemNo = (String) item.get(0);
-                String itemName = (String) item.get(1);
-                String description = (String) item.get(2);
-                String quantity = (String) item.get(3);
+                String itemNo = item.getItemNo();
+                String itemName = item.getItemName();
+                String description = item.getDescription();
+                String quantity = "quantity: " + item.getQuantity();
         %>
         <TR>
             <TD><%=itemNo%>
@@ -57,15 +60,18 @@
             <TD><%=quantity%>
             </TD>
         </TR>
-        <% }%>
+        <%}%>
     </TABLE>
-    <%}%>
+    <% }
+    } catch (ItemException e) { %>
+        Error: <%=e.getMessage()%>    
+    <% }%>
     <br>
     <br>
     <TABLE>
         <TR>
             <TD><A href="jsp/add.jsp">Add Items </A></TD>
-            <TD><A href="jsp/recv.jsp">Recieving</A></TD>
+            <TD><A href="jsp/recv.jsp">Receiving</A></TD>
             <TD><A href="jsp/issue.jsp">Issueing</A></TD>
         </TR>
     </TABLE>