From: camjan Date: Wed, 20 May 2015 16:46:45 +0000 (+0200) Subject: Merge branch 'master' of https://xp-dev.com/git/RRRRHHHH_Code X-Git-Url: https://xp-dev.com/git/RRRRHHHH_Code/commitdiff_plain/b09f345318baa9ca734e11c87f52f8522d7cc1fb?hp=ccac9974c8183f7f0d30e8cabd84ee0386e8cd97 Merge branch 'master' of https://xp-dev.com/git/RRRRHHHH_Code --- diff --git a/ruralHouses/src/businessLogic/AccountManager.java b/ruralHouses/src/businessLogic/AccountManager.java index 705ef27..0ad55b1 100644 --- a/ruralHouses/src/businessLogic/AccountManager.java +++ b/ruralHouses/src/businessLogic/AccountManager.java @@ -6,20 +6,20 @@ import java.rmi.server.UnicastRemoteObject; import javax.mail.MessagingException; import common.AccountInterface; - import dataAccess.DB4oManager; import domain.Account; import domain.Administrator; +import domain.Owner; + +public class AccountManager extends UnicastRemoteObject implements + AccountInterface { -public class AccountManager extends UnicastRemoteObject implements AccountInterface { - /** * */ private static final long serialVersionUID = 1L; private DB4oManager dbMngr; - - + public AccountManager() throws RemoteException { try { dbMngr = DB4oManager.getInstance(); @@ -28,30 +28,39 @@ public class AccountManager extends UnicastRemoteObject implements AccountInterf e.printStackTrace(); } } - + public boolean addAccount(int index) throws RemoteException { - Account ac = Administrator.getInstance().getNewOwnerRequest().get(index); - if(this.dbMngr.addAccount(ac)){ + Account ac = Administrator.getInstance().getNewOwnerRequest() + .get(index); + if (this.dbMngr.addAccount(ac)) { try { - MailManager.getInstance().Send(ac.getOwner().getMailAccount(), "Entered into the system", "Congratulations"); + MailManager.getInstance().Send(ac.getOwner().getMailAccount(), + "Entered into the system", "Congratulations"); } catch (MessagingException e) { e.printStackTrace(); } return true; - } + } return false; - + } - - public boolean removeAccount(int index)throws RemoteException { + + public boolean removeAccount(int index) throws RemoteException { AdminManager adm = new AdminManager(); + Owner own = adm.getAllOwners().get(index); try { - if(this.dbMngr.removeAccount(adm.getAllOwners().get(index))) + if (this.dbMngr.removeAccount(own)) { + try { + MailManager.getInstance().Send(own.getMailAccount(), "Removed from the system", "We are sorry"); + } catch (MessagingException e) { + e.printStackTrace(); + } return true; + } } catch (Exception e) { e.printStackTrace(); } return false; - + } } diff --git a/ruralHouses/src/businessLogic/BookingManager.java b/ruralHouses/src/businessLogic/BookingManager.java index 138484b..356d3ba 100644 --- a/ruralHouses/src/businessLogic/BookingManager.java +++ b/ruralHouses/src/businessLogic/BookingManager.java @@ -41,6 +41,11 @@ public final class BookingManager extends UnicastRemoteObject implements Booking public void denyBooking(Booking b) throws RemoteException{ this.dbMngr.removeBooking(b); + try { + MailManager.getInstance().Send(b.getClient().getMailAccount(), "Your booking has not been accepted","We are sorry"); + } catch (MessagingException e) { + e.printStackTrace(); + } }