smartticketfacadebean.java
来自「SUN公司发布的SmartTicket 2.0蓝图」· Java 代码 · 共 462 行 · 第 1/2 页
JAVA
462 行
||!account.getPassword().equals(password)) { try { AccountLocal account = (AccountLocal) accountHome.findByPrimaryKey(userName); if (account.getPassword().equals(password)) { this.account = account; try { ticketing = ticketingHome.create(account); synchronizing = synchronizingHome.create(account); return; } catch (CreateException ce) { this.account = null; ticketing = null; synchronizing = null; throw new EJBException("SmartTicketFacadeBean.login: " + ce.getMessage()); } } throw new SmartTicketFacadeException("Incorrect password."); } catch (FinderException fe) { throw new SmartTicketFacadeException("No such user."); } } } public void createAccount(String userName, String password, String firstName, String lastName, String zipCode, String eMail, String creditCardHolderName, String CreditCardNumber, String creditCardExpirationDate, String creditCardType, String smscAddress) throws SmartTicketFacadeException { try { account = accountHome.create(userName, password); account.setFirstName(firstName); account.setLastName(lastName); account.setZipCode(zipCode); account.setEMail(eMail); account.setCreditCardNumber(CreditCardNumber); account.setCreditCardHolderName(creditCardHolderName); account.setCreditCardExpirationDate(creditCardExpirationDate); account.setCreditCardType(creditCardType); account.setSMSCAddress(smscAddress); ticketing = ticketingHome.create(account); synchronizing = synchronizingHome.create(account); return; } catch (CreateException ce) { ticketing = null; synchronizing = null; throw new SmartTicketFacadeException("Account creation error."); } } public void updateAccount(String userName, String password, String firstName, String lastName, String zipCode, String eMail, String creditCardHolderName, String CreditCardNumber, String creditCardExpirationDate, String creditCardType, String smscAddress) throws SmartTicketFacadeException { if (account != null && account.getUserName().equals(userName)) { account.setPassword(password); account.setFirstName(firstName); account.setLastName(lastName); account.setZipCode(zipCode); account.setEMail(eMail); account.setCreditCardNumber(CreditCardNumber); account.setCreditCardHolderName(creditCardHolderName); account.setCreditCardExpirationDate(creditCardExpirationDate); account.setCreditCardType(creditCardType); account.setSMSCAddress(smscAddress); return; } throw new SmartTicketFacadeException("User not logged in."); } public TheaterLocal[] getTheaters(String zipCode) throws SmartTicketFacadeException { try { return (TheaterLocal[]) new ArrayList(theaterHome.findByZipCode(zipCode)).toArray(new TheaterLocal[0]); } catch (FinderException fe) { throw new SmartTicketFacadeException("No matching theaters."); } } public MovieScheduleLocal[] getMovieSchedules(String theaterId) throws SmartTicketFacadeException { try { return (MovieScheduleLocal[]) new ArrayList(theaterHome.findByPrimaryKey(theaterId).getSchedule().getMovieSchedules()).toArray(new MovieScheduleLocal[0]); } catch (FinderException fe) { throw new SmartTicketFacadeException("No matching movie schedules."); } } public MovieLocal getMovie(String movieId) throws SmartTicketFacadeException { try { return movieHome.findByPrimaryKey(movieId); } catch (FinderException fe) { throw new SmartTicketFacadeException("No matching movie."); } } public ShowTimePattern[] getMovieShowTimes(String theaterId, String movieId) throws SmartTicketFacadeException { try { return movieScheduleHome.findByPrimaryKey(new MovieSchedulePK(theaterId, movieId)).getShowTimePatterns(); } catch (FinderException fe) { throw new SmartTicketFacadeException("No matching movie schedule."); } } public Seating getSeating(String theaterId, String movieId, ShowTime showTime) throws SmartTicketFacadeException { try { return movieScheduleHome.findByPrimaryKey(new MovieSchedulePK(theaterId, movieId)).getShow(showTime).getSeating(); } catch (FinderException fe) { throw new SmartTicketFacadeException("No matching movie show."); } } public ReservationData reserveSeats(String theaterId, String movieId, ShowTime showTime, Seat[] seats) throws SmartTicketFacadeException { if (ticketing != null) { return ticketing.reserveSeats(theaterId, movieId, showTime, seats); } throw new SmartTicketFacadeException("User not logged in."); } public void purchaseTickets(String reservationId) throws SmartTicketFacadeException { if (ticketing != null) { ticketing.purchaseTickets(reservationId); return; } throw new SmartTicketFacadeException("User not logged in."); } public void cancelSeatReservation(String reservationId) throws SmartTicketFacadeException { if (ticketing != null) { ticketing.cancelSeatReservation(reservationId); return; } throw new SmartTicketFacadeException("User not logged in."); } public SyncClientAnchor initiateSynchronization(SyncClientAnchor syncClientAnchor, long clientTime) throws SmartTicketFacadeException { if (synchronizing != null) { return synchronizing.initiateSynchronization(syncClientAnchor, clientTime); } throw new SmartTicketFacadeException("User not logged in."); } public MovieRatingData[] synchronizeMovieRatings(MovieRatingData[] movieRatings, int conflictResolutionStrategyId) throws SmartTicketFacadeException { if (synchronizing != null) { return synchronizing.synchronizeMovieRatings(movieRatings, conflictResolutionStrategyId); } throw new SmartTicketFacadeException("User not logged in."); } public MovieRatingData[] commitMovieRatings(MovieRatingData[] movieRatings) throws SmartTicketFacadeException { if (synchronizing != null) { return synchronizing.commitMovieRatings(movieRatings); } throw new SmartTicketFacadeException("User not logged in."); } public MovieRatingLocal[] getMovieRatings() throws SmartTicketFacadeException { if (account != null) { return (MovieRatingLocal[]) new ArrayList(account.getMovieRatings()).toArray(new MovieRatingLocal[0]); } throw new SmartTicketFacadeException("User not logged in."); } public MovieRatingLocal getMovieRating(String movieId) throws SmartTicketFacadeException { if (account != null) { return account.getMovieRating(movieId); } throw new SmartTicketFacadeException("User not logged in."); } public String getSMSCAddress(String userName) throws SmartTicketFacadeException { try { AccountLocal account = (AccountLocal) accountHome.findByPrimaryKey(userName); return account.getSMSCAddress(); } catch (FinderException fe) { throw new SmartTicketFacadeException("No such user."); } } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?