New owners now can be created properly.
authorepinzolas001 <epinzolas001@u004529.gl.ehu.es>
Mon, 18 May 2015 11:44:38 +0000 (13:44 +0200)
committerepinzolas001 <epinzolas001@u004529.gl.ehu.es>
Mon, 18 May 2015 11:44:38 +0000 (13:44 +0200)
ruralHouses client/src/common/AccountInterface.java
ruralHouses client/src/common/AdminInterface.java
ruralHouses client/src/configuration/___IntNames.java
ruralHouses client/src/gui/listOfOwnerAddittionRequests.java
ruralHouses/src/businessLogic/AccountManager.java
ruralHouses/src/businessLogic/AdminManager.java
ruralHouses/src/common/AccountInterface.java
ruralHouses/src/common/AdminInterface.java
ruralHouses/src/launcher/RMILauncher.java

index cb53684..9d489d4 100644 (file)
@@ -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;
 }
index c45a81c..5a76296 100644 (file)
@@ -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 ;
 
index e2da70d..462ff65 100644 (file)
@@ -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";
        
 }
index 9e1b6a3..1d78a53 100644 (file)
@@ -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());
                                }
                        }
                });
index 3f0bc5b..3747973 100644 (file)
@@ -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");
index 9c562fd..a344f2c 100644 (file)
@@ -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 {
index 07f8ced..8e48aeb 100644 (file)
@@ -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;
 }
index c45a81c..5a76296 100644 (file)
@@ -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 ;
 
index f5a4cf8..167f1e0 100644 (file)
@@ -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 {