01: package org.jasig.portal.channels.cusermanager;
02:
03: import org.jasig.portal.ChannelRuntimeData;
04: import org.jasig.portal.security.IPerson;
05: import org.jasig.portal.security.provider.PersonImpl;
06:
07: /**
08: * This is a utility class for extracting parameters from ChannelRuntimeData and populating them into an IPerson.
09: * @author apetro
10: *
11: */
12: public class ChannelRuntimeDataToPersonConverter {
13:
14: public IPerson channelRuntimeDataToPerson(
15: ChannelRuntimeData channelRuntimeData) {
16:
17: IPerson newborn = new PersonImpl();
18:
19: for (String channelRuntimeDataParameterName : channelRuntimeData
20: .getParameters().keySet()) {
21: if (!channelRuntimeDataParameterName
22: .equals(Constants.FORMACTION)) {
23: String paramValue = channelRuntimeData
24: .getParameter(channelRuntimeDataParameterName);
25: // this null handling is required becausee PersonImpl is a HashTable
26: // which does not allow null user attribute values
27: if (paramValue == null) {
28: paramValue = "";
29: }
30: newborn.setAttribute(channelRuntimeDataParameterName,
31: paramValue);
32: }
33: }
34:
35: return newborn;
36: }// crd2persion
37:
38: }
|