[portal-commits] JBoss Portal SVN: r9050 - branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Tue Nov 20 16:26:47 EST 2007


Author: chris.laprun at jboss.com
Date: 2007-11-20 16:26:47 -0500 (Tue, 20 Nov 2007)
New Revision: 9050

Modified:
   branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/UserContextConverter.java
Log:
- Updated to use latest version of P3PConstants.

Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/UserContextConverter.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/UserContextConverter.java	2007-11-20 21:02:47 UTC (rev 9049)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/UserContextConverter.java	2007-11-20 21:26:47 UTC (rev 9050)
@@ -23,7 +23,7 @@
 
 package org.jboss.portal.wsrp;
 
-import org.jboss.portal.common.p3p.P3PConstants;
+import static org.jboss.portal.common.p3p.P3PConstants.*;
 import org.jboss.portal.portlet.spi.UserContext;
 import org.jboss.portal.wsrp.core.Contact;
 import org.jboss.portal.wsrp.core.EmployerInfo;
@@ -78,68 +78,63 @@
       PersonName name = createNameFrom(userInfos);
 
       Calendar bdate = null;
-      String bdateAsString = (String)userInfos.get(P3PConstants.INFO_USER_BDATE);
+      String bdateAsString = (String)userInfos.get(INFO_USER_BDATE);
       if (bdateAsString != null)
       {
          bdate = SimpleTypeBindings.unmarshalDateTime(bdateAsString);
       }
 
-      EmployerInfo employerInfo = new EmployerInfo((String)userInfos.get(P3PConstants.INFO_USER_EMPLOYER),
-         (String)userInfos.get(P3PConstants.INFO_USER_DEPARTMENT),
-         (String)userInfos.get(P3PConstants.INFO_USER_JOB_TITLE), null);
+      EmployerInfo employerInfo = new EmployerInfo((String)userInfos.get(INFO_USER_EMPLOYER),
+         (String)userInfos.get(INFO_USER_DEPARTMENT),
+         (String)userInfos.get(INFO_USER_JOB_TITLE), null);
 
-      return new UserProfile(name, bdate, (String)userInfos.get(P3PConstants.INFO_USER_GENDER), employerInfo,
+      return new UserProfile(name, bdate, (String)userInfos.get(INFO_USER_GENDER), employerInfo,
          createContactFrom(userInfos, false), createContactFrom(userInfos, true), null);
    }
 
    private static PersonName createNameFrom(Map userInfos)
    {
       return new PersonName(
-         (String)userInfos.get(P3PConstants.INFO_USER_NAME_PREFIX),
-         (String)userInfos.get(P3PConstants.INFO_USER_NAME_GIVEN),
-         (String)userInfos.get(P3PConstants.INFO_USER_NAME_FAMILY),
-         (String)userInfos.get(P3PConstants.INFO_USER_NAME_MIDDLE),
-         (String)userInfos.get(P3PConstants.INFO_USER_NAME_SUFFIX),
-         (String)userInfos.get(P3PConstants.INFO_USER_NAME_NICKNAME), null);
+         (String)userInfos.get(INFO_USER_NAME_PREFIX),
+         (String)userInfos.get(INFO_USER_NAME_GIVEN),
+         (String)userInfos.get(INFO_USER_NAME_FAMILY),
+         (String)userInfos.get(INFO_USER_NAME_MIDDLE),
+         (String)userInfos.get(INFO_USER_NAME_SUFFIX),
+         (String)userInfos.get(INFO_USER_NAME_NICKNAME), null);
    }
 
    private static Contact createContactFrom(Map infos, boolean isBusiness)
    {
-      String key = getHomeOrBusinessPrefix(isBusiness);
+      Online online = new Online((String)infos.get(getOnlineUserInfoKey(OnlineInfo.EMAIL, isBusiness)),
+         (String)infos.get(getOnlineUserInfoKey(OnlineInfo.URI, isBusiness)), null);
 
-      Online online = new Online((String)infos.get(key + P3PConstants.ONLINE_EMAIL),
-         (String)infos.get(key + P3PConstants.ONLINE_URI), null);
-
       Postal postal = new Postal(
-         (String)infos.get(key + P3PConstants.POSTAL_NAME),
-         (String)infos.get(key + P3PConstants.POSTAL_STREET),
-         (String)infos.get(key + P3PConstants.POSTAL_CITY),
-         (String)infos.get(key + P3PConstants.POSTAL_STATEPROV),
-         (String)infos.get(key + P3PConstants.POSTAL_POSTALCODE),
-         (String)infos.get(key + P3PConstants.POSTAL_COUNTRY),
-         (String)infos.get(key + P3PConstants.POSTAL_ORGANIZATION), null);
+         (String)infos.get(getPostalUserInfoKey(PostalInfo.NAME, isBusiness)),
+         (String)infos.get(getPostalUserInfoKey(PostalInfo.STREET, isBusiness)),
+         (String)infos.get(getPostalUserInfoKey(PostalInfo.CITY, isBusiness)),
+         (String)infos.get(getPostalUserInfoKey(PostalInfo.STATEPROV, isBusiness)),
+         (String)infos.get(getPostalUserInfoKey(PostalInfo.POSTALCODE, isBusiness)),
+         (String)infos.get(getPostalUserInfoKey(PostalInfo.COUNTRY, isBusiness)),
+         (String)infos.get(getPostalUserInfoKey(PostalInfo.ORGANIZATION, isBusiness)), null);
 
