cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with IUser Object

Former Member
0 Kudos

HI Experts,

I am developing a Search Application using the KM Indexmanagement API for TREX.

As part of my development, i need current loged in USER,

i am getting IUSER Object using com.sap.security.IUser.(NEW VERSION API OBJECT)

Now I need to create ResouceContext Object using IResourceContext API.

But it takes IUser object as argument,

which is of type com.sapportals.portal.security.usermanagement.IUser (OLDER VERSION API OBJECT).

NOW I need to convert New version IUSER to older version IUSER.

HOW IT IS POSSIBLE??????

I tried all the possible ways like........using

Fisrt way i tried is......

*****************************************

IWDClientUser wdClientUser = WDClientUser.getCurrentUser();

IUser sapUser = wdClientUser.getSAPUser();

com.sapportals.portal.security.usermanagement.IUser ep5User =

WPUMFactory.getUserFactory().

getEP5User(sapUser);

IResourceContext resourseContext = new ResourceContext(ep5User);

*********************************************************

When i try using this it says the below code is deprecated and it is not excuting at all

but not giving error, it show warning saying these methods are deprecated

com.sapportals.portal.security.usermanagement.IUser ep5User =

WPUMFactory.getUserFactory().

getEP5User(sapUser);

For the above code it says getEP5User, IUser are deprecated.

using this way i am unable to run.

The second way i tried is

**********************************************************

After searching some thread in SDN i got this solution , i tried this ......

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

IResourceContext resourceContext=new ResourceContext(user);

**********************************************************

But in this what is REQUEST ?

where can i get this request object.

when i read that thread, where i found the above solution , he is working with PDK and developed some servlet.

in his servlet he wrote some code for request object.

But in my case i am developing some WebDynpro application.

I am unable to get request object.

I tried all the possible ways..... searched in entire SDN....understood all API'S but i didn't find any solution.

I feel even SAP has not recognised this problem.

I explained my problem in detail, if any one has solution please help me out.

Thanks in advance

regards

Bala

Accepted Solutions (1)

Accepted Solutions (1)

Mattias
Active Participant
0 Kudos

Hi,

The first way indeed give you warnings about some methods/objects being deprecated, but it should run. Have you tried debugging it to see where it goes wrong? I have used it before, and so is also this <a href="/people/vinod.patil/blog/2007/03/27/knowledge-management-and-trex-functionalities-through-webdynpro-using-km-index-management-apis.

Request is the PortalRequest, which you have access to if you're creating a portal component.

We managed to access KM content without using depracated methods, but unfortunatly I have since then changed jobs and don't have access to the code anymore.

Regards

Mattias

Former Member
0 Kudos

Thank you very much for your reply .

I am getting the result now. i have not added those things in references.

But my the result is not as per my requirement.

I am not getting the links.

when search any document, it is showing the path to that document, but it is not showing the link to open that document.

I am unable to open the required search document.

i could able to see only the path.

Meanse i am not getting the link to that perticular document,i am getting the path

to searched document.

I dont know where is the problem .

can you please help me out.

Thanks again

Regards

Bala

Mattias
Active Participant
0 Kudos

Hi,

I'm not sure I'm following you. But if you get the correct path to the document, all you need to do to create a link is to create a "link to url" and map the path to the attribute "reference". This should give you a link to your document.

/Mattias

Former Member
0 Kudos

Hi,

I wrote the below code to display the links ,

but still i get only the path to the searched folders, not the link.

I tried with the below code but still i get the same.

<b>what to do to get the link to the searched ocuments</b>

ResourceContext resourseContext = new ResourceContext(ep5User);

IIndexService indexService =

(IIndexService)ResourceFactory.getInstance().getServiceFactory().getService ( "IndexmanagementService");

IFederatedSearch federatedSearch =

(IFederatedSearch)indexService.getObjectInstance("federatedSearchInstance");

List listuser=indexService.getActiveIndexes();

SearchQueryListBuilder sqb = new SearchQueryListBuilder();

sqb.setSearchTerm(query);

IQueryEntryList qel = sqb.buildSearchQueryList();

ISearchSession session = federatedSearch.searchWithSession(qel, listuser,resourseContext);

//searchSimilarDocumentsWithSession(listuser,rl);

ISearchResultList results = session.getSearchResults(

1, session.getTotalNumberResultKeys()

);

