import java.util.*;
import lotus.domino.*;

public class myDbAccessLevel{
	public static void main(String argv[]){
		try{
			// test and get args
			if (argv.length < 4){
				// arguments were entered. give user the variables
				System.out.println("You need to enter arguments for this application...");
				System.out.println("   server, database, user, password");
				System.exit(0);
			}			
			String server = argv[0];
			String database = argv[1];
			String user = argv[2];
			String pass = argv[3];

			// start bubblegum wrapper and start session
			NotesThread.sinitThread();
			Session s = NotesFactory.createSession(server, user, pass);

			//get server, database
			String servername=s.getServerName();
			if(servername==""){
				System.out.println("Could not attach to server");
				System.exit(0);
				}
			System.out.println("Attached to Server: " + servername);
			Database db = s.getDatabase(servername, database);
			if (db.isOpen()==false){
				System.out.println("Could not open database: " + database);
				System.exit(0);
			}
			System.out.println("Attached to database: " + db.getTitle());
			
			// get my acl info
      			System.out.println ("You are " + s.getUserName());
			int accLevel = db.queryAccess(s.getUserName());
      			System.out.print ("You have ");
      			switch (accLevel) {
				case(ACL.LEVEL_NOACCESS) :
				  System.out.println("no access");
        			  break;
			        case(ACL.LEVEL_DEPOSITOR) :
			          System.out.println("depositor access");
			          break;
			        case(ACL.LEVEL_READER) :
			          System.out.println("reader access");
			          break;
			        case(ACL.LEVEL_AUTHOR) :
			          System.out.println("author access");
			          break;
			        case(ACL.LEVEL_EDITOR) :
			          System.out.println("editor access");
			          break;
			        case(ACL.LEVEL_DESIGNER) :
			          System.out.println("designer access");
			          break;
			        case(ACL.LEVEL_MANAGER) :
			          System.out.println("manager access");
			          break;
			        default:
			          System.out.println("unknown access");
			          break; }
			
		}
		catch (Exception e){
		if (e instanceof NotesException){
			NotesException ne=(NotesException)e;
			System.out.println("Domino-side error:\n" + ne.text + "\n");
		}
		e.printStackTrace();
		}
		finally {
		NotesThread.stermThread();
		}
	}
}	