-      Telecom telecom = new Telecom(createTelephoneNumFrom(infos, P3PConstants.TELECOM_TELEPHONE, isBusiness),
-         createTelephoneNumFrom(infos, P3PConstants.TELECOM_FAX, isBusiness),
-         createTelephoneNumFrom(infos, P3PConstants.TELECOM_MOBILE, isBusiness),
-         createTelephoneNumFrom(infos, P3PConstants.TELECOM_PAGER, isBusiness), null);
+      Telecom telecom = new Telecom(createTelephoneNumFrom(infos, TelecomType.TELEPHONE, isBusiness),
+         createTelephoneNumFrom(infos, TelecomType.FAX, isBusiness),
+         createTelephoneNumFrom(infos, TelecomType.MOBILE, isBusiness),
+         createTelephoneNumFrom(infos, TelecomType.PAGER, isBusiness), null);
 
       return new Contact(postal, telecom, online, null);
    }
 
-   private static TelephoneNum createTelephoneNumFrom(Map infos, String prefix, boolean isBusiness)
+   private static TelephoneNum createTelephoneNumFrom(Map infos, TelecomType type, boolean isBusiness)
    {
-      String key = getHomeOrBusinessPrefix(isBusiness) + prefix;
-      return new TelephoneNum((String)infos.get(key + P3PConstants.INTCODE),
-         (String)infos.get(key + P3PConstants.LOCCODE), (String)infos.get(key + P3PConstants.NUMBER),
-         (String)infos.get(key + P3PConstants.EXT), (String)infos.get(key + P3PConstants.COMMENT), null);
+      return new TelephoneNum(
+         (String)infos.get(getTelecomInfoKey(type, TelecomInfo.INTCODE, isBusiness)),
+         (String)infos.get(getTelecomInfoKey(type, TelecomInfo.LOCCODE, isBusiness)),
+         (String)infos.get(getTelecomInfoKey(type, TelecomInfo.NUMBER, isBusiness)),
+         (String)infos.get(getTelecomInfoKey(type, TelecomInfo.EXT, isBusiness)),
+         (String)infos.get(getTelecomInfoKey(type, TelecomInfo.COMMENT, isBusiness)), null);
    }
 
