Best way to get handle to Profile

1,023 views
Skip to first unread message

David Herman

unread,
Jul 1, 2008, 5:50:42 PM7/1/08
to ATG_Tech
Is there an "preferred" way in which to get a handle to the actual
Profile object given a ProfileID?

I'm doing :
Profile profile = new Profile();
boolean found = profileTools.locateUserFromId(profileId, profile);

But I wanted to know if this was the preferred way? I've not found
anything that will return a profile object...

George Oprica

unread,
Jul 1, 2008, 6:49:09 PM7/1/08
to atg_...@googlegroups.com
The Profile is nothing more than a wrapper for a RepositoryItem (of
item type "user") from the
/atg/userprofiling/ProfileAdapterRepository, so you can access or
update properties using the repository API.

The methods you are looking for are in atg.userprofiling.ProfileTools,
like getItem, getItemFromEmail, etc.

- George

David Herman

unread,
Jul 1, 2008, 10:34:19 PM7/1/08
to ATG_Tech
I understand that the profile is just a wrapper, but sometimes it's
nice to state that a method is Supposed to take in a Profile object
rather than a rather generic RepositoryItem. In most cases the
calling class will already have a handle to the profile, but if all
you have is let's say an Order an the class you need to call takes a
Profile, you need a way to get the actual profile object rather than
just a RepositoryItem.

Belmont, Adam

unread,
Jul 1, 2008, 11:04:19 PM7/1/08
to atg_...@googlegroups.com
ProfileTools.locateUserFromId is good (for when you have the id of course).
All it really does to the Profile object passed in is to call its
"setDataSource()" method.

ProfileTools is available in Nucleus at "/atg/userprofiling/ProfileTools".
So you can set it up in your .properties file for components that need it.

Use those methods for getting at any given user profile. If you want the
"current" user profile there are a couple other ways.

If you are in a request thread the current user's profile is bound to that
thread. This is setup in the servlet pipeline (well dafpipeline on non-DAS
appservers!)

If you have access to DynamoHttpServletRequest you can always just resolve
it with that

request.resolveName("/atg/userprofiling/Profile");

If you don't have access to DynamoHttpServletRequest, but you are in a
request thread you can still get the Profile object since it's bound to a
thread local. This is kind of a last resort though, it's really not
preferred.

Use:
Profile p = (Profile) atg.servlet.ServletUtil.getCurrentUserProfile();
You need to make the cast to Profile since ServletUtil is actually in the
DAS module. It has no reference to DPS classes.

-- Adam

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ATG_Tech" group.
To post to this group, send email to atg_...@googlegroups.com
To unsubscribe from this group, send email to
atg_tech-u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/atg_tech?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply all
Reply to author
Forward
0 new messages