From: epinzolas001 Date: Mon, 18 May 2015 11:44:38 +0000 (+0200) Subject: New owners now can be created properly. X-Git-Url: https://xp-dev.com/git/RRRRHHHH_Code/commitdiff_plain/578bec184aad79cdf233d774c8f574c9de8438b8 New owners now can be created properly. --- diff --git a/ruralHouses client/src/common/AccountInterface.java b/ruralHouses client/src/common/AccountInterface.java index cb53684..9d489d4 100644 --- a/ruralHouses client/src/common/AccountInterface.java +++ b/ruralHouses client/src/common/AccountInterface.java @@ -9,7 +9,7 @@ import domain.Owner; 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; } diff --git a/ruralHouses client/src/common/AdminInterface.java b/ruralHouses client/src/common/AdminInterface.java index c45a81c..5a76296 100644 --- a/ruralHouses client/src/common/AdminInterface.java +++ b/ruralHouses client/src/common/AdminInterface.java @@ -21,7 +21,7 @@ public interface AdminInterface extends Remote { 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 ; diff --git a/ruralHouses client/src/configuration/___IntNames.java b/ruralHouses client/src/configuration/___IntNames.java index e2da70d..462ff65 100644 --- a/ruralHouses client/src/configuration/___IntNames.java +++ b/ruralHouses client/src/configuration/___IntNames.java @@ -1,12 +1,13 @@ 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"; } diff --git a/ruralHouses client/src/gui/listOfOwnerAddittionRequests.java b/ruralHouses client/src/gui/listOfOwnerAddittionRequests.java index 9e1b6a3..1d78a53 100644 --- a/ruralHouses client/src/gui/listOfOwnerAddittionRequests.java +++ b/ruralHouses client/src/gui/listOfOwnerAddittionRequests.java @@ -106,23 +106,22 @@ public class listOfOwnerAddittionRequests extends JFrame { 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()); } } }); @@ -133,17 +132,16 @@ public class listOfOwnerAddittionRequests extends JFrame { 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()); } } }); diff --git a/ruralHouses/src/businessLogic/AccountManager.java b/ruralHouses/src/businessLogic/AccountManager.java index 3f0bc5b..3747973 100644 --- a/ruralHouses/src/businessLogic/AccountManager.java +++ b/ruralHouses/src/businessLogic/AccountManager.java @@ -8,6 +8,7 @@ import javax.mail.MessagingException; import common.AccountInterface; import dataAccess.DB4oManager; import domain.Account; +import domain.Administrator; public class AccountManager extends UnicastRemoteObject implements AccountInterface { @@ -27,7 +28,8 @@ public class AccountManager extends UnicastRemoteObject implements AccountInterf } } - 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"); diff --git a/ruralHouses/src/businessLogic/AdminManager.java b/ruralHouses/src/businessLogic/AdminManager.java index 9c562fd..a344f2c 100644 --- a/ruralHouses/src/businessLogic/AdminManager.java +++ b/ruralHouses/src/businessLogic/AdminManager.java @@ -46,8 +46,8 @@ public class AdminManager extends UnicastRemoteObject implements AdminInterface 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 { diff --git a/ruralHouses/src/common/AccountInterface.java b/ruralHouses/src/common/AccountInterface.java index 07f8ced..8e48aeb 100644 --- a/ruralHouses/src/common/AccountInterface.java +++ b/ruralHouses/src/common/AccountInterface.java @@ -7,7 +7,7 @@ import domain.Account; 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; } diff --git a/ruralHouses/src/common/AdminInterface.java b/ruralHouses/src/common/AdminInterface.java index c45a81c..5a76296 100644 --- a/ruralHouses/src/common/AdminInterface.java +++ b/ruralHouses/src/common/AdminInterface.java @@ -21,7 +21,7 @@ public interface AdminInterface extends Remote { 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 ; diff --git a/ruralHouses/src/launcher/RMILauncher.java b/ruralHouses/src/launcher/RMILauncher.java index f5a4cf8..167f1e0 100644 --- a/ruralHouses/src/launcher/RMILauncher.java +++ b/ruralHouses/src/launcher/RMILauncher.java @@ -4,6 +4,7 @@ import java.rmi.Naming; import java.rmi.RMISecurityManager; import java.rmi.Remote; +import businessLogic.AccountManager; import businessLogic.AdminManager; import businessLogic.BookingManager; import businessLogic.HouseManager; @@ -37,13 +38,15 @@ public class RMILauncher { 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() { @@ -58,6 +61,17 @@ public class RMILauncher { } } + 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 {