Update of /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/consoleclient
In directory sc8-pr-cvs1:/tmp/cvs-serv13116/src/org/asturlinux/frade/prolix/consoleclient
Modified Files:
ConsoleClient.java
Log Message:
Added to console client login and logout functionality
Index: ConsoleClient.java
===================================================================
RCS file: /cvsroot/pfc-prolog/prolix/src/org/asturlinux/frade/prolix/consoleclient/ConsoleClient.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** ConsoleClient.java 27 Jul 2003 14:08:38 -0000 1.10
--- ConsoleClient.java 2 Aug 2003 20:29:17 -0000 1.11
***************
*** 1,3 ****
-
/**
*
--- 1,2 ----
***************
*** 31,35 ****
import org.asturlinux.frade.prolix.ejb.interfaces.*;
import org.asturlinux.frade.prolix.interpreter.exceptions.*;
!
/**
--- 30,34 ----
import org.asturlinux.frade.prolix.ejb.interfaces.*;
import org.asturlinux.frade.prolix.interpreter.exceptions.*;
! import org.asturlinux.frade.prolix.exceptions.*;
/**
***************
*** 62,66 ****
{
System.out.println("ERROR: Naming Exception");
- ne.printStackTrace();
return;
}
--- 61,64 ----
***************
*** 76,80 ****
}
! String[] optionsMenu = {"Load Program",
"Get loaded program",
"Load Consult",
--- 74,79 ----
}
! String[] optionsMenu = {"Login",
! "Load Program",
"Get loaded program",
"Load Consult",
***************
*** 82,85 ****
--- 81,85 ----
"Step",
"NextSolution",
+ "Logout",
"Exit"};
***************
*** 92,108 ****
optionsMenu))
{
! case 1: program();
break;
! case 2: getLoadedProgram();
break;
! case 3: consult();
break;
! case 4: getLoadedConsult();
break;
! case 5: goStep();
break;
! case 6: goNextSolution();
break;
! case 7: otherIteration = false;
break;
}
--- 92,112 ----
optionsMenu))
{
! case 1: doLogin();
break;
! case 2: program();
break;
! case 3: getLoadedProgram();
break;
! case 4: consult();
break;
! case 5: getLoadedConsult();
break;
! case 6: goStep();
break;
! case 7: goNextSolution();
! break;
! case 8: doLogout();
! break;
! case 9: otherIteration = false;
break;
}
***************
*** 144,147 ****
--- 148,156 ----
System.out.println("Please, write something with sense");
}
+ catch (NotEnoughtPermissionsException notAuth)
+ {
+ //PERMISSIONS-MESSAGE
+ System.out.println("Sorry, you don't have enought permissions");
+ }
}
***************
*** 187,190 ****
--- 196,204 ----
System.out.println("Please, write something with sense");
}
+ catch (NotEnoughtPermissionsException notAuth)
+ {
+ //PERMISSIONS-MESSAGE
+ System.out.println("Sorry, you don't have enought permissions");
+ }
}
***************
*** 223,226 ****
--- 237,246 ----
System.out.println("Remote exception doing an step");
}
+ catch (NotEnoughtPermissionsException notAuth)
+ {
+ //PERMISSIONS-MESSAGE
+ System.out.println("Sorry, you don't have enought permissions");
+ }
+
}
***************
*** 243,248 ****
--- 263,309 ----
System.out.println("Remote exception doing an step");
}
+ catch (NotEnoughtPermissionsException notAuth)
+ {
+ //PERMISSIONS-MESSAGE
+ System.out.println("Sorry, you don't have enought permissions");
+ }
}
+ private void doLogin()
+ {
+ BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+ try
+ {
+ System.out.println("Write your user name: ");
+ String id = new String(in.readLine());
+ System.out.println("Write your password: ");
+ String pwd = new String(in.readLine());
+ interpreter.login(id,pwd);
+ }
+ catch (IOException io)
+ {
+ System.out.println("IO Exception doing login");
+ }
+ catch (FailedLoginException fe)
+ {
+ System.out.println("User not exist, password incorrect or someone already loaded");
+ }
+ }
+
+ private void doLogout()
+ {
+ try
+ {
+ interpreter.logout();
+ }
+ catch (NoLoggedUserException nlue)
+ {
+ System.out.println("Cannot logout: No loged user");
+ }
+ catch (RemoteException re)
+ {
+ System.out.println("Remote Exception doing logout");
+ }
+ }
}
|