Subject: Abouts NotesException
Please find the following code i have written for handling NotesException.What’s my problem is When i got exception in any of the following option,first time i am able to handle the notesException properly.But i run the same command(option) ,it is terminating the program.It should catch the properly and it displays the options again.It doesn’t happening.Please suggst me.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import lotus.domino.AdministrationProcess;
import lotus.domino.NotesException;
import lotus.domino.NotesThread;
import lotus.domino.Registration;
import lotus.domino.Session;
public class TestNotesException {
public static void mainMenu()throws Exception{
while (true) {
BufferedReader reader = new BufferedReader(new InputStreamReader(
System.in));
System.out.println("\nNotesTool Commands");
int option = 0;
System.out.println("\t1.Driver/Notes Configuration Information "
+ "\n\t2.JVM Information"
+ " \n\t3.Domino Server Session Information"
+ "\n\t4.Authenticate to Domino Server"
+ " \n\t5.Create Lotus Notes Test User"
+ "\n\t6.Delete Lotus Notes User"
+ "\n\t7.Open Lotus Notes Database"
+ "\n\t8.Send Domino Console Command" + "\n\t99.Quit");
System.out.println("Enter Command:");
option = Integer.parseInt(reader.readLine());
switch (option) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
System.out
.println("\n*************** DELETE THE USER *********************\n");
System.out
.println("Please enter user's full name that you want delete:::");
String userName = reader.readLine();
System.out.println("User "
+ deleteUser(userName)
+ " is deleted from the domino Server "
);
break;
case 99:
System.out.println("");
System.exit(0);
default:
System.out.println("Command not supported.Choose correct option");
}
}
}
/**
* @param args
* @throws Exception
* @throws IOException
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
mainMenu();
/*} catch (NotesException e) {
try{
throw new NotesException(e.id, e.text, e.internal);
}catch(NotesException e1){
e1.printStackTrace();
System.out.println(e.getCause());
System.out.println(e.getClass());
System.out.println(e.internal);
//throw new NotesException(e.id, e.text, e.internal);
}*/
}catch (NotesException e) {
System.out.println("Command not supported.Choose correct option");
try{
mainMenu();
}catch (Exception e1) {
e1.printStackTrace();
// TODO: handle exception
}
//throw new NotesException(e.id, e.text, e.internal);
}
catch (NumberFormatException e) {
System.out.println("Command not supported.Choose correct option");
//throw new NotesException(e.id, e.text, e.internal);
}
catch (Exception e) {
System.out.println("Command not supported.Choose correct option");
//throw new NotesException(e.id, e.text, e.internal);
}
}
private static String deleteUser(String userName) throws Exception{
// TODO Auto-generated method stub
NotesThread.sinitThread();
Session NotesSess = lotus.domino.NotesFactory.createSession();
Registration tmpNReg = NotesSess.createRegistration();
String userName1 = tmpNReg.switchToID("C:\\Program Files\\Lotus\\Domino\\data\\admin.id", "novell");
AdministrationProcess pAdminP = NotesSess
.createAdministrationProcess("DomainA/NotesOrg");
pAdminP.deleteUser(userName, true,
AdministrationProcess.MAILFILE_DELETE_ALL, "");
return userName;
}
}