...
Note | ||||
---|---|---|---|---|
| ||||
PersonDirectory was refactored for uPortal 2.5 to be backed by Spring to wire together its implementation. However, documentation exists for PersonDirectory in uPortal 2.4 and earlier. |
PersonDirectory as API
In keeping with the uPortal 2 static service class model (often these static services are factories, e.g. ChannelManagerFactory, but sometimes they are merely static services such as RDBMServices, LdapServices, and PersonDirectory), PersonDirectory now provides a public static method whereby you can get an instance of IPersonAttributeDao.
Code Block |
---|
IPersonAttributeDao dao = PersonDirectory.getPersonAttributeDaoInstance();
|
The public IPersonAttributeDao interface methods, in turn, provide an API whereby uPortal components access user attributes.
Code Block |
---|
/**
* Obtains a mutable {@link Map} from attribute names to values for
* the given query seed. The values may be mutable objects but it is
* recommended they are immutable.<br>
*
* For the returned {@link Map}; Names must be {@link String}, Values
* can be any {@link Object}, they are typically {@link String}<br>
*
* Values may also be multi-valued, in this case they are of type
* {@link java.util.List} and the lists contents are the values of the
* attribute.<br>
*
* The return of this method uses the following rules:<br>
* <ul>
* <li>If the user exists and has attributes a populated {@link Map} is returned.</li>
* <li>If the user exists and has no attributes an empty {@link Map} is returned.</li>
* <li>If the user doesn't exist <code>null</code> is returned.</li>
* <li>If an error occurs while getting the attributes the appropriate exception will be propagated.</li>
* </ul>
*
* @param seed Map of attributes and values to use for the query
* @return Map from attribute names to values
* @throws IllegalArgumentException If <code>seed</code> is <code>null</code>
*/
public Map getUserAttributes(final Map seed);
/**
* This method uses the default attribute to construct a seed
* {@link Map} and call the {@link #getUserAttributes(Map)} method
* with.
*
* @param uid The string to use as the value in the seed
* @return The same value as returned by {@link #getUserAttributes(Map)}
* @see #getUserAttributes(Map)
*/
public Map getUserAttributes(final String uid);
/**
* Gets a {@link Set} of attribute names that may be returned by the
* {@link #getUserAttributes(Map)}. The names returned represent all
* possible names {@link #getUserAttributes(Map)} could return. If the
* dao doesn't have a way to know all possible attribute names this
* method should return <code>null</code>
* <br>
* An immutable {@link Set} is returned.
*
* @return A {link Set} of possible attribute names for user queries.
*/
public Set getPossibleUserAttributeNames();
|
To get the attributes into an IPerson object use the setAttributes method:
Code Block |
---|
/**
* Associates attributes with the user
* @param attrs
*/
public void setAttributes (Map attrs);
|
PersonFactory now offers the service of RestrictedPerson creation.
...
The uPortal Person Directory Service is provided by the separate source project PersonDirectory. uPortal 3.2 provides the single class, PersonDirectory, to obtain an instance of IPersonAttributeDao. IPersonAttributeDao is configured by Spring to acquire attributes for a person. Attributes can be acquired from multiple sources via LDAP, JDBC or other sources as required.
An example of how to get a standard IPerson and attributes for it:
...