cancel
Showing results for 
Search instead for 
Did you mean: 

ICollection.getChildren()

Former Member
0 Kudos

Hello,

I don't know if this Forum is the right place for my issue. I created in KM successfully a CM Repository pointing to a Fileshare. When I want to get all children of the repository I tried the following:

// create an user object from the current user
IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
//Create a EP user from the retrieved user
IUser epUser = WPUMFactory.getUserFactory().getEP5User(sapUser);
//Establish a Resource Context
IResourceContext resourceContext = new ResourceContext(epUser);
//get a resource factory
IResourceFactory resourceFactory = ResourceFactory.getInstance();
//Get a RID from the CSV File
RID file = RID.getRID(path);
//Get a Iresource for CSV File to work on
IResource resource = resourceFactory.getResource(file, resourceContext);
ICollection collection = (ICollection) resource;
 
IResourceList resourceList = collection.getChildren();

This code should give me all available children of a resource. The problem is, that the repository uses the permissions of the Fileshare (W2KSecurity). When a user wants to get all children, although he has no read permissions (but only for some children) for the resource, he gets an Exception. How can I get all children for which the user has the appropriate permissions?? Can someone help me out?

In the KM API I found the following method:

getChildren(Selector childrenSelector, Collator sortBy, IPropertyNameList propertyPrefill, String[] permissionNames)

I think this is the right method to use, but I was not able to implement it correctly.

Points will be awarded.

Best regards,

Denis

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Denis,

What is the Exception message?

Former Member
0 Kudos

Hi Julien,

thanks for the answers. Here my Exception message:

com.sapportals.wcm.repository.AccessDeniedException: Permission denied: uri=/<uri>, permission=node_list_children, user=<user>

Former Member
0 Kudos

Hello Denis,

According to the Javadoc :

<i>

getChildren

public IResourceList getChildren(Selector childrenSelector,

Collator sortBy,

IPropertyNameList propertyPrefill,

String[] permissionNames)

throws ResourceException, AccessDeniedException

Returns the children of this collection. The list of children can be filtered by properties and permissions and sorted by properties. A child resource is not included in the result if the user in the context does not have read permission for the properties (this is true if at least one parameter is used (not null) which will cause properties to be fetched: Collator, Selector or propertyPrefill).

Parameters:

childrenSelector - Specifies the filter expression

sortBy - Specifies the ordering of the returned list. Children which are collections are grouped together and are placed BEFORE the non-collections.

propertyPrefill - Specifies the names of properties which should be fetched for the children of the collection in addition to those needed for filtering and sorting. This "prefetching" can improve performance of subsequent getProperty() calls on the child resources.

permissionNames - An array of permission names (permission name constants are defined in IPermission). Resources for which the user in the context does not have one of the specified permissions are removed from the result list.

Throws:

ResourceException

<b>AccessDeniedException - If the resource is locked, readonly or authorization failed</b></i>

I think that if you define permissions in getChildren parameters, the exception should not be thrown, because if the user does not have permissions for the child, the child will not be included in the children list.

Here is the IPermission Javadoc which can be useful.

https://media.sdn.sap.com/html/submitted_docs/nw_kmc/javadoc/com/sap/netweaver/bc/rf/common/security...

Hope it helps.

Regards,

Julien.