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();
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;
-
+
}
}