Procedure for KM Content Access from NetWeaver 7.3
1. Specifying the Dependencies of a KM Development Component
http://help.sap.com/saphelp_nw73/helpdata/en/4e/58bd98f2c55656e10000000a15822b/frameset.htm
2. Create and add external library to DC contaning “com.sap.security.api jar”
3. Add following code in web dynpro Code.
String pathofkmfile=”/documents/Public Documents/TREX.txt”; //Path of KM file can be changed as Required
try {
IUser sapUser= WDClientUser.getCurrentUser().getSAPUser();
ResourceContext contex= ResourceContext.getInstance(sapUser);
IResourceFactory factory = ResourceFactory.getInstance();
RID rid =RID.getRID(pathofkmfile);
final IResource kmResource = factory.getResource(rid,contex);
if(kmResource==null){
throw new ResourceNotFoundException(“KM Resource Not Found”+kmResource.getDisplayName());
}
InputStream in = kmResource.getContent().getInputStream();
InputStreamReader is = new InputStreamReader(in);
StringBuilder sb=new StringBuilder();
BufferedReader br = new BufferedReader(is);
String read = br.readLine();
while(read != null) {
sb.append(read);
read =br.readLine();
}
wdComponentAPI.getMessageManager().reportSuccess(sb.toString());
}
catch (Exception e) {
wdComponentAPI.getMessageManager().reportException(e);
}
com.sap.security.api jar this should be standard one, why you need to add it in external lib dc?
Though com.sap.security.api jar is Standard one but this is not available with tc/km/frwk dc of KMC- CM SC. So the code gives compiler error in central build without com.sap.security.api jar as external lib.
then you should add other sc as dependency.
adding sap jar as external jar is quite wrong