1 16 package org.apache.cocoon.portal.wsrp.consumer; 17 18 import org.apache.avalon.framework.thread.ThreadSafe; 19 import org.apache.wsrp4j.consumer.util.ConsumerConstants; 20 import org.apache.wsrp4j.util.Constants; 21 22 import oasis.names.tc.wsrp.v1.types.Contact; 23 import oasis.names.tc.wsrp.v1.types.EmployerInfo; 24 import oasis.names.tc.wsrp.v1.types.PersonName; 25 import oasis.names.tc.wsrp.v1.types.UserProfile; 26 27 36 public class UserContextProviderImpl implements UserContextProvider, ThreadSafe { 37 38 41 public UserContextExtension createUserContext(String userId) { 42 final UserContextExtension userContext = new UserContextExtension(); 43 44 userContext.setUserContextKey(userId); 45 46 UserProfile userProfile = new UserProfile(); 47 this.fill(userProfile, userContext); 48 49 PersonName personName = new PersonName(); 50 this.fill(personName, userContext); 51 52 userProfile.setName(personName); 53 userContext.setProfile(userProfile); 54 55 userContext.setUserAuthentication(ConsumerConstants.PASSWORD); 56 this.setSupportedLocales(userContext); 57 return userContext; 58 } 59 60 66 protected void setSupportedLocales(UserContextExtension userContext) { 67 String [] supportedLocales = new String [2]; 68 supportedLocales[0] = Constants.LOCALE_EN_US; 69 supportedLocales[1] = Constants.LOCALE_DE_DE; 70 userContext.setSupportedLocales(supportedLocales); 71 } 72 73 80 protected void fill(UserProfile profile, UserContextExtension context) { 81 profile.setEmployerInfo(new EmployerInfo()); 82 profile.setHomeInfo(new Contact()); 83 profile.setBusinessInfo(new Contact()); 84 } 85 86 93 protected void fill(PersonName name, UserContextExtension context) { 94 name.setNickname(context.getUserContextKey()); 95 } 96 } 97 | Popular Tags |