public interface AccountInterface extends Remote{
- public boolean addAccount(Account ac) throws RemoteException;
+ public boolean addAccount(int index) throws RemoteException;
public boolean removeAccount(Account ac) throws RemoteException;
}
public void removeHouseDeletionRequests(RuralHouse house) throws RemoteException ;
- public void removeOwnerAdditionRequests(Account acc) throws RemoteException ;
+ public void removeOwnerAdditionRequests(int index) throws RemoteException ;
public boolean addAdditionRequest(RuralHouse rh) throws RemoteException ;
package configuration;
public class ___IntNames {
- private static String serverPath = "rmi://158.227.140.215:9999//";
+ private static String serverPath = "rmi://localhost:9999//";
public static String AdminManager = serverPath+"AdM";
public static String BookingManager = serverPath+"BoM";
public static String HouseManager = serverPath+"HoM";
public static String LoginManager = serverPath+"LoM";
public static String OfferManager = serverPath+"OfM";
public static String OwnerManager = serverPath+"OwM";
+ public static String AccountManager = serverPath+"AcM";
}
try {
acm = (AccountInterface) Naming
- .lookup(___IntNames.AdminManager);
+ .lookup(___IntNames.AccountManager);
} catch (Exception e1) {
System.out.println("Error accessing remote authentication: "
+ e1.toString());
}
- Account accou = accounts.get(table.getSelectedRow());
+
try {
- acm.addAccount(accou);
- am.removeOwnerAdditionRequests(accou);
+ acm.addAccount(table.getSelectedRow());
+ am.removeOwnerAdditionRequests(table.getSelectedRow());
am.saveInstance();
} catch (RemoteException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
- ((DefaultTableModel)table.getModel()).removeRow(accounts.indexOf(accou));
- accounts.remove(accou);
+ ((DefaultTableModel)table.getModel()).removeRow(table.getSelectedRow());
}
}
});
btnDenyAddition.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
- Account acc = accounts.get(table.getSelectedRow());
try {
- am.removeOwnerAdditionRequests(acc);
+ am.removeOwnerAdditionRequests(table.getSelectedRow());
am.saveInstance();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
- ((DefaultTableModel)table.getModel()).removeRow(accounts.indexOf(acc));
- accounts.remove(acc);
+ ((DefaultTableModel)table.getModel()).removeRow(table.getSelectedRow());
+ accounts.remove(table.getSelectedRow());
}
}
});
import common.AccountInterface;
import dataAccess.DB4oManager;
import domain.Account;
+import domain.Administrator;
public class AccountManager extends UnicastRemoteObject implements AccountInterface {
}
}
- public boolean addAccount(Account ac) throws RemoteException {
+ public boolean addAccount(int index) throws RemoteException {
+ Account ac = Administrator.getInstance().getNewOwnerRequest().get(index);
if(this.dbMngr.addAccount(ac)){
try {
MailManager.getInstance().Send(ac.getOwner().getMailAccount(), "Entered into the system", "Congratulations");
Administrator.getInstance().getRemoveRequest().remove(house);
}
- public void removeOwnerAdditionRequests(Account acc) throws RemoteException {
- Administrator.getInstance().getNewOwnerRequest().remove(acc);
+ public void removeOwnerAdditionRequests(int index) throws RemoteException {
+ Administrator.getInstance().getNewOwnerRequest().remove(index);
}
public boolean addAdditionRequest(RuralHouse rh) throws RemoteException {
public interface AccountInterface extends Remote{
- public boolean addAccount(Account ac) throws RemoteException;
+ public boolean addAccount(int index) throws RemoteException;
public boolean removeAccount(Account ac) throws RemoteException;
}
public void removeHouseDeletionRequests(RuralHouse house) throws RemoteException ;
- public void removeOwnerAdditionRequests(Account acc) throws RemoteException ;
+ public void removeOwnerAdditionRequests(int index) throws RemoteException ;
public boolean addAdditionRequest(RuralHouse rh) throws RemoteException ;
import java.rmi.RMISecurityManager;
import java.rmi.Remote;
+import businessLogic.AccountManager;
import businessLogic.AdminManager;
import businessLogic.BookingManager;
import businessLogic.HouseManager;
boolean off = runOffer();
boolean own = runOwner();
boolean log = runLogin();
+ boolean acc = runAccount();
System.out.println(" Admin: "+adm+
"\t Booking: "+bok+
"\t House: "+hou+
"\t Login: "+log+
"\t Offer: "+off+
- "\t Owner: "+own);
+ "\t Owner: "+own+
+ "\t Account: "+acc);
}
private static boolean runAdmin() {
}
}
+ private static boolean runAccount() {
+ try {
+ Remote remoteObject = new AccountManager();
+ String authService = "rmi://localhost:9999//AcM";
+ Naming.rebind(authService, remoteObject);
+ return true;
+ } catch (Exception e) {
+ System.out.println(e.toString());
+ return false;
+ }
+ }
private static boolean runBooking() {
try {