Home
TeamSite
CSclient object
vikku
Can any one give me the logic how i write the java code for getting the CSclient object
Find more posts tagged with
Comments
VixRox
follow the steps below:
----------------------
Properties properties = new Properties();
properties.setProperty("com.interwoven.cssdk.factory.CSFactory",
"com.interwoven.cssdk.factory.CSSOAPFactory");
properties.setProperty("serviceBaseURL","url");
String username = "";
String password = "";
CSFactory factory = CSFactory.getFactory( properties );
CSClient client = factory.getClient
( UserName,Roles, Password,Locale ,Application Context,host);
Binettoid
If your external is extending the BaseLscsExternal, you can just use
Client client = getLscsClient(context);
where context is a RequestContext.
I heard a rumour this is deprecated, though.
vikku
import java.io.*;
import java.util.*;
import com.interwoven.cssdk.access.CSUser;
import com.interwoven.cssdk.common.CSClient;
import com.interwoven.cssdk.common.CSException;
import com.interwoven.cssdk.factory.CSFactory;
import com.interwoven.cssdk.factory.CSFactoryInitializationException;
public class MyCSClient {
CSFactory factory;
public void init() {
// read a factory setting from a properties file
try {
Properties props = new Properties();
InputStream in = (InputStream) getClass().getResourceAsStream(
"/samples.properties");
props.load(in);
System.out.println("Using factory properties");
props.list(System.out);
in.close();
System.out.println("Factory object 1...");
factory = CSFactory.getFactory(props);
} catch (FileNotFoundException fnf) {
} catch (IOException io) {
} catch (CSFactoryInitializationException csfie) {
} catch (Exception ex) {
System.out.println(ex);
}
System.out.println("Factory object =" + factory);
}
// authenticating user
public String getUser() {
String sessionString = "";
CSClient client = null;
try {
System.out.println("java.util.Locale.getDefault()--> "
+ java.util.Locale.getDefault());
client = factory.getClient("servername\\username", "role",
"password", java.util.Locale.getDefault(),
"Application Context,host", "host");
//CSUser userid = client.getCurrentUser();
//System.out.println("userid : " + userid);
//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();
System.out.println("The logged in user : " + sessionString);
} catch (CSException e) {
System.out.println("CSException viv : " + e.toString());
}
System.out.println("User authenticated and client object obtained");
return sessionString;
}
public static void main(String[] args) {
MyCSClient cont = new MyCSClient();
cont.init();
cont.getUser();
}
}
em using the following code..but em not getting the factory object and client object.....
CSClient client = factory.getClient
( UserName,Roles, Password,Locale ,Application Context,host);
em also confused regarding these parameters please clarify the parameters detail and suggest me if i m doing wrong
________________________________________________________________
sample.propertiess file is ----
# creates a CS JNI factory
# com.interwoven.cssdk.factory.CSFactory=com.interwo ven.cssdk.factory.CSLocalFactory
# cssdk.cfg.path=:/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=172.16.3.85