X-Git-Url: https://xp-dev.com/git/RRRRHHHH_Code/blobdiff_plain/d30bcc8a3c13bbf5144b03a644c1345865aed708..ccac9974c8183f7f0d30e8cabd84ee0386e8cd97:/ruralHouses/src/gui/OwnerRegistrationGUI.java diff --git a/ruralHouses/src/gui/OwnerRegistrationGUI.java b/ruralHouses/src/gui/OwnerRegistrationGUI.java index 5a4ffe9..62395d5 100644 --- a/ruralHouses/src/gui/OwnerRegistrationGUI.java +++ b/ruralHouses/src/gui/OwnerRegistrationGUI.java @@ -41,10 +41,9 @@ public class OwnerRegistrationGUI extends JFrame { * Create the frame. */ public OwnerRegistrationGUI() { - + try { - am = (AdminInterface) Naming - .lookup(___IntNames.AdminManager); + am = (AdminInterface) Naming.lookup(___IntNames.AdminManager); } catch (Exception e1) { System.out.println("Error accessing remote authentication: " + e1.toString()); @@ -139,23 +138,32 @@ public class OwnerRegistrationGUI extends JFrame { private void jButton_ActionPerformed(ActionEvent e) { - Owner own = new Owner(this.nameField.getText(), - this.bank1Field.getText() + " " + this.bank2Field.getText() - + " " + this.bank3Field.getText() + " " - + this.bank4Field.getText(), this.emailField.getText()); - - - try { - if (this.am.addAccountRequest(this.userNameField.getText(), - this.passField.getText(), own)) { - this.am.saveInstance(); - this.feedback.setText("Request sended"); - } else { - this.feedback.setText("Can't send the request"); + if (!emailField + .getText() + .matches( + "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$") + || !this.nameField.getText().isEmpty()||this.bank1Field.getText().length()!=4 || this.bank2Field.getText().length()!=4 + ||this.bank3Field.getText().length()!=2 || this.bank4Field.getText().length()!=10) { + Owner own = new Owner(this.nameField.getText(), + this.bank1Field.getText() + " " + this.bank2Field.getText() + + " " + this.bank3Field.getText() + " " + + this.bank4Field.getText(), + this.emailField.getText()); + + try { + if (this.am.addAccountRequest(this.userNameField.getText(), + this.passField.getText(), own)) { + this.am.saveInstance(); + this.feedback.setText("Request sended"); + } else { + this.feedback.setText("Can't send the request"); + } + } catch (RemoteException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); } - } catch (RemoteException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); + } else { + this.feedback.setText("Bad formatted data"); } }