1 package SOFA.SOFAnode.Made.TIR.Access.Tests; 2 import java.io.BufferedReader ; 3 import java.io.InputStreamReader ; 4 import java.rmi.Naming ; 5 6 import SOFA.SOFAnode.Made.TIR.ManageProfiles; 7 import SOFA.SOFAnode.Made.TIR.Repository; 8 import SOFA.SOFAnode.Made.TIR.WorkRepository; 9 10 11 public class AddProfile { 12 public static void main(String [] argv) { 13 try { 14 System.setSecurityManager(new java.rmi.RMISecurityManager ()); 15 16 BufferedReader in = new BufferedReader (new InputStreamReader (System.in)); 17 String rmiport = System.getProperty("sofa.rmiport","1099"); 18 String 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 a = new String (""); 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 e) { 45 System.out.println("Exception: " + e.getMessage()); 46 e.printStackTrace(); 47 } 48 } 49 } 50 | Popular Tags |