/* Example Program : Reverse the model variable list value strings, of each MVL on a Host Integrator Server. Compile: javac -classpath sconfig.jar;jaas.jar;wcp.jar ReverseMVLs.java Run: java -classpath sconfig.jar;jaas.jar;wcp.jar ReverseMVLs <AADSName> <ServerName> Use with care! This program changes the Host Integrator Server's configuration. Before running this program, run the 'ObtainAADSCertificates' program to obtain certificates for the AADS servers of interest. */ import java.io.IOException; import java.util.*; import com.wrq.vhi.sconfig.*; class ReverseMVLs { public static final String CERTFILE = "certificates.aads"; public static final String DIVIDER = "========================================"; public static final String username = ""; public static final String password = ""; /* Display the contents of a single model variable list. */ static void reverseMvlValues( IMvlBrowser mvlb, String mvlname ) throws SCException { VhiMvl mvl = mvlb.getMvl(mvlname); for(int i=0; i<mvl.size(); i++) { Map mvle = mvl.get(i); for(Iterator it=mvle.entrySet().iterator(); it.hasNext(); ) { Map.Entry item = (Map.Entry)it.next(); String vname = (String)item.getKey(); String vval = (String)item.getValue(); /* Reverse the characters in the value string. */ String newval = new StringBuffer(vval).reverse().toString(); /* Change the value of an MVL entry. */ mvle.put( vname, newval ); System.out.println(" Entry " + (i+1) + " : Variable : " + vname + " Old Value : " + vval + " New Value : " + newval); } System.out.println(""); mvl.set(i, mvle); /* Update the MVL entry. */ } mvlb.setMvl(mvl); /* Update the MVL with our changes. */ } /* Display all of the MVLs defined on a Host Integrator Server. */ static void reverseMVLs(String AADSName, String serverName) throws SCException, IOException, ClassNotFoundException { IAADSConnection aadsConn = ServerConfig.newAADSConnection( AADSName, CERTFILE ); IServerAdminSession sas = ServerConfig.newServerAdminSession( serverName, aadsConn, username, password ); sas.open(); /* Connect to the Host Integrator Server. */ System.out.println("AADS: " + AADSName); System.out.println("Server: " + serverName); IMvlBrowser mvlb = ServerConfig.newMvlBrowser( sas ); mvlb.readConfiguration(); /* Read the MVLs from the Host Integrator Server. */ List mvlnames = mvlb.getMvlNames(); for(Iterator it1=mvlnames.iterator(); it1.hasNext(); ) { String mvlname = (String)it1.next(); System.out.println( DIVIDER ); System.out.println("MVL Name: " + mvlname); reverseMvlValues( mvlb, mvlname ); } mvlb.updateConfiguration(); /* Write the updated MVLs to the Host Integrator Server. */ sas.close(); /* Disconnect from the Host Integrator Server. */ } static public void main(String [] args) { if(args.length != 2) { System.out.println("Usage: ReverseMVLs <AADSName><Servername>"); return; } try { reverseMVLs( args[0], args[1] ); } catch(Exception e) { System.err.println("Exception caught: " + e); e.printStackTrace(); } } }
© 1999-2007 Attachmate Corporation. All rights reserved. Terms of Use.