cancel
Showing results for 
Search instead for 
Did you mean: 

get internal url from resource as link

Former Member
0 Kudos

Hi

I am using the KM API where I try to get the url to an internal link.

myResource.getTargetURL();

myResou.

I am not sure what method should retrieve the URL.

Any help would be appreciated.

Regards

yuval

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

No real solution until now!!!

former_member188556
Active Contributor
0 Kudos

Yes, getTargetURL() gives u the url.

getTargetURL
public URL getTargetURL()
                 throws ResourceExceptionReturns 
the target URL of a link or null if the resource is not a link. 

Returns:
the target URL of a link or null if the resource is not a link. 
Throws: 
ResourceException

Check this JavaDocs for [IResource|https://help.sap.com/javadocs/NW04s/current/km/com/sapportals/wcm/repository/IResource.html]

Regards

BP

Former Member
0 Kudos

You will have do myResource.getProperty(<enter the name>); then retrive the value. I think the property would be access url.

Mahesh

Former Member
0 Kudos

Mahesh

Thanks for r reply

I am trying to figure out what property to provide as argument....

regards

yuval

former_member188556
Active Contributor
0 Kudos

Hi

Have you used,

myResource.getTargetURL();

???

Regards

BP

Former Member
0 Kudos

BP

resource.getTargetURL()

returns null;

I'm desparate....

Regards

yuval

Former Member
0 Kudos

>

> BP

>

> resource.getTargetURL()

>

> returns null;

>

> I'm desparate....

>

> Regards

> yuval

In that case the resource isn't a link. Or you found a bug.

Best regards, Julian

Former Member
0 Kudos

Julian

I am quite sure it is a link, first because it is of LinkType.Internal and second because

when we press this link in portal Favorites it we are being transferred to the corresponding

Iview

Regards

yuval

former_member188556
Active Contributor
0 Kudos

Hi

Can u paste the full code of the method u r using?

Also, just try to print the RID of the

myResource

.

I think

myResource

in ur case is really the target resource.

Please get back with code and the outcome of what i have suggested

Regards

BP

Former Member
0 Kudos

Bp

1. First, RID of my resource retrieves the path to it userhome/userID/Favorites/nameOfmyLink

2. Code:

ICollection collection = (ICollection) myResource;

IResourceList list = collection.getChildren();

IResourceListIterator iter = list.listIterator();

While(iter.hasNext())

{

com.sapportals.wcm.repository.IResource doc = ( com.sapportals.wcm.repository.IResource ) iter.next();

doc.getTargetURL(): // not working

IURLGENERATORService ugs =

(IURLGeneratorService) ResourceFactory.getInstance().getServiceFactory(0.getService(

IServiceTypesConst.URLGENERATOR_SERVICE);

uniRef = ugs.getRelativeUri(PathKey.Content_Access_Path).appendPath(doc.getRID().ToExternalForm());

etc

Thank you for your support!!

yuval

}

former_member188556
Active Contributor
0 Kudos

Hi

In ur code...

While(iter.hasNext())
{
com.sapportals.wcm.repository.IResource doc = 
( com.sapportals.wcm.repository.IResource ) iter.next();
*doc.getRID();*
}

What would doc.getRID() print?

Regards

BP

Former Member
0 Kudos

In your loop, just print out

- classname of IResouce instance (resource.getClass().getName()),

- link type,

- RID, and

- targetURL

and let us see the results.

Former Member
0 Kudos

Julian

I already did all that.

Nothing brings in the exact url.

All you get is the path up to the name of document, nothing more.

Whereas in reality the path is very long and contains a mixture of alphanumeric characters

Regards

yuval

Former Member
0 Kudos

Please do it and post the results here.

Former Member
0 Kudos

Julian hi

I think I know why I am getting null when I run iresource.getTargetURL().

I discovered that the LinkType of my resource is LinkType.NONE.

It very strange, isn't it??

regards

yuval

Former Member
0 Kudos

Julian

The class of my resource is :

com.sapportals.wcm.repository.manager.cm.Node.

regards

yuval

Former Member
0 Kudos

Julian

The class of my resource is: com.sapportals.wcm.repository.manager.cm.Node

Regards

yuval

Former Member
0 Kudos

>

> Julian hi

>

> I think I know why I am getting null when I run iresource.getTargetURL().

> I discovered that the LinkType of my resource is LinkType.NONE.

> It very strange, isn't it??

>

>

> regards

> yuval

It's not strange at all. It means that the resource is not a link.

Former Member
0 Kudos

Hi Julian

Very strange, then.

If I press this resouce in Favorites I get redirected to the page I added to my favorites.

I also tried to see if this resource has a collection under it. I got none.

Moreover when I studies the KM I saw this link is of 0 bytes i.e it holds nothing in it.

I tend to say that this is not a linktourl but a linktoaction. Once pressed the method behinds it goes to the PCD searches for this name and retrieves the url from there.....

But this is only a wild guess....

By the way can you check if your links arte of any size?

Thank you for yr support.!!!

regards

yuval

Former Member
0 Kudos

KM links do not have content, thus their size is 0.

It appears that the resources you are looking at aren't proper KM links, but something else.

Former Member
0 Kudos

Julian

How do I find out, through WDP, what they are???

regsrds

yuval

Former Member
0 Kudos

I don't know what WDP is, so I can't tell you.

Former Member
0 Kudos

Julian

I meant Web Dynpro

regards -:)

yuval