cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Portal Namespace_filter KM question

Former Member
0 Kudos

Friends,

I have a requirement where i need to filter out the KM documents based on his/her userid. IF the login user id matches the name of the document in kM folder, I need to show , if not hide the document. The goal is to user should see his document only but not others.

I do not want to setup KM folders for each user and configure ACLs, that is too much administration efforts involved. The approach i am looking is all the documents are stored in  KM folder, apply filter on that KM folder. the job of the filter should be check the login user, if the portal user id  matches to the file name, show the document if not hide the document.

Example:if  login userid : JOHNS , FIle name as: JOHNS_1234_343454.PDF , in this case user JOHNS should see the file in KM folder

              if login userud : JOEL   , in this case JOEL should not see any file in KM folder.

So far:

Created a Java project: abc.com.filter, two clasess, FilterDoc.java, FilterManagerDoc.java.

                                  com.sap.netweaver.rf.wrapper IRFServiceWrapper.java, RFServiceWrapper.java

I think only implementing the filter method in FilterDoc.java should sufficient, Please suggest a piece of code snippet two meet my requirement.

Thanks

KR.

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member254395
Active Participant
0 Kudos

Hi,

This is possible . Look for KM querying api, which will query your km repository based on the parameters which you pass as input.

also refer

http://scn.sap.com/docs/DOC-8112

https://help.sap.com/javadocs/NW04s/current/km/index.html

http://scn.sap.com/docs/DOC-8317

http://scn.sap.com/thread/643072

http://scn.sap.com/thread/842258

Rabin D

Former Member
0 Kudos

Thanks for your time. Sorry, my question was very generic in the initial post. let me post where I am .

I have implemented a filter method the code as below. Our portal server has limitation on ports some reason we are unable to switch on debug port. I have no option to troubleshoot my code in debug mode.

coming to the point, I deployed my project  , I can see my filter name in portal, I applied filter on repository but still i did not see the desired output. I added the system.out.print message to see message on the Java console but not writing any logs are any thing...I am not sure what is the location to check these log files....

is there any thing wrong with the below code? It looks good to me....I cannot even see any error. When I deploy, the .ear file deployed fine. I also used logger class , do you know where these log files are get stored?

package com.test.km;

import java.util.logging.Logger;

import com.sap.security.api.IUser;

import com.sap.tc.webdynpro.services.sal.um.api.IWDClientUser;

import com.sap.tc.webdynpro.services.sal.um.api.WDClientUser;

import com.sap.tc.webdynpro.services.sal.um.api.WDUMException;

import com.sapportals.wcm.WcmException;

import com.sapportals.wcm.repository.ICollection;

import com.sapportals.wcm.repository.IResource;

import com.sapportals.wcm.repository.IResourceList;

import com.sapportals.wcm.repository.IResourceListIterator;

import com.sapportals.wcm.repository.PropertyName;

import com.sapportals.wcm.repository.filter.INamespaceFilter;

public class KMDocumentFilter implements INamespaceFilter {

  private final INamespaceFilter predecessorFilter;

  KMDocumentFilter(INamespaceFilter predecessorFilter) {

    this.predecessorFilter = predecessorFilter;

  }

