Hi Gurus,
I'm trying to implement a little EFP project and I wanted to access files, which are stored in KM. I did it several times with WebDynpro successfully, but it seems to be a bit difficult within a JSP file. My code is as follows:
<%@ page import="com.sapportals.wcm.repository.*"%>
<%@ page import="com.sapportals.wcm.util.usermanagement.WPUMFactory"%>
<%@ page import="com.sapportals.wcm.util.uri.RID"%>
<%@ page import="com.sapportals.portal.security.usermanagement.IUser"%>
<%
String languageParam = componentRequest.getUser().getLocale().toString();
String currentUserName = componentRequest.getUser().getLogonUid();
IPortalComponentProfile profile = componentRequest.getComponentContext().getProfile();
//Get Bundle file
ResourceBundle bundle = componentRequest.getResourceBundle();
//Get Portal Favorites for the user
try {
//Get current User
com.sap.security.api.IUser user = componentRequest.getUser().getUserFactory().getUserByLogonID(currentUserName);
IUser ep5User = WPUMFactory.getUserFactory().getEP5User(user);
//Create Resource Context
IResourceContext resourceContext = new ResourceContext(ep5User);
IResourceFactory resourceFactory = ResourceFactory.getInstance();
//Get KM Resource
RID pathRID = RID.getRID("/userhome/" + currentUserName + "/favorites");
IResource resource = resourceFactory.getResource(pathRID, resourceContext);
ICollection collection = (ICollection) resource;
IResourceList resourceList = collection.getChildren(); //There will be thrown the Exception
//user = componentRequest.getUser().getUserFactory().getUserByLogonID(currentUserName);
//com.sapportals.portal.security.usermanagement.IUser ep5User = WPUMFactory.getUserFactory().getEP5User(user);
//IResourceContext resourceContext = new ResourceContext(ep5User);
//IResourceFactory resourceFactory = ResourceFactory.getInstance();
//RID pathRID = RID.getRID("/userhome/" + currentUserName + "/Favorites");
//IResource resource = resourceFactory.getResource(pathRID, resourceContext);
//ICollection collection = (ICollection) resource;
//IResourceList resourceList = collection.getChildren();
//IResourceListIterator resourceListIterator = resourceList.listIterator();
//int links = 0;
%>
//Here is some HTML-Code
<div class="link"><a href="#"><%=resource%></a></div>
<%
} catch(AccessDeniedException e) {
e.printStackTrace();
} catch(NullPointerException e) {
e.printStackTrace();
}
%>
I always get an AccesDeniedException after executing the method "getChildren" for the resource, although the user is Super-Administrator. I also specified "knowledgemanagement and usermanagement" in the SharingReference of my portalapp.xml. Does anybody know, where the problem is?
Help would be appreciated.
Thanks in advance.
Denis