* {@inheritDoc}.
*/
@Override
public Principal execute(final String inAccountId)
{
DefaultPrincipal result = null;
try
{
// grab info from cache/db.
PersonModelView pmv = getPersonMVByAccountId.execute(inAccountId);
// if found, create principal, else attempt to create from LDAP (creates locked user in DB).
if (pmv != null)
{
result = new DefaultPrincipal(pmv.getAccountId(), pmv.getOpenSocialId(), pmv.getId());
}
// not found in cache or DB, go to ldap to create person entry and principal if possible.
else
{
logger.info("Unable to populate principal from cache/db, looking up user in LDAP for: " + inAccountId);
Person person = (Person) serviceActionController.execute(new ServiceActionContext(inAccountId, null),
createUserfromLdapAction);
result = new DefaultPrincipal(person.getAccountId(), person.getOpenSocialId(), person.getId());
}
}
catch (Exception ex)
{
logger.info("Unable to populate principal from DataStore for: " + inAccountId, ex);