cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the list of documents

Former Member
0 Kudos

Hi everyone

Can anyone help me How to get the list of documents residing in a folder of KM repository of SAP Netweaver using a simple java program

Thanks in ADV.

Rupesh Khemka

Accepted Solutions (1)

Accepted Solutions (1)

former_member193726
Active Participant
0 Kudos

Hi Rupesh,

I have written the code for you and it works with WebDynpro, no seperate java program is required.

Just try to paste it in your application code and run it.

try{

// Will check the user athentication for EP

IWDClientUser wdClientUser = WDClientUser.getCurrentUser();

IUser sapUser = wdClientUser.getSAPUser();

com.sapportals.portal.security.usermanagement.IUser ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);

ResourceContext context = new ResourceContext(ep5User);

// The path in which your folder resides

RID rid1 =RID.getRID("/documents/Public Documents/SCAP/");

IResourceFactory factory1 = ResourceFactory.getInstance();

ICollection icollection = (ICollection)factory1.getResource(rid1, context);

IResourceList resourcelist = icollection.getChildren();

int size1 = resourcelist.size();

for(int s=0; s<listOfDocuments.getLength(); s++){

IResource resource = resourcelist.get(i);

InputStream input = new InputStream();

input = resource.getContent().getInputStream();

}

}catch(Exception e){

e.getMessage();

}

Once you get the InputStream everything else is possible....

This will surely help you in reading the documents from KM.

Regards,

Rekha Malavathu

Former Member
0 Kudos

Hi Rekha..

Thanks for ur useful answer... But i m making a application that require a simple java code or say a servlet program that can fetch the list of all the text file or say HTML files that are residing in a particular folder of KM repository... Ur code was using WebDynpro..... which my application doesn't want..Can u plz help me in getting this problem solved....

Can u Divert ur code to my mail box..

rupeshkhemka@hcl.in

Thanks for ur concern & response

Rupesh Khemka

Answers (1)

Answers (1)

Former Member
0 Kudos

<b>Try using</b>

com.sapportals.portal.security.usermanagement.IUser adminUser = WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service");
ResourceContext context = new ResourceContext(adminUser);

<b>//and the same code you already have.</b>