  public IResourceList filter() throws WcmException {

     // TODO Implement filtering (remove resources from the list)

  

   String filename;

   IWDClientUser wdUser = null;

   IUser portalUser = null;

  // get the currently logged in user

 

  try{

  wdUser = WDClientUser.getCurrentUser();

  portalUser = wdUser.getSAPUser();

  } catch (WDUMException e)

      {

  System.out.println("Error occurred while getting EP User : " + e.toString());

      }

   Logger.getLogger("Test log").info("user message" + portalUser );

   Logger.getLogger("Entered filter() method and predecessorFilter is " ).info("message" + this.predecessorFilter );

   IResourceList workingResourceList = this.predecessorFilter.filter();

   System.out.println("workingResourceList is " + workingResourceList);

   IResourceListIterator workingResourcelistIter = workingResourceList.listIterator();

   System.out.println("workingResourceListIter is " + workingResourcelistIter + " and workingResourceList size is " + workingResourceList.size());

   while (workingResourcelistIter.hasNext())

  {

  IResource currentResource = workingResourcelistIter.next();

  System.out.print("currentResource is " + currentResource);

  if (currentResource != null)

  {

  System.out.println(" currentResource.isCollection() is " + currentResource.isCollection());

  if (!currentResource.isCollection())

  {

  filename = currentResource.getName().toUpperCase();

  if(portalUser != null && filename != null) {

  if(portalUser.toString().equalsIgnoreCase(filename.substring(0, filename.indexOf("_")))) {

  System.out.println(" File not removed even though name matches");

  }else {

  workingResourcelistIter.remove();

  System.out.println(" File removed");

  }

  }

  }

  }

}

 

   return workingResourceList;

 

   //return this.predecessorFilter.filter();

  }

  public ICollection getCollection() throws WcmException {

    return this.predecessorFilter.getCollection();

  }  

      

}

Thanks

Krishna

former_member254395
Active Participant
0 Kudos

Hi,

For log purpose use below line , before the constructor

public static Location location = Location.getLocation(com.test.km.KMDocumentFilter.class);

location.errorT(""); --> this line will print all logs .

You can see this logs in nwa.

Thanks & Regards,

Rabin D

Former Member
0 Kudos

Thanks Rabin, It looks like the service class it self is not calling from the portal. When run this service, as per the program execution, expected to invoke the init() method from the RFServiceWrapper class.

public void init(IServiceContext serviceContext){

     mm_serviceContext = serviceContext;

    CrtClassLoaderRegistry.addClassLoader(this.getKey(), this.getClass().getClassLoader());

}

The service key has provided as below in IRFServiceWrapper Interface.

public interface IRFServiceWrapper extends IService{

    public static final String KEY = "com.xxx.km.KMFilter";

   

}

The error log from trace as below:

Message:   Registration of classloader with id 'com.xxx.km.KMDocumentFilter' ignored, as hot-deployment is not supported

(see OSS Note 894884). Please restart the server to enable newly deployed components.

Severity:   Error

Date:   2013-12-27

Time:   13:11:59:862

Category:   /Applications/KMC/CRT

Location:   com.sapportals.wcm.crt.CrtClassLoaderRegistry

Application:   sap.com/com.xxx.km.docfilter

Thread:   Application [35]

Data Source:   j2ee\cluster\server0\log\applications_00.log

Arguments:

Passport User Activity ID:   b5df4971f0a710019fd5d0799d65da7e

Message ID:

Session:   0

Transaction:

User:   Guest

Time Zone:   0-500

Customer Message Component:   EP-KM-FWK-RF

Runtime Component:   sap.com/com.sap.netweaver.bc.crt

Correlation ID:   9803450000000035

Passport Session:   B5DF4971F0A710019FD5D0799D65DA7E

Passport Connection:   b5df4971f0a710019fd5d0799d65da7e

Passport Connection Counter:   0

Log ID:   C0000AB8180F013A00000001000011B8

Host:   PIDWEPL001

System:   ABS

Instance:   J00

Node:   server0

Here is my XML:

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?><application>

<application-config><property name="SharingReference" value="usermanagement, knowledgemanagement, landscape, htmlb, exportalJCOclient, exportal"/>

  </application-config>

<components/>

<services>

  <service name="RFServiceWrapper">

   <service-config>

    <property name="className" value="com.sap.netweaver.rf.wrapper.RFServiceWrapper"/>

    <property name="startup" value="true"/>

   </service-config>

  </service></services>

</application>

Error message from component monitor:

When I looked at the system Info from System Administration>>Monitoring>>Component Monitor