-   private static String getHomeOrBusinessPrefix(boolean isBusiness)
-   {
-      return isBusiness ? P3PConstants.INFO_USER_BUSINESS_PREFIX : P3PConstants.INFO_USER_HOME_PREFIX;
-   }
-
    /**
     * Builds a Portal {@link org.jboss.portal.portlet.spi.UserContext} from a WSRP {@link
     * org.jboss.portal.wsrp.core.UserContext}.
@@ -167,20 +162,20 @@
                Calendar bdate = profile.getBdate();
                if (bdate != null)
                {
-                  infos.put(P3PConstants.INFO_USER_BDATE, SimpleTypeBindings.marshalDateTime(bdate));
+                  infos.put(INFO_USER_BDATE, SimpleTypeBindings.marshalDateTime(bdate));
                }
 
-               infos.put(P3PConstants.INFO_USER_GENDER, profile.getGender());
+               infos.put(INFO_USER_GENDER, profile.getGender());
 
                PersonName name = profile.getName();
                if (name != null)
                {
-                  infos.put(P3PConstants.INFO_USER_NAME_FAMILY, name.getFamily());
-                  infos.put(P3PConstants.INFO_USER_NAME_GIVEN, name.getGiven());
-                  infos.put(P3PConstants.INFO_USER_NAME_MIDDLE, name.getMiddle());
-                  infos.put(P3PConstants.INFO_USER_NAME_NICKNAME, name.getNickname());
-                  infos.put(P3PConstants.INFO_USER_NAME_PREFIX, name.getPrefix());
-                  infos.put(P3PConstants.INFO_USER_NAME_SUFFIX, name.getSuffix());
+                  infos.put(INFO_USER_NAME_FAMILY, name.getFamily());
+                  infos.put(INFO_USER_NAME_GIVEN, name.getGiven());
+                  infos.put(INFO_USER_NAME_MIDDLE, name.getMiddle());
+                  infos.put(INFO_USER_NAME_NICKNAME, name.getNickname());
+                  infos.put(INFO_USER_NAME_PREFIX, name.getPrefix());
+                  infos.put(INFO_USER_NAME_SUFFIX, name.getSuffix());
                }
 
                populateContactInfo(profile.getBusinessInfo(), true);
@@ -190,9 +185,9 @@
                EmployerInfo employerInfo = profile.getEmployerInfo();
                if (employerInfo != null)
                {
-                  infos.put(P3PConstants.INFO_USER_DEPARTMENT, employerInfo.getDepartment());
-                  infos.put(P3PConstants.INFO_USER_EMPLOYER, employerInfo.getEmployer());
-                  infos.put(P3PConstants.INFO_USER_JOB_TITLE, employerInfo.getJobtitle());
+                  infos.put(INFO_USER_DEPARTMENT, employerInfo.getDepartment());
+                  infos.put(INFO_USER_EMPLOYER, employerInfo.getEmployer());
+                  infos.put(INFO_USER_JOB_TITLE, employerInfo.getJobtitle());
                }
             }
 
@@ -223,48 +218,45 @@
       {
          if (contact != null)
          {
-            String key = getHomeOrBusinessPrefix(isBusiness);
-
             Online online = contact.getOnline();
             if (online != null)
             {
-               infos.put(key + P3PConstants.ONLINE_EMAIL, online.getEmail());
-               infos.put(key + P3PConstants.ONLINE_URI, online.getUri());
+               infos.put(getOnlineUserInfoKey(OnlineInfo.EMAIL, isBusiness), online.getEmail());
+               infos.put(getOnlineUserInfoKey(OnlineInfo.URI, isBusiness), online.getUri());
             }
 
             Postal postal = contact.getPostal();
             if (postal != null)
             {
-               infos.put(key + P3PConstants.POSTAL_CITY, postal.getCity());
-               infos.put(key + P3PConstants.POSTAL_COUNTRY, postal.getCountry());
-               infos.put(key + P3PConstants.POSTAL_NAME, postal.getName());
-               infos.put(key + P3PConstants.POSTAL_ORGANIZATION, postal.getOrganization());
-               infos.put(key + P3PConstants.POSTAL_POSTALCODE, postal.getPostalcode());
-               infos.put(key + P3PConstants.POSTAL_STATEPROV, postal.getStateprov());
-               infos.put(key + P3PConstants.POSTAL_STREET, postal.getStreet());
+               infos.put(getPostalUserInfoKey(PostalInfo.NAME, isBusiness), postal.getName());
+               infos.put(getPostalUserInfoKey(PostalInfo.STREET, isBusiness), postal.getStreet());
+               infos.put(getPostalUserInfoKey(PostalInfo.CITY, isBusiness), postal.getCity());
+               infos.put(getPostalUserInfoKey(PostalInfo.STATEPROV, isBusiness), postal.getStateprov());
+               infos.put(getPostalUserInfoKey(PostalInfo.POSTALCODE, isBusiness), postal.getPostalcode());
+               infos.put(getPostalUserInfoKey(PostalInfo.COUNTRY, isBusiness), postal.getCountry());
+               infos.put(getPostalUserInfoKey(PostalInfo.ORGANIZATION, isBusiness), postal.getOrganization());
             }
 
             Telecom telecom = contact.getTelecom();
             if (telecom != null)
             {
-               populateTelephoneInfo(telecom.getFax(), P3PConstants.TELECOM_FAX, isBusiness);
-               populateTelephoneInfo(telecom.getMobile(), P3PConstants.TELECOM_MOBILE, isBusiness);
-               populateTelephoneInfo(telecom.getPager(), P3PConstants.TELECOM_PAGER, isBusiness);
-               populateTelephoneInfo(telecom.getTelephone(), P3PConstants.TELECOM_TELEPHONE, isBusiness);
+               populateTelephoneInfo(telecom.getFax(), TelecomType.FAX, isBusiness);
+               populateTelephoneInfo(telecom.getMobile(), TelecomType.MOBILE, isBusiness);
+               populateTelephoneInfo(telecom.getPager(), TelecomType.PAGER, isBusiness);
+               populateTelephoneInfo(telecom.getTelephone(), TelecomType.TELEPHONE, isBusiness);
             }
          }
       }
 
-      private void populateTelephoneInfo(TelephoneNum telephoneNum, String prefix, boolean isBusiness)
+      private void populateTelephoneInfo(TelephoneNum telephoneNum, TelecomType type, boolean isBusiness)
       {
          if (telephoneNum != null)
          {
-            String key = getHomeOrBusinessPrefix(isBusiness) + prefix;
-            infos.put(key + P3PConstants.COMMENT, telephoneNum.getComment());
-            infos.put(key + P3PConstants.EXT, telephoneNum.getExt());
-            infos.put(key + P3PConstants.INTCODE, telephoneNum.getIntcode());
-            infos.put(key + P3PConstants.LOCCODE, telephoneNum.getLoccode());
-            infos.put(key + P3PConstants.NUMBER, telephoneNum.getNumber());
+            infos.put(getTelecomInfoKey(type, TelecomInfo.INTCODE, isBusiness), telephoneNum.getIntcode());
+            infos.put(getTelecomInfoKey(type, TelecomInfo.LOCCODE, isBusiness), telephoneNum.getLoccode());
+            infos.put(getTelecomInfoKey(type, TelecomInfo.NUMBER, isBusiness), telephoneNum.getNumber());
+            infos.put(getTelecomInfoKey(type, TelecomInfo.EXT, isBusiness), telephoneNum.getExt());
+            infos.put(getTelecomInfoKey(type, TelecomInfo.COMMENT, isBusiness), telephoneNum.getComment());
          }
       }
 




More information about the portal-commits mailing list