Author: ekoneil
Date: Sat Apr 30 14:28:13 2005
New Revision: 165419
URL: http://svn.apache.org/viewcvs?rev=165419&view=rev
Log:
Petstore updates from a patch by Scott Semyan.
This includes code-cleanup in the petstore and an additional test.
BB: self
Modified:
incubator/beehive/trunk/samples/petstoreWeb-test/src/org/apache/beehive/samples/petstore/test/Account.java
incubator/beehive/trunk/samples/petstoreWeb/Controller.jpf
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controller/PetstoreController.java
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/AccountControlImpl.jcs
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/AddressControl.java
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/AddressControlImpl.jcs
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/CatalogControl.java
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/CatalogControlImpl.jcs
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/OrderControlImpl.jcs
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/AccountDBControl.jcx
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/exceptions/DataStoreException.java
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Account.java
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Category.java
incubator/beehive/trunk/samples/petstoreWeb/account/addresses/Controller.jpf
incubator/beehive/trunk/samples/petstoreWeb/account/create/Controller.jpf
incubator/beehive/trunk/samples/petstoreWeb/account/create/create.jsp
incubator/beehive/trunk/samples/petstoreWeb/account/edit/Controller.jpf
incubator/beehive/trunk/samples/petstoreWeb/auth/Controller.jpf
incubator/beehive/trunk/samples/petstoreWeb/checkout/Controller.jpf
incubator/beehive/trunk/samples/petstoreWeb/search/Controller.jpf
incubator/beehive/trunk/samples/petstoreWeb/shop/Controller.jpf
incubator/beehive/trunk/samples/petstoreWeb/webappRoot/SharedFlow.jpfs
Modified:
incubator/beehive/trunk/samples/petstoreWeb-test/src/org/apache/beehive/samples/petstore/test/Account.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb-test/src/org/apache/beehive/samples/petstore/test/Account.java?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb-test/src/org/apache/beehive/samples/petstore/test/Account.java
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb-test/src/org/apache/beehive/samples/petstore/test/Account.java
Sat Apr 30 14:28:13 2005
@@ -18,6 +18,7 @@
import junit.framework.TestCase;
+import com.meterware.httpunit.HttpUnitOptions;
import com.meterware.httpunit.WebForm;
import com.meterware.httpunit.WebResponse;
@@ -89,5 +90,49 @@
form.setCheckbox("wlw-checkbox_key:{actionForm.myListOpt}", true);
form.setCheckbox("wlw-checkbox_key:{actionForm.bannerOpt}", true);
form.submit();
+ }
+
+ public void testNewAccount() throws Exception
+ {
+ // Turn off javaScript
+ HttpUnitOptions.setScriptingEnabled(false);
+
+ // Start the conversation
+ WebResponse resp = Util.navToStore();
+
+ // Click the Sign In link
+ resp = resp.getLinkWith("Sign In").click();
+
+ // Click the Register Now link
+ resp = resp.getLinkWith(Util.getBundle("view",
"buttonRegisterNow")).click();
+
+ // Enter the new user data
+ WebForm form = resp.getForms()[1];
+ form.setParameter( "{actionForm.userId}", "newuser" );
+ form.setParameter( "{actionForm.password}", "x" );
+ form.setParameter( "{actionForm.repeatedPassword}", "x" );
+ form.setParameter( "{actionForm.firstName}", "New" );
+ form.setParameter( "{actionForm.lastName}", "User" );
+ form.setParameter( "{actionForm.email}", "[EMAIL PROTECTED]" );
+ form.setParameter( "wlw-select_key:{actionForm.langPref}", "English"
);
+ form.setParameter( "wlw-select_key:{actionForm.favCategory}", "DOGS"
);
+ form.setCheckbox("wlw-checkbox_key:{actionForm.myListOpt}", true);
+ form.setCheckbox("wlw-checkbox_key:{actionForm.bannerOpt}", true);
+ resp = form.submit();
+
+ // Logout, then login again
+ resp = resp.getLinkWith("Sign Out").click();
+ resp = Util.doSignIn("newuser", "x");
+ resp = resp.getLinkWith("My Account").click();
+
+ // Make sure the values stuck
+ form = resp.getForms()[1];
+ assertEquals(form.getParameterValue("{actionForm.firstName}"), "New");
+ assertEquals(form.getParameterValue("{actionForm.lastName}"), "User");
+ assertEquals(form.getParameterValue("{actionForm.email}"), "[EMAIL
PROTECTED]");
+
assertEquals(form.getParameterValue("wlw-select_key:{actionForm.langPref}"),
"English" );
+
assertEquals(form.getParameterValue("wlw-select_key:{actionForm.favCategory}"),
"DOGS" );
+
assertNotNull(form.getParameterValue("wlw-checkbox_key:{actionForm.myListOpt}"));
+
assertNotNull(form.getParameterValue("wlw-checkbox_key:{actionForm.bannerOpt}"));
}
}
Modified: incubator/beehive/trunk/samples/petstoreWeb/Controller.jpf
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/Controller.jpf?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/petstoreWeb/Controller.jpf (original)
+++ incubator/beehive/trunk/samples/petstoreWeb/Controller.jpf Sat Apr 30
14:28:13 2005
@@ -83,7 +83,7 @@
@Jpf.Forward(name = "index", path = "index.jsp")
}
)
- protected Forward initDB() throws DataStoreException, Exception
+ protected Forward initDB() throws Exception
{
List<String> dbInit = getSqlStatements(SQL_FILE);
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controller/PetstoreController.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controller/PetstoreController.java?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controller/PetstoreController.java
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controller/PetstoreController.java
Sat Apr 30 14:28:13 2005
@@ -1,37 +0,0 @@
-/*
- * Copyright 2004 The Apache Software Foundation.
- *
- * Licensed 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.
- *
- * $Header:$
- */
-package org.apache.beehive.samples.petstore.controller;
-
-import org.apache.beehive.netui.pageflow.PageFlowController;
-
-public abstract class PetstoreController
- extends PageFlowController {
-
- /*
- There are a set of JPF bugs that prevent the use of PageFlowController
- base classes. Generally, they are related to being unable to use
- controls / shared flows as annotated fields as the runtime doesn't
- discover and initialize them correctly.
-
- Once this happens, methods like getAccount() in the SharedFlow
- can be implemented once for the Page Flows in the base class.
-
- In addition, all JPFs would then have protected access to the SharedFlow
- field
- */
-}
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/AccountControlImpl.jcs
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/AccountControlImpl.jcs?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/AccountControlImpl.jcs
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/AccountControlImpl.jcs
Sat Apr 30 14:28:13 2005
@@ -22,9 +22,9 @@
import org.apache.beehive.samples.petstore.controls.AccountControl;
import org.apache.beehive.samples.petstore.controls.data.AccountDBControl;
import
org.apache.beehive.samples.petstore.controls.exceptions.AccountAlreadyExistsException;
-import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import
org.apache.beehive.samples.petstore.controls.exceptions.InvalidIdentifierException;
import
org.apache.beehive.samples.petstore.controls.exceptions.NoSuchAccountException;
+import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import org.apache.beehive.samples.petstore.model.Account;
import java.sql.SQLException;
@@ -35,7 +35,7 @@
@Control()
private AccountDBControl _accountDBControl;
- public boolean checkAccountExists(String key) throws DataStoreException
+ public boolean checkAccountExists(String key)
{
boolean ret = false;
try {
@@ -50,7 +50,7 @@
return ret;
}
- public Account getAccount(String key) throws InvalidIdentifierException,
DataStoreException
+ public Account getAccount(String key) throws InvalidIdentifierException
{
Account acct = new Account();
try {
@@ -95,7 +95,7 @@
doInsertAccount(account);
}
- private void doUpdateAccount(Account account) throws DataStoreException
+ private void doUpdateAccount(Account account)
{
try {
_accountDBControl.updateAccount(account);
@@ -107,7 +107,7 @@
}
}
- private void doInsertAccount(Account account) throws DataStoreException
+ private void doInsertAccount(Account account)
{
try {
_accountDBControl.insertAccount(account);
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/AddressControl.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/AddressControl.java?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/AddressControl.java
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/AddressControl.java
Sat Apr 30 14:28:13 2005
@@ -35,8 +35,6 @@
public void updateAddress(Address address)
throws InvalidIdentifierException, NoSuchAddressException,
DataStoreException;
- public boolean checkAddressExists(int addressId, String userId) throws
DataStoreException;
-
public Address[] getUserAddresses(String userId) throws DataStoreException;
public void deleteAddress(int addressId, String userId) throws
InvalidIdentifierException, DataStoreException, NoSuchAddressException;
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/AddressControlImpl.jcs
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/AddressControlImpl.jcs?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/AddressControlImpl.jcs
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/AddressControlImpl.jcs
Sat Apr 30 14:28:13 2005
@@ -20,9 +20,9 @@
import org.apache.beehive.controls.api.bean.Control;
import org.apache.beehive.controls.api.bean.ControlImplementation;
import org.apache.beehive.samples.petstore.controls.data.AddressDBControl;
-import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import
org.apache.beehive.samples.petstore.controls.exceptions.InvalidIdentifierException;
import
org.apache.beehive.samples.petstore.controls.exceptions.NoSuchAddressException;
+import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import org.apache.beehive.samples.petstore.model.Address;
import java.sql.SQLException;
@@ -34,22 +34,7 @@
@Control()
private AddressDBControl _addressDBControl;
- public boolean checkAddressExists(int key, String userKey) throws
DataStoreException
- {
- boolean ret = false;
- try {
- if (_addressDBControl.checkAddressExists(key, userKey)
> 0)
- ret = true;
- } catch (SQLException e) {
-
- // Print the stack to std out and bubble a friendly
error
- e.printStackTrace();
- throw new DataStoreException("Database Error: " +
e.getMessage());
- }
- return ret;
- }
-
- public Address[] getUserAddresses(String key) throws DataStoreException
+ public Address[] getUserAddresses(String key)
{
Address[] addresses;
try {
@@ -63,7 +48,7 @@
return addresses;
}
- public Address getAddress(int key) throws InvalidIdentifierException,
DataStoreException
+ public Address getAddress(int key) throws InvalidIdentifierException
{
Address add = new Address();
try {
@@ -81,7 +66,7 @@
}
public void updateAddress(Address address)
- throws InvalidIdentifierException, NoSuchAddressException,
DataStoreException
+ throws InvalidIdentifierException, NoSuchAddressException
{
String userId = address.getUserId();
int addressId = address.getAddressId();
@@ -89,10 +74,10 @@
if (userId == null || userId.length() == 0 || addressId == -1)
throw new InvalidIdentifierException("cannot update Address with
null or empty userId or addressId of -1");
- if (!checkAddressExists(addressId, userId))
- throw new NoSuchAddressException("no Address found for userId: " +
userId + " and addressId " + addressId);
-
try {
+ if (_addressDBControl.checkAddressExists(addressId,
userId) == 0)
+ throw new NoSuchAddressException("no Address
found for userId: " + userId + " and addressId " + addressId);
+
_addressDBControl.updateAddress(address);
} catch (SQLException e) {
@@ -103,7 +88,7 @@
}
public void insertAddress(Address address)
- throws InvalidIdentifierException, DataStoreException
+ throws InvalidIdentifierException
{
String userId = address.getUserId();
if (userId == null || userId.length() == 0)
@@ -122,15 +107,15 @@
}
public void deleteAddress(int addressId, String userId)
- throws InvalidIdentifierException, DataStoreException,
NoSuchAddressException
+ throws InvalidIdentifierException, NoSuchAddressException
{
if (userId == null || userId.length() == 0 || addressId == -1)
throw new InvalidIdentifierException("cannot delete Address with
null or empty userId or addressId of -1");
- if (!checkAddressExists(addressId, userId))
- throw new NoSuchAddressException("no Address found for userId: " +
userId + " and addressId " + addressId);
-
try {
+ if (_addressDBControl.checkAddressExists(addressId,
userId) == 0)
+ throw new NoSuchAddressException("no Address
found for userId: " + userId + " and addressId " + addressId);
+
_addressDBControl.deleteAddress(addressId, userId);
} catch (SQLException e) {
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/CatalogControl.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/CatalogControl.java?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/CatalogControl.java
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/CatalogControl.java
Sat Apr 30 14:28:13 2005
@@ -21,29 +21,27 @@
import org.apache.beehive.samples.petstore.model.Item;
import org.apache.beehive.samples.petstore.model.Product;
import org.apache.beehive.samples.petstore.model.Category;
-import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import
org.apache.beehive.samples.petstore.controls.exceptions.InvalidIdentifierException;
@ControlInterface
public interface CatalogControl {
- public Category[] getCategoryList() throws DataStoreException;
+ public Category[] getCategoryList();
- public Category getCategory(String categoryId) throws
InvalidIdentifierException, DataStoreException;
+ public Category getCategory(String categoryId) throws
InvalidIdentifierException;
- public Product getProduct(String productId) throws
InvalidIdentifierException, DataStoreException;
+ public Product getProduct(String productId) throws
InvalidIdentifierException;
- public Product[] getProductListByCategory(String categoryId) throws
DataStoreException;
+ public Product[] getProductListByCategory(String categoryId);
- public Product[] searchProductList(String searchString) throws
DataStoreException;
+ public Product[] searchProductList(String searchString);
- public Item getItem(String itemId) throws InvalidIdentifierException,
DataStoreException;
+ public Item getItem(String itemId) throws InvalidIdentifierException;
- public Item[] getItemListByProduct(String categoryId) throws
DataStoreException;
+ public Item[] getItemListByProduct(String categoryId);
public void updateItemQuantity(Item item, int quantity)
- throws InvalidIdentifierException, DataStoreException;
+ throws InvalidIdentifierException;
- public int checkDB() throws DataStoreException;
- public void initDB(String initString) throws DataStoreException;
+ public void initDB(String initString);
}
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/CatalogControlImpl.jcs
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/CatalogControlImpl.jcs?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/CatalogControlImpl.jcs
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/CatalogControlImpl.jcs
Sat Apr 30 14:28:13 2005
@@ -23,8 +23,8 @@
import org.apache.beehive.samples.petstore.model.Category;
import org.apache.beehive.samples.petstore.model.Product;
import org.apache.beehive.samples.petstore.controls.data.CatalogDBControl;
-import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import
org.apache.beehive.samples.petstore.controls.exceptions.InvalidIdentifierException;
+import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import java.sql.SQLException;
@@ -35,7 +35,7 @@
@Control()
private CatalogDBControl _petsDBControl;
- public Category[] getCategoryList() throws DataStoreException
+ public Category[] getCategoryList()
{
// todo: bad form -- should return an immutable array here
Category[] categories;
@@ -49,7 +49,7 @@
return categories;
}
- public Category getCategory(String key) throws InvalidIdentifierException,
DataStoreException
+ public Category getCategory(String key) throws InvalidIdentifierException
{
Category cat = new Category();
try {
@@ -67,7 +67,7 @@
/**
*/
- public Item getItem(String key) throws InvalidIdentifierException,
DataStoreException
+ public Item getItem(String key) throws InvalidIdentifierException
{
Item item = new Item();
try {
@@ -85,7 +85,7 @@
/**
*/
- public Item[] getItemListByProduct(String key) throws DataStoreException
+ public Item[] getItemListByProduct(String key)
{
Item[] items;
try {
@@ -99,8 +99,7 @@
}
// todo: this doesn't handle the case where something goes "out of stock",
ie a negative quantity
- public void updateItemQuantity(Item item, int quantity)
- throws InvalidIdentifierException, DataStoreException
+ public void updateItemQuantity(Item item, int quantity) throws
InvalidIdentifierException
{
if(item == null)
throw new InvalidIdentifierException("cannot update Item inventory
with null or empty itemId");
@@ -116,7 +115,7 @@
}
}
- public Product getProduct(String key) throws InvalidIdentifierException,
DataStoreException
+ public Product getProduct(String key) throws InvalidIdentifierException
{
Product prod = new Product();
try {
@@ -133,7 +132,7 @@
}
- public Product[] getProductListByCategory(String key) throws
DataStoreException
+ public Product[] getProductListByCategory(String key)
{
Product[] products;
try {
@@ -147,7 +146,7 @@
}
- public Product[] searchProductList(String searchTerm) throws
DataStoreException
+ public Product[] searchProductList(String searchTerm)
{
Product[] products;
try {
@@ -160,7 +159,7 @@
return products;
}
- public void initDB(String initString) throws DataStoreException
+ public void initDB(String initString)
{
try {
_petsDBControl.initDB(initString);
@@ -169,17 +168,5 @@
e.printStackTrace();
throw new DataStoreException("Database Error: " +
e.getMessage());
}
- }
- public int checkDB() throws DataStoreException
- {
- int nRet = 0;
- try {
- nRet = _petsDBControl.checkDB();
- } catch (SQLException e) {
- // Print the stack to std out and bubble a friendly
error
- e.printStackTrace();
- throw new DataStoreException("Database Error: " +
e.getMessage());
- }
- return nRet;
}
}
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/OrderControlImpl.jcs
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/OrderControlImpl.jcs?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/OrderControlImpl.jcs
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/OrderControlImpl.jcs
Sat Apr 30 14:28:13 2005
@@ -28,10 +28,10 @@
import org.apache.beehive.samples.petstore.model.Item;
import org.apache.beehive.samples.petstore.model.OrderItem;
import org.apache.beehive.samples.petstore.controls.data.OrderDBControl;
-import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import
org.apache.beehive.samples.petstore.controls.exceptions.OrderAlreadyExistsException;
import
org.apache.beehive.samples.petstore.controls.exceptions.NoSuchOrderException;
import
org.apache.beehive.samples.petstore.controls.exceptions.InvalidIdentifierException;
+import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import org.apache.beehive.controls.api.bean.ControlImplementation;
@ControlImplementation
@@ -61,43 +61,47 @@
}
public int commitOrder(Order order, Cart cart)
- throws OrderAlreadyExistsException, NoSuchOrderException,
InvalidIdentifierException, DataStoreException
+ throws OrderAlreadyExistsException, NoSuchOrderException,
InvalidIdentifierException
{
int orderId = -1;
- // TODO: the following should be in a transaction
- // Add order to DB
try {
+ java.sql.Connection connection =
_orderDBControl.getConnection();
+ connection.setAutoCommit( false );
+
+ // Add order to DB
_orderDBControl.addOrder(order);
orderId =
_orderDBControl.getLastOrderIdForUser(order.getUserId());
- } catch (SQLException e) {
+ // Add the cart items and update the quantities in the DB
+ Item item = null;
+ Iterator i = cart.getLineItems().iterator();
+ while (i.hasNext())
+ {
+ LineItem lineItem = (LineItem) i.next();
+ updateItemQuantity(lineItem.getItem(),
lineItem.getQuantity());
+ addItemToOrder(orderId, lineItem.getItem(),
lineItem.getQuantity());
+ }
+ connection.commit();
+ } catch (SQLException e) {
+
// Print the stack to std out and bubble a friendly
error
e.printStackTrace();
throw new DataStoreException("Database Error: " +
e.getMessage());
}
-
- // Add the cart items and update the quantities in the DB
- Item item = null;
- Iterator i = cart.getLineItems().iterator();
- while (i.hasNext())
- {
- LineItem lineItem = (LineItem) i.next();
- updateItemQuantity(lineItem.getItem(), lineItem.getQuantity());
- addItemToOrder(orderId, lineItem.getItem(),
lineItem.getQuantity());
- }
+
return orderId;
}
/**
*/
public Order getOrder(String userId, int key)
- throws NoSuchOrderException, DataStoreException
+ throws NoSuchOrderException
{
Order order = new Order();
try {
order = _orderDBControl.getOrder(key, userId);
- if(order.getOrderId() == -1)
+ if((order == null) || (order.getOrderId() == -1))
throw new NoSuchOrderException("No order could be found
with order id: " + key + " for user: " + userId);
} catch (SQLException e) {
@@ -109,7 +113,7 @@
return order;
}
- public Order[] getOrdersByUserId(String userId) throws DataStoreException
+ public Order[] getOrdersByUserId(String userId)
{
Order[] orders;
try {
@@ -124,7 +128,7 @@
return orders;
}
- public OrderItem[] getOrderItemsByOrderId(int orderId) throws
DataStoreException
+ public OrderItem[] getOrderItemsByOrderId(int orderId)
{
OrderItem[] orderItems;
try {
@@ -145,13 +149,13 @@
}
private void updateItemQuantity(Item item, int quantity)
- throws InvalidIdentifierException, DataStoreException
+ throws InvalidIdentifierException
{
_catalogControl.updateItemQuantity(item, quantity);
}
private void addItemToOrder(int orderId, Item item, int quantity)
- throws InvalidIdentifierException, DataStoreException
+ throws InvalidIdentifierException
{
try {
_orderDBControl.addOrderItem(orderId, item.getItemId(),
quantity);
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/AccountDBControl.jcx
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/AccountDBControl.jcx?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/AccountDBControl.jcx
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/data/AccountDBControl.jcx
Sat Apr 30 14:28:13 2005
@@ -61,6 +61,6 @@
// insertAccount
@SQL(statement="insert into Accounts values ({account.userId},
{account.password}, {account.email}, {account.firstName}, " +
"{account.lastName}, {account.status}, {account.favCategory},
{account.langPref}, " +
- "{account.bannerData}, {account.myListState},
{account.bannerOptState})")
+ "'', {account.myListState}, {account.bannerOptState})")
public void insertAccount(Account account) throws SQLException;
}
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/exceptions/DataStoreException.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/exceptions/DataStoreException.java?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/exceptions/DataStoreException.java
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/controls/exceptions/DataStoreException.java
Sat Apr 30 14:28:13 2005
@@ -18,7 +18,7 @@
package org.apache.beehive.samples.petstore.controls.exceptions;
public class DataStoreException
- extends Exception {
+ extends RuntimeException {
public DataStoreException(String message) {
super(message);
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Account.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Account.java?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Account.java
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Account.java
Sat Apr 30 14:28:13 2005
@@ -119,6 +119,7 @@
_myListOpt = myListOpt;
}
+ // Derby does not have a boolean datatype so we use the myListState to
simulate one with an int
public int getMyListState() {
if (_myListOpt)
return 1;
@@ -126,6 +127,7 @@
return 0;
}
+ // Derby does not have a boolean datatype so we use the myListState to
simulate one with an int
public void setMyListState(int myListOpt) {
if (myListOpt == 0)
_myListOpt = false;
@@ -141,13 +143,15 @@
_bannerOpt = bannerOpt;
}
- public int getBannerOptState() {
+ // Derby does not have a boolean datatype so we use the bannerOptState to
simulate one with an int
+ public int getBannerOptState() {
if (_bannerOpt)
return 1;
else
return 0;
}
+ // Derby does not have a boolean datatype so we use the bannerOptState to
simulate one with an int
public void setBannerOptState(int bannerOpt) {
if (bannerOpt == 0)
_bannerOpt = false;
Modified:
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Category.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Category.java?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Category.java
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/WEB-INF/src/org/apache/beehive/samples/petstore/model/Category.java
Sat Apr 30 14:28:13 2005
@@ -33,7 +33,7 @@
}
public void setCatId(String catId) {
- _catId = catId.trim();
+ _catId = catId;
}
public String getImage() {
Modified:
incubator/beehive/trunk/samples/petstoreWeb/account/addresses/Controller.jpf
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/account/addresses/Controller.jpf?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
---
incubator/beehive/trunk/samples/petstoreWeb/account/addresses/Controller.jpf
(original)
+++
incubator/beehive/trunk/samples/petstoreWeb/account/addresses/Controller.jpf
Sat Apr 30 14:28:13 2005
@@ -29,7 +29,6 @@
import org.apache.beehive.controls.api.bean.Control;
import org.apache.beehive.samples.petstore.controls.AddressControl;
-import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import
org.apache.beehive.samples.petstore.controls.exceptions.NoSuchAddressException;
import
org.apache.beehive.samples.petstore.controls.exceptions.InvalidIdentifierException;
import org.apache.beehive.samples.petstore.forms.AddressForm;
@@ -52,7 +51,6 @@
private CreateAddressForm _createForm = null;
- // begin - show list of addresses
@Jpf.Action(
forwards = {
@Jpf.Forward(name = "success", path = "listAddresses.jsp",
@@ -63,7 +61,7 @@
})
}
)
- protected Forward begin() throws DataStoreException {
+ protected Forward begin() {
_sharedFlow.ensureLogin();
Forward forward = new Forward("success");
@@ -71,13 +69,12 @@
return forward;
}
- // createUpdateAddress - get new/existing address and display on
createUpdate page
@Jpf.Action(
forwards = {
@Jpf.Forward(name = "success", path = "createUpdate.jsp")
}
)
- protected Forward createUpdateAddress() throws DataStoreException,
InvalidIdentifierException
+ protected Forward createUpdateAddress() throws InvalidIdentifierException
{
_sharedFlow.ensureLogin();
@@ -100,7 +97,6 @@
return forward;
}
- // updateAddress - Insert/update new or existing address
@Jpf.Action(
useFormBean = "_createForm",
forwards = {
@@ -108,7 +104,7 @@
}, validationErrorForward = @Jpf.Forward(name = "failure",
navigateTo = Jpf.NavigateTo.currentPage)
)
protected Forward updateAddress(CreateAddressForm form)
- throws InvalidIdentifierException, NoSuchAddressException,
DataStoreException
+ throws InvalidIdentifierException, NoSuchAddressException
{
_sharedFlow.ensureLogin();
@@ -126,18 +122,19 @@
return new Forward("success");
}
- // deleteAddress - delete a user's address
@Jpf.Action(
forwards = {
@Jpf.Forward(name = "success", action = "begin")
}
)
- protected Forward deleteAddress() throws DataStoreException,
InvalidIdentifierException, NoSuchAddressException
+ protected Forward deleteAddress() throws InvalidIdentifierException,
NoSuchAddressException
{
_sharedFlow.ensureLogin();
String addressId = getRequest().getParameter("addressId");
-
+ if (addressId == null)
+ throw new InvalidIdentifierException("AddressId not
passed in");
+
// Will only delete the address if the user owns it
_addressControl.deleteAddress(Integer.parseInt(addressId),
_sharedFlow.getAccount().getUserId());
Modified:
incubator/beehive/trunk/samples/petstoreWeb/account/create/Controller.jpf
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/account/create/Controller.jpf?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/petstoreWeb/account/create/Controller.jpf
(original)
+++ incubator/beehive/trunk/samples/petstoreWeb/account/create/Controller.jpf
Sat Apr 30 14:28:13 2005
@@ -30,7 +30,6 @@
import org.apache.beehive.samples.petstore.controller.AccountController;
import org.apache.beehive.samples.petstore.controls.AccountControl;
import org.apache.beehive.samples.petstore.controls.CatalogControl;
-import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import
org.apache.beehive.samples.petstore.controls.exceptions.NoSuchAccountException;
import
org.apache.beehive.samples.petstore.controls.exceptions.InvalidIdentifierException;
import
org.apache.beehive.samples.petstore.controls.exceptions.AccountAlreadyExistsException;
@@ -105,7 +104,7 @@
validationErrorForward = @Jpf.Forward(name = "failure", navigateTo
= Jpf.NavigateTo.currentPage)
)
protected Forward createAccount(CreateAccountForm form)
- throws AccountAlreadyExistsException, InvalidIdentifierException,
UserAlreadyExistsException, NoSuchAccountException, DataStoreException {
+ throws AccountAlreadyExistsException, InvalidIdentifierException,
UserAlreadyExistsException, NoSuchAccountException {
// ensure unique user name
_isUsernameTaken = false;
if(_accountControl.checkAccountExists(form.getUserId())) {
Modified: incubator/beehive/trunk/samples/petstoreWeb/account/create/create.jsp
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/account/create/create.jsp?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/petstoreWeb/account/create/create.jsp
(original)
+++ incubator/beehive/trunk/samples/petstoreWeb/account/create/create.jsp Sat
Apr 30 14:28:13 2005
@@ -54,7 +54,6 @@
</td>
</tr>
</table>
- <!-- beehive-petstore:accountFields
categoryNames="${pageInput.accountFields}" languages="${pageInput.languages}"/
-->
<netui:span styleClass="boldlabel"
value="${bundle.default.accountInformation}"/>
<table class="tablegreen">
<tr class="rowyellow">
Modified:
incubator/beehive/trunk/samples/petstoreWeb/account/edit/Controller.jpf
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/account/edit/Controller.jpf?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/petstoreWeb/account/edit/Controller.jpf
(original)
+++ incubator/beehive/trunk/samples/petstoreWeb/account/edit/Controller.jpf Sat
Apr 30 14:28:13 2005
@@ -26,7 +26,6 @@
import org.apache.beehive.samples.petstore.model.*;
import org.apache.beehive.samples.petstore.controls.*;
-import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import
org.apache.beehive.samples.petstore.controls.exceptions.InvalidIdentifierException;
import
org.apache.beehive.samples.petstore.controls.exceptions.NoSuchAccountException;
import
org.apache.beehive.samples.petstore.controls.exceptions.NoSuchUserException;
@@ -98,7 +97,7 @@
validationErrorForward = @Jpf.Forward(name = "failure", navigateTo =
Jpf.NavigateTo.currentPage)
)
protected Forward updateAccount(UpdateAccountForm form)
- throws InvalidIdentifierException, NoSuchAccountException,
NoSuchUserException, DataStoreException
+ throws InvalidIdentifierException, NoSuchAccountException,
NoSuchUserException
{
_sharedFlow.ensureLogin();
@@ -121,7 +120,7 @@
})
}
)
- protected Forward listOrders() throws DataStoreException {
+ protected Forward listOrders() {
_sharedFlow.ensureLogin();
_orders =
_orderControl.getOrdersByUserId(_sharedFlow.getAccount().getUserId());
Modified: incubator/beehive/trunk/samples/petstoreWeb/auth/Controller.jpf
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/auth/Controller.jpf?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/petstoreWeb/auth/Controller.jpf (original)
+++ incubator/beehive/trunk/samples/petstoreWeb/auth/Controller.jpf Sat Apr 30
14:28:13 2005
@@ -22,7 +22,6 @@
import org.apache.beehive.netui.pageflow.Forward;
import org.apache.beehive.netui.pageflow.PageFlowController;
-import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import
org.apache.beehive.samples.petstore.controls.exceptions.InvalidIdentifierException;
import
org.apache.beehive.samples.petstore.controls.exceptions.NoSuchAccountException;
import org.apache.beehive.samples.petstore.forms.ReturnToForm;
@@ -71,7 +70,7 @@
}
)
protected Forward securityCheck(SecurityCheckForm form)
- throws DataStoreException, InvalidIdentifierException,
NoSuchAccountException
+ throws InvalidIdentifierException, NoSuchAccountException
{
_sharedFlow.handleLogin(form.getj_username());
Modified: incubator/beehive/trunk/samples/petstoreWeb/checkout/Controller.jpf
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/checkout/Controller.jpf?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/petstoreWeb/checkout/Controller.jpf
(original)
+++ incubator/beehive/trunk/samples/petstoreWeb/checkout/Controller.jpf Sat Apr
30 14:28:13 2005
@@ -23,7 +23,6 @@
import org.apache.beehive.samples.petstore.controls.AddressControl;
import org.apache.beehive.samples.petstore.controls.OrderControl;
-import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import
org.apache.beehive.samples.petstore.controls.exceptions.NoSuchOrderException;
import
org.apache.beehive.samples.petstore.controls.exceptions.InvalidIdentifierException;
import
org.apache.beehive.samples.petstore.controls.exceptions.OrderAlreadyExistsException;
@@ -74,7 +73,7 @@
[EMAIL PROTECTED](name="success", action="viewCreateOrder")
}
)
- protected Forward createNewOrder() throws DataStoreException
+ protected Forward createNewOrder()
{
_sharedFlow.ensureLogin();
@@ -104,7 +103,7 @@
)
}
)
- protected Forward viewCreateOrder() throws DataStoreException
+ protected Forward viewCreateOrder()
{
_sharedFlow.ensureLogin();
@@ -148,22 +147,15 @@
},
[EMAIL PROTECTED](name="failure",
navigateTo=Jpf.NavigateTo.currentPage)
)
- protected Forward viewConfirm(CheckoutForm orderForm) throws
InvalidIdentifierException, DataStoreException
+ protected Forward viewConfirm(CheckoutForm orderForm) throws
InvalidIdentifierException
{
_sharedFlow.ensureLogin();
- Address billingAddress = new Address();
- Address shippingAddress = new Address();
-
- billingAddress =
_addressControl.getAddress(orderForm.getOrder().getBillingAddress());
- shippingAddress =
_addressControl.getAddress(orderForm.getOrder().getShippingAddress());
-
Forward f = new Forward("confirm");
f.addActionOutput("order", _order);
f.addActionOutput("lineItems", _sharedFlow.getCart().getLineItems());
- f.addActionOutput("billingAddress", billingAddress);
- f.addActionOutput("shippingAddress", shippingAddress);
- f.addOutputForm(_orderForm);
+ f.addActionOutput("billingAddress",
_addressControl.getAddress(orderForm.getOrder().getBillingAddress()));
+ f.addActionOutput("shippingAddress",
_addressControl.getAddress(orderForm.getOrder().getShippingAddress()));
return f;
}
@@ -171,7 +163,7 @@
[EMAIL PROTECTED](name="success", action="viewOrder")}
)
protected Forward confirm()
- throws NoSuchOrderException, InvalidIdentifierException,
OrderAlreadyExistsException, DataStoreException
+ throws NoSuchOrderException, InvalidIdentifierException,
OrderAlreadyExistsException
{
_sharedFlow.ensureLogin();
@@ -204,7 +196,7 @@
})
}
)
- protected Forward viewOrder() throws NoSuchOrderException,
DataStoreException, InvalidIdentifierException
+ protected Forward viewOrder() throws NoSuchOrderException,
InvalidIdentifierException
{
_sharedFlow.ensureLogin();
@@ -240,7 +232,7 @@
return f;
}
- private LineItem[] getLineItems(int orderId) throws DataStoreException
+ private LineItem[] getLineItems(int orderId)
{
OrderItem[] orderItems =
_orderControl.getOrderItemsByOrderId(orderId);
LineItem[] lineItems = new LineItem[orderItems.length];
Modified: incubator/beehive/trunk/samples/petstoreWeb/search/Controller.jpf
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/search/Controller.jpf?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/petstoreWeb/search/Controller.jpf (original)
+++ incubator/beehive/trunk/samples/petstoreWeb/search/Controller.jpf Sat Apr
30 14:28:13 2005
@@ -24,7 +24,6 @@
import org.apache.beehive.samples.petstore.forms.SearchForm;
import org.apache.beehive.samples.petstore.model.Product;
import org.apache.beehive.samples.petstore.controls.CatalogControl;
-import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import org.apache.beehive.controls.api.bean.Control;
@Jpf.Controller(
@@ -52,7 +51,7 @@
})
}
)
- protected Forward begin(SearchForm form) throws DataStoreException {
+ protected Forward begin(SearchForm form) {
Product[] searchResults =
_catalogControl.searchProductList(form.getKeyword());
return new Forward("success", "searchResults", searchResults);
Modified: incubator/beehive/trunk/samples/petstoreWeb/shop/Controller.jpf
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/shop/Controller.jpf?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/petstoreWeb/shop/Controller.jpf (original)
+++ incubator/beehive/trunk/samples/petstoreWeb/shop/Controller.jpf Sat Apr 30
14:28:13 2005
@@ -27,7 +27,6 @@
import org.apache.beehive.netui.pageflow.annotations.Jpf;
import org.apache.beehive.samples.petstore.controls.CatalogControl;
-import
org.apache.beehive.samples.petstore.controls.exceptions.DataStoreException;
import
org.apache.beehive.samples.petstore.controls.exceptions.InvalidIdentifierException;
import org.apache.beehive.samples.petstore.model.Cart;
import org.apache.beehive.samples.petstore.model.Category;
@@ -85,7 +84,7 @@
})
}
)
- protected Forward begin() throws DataStoreException {
+ protected Forward begin() {
if(_categories == null)
_categories = _catalogControl.getCategoryList();
@@ -105,7 +104,7 @@
})
}
)
- protected Forward viewCategory() throws InvalidIdentifierException,
DataStoreException {
+ protected Forward viewCategory() throws InvalidIdentifierException {
String categoryId = getRequest().getParameter("catId");
if(categoryId == null || categoryId.equals(""))
@@ -133,7 +132,7 @@
})
}
)
- protected Forward viewProduct() throws InvalidIdentifierException,
DataStoreException {
+ protected Forward viewProduct() throws InvalidIdentifierException {
String productId = getRequest().getParameter("productId");
if(productId == null || productId.equals(""))
@@ -161,7 +160,7 @@
})
}
)
- protected Forward viewItem() throws InvalidIdentifierException,
DataStoreException {
+ protected Forward viewItem() throws InvalidIdentifierException {
String itemId = getRequest().getParameter("itemId");
if(itemId == null || itemId.equals(""))
@@ -187,7 +186,7 @@
}),
@Jpf.Forward(name="cart", path="cart.jsp")
})
- protected Forward addItemToCart(CartForm form) throws
InvalidIdentifierException, DataStoreException {
+ protected Forward addItemToCart(CartForm form) throws
InvalidIdentifierException {
Cart cart = form.getCart();
if (cart.containsItemId(form.getWorkingItemId()))
{
Modified: incubator/beehive/trunk/samples/petstoreWeb/webappRoot/SharedFlow.jpfs
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/petstoreWeb/webappRoot/SharedFlow.jpfs?rev=165419&r1=165418&r2=165419&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/petstoreWeb/webappRoot/SharedFlow.jpfs
(original)
+++ incubator/beehive/trunk/samples/petstoreWeb/webappRoot/SharedFlow.jpfs Sat
Apr 30 14:28:13 2005
@@ -40,7 +40,8 @@
catches={
@Jpf.Catch(method="handlePageFlowException",
type=PageFlowException.class),
@Jpf.Catch(method="handleException", type=Exception.class),
- @Jpf.Catch(method="handleNotLoggedInException",
type=NotLoggedInException.class)
+ @Jpf.Catch(method="handleNotLoggedInException",
type=NotLoggedInException.class),
+ @Jpf.Catch(method="handleDataStoreException",
type=DataStoreException.class)
},
simpleActions={
@Jpf.SimpleAction(name="signoff", path="/auth/logout.do"),
@@ -69,7 +70,7 @@
private Cart _cart = null;
private Product[] _myList;
- protected void onCreate() throws DataStoreException {
+ protected void onCreate() {
// todo: move to ServletContext so it's cached for all users
Category[] categories = _catalogControl.getCategoryList();
@@ -90,7 +91,7 @@
throw new NotLoggedInException("User not logged in", this);
}
- public void handleLogin(String username) throws DataStoreException,
NoSuchAccountException, InvalidIdentifierException {
+ public void handleLogin(String username) throws NoSuchAccountException,
InvalidIdentifierException {
Account account = _accountControl.getAccount(username);
// Throw an exception if the user is not found
@@ -119,7 +120,7 @@
}
public void updateAccount(Account account)
- throws InvalidIdentifierException, NoSuchAccountException,
DataStoreException {
+ throws InvalidIdentifierException, NoSuchAccountException {
// update account info in globalApp
_account = account;
@@ -247,13 +248,24 @@
@Jpf.ExceptionHandler(
forwards={
- @Jpf.Forward(name="login", path="actionSignon.do")
+ @Jpf.Forward(name="errorPage", path="/error.jsp")
}
)
- protected Forward handleNotLoggedInException(NotLoggedInException ex,
String actionName, String message, Object form) {
- return new Forward("login");
+ protected Forward handleDataStoreException(DataStoreException ex, String
actionName, String message, Object form) {
+ System.err.print("[" + getRequest().getContextPath() + "] ");
+ System.err.println("DataStore exception caught in SharedFlow.jpfs:");
+ ex.printStackTrace();
+ return new Forward("errorPage");
}
+ @Jpf.ExceptionHandler(
+ [EMAIL PROTECTED](name="auth", path="/auth/Controller.jpf")}
+ )
+ protected Forward handleNotLoggedInException(NotLoggedInException ex,
String actionName, String message, Object form) {
+ ReturnToForm initForm = new ReturnToForm(true);
+ return new Forward("auth", initForm);
+ }
+
@Jpf.ExceptionHandler()
public Forward handlePageFlowException(PageFlowException ex, String
message, String action, Object form)
throws java.io.IOException {