I'm trying to develop a program to read through a KM repository, but before I get started I must get around the issue of establishing a ResourceContext (which needs a valid com.sapportals.portal.security.usermanagement.IUser passed to it)...
Anyway does anyone have any ideas as to why I'm having the following issues with the code that I have below:
package src.api;
import com.sapportals.wcm.util.uri.RID;
import com.sapportals.portal.security.usermanagement.IUser;
import com.sapportals.wcm.util.usermanagement.WPUMFactory;
import com.sapportals.portal.prt.session.IUserContext;
import com.sapportals.portal.prt.component.*;
public class MyComponent extends AbstractPortalComponent
{
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
{
System.out.println("dan88");
System.out.println("dan test222");
response.write("testing 2 ");
RID rid = RID.getRID("/Corporate Services");
System.out.println(rid.toString());
System.out.println("dan test222");
//Issue need to:
//IResourceContext ctxt = new
//ResourceContext(com.sapportals.portal.security.usermanagement.IUser);
//Need a com.sapportals.portal.security.usermanagement.IUser
//Also No java doc for com.sapportals.portal.security.usermanagement.IUser
// #1
try
{
IUser loggedOnUser = (IUser)request.getUser().getUser();
// Exception caught ...java.lang.ClassCastException: com.sapportals.portal.
// security.usermanagement.User50_Impl
String user = loggedOnUser.getId();
System.out.println(user);
}
catch (Exception ex)
{
// System.err.println("Exception caught ..." + ex);
System.out.println("Exception caught ..." + ex);
}
// #2
try
{
IUser user = WPUMFactory.getUserFactory().getEP5User(request.getUser());
//Exception caught ...java.lang.NullPointerException
System.out.println("made it!");
}
catch (Exception ex)
{
// System.err.println("Exception caught ..." + ex);
System.out.println("Exception caught ..." + ex);
}
// #3
try
{
//IUser user = WPUMFactory.getUserFactory().getEP5User();
// No java doc for com.sapportals.portal.security.usermanagement.IUserFactory
System.out.println("number 3!");
}
catch (Exception ex)
{
// System.err.println("Exception caught ..." + ex);
System.out.println("Exception caught ..." + ex);
}
// #4
try
{
System.out.println("in 4!");
//String userID = request.getUser().getUserID();
//String userID2 = ((IUser) request.getUser().getUser()).getDisplayID();
IUserContext userContext = request.getUser();
System.out.println("did first instruction");
IUser user = (IUser) userContext.getUser();
System.out.println("made it!");
}
catch (Exception ex)
{
// System.err.println("Exception caught ..." + ex);
System.out.println("Exception caught ..." + ex);
}
System.out.println("donexx");
}
}
The log yields the following:
dan88
dan test222
/Corporate Services
dan test222
Exception caught ...java.lang.ClassCastException: com.sapportals.portal.security
.usermanagement.User50_Impl
Exception caught ...java.lang.NullPointerException
number 3!
in 4!
did first instruction
Exception caught ...java.lang.ClassCastException: com.sapportals.portal.security
.usermanagement.User50_Impl
donexx
Any thoughts on this would be greatly appreciated!