RRRRHHHH_Code
Diff Revisions
3a0296 ...
vs
1cf395 ...
for ruralHouses/src/businessLogic/AccountManager.java
|
@@ -6,20 +6,20 @@ |
6 |
6 |
|
import javax.mail.MessagingException; |
7 |
7 |
|
|
8 |
8 |
|
import common.AccountInterface; |
9 |
|
- |
|
10 |
9 |
|
import dataAccess.DB4oManager; |
11 |
10 |
|
import domain.Account; |
12 |
11 |
|
import domain.Administrator; |
|
12 |
+ |
import domain.Owner; |
|
13 |
+ |
|
|
14 |
+ |
public class AccountManager extends UnicastRemoteObject implements |
|
15 |
+ |
AccountInterface { |
13 |
16 |
|
|
14 |
|
- |
public class AccountManager extends UnicastRemoteObject implements AccountInterface { |
15 |
|
- |
|
16 |
17 |
|
/** |
17 |
18 |
|
* |
18 |
19 |
|
*/ |
19 |
20 |
|
private static final long serialVersionUID = 1L; |
20 |
21 |
|
private DB4oManager dbMngr; |
21 |
|
- |
|
22 |
|
- |
|
|
22 |
+ |
|
23 |
23 |
|
public AccountManager() throws RemoteException { |
24 |
24 |
|
try { |
25 |
25 |
|
dbMngr = DB4oManager.getInstance(); |
|
@@ -28,30 +28,39 @@ |
28 |
28 |
|
e.printStackTrace(); |
29 |
29 |
|
} |
30 |
30 |
|
} |
31 |
|
- |
|
|
31 |
+ |
|
32 |
32 |
|
public boolean addAccount(int index) throws RemoteException { |
33 |
|
- |
Account ac = Administrator.getInstance().getNewOwnerRequest().get(index); |
34 |
|
- |
if(this.dbMngr.addAccount(ac)){ |
|
33 |
+ |
Account ac = Administrator.getInstance().getNewOwnerRequest() |
|
34 |
+ |
.get(index); |
|
35 |
+ |
if (this.dbMngr.addAccount(ac)) { |
35 |
36 |
|
try { |
36 |
|
- |
MailManager.getInstance().Send(ac.getOwner().getMailAccount(), "Entered into the system", "Congratulations"); |
|
37 |
+ |
MailManager.getInstance().Send(ac.getOwner().getMailAccount(), |
|
38 |
+ |
"Entered into the system", "Congratulations"); |
37 |
39 |
|
} catch (MessagingException e) { |
38 |
40 |
|
e.printStackTrace(); |
39 |
41 |
|
} |
40 |
42 |
|
return true; |
41 |
|
- |
} |
|
43 |
+ |
} |
42 |
44 |
|
return false; |
43 |
|
- |
|
|
45 |
+ |
|
44 |
46 |
|
} |
45 |
|
- |
|
46 |
|
- |
public boolean removeAccount(int index)throws RemoteException { |
|
47 |
+ |
|
|
48 |
+ |
public boolean removeAccount(int index) throws RemoteException { |
47 |
49 |
|
AdminManager adm = new AdminManager(); |
|
50 |
+ |
Owner own = adm.getAllOwners().get(index); |
48 |
51 |
|
try { |
49 |
|
- |
if(this.dbMngr.removeAccount(adm.getAllOwners().get(index))) |
|
52 |
+ |
if (this.dbMngr.removeAccount(own)) { |
|
53 |
+ |
try { |
|
54 |
+ |
MailManager.getInstance().Send(own.getMailAccount(), "Removed from the system", "We are sorry"); |
|
55 |
+ |
} catch (MessagingException e) { |
|
56 |
+ |
e.printStackTrace(); |
|
57 |
+ |
} |
50 |
58 |
|
return true; |
|
59 |
+ |
} |
51 |
60 |
|
} catch (Exception e) { |
52 |
61 |
|
e.printStackTrace(); |
53 |
62 |
|
} |
54 |
63 |
|
return false; |
55 |
|
- |
|
|
64 |
+ |
|
56 |
65 |
|
} |
57 |
66 |
|
} |