cancel
Showing results for 
Search instead for 
Did you mean: 

KM repository framework issue

Former Member
0 Kudos

I am trying to implement a simple KM repository framework program.

I was informed to use this:

IUser serviceUser = WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service");
ResourceContext c = new ResourceContext(serviceUser);

Since I am on EP 7 2004S I have to use this:

com.sap.security.api.IUser user=(com.sap.security.api.IUser)request.getUser();
IResourceContext resourceContext=new ResourceContext(user);

But now I get an error:

<b>Constructor ResourceContext(IUser) is undefined</b> in Eclipse.

And I get this whole list of errors <b>"Missing required library: C:Program Files/SAP/IDE/IDE70/eclipse/plugins/com.sap.km.rfwizard/lib/prtapi.jar"</b> when in my nwds i get all the jars in folder <b>com.sap.km.rfwizard_7.1.5</b>

Please do help me out.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

In portalapp.xml:

Mention

<property name="SharingReference" value="com.sap.km.cm"/>

also

import com.sap.security.api.IUser;
import com.sapportals.portal.security.usermanagement.IUser

com.sapportals.portal.security.usermanagement.IUser user=(com.sapportals.portal.security.usermanagement.IUser)request.getUser().getUser();

IResourceContext resourceContext=new ResourceContext(user);

Regards,

Ganesh N

Message was edited by: Ganesh Natarajan

Former Member
0 Kudos

Thanks Ganesh,

It solved my problem.

Do you have an idea how to get the content of an HTML document stored as it is in KM and display in an abstract portal component.

P.S Assigned points to you.

Former Member
0 Kudos

Hi,

Try something like this:

...
IResourceFactory resFactory = ResourceFactory.getInstance();
IResource res = (IResource) resFactory.getResource(rid, rContext); 
IContent content = resource.getUnfilteredContent();
InputStream is = content.getInputStream();
        byte[] bytes = new byte[(int) content.getContentLength()];
        int i = is.read();
        int count = 0;
        while (i != -1) {
          char b = (char) i;
          bytes[count] = (byte) i;
          count++;
          i = is.read();
        }
...
response.write(new String(bytes, "UTF-8"));

Getting the content and writing to the response could be better, but works good enough for my case

Romano

Former Member
0 Kudos

Thanks Romano,

response.write() takes string as a parameter.

How do we put the content object there?

P.S. Assigned points for your help

Former Member
0 Kudos

Hi,

If you know, that the resource is HTML (or generally text/string) you read the content (<i>resource.getUnfilteredContent()</i>) get the inputstream (<i>resource.getUnfilteredContent().getInputStream()</i>) read it byte by byte and write it to string (<i>new String(bytes, "UTF-8")</i>). Then give this string to <i>response.write()</i> method.

There is a lot of methods how to read InputStream in java, check the Google for some (surely better) examples

Romano

Answers (1)

Answers (1)

Former Member
0 Kudos

Dear All,

Could I have some help on this please.

I need it urgently.

Thanks in advance.