View Javadoc

1   /*
2    * Copyright 2010 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kim.ldap;
17  
18  import org.springframework.ldap.core.DirContextOperations;
19  import org.springframework.ldap.core.support.AbstractContextMapper;
20  
21  import org.kuali.rice.kim.api.identity.Type;
22  import org.kuali.rice.kim.api.identity.email.EntityEmail;
23  import org.kuali.rice.kim.util.Constants;
24  
25  /**
26   * 
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  public class EntityEmailMapper extends AbstractContextMapper {
30      private Constants constants;
31      
32      public EntityEmail.Builder mapFromContext(DirContextOperations context) {
33          return (EntityEmail.Builder) doMapFromContext(context);
34      }
35  
36      public Object doMapFromContext(DirContextOperations context) {        
37          return doMapFromContext(context, true);
38      }
39  
40      public Object doMapFromContext(DirContextOperations context, boolean isdefault) {        
41          final EntityEmail.Builder retval = EntityEmail.Builder.create();
42          final String emailAddress = context.getStringAttribute(getConstants().getEmployeeMailLdapProperty());
43          retval.setEmailAddress(emailAddress);
44          retval.setEmailType(Type.Builder.create("WORK"));
45          retval.setDefaultValue(isdefault);
46          retval.setActive(true);
47          return retval;
48      }
49      
50      /**
51       * Gets the value of constants
52       *
53       * @return the value of constants
54       */
55      public final Constants getConstants() {
56          return this.constants;
57      }
58  
59      /**
60       * Sets the value of constants
61       *
62       * @param argConstants Value to assign to this.constants
63       */
64      public final void setConstants(final Constants argConstants) {
65          this.constants = argConstants;
66      }
67  }