ISearchResultListIterator iter = results.listIterator();

String r= "";

String k= "";

while (iter.hasNext())

{

ISearchResult result = iter.next();

IResource resource = result.getResource();

IURLGeneratorService url =

(IURLGeneratorService)ResourceFactory.getInstance().getServiceFactory().getService(IServiceTypesConst.URLGENERATOR_SERVICE);

k=url.getResourcePageUri(PathKey.CONTENT_ACCESS_PATH,resource.getAccessRID(),null).toString();

r = r + k + "\n" ;

}

wdContext.currentContextElement().setMsg(r);

wdComponentAPI.getMessageManager().reportSuccess("Searched Successfully");

}

Regards

Bala

Mattias
Active Participant
0 Kudos

Hi,

What do you mean you get the path and not the link? What does the path look like? Do you mean you want the content in the documents, or a web link that opens the document?

Regards

Mattias

Former Member
0 Kudos

Hi mattias ,

Thank you very much for your reply.

I need a web link that opens the document.

regards

Bala

Mattias
Active Participant
0 Kudos

Hi Bala

If you're creating a web link you can't concatenate the results, or it will become an invalid web link. If you can get more than one link as a response you need to create a table with links and save each of them as new elements. Lets just assume you always get one response just for the sake of clarity.

(I also changed the name of the variable k to uri and of the variable url to urlService, just to make it more readable.)

After doing this you should be able to map the context attribute msg to the resource property of a view element of tyme linkToUrl.

Regards

mattias


ISearchResult result = iter.next();
IResource resource = result.getResource();
IURLGeneratorService url =  (IURLGeneratorService)ResourceFactory.getInstance().getServiceFactory().getService(IServiceTypesConst.URLGENERATOR_SERVICE);
uri =url.getResourcePageUri(PathKey.CONTENT_ACCESS_PATH,resource.getAccessRID(),null).toString(); 
wdContext.currentContextElement().setMsg(uri);
wdComponentAPI.getMessageManager().reportSuccess("Searched Successfully");
}

Former Member
0 Kudos

HI mattias,

What do you mean by this, Can you please elaborate your answer.

<b>you should be able to map the context attribute msg to the resource property of a view element of tyme linkToUrl</b>.

What i have understood is,

We need to create a context element msg of type LinkToURL from selecting javaNative libraries.

And map it with wdContext.currentContextElement().setMsg(uri);

when i do like this it says....

setMsg(); takes an argument of LinkToURL type, but we are giving uri of string type.

I tried to create the object for LinkToURL with uri like this...

com.sap.tc.webdynpro.clientserver.uielib.standard.impl.LinkToURL uri = new com.sap.tc.webdynpro.clientserver.uielib.standard.impl.LinkToURL();

This is not working.

What to do now ??

Am i doing correct? where is the problem.

Regards

Bala

Mattias
Active Participant
0 Kudos

Hi,

I think you misunderstood. What you need to do is add an element in your view. Just like you add a label or an input field, there's an element type called LinkToUrl (Under Standard Complex) that you can add. Then you bind the property "reference" to your context attribute Msg.

The context attribute should be of type String, just leave it at it's default properties.

Regards

Mattias

Former Member
0 Kudos

Hi,

As you said i have created a view element LinkToURL and given its name as SearchResult

and mapped the reference with context variable Msg of type string.

When i search i am getting link....with the same name as i gave to view element(SearchResult).

It is not getting changed.

And when i click on that link below message is coming in a window...(see below)

http://iginsapsm:50000/irj/go/km/docs/documents/Aruna

The folder you are looking for has no displayable content.

You can try one of the following:

Access the folder using the <u>Navigation user interface</u>.

Access the folder as a <u>Web folder</u>. Your operating system and browser dictate whether or not this will work.

When i click any of these links..

<u>Navigation user interface </u>

<u>Web folder</u>

I am getting the required Result.(meanse it is opening the document from portal)

Why it is not displaying directly, why it is happening so.

Thank you very much for your help.

regards

Bala

Mattias
Active Participant
0 Kudos

Hi,

Seems like you found a folder and not a document, I'm no KM expert so I don't know what happens when you link to a folder.

To change the name of the link you need to bind another property of the view element, it's probably called "text" or something similar, I don't have the developer studio available.

Regards

Mattias

Answers (0)