* @return
* the corresponding {@link LdapServer}
*/
private static LdapServer readLdapServer( Element element )
{
LdapServer server = new LdapServer();
// ID
Attribute idAttribute = element.attribute( ID_ATTRIBUTE );
if ( idAttribute != null )
{
server.setId( idAttribute.getValue() );
}
// Name
Attribute nameAttribute = element.attribute( NAME_ATTRIBUTE );
if ( nameAttribute != null )
{
server.setName( nameAttribute.getValue() );
}
// Adapter ID
Attribute adapterIdAttribute = element.attribute( ADAPTER_ID_ATTRIBUTE );
if ( adapterIdAttribute != null )
{
// Getting the id
String adapterId = adapterIdAttribute.getValue();
// Looking for the correct LDAP Server Adapter Extension object
LdapServerAdapterExtension ldapServerAdapterExtension = LdapServerAdapterExtensionsManager.getDefault()
.getLdapServerAdapterExtensionById( adapterId );
if ( ldapServerAdapterExtension != null )
{
// The Adapter Extension has been found
// Assigning it to the server
server.setLdapServerAdapterExtension( ldapServerAdapterExtension );
}
else
{
// The Adapter Extension has not been found
// Creating an "unknown" Adapter Extension
UnknownLdapServerAdapterExtension unknownLdapServerAdapterExtension = new UnknownLdapServerAdapterExtension();
// Adapter Id
unknownLdapServerAdapterExtension.setId( adapterId );
// Adapter Name
Attribute adapterNameAttribute = element.attribute( ADAPTER_NAME_ATTRIBUTE );
if ( adapterNameAttribute != null )
{
unknownLdapServerAdapterExtension.setName( adapterNameAttribute.getValue() );
}
// Adapter Vendor
Attribute adapterVendorAttribute = element.attribute( ADAPTER_VENDOR_ATTRIBUTE );
if ( adapterVendorAttribute != null )
{
unknownLdapServerAdapterExtension.setVendor( adapterVendorAttribute.getValue() );
}
// Adapter Version
Attribute adapterVersionAttribute = element.attribute( ADAPTER_VERSION_ATTRIBUTE );
if ( adapterVersionAttribute != null )
{
unknownLdapServerAdapterExtension.setVersion( adapterVersionAttribute.getValue() );
}
// Assigning the "unknown" Adapter Extension to the server
server.setLdapServerAdapterExtension( unknownLdapServerAdapterExtension );
}
}
else
{
// TODO No Adapter ID, throw an error ?