Merge conflicts solutioned
authorepinzolas001 <epinzolas001@u004529.gl.ehu.es>
Mon, 18 May 2015 09:49:54 +0000 (11:49 +0200)
committerepinzolas001 <epinzolas001@u004529.gl.ehu.es>
Mon, 18 May 2015 09:49:54 +0000 (11:49 +0200)
78 files changed:
ruralHouses client/.DS_Store [new file with mode: 0644]
ruralHouses client/.classpath [new file with mode: 0644]
ruralHouses client/.gitignore [new file with mode: 0644]
ruralHouses client/.project [new file with mode: 0644]
ruralHouses client/config.xml [new file with mode: 0644]
ruralHouses client/java.policy [new file with mode: 0644]
ruralHouses client/src/common/AccountInterface.java [new file with mode: 0644]
ruralHouses client/src/common/AdminInterface.java [new file with mode: 0644]
ruralHouses client/src/common/BookingInterface.java [new file with mode: 0644]
ruralHouses client/src/common/HouseInterface.java [moved from ruralHouses/src/businessLogic/HouseManagerInterface.java with 61% similarity]
ruralHouses client/src/common/LoginInterface.java [new file with mode: 0644]
ruralHouses client/src/common/OfferInterface.java [new file with mode: 0644]
ruralHouses client/src/common/OwnerInterface.java [moved from ruralHouses/src/businessLogic/OwnerManagerInterface.java with 63% similarity]
ruralHouses client/src/configuration/.DS_Store [new file with mode: 0644]
ruralHouses client/src/configuration/ConfigXML.java [new file with mode: 0644]
ruralHouses client/src/configuration/___IntNames.java [new file with mode: 0644]
ruralHouses client/src/domain/Account.java [new file with mode: 0644]
ruralHouses client/src/domain/Administrator.java [new file with mode: 0644]
ruralHouses client/src/domain/Booking.java [new file with mode: 0644]
ruralHouses client/src/domain/Client.java [new file with mode: 0644]
ruralHouses client/src/domain/Districs.java [new file with mode: 0644]
ruralHouses client/src/domain/HouseFeatures.java [new file with mode: 0644]
ruralHouses client/src/domain/Offer.java [new file with mode: 0644]
ruralHouses client/src/domain/Owner.java [new file with mode: 0644]
ruralHouses client/src/domain/RuralHouse.java [new file with mode: 0644]
ruralHouses client/src/exceptions/.DS_Store [moved from ruralHouses/src/gui/.DS_Store with 100% similarity]
ruralHouses client/src/exceptions/BadDates.java [new file with mode: 0644]
ruralHouses client/src/exceptions/DB4oManagerCreationException.java [new file with mode: 0644]
ruralHouses client/src/exceptions/OfferCanNotBeBooked.java [new file with mode: 0644]
ruralHouses client/src/exceptions/OverlappingOfferExists.java [new file with mode: 0644]
ruralHouses client/src/gui/.DS_Store [new file with mode: 0644]
ruralHouses client/src/gui/AddOffersGUI.java [moved from ruralHouses/src/gui/AddOffersGUI.java with 96% similarity]
ruralHouses client/src/gui/AdminMenuGUI.java [moved from ruralHouses/src/gui/AdminMenuGUI.java with 96% similarity]
ruralHouses client/src/gui/BookRuralHouseConfirmationWindow.java [moved from ruralHouses/src/gui/BookRuralHouseConfirmationWindow.java with 100% similarity]
ruralHouses client/src/gui/DeleteOfferGUI.java [moved from ruralHouses/src/gui/DeleteOfferGUI.java with 91% similarity]
ruralHouses client/src/gui/HouseFeaturesGUI.java [moved from ruralHouses/src/gui/HouseFeaturesGUI.java with 93% similarity]
ruralHouses client/src/gui/HousesRelatedOwnerGUI.java [moved from ruralHouses/src/gui/HousesRelatedOwnerGUI.java with 100% similarity]
ruralHouses client/src/gui/LoginGUI.java [moved from ruralHouses/src/gui/LoginGUI.java with 67% similarity]
ruralHouses client/src/gui/ModifyHouseGUI.java [moved from ruralHouses/src/gui/ModifyHouseGUI.java with 89% similarity]
ruralHouses client/src/gui/ModifyOfferGUI.java [moved from ruralHouses/src/gui/ModifyOfferGUI.java with 96% similarity]
ruralHouses client/src/gui/OffersRelatedOwnerGUI.java [moved from ruralHouses/src/gui/OffersRelatedOwnerGUI.java with 100% similarity]
ruralHouses client/src/gui/OwnerMenuGUI.java [moved from ruralHouses/src/gui/OwnerMenuGUI.java with 100% similarity]
ruralHouses client/src/gui/OwnerRegistrationGUI.java [moved from ruralHouses/src/gui/OwnerRegistrationGUI.java with 85% similarity]
ruralHouses client/src/gui/QueryAvailabilityGUI2.java [moved from ruralHouses/src/gui/QueryAvailabilityGUI2.java with 93% similarity]
ruralHouses client/src/gui/RequestDeleteHouseGUI.java [moved from ruralHouses/src/gui/RequestDeleteHouseGUI.java with 76% similarity]
ruralHouses client/src/gui/RequestNewHouseGUI.java [moved from ruralHouses/src/gui/RequestNewHouseGUI.java with 94% similarity]
ruralHouses client/src/gui/StartWindow.java [moved from ruralHouses/src/gui/StartWindow.java with 74% similarity]
ruralHouses client/src/gui/listOfAdditionRequestsGUI.java [moved from ruralHouses/src/gui/listOfAdditionRequestsGUI.java with 77% similarity]
ruralHouses client/src/gui/listOfBookingRequestsGUI.java [moved from ruralHouses/src/gui/listOfBookingRequestsGUI.java with 91% similarity]
ruralHouses client/src/gui/listOfHousesGUI.java [moved from ruralHouses/src/gui/listOfHousesGUI.java with 100% similarity]
ruralHouses client/src/gui/listOfOffers.java [moved from ruralHouses/src/gui/listOfOffers.java with 100% similarity]
ruralHouses client/src/gui/listOfOwnerAddittionRequests.java [moved from ruralHouses/src/gui/ownerAddittionRequests.java with 70% similarity]
ruralHouses client/src/gui/listOfRemovalRequestsGUI.java [moved from ruralHouses/src/gui/listOfRemovalRequestsGUI.java with 76% similarity]
ruralHouses/.classpath
ruralHouses/.gitignore
ruralHouses/src/businessLogic/AccountManager.java
ruralHouses/src/businessLogic/AdminManager.java
ruralHouses/src/businessLogic/BookingManager.java
ruralHouses/src/businessLogic/HouseManager.java
ruralHouses/src/businessLogic/LoginManager.java
ruralHouses/src/businessLogic/LoginManagerInterface.java [deleted file]
ruralHouses/src/businessLogic/OfferManager.java
ruralHouses/src/businessLogic/OwnerManager.java
ruralHouses/src/common/AccountInterface.java [new file with mode: 0644]
ruralHouses/src/common/AdminInterface.java [new file with mode: 0644]
ruralHouses/src/common/BookingInterface.java [new file with mode: 0644]
ruralHouses/src/common/HouseInterface.java [new file with mode: 0644]
ruralHouses/src/common/LoginInterface.java [new file with mode: 0644]
ruralHouses/src/common/OfferInterface.java [new file with mode: 0644]
ruralHouses/src/common/OwnerInterface.java [new file with mode: 0644]
ruralHouses/src/dataAccess/DB4oManager.java
ruralHouses/src/domain/Account.java
ruralHouses/src/domain/Administrator.java
ruralHouses/src/domain/Booking.java
ruralHouses/src/domain/Districs.java
ruralHouses/src/domain/HouseFeatures.java
ruralHouses/src/domain/Owner.java
ruralHouses/src/launcher/RMILauncher.java [new file with mode: 0644]

diff --git a/ruralHouses client/.DS_Store b/ruralHouses client/.DS_Store
new file mode 100644 (file)
index 0000000..4eec472
Binary files /dev/null and b/ruralHouses client/.DS_Store differ
diff --git a/ruralHouses client/.classpath b/ruralHouses client/.classpath
new file mode 100644 (file)
index 0000000..40ed315
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src" />
+       <classpathentry kind="con"
+               path="org.eclipse.jdt.launching.JRE_CONTAINER" />
+       <classpathentry kind="lib" path="lib/additionalLibs/jcalendar.jar" />
+       <classpathentry kind="lib"
+               path="lib/db4o/lib/db4o-8.0.249.16098-all-java5.jar" />
+       <classpathentry kind="output" path="bin" />
+</classpath>
diff --git a/ruralHouses client/.gitignore b/ruralHouses client/.gitignore
new file mode 100644 (file)
index 0000000..2a22d9f
--- /dev/null
@@ -0,0 +1,4 @@
+/bin
+/lib
+/db
+/src/*/*.class
\ No newline at end of file
diff --git a/ruralHouses client/.project b/ruralHouses client/.project
new file mode 100644 (file)
index 0000000..755d15b
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>ruralHouses_client</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/ruralHouses client/config.xml b/ruralHouses client/config.xml
new file mode 100644 (file)
index 0000000..d80475a
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<config>
+       <businessLogic local="true">
+               <businessLogicNode>localhost</businessLogicNode>
+               <portRMI>1099</portRMI>
+               <serviceRMI>RuralHouses</serviceRMI>
+       </businessLogic>
+       <database local="true">
+
+       <databaseNode>localhost</databaseNode>
+       <db4oFilename>db/casas.db4o</db4oFilename>
+       <dataBaseOpenMode>initialize</dataBaseOpenMode>
+       <activationDepth>10</activationDepth>
+       <updateDepth>10</updateDepth>
+       <databasePort>8100</databasePort>
+       <user>softEng</user>
+       <password>i4softwEngin2matx</password>
+</database>
+<javaPolicyPath>java.policy</javaPolicyPath>
+
+</config>
\ No newline at end of file
diff --git a/ruralHouses client/java.policy b/ruralHouses client/java.policy
new file mode 100644 (file)
index 0000000..a38bc88
--- /dev/null
@@ -0,0 +1,9 @@
+grant {
+permission java.security.AllPermission;
+};
+// If there problems with permissions:
+// permission java.security.AllPermission;
+//permission java.net.SocketPermission "localhost:1099", "connect,resolve";
+//permission java.net.SocketPermission "*", "accept,resolve";
+//permission java.io.FilePermission "casas.db4o", "delete,read,write";
+//permission java.util.PropertyPermission "*", "read";
\ No newline at end of file
diff --git a/ruralHouses client/src/common/AccountInterface.java b/ruralHouses client/src/common/AccountInterface.java
new file mode 100644 (file)
index 0000000..a6f3df9
--- /dev/null
@@ -0,0 +1,14 @@
+package common;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+import domain.Account;
+
+public interface AccountInterface extends Remote{
+       
+
+       public boolean addAccount(Account ac) 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
new file mode 100644 (file)
index 0000000..eb5e888
--- /dev/null
@@ -0,0 +1,34 @@
+package common;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.Vector;
+
+import domain.Account;
+import domain.RuralHouse;
+
+public interface AdminInterface extends Remote {
+
+       
+       public Vector<RuralHouse> getAdditionRequests() throws RemoteException;
+
+       public Vector<RuralHouse> getDeletionRequests() throws RemoteException ;
+
+       public Vector<Account> getOwnerAdditionRequests() throws RemoteException ;
+       
+       public void removeHouseAdditionRequests(RuralHouse house) throws RemoteException ;
+
+       public void removeHouseDeletionRequests(RuralHouse house) throws RemoteException ;
+       
+       public void removeOwnerAdditionRequests(Account acc) throws RemoteException ;
+       
+       public boolean addAdditionRequest(RuralHouse rh) throws RemoteException ;
+
+       public boolean addDeletionRequest(RuralHouse rh) throws RemoteException ;
+       
+       public boolean addAccount(Account acc) throws RemoteException ;
+       
+       public void saveInstance() throws RemoteException;
+       
+       
+}
diff --git a/ruralHouses client/src/common/BookingInterface.java b/ruralHouses client/src/common/BookingInterface.java
new file mode 100644 (file)
index 0000000..8262f30
--- /dev/null
@@ -0,0 +1,28 @@
+package common;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.Date;
+import java.util.Vector;
+
+import domain.Booking;
+import domain.Client;
+import domain.RuralHouse;
+import exceptions.OfferCanNotBeBooked;
+
+public interface BookingInterface extends Remote {
+
+
+       public int getNumber() throws RemoteException;
+
+
+       public void removeDenyBooking(Booking b) throws RemoteException;
+
+
+       public void acceptBooking(Booking b) throws RemoteException;
+               
+       public Vector<Booking> createBooking(RuralHouse ruralHouse, Date firstDate,
+                               Date lastDate, Client client)
+                               throws OfferCanNotBeBooked,RemoteException ;
+
+}
\ No newline at end of file
@@ -1,21 +1,22 @@
-package businessLogic;
+package common;
 
 
+import java.rmi.Remote;
 import java.rmi.RemoteException;
 import java.util.Vector;
 
 import domain.Owner;
 import domain.RuralHouse;
 
 import java.rmi.RemoteException;
 import java.util.Vector;
 
 import domain.Owner;
 import domain.RuralHouse;
 
-public interface HouseManagerInterface {
+public interface HouseInterface extends Remote {
 
        // For future implementation
        // public void modifyHouse(int houseName, Owner owner,
        // String description, String town, int nRooms, int nKitchens,
        // int nBaths, int nLivings, int nParkings);
 
 
        // For future implementation
        // public void modifyHouse(int houseName, Owner owner,
        // String description, String town, int nRooms, int nKitchens,
        // int nBaths, int nLivings, int nParkings);
 
-       public void removeHouse(RuralHouse rh, Owner owner);
+       public void removeHouse(RuralHouse rh, Owner owner)throws RemoteException;
 
 
-       public Vector<RuralHouse> getHouses(String name,String town,int nBed , int nKit, int nBath, int nPark, int nLiv) ;
+       public Vector<RuralHouse> getHouses(String name,String town,int nBed , int nKit, int nBath, int nPark, int nLiv) throws RemoteException;
 
        /**
         * This method retrieves the existing  rural houses 
 
        /**
         * This method retrieves the existing  rural houses 
@@ -23,8 +24,8 @@ public interface HouseManagerInterface {
         * @return a Set of rural houses
         */
        public Vector<RuralHouse> getAllRuralHouses()throws RemoteException,
         * @return a Set of rural houses
         */
        public Vector<RuralHouse> getAllRuralHouses()throws RemoteException,
-       Exception;
+       Exception, RemoteException;
 
 
-       public boolean registerNewHouse(RuralHouse rh);
+       public boolean registerNewHouse(RuralHouse rh)throws RemoteException;
        
 }
        
 }
