Hi all,
I have written a class to get the factory object from the properties file and then obtain the CSClient object. I ran my code and i can get the factory being created successfully from the properties file. But it gets stuck at the point when it has to take the factory.getClient() method.
COde:
-------------------------------------------------------------------------
public class Controller {
private CSFactory factory;
public void init(){
//read a factory setting from a properties file
try{
Properties props = new Properties();
InputStream in = (InputStream)getClass().getResourceAsStream("run/samples.properties");
props.load(in);
System.out.println("Using factory properties");
props.list(System.out);
in.close();
factory = CSFactory.getFactory(props);
}
catch(FileNotFoundException fnf){
//throw new CSWebAppException(fnf);
}
catch(IOException io){
//throw new CSWebAppException(io);
}
catch(CSFactoryInitializationException csfie){
//throw new CSWebAppException(csfie);
}
System.out.println("Factory object created from properties file");
}
//authenticating user
public String getUser(String username, String password, String role){
String sessionString ="";
try{
CSClient client = factory.getClient(username, role, password, Locale.getDefault(), "cssdk", null); ##Problem here##
CSUser userid = client.getCurrentUser();
String currentUser = userid.getName();
System.out.println("Current user name ::"+currentUser);
String userRole = client.getCurrentRole();
System.out.println("Current user role ::"+userRole);
sessionString = client.getContext().getSessionString();
}
catch(CSException e){
//throw new CSWebAppException(e);
}
System.out.println("User authenticated and client object obtained");
return sessionString;
}
public static void main(String[] args){
Controller cont = new Controller();
cont.init();
System.out.println("values::"+args[0]+args[1]+args[2]);
String sessionValues = cont.getUser(args[0], args[1], args[2]);
System.out.println("The logged in user : "+sessionValues);
}
}
--------------------------------------------------------------------=
One more issue i see was that while getting "factory.getClient()", it didn't recognise "Locale.getDefault()" so i tried by changing it with null and it gets stuck there then. which class specifically has to be imported for Locale?
Also, i m setting the username, password, role as command arguments here for now but i need to pick them up from the teamsite server login screen. Couldn't figure out how? Only know that these credentials are stored in tsusers.xml file. Please suggest on this ....
I am just checking to be able to get the cssdk connection to the remote TS server...then i can proceed with further tasks........
Also, my samples.properties is as follows:
------------------------------------------------------------------------
# creates a CS JNI factory
# com.interwoven.cssdk.factory.CSFactory=com.interwoven.cssdk.factory.CSLocalFactory
# cssdk.cfg.path=c:/iw-home/cssdk/cssdk.cfg
# creates a CS SOAP factory
com.interwoven.cssdk.factory.CSFactory=com.interwoven.cssdk.factory.CSSOAPFactory
# use the machine name and HTTP port of the ContentServices SOAP server
serviceBaseURL=
http://negril1.putnaminv.com>-------------------------------------------------------------------------
Thanks in advance !!