@ SuppressWarnings ( "unchecked" ) private void setPropertyValue ( Entity entity , Attribute attr , String propName , LdapAttribute ldapAttr ) throws WIMException { String dataType = entity . getDataType ( propName ) ; boolean isMany = entity . isMultiValuedProperty ( propName ) ; String syntax = LDAP_ATTR_SYNTAX_STRING ; if ( ldapAttr != null ) { syntax = ldapAttr . getSyntax ( ) ; if ( tc . isEventEnabled ( ) ) { Tr . event ( tc , "ldapAttr " + ldapAttr + " syntax is " + syntax ) ; } } try { if ( isMany ) { for ( NamingEnumeration < ? > enu = attr . getAll ( ) ; enu . hasMoreElements ( ) ; ) { Object ldapValue = enu . nextElement ( ) ; if ( ldapValue != null ) { entity . set ( propName , processPropertyValue ( entity , propName , dataType , syntax , ldapValue ) ) ; } } } else { Object ldapValue = attr . get ( ) ; if ( ldapValue != null ) { entity . set ( propName , processPropertyValue ( entity , propName , dataType , syntax , ldapValue ) ) ; } } } catch ( NamingException e ) { if ( tc . isEventEnabled ( ) ) { Tr . event ( tc , "Unexpected on " + propName + " with dataType " + dataType , e ) ; } String msg = Tr . formatMessage ( tc , WIMMessageKey . NAMING_EXCEPTION , WIMMessageHelper . generateMsgParms ( e . toString ( true ) ) ) ; throw new WIMSystemException ( WIMMessageKey . NAMING_EXCEPTION , msg , e ) ; } catch ( ClassCastException ce ) { if ( tc . isEventEnabled ( ) ) { Tr . event ( tc , "Failed to cast property " + propName + " to " + dataType , ce ) ; } if ( tc . isErrorEnabled ( ) ) Tr . error ( tc , WIMMessageKey . INVALID_PROPERTY_DATA_TYPE , WIMMessageHelper . generateMsgParms ( propName ) ) ; } catch ( ArrayStoreException ae ) { if ( tc . isEventEnabled ( ) ) { Tr . event ( tc , "Unexpected on " + propName + " with dataType " + dataType , ae ) ; } if ( tc . isErrorEnabled ( ) ) Tr . error ( tc , WIMMessageKey . INVALID_PROPERTY_DATA_TYPE , WIMMessageHelper . generateMsgParms ( propName ) ) ; } }
Set the appropriate value for the specified property .