diff --git a/ruralHouses client/src/common/LoginInterface.java b/ruralHouses client/src/common/LoginInterface.java
new file mode 100644 (file)
index 0000000..bb5e3e0
--- /dev/null
@@ -0,0 +1,15 @@
+package common;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+import domain.Account;
+
+public interface LoginInterface extends Remote {
+       
+       public Account checkCredentials(String usr, String pwd)throws RemoteException;
+
+       
+       
+       
+}
diff --git a/ruralHouses client/src/common/OfferInterface.java b/ruralHouses client/src/common/OfferInterface.java
new file mode 100644 (file)
index 0000000..6e3b9b3
--- /dev/null
@@ -0,0 +1,29 @@
+package common;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.sql.Date;
+
+import domain.Offer;
+import domain.RuralHouse;
+import exceptions.BadDates;
+import exceptions.OverlappingOfferExists;
+
+public interface OfferInterface extends Remote {
+
+       /**
+        * This method creates an offer with a house number, first day, last day and
+        * price
+        * 
+        * @param House
+        *            number, start day, last day and price
+        * @return the created offer, or null, or an exception
+        */
+       public Offer createOffer(RuralHouse ruralHouse, Date firstDay,
+                       Date lastDay, float price) throws OverlappingOfferExists, BadDates,
+                       RemoteException, Exception;
+
+       public void deleteOffer(RuralHouse rh, Offer o) throws RemoteException,
+                       Exception;
+
+}
@@ -1,11 +1,12 @@
-package businessLogic;
+package common;
 
 
+import java.rmi.Remote;
 import java.rmi.RemoteException;
 import java.util.Vector;
 
 import domain.Owner;
 
 import java.rmi.RemoteException;
 import java.util.Vector;
 
 import domain.Owner;
 
