KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Made > TIR > Access > Tests > AddProfile


1 package SOFA.SOFAnode.Made.TIR.Access.Tests;
2 import java.io.BufferedReader JavaDoc;
3 import java.io.InputStreamReader JavaDoc;
4 import java.rmi.Naming JavaDoc;
5
6 import SOFA.SOFAnode.Made.TIR.ManageProfiles;
7 import SOFA.SOFAnode.Made.TIR.Repository;
8 import SOFA.SOFAnode.Made.TIR.WorkRepository;
9
10 /** Tests of adding profiles */
11 public class AddProfile {
12   public static void main(String JavaDoc[] argv) {
13     try {
14       System.setSecurityManager(new java.rmi.RMISecurityManager JavaDoc());
15
16       BufferedReader JavaDoc in = new BufferedReader JavaDoc(new InputStreamReader JavaDoc(System.in));
17       String JavaDoc rmiport = System.getProperty("sofa.rmiport","1099");
18       String JavaDoc rmihost = System.getProperty("sofa.rmihost","localhost");
19       System.out.print("Connecting to repository...");
20       Repository rep = (Repository) Naming.lookup("//"+rmihost+":"+rmiport+"/Repository");
21       System.out.println("OK");
22       System.out.print("Getting work repository...");
23       WorkRepository work = rep.beginChanges(null);
24       System.out.println("OK");
25       System.out.print("Getting profiles object...");
26       ManageProfiles mProf = work.getProfiles();
27       System.out.println("OK");
28       boolean ok = false;
29       String JavaDoc a = new String JavaDoc("");
30       while (!ok) {
31         System.out.print("Name of new profile: ");
32         a = in.readLine();
33         if (a.compareTo("")!=0)
34           ok = true;
35       }
36       System.out.print("Creating profile...");
37       mProf.create_profile(a);
38       System.out.println("OK");
39       System.out.print("Commiting changes...");
40       if (work.commit())
41         System.out.println("OK");
42       else
43         System.out.println("NO!");
44     } catch (Exception JavaDoc e) {
45       System.out.println("Exception: " + e.getMessage());
46       e.printStackTrace();
47     }
48   }
49 }
50
Popular Tags