diff options
Diffstat (limited to 'tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient')
12 files changed, 0 insertions, 984 deletions
diff --git a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java b/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java deleted file mode 100644 index 7de9658d34..0000000000 --- a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * 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. - */ -package bigbank.webclient.services.account; - -import java.rmi.RemoteException; - -import org.osoa.sca.ServiceUnavailableException; -import org.osoa.sca.annotations.Reference; -import org.osoa.sca.annotations.Service; - -import com.bigbank.account.AccountReport; -import com.bigbank.account.AccountService; -import com.bigbank.account.CustomerProfileData; -import com.bigbank.account.StockSummary; - -/** - */ -@Service(AccountService.class) -public class AccountServiceComponentImpl implements AccountService { - - private AccountService accountService; - - @Reference - public void setAccountService(AccountService accountService) { - this.accountService = accountService; - } - - /** - * - */ - public AccountServiceComponentImpl() { - super(); - } - - /** - * @see bigbank.account.services.account.AccountService#getAccountReport(java.lang.String) - */ - public AccountReport getAccountReport(int customerID) { - try { - return accountService.getAccountReport(customerID); - } catch (Exception e) { - throw new ServiceUnavailableException(e); - } - } - - public StockSummary purchaseStock(int customerID, StockSummary stockSummary) throws RemoteException { - try { - return accountService.purchaseStock(customerID, stockSummary); - } catch (Exception e) { - throw new ServiceUnavailableException(e); - } - } - - public CustomerProfileData getCustomerProfile(String param2) throws RemoteException { - try { - return accountService.getCustomerProfile(param2); - } catch (Exception e) { - throw new ServiceUnavailableException(e); - } - } - - public float deposit(String account, float amount) throws RemoteException { - try { - return accountService.deposit(account, amount); - } catch (Exception e) { - throw new ServiceUnavailableException(e); - } - } - - public StockSummary sellStock(int purchaseLotNumber, int quantity) throws RemoteException { - try { - return accountService.sellStock(purchaseLotNumber, quantity); - } catch (Exception e) { - throw new ServiceUnavailableException(e); - } - } - - public float withdraw(String account, float amount) throws RemoteException { - try { - return accountService.withdraw(account, amount); - } catch (Exception e) { - throw new ServiceUnavailableException(e); - } - } - - public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings) - throws RemoteException { - - return accountService.createAccount(customerProfile, createSavings, createCheckings); - } - -} diff --git a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java b/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java deleted file mode 100644 index 0de0ef85c3..0000000000 --- a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.
- */
-package bigbank.webclient.services.profile;
-
-import java.rmi.RemoteException;
-
-import org.osoa.sca.annotations.Reference;
-import org.osoa.sca.annotations.Service;
-
-import com.bigbank.account.AccountService;
-import com.bigbank.account.CustomerProfileData;
-
-@Service(LoginService.class)
-public class AccountLoginServiceImpl implements LoginService {
- @Reference
- public AccountService accountService;
-
- @Reference
- public ProfileService profileService;
-
- public int login(String userName, String password) throws RemoteException {
-
- CustomerProfileData profileData = accountService.getCustomerProfile(userName);
-
- if (!password.equals(profileData.getPassword())) {
- return INVALID_PASSWORD;
- }
-
- profileService.setLoggedIn(true);
- profileService.setFirstName(profileData.getFirstName());
- profileService.setLastName(profileData.getLastName());
- profileService.setId(profileData.getId());
-
- return SUCCESS;
- }
-}
diff --git a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java b/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java deleted file mode 100644 index 465c1b3e7e..0000000000 --- a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * 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. - */ -package bigbank.webclient.services.profile; - -import java.rmi.RemoteException; - -public interface LoginService { - - public static final int SUCCESS = 1; - - public static final int INVALID_LOGIN = -1; - - public static final int INVALID_PASSWORD = -2; - - public int login(String userName, String password) throws RemoteException; -} diff --git a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileService.java b/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileService.java deleted file mode 100644 index 2cbfbf489a..0000000000 --- a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileService.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * 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. - */ -package bigbank.webclient.services.profile; - -public interface ProfileService { - - public String getFirstName(); - - public void setFirstName(String pName); - - public String getLastName(); - - public void setLastName(String pName); - - public boolean isLoggedIn(); - - public void setLoggedIn(boolean pStatus); - - public int getId(); - - public void setId(int pId); -} diff --git a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java b/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java deleted file mode 100644 index 4ae808f31a..0000000000 --- a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * 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. - */ -package bigbank.webclient.services.profile; - -import org.osoa.sca.annotations.Property; -import org.osoa.sca.annotations.Scope; -import org.osoa.sca.annotations.Service; - -@Service(ProfileService.class) -@Scope("session") -public class ProfileServiceImpl implements ProfileService { - - private String firstName; - - public String getFirstName() { - return firstName; - } - - @Property - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - private String lastName; - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - private boolean loggedIn; - - public boolean isLoggedIn() { - return loggedIn; - } - - public void setLoggedIn(boolean status) { - loggedIn = status; - } - - private int id; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } -} diff --git a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/SimpleLoginServiceImpl.java b/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/SimpleLoginServiceImpl.java deleted file mode 100644 index a8d57fb506..0000000000 --- a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/SimpleLoginServiceImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * 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. - */ -package bigbank.webclient.services.profile; - -import org.osoa.sca.annotations.Reference; -import org.osoa.sca.annotations.Service; - -@Service(LoginService.class) -public class SimpleLoginServiceImpl implements LoginService { - - public ProfileService profileService; - - @Reference - public void setProfileService(ProfileService profileService) { - this.profileService = profileService; - } - - public int login(String userName, String password) { - - if (!"test".equals(userName)) { - return INVALID_LOGIN; - } - - if (!"password".equals(password)) { - return INVALID_PASSWORD; - } - - profileService.setLoggedIn(true); - profileService.setFirstName("John"); - profileService.setLastName("Doe"); - profileService.setId(12345); - - return SUCCESS; - } -} diff --git a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java b/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java deleted file mode 100644 index c11d3f9e46..0000000000 --- a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * 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. - */ -package bigbank.webclient.tags.account; - -import java.util.Iterator; -import java.util.List; - -import javax.servlet.jsp.JspException; -import javax.servlet.jsp.tagext.TagSupport; - -import org.osoa.sca.CurrentModuleContext; -import org.osoa.sca.ModuleContext; - -import bigbank.webclient.services.profile.ProfileService; - -import com.bigbank.account.AccountReport; -import com.bigbank.account.AccountService; - -/** - * Retrieves and iterates over account summary information for the current profile by accessing the remotable account service component - */ - -public class AccountStatusTag extends TagSupport { - - // ---------------------------------- - // Constructors - // ---------------------------------- - - public AccountStatusTag() { - super(); - } - - // ---------------------------------- - // Methods - // ---------------------------------- - - private String mAccountService; - - public String getAccountService() { - return mAccountService; - } - - public void setAccountService(String pAccountService) { - mAccountService = pAccountService; - } - - private String mProfileService; - - public String getProfileService() { - return mProfileService; - } - - public void setProfileService(String pProfileService) { - mProfileService = pProfileService; - } - - private String mId; - - public String getId() { - return mId; - } - - public void setId(String pId) { - mId = pId; - } - - private Iterator mIterator; - - public int doStartTag() throws JspException { - ModuleContext moduleContext = CurrentModuleContext.getContext(); - ProfileService profile = (ProfileService) moduleContext.locateService(mProfileService); - if (profile == null) { - throw new JspException("Profile [" + mProfileService + "] not found in current module context"); - } - - AccountService service = (AccountService) moduleContext.locateService(mAccountService); - if (service == null) { - throw new JspException("Service [" + mAccountService + "] not found in current module context"); - } - List summaries; - try { - AccountReport accountReport = service.getAccountReport(profile.getId()); - pageContext.setAttribute("StockSummaries", accountReport.getStockSummaries()); - summaries = accountReport.getAccountSummaries(); - } catch (Exception e) { - throw new JspException(e); - } - mIterator = summaries.iterator(); - if (mIterator.hasNext()) { - pageContext.setAttribute(mId, mIterator.next()); - return EVAL_BODY_INCLUDE; - } else { - return SKIP_BODY; - } - } - - public int doAfterBody() { - if (mIterator.hasNext()) { - pageContext.setAttribute(mId, mIterator.next()); - return EVAL_BODY_AGAIN; - } else { - return SKIP_BODY; - } - } - - public void release() { - super.release(); - mId = null; - mIterator = null; - } -}
\ No newline at end of file diff --git a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java b/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java deleted file mode 100644 index ac0b5f4467..0000000000 --- a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java +++ /dev/null @@ -1,79 +0,0 @@ -/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.
- */
-package bigbank.webclient.tags.account;
-
-import java.util.Iterator;
-import java.util.List;
-
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.tagext.TagSupport;
-
-/**
- * Retrieves and iterates over account summary information for the current profile by accessing the remotable account service component
- */
-
-public class StockStatusTag extends TagSupport {
-
-
- public StockStatusTag() {
- super();
- }
-
-
- private String mId;
-
- public String getId() {
- return mId;
- }
-
- public void setId(String pId) {
- mId = pId;
- }
-
- private Iterator mIterator;
-
- public int doStartTag() throws JspException {
-
- List summaries = (List) pageContext.getAttribute("StockSummaries");
- if (null == summaries)
- return SKIP_BODY;
- mIterator = summaries.iterator();
- if (mIterator.hasNext()) {
- pageContext.setAttribute(mId, mIterator.next());
- return EVAL_BODY_INCLUDE;
- } else {
- return SKIP_BODY;
- }
- }
-
- public int doAfterBody() {
- if (mIterator.hasNext()) {
- pageContext.setAttribute(mId, mIterator.next());
- return EVAL_BODY_AGAIN;
- } else {
- pageContext.setAttribute("StockSummaries", null);
- return SKIP_BODY;
- }
- }
-
- public void release() {
- pageContext.setAttribute("StockSummaries", null);
- super.release();
- mId = null;
- mIterator = null;
- }
-}
\ No newline at end of file diff --git a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java b/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java deleted file mode 100644 index e923596bae..0000000000 --- a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * 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. - */ -package bigbank.webclient.tags.sca; - -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.jsp.JspException; -import javax.servlet.jsp.tagext.TagSupport; - -import org.osoa.sca.CurrentModuleContext; -import org.osoa.sca.ModuleContext; - -import bigbank.webclient.services.profile.ProfileService; - -public class LoginBarrierTag extends TagSupport { - - public LoginBarrierTag() { - super(); - } - - private String mProfile; - - public String getProfile() { - return mProfile; - } - - public void setProfile(String pProfile) { - mProfile = pProfile; - } - - private String mUrl; - - public String getUrl() { - return mUrl; - } - - public void setUrl(String pUrl) { - mUrl = pUrl; - } - - int doPage = EVAL_PAGE; - - - public int doStartTag() throws JspException { - if (mProfile == null || mProfile.length() < 1) { - throw new JspException("Invalid profile location specified"); - } - - ModuleContext moduleContext = CurrentModuleContext.getContext(); - - ProfileService profile = (ProfileService) moduleContext.locateService(mProfile); - - if (profile == null) { - throw new JspException("Profile [" + mProfile + "] not found in current module context"); - } - - if (profile.isLoggedIn()) { - return EVAL_BODY_INCLUDE; - } else { - try { - doPage = SKIP_PAGE; - pageContext.forward(mUrl); - ((HttpServletResponse) (pageContext.getResponse())).sendRedirect("login.html"); - return SKIP_BODY; - } catch (ServletException e) { - throw new JspException("Unable to forward to [" + mUrl + "]"); - } catch (IOException e) { - throw new JspException("Unable to forward to [" + mUrl + "]"); - } - } - } - - public int doEndTag() throws JspException { - return doPage; - } - - public void release() { - super.release(); - } - -} diff --git a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java b/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java deleted file mode 100644 index 1fa4252c0c..0000000000 --- a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * 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. - */ -package bigbank.webclient.tags.sca; - -import javax.servlet.jsp.JspException; -import javax.servlet.jsp.tagext.TagSupport; - -import org.osoa.sca.CurrentModuleContext; -import org.osoa.sca.ModuleContext; - -/** - * Places an SCA service in the JSP page context, making it available to other tags corresponding to its id value. - */ - -public class ServiceTag extends TagSupport { - - // ---------------------------------- - // Constructors - // ---------------------------------- - - public ServiceTag() { - super(); - } - - // ---------------------------------- - // Methods - // ---------------------------------- - - private String mName; - - /** - * Returns the name of the SCA service to import into the page context. - */ - public String getName() { - return mName; - } - - /** - * Sets name of the SCA service to import into the page context. - */ - public void setName(String pName) { - mName = pName; - } - - private String mId; - - /** - * Returns the id of the service in the page context - */ - public String getId() { - return mId; - } - - /** - * Sets the id of the service for the page context - */ - - public void setId(String pId) { - mId = pId; - } - - public int doStartTag() throws JspException { - ModuleContext moduleContext = CurrentModuleContext.getContext(); - Object service = moduleContext.locateService(mName); - if (service == null) { - throw new JspException("Service [" + mName + "] not found in current module context"); - } - if (mId == null) { - // if the Id name was not specified, default to the basic name of the - // service - mId = mName; - } - pageContext.setAttribute(mId, service); - return EVAL_BODY_INCLUDE; - } - - public int doEndTag() throws JspException { - return EVAL_PAGE; - } - - public void release() { - super.release(); - } -}
\ No newline at end of file diff --git a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java b/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java deleted file mode 100644 index bad6d370b0..0000000000 --- a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java +++ /dev/null @@ -1,156 +0,0 @@ -/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * 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.
- */
-package bigbank.webclient.ui;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.osoa.sca.CurrentModuleContext;
-import org.osoa.sca.ModuleContext;
-
-import bigbank.webclient.services.profile.ProfileService;
-
-import com.bigbank.account.AccountFactory;
-import com.bigbank.account.AccountService;
-import com.bigbank.account.CustomerProfileData;
-import com.bigbank.account.StockSummary;
-
-public class FormServlet extends HttpServlet {
-
- // private ServletContext mContext;
- // public void init(ServletConfig pCfg) throws ServletException {
- // mContext = pCfg.getServletContext();
- // }
-
- public void doPost(HttpServletRequest pReq, HttpServletResponse pResp) throws ServletException {
-
- try {
- final String action = pReq.getParameter("action");
- ModuleContext moduleContext = CurrentModuleContext.getContext();
- AccountService accountServices = (AccountService) moduleContext.locateService("AccountServiceComponent");
- if (accountServices == null) {
- throw new ServletException("AccountServiceComponent");
- }
- ProfileService profileServices = null;
- if (!"createAccount".equals(action)) {
- profileServices = (ProfileService) moduleContext.locateService("ProfileServiceComponent");
- if (profileServices == null) {
- throw new ServletException("ProfileServiceComponent not found.");
- }
- if (!profileServices.isLoggedIn()) {
- throw new ServletException("User id '" + profileServices.getId() + "' not logged on.");
- }
- }
-
- if ("createAccount".equals(action)) {
- createAccount(pReq, pResp, accountServices);
- } else if ("account".equals(action)) {
- accountTransaction(pReq, pResp, accountServices);
- } else if ("stockPurchase".equals(action)) {
- stockPurchase(pReq, pResp, profileServices, accountServices);
- } else if ("stockSale".equals(action)) {
- stockSale(pReq, pResp, profileServices, accountServices);
- } else {
- throw new IllegalArgumentException("Unknown action in Form servlet '" + action + "'.");
- }
- // mContext.getRequestDispatcher("summary.jsp").forward(pReq, pResp);
- pResp.sendRedirect("summary.jsp");
- } catch (ServletException e) {
- e.printStackTrace();
- throw e;
-
- } catch (Exception e) {
-
- throw new ServletException(e);
- }
-
- }
-
- private void stockSale(HttpServletRequest req, HttpServletResponse resp, ProfileService profileServices, AccountService accountServices)
- throws ServletException {
- try {
- if (!"cancel".equals(req.getParameter("cancel"))) {
-
- int quantity = Integer.parseInt(req.getParameter("quantity"));
- int purchaseLotNumber = Integer.parseInt(req.getParameter("purchaseLotNumber"));
- accountServices.sellStock(purchaseLotNumber, quantity);
- }
-
- } catch (Exception e) {
-
- throw new ServletException("stockSale " + e.getMessage(), e);
- }
-
- }
-
- private void stockPurchase(HttpServletRequest req, HttpServletResponse resp, ProfileService profileServices, AccountService accountServices)
- throws ServletException {
- try {
- if (!"cancel".equals(req.getParameter("cancel"))) {
-
- String symbol = req.getParameter("symbol").trim().toUpperCase();
- int quantity = Integer.parseInt(req.getParameter("quantity"));
- StockSummary stockSummry = AccountFactory.INSTANCE.createStockSummary();
- stockSummry.setSymbol(symbol);
- stockSummry.setQuantity(quantity);
- accountServices.purchaseStock(profileServices.getId(), stockSummry);
- }
- } catch (Exception e) {
- throw new ServletException("stockPurchase " + e.getMessage(), e);
- }
- }
-
- private void accountTransaction(HttpServletRequest req, HttpServletResponse resp, AccountService accountServices) throws ServletException {
- try {
- if (!"cancel".equals(req.getParameter("cancel"))) {
- String account = req.getParameter("account");
- String amount = req.getParameter("Amount");
- if ("deposit".equals(req.getParameter("actionType")))
- accountServices.deposit(account, Float.parseFloat(amount));
- else
- accountServices.withdraw(account, Float.parseFloat(amount));
- }
- } catch (Exception e) {
- throw new ServletException("accountTransaction " + e.getMessage(), e);
- }
-
- }
-
- private void createAccount(HttpServletRequest pReq, HttpServletResponse pResp, AccountService accountServices) throws ServletException {
- try {
- CustomerProfileData customerProfileData = AccountFactory.INSTANCE.createCustomerProfileData();
- customerProfileData.setFirstName(pReq.getParameter("firstName"));
- customerProfileData.setLastName(pReq.getParameter("lastName"));
- customerProfileData.setAddress(pReq.getParameter("address"));
- customerProfileData.setEmail(pReq.getParameter("email"));
- customerProfileData.setLoginID(pReq.getParameter("loginID"));
- customerProfileData.setPassword(pReq.getParameter("password"));
-
- CustomerProfileData resp = accountServices.createAccount(customerProfileData, "savings".equals(pReq.getParameter("savings")), "checkings"
- .equals(pReq.getParameter("checkings")));
- LoginServlet.login(resp.getLoginID(), resp.getPassword());
-
- } catch (IOException e) {
- throw new ServletException(e);
- }
-
- }
-}
diff --git a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java b/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java deleted file mode 100644 index 886f42a778..0000000000 --- a/tags/java-M1-final/java/sampleapps/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * 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. - */ -package bigbank.webclient.ui; - -import java.io.IOException; -import java.rmi.RemoteException; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.osoa.sca.CurrentModuleContext; -import org.osoa.sca.ModuleContext; - -import bigbank.webclient.services.profile.LoginService; - -public class LoginServlet extends HttpServlet { - - public void init(ServletConfig pCfg) throws ServletException { - - } - - public void doPost(HttpServletRequest pReq, HttpServletResponse pResp) throws ServletException { - - if ("logout".equals(pReq.getParameter("logout")) || "logoutHIDDEN".equals(pReq.getParameter("logoutHIDDEN"))) { - HttpSession sess = pReq.getSession(); - if (sess != null) - sess.invalidate(); - try { - pResp.sendRedirect("login.html"); - } catch (IOException e) { - - e.printStackTrace(); - throw new ServletException(e); - } - - } else { - - String login = pReq.getParameter("login"); - String password = pReq.getParameter("password"); - try { - int resp = login(login, password); - if (resp == LoginService.SUCCESS) { - - pResp.sendRedirect("summary.jsp"); - } else { - - pResp.sendRedirect("login.html"); - } - } catch (IOException e) { - throw new ServletException(e); - } - } - } - - static int login(final String login, final String password) throws ServletException { - - ModuleContext moduleContext = CurrentModuleContext.getContext(); - LoginService loginMgr = (LoginService) moduleContext.locateService("LoginServiceComponent"); - - if (loginMgr == null) { - throw new ServletException("LoginManager not found"); - } - - try { - return loginMgr.login(login, password); - } catch (RemoteException e) { - - throw new ServletException(e); - } - - } - -} |