-public interface OwnerManagerInterface {
+public interface OwnerInterface extends Remote {
 
 
        public Vector<Owner> getOwners() throws RemoteException,
 
 
        public Vector<Owner> getOwners() throws RemoteException,
diff --git a/ruralHouses client/src/configuration/.DS_Store b/ruralHouses client/src/configuration/.DS_Store
new file mode 100644 (file)
index 0000000..02896dc
Binary files /dev/null and b/ruralHouses client/src/configuration/.DS_Store differ
diff --git a/ruralHouses client/src/configuration/ConfigXML.java b/ruralHouses client/src/configuration/ConfigXML.java
new file mode 100644 (file)
index 0000000..ca4a156
--- /dev/null
@@ -0,0 +1,175 @@
+package configuration;
+
+import java.io.File;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class ConfigXML {
+       private String businessLogicNode;
+
+       private String portRMI;
+
+       private String serviceRMI;
+
+       private String javaPolicyPath;
+
+       private static String db4oFilename;
+
+       //Two possible values: "open" or "initialize"
+       private String dataBaseOpenMode;
+
+       //Two possible values: true (no instance of RemoteServer needs to be launched) or false (RemoteServer needs to be run first)
+       private boolean businessLogicLocal;
+
+       //Two possible values: true (if the database is in same node as business logic ) or false (in other case)
+       private boolean databaseLocal;
+       
+       private String databaseNode;
+
+       private int activationDepth;
+       
+       private int updateDepth;
+       
+       private int databasePort;
+       
+       private String user;
+       
+       private String password;
+       
+       public int getDatabasePort() {
+               return databasePort;
+       }
+
+       public String getUser() {
+               return user;
+       }
+
+       public String getPassword() {
+               return password;
+       }
+
+       public int getActivationDepth() {
+               return activationDepth;
+       }
+
+       public int getUpdateDepth() {
+               return updateDepth;
+       }
+       
+       public boolean isDatabaseLocal() {
+               return databaseLocal;
+       }
+
+       public boolean isBusinessLogicLocal() {
+               return businessLogicLocal;
+       }
+       private static ConfigXML theInstance = new ConfigXML();
+
+       private ConfigXML(){
+               
+                 try {
+                         DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+                         DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
+                         Document doc = dBuilder.parse(new File("config.xml"));
+                         doc.getDocumentElement().normalize();
+
+                         NodeList list = doc.getElementsByTagName("config");
+                         Element config = (Element) list.item(0); // list.item(0) is a Node that is an Element
+
+                         
+                               //Two possible values: true (no instance of RemoteServer needs to be launched) or false (RemoteServer needs to be run first)
+                         String value= ((Element)config.getElementsByTagName("businessLogic").item(0)).getAttribute("local");
+                         businessLogicLocal=value.equals("true");
+
+                         businessLogicNode = getTagValue("businessLogicNode", config);
+
+                         portRMI = getTagValue("portRMI", config);
+
+                         serviceRMI = getTagValue("serviceRMI", config);
+
+                         javaPolicyPath= getTagValue("javaPolicyPath", config);
+
+                         db4oFilename = getTagValue("db4oFilename", config);
+
+                               //Two possible values: true (no instance of RemoteServer needs to be launched) or false (RemoteServer needs to be run first)
+                         value= ((Element)config.getElementsByTagName("database").item(0)).getAttribute("local");
+                         databaseLocal=value.equals("true");
+                         
+                         
+                         //Two possible values: "open" or "initialize"
+                         dataBaseOpenMode= getTagValue("dataBaseOpenMode", config);
+
+       
+                         databaseNode = getTagValue("databaseNode", config);
+
+                         activationDepth=Integer.parseInt(getTagValue("activationDepth", config));
+
+                         updateDepth=Integer.parseInt(getTagValue("updateDepth", config));
+                         
+                         
+                         databasePort=Integer.parseInt(getTagValue("databasePort", config));
+                               
+                         user=getTagValue("user", config);
+                               
+                         password=getTagValue("password", config);
+
+                         System.out.print("Read from config.xml: ");
+                         System.out.print("\t businessLogicLocal="+businessLogicLocal);
+                         System.out.print("\t databaseLocal="+databaseLocal);
+                         System.out.println("\t dataBaseOpenMode="+dataBaseOpenMode); 
+                                         
+                 } catch (Exception e) {
+                       System.out.println("Error in ConfigXML.java: problems with config.xml");
+                   e.printStackTrace();
+                 }             
+               
+               
+               
+               
+       }
+
+       private static String getTagValue(String sTag, Element eElement)
+        {
+                 NodeList nlList= eElement.getElementsByTagName(sTag).item(0).getChildNodes();
+                 Node nValue = (Node) nlList.item(0);
+
+                 return nValue.getNodeValue();
+
+        }
+       
+       public static ConfigXML getInstance() {
+               return theInstance;
+       }
+
+       public String getBusinessLogicNode() {
+               return businessLogicNode;
+       }
+
+       public String getPortRMI() {
+               return portRMI;
+       }
+
+       public String getServiceRMI() {
+               return serviceRMI;
+       }
+       public String getDb4oFilename(){
+               return db4oFilename;
+       }
+       public String getJavaPolicyPath(){
+               return javaPolicyPath;
+       }
+       public String getDataBaseOpenMode(){
+               return dataBaseOpenMode;
+       }
+
+       public String getDatabaseNode() {
+               return databaseNode;
+       }
+
+}
diff --git a/ruralHouses client/src/configuration/___IntNames.java b/ruralHouses client/src/configuration/___IntNames.java
new file mode 100644 (file)
index 0000000..e2da70d
--- /dev/null
@@ -0,0 +1,12 @@
+package configuration;
+
+public class ___IntNames {
+       private static String serverPath = "rmi://158.227.140.215: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";
+       
+}
diff --git a/ruralHouses client/src/domain/Account.java b/ruralHouses client/src/domain/Account.java
new file mode 100644 (file)
index 0000000..851e547
--- /dev/null
@@ -0,0 +1,84 @@
+package domain;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+
+
+public class Account implements Serializable {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+       
+
+       private byte[] username;
+       private byte[] password;
+       private byte[] salt;
+
+
+       private Owner owner;
+       private boolean admin = false;
+
+       
+       public Account(String usr){
+               
+               
+       }
+       public Account(String usr, String pass, boolean isAdmin) {
+               
+
+       }
+
+       public Account(String usr, String pass, Owner ow) {
+               
+
+       }
+
+       public byte[] getUsername() {
+               return username;
+       }
+
+       public byte[] getPassword() {
+               return password;
+       }
+
+       public Owner getOwner() {
+               return owner;
+       }
+
+       public boolean getAdmin() {
+               return admin;
+       }
+
+       public void setAdmin(boolean admin) {
+               this.admin = admin;
+       }
+
+       public byte[] getSalt() {
+               return salt;
+       }
+
+       public void setSalt(byte[] salt) {
+               this.salt = salt;
+       }
+       
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               Account other = (Account) obj;
+               if (!Arrays.equals(password, other.password))
+                       return false;
+               if (!Arrays.equals(username, other.username))
+                       return false;
+               return true;
+       }
+
+}
diff --git a/ruralHouses client/src/domain/Administrator.java b/ruralHouses client/src/domain/Administrator.java
new file mode 100644 (file)
index 0000000..d6e9d79
--- /dev/null
@@ -0,0 +1,62 @@
+package domain;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+
+import configuration.ConfigXML;
+
+public class Administrator implements Serializable {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+
+       private static Administrator admin = null;
+       private static LinkedList<RuralHouse> addRequest;
+       private static LinkedList<RuralHouse> removeRequest;
+       private static LinkedList<Account> newOwnerRequest;
+       static ConfigXML c;
+
+       private Administrator() {
+               addRequest = new LinkedList<RuralHouse>();
+               removeRequest = new LinkedList<RuralHouse>();
+               newOwnerRequest = new LinkedList<Account>();
+       }
+
+       public static Administrator getInstance() {
+               return null;
+
+
+       }
+
+       public static void saveInstance() {
+
+       }
+
+       public LinkedList<RuralHouse> getAddRequest() {
+               return addRequest;
+       }
+
+       public LinkedList<RuralHouse> getRemoveRequest() {
+               return removeRequest;
+       }
+
+       public void setAddRequest(LinkedList<RuralHouse> addRequest) {
+               Administrator.addRequest = addRequest;
+       }
+
+       public void setRemoveRequest(LinkedList<RuralHouse> removeRequest) {
+               Administrator.removeRequest = removeRequest;
+
+       }
+
+       public LinkedList<Account> getNewOwnerRequest() {
+               return newOwnerRequest;
+       }
+
+       public void setNewOwnerRequest(LinkedList<Account> newOwnerRequest) {
+               Administrator.newOwnerRequest = newOwnerRequest;
+       }
+
+}
diff --git a/ruralHouses client/src/domain/Booking.java b/ruralHouses client/src/domain/Booking.java
new file mode 100644 (file)
index 0000000..0f72a6c
--- /dev/null
@@ -0,0 +1,86 @@
+package domain;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class Booking implements Serializable  {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+       private int bookingNumber;
+       private boolean isPaid;
+       private Date bookingDate;
+       private Client client;
+       private Offer offer;
+       
+       
+       public Booking() {
+       }
+
+       public Booking(int bN , Offer offer,Client client) {
+               
+               this.bookingNumber = bN;
+               this.offer = offer;
+               this.client=client;
+               //Booking date is assigned to actual date
+               this.bookingDate= new java.util.Date(System.currentTimeMillis());
+               this.isPaid=false;
+       }
+       
+       public void imprimete(){
+               System.out.println(bookingNumber);
+               System.out.println(isPaid);
+               System.out.println(bookingDate);
+               System.out.println(client.toString());
+               System.out.println(offer);      
+       }
+
+       public int getBookNumber() {
+               return this.bookingNumber;
+       }
+
+       public void setOffer(Offer offer) {
+               this.offer = offer;
+       }
+
+       public Offer getOffer() {
+               return this.offer;
+       }
+
+       public float getPrice() {
+               return this.offer.getPrice();
+       }
+       
+       public void setBookDate(Date bookDate) {
+               this.bookingDate = bookDate;
+       }
+
+       public Date getBookDate() {
+               return this.bookingDate;
+       }
+       
+       public void paid() {
+               this.isPaid = true;
+       }
+
+       public void notPaid() {
+               this.isPaid=false;
+       }
+
+       public boolean isPaid() {
+               return isPaid;
+       }
+       
+
+
+       public Client getClient() {
+               return client;
+       }
+
+       public void setClient(Client client) {
+               this.client = client;
+       }
+       
+}
\ No newline at end of file
diff --git a/ruralHouses client/src/domain/Client.java b/ruralHouses client/src/domain/Client.java
new file mode 100644 (file)
index 0000000..4dd9eb2
--- /dev/null
@@ -0,0 +1,40 @@
+package domain;
+
+public class Client {
+
+       private String name;
+       private String mailAccount;
+       private String telephone;
+
+       public Client(String name, String mailAccount, String telephone) {
+               super();
+               this.name = name;
+               this.mailAccount = mailAccount;
+               this.telephone = telephone;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public String getMailAccount() {
+               return mailAccount;
+       }
+
+       public void setMailAccount(String mailAccount) {
+               this.mailAccount = mailAccount;
+       }
+
+       public String getTelephone() {
+               return telephone;
+       }
+
+       public void setTelephone(String telephone) {
+               this.telephone = telephone;
+       }
+
+}
diff --git a/ruralHouses client/src/domain/Districs.java b/ruralHouses client/src/domain/Districs.java
new file mode 100644 (file)
index 0000000..db62454
--- /dev/null
@@ -0,0 +1,34 @@
+package domain;
+
+import java.io.Serializable;
+
+public enum Districs implements Serializable {
+
+       /**
+        * 
+        */
+       BEA("Beatriz"), GUA("Guazate"), VEG("Vegas"), FAR("Farallón"), CED("Cedro"), MOT(
+                       "Monte LLano"), RIN("Rincón"), PUE("Pueblo"), QUA("Quebrada Arriba"), QEB(
+                       "Quebrada Abajo"), TOI("Toita"), MAB("Matón Abajo"), MAA(
+                       "Matón Arriba"), PIE("Piedras"), PAV("Pasto Viejo"), PEA(
+                       "PedroAvila"), SUM("Sumido"), LAP("Lapa"), CER("Cercadillo"), JAJ(
+                       "JájomeAlto"), CUL("CulebrasAbajo");
+                       
+       private static final long serialVersionUID = 1L; 
+
+       
+       private final String longName;
+
+       Districs(String longName) {
+               this.longName = longName;
+       }
+
+       public static String[] longNames() {
+               String[] result = new String[Districs.values().length];
+               for (Districs d : Districs.values()) {
+                       result[d.ordinal()] = d.longName;
+               }
+               return result;
+
+       }
+}
diff --git a/ruralHouses client/src/domain/HouseFeatures.java b/ruralHouses client/src/domain/HouseFeatures.java
new file mode 100644 (file)
index 0000000..e79a446
--- /dev/null
@@ -0,0 +1,67 @@
+package domain;
+
+import java.io.Serializable;
+
+public class HouseFeatures implements Serializable {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+       private int nRooms;
+       private int nKitchens;
+       private int nBaths;
+       private int nLivings;
+       private int nParkings;
+
+       public HouseFeatures(int nRooms, int nKitchens, int nBaths, int nLivings,
+                       int nParkings) {
+               super();
+               this.setnRooms(nRooms);
+               this.setnKitchens(nKitchens);
+               this.setnBaths(nBaths);
+               this.setnLivings(nLivings);
+               this.setnParkings(nParkings);
+       }
+
+       public int getnRooms() {
+               return nRooms;
+       }
+
+       public void setnRooms(int nRooms) {
+               this.nRooms = nRooms;
+       }
+
+       public int getnKitchens() {
+               return nKitchens;
+       }
+
+       public void setnKitchens(int nKitchens) {
+               this.nKitchens = nKitchens;
+       }
+
+       public int getnBaths() {
+               return nBaths;
+       }
+
+       public void setnBaths(int nBaths) {
+               this.nBaths = nBaths;
+       }
+
+       public int getnLivings() {
+               return nLivings;
+       }
+
+       public void setnLivings(int nLivings) {
+               this.nLivings = nLivings;
+       }
+
+       public int getnParkings() {
+               return nParkings;
+       }
+
+       public void setnParkings(int nParkings) {
+               this.nParkings = nParkings;
+       }
+
+}
diff --git a/ruralHouses client/src/domain/Offer.java b/ruralHouses client/src/domain/Offer.java
new file mode 100644 (file)
index 0000000..3442a6a
--- /dev/null
@@ -0,0 +1,143 @@
+package domain;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Vector;
+
+
+@SuppressWarnings("serial")
+public class Offer implements Serializable {
+       
+
+       private int offerNumber;
+       private Date firstDay; // Dates are stored as java.util.Date objects instead of java.sql.Date objects
+       private Date lastDay;  // because, they are not well stored in db4o as java.util.Date objects
+       private float price;   // This is coherent because objects of java.sql.Date are objects of java.util.Date ç
+       private boolean isBooked;
+       private Vector<Booking> bookings = new Vector<Booking>();  // That is: java.sql.Date is a subclass (or extends) java.util.Date
+       private RuralHouse ruralHouse;
+
+       
+       public Offer(int offerNumber,RuralHouse ruralHouse, Date firstDay, Date lastDay, float price){
+                 this.firstDay=firstDay;
+                 this.lastDay=lastDay;
+                 this.price=price;
+                 this.ruralHouse=ruralHouse;
+                 this.offerNumber=offerNumber;
+       }
+       /**
+        * Get the house number of the offer
+        * 
+        * @return the house number
+        */
+       public RuralHouse getRuralHouse() {
+               return this.ruralHouse;
+       }
+
+       /**
+        * Set the house number to a offer
+        * 
+        * @param house number
+        */
+       public void setRuralHouse(RuralHouse ruralHouse) {
+               this.ruralHouse = ruralHouse;
+       }
+
+
+       /**
+        * Get the offer number
+        * 
+        * @return offer number
+        */
+       public int getOfferNumber() {
+               return this.offerNumber;
+       }
+
+       
+
+       /**
+        * Get the first day of the offer
+        * 
+        * @return the first day
+        */
+       public Date getFirstDay() {
+               return this.firstDay;
+       }
+
+       /**
+        * Set the first day of the offer
+        * 
+        * @param firstDay
+        *            The first day
+        */
+       public void setFirstDay(Date firstDay) {
+               this.firstDay = firstDay;
+       }
+
+       /**
+        * Get the last day of the offer
+        * 
+        * @return the last day
+        */
+       public Date getLastDay() {
+               return this.lastDay;
+       }
+
+       /**
+        * Set the last day of the offer
+        * 
+        * @param lastDay
+        *            The last day
+        */
+       public void setLastDay(Date lastDay) {
+               this.lastDay = lastDay;
+       }
+
+       /**
+        * Get the price
+        * 
+        * @return price
+        */
+       public float getPrice() {
+               return this.price;
+       }
+
+       /**
+        * Set the price
+        * 
+        * @param price
+        */
+       public void setPrice(float price) {
+               this.price = price;
+       }
+
+       
+       /**
+        * This method creates a book with a corresponding parameters
+        * 
+        * @param First day, last day, house number and telephone
+        * @return a book
+        */
+       public Vector<Booking> createBooking(int numBooking,Client client) {
+               Booking b = new Booking(numBooking,this,client);
+               this.bookings.add(b);
+               return this.bookings;
+                       
+       }
+       
+       public String toString(){
+               return firstDay.toString()+", "+lastDay.toString()+", "+price;
+       }
+       public Vector<Booking> getBookings() {
+               return bookings;
+       }
+       public void setBookings(Vector<Booking> bookings) {
+               this.bookings = bookings;
+       }
+       public boolean isBooked() {
+               return isBooked;
+       }
+       public void setBooked(boolean isBooked) {
+               this.isBooked = isBooked;
+       }
+}
\ No newline at end of file
diff --git a/ruralHouses client/src/domain/Owner.java b/ruralHouses client/src/domain/Owner.java
new file mode 100644 (file)
index 0000000..550aceb
--- /dev/null
@@ -0,0 +1,87 @@
+package domain;
+
+import java.io.Serializable;
+import java.util.Vector;
+
+public class Owner implements Serializable {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+       private String bankAccount = "";
+       private String name = "";
+       private String mailAccount = "";
+       private Vector<RuralHouse> ruralHouses;
+
+//     public Owner(String name) {
+//             this.name = name;
+//             ruralHouses = new Vector<RuralHouse>();
+//     }
+
+       public Owner(String name, String bankAccount,String mail) {
+               this.bankAccount = bankAccount;
+               this.name = name;
+               this.mailAccount = mail;
+               ruralHouses = new Vector<RuralHouse>();
+       }
+
+       public String getName() {
+               return this.name;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public String getBankAccount() {
+               return this.bankAccount;
+       }
+
+       public void setBankAccount(String bankAccount) {
+               this.bankAccount = bankAccount;
+       }
+
+       public Vector<RuralHouse> getRuralHouses(){
+               return this.ruralHouses;
+       }
+
+
+
+       public RuralHouse addRuralHouse(String houseName, String description,
+                       String town, int nRooms, int nKitchens, int nBaths, int nLivings,
+                       int nParkings) {
+               HouseFeatures feature = new HouseFeatures(nRooms, nKitchens, nBaths, nLivings, nParkings);
+               RuralHouse rh = new RuralHouse(houseName, this, description, town,feature);
+               ruralHouses.add(rh);
+               return rh;
+       }
+       
+       public RuralHouse addRuralHouse(RuralHouse rh) {
+               ruralHouses.add(rh);
+               return rh;
+       }
+
+       public String toString() {
+               return name;
+       }
+
+       public String getMailAccount() {
+               return mailAccount;
+       }
+
+       public void setMailAccount(String mailAccount) {
+               this.mailAccount = mailAccount;
+       }
+       
+       public Vector<Offer> getAllOffers (){
+               Vector<Offer> offers = new Vector<Offer>();
+               for(RuralHouse rh: this.ruralHouses){
+                       for(Offer of : rh.getAllOffers()){
+                       offers.add(of);
+                       }
+               }
+               return offers;
+       }
+
+}
\ No newline at end of file
diff --git a/ruralHouses client/src/domain/RuralHouse.java b/ruralHouses client/src/domain/RuralHouse.java
new file mode 100644 (file)
index 0000000..4245458
--- /dev/null
@@ -0,0 +1,170 @@
+package domain;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Vector;
+
+public class RuralHouse implements Serializable {
+
+       private static final long serialVersionUID = 1L;
+
+       private String houseName;
+       private String description;
+       private Owner owner;
+       private String district;
+       private HouseFeatures features;
+       public Vector<Offer> offers;
+       public boolean isAccepted;
+
+       public RuralHouse() {
+               super();
+       }
+
+       public RuralHouse(String houseName, Owner owner, String description,
+                       String ds, HouseFeatures features) {
+               this.houseName = houseName;
+               this.description = description;
+               this.owner = owner;
+               this.district = ds;
+               this.features = features;
+               offers = new Vector<Offer>();
+       }
+
+       public String getHouseName() {
+               return houseName;
+       }
+
+       public void setHouseName(String houseName) {
+               this.houseName = houseName;
+       }
+
+       public String getDescription() {
+               return description;
+       }
+
+       public void setDescription(String description) {
+               this.description = description;
+       }
+
+       public Owner getOwner() {
+               return owner;
+       }
+
+       public void setOwner(Owner owner) {
+               this.owner = owner;
+       }
+
+       public String getDistrict() {
+               return district;
+       }
+
+       public void setDistrict(String ds) {
+               this.district = ds;
+       }
+
+       public HouseFeatures getFeatures() {
+               return features;
+       }
+
+       public void setFeatures(HouseFeatures features) {
+               this.features = features;
+       }
+
+       public String toString() {
+               return this.houseName + ": " + this.district;
+       }
+
+       public Offer createOffer(int offerNumber, Date firstDay, Date lastDay,
+                       float price) {
+               Offer off = new Offer(offerNumber, this, firstDay, lastDay, price);
+               offers.add(off);
+               return off;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               RuralHouse other = (RuralHouse) obj;
+               if (houseName == null) {
+                       if (other.houseName != null)
+                               return false;
+               } else if (!houseName.equals(other.houseName))
+                       return false;
+               return true;
+       }
+
+       /**
+        * This method obtains available offers for a concrete house in a certain
+        * period
+        * 
+        * @param houseName
+        *            , the house number where the offers must be obtained
+        * @param firstDay
+        *            , first day in a period range
+        * @param lastDay
+        *            , last day in a period range
+        * @return a vector of offers(Offer class) available in this period
+        */
+       public Vector<Offer> getOffers(Date firstDay, Date lastDay) {
+               Vector<Offer> availableOffers = new Vector<Offer>();
+               Iterator<Offer> e = offers.iterator();
+               Offer offer;
+               while (e.hasNext()) {
+                       offer = e.next();
+                       if ((offer.getFirstDay().compareTo(firstDay) >= 0)
+                                       && (offer.getLastDay().compareTo(lastDay) <= 0)
+                                       && (!offer.isBooked()))
+                               availableOffers.add(offer);
+               }
+               return availableOffers;
+       }
+
+       public Vector<Offer> getAllOffers() {
+
+               return this.offers;
+       }
+
+       /**
+        * This method obtains the offer that match exactly with a given dates that
+        * has not been booked
+        * 
+        * @param firstDay
+        *            , first day in a period range
+        * @param lastDay
+        *            , last day in a period range
+        * @return the offer(Offer class) available for a this period
+        */
+       public Offer findOffer(Date firstDay, Date lastDay) {
+               Iterator<Offer> e = offers.iterator();
+               Offer offer = null;
+               while (e.hasNext()) {
+                       offer = e.next();
+                       if ((offer.getFirstDay().compareTo(firstDay) == 0)
+                                       && (offer.getLastDay().compareTo(lastDay) == 0)
+                                       && (!offer.isBooked()))
+                               return offer;
+               }
+               return null;
+       }
+
+       public Offer overlapsWith(Date firstDay, Date lastDay) {
+
+               Iterator<Offer> e = offers.iterator();
+               Offer offer = null;
+               while (e.hasNext()) {
+                       offer = e.next();
+                       if ((offer.getFirstDay().compareTo(lastDay) < 0)
+                                       && (offer.getLastDay().compareTo(firstDay) > 0))
+                               return offer;
+               }
+               return null;
+
+       }
+
+}
diff --git a/ruralHouses client/src/exceptions/BadDates.java b/ruralHouses client/src/exceptions/BadDates.java
new file mode 100644 (file)
index 0000000..9cf6915
--- /dev/null
@@ -0,0 +1,17 @@
+package exceptions;
+public class BadDates extends Exception {
+ private static final long serialVersionUID = 1L;
+ public BadDates()
+  {
+    super();
+  }
+  /**This exception is triggered if first date is greater than last date in offers
+  *@param String
+  *@return None
+  */
+  public BadDates(String s)
+  {
+    super(s);
+  }
+}
\ No newline at end of file
diff --git a/ruralHouses client/src/exceptions/DB4oManagerCreationException.java b/ruralHouses client/src/exceptions/DB4oManagerCreationException.java
new file mode 100644 (file)
index 0000000..4b49471
--- /dev/null
@@ -0,0 +1,17 @@
+package exceptions;
+public class DB4oManagerCreationException extends Exception {
+ private static final long serialVersionUID = 1L;
+ public DB4oManagerCreationException()
+  {
+    super();
+  }
+  /**This exception is triggered if there is a problem when constructor of DB4oManager is executed
+  *@param String
+  *@return None
+  */
+  public DB4oManagerCreationException(String s)
+  {
+    super(s);
+  }
+}
\ No newline at end of file
diff --git a/ruralHouses client/src/exceptions/OfferCanNotBeBooked.java b/ruralHouses client/src/exceptions/OfferCanNotBeBooked.java
new file mode 100644 (file)
index 0000000..b4539d0
--- /dev/null
@@ -0,0 +1,17 @@
+package exceptions;
+public class OfferCanNotBeBooked extends Exception {
+       private static final long serialVersionUID = 1L;
+
+       public OfferCanNotBeBooked() {
+               super();
+       }
+       
+       /**This exception is triggered if an offer cannot be booked 
+        *@param String
+        *@return None
+        */
+       public OfferCanNotBeBooked(String s)
+       {
+               super(s);
+       }
+}
\ No newline at end of file
diff --git a/ruralHouses client/src/exceptions/OverlappingOfferExists.java b/ruralHouses client/src/exceptions/OverlappingOfferExists.java
new file mode 100644 (file)
index 0000000..c776a3b
--- /dev/null
@@ -0,0 +1,17 @@
+package exceptions;
+public class OverlappingOfferExists extends Exception {
+ private static final long serialVersionUID = 1L;
+ public OverlappingOfferExists()
+  {
+    super();
+  }
+  /**This exception is triggered if there exists an overlapping offer
+  *@param String
+  *@return None
+  */
+  public OverlappingOfferExists(String s)
+  {
+    super(s);
+  }
+}
\ No newline at end of file
diff --git a/ruralHouses client/src/gui/.DS_Store b/ruralHouses client/src/gui/.DS_Store
new file mode 100644 (file)
index 0000000..5008ddf
Binary files /dev/null and b/ruralHouses client/src/gui/.DS_Store differ
similarity index 96%
rename from ruralHouses/src/gui/AddOffersGUI.java
rename to ruralHouses client/src/gui/AddOffersGUI.java
index 8d34025..e8b3df6 100644 (file)
@@ -8,6 +8,7 @@ import java.awt.event.FocusEvent;
 import java.awt.event.FocusListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.awt.event.FocusListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.rmi.Naming;
 import java.sql.Date;
 import java.text.DateFormat;
 import java.util.Calendar;
 import java.sql.Date;
 import java.text.DateFormat;
 import java.util.Calendar;
@@ -20,10 +21,10 @@ import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JTextField;
 
 import javax.swing.JLabel;
 import javax.swing.JTextField;
 
-import businessLogic.OfferManager;
-
 import com.toedter.calendar.JCalendar;
 import com.toedter.calendar.JCalendar;
+import common.OfferInterface;
 
 
+import configuration.___IntNames;
 import domain.RuralHouse;
 import exceptions.BadDates;
 import exceptions.OverlappingOfferExists;
 import domain.RuralHouse;
 import exceptions.BadDates;
 import exceptions.OverlappingOfferExists;
@@ -207,8 +208,15 @@ private static final long serialVersionUID = 1L;
                        float price= Float.parseFloat(jTextField3.getText());
 
                        //Obtain the business logic from a StartWindow class (local or remote)
                        float price= Float.parseFloat(jTextField3.getText());
 
                        //Obtain the business logic from a StartWindow class (local or remote)
-                       OfferManager offerM = new OfferManager();
-
+                       OfferInterface offerM = null;
+                       try {
+                               offerM = (OfferInterface) Naming
+                                               .lookup(___IntNames.OfferManager);
+                       } catch (Exception e1) {
+                               System.out.println("Error accessing remote authentication: "
+                                               + e1.toString());
+                       }
+                       
                        offerM.createOffer(ruralHouse, firstDay, lastDay, price); 
 
                        jLabel5.setText("Offer created");
                        offerM.createOffer(ruralHouse, firstDay, lastDay, price); 
 
                        jLabel5.setText("Offer created");
similarity index 96%
rename from ruralHouses/src/gui/AdminMenuGUI.java
rename to ruralHouses client/src/gui/AdminMenuGUI.java
index 2ded6f6..eef2ba4 100644 (file)
@@ -11,8 +11,6 @@ import javax.swing.JFrame;
 import javax.swing.JPanel;
 import javax.swing.border.EmptyBorder;
 
 import javax.swing.JPanel;
 import javax.swing.border.EmptyBorder;
 
-import domain.Administrator;
-
 public class AdminMenuGUI extends JFrame {
 
        /**
 public class AdminMenuGUI extends JFrame {
 
        /**
@@ -29,7 +27,6 @@ public class AdminMenuGUI extends JFrame {
        public AdminMenuGUI() {
                
                
        public AdminMenuGUI() {
                
                
-               Administrator.getInstance();
                this.setTitle("Administrator Menu");
                this.getContentPane().setLayout(null);
                setBounds(100, 100, 450, 473);
                this.setTitle("Administrator Menu");
                this.getContentPane().setLayout(null);
                setBounds(100, 100, 450, 473);
@@ -56,7 +53,7 @@ public class AdminMenuGUI extends JFrame {
                JButton btnOwneraddition = new JButton("OwnerAddition");
                btnOwneraddition.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                JButton btnOwneraddition = new JButton("OwnerAddition");
                btnOwneraddition.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
-                               Frame a = new ownerAddittionRequests();
+                               Frame a = new listOfOwnerAddittionRequests();
                                a.setVisible(true);
                        }
                });
                                a.setVisible(true);
                        }
                });
similarity index 91%
rename from ruralHouses/src/gui/DeleteOfferGUI.java
rename to ruralHouses client/src/gui/DeleteOfferGUI.java
index cd2665a..d3a79e4 100644 (file)
@@ -4,6 +4,7 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
+import java.rmi.Naming;
 import java.util.Vector;
 
 import javax.swing.JButton;
 import java.util.Vector;
 
 import javax.swing.JButton;
@@ -14,7 +15,9 @@ import javax.swing.JPanel;
 import javax.swing.JRadioButton;
 import javax.swing.border.EmptyBorder;
 
 import javax.swing.JRadioButton;
 import javax.swing.border.EmptyBorder;
 
-import businessLogic.OfferManager;
+import common.OfferInterface;
+
+import configuration.___IntNames;
 import domain.Offer;
 import domain.Owner;
 import domain.RuralHouse;
 import domain.Offer;
 import domain.Owner;
 import domain.RuralHouse;
@@ -119,7 +122,15 @@ public class DeleteOfferGUI extends JFrame {
        private void actionListenerButton(ActionEvent e) {
 
                Offer toDel = (Offer) comboBox_1.getSelectedItem();
        private void actionListenerButton(ActionEvent e) {
 
                Offer toDel = (Offer) comboBox_1.getSelectedItem();
-               OfferManager oM = new OfferManager();
+               OfferInterface oM = null;
+               try {
+                       oM = (OfferInterface) Naming
+                                       .lookup(___IntNames.OfferManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
+               
                try {
                        oM.deleteOffer((RuralHouse) comboBox.getSelectedItem(), toDel);
                        comboBox_1.removeItem(toDel);
                try {
                        oM.deleteOffer((RuralHouse) comboBox.getSelectedItem(), toDel);
                        comboBox_1.removeItem(toDel);
similarity index 93%
rename from ruralHouses/src/gui/HouseFeaturesGUI.java
rename to ruralHouses client/src/gui/HouseFeaturesGUI.java
index 9008a65..254f9c9 100644 (file)
@@ -6,6 +6,7 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
+import java.rmi.Naming;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.Vector;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.Vector;
@@ -22,7 +23,9 @@ import javax.swing.border.EmptyBorder;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.DefaultTableModel;
 
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.DefaultTableModel;
 
-import businessLogic.BookingManager;
+import common.BookingInterface;
+
+import configuration.___IntNames;
 import domain.Booking;
 import domain.Client;
 import domain.Offer;
 import domain.Booking;
 import domain.Client;
 import domain.Offer;
@@ -235,7 +238,7 @@ public class HouseFeaturesGUI extends JFrame {
                while (rhs.hasMoreElements()) {
                        Offer of = rhs.nextElement();
                        if (of.getBookings() == null
                while (rhs.hasMoreElements()) {
                        Offer of = rhs.nextElement();
                        if (of.getBookings() == null
-                                       || !(of.getBookings().size() == 1 && of.isBooked())) {
+                                       || of.isBooked()) {
                                Vector<Object> row = new Vector<Object>();
                                row.add(of.getOfferNumber());
                                row.add(of.getFirstDay());
                                Vector<Object> row = new Vector<Object>();
                                row.add(of.getOfferNumber());
                                row.add(of.getFirstDay());
@@ -275,14 +278,23 @@ public class HouseFeaturesGUI extends JFrame {
        }
 
        private void jButton_ActionPerformed(ActionEvent arg0) {
        }
 
        private void jButton_ActionPerformed(ActionEvent arg0) {
-               BookingManager bookingM = new BookingManager();
 
 
+               BookingInterface bookingM = null;
+               try {
+                       bookingM = (BookingInterface) Naming
+                                       .lookup(___IntNames.BookingManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
+               
+               //RegExp to see if telephone number is correct??TODO
                if (telIn.getText().matches("[976]\\d{2}[.\\- ]?\\d{3}[.\\- ]?\\d{3}")
                                && mailField
                if (telIn.getText().matches("[976]\\d{2}[.\\- ]?\\d{3}[.\\- ]?\\d{3}")
                                && mailField
-                                               .getText()
-                                               .matches(
-                                                               "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$")
-                               && !nameField.getText().isEmpty()) {
+                               .getText()
+                               .matches(
+                                               "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$")
+               && !nameField.getText().isEmpty()) {
                        labelPhone.setText("");
                        Vector<Booking> book = null;
                        try {
                        labelPhone.setText("");
                        Vector<Booking> book = null;
                        try {
similarity index 67%
rename from ruralHouses/src/gui/LoginGUI.java
rename to ruralHouses client/src/gui/LoginGUI.java
index ab22f39..cf075b2 100644 (file)
@@ -2,8 +2,15 @@ package gui;
 
 import java.awt.Color;
 import java.awt.Frame;
 
 import java.awt.Color;
 import java.awt.Frame;
+import java.awt.KeyEventDispatcher;
+import java.awt.KeyboardFocusManager;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
 
 import javax.swing.JButton;
 import javax.swing.JFrame;
 
 import javax.swing.JButton;
 import javax.swing.JFrame;
@@ -13,8 +20,9 @@ import javax.swing.JPasswordField;
 import javax.swing.JTextField;
 import javax.swing.SwingConstants;
 
 import javax.swing.JTextField;
 import javax.swing.SwingConstants;
 
-import businessLogic.LoginManager;
-import businessLogic.LoginManagerInterface;
+import common.LoginInterface;
+
+import configuration.___IntNames;
 import domain.Account;
 
 public class LoginGUI extends JFrame {
 import domain.Account;
 
 public class LoginGUI extends JFrame {
@@ -23,21 +31,52 @@ public class LoginGUI extends JFrame {
        private JPanel jContentPane = null;
        private JTextField usernameField;
        private JPasswordField passwordField;
        private JPanel jContentPane = null;
        private JTextField usernameField;
        private JPasswordField passwordField;
-       private LoginManagerInterface loginManager = new LoginManager();
+       private LoginInterface loginManager = null;
        private JLabel loginFeedback;
        private JButton btnRegister;
        private JLabel loginFeedback;
        private JButton btnRegister;
+       protected boolean isFocused = false;
        public LoginGUI() {
                super();
                initialize();
        }
 
        private void initialize() {
        public LoginGUI() {
                super();
                initialize();
        }
 
        private void initialize() {
+               try {
+                       loginManager = (LoginInterface) Naming
+                                       .lookup(___IntNames.LoginManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
                this.setSize(449, 293);
                this.setContentPane(getJContentPane());
                this.setTitle("Login");
                this.setSize(449, 293);
                this.setContentPane(getJContentPane());
                this.setTitle("Login");
+               addWindowListener(new WindowAdapter() {
+
 
 
+                       @Override
+                       public void windowGainedFocus(WindowEvent e) {
+                               isFocused = true;
+                       }
+
+                       @Override
+                       public void windowLostFocus(WindowEvent e) {
+                               isFocused = false;
+                       }
+               });
+
+        KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
+
+                       @Override
+                       public boolean dispatchKeyEvent(KeyEvent e) {
+                               if (isFocused && e.getKeyCode() == KeyEvent.VK_ENTER )
+                                       jButton_ActionPerformed();
+                               
+                               return false;
+                       }});
        }
 
        }
 
+       
        private JPanel getJContentPane() {
                if (jContentPane == null) {
                        jContentPane = new JPanel();
        private JPanel getJContentPane() {
                if (jContentPane == null) {
                        jContentPane = new JPanel();
@@ -64,7 +103,7 @@ public class LoginGUI extends JFrame {
                        loginButton.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent arg0) {
 
                        loginButton.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent arg0) {
 
-                               jButton_ActionPerformed(arg0);  
+                               jButton_ActionPerformed();      
                                }                                       
                        });
                        loginButton.setBounds(95, 179, 117, 25);
                                }                                       
                        });
                        loginButton.setBounds(95, 179, 117, 25);
@@ -97,9 +136,18 @@ public class LoginGUI extends JFrame {
                
                
        }
                
                
        }
-       private void jButton_ActionPerformed(ActionEvent e){
+
+
+       
+       private void jButton_ActionPerformed(){
                        
                        
-               Account acc = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword()));
+               Account acc = null;
+               try {
+                       acc = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword()));
+               } catch (RemoteException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
                if (acc == null) loginFeedback.setText("Incorrect username or password");
                else if( acc.getAdmin()) {
                        this.setVisible(false);
                if (acc == null) loginFeedback.setText("Incorrect username or password");
                else if( acc.getAdmin()) {
                        this.setVisible(false);
similarity index 89%
rename from ruralHouses/src/gui/ModifyHouseGUI.java
rename to ruralHouses client/src/gui/ModifyHouseGUI.java
index 06b679e..3377c69 100644 (file)
@@ -4,6 +4,8 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
 
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.JButton;
 
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.JButton;
@@ -15,7 +17,9 @@ import javax.swing.JTextField;
 import javax.swing.SwingConstants;
 import javax.swing.border.EmptyBorder;
 
 import javax.swing.SwingConstants;
 import javax.swing.border.EmptyBorder;
 
-import businessLogic.HouseManager;
+import common.HouseInterface;
+
+import configuration.___IntNames;
 import domain.Districs;
 import domain.HouseFeatures;
 import domain.Owner;
 import domain.Districs;
 import domain.HouseFeatures;
 import domain.Owner;
@@ -132,14 +136,26 @@ public class ModifyHouseGUI extends JFrame {
                                                                                baths_f.getText()), new Integer(
                                                                                lRooms_f.getText()), new Integer(
                                                                                parkings_f.getText())));
                                                                                baths_f.getText()), new Integer(
                                                                                lRooms_f.getText()), new Integer(
                                                                                parkings_f.getText())));
-                               HouseManager hm = new HouseManager();
-
-                               if (hm.registerNewHouse(newRh)) {
-                                       owner.getRuralHouses().add(newRh);
-                                       houseBox.removeItem(rh);
-                                       feedback.setText("House properly modified");
-                               } else
-                                       feedback.setText("Imposible to modify the house");
+                               HouseInterface hm= null;
+                               try {
+                                       hm = (HouseInterface) Naming
+                                                       .lookup(___IntNames.HouseManager);
+                               } catch (Exception e1) {
+                                       System.out.println("Error accessing remote authentication: "
+                                                       + e1.toString());
+                               }
+               
+                               try {
+                                       if (hm.registerNewHouse(newRh)) {
+                                               owner.getRuralHouses().add(newRh);
+                                               houseBox.removeItem(rh);
+                                               feedback.setText("House properly modified");
+                                       } else
+                                               feedback.setText("Imposible to modify the house");
+                               } catch (RemoteException e) {
+                                       // TODO Auto-generated catch block
+                                       e.printStackTrace();
+                               }
 
                        }
                });
 
                        }
                });
similarity index 96%
rename from ruralHouses/src/gui/ModifyOfferGUI.java
rename to ruralHouses client/src/gui/ModifyOfferGUI.java
index 6f69df6..4dbdacc 100644 (file)
@@ -11,6 +11,7 @@ import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.awt.event.ItemListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.rmi.Naming;
 import java.sql.Date;
 import java.text.DateFormat;
 import java.util.Calendar;
 import java.sql.Date;
 import java.text.DateFormat;
 import java.util.Calendar;
@@ -23,10 +24,10 @@ import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JTextField;
 
 import javax.swing.JLabel;
 import javax.swing.JTextField;
 
-import businessLogic.OfferManager;
-
 import com.toedter.calendar.JCalendar;
 import com.toedter.calendar.JCalendar;
+import common.OfferInterface;
 
 
+import configuration.___IntNames;
 import domain.Offer;
 import domain.RuralHouse;
 import exceptions.BadDates;
 import domain.Offer;
 import domain.RuralHouse;
 import exceptions.BadDates;
@@ -265,7 +266,15 @@ public class ModifyOfferGUI extends JFrame {
 
                        // Obtain the business logic from a StartWindow class (local or
                        // remote)
 
                        // Obtain the business logic from a StartWindow class (local or
                        // remote)
-                       OfferManager offerM = new OfferManager();
+                       OfferInterface offerM = null;
+                       try {
+                               offerM = (OfferInterface) Naming
+                                               .lookup(___IntNames.OfferManager);
+                       } catch (Exception e1) {
+                               System.out.println("Error accessing remote authentication: "
+                                               + e1.toString());
+                       }
+                       
                        offerM.deleteOffer(ruralHouse, (Offer) comboBox_o.getSelectedItem());
                        offerM.createOffer(ruralHouse, firstDay, lastDay, price);
 
                        offerM.deleteOffer(ruralHouse, (Offer) comboBox_o.getSelectedItem());
                        offerM.createOffer(ruralHouse, firstDay, lastDay, price);
 
@@ -3,6 +3,8 @@ package gui;
 import java.awt.Color;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.Color;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
 
 import javax.swing.JButton;
 import javax.swing.JFrame;
 
 import javax.swing.JButton;
 import javax.swing.JFrame;
@@ -11,7 +13,9 @@ import javax.swing.JPanel;
 import javax.swing.JTextField;
 import javax.swing.border.EmptyBorder;
 
 import javax.swing.JTextField;
 import javax.swing.border.EmptyBorder;
 
-import businessLogic.AdminManager;
+import common.AdminInterface;
+
+import configuration.___IntNames;
 import domain.Account;
 import domain.Owner;
 
 import domain.Account;
 import domain.Owner;
 
@@ -20,7 +24,7 @@ public class OwnerRegistrationGUI extends JFrame {
        private JPanel panel;
        private JTextField nameField;
        private JTextField userNameField;
        private JPanel panel;
        private JTextField nameField;
        private JTextField userNameField;
-       private AdminManager am = new AdminManager();
+       private AdminInterface am = null;
        private JTextField passField;
        private JTextField bank1Field;
        private JTextField bank2Field;
        private JTextField passField;
        private JTextField bank1Field;
        private JTextField bank2Field;
@@ -34,6 +38,14 @@ public class OwnerRegistrationGUI extends JFrame {
         * Create the frame.
         */
        public OwnerRegistrationGUI() {
         * Create the frame.
         */
        public OwnerRegistrationGUI() {
+               
+               try {
+                       am = (AdminInterface) Naming
+                                       .lookup(___IntNames.AdminManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
                setTitle("Owner registration");
                setBounds(100, 100, 500, 400);
                panel = new JPanel();
                setTitle("Owner registration");
                setBounds(100, 100, 500, 400);
                panel = new JPanel();
@@ -131,10 +143,15 @@ public class OwnerRegistrationGUI extends JFrame {
                Account acc = new Account(this.userNameField.getText(),
                                this.passField.getText(), own);
 
                Account acc = new Account(this.userNameField.getText(),
                                this.passField.getText(), own);
 
-               if (this.am.addAccount(acc)) {
-                       this.feedback.setText("Request sended");
-               } else {
-                       this.feedback.setText("Can't send the request");
+               try {
+                       if (this.am.addAccount(acc)) {
+                               this.feedback.setText("Request sended");
+                       } else {
+                               this.feedback.setText("Can't send the request");
+                       }
+               } catch (RemoteException e1) {
+                       // TODO Auto-generated catch block
+                       e1.printStackTrace();
                }
 
        }
                }
 
        }
@@ -12,6 +12,8 @@ import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.awt.event.MouseEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
 import java.sql.Date;
 import java.text.DateFormat;
 import java.util.Calendar;
 import java.sql.Date;
 import java.text.DateFormat;
 import java.util.Calendar;
@@ -32,10 +34,10 @@ import javax.swing.JRadioButton;
 import javax.swing.JTextField;
 import javax.swing.SwingConstants;
 
 import javax.swing.JTextField;
 import javax.swing.SwingConstants;
 
-import businessLogic.HouseManager;
-
 import com.toedter.calendar.JCalendar;
 import com.toedter.calendar.JCalendar;
+import common.HouseInterface;
 
 
+import configuration.___IntNames;
 import domain.Districs;
 import domain.RuralHouse;
 
 import domain.Districs;
 import domain.RuralHouse;
 
@@ -75,12 +77,20 @@ public class QueryAvailabilityGUI2 extends JFrame {
        private final JTextField nBaths = new JTextField();
        private final JLabel lblParkings = new JLabel("Parking slots:");
        private final JTextField nParkings = new JTextField();
        private final JTextField nBaths = new JTextField();
        private final JLabel lblParkings = new JLabel("Parking slots:");
        private final JTextField nParkings = new JTextField();
-       private HouseManager houseMan = new HouseManager();
+       private HouseInterface houseMan = null;
        private final JLabel lblNumberOfLivings = new JLabel("Number of Livings:");
        private final JTextField nLivings = new JTextField();
        private final JLabel feedback = new JLabel("");
 
        public QueryAvailabilityGUI2() {
        private final JLabel lblNumberOfLivings = new JLabel("Number of Livings:");
        private final JTextField nLivings = new JTextField();
        private final JLabel feedback = new JLabel("");
 
        public QueryAvailabilityGUI2() {
+               
+               try {
+                       houseMan =  (HouseInterface) Naming
+                                       .lookup(___IntNames.HouseManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
                nLivings.setText("0");
                nLivings.setColumns(10);
                nParkings.setText("0");
                nLivings.setText("0");
                nLivings.setColumns(10);
                nParkings.setText("0");
@@ -286,11 +296,17 @@ public class QueryAvailabilityGUI2 extends JFrame {
 
        private void jButton1_actionPerformed(ActionEvent e) {
                if (this.district.isSelected()) {
 
        private void jButton1_actionPerformed(ActionEvent e) {
                if (this.district.isSelected()) {
-                       Vector<RuralHouse> houses = houseMan.getHouses(null, jComboBox1
-                                       .getSelectedItem().toString(), Integer.parseInt(nBedrooms
-                                       .getText()), Integer.parseInt(nKitchens.getText()), Integer
-                                       .parseInt(nBaths.getText()), Integer.parseInt(nParkings
-                                       .getText()), Integer.parseInt(nLivings.getText()));
+                       Vector<RuralHouse> houses = null;
+                       try {
+                               houses = houseMan.getHouses(null, jComboBox1
+                                               .getSelectedItem().toString(), Integer.parseInt(nBedrooms
+                                               .getText()), Integer.parseInt(nKitchens.getText()), Integer
+                                               .parseInt(nBaths.getText()), Integer.parseInt(nParkings
+                                               .getText()), Integer.parseInt(nLivings.getText()));
+                       } catch (NumberFormatException | RemoteException e1) {
+                               // TODO Auto-generated catch block
+                               e1.printStackTrace();
+                       }
                        listOfHousesGUI list = new listOfHousesGUI(houses);
                        list.setVisible(true);
                } else if (this.ruralHouseName.isSelected()) {
                        listOfHousesGUI list = new listOfHousesGUI(houses);
                        list.setVisible(true);
                } else if (this.ruralHouseName.isSelected()) {
@@ -4,6 +4,8 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
 
 import javax.swing.JButton;
 import javax.swing.JComboBox;
 
 import javax.swing.JButton;
 import javax.swing.JComboBox;
@@ -13,7 +15,9 @@ import javax.swing.JPanel;
 import javax.swing.JRadioButton;
 import javax.swing.border.EmptyBorder;
 
 import javax.swing.JRadioButton;
 import javax.swing.border.EmptyBorder;
 
-import businessLogic.AdminManager;
+import common.AdminInterface;
+
+import configuration.___IntNames;
 import domain.Owner;
 import domain.RuralHouse;
 
 import domain.Owner;
 import domain.RuralHouse;
 
@@ -27,14 +31,20 @@ public class RequestDeleteHouseGUI extends JFrame {
        private Owner owner;
        private JComboBox<RuralHouse> comboBox;
        private JButton btnDelete;
        private Owner owner;
        private JComboBox<RuralHouse> comboBox;
        private JButton btnDelete;
-       private AdminManager am;
+       private AdminInterface am = null;
        JLabel feedback = new JLabel("");
 
        /**
         * Create the frame.
         */
        public RequestDeleteHouseGUI(Owner o) {
        JLabel feedback = new JLabel("");
 
        /**
         * Create the frame.
         */
        public RequestDeleteHouseGUI(Owner o) {
-               am  = new AdminManager();
+               try {
+                       am = (AdminInterface) Naming
+                                       .lookup(___IntNames.AdminManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
                this.owner = o;
                setBounds(100, 100, 450, 300);
                contentPane = new JPanel();
                this.owner = o;
                setBounds(100, 100, 450, 300);
                contentPane = new JPanel();
@@ -85,11 +95,16 @@ public class RequestDeleteHouseGUI extends JFrame {
        private void actionListenerButton(ActionEvent e){
                RuralHouse toDel = (RuralHouse)comboBox.getSelectedItem();
                
        private void actionListenerButton(ActionEvent e){
                RuralHouse toDel = (RuralHouse)comboBox.getSelectedItem();
                
-               if(am.addDeletionRequest(toDel)){
-                       feedback.setText("Delete request sended");
-                       
-               }else{
-                       feedback.setText("Request cannot be sended(Already sended)");
+               try {
+                       if(am.addDeletionRequest(toDel)){
+                               feedback.setText("Delete request sended");
+                               
+                       }else{
+                               feedback.setText("Request cannot be sended(Already sended)");
+                       }
+               } catch (RemoteException e1) {
+                       // TODO Auto-generated catch block
+                       e1.printStackTrace();
                }
        }
 }
                }
        }
 }
@@ -3,6 +3,8 @@ package gui;
 import java.awt.Color;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.Color;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
 
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.GroupLayout;
 
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.GroupLayout;
@@ -17,7 +19,9 @@ import javax.swing.LayoutStyle.ComponentPlacement;
 import javax.swing.SwingConstants;
 import javax.swing.border.EmptyBorder;
 
 import javax.swing.SwingConstants;
 import javax.swing.border.EmptyBorder;
 
-import businessLogic.AdminManager;
+import common.AdminInterface;
+
+import configuration.___IntNames;
 import domain.Districs;
 import domain.HouseFeatures;
 import domain.Owner;
 import domain.Districs;
 import domain.HouseFeatures;
 import domain.Owner;
@@ -48,7 +52,7 @@ public class RequestNewHouseGUI extends JFrame {
        private JLabel lblBaths;
        private JTextField baths_f;
        private JButton btnRegister;
        private JLabel lblBaths;
        private JTextField baths_f;
        private JButton btnRegister;
-       private AdminManager am;
+       private AdminInterface am = null;
        private JComboBox<String> comboBox;
 
 
        private JComboBox<String> comboBox;
 
 
@@ -58,7 +62,13 @@ public class RequestNewHouseGUI extends JFrame {
        public RequestNewHouseGUI(Owner o) {
                comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
                                Districs.longNames()));
        public RequestNewHouseGUI(Owner o) {
                comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
                                Districs.longNames()));
-               am  = new AdminManager();
+               try {
+                       am = (AdminInterface) Naming
+                                       .lookup(___IntNames.AdminManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
                this.setTitle("New House");
                setBackground(Color.WHITE);
                this.getContentPane().setLayout(null);
                this.setTitle("New House");
                setBackground(Color.WHITE);
                this.getContentPane().setLayout(null);
@@ -134,10 +144,15 @@ public class RequestNewHouseGUI extends JFrame {
                                        e.printStackTrace();
                                }
                                
                                        e.printStackTrace();
                                }
                                
-                               if(am.addAdditionRequest(rh)){
-                                       feedback.setText("Request sended");
-                               }else{
-                                       feedback.setText("Request cannot be sended(Already added)");
+                               try {
+                                       if(am.addAdditionRequest(rh)){
+                                               feedback.setText("Request sended");
+                                       }else{
+                                               feedback.setText("Request cannot be sended(Already added)");
+                                       }
+                               } catch (RemoteException e) {
+                                       // TODO Auto-generated catch block
+                                       e.printStackTrace();
                                }
                        }
                });
                                }
                        }
                });
similarity index 74%
rename from ruralHouses/src/gui/StartWindow.java
rename to ruralHouses client/src/gui/StartWindow.java
index 385d09b..5325d56 100644 (file)
@@ -5,6 +5,9 @@ package gui;
  */
 import java.awt.Color;
 import java.awt.Font;
  */
 import java.awt.Color;
 import java.awt.Font;
+import java.awt.KeyEventDispatcher;
+import java.awt.KeyboardFocusManager;
+import java.awt.event.KeyEvent;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
 import java.rmi.RMISecurityManager;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
 import java.rmi.RMISecurityManager;
@@ -18,10 +21,9 @@ import javax.swing.UIManager;
 
 import configuration.ConfigXML;
 
 
 import configuration.ConfigXML;
 
-
 @SuppressWarnings("deprecation")
 public class StartWindow extends JFrame {
 @SuppressWarnings("deprecation")
 public class StartWindow extends JFrame {
-       
+
        private static final long serialVersionUID = 1L;
 
        private JPanel jContentPane = null;
        private static final long serialVersionUID = 1L;
 
        private JPanel jContentPane = null;
@@ -29,39 +31,42 @@ public class StartWindow extends JFrame {
        private JButton boton3 = null;
        private static configuration.ConfigXML c;
 
        private JButton boton3 = null;
        private static configuration.ConfigXML c;
 
-       //public static ApplicationFacadeInterface facadeInterface;
+       // public static ApplicationFacadeInterface facadeInterface;
        private JLabel lblNewLabel;
        private JLabel lblNewLabel;
-       
+
        public static void main(String[] args) {
 
                StartWindow a = new StartWindow();
        public static void main(String[] args) {
 
                StartWindow a = new StartWindow();
-               a.setVisible(true);
                
                
+               System.setProperty("java.security.policy", "java.policy");
+               
+               a.setVisible(true);
+
                try {
 
                try {
 
-                       c=ConfigXML.getInstance();
+                       c = ConfigXML.getInstance();
 
                        System.setProperty("java.security.policy", c.getJavaPolicyPath());
 
                        System.setProperty("java.security.policy", c.getJavaPolicyPath());
-                                               
+
                        System.setSecurityManager(new RMISecurityManager());
 
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
 
                        System.setSecurityManager(new RMISecurityManager());
 
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
 
-                       c=configuration.ConfigXML.getInstance();
+                       c = configuration.ConfigXML.getInstance();
 
 
-               }catch (com.db4o.ext.DatabaseFileLockedException e) {
-                       a.lblNewLabel.setText("Database locked: Do not run BusinessLogicServer or BusinessLogicServer!!");
-                       a.lblNewLabel.setForeground(Color.RED);         
-                       System.out.println("Error in StartWindow: "+e.toString());
+               } catch (com.db4o.ext.DatabaseFileLockedException e) {
+                       a.lblNewLabel
+                                       .setText("Database locked: Do not run BusinessLogicServer or BusinessLogicServer!!");
+                       a.lblNewLabel.setForeground(Color.RED);
+                       System.out.println("Error in StartWindow: " + e.toString());
                } catch (Exception e) {
                } catch (Exception e) {
-                       a.lblNewLabel.setText("Error: "+e.toString());
-                       a.lblNewLabel.setForeground(Color.RED);         
-                       System.out.println("Error in StartWindow: "+e.toString());
+                       a.lblNewLabel.setText("Error: " + e.toString());
+                       a.lblNewLabel.setForeground(Color.RED);
+                       System.out.println("Error in StartWindow: " + e.toString());
                }
 
                }
 
-               
-
        }
        }
+
        /**
         * This is the default constructor
         */
        /**
         * This is the default constructor
         */
@@ -75,12 +80,26 @@ public class StartWindow extends JFrame {
 
                                System.exit(1);
                        }
 
                                System.exit(1);
                        }
+
                });
                });
+
+               KeyboardFocusManager.getCurrentKeyboardFocusManager()
+                               .addKeyEventDispatcher(new KeyEventDispatcher() {
+
+                                       @Override
+                                       public boolean dispatchKeyEvent(KeyEvent e) {
+                                               switch (e.getKeyCode()) {
+
+                                               case KeyEvent.VK_ESCAPE:
+                                                       System.exit(1);
+                                               
+                                               }
+                                               return false;
+                                       }
+                               });
                initialize();
                initialize();
-               //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+               // this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }
        }
-       
-       
 
        /**
         * This method initializes this
 
        /**
         * This method initializes this
@@ -130,7 +149,7 @@ public class StartWindow extends JFrame {
                }
                return boton2;
        }
                }
                return boton2;
        }
-       
+
        /**
         * This method initializes boton3
         * 
        /**
         * This method initializes boton3
         * 
@@ -144,7 +163,7 @@ public class StartWindow extends JFrame {
                        boton3.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent e) {
                                        // C?digo cedido por la universidad
                        boton3.addActionListener(new java.awt.event.ActionListener() {
                                public void actionPerformed(java.awt.event.ActionEvent e) {
                                        // C?digo cedido por la universidad
-                                       //JFrame a = new QueryAvailabilityWindow();
+                                       // JFrame a = new QueryAvailabilityWindow();
                                        JFrame a = new QueryAvailabilityGUI2();
 
                                        a.setVisible(true);
                                        JFrame a = new QueryAvailabilityGUI2();
 
                                        a.setVisible(true);
@@ -153,7 +172,6 @@ public class StartWindow extends JFrame {
                }
                return boton3;
        }
                }
                return boton3;
        }
-       
 
        private JLabel getLblNewLabel() {
                if (lblNewLabel == null) {
 
        private JLabel getLblNewLabel() {
                if (lblNewLabel == null) {
@@ -4,6 +4,8 @@ import java.awt.Font;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
 import java.util.Enumeration;
 import java.util.Vector;
 
 import java.util.Enumeration;
 import java.util.Vector;
 
@@ -16,10 +18,10 @@ import javax.swing.JTable;
 import javax.swing.border.EmptyBorder;
 import javax.swing.table.DefaultTableModel;
 
 import javax.swing.border.EmptyBorder;
 import javax.swing.table.DefaultTableModel;
 
-import businessLogic.AdminManager;
-import businessLogic.HouseManager;
-import businessLogic.HouseManagerInterface;
-import domain.Administrator;
+import common.AdminInterface;
+import common.HouseInterface;
+
+import configuration.___IntNames;
 import domain.RuralHouse;
 
 public class listOfAdditionRequestsGUI extends JFrame {
 import domain.RuralHouse;
 
 public class listOfAdditionRequestsGUI extends JFrame {
@@ -31,12 +33,21 @@ public class listOfAdditionRequestsGUI extends JFrame {
        private JPanel contentPane;
        private JTable table;
        private DefaultTableModel tableModel;
        private JPanel contentPane;
        private JTable table;
        private DefaultTableModel tableModel;
-       private AdminManager am = new AdminManager();
+       private AdminInterface am = null;
        private Vector<RuralHouse> houses;
        /**
         * Create the frame.
         */
        public listOfAdditionRequestsGUI() {
        private Vector<RuralHouse> houses;
        /**
         * Create the frame.
         */
        public listOfAdditionRequestsGUI() {
+               
+               try {
+                       am = (AdminInterface) Naming
+                                       .lookup(___IntNames.AdminManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
+               
                setTitle("Adding requests");
                try {
                        this.houses= am.getAdditionRequests();
                setTitle("Adding requests");
                try {
                        this.houses= am.getAdditionRequests();
@@ -86,12 +97,26 @@ public class listOfAdditionRequestsGUI extends JFrame {
                btnNewButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
                btnNewButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
-                                       HouseManagerInterface hm = new HouseManager();
+                                       HouseInterface hm= null;
+                                       try {
+                                               hm = (HouseInterface) Naming
+                                                               .lookup(___IntNames.HouseManager);
+                                       } catch (Exception e1) {
+                                               System.out.println("Error accessing remote authentication: "
+                                                               + e1.toString());
+                                       }
+                                       
                                        RuralHouse rh = houses.get(table.getSelectedRow());
                                        //TODO when the house is not added show a warning to the user. Method below returns a boolean stating that.
                                        RuralHouse rh = houses.get(table.getSelectedRow());
                                        //TODO when the house is not added show a warning to the user. Method below returns a boolean stating that.
-                                       hm.registerNewHouse(rh);
-                                       am.removeHouseAdditionRequests(rh);
-                                       Administrator.saveInstance();
+                                       try {
+                                               hm.registerNewHouse(rh);
+                                               am.removeHouseAdditionRequests(rh);
+                                               am.saveInstance();
+                                       } catch (RemoteException e1) {
+                                               // TODO Auto-generated catch block
+                                               e1.printStackTrace();
+                                       }
+                                       
                                        ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
                                        houses.remove(rh);
                                }
                                        ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
                                        houses.remove(rh);
                                }
@@ -105,8 +130,13 @@ public class listOfAdditionRequestsGUI extends JFrame {
                        public void actionPerformed(ActionEvent arg0) {
                                if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
                                        RuralHouse rh = houses.get(table.getSelectedRow());
                        public void actionPerformed(ActionEvent arg0) {
                                if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
                                        RuralHouse rh = houses.get(table.getSelectedRow());
-                                       am.removeHouseAdditionRequests(rh);
-                                       Administrator.saveInstance();
+                                       try {
+                                               am.removeHouseAdditionRequests(rh);
+                                               am.saveInstance();
+                                       } catch (RemoteException e) {
+                                               // TODO Auto-generated catch block
+                                               e.printStackTrace();
+                                       }
                                        ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
                                        houses.remove(rh);
                                }
                                        ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
                                        houses.remove(rh);
                                }
@@ -4,6 +4,7 @@ import java.awt.Font;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.rmi.RemoteException;
 import java.util.Enumeration;
 import java.util.Vector;
 
 import java.util.Enumeration;
 import java.util.Vector;
 
@@ -16,7 +17,8 @@ import javax.swing.JTable;
 import javax.swing.border.EmptyBorder;
 import javax.swing.table.DefaultTableModel;
 
 import javax.swing.border.EmptyBorder;
 import javax.swing.table.DefaultTableModel;
 
-import businessLogic.BookingManager;
+import common.BookingInterface;
+
 import domain.Booking;
 import domain.Offer;
 
 import domain.Booking;
 import domain.Offer;
 
@@ -29,7 +31,7 @@ public class listOfBookingRequestsGUI extends JFrame {
        private JPanel contentPane;
        private JTable table;
        private Offer off;
        private JPanel contentPane;
        private JTable table;
        private Offer off;
-       private BookingManager bookM = new BookingManager();
+       private BookingInterface bookM =null;
        private DefaultTableModel tableModel;
        private Vector<Booking> bookings = new Vector<Booking>();
 
        private DefaultTableModel tableModel;
        private Vector<Booking> bookings = new Vector<Booking>();
 
@@ -39,6 +41,7 @@ public class listOfBookingRequestsGUI extends JFrame {
        public listOfBookingRequestsGUI(Offer of) {
                setTitle("Adding requests");
                this.off = of;
        public listOfBookingRequestsGUI(Offer of) {
                setTitle("Adding requests");
                this.off = of;
+
                try {
 
                        init();
                try {
 
                        init();
@@ -90,8 +93,13 @@ public class listOfBookingRequestsGUI extends JFrame {
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
                                        if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
                                                Booking book = bookings.get(table.getSelectedRow());
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
                                        if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
                                                Booking book = bookings.get(table.getSelectedRow());
-                                               bookM.acceptBooking(book);
+                                               try {
+                                                       bookM.acceptBooking(book);
+                                               } catch (RemoteException e1) {
+                                                       e1.printStackTrace();
+                                               }
                                        }
                                        }
+
                                }
                        }
                });
                                }
                        }
                });
@@ -103,7 +111,12 @@ public class listOfBookingRequestsGUI extends JFrame {
                        public void actionPerformed(ActionEvent arg0) {
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
                                        Booking book = bookings.get(table.getSelectedRow());
                        public void actionPerformed(ActionEvent arg0) {
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
                                        Booking book = bookings.get(table.getSelectedRow());
-                                       bookM.removeDenyBooking(book);
+                                       try {
+                                               bookM.removeDenyBooking(book);
+                                       } catch (RemoteException e) {
+                                               e.printStackTrace();
+                                       }
+
                                }
                        }
                });
                                }
                        }
                });
@@ -4,6 +4,8 @@ import java.awt.Font;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
 import java.util.Enumeration;
 import java.util.Vector;
 
 import java.util.Enumeration;
 import java.util.Vector;
 
@@ -16,12 +18,13 @@ import javax.swing.JTable;
 import javax.swing.border.EmptyBorder;
 import javax.swing.table.DefaultTableModel;
 
 import javax.swing.border.EmptyBorder;
 import javax.swing.table.DefaultTableModel;
 
-import businessLogic.AccountManager;
-import businessLogic.AdminManager;
+import common.AccountInterface;
+import common.AdminInterface;
+
+import configuration.___IntNames;
 import domain.Account;
 import domain.Account;
-import domain.Administrator;
 
 
-public class ownerAddittionRequests extends JFrame {
+public class listOfOwnerAddittionRequests extends JFrame {
 
        /**
         * 
 
        /**
         * 
@@ -30,15 +33,22 @@ public class ownerAddittionRequests extends JFrame {
        private JPanel contentPane;
        private JTable table;
        private DefaultTableModel tableModel;
        private JPanel contentPane;
        private JTable table;
        private DefaultTableModel tableModel;
-       private AdminManager am = new AdminManager();
+       private AdminInterface am = null;
        private Vector<Account> accounts;
        /**
         * Create the frame.
         */
        private Vector<Account> accounts;
        /**
         * Create the frame.
         */
-       public  ownerAddittionRequests()  {
+       public  listOfOwnerAddittionRequests()  {
+               try {
+                       am = (AdminInterface) Naming
+                                       .lookup(___IntNames.AdminManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }               
                setTitle("Adding requests");
                try {
                setTitle("Adding requests");
                try {
-                       this.accounts= am.getOwnerAdditionReuests();
+                       this.accounts= am.getOwnerAdditionRequests();
                        init();
                } catch (Exception e) {
                        e.printStackTrace();
                        init();
                } catch (Exception e) {
                        e.printStackTrace();
@@ -46,6 +56,14 @@ public class ownerAddittionRequests extends JFrame {
        }
 
        private void init() throws Exception {
        }
 
        private void init() throws Exception {
+               
+               try {
+                       am = (AdminInterface) Naming
+                                       .lookup(___IntNames.AdminManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
                setBounds(100, 100, 600, 450);
                contentPane = new JPanel();
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
                setBounds(100, 100, 600, 450);
                contentPane = new JPanel();
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
@@ -84,12 +102,25 @@ public class ownerAddittionRequests extends JFrame {
                btnNewButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
                btnNewButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
-                                       AccountManager ama = new AccountManager();
+                                       AccountInterface acm = null;
+                                       
+                                       try {
+                                               acm = (AccountInterface) Naming
+                                                               .lookup(___IntNames.AdminManager);
+                                       } catch (Exception e1) {
+                                               System.out.println("Error accessing remote authentication: "
+                                                               + e1.toString());
+                                       }
                                        Account accou = accounts.get(table.getSelectedRow());
                                        Account accou = accounts.get(table.getSelectedRow());
-                                       //TODO when the house is not added show a warning to the user. Method below returns a boolean stating that.
-                                       ama.addAccount(accou);
-                                       am.removeOwnerAdditionRequests(accou);;
-                                       Administrator.saveInstance();
+                                       try {
+                                               acm.addAccount(accou);
+                                               am.removeOwnerAdditionRequests(accou);
+                                               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(accounts.indexOf(accou));
                                        accounts.remove(accou);
                                }
@@ -103,8 +134,14 @@ public class ownerAddittionRequests extends JFrame {
                        public void actionPerformed(ActionEvent arg0) {
                                if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
                                        Account acc = accounts.get(table.getSelectedRow());
                        public void actionPerformed(ActionEvent arg0) {
                                if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
                                        Account acc = accounts.get(table.getSelectedRow());
-                                       am.removeOwnerAdditionRequests(acc);
-                                       Administrator.saveInstance();
+                                       try {
+                                               am.removeOwnerAdditionRequests(acc);
+                                               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(accounts.indexOf(acc));
                                        accounts.remove(acc);
                                }
@@ -4,6 +4,8 @@ import java.awt.Font;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
 import java.util.Enumeration;
 import java.util.Vector;
 
 import java.util.Enumeration;
 import java.util.Vector;
 
@@ -16,10 +18,10 @@ import javax.swing.JTable;
 import javax.swing.border.EmptyBorder;
 import javax.swing.table.DefaultTableModel;
 
 import javax.swing.border.EmptyBorder;
 import javax.swing.table.DefaultTableModel;
 
-import businessLogic.AdminManager;
-import businessLogic.HouseManager;
-import businessLogic.HouseManagerInterface;
-import domain.Administrator;
+import common.AdminInterface;
+import common.HouseInterface;
+
+import configuration.___IntNames;
 import domain.RuralHouse;
 
 public class listOfRemovalRequestsGUI extends JFrame {
 import domain.RuralHouse;
 
 public class listOfRemovalRequestsGUI extends JFrame {
@@ -31,13 +33,20 @@ public class listOfRemovalRequestsGUI extends JFrame {
        private JPanel contentPane;
        private JTable table;
        private DefaultTableModel tableModel;
        private JPanel contentPane;
        private JTable table;
        private DefaultTableModel tableModel;
-       private AdminManager am = new AdminManager();
+       private AdminInterface am = null;
        private Vector<RuralHouse> houses;
 
        /**
         * Create the frame.
         */
        public listOfRemovalRequestsGUI() {
        private Vector<RuralHouse> houses;
 
        /**
         * Create the frame.
         */
        public listOfRemovalRequestsGUI() {
+               try {
+                       am = (AdminInterface) Naming
+                                       .lookup(___IntNames.AdminManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
                setTitle("Deleting requests");
                try {
                        this.houses = am.getDeletionRequests();
                setTitle("Deleting requests");
                try {
                        this.houses = am.getDeletionRequests();
@@ -85,13 +94,26 @@ public class listOfRemovalRequestsGUI extends JFrame {
                btnNewButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
                btnNewButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
-                                       HouseManagerInterface hm = new HouseManager();
+                                       HouseInterface hm= null;
+                                       try {
+                                               hm = (HouseInterface) Naming
+                                                               .lookup(___IntNames.HouseManager);
+                                       } catch (Exception e1) {
+                                               System.out.println("Error accessing remote authentication: "
+                                                               + e1.toString());
+                                       }
                                        RuralHouse rh = houses.get(table.getSelectedRow());
                                        ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
                                        RuralHouse rh = houses.get(table.getSelectedRow());
                                        ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
-                                               hm.removeHouse(rh, rh.getOwner());
+                                               try {
+                                                       hm.removeHouse(rh, rh.getOwner());
+                                                       am.removeHouseDeletionRequests(rh);
+                                                       am.saveInstance();
+                                               } catch (RemoteException e1) {
+                                                       // TODO Auto-generated catch block
+                                                       e1.printStackTrace();
+                                               }
                                                houses.remove(rh);
                                                houses.remove(rh);
-                                               am.removeHouseDeletionRequests(rh);
-                                               Administrator.saveInstance();
+                                               
 
                                        
                                }
 
                                        
                                }
@@ -107,8 +129,14 @@ public class listOfRemovalRequestsGUI extends JFrame {
                                        RuralHouse rh = houses.get(table.getSelectedRow());
                                        ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
                                                houses.remove(rh);
                                        RuralHouse rh = houses.get(table.getSelectedRow());
                                        ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
                                                houses.remove(rh);
-                                               am.removeHouseDeletionRequests(rh);
-                                               Administrator.saveInstance();
+                                               try {
+                                                       am.removeHouseDeletionRequests(rh);
+                                                       am.saveInstance();
+                                               } catch (RemoteException e1) {
+                                                       // TODO Auto-generated catch block
+                                                       e1.printStackTrace();
+                                               }
+                                               
 
                                        
                                }
 
                                        
                                }
index 833b790..4a939f6 100644 (file)
@@ -4,6 +4,6 @@
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
        <classpathentry kind="lib" path="lib/additionalLibs/jcalendar.jar"/>
        <classpathentry kind="lib" path="lib/db4o/lib/db4o-8.0.249.16098-all-java5.jar"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
        <classpathentry kind="lib" path="lib/additionalLibs/jcalendar.jar"/>
        <classpathentry kind="lib" path="lib/db4o/lib/db4o-8.0.249.16098-all-java5.jar"/>
-       <classpathentry kind="lib" path="lib/javax.mail.jar"/>
+       <classpathentry kind="lib" path="lib/mail/javax.mail.jar"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>
        <classpathentry kind="output" path="bin"/>
 </classpath>
index 2a22d9f..b83f20a 100644 (file)
@@ -1,4 +1,5 @@
 /bin
 /lib
 /bin
 /lib
+!lib/mail/
 /db
 /db
-/src/*/*.class
\ No newline at end of file
+/src/*/*.class
index 7b5efe9..3f0bc5b 100644 (file)
@@ -1,16 +1,24 @@
 package businessLogic;
 
 package businessLogic;
 
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
 import javax.mail.MessagingException;
 
 import javax.mail.MessagingException;
 
+import common.AccountInterface;
 import dataAccess.DB4oManager;
 import domain.Account;
 
 import dataAccess.DB4oManager;
 import domain.Account;
 
-public class AccountManager {
+public class AccountManager extends UnicastRemoteObject implements AccountInterface {
        
        
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
        private DB4oManager dbMngr;
        
        
        private DB4oManager dbMngr;
        
        
-       public AccountManager() {
+       public AccountManager() throws RemoteException {
                try {
                        dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
                try {
                        dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
@@ -19,12 +27,11 @@ public class AccountManager {
                }
        }
        
                }
        }
        
-       public boolean addAccount(Account ac){
+       public boolean addAccount(Account ac) throws RemoteException {
                if(this.dbMngr.addAccount(ac)){
                        try {
                                MailManager.getInstance().Send(ac.getOwner().getMailAccount(), "Entered into the system", "Congratulations");
                        } catch (MessagingException e) {
                if(this.dbMngr.addAccount(ac)){
                        try {
                                MailManager.getInstance().Send(ac.getOwner().getMailAccount(), "Entered into the system", "Congratulations");
                        } catch (MessagingException e) {
-                               // TODO Auto-generated catch block
                                e.printStackTrace();
                        }
                        return true;
                                e.printStackTrace();
                        }
                        return true;
@@ -33,7 +40,7 @@ public class AccountManager {
                
        }
        
                
        }
        
-       public boolean removeAccount(Account ac){
+       public boolean removeAccount(Account ac)throws RemoteException {
                if(this.dbMngr.removeAccount(ac))
                        return true;
                return false;
                if(this.dbMngr.removeAccount(ac))
                        return true;
                return false;
index a51ec98..f2790a9 100644 (file)
@@ -1,61 +1,89 @@
 package businessLogic;
 
 package businessLogic;
 
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
 import java.util.Vector;
 
 import java.util.Vector;
 
+import common.AdminInterface;
+
 import domain.Account;
 import domain.Administrator;
 import domain.RuralHouse;
 
 import domain.Account;
 import domain.Administrator;
 import domain.RuralHouse;
 
-public class AdminManager {
-       public AdminManager() {
+public class AdminManager extends UnicastRemoteObject implements AdminInterface {
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+
+
+
+
+       public AdminManager() throws RemoteException {
 
        }
 
 
        }
 
-       public Vector<RuralHouse> getAdditionRequests() {
+       public Vector<RuralHouse> getAdditionRequests() throws RemoteException {
                return new Vector<RuralHouse>(Administrator.getInstance()
                                .getAddRequest());
        }
 
                return new Vector<RuralHouse>(Administrator.getInstance()
                                .getAddRequest());
        }
 
-       public Vector<RuralHouse> getDeletionRequests() {
+       public Vector<RuralHouse> getDeletionRequests() throws RemoteException {
                return new Vector<RuralHouse>(Administrator.getInstance()
                                .getRemoveRequest());
        }
 
                return new Vector<RuralHouse>(Administrator.getInstance()
                                .getRemoveRequest());
        }
 
-       public Vector<Account> getOwnerAdditionReuests() {
+       public Vector<Account> getOwnerAdditionRequests() throws RemoteException {
                return new Vector<Account>(Administrator.getInstance()
                                .getNewOwnerRequest());
        }
        
                return new Vector<Account>(Administrator.getInstance()
                                .getNewOwnerRequest());
        }
        
-       public void removeHouseAdditionRequests(RuralHouse house) {
+       public void removeHouseAdditionRequests(RuralHouse house) throws RemoteException {
                Administrator.getInstance().getAddRequest().remove(house);
        }
 
                Administrator.getInstance().getAddRequest().remove(house);
        }
 
-       public void removeHouseDeletionRequests(RuralHouse house) {
+       public void removeHouseDeletionRequests(RuralHouse house) throws RemoteException {
                Administrator.getInstance().getRemoveRequest().remove(house);
        }
                Administrator.getInstance().getRemoveRequest().remove(house);
        }
-       public void removeOwnerAdditionRequests(Account acc) {
+       
+       public void removeOwnerAdditionRequests(Account acc) throws RemoteException {
                Administrator.getInstance().getNewOwnerRequest().remove(acc);
        }
                Administrator.getInstance().getNewOwnerRequest().remove(acc);
        }
-       public boolean addAdditionRequest(RuralHouse rh) {
+       
+       public boolean addAdditionRequest(RuralHouse rh) throws RemoteException {
                if (this.getAdditionRequests().contains(rh)) {
                        return false;
                }
                return Administrator.getInstance().getAddRequest().add(rh);
                if (this.getAdditionRequests().contains(rh)) {
                        return false;
                }
                return Administrator.getInstance().getAddRequest().add(rh);
+
        }
 
        }
 
-       public boolean addDeletionRequest(RuralHouse rh) {
+       public boolean addDeletionRequest(RuralHouse rh) throws RemoteException {
                if (this.getDeletionRequests().contains(rh))
                        return false;
                if (this.getDeletionRequests().contains(rh))
                        return false;
+
                return Administrator.getInstance().getRemoveRequest().add(rh);
                return Administrator.getInstance().getRemoveRequest().add(rh);
+
        }
        
        }
        
-       public boolean addAccount(Account acc) {
-               if (this.getOwnerAdditionReuests().contains(acc)) {
+       
+
+       
+       public boolean addAccount(Account acc) throws RemoteException {
+               if (this.getOwnerAdditionRequests().contains(acc)) {
                        return false;
                }
                return Administrator.getInstance().getNewOwnerRequest().add(acc);
        }
 
                        return false;
                }
                return Administrator.getInstance().getNewOwnerRequest().add(acc);
        }
 
+       @Override
+       public void saveInstance() throws RemoteException {
+               Administrator.saveInstance();
+               
+       }
+
+
+
 //     public boolean removeAccount(Account acc) {
 //             if (this.getDeletionRequests().contains(acc))
 //                     return false;
 //     public boolean removeAccount(Account acc) {
 //             if (this.getDeletionRequests().contains(acc))
 //                     return false;
index 017b1aa..601eb3a 100644 (file)
@@ -1,12 +1,13 @@
 package businessLogic;
 
 package businessLogic;
 
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
 import java.util.Date;
 import java.util.Vector;
 
 import java.util.Date;
 import java.util.Vector;
 
-import javax.mail.MessagingException;
-
 import com.db4o.ObjectContainer;
 import com.db4o.ObjectSet;
 import com.db4o.ObjectContainer;
 import com.db4o.ObjectSet;
+import common.BookingInterface;
 
 import dataAccess.DB4oManager;
 import domain.Booking;
 
 import dataAccess.DB4oManager;
 import domain.Booking;
@@ -14,14 +15,21 @@ import domain.Client;
 import domain.RuralHouse;
 import exceptions.OfferCanNotBeBooked;
 
 import domain.RuralHouse;
 import exceptions.OfferCanNotBeBooked;
 
-public final class BookingManager {
 
 
+
+public final class BookingManager extends UnicastRemoteObject implements BookingInterface {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
        private int bookingNumber = 0;
        dataAccess.DB4oManager dbMngr;
 
        private static BookingManager theBookingManager;
 
        private int bookingNumber = 0;
        dataAccess.DB4oManager dbMngr;
 
        private static BookingManager theBookingManager;
 
-       public BookingManager() {
+       public BookingManager() throws RemoteException {
+               super();
                try {
                        this.dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
                try {
                        this.dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
@@ -34,52 +42,54 @@ public final class BookingManager {
         * 
         * @return the book number
         */
         * 
         * @return the book number
         */
-       public static int getNumber() {
-               ObjectContainer db = DB4oManager.getContainer();
-               BookingManager b = getInstance();
-               b.bookingNumber++;
-               db.store(b);
-               db.commit();
-               return b.bookingNumber;
-       }
 
 
+    public int getNumber() throws RemoteException{
+               ObjectContainer db=DB4oManager.getContainer();
+       BookingManager b=getInstance();
+       b.bookingNumber++;
+       db.store(b);
+       db.commit();
+       return b.bookingNumber;
+    }
+       
        /**
         * This method returns the instance of the BookingManager class
         * 
         * @return the booking manager
        /**
         * This method returns the instance of the BookingManager class
         * 
         * @return the booking manager
+        * @throws RemoteException 
         */
         */
-       public static BookingManager getInstance() {
-               ObjectContainer db = DB4oManager.getContainer();
-               BookingManager b = new BookingManager();
-               ObjectSet<BookingManager> result = db.queryByExample(b);
-               if (!result.hasNext()) {
-                       theBookingManager = new BookingManager();
-                       db.store(theBookingManager);
-                       db.commit();
-               } else
-                       theBookingManager = (BookingManager) result.next();
+
+       public BookingManager getInstance() throws RemoteException  {
+               ObjectContainer db=DB4oManager.getContainer();
+           BookingManager b = new BookingManager();
+           ObjectSet<BookingManager> result = db.queryByExample(b);
+           if (!result.hasNext()){
+               theBookingManager = new BookingManager();
+               db.store(theBookingManager);
+               db.commit();
+           } else theBookingManager=(BookingManager)result.next();
                return theBookingManager;
        }
 
                return theBookingManager;
        }
 
-       public void removeDenyBooking(Booking b){
+       public void removeDenyBooking(Booking b) throws RemoteException{
                                b.getOffer().getBookings().remove(b);
                                this.dbMngr.removeBooking(b);
        }
 
 
                                b.getOffer().getBookings().remove(b);
                                this.dbMngr.removeBooking(b);
        }
 
 
-       public void acceptBooking(Booking b){
+       public void acceptBooking(Booking b) throws RemoteException{
                b.getOffer().setBooked(true);
                for(Booking boo : b.getOffer().getBookings()){
                        if(!boo.equals(b))
                                b.getOffer().getBookings().remove(b);
                }
                this.dbMngr.acceptBooking(b.getOffer());
                b.getOffer().setBooked(true);
                for(Booking boo : b.getOffer().getBookings()){
                        if(!boo.equals(b))
                                b.getOffer().getBookings().remove(b);
                }
                this.dbMngr.acceptBooking(b.getOffer());
-               try {
+               /*try {
                        MailManager.getInstance().Send(b.getClient().getMailAccount(), "Your booking has been accepted","Here should be the bill");
                } catch (MessagingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                        MailManager.getInstance().Send(b.getClient().getMailAccount(), "Your booking has been accepted","Here should be the bill");
                } catch (MessagingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
-               }
+               }*/
                
        }
        /**
                
        }
        /**
@@ -91,7 +101,7 @@ public final class BookingManager {
         */
        public Vector<Booking> createBooking(RuralHouse ruralHouse, Date firstDate,
                        Date lastDate, Client client)
         */
        public Vector<Booking> createBooking(RuralHouse ruralHouse, Date firstDate,
                        Date lastDate, Client client)
-                       throws OfferCanNotBeBooked {
+                       throws OfferCanNotBeBooked,RemoteException {
 
                return dbMngr.createBooking(ruralHouse, firstDate, lastDate,
                                client);
 
                return dbMngr.createBooking(ruralHouse, firstDate, lastDate,
                                client);
index e3e5317..cd3f11e 100644 (file)
@@ -1,17 +1,24 @@
 package businessLogic;
 
 import java.rmi.RemoteException;
 package businessLogic;
 
 import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
 import java.util.Vector;
 
 import java.util.Vector;
 
+import common.HouseInterface;
+
 import dataAccess.DB4oManager;
 import domain.Owner;
 import domain.RuralHouse;
 
 import dataAccess.DB4oManager;
 import domain.Owner;
 import domain.RuralHouse;
 
-public class HouseManager implements HouseManagerInterface {
-       
-       private DB4oManager dbMngr;
 
 
-       public HouseManager() {
+public class HouseManager extends UnicastRemoteObject implements HouseInterface {
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+       DB4oManager dbMngr;
+       public HouseManager() throws RemoteException {
+               super();
                try {
                        dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
                try {
                        dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
index 950f683..1f766a3 100644 (file)
@@ -1,18 +1,26 @@
 package businessLogic;
 
 
 package businessLogic;
 
 
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
 import java.util.Vector;
 
 import java.util.Vector;
 
+import common.LoginInterface;
+
 import dataAccess.DB4oManager;
 import domain.Account;
 
 
 import dataAccess.DB4oManager;
 import domain.Account;
 
 
-public class LoginManager implements LoginManagerInterface {
+public class LoginManager extends UnicastRemoteObject implements LoginInterface {
 
 
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
        DB4oManager dbMngr;
 
        DB4oManager dbMngr;
 
-       public LoginManager() {
-
+       public LoginManager() throws RemoteException  {
+               super();
                try {
                        dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
                try {
                        dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
diff --git a/ruralHouses/src/businessLogic/LoginManagerInterface.java b/ruralHouses/src/businessLogic/LoginManagerInterface.java
deleted file mode 100644 (file)
index f2a1f8d..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-package businessLogic;
-
-import domain.Account;
-
-public interface LoginManagerInterface {
-       
-       public Account checkCredentials(String usr, String pwd);
-
-       
-       
-       
-}
index 8c6fb3e..e3b1739 100644 (file)
@@ -1,20 +1,29 @@
 package businessLogic;
 
 import java.rmi.RemoteException;
 package businessLogic;
 
 import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
 import java.sql.Date;
 
 import java.sql.Date;
 
+import common.OfferInterface;
+
 import dataAccess.DB4oManager;
 import domain.Offer;
 import domain.RuralHouse;
 import exceptions.BadDates;
 import exceptions.OverlappingOfferExists;
 
 import dataAccess.DB4oManager;
 import domain.Offer;
 import domain.RuralHouse;
 import exceptions.BadDates;
 import exceptions.OverlappingOfferExists;
 
-public final class OfferManager {
+public final class OfferManager extends UnicastRemoteObject implements OfferInterface{
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
 
        private int offerNumber = 0;
        dataAccess.DB4oManager dbMngr;
 
 
        private int offerNumber = 0;
        dataAccess.DB4oManager dbMngr;
 
-       public OfferManager() {
+       public OfferManager() throws RemoteException {
+               super();
                try {
                        this.dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
                try {
                        this.dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
index 7f3cef0..9042bd2 100644 (file)
@@ -1,15 +1,23 @@
 package businessLogic;
 
 import java.rmi.RemoteException;
 package businessLogic;
 
 import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
 import java.util.Vector;
 
 import java.util.Vector;
 
+import common.OwnerInterface;
+
 import dataAccess.DB4oManager;
 import domain.Owner;
 
 import dataAccess.DB4oManager;
 import domain.Owner;
 
-public class OwnerManager implements OwnerManagerInterface {
+public class OwnerManager extends UnicastRemoteObject implements OwnerInterface {
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
        DB4oManager dbMngr;
 
        DB4oManager dbMngr;
 
-       public OwnerManager() {
+       public OwnerManager() throws RemoteException {
+               super();
                try {
                        dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
                try {
                        dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
diff --git a/ruralHouses/src/common/AccountInterface.java b/ruralHouses/src/common/AccountInterface.java
new file mode 100644 (file)
index 0000000..07f8ced
--- /dev/null
@@ -0,0 +1,13 @@
+package common;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import domain.Account;
+
+public interface AccountInterface extends Remote{
+       
+
+       public boolean addAccount(Account ac) throws RemoteException;
+       
+       public boolean removeAccount(Account ac) throws RemoteException;
+}
diff --git a/ruralHouses/src/common/AdminInterface.java b/ruralHouses/src/common/AdminInterface.java
new file mode 100644 (file)
index 0000000..eb5e888
--- /dev/null
@@ -0,0 +1,34 @@
+package common;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.Vector;
+
+import domain.Account;
+import domain.RuralHouse;
+
+public interface AdminInterface extends Remote {
+
+       
+       public Vector<RuralHouse> getAdditionRequests() throws RemoteException;
+
+       public Vector<RuralHouse> getDeletionRequests() throws RemoteException ;
+
+       public Vector<Account> getOwnerAdditionRequests() throws RemoteException ;
+       
+       public void removeHouseAdditionRequests(RuralHouse house) throws RemoteException ;
+
+       public void removeHouseDeletionRequests(RuralHouse house) throws RemoteException ;
+       
+       public void removeOwnerAdditionRequests(Account acc) throws RemoteException ;
+       
+       public boolean addAdditionRequest(RuralHouse rh) throws RemoteException ;
+
+       public boolean addDeletionRequest(RuralHouse rh) throws RemoteException ;
+       
+       public boolean addAccount(Account acc) throws RemoteException ;
+       
+       public void saveInstance() throws RemoteException;
+       
+       
+}
diff --git a/ruralHouses/src/common/BookingInterface.java b/ruralHouses/src/common/BookingInterface.java
new file mode 100644 (file)
index 0000000..8262f30
--- /dev/null
@@ -0,0 +1,28 @@
+package common;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.Date;
+import java.util.Vector;
+
+import domain.Booking;
+import domain.Client;
+import domain.RuralHouse;
+import exceptions.OfferCanNotBeBooked;
+
+public interface BookingInterface extends Remote {
+
+
+       public int getNumber() throws RemoteException;
+
+
+       public void removeDenyBooking(Booking b) throws RemoteException;
+
+
+       public void acceptBooking(Booking b) throws RemoteException;
+               
+       public Vector<Booking> createBooking(RuralHouse ruralHouse, Date firstDate,
+                               Date lastDate, Client client)
+                               throws OfferCanNotBeBooked,RemoteException ;
+
+}
\ No newline at end of file
diff --git a/ruralHouses/src/common/HouseInterface.java b/ruralHouses/src/common/HouseInterface.java
new file mode 100644 (file)
index 0000000..9731172
--- /dev/null
@@ -0,0 +1,31 @@
+package common;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.Vector;
+
+import domain.Owner;
+import domain.RuralHouse;
+
+public interface HouseInterface extends Remote {
+
+       // For future implementation
+       // public void modifyHouse(int houseName, Owner owner,
+       // String description, String town, int nRooms, int nKitchens,
+       // int nBaths, int nLivings, int nParkings);
+
+       public void removeHouse(RuralHouse rh, Owner owner)throws RemoteException;
+
+       public Vector<RuralHouse> getHouses(String name,String town,int nBed , int nKit, int nBath, int nPark, int nLiv) throws RemoteException;
+
+       /**
+        * This method retrieves the existing  rural houses 
+        * 
+        * @return a Set of rural houses
+        */
+       public Vector<RuralHouse> getAllRuralHouses()throws RemoteException,
+       Exception, RemoteException;
+
+       public boolean registerNewHouse(RuralHouse rh)throws RemoteException;
+       
+}
diff --git a/ruralHouses/src/common/LoginInterface.java b/ruralHouses/src/common/LoginInterface.java
new file mode 100644 (file)
index 0000000..bb5e3e0
--- /dev/null
@@ -0,0 +1,15 @@
+package common;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+import domain.Account;
+
+public interface LoginInterface extends Remote {
+       
+       public Account checkCredentials(String usr, String pwd)throws RemoteException;
+
+       
+       
+       
+}
diff --git a/ruralHouses/src/common/OfferInterface.java b/ruralHouses/src/common/OfferInterface.java
new file mode 100644 (file)
index 0000000..6e3b9b3
--- /dev/null
@@ -0,0 +1,29 @@
+package common;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.sql.Date;
+
+import domain.Offer;
+import domain.RuralHouse;
+import exceptions.BadDates;
+import exceptions.OverlappingOfferExists;
+
+public interface OfferInterface extends Remote {
+
+       /**
+        * This method creates an offer with a house number, first day, last day and
+        * price
+        * 
+        * @param House
+        *            number, start day, last day and price
+        * @return the created offer, or null, or an exception
+        */
+       public Offer createOffer(RuralHouse ruralHouse, Date firstDay,
+                       Date lastDay, float price) throws OverlappingOfferExists, BadDates,
+                       RemoteException, Exception;
+
+       public void deleteOffer(RuralHouse rh, Offer o) throws RemoteException,
+                       Exception;
+
+}
diff --git a/ruralHouses/src/common/OwnerInterface.java b/ruralHouses/src/common/OwnerInterface.java
new file mode 100644 (file)
index 0000000..c96e013
--- /dev/null
@@ -0,0 +1,15 @@
+package common;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.Vector;
+
+import domain.Owner;
+
+public interface OwnerInterface extends Remote {
+
+
+       public Vector<Owner> getOwners() throws RemoteException,
+       Exception;
+       
+}
index a541e95..b0513ae 100644 (file)
@@ -135,8 +135,10 @@ public class DB4oManager {
                        Account alfredoAcc = new Account("userAlfredo", "passAlfredo",
                                        alfredo);
 
                        Account alfredoAcc = new Account("userAlfredo", "passAlfredo",
                                        alfredo);
 
+
                        Account admin = new Account("admin", "admin", true);
                        db.store(Administrator.getInstance());
                        Account admin = new Account("admin", "admin", true);
                        db.store(Administrator.getInstance());
+
                        db.store(jonAcc);
                        db.store(alfredoAcc);
                        db.store(admin);
                        db.store(jonAcc);
                        db.store(alfredoAcc);
                        db.store(admin);
@@ -219,7 +221,9 @@ public class DB4oManager {
                }
        }
 
                }
        }
 
-       public Administrator getAdminData() {
+
+       
+       public Administrator getAdminData(){
                if (c.isDatabaseLocal() == false)
                        openSDB();
                else
                if (c.isDatabaseLocal() == false)
                        openSDB();
                else
@@ -227,10 +231,8 @@ public class DB4oManager {
 
                try {
 
 
                try {
 
-                       List<Administrator> admL = db.query(new Predicate<Administrator>() {
-                               /**
-                                * 
-                                */
+                       
+                       List<Administrator> admL = db.query(new Predicate<Administrator>(){
                                private static final long serialVersionUID = 1L;
 
                                public boolean match(Administrator admin) {
                                private static final long serialVersionUID = 1L;
 
                                public boolean match(Administrator admin) {
@@ -238,8 +240,11 @@ public class DB4oManager {
                                }
                        });
 
                                }
                        });
 
+                       
+                       
                        return admL.get(0);
                        return admL.get(0);
-               } finally {
+               }
+               finally {
                        db.close();
 
                }
                        db.close();
 
                }
@@ -247,6 +252,7 @@ public class DB4oManager {
        }
 
        public void storeAdmin() {
        }
 
        public void storeAdmin() {
+
                if (c.isDatabaseLocal() == false)
                        openSDB();
                else
                if (c.isDatabaseLocal() == false)
                        openSDB();
                else
@@ -270,6 +276,7 @@ public class DB4oManager {
                                        Administrator.getInstance().getRemoveRequest());
                        admL.get(0).setNewOwnerRequest(
                                        Administrator.getInstance().getNewOwnerRequest());
                                        Administrator.getInstance().getRemoveRequest());
                        admL.get(0).setNewOwnerRequest(
                                        Administrator.getInstance().getNewOwnerRequest());
+
                        db.commit();
 
                } catch (Exception e) {
                        db.commit();
 
                } catch (Exception e) {
index ba7a630..90f3a23 100644 (file)
@@ -1,17 +1,23 @@
 package domain;
 
 package domain;
 
+import java.io.Serializable;
 import java.util.Arrays;
 
 import businessLogic.SecurityManager;
 
 import java.util.Arrays;
 
 import businessLogic.SecurityManager;
 
-public class Account {
+public class Account implements Serializable {
 
 
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
        
 
        private byte[] username;
        private byte[] password;
        private byte[] salt;
 
        
 
        private byte[] username;
        private byte[] password;
        private byte[] salt;
 
+
        private Owner owner;
        private boolean admin = false;
 
        private Owner owner;
        private boolean admin = false;
 
index bead633..8244f09 100644 (file)
@@ -1,11 +1,17 @@
 package domain;
 
 package domain;
 
+import java.io.Serializable;
 import java.util.LinkedList;
 
 import configuration.ConfigXML;
 import dataAccess.DB4oManager;
 
 import java.util.LinkedList;
 
 import configuration.ConfigXML;
 import dataAccess.DB4oManager;
 
-public class Administrator {
+public class Administrator implements Serializable {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
 
        private static Administrator admin = null;
        private static LinkedList<RuralHouse> addRequest;
 
        private static Administrator admin = null;
        private static LinkedList<RuralHouse> addRequest;
@@ -63,6 +69,7 @@ public class Administrator {
 
        public void setRemoveRequest(LinkedList<RuralHouse> removeRequest) {
                Administrator.removeRequest = removeRequest;
 
        public void setRemoveRequest(LinkedList<RuralHouse> removeRequest) {
                Administrator.removeRequest = removeRequest;
+
        }
 
        public LinkedList<Account> getNewOwnerRequest() {
        }
 
        public LinkedList<Account> getNewOwnerRequest() {
index 51546c3..0f72a6c 100644 (file)
@@ -3,8 +3,12 @@ package domain;
 import java.io.Serializable;
 import java.util.Date;
 
 import java.io.Serializable;
 import java.util.Date;
 
-@SuppressWarnings("serial")
-public class Booking implements Serializable {
+public class Booking implements Serializable  {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
        private int bookingNumber;
        private boolean isPaid;
        private Date bookingDate;
        private int bookingNumber;
        private boolean isPaid;
        private Date bookingDate;
index fa2fee5..db62454 100644 (file)
@@ -1,13 +1,22 @@
 package domain;
 
 package domain;
 
-public enum Districs {
+import java.io.Serializable;
+
+public enum Districs implements Serializable {
+
+       /**
+        * 
+        */
        BEA("Beatriz"), GUA("Guazate"), VEG("Vegas"), FAR("Farallón"), CED("Cedro"), MOT(
                        "Monte LLano"), RIN("Rincón"), PUE("Pueblo"), QUA("Quebrada Arriba"), QEB(
                        "Quebrada Abajo"), TOI("Toita"), MAB("Matón Abajo"), MAA(
                        "Matón Arriba"), PIE("Piedras"), PAV("Pasto Viejo"), PEA(
                        "PedroAvila"), SUM("Sumido"), LAP("Lapa"), CER("Cercadillo"), JAJ(
                        "JájomeAlto"), CUL("CulebrasAbajo");
        BEA("Beatriz"), GUA("Guazate"), VEG("Vegas"), FAR("Farallón"), CED("Cedro"), MOT(
                        "Monte LLano"), RIN("Rincón"), PUE("Pueblo"), QUA("Quebrada Arriba"), QEB(
                        "Quebrada Abajo"), TOI("Toita"), MAB("Matón Abajo"), MAA(
                        "Matón Arriba"), PIE("Piedras"), PAV("Pasto Viejo"), PEA(
                        "PedroAvila"), SUM("Sumido"), LAP("Lapa"), CER("Cercadillo"), JAJ(
                        "JájomeAlto"), CUL("CulebrasAbajo");
+                       
+       private static final long serialVersionUID = 1L; 
 
 
+       
        private final String longName;
 
        Districs(String longName) {
        private final String longName;
 
        Districs(String longName) {
index 2327608..e79a446 100644 (file)
@@ -1,7 +1,13 @@
 package domain;
 
 package domain;
 
-public class HouseFeatures {
+import java.io.Serializable;
 
 
+public class HouseFeatures implements Serializable {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
        private int nRooms;
        private int nKitchens;
        private int nBaths;
        private int nRooms;
        private int nKitchens;
        private int nBaths;
index a218f03..550aceb 100644 (file)
@@ -3,9 +3,12 @@ package domain;
 import java.io.Serializable;
 import java.util.Vector;
 
 import java.io.Serializable;
 import java.util.Vector;
 
-@SuppressWarnings("serial")
 public class Owner implements Serializable {
 
 public class Owner implements Serializable {
 
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
        private String bankAccount = "";
        private String name = "";
        private String mailAccount = "";
        private String bankAccount = "";
        private String name = "";
        private String mailAccount = "";
diff --git a/ruralHouses/src/launcher/RMILauncher.java b/ruralHouses/src/launcher/RMILauncher.java
new file mode 100644 (file)
index 0000000..f5a4cf8
--- /dev/null
@@ -0,0 +1,127 @@
+package launcher;
+
+import java.rmi.Naming;
+import java.rmi.RMISecurityManager;
+import java.rmi.Remote;
+
+import businessLogic.AdminManager;
+import businessLogic.BookingManager;
+import businessLogic.HouseManager;
+import businessLogic.LoginManager;
+import businessLogic.OfferManager;
+import businessLogic.OwnerManager;
+
+public class RMILauncher {
+
+       public static void main(String[] args) {
+               RMILauncher.startRegistry();
+               RMILauncher.initRemoteObject();
+       }
+
+       private static void startRegistry() {
+               System.setProperty("java.security.policy", "java.policy");
+               System.setSecurityManager(new RMISecurityManager());
+               try {
+                       java.rmi.registry.LocateRegistry.createRegistry(9999);
+               } catch (Exception e) {
+                       System.out.println(e.toString()
+                                       + "\nRMI registry was already created");
+               }
+
+       }
+
+       private static void initRemoteObject() {
+               boolean adm = runAdmin();
+               boolean bok = runBooking();
+               boolean hou = runHouse();
+               boolean off = runOffer();
+               boolean own = runOwner();
+               boolean log = runLogin();
+
+               System.out.println("  Admin: "+adm+
+                                                       "\t Booking:  "+bok+
+                                                       "\t House:  "+hou+
+                                                       "\t Login:  "+log+
+                                                       "\t Offer:  "+off+
+                                                       "\t Owner:  "+own);
+       }
+       
+       private static boolean runAdmin() {
+               try {
+                       Remote remoteObject = new AdminManager();
+                       String authService = "rmi://localhost:9999//AdM";
+                       Naming.rebind(authService, remoteObject);
+                       return true;
+               } catch (Exception e) {
+                       System.out.println(e.toString());
+                       return false;
+               }
+       }
+
+       
+       private static boolean runBooking() {
+               try {
+                       Remote remoteBooking = new BookingManager();
+                       String authService = "rmi://localhost:9999//BoM";
+                       Naming.rebind(authService, remoteBooking);
+                       return true;
+               } catch (Exception e) {
+                       System.out.println(e.toString());
+                       return false;
+               }
+       }
+
+       
+       private static boolean runHouse() {
+               try {
+                       Remote remoteHouse = new HouseManager();
+                       String authService = "rmi://localhost:9999//HoM";
+                       Naming.rebind(authService, remoteHouse);
+                       return true;
+               } catch (Exception e) {
+                       System.out.println(e.toString());
+                       return false;
+               }
+       }
+
+       
+       private static boolean runLogin() {
+               try {
+                       Remote remoteLogin = new LoginManager();
+                       String authService = "rmi://localhost:9999//LoM";
+                       Naming.rebind(authService, remoteLogin);
+                       return true;
+               } catch (Exception e) {
+                       System.out.println(e.toString());
+                       return false;
+               }
+       }
+
+       
+       private static boolean runOffer() {
+               try {
+                       Remote remoteOffer = new OfferManager();
+                       String authService = "rmi://localhost:9999//OfM";
+                       Naming.rebind(authService, remoteOffer);
+                       return true;
+               } catch (Exception e) {
+                       System.out.println(e.toString());
+                       return false;
+               }
+       }
+
+       
+       private static boolean runOwner() {
+               try {
+                       Remote remoteOwner = new OwnerManager();
+                       String authService = "rmi://localhost:9999//OwM";
+                       Naming.rebind(authService, remoteOwner);
+                       return true;
+               } catch (Exception e) {
+                       System.out.println(e.toString());
+                       return false;
+               }
+       }
+       
+       
+}