Link to home
Start Free TrialLog in
Avatar of Lucky48390
Lucky48390

asked on

java portlet for oracle portal

Hi All,

This seems like such a simple question, but nobody on Oracle's site seems to be able to come up with a response to it, so I thought I would give it a go here.

This is driving me nuts for a while now! Can somebody please please help me figure out what is wrong?  I wish to get the user's First Name as it is stored in OID.

The code below seems as if it should work, but it only gives me the username, instead of the user's first name. Can anyone see if they know why?

imports:
oracle.portal.provider.v2.render.PortletRenderRequest
oracle.portal.provider.v2.http.HttpCommonConstants
oracle.portal.provider.v2.http.ServletProviderUser
oracle.portal.provider.v2.oid.OidManager
oracle.portal.provider.v2.ProviderContext
java.util.ResourceBundle

Work:
PortletRenderRequest pReq = (PortletRenderRequest)
request.getAttribute(HttpCommonConstants.PORTLET_RENDER_REQUEST);

ProviderContext pc = pReq.getProviderInstance().getProviderContext();

OidManager oidman = pReq.getProviderInstance().getOidManager();

String first_name = (oidman != null) ? pReq.getUser().getFirstName().toString() : pReq.getUser().getName().toString();

Thanks in advance!
Lisa
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Try finding out what names are available:

System.out.println((Collections.list(pReq.getAttributeNames()));
is oidman null, or is it returning the wrong name?
Avatar of Lucky48390
Lucky48390

ASKER

Hi Objects, oidman is returning null. So I am left with LMMXP instead of Lisa. Also, I am using an Oracle API and there is no setOidManager() class in it. There are classes to set LDAP information. Do you think i would need to do all of that?

CEHJ, the OidManager has been configured properly

Thanks for all your input - i really appreciate it


Where do you initialise the provider?
I thought that the object would be out there waiting for me to grab in the portal instance. So, I tried a different approach, and am now receiving a "Listener returned the following message: 500 Internal Server Error" at the line of code containing the asterisks...

PortletRenderRequest pReq = (PortletRenderRequest)
      request.getAttribute(HttpCommonConstants.PORTLET_RENDER_REQUEST);
   ProviderContext pc = pReq.getProviderInstance().getProviderContext();
   
   ***************OidManager oidman = new OidManager(pc);***********************
   
   DirContext userContext = oidman.getUserLDAPContext(pReq.getUser().getUserDN(),pReq.getUser().getSubscriberDN());
   
   ResourceBundle bundle = ResourceBundle.getBundle("welcome_portlet.MlsResourceBundle", pReq.getLocale());
 
   String first_name = (pReq.getUser().isLDAPEnabled()) ? oidman.getUserProperty(pReq.getUser().getUserDN(),pReq.getUser().getSubscriberDN(), "givenname") : pReq.getUser().getName().toString();

Try

OidManager oidman = pReq.getProviderInstance().getOidManager();
> OidManager oidman = pReq.getProviderInstance().getOidManager();

That returns null
If it returns null, as opposed to causing NPE that may suggest that the OidManager is not configured properly
It returns null. That is how it was programmed originally. It does not throw an exception. I will verify again that it is configured properly.
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok - i'm back... Sorry it took so long. DBA's have tripple verified that the OidManager is configured properly... :( This is so irritating, I might consider calling the pl/sql api...
Ok - it didn't matter how i did it the Oracle JPDK API would not work! So i said forget it and used the JNDI java api - and it worked on the first try!

I'm going to split the points b/w the two of you anyways because you have both helped me out so much in the past. :)

Thanks for your efforts!
:-)
Good to hear u got it working :)