In this blog describes the issues faced while accessing  KM files from ear file (iView in portal) in NW 7.31

Prerequisites

You have created a ear file project in NWDS and need to access KM files or folders

Issues faced


  1. How to get required KM API?

          By default NWDS is not having KM related dependencies , you need to download below two SCA files from Service market place relevant to your server           version.

          KMCCM and KMCWPC

          Then import these sca files into NWDS from development infrastructure perspective.

          Next step is in development infrastructure perspective click in KMC-CM SCA file-> in Component properties-> overview tab->Archive store ->select the           downloaded SCA file and upload.

   2. Adding KM API jar files to ear file?

          Right click ear file project->Properties->Java build path->Add external Jars then select KM API from           “LocalDevelopment\KMC-          CM\sap.com\tc\km\frwk\_comp\gen\default\public\api\lib\java”

          Next is the important step in ear project-> dist-> portal-INF->portalapp.xml->Application Tab->SharingReference -> add this value           “com.sap.km.application” . Now you can access KM related classes in ear file.

           Below code is an example to access files from a KM folder and lists users having access to file.

      IResourceFactory resourceFactory = ResourceFactory.getInstance();            

      com.sapportals.wcm.repository.IResourceContext resourceContext =      ResourceFactory.getInstance().getServiceContextUME(“cmadmin_service”);      

            RID rid = RID.getRID(“/documents/Files “);

            com.sapportals.wcm.repository.IResource resourceN = resourceFactory.getResource(rid, resourceContext);

            if(resourceN.isCollection())

            {

                  ICollection collection=(ICollection)resourceN;

                  IResourceList resourceList=collection.getChildren();

                  IResourceListIterator iterator=resourceList.listIterator();

                  while(iterator.hasNext())

                  {

                        try{

                              IResource resource2=(IResource)iterator.next();                          

                              ISecurityManager securityManager      =resource2.getRepositoryManager().getSecurityManager(resource2);

                              IResourceAclManager irm =((IAclSecurityManager)securityManager).getAclManager();

                              IResourceAcl resourceAcl = irm.getAcl(resource2);                                                

                        IResourceAclEntryList list = resourceAcl.getEntries();

                              IResourceAclEntryListIterator iteratorAcl = list.iterator();                

                        while (iteratorAcl.hasNext()){

                        IResourceAclEntry entry = iteratorAcl.next();

                       System.err.println(entry.getPrincipalUME().getDisplayName());

                         }

                       }                    

                        }

                        } catch ( Exception e) {

                                System.err.println(“exception: “ + e.getLocalizedMessage());

                        }

                      

                  }

            }


regards,

Rakesh Mathew

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. krishna chaitanya

    Hi Rakesh,

    I am also in search of a custom par application that fetches the data from a KM folder and displays the content as links in portal. Can you let me know how to achieve this.

    Thanks,

    Krishna

    (0) 

Leave a Reply