Hot-Deployment:   Restart/Redeployment of application with reg. ID 'com.xxx.km.KMDocumentFilter' detected. Please see OSS Note 894884 for details and restart the server. New classloader was: sap.com/com.xxx.km.docfilter@com.sap.engine.boot.loader.ResourceMultiParentClassLoader@451f6fc3@alive

Restart server done, followed the note but no luck.

Thanks

Krishna

Former Member
0 Kudos

Hi Rabin,

Do you know where is thelocation of these logs in NWA?

public static Location location = Location.getLocation(com.test.km.KMDocumentFilter.class);

location.errorT(""); --> this line will print all logs

I printed messages every where in my program but I cannot see any logs.....I checked Default trace logs, system logs, in nwa but did not find..

Thanks

Krishna

former_member254395
Active Participant
0 Kudos

Hi

As mentioned by you, please look why the service class itself is not calling . Until then it wont print error message.

Ether default trace or last 24 houses trace is the exact place.

I hope you imported import com.sap.tc.logging.Location;import com.sap.tc.logging.Location;

class for log purpose.

Rabin D

Former Member
0 Kudos

Hi Rabin,

I do have import com.sap.tc.logging.Location in program.

I am still not sure why my repository not hitting configured namespace filter. Any input or advice greatly appreciated in advance.

I am thinking that if repository invoke the applied filter I must see the message from RFServiceWrapper , init() method.

public void init(IServiceContext serviceContext){

 

  logger.errorT("Entered serviceContext method in RF Service Wrapper() : krishna ");

  mm_serviceContext = serviceContext;

 

  try {

  logger.errorT("Entered  test CrtClassLoaderRegistry method in RF Service Wrapper() ");

  CrtClassLoaderRegistry.addClassLoader(this.getKey(), this.getClass().getClassLoader());

  } catch (Exception e) {

  // TODO Auto-generated catch block

  e.printStackTrace();

  }

  logger.errorT("After CrtClassLoaderRegistry method execution ");

  // Refer the context class after the registry.

}

Alos, When I generate a >EAR file, the log shows in NWDS as below, but still NWDS 7.3 is generating .EAR file and I am able to deploy .EAR file on server.

is the below errors any thing to do with my issue?

class: com.sap.portal.plugins.ConfigFrameworkArchiver   -> Config archive successfully created (time to export 98 ms)      [Error: com.sap.ep.connectionManager.util.SapPortalPluginsLogger  Thread[main,6,main]]

class: com.sap.portal.plugins.ConfigFrameworkArchiver   -> Missing file plugin.header.properties in /Test1230/src.config/install/meta/expanded/cm/repository_filters      [Error: com.sap.ep.connectionManager.util.SapPortalPluginsLogger  Thread[main,6,main]]

class: com.sap.portal.plugins.ConfigFrameworkArchiver   -> No privateArchive.properties file is defined.      [Error: com.sap.ep.connectionManager.util.SapPortalPluginsLogger  Thread[main,6,main]]

Thanks

Krishna

Former Member
0 Kudos

Any input please?

Thanks

Krishna

Former Member
0 Kudos

Hi Experts,

Any advice, badly stuck here.

Thanks

Krishna

Former Member
0 Kudos


Any one???? Some reason the KM Repository mangers are not registering with developed customer filter?

Any input would be a great help....badly stuck here...Appreciate your help

Thanks

Krishna

Former Member
0 Kudos

Hi All, here is the solution for this issue:

Finally the issue got resolved. The issue is SAP Portal 7.3 some of the repositories and services are obsolete example: Tasks, docu_example they more need in sap portal 7.3, also these repositories marked as RED and eventually this is stopping to initiate namesape filters on any repository. I have created a sap note and they replied to deactivate or delete these unused services or repositories, then started working my filter.

Spent lot of time on this and finally got the solution. Appreciate your time in replying my question.

Thanks

Krishna