- The Custom Repository filter is developed and deployed
- Meta Data attributes are created in KM and attached to all the relevant documents
- Repository filter is applied to the respective repositories
- On an incoming user request, the filter intercepts the request and talks to the repository and filters out the documents that do not match the Users Profile Attributes. ( The filter may get the list from either the repository or the KM cache)
- If the attributes do not match then the resource is removed from the resource list which will be shown to the user.
Repository filter: What you have to do is build a Namespace Repository Filter, which will filter the lists of documents sent to the user upon the user visiting the repository. Most of the initial steps have been mentioned in the following weblog by Prakash Singh on implementing a namespace filter. How to create namespace filter for KM. In this web log, I will show some code on how to use the user attributes and meta data properties of KM resources for the same. Prerequisites:
- Custom Meta Data has been defined in the CM System
- Portal Objects are created and present with the appropriate meta data.
- Repository Filters have been created and applied to the repositories
- The User Profile attributes have been mapped to the UME.
- Accessing User Profile attributes: Since this is basically a filtering out resources of the resource list shown to the user, we have to get the context from the current resource you can do that like this: “abc = currentResource.getContext();” Once we have the resource context, we need to get the user context to retrieve its properties. you can do that like this with mutable user: IUser user = abc.getUser();
IUserMaint usermaint = userFact.getMutableUser(abc.getUser().getUMEId()); The next step would be to retrieve the mentioned properties of the user. ( note we can do this in a string array) String functionAttrs = usermaint.getAttribute(<<enter user attribute namespace here>>, <<enter user attribute name here>>); Remember, the namespace is for the custom user profile attribute which you have made available in the datasource xml file. This could be standard ( com.sap.security.core.usermanagement) Accessing meta data properties Now you have retrieved the user’s profile attribute and have access to it. The Next step would be to extract the meta data property of the concerned KM resource. you have to get the property name of the meta data property in context. you can do this through: IPropertyName propNameFunction = new PropertyName(<<enter namespace for custom km metadata>>, <<enter property name of custom KM meta data property>>); e.g for custom namespace: “http://yourcompany” Next , you actually pick up the property value for the property name: IProperty propFunction = currentResource.getProperty(propNameFunction) ; Now you have both the user profile attribute and the cutom meta data property of the current resource. To see if this document is to be made visible by the user you can compare the two properties and then either filter out the doc from the resource list or let it be. To filter the document out you can use the following : workingResourceList = this.predecessorFilter.filter(); IResourceListIterator workingResourcelistIter =workingResourceList.listIterator(); workingResourcelistIter.remove(); Now you know how to retrieve the meta data properties of the KM document, the custom user profile attributes and how to remove a resource from the list. In my next Blog, I will talk about how to publish custom meta data properties for documents and custom user profile attributes.