| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kim.ldap; |
| 17 | |
|
| 18 | |
import java.util.ArrayList; |
| 19 | |
import java.util.List; |
| 20 | |
|
| 21 | |
import org.springframework.ldap.core.ContextMapper; |
| 22 | |
import org.springframework.ldap.core.DirContextOperations; |
| 23 | |
import org.springframework.ldap.core.support.AbstractContextMapper; |
| 24 | |
|
| 25 | |
import org.kuali.rice.kim.api.identity.principal.Principal; |
| 26 | |
import org.kuali.rice.kim.api.identity.address.EntityAddress; |
| 27 | |
import org.kuali.rice.kim.api.identity.email.EntityEmail; |
| 28 | |
import org.kuali.rice.kim.api.identity.type.EntityTypeContactInfo; |
| 29 | |
import org.kuali.rice.kim.api.identity.phone.EntityPhone; |
| 30 | |
import org.kuali.rice.kim.util.Constants; |
| 31 | |
|
| 32 | |
import static org.kuali.rice.core.util.BufferedLogger.*; |
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | 0 | public class EntityTypeContactInfoMapper extends AbstractContextMapper { |
| 39 | |
private Constants constants; |
| 40 | |
|
| 41 | |
private EntityAddressMapper addressMapper; |
| 42 | |
private EntityPhoneMapper phoneMapper; |
| 43 | |
private EntityEmailMapper emailMapper;; |
| 44 | |
|
| 45 | |
|
| 46 | |
public Object doMapFromContext(DirContextOperations context) { |
| 47 | 0 | final String entityId = (String) context.getStringAttribute(getConstants().getKimLdapIdProperty()); |
| 48 | 0 | final String entityTypeCode = (String ) getConstants().getPersonEntityTypeCode(); |
| 49 | |
|
| 50 | 0 | final EntityTypeContactInfo.Builder builder = EntityTypeContactInfo.Builder.create(entityId, entityTypeCode); |
| 51 | 0 | final EntityAddress.Builder address = getAddressMapper().mapFromContext(context); |
| 52 | 0 | final List<EntityAddress.Builder> addresses = new ArrayList<EntityAddress.Builder>(); |
| 53 | 0 | addresses.add(address); |
| 54 | 0 | final List<EntityEmail.Builder> email = new ArrayList<EntityEmail.Builder>(); |
| 55 | 0 | email.add(getEmailMapper().mapFromContext(context)); |
| 56 | 0 | final List<EntityPhone.Builder> phone = new ArrayList<EntityPhone.Builder>(); |
| 57 | 0 | phone.add(getPhoneMapper().mapFromContext(context)); |
| 58 | 0 | builder.setAddresses(addresses); |
| 59 | 0 | builder.setEmailAddresses(email); |
| 60 | 0 | builder.setPhoneNumbers(phone); |
| 61 | 0 | debug("Created Entity Type with code ", builder.getEntityTypeCode()); |
| 62 | |
|
| 63 | 0 | return builder; |
| 64 | |
} |
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
public final Constants getConstants() { |
| 72 | 0 | return this.constants; |
| 73 | |
} |
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
public final void setConstants(final Constants argConstants) { |
| 81 | 0 | this.constants = argConstants; |
| 82 | 0 | } |
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
public final EntityAddressMapper getAddressMapper() { |
| 90 | 0 | return this.addressMapper; |
| 91 | |
} |
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
public final void setAddressMapper(final EntityAddressMapper argAddressMapper) { |
| 99 | 0 | this.addressMapper = argAddressMapper; |
| 100 | 0 | } |
| 101 | |
|
| 102 | |
|
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
public final EntityPhoneMapper getPhoneMapper() { |
| 108 | 0 | return this.phoneMapper; |
| 109 | |
} |
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
|
| 115 | |
|
| 116 | |
public final void setPhoneMapper(final EntityPhoneMapper argPhoneMapper) { |
| 117 | 0 | this.phoneMapper = argPhoneMapper; |
| 118 | 0 | } |
| 119 | |
|
| 120 | |
|
| 121 | |
|
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
public final EntityEmailMapper getEmailMapper() { |
| 126 | 0 | return this.emailMapper; |
| 127 | |
} |
| 128 | |
|
| 129 | |
|
| 130 | |
|
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
public final void setEmailMapper(final EntityEmailMapper argEmailMapper) { |
| 135 | 0 | this.emailMapper = argEmailMapper; |
| 136 | 0 | } |
| 137 | |
} |