Element contextEntryElement = element.element( ServerXmlIOV152.ELEMENT_CONTEXT_ENTRY );
if ( contextEntryElement == null )
{
// If the 'contextEntry' element does not exists,
// we throw an exception
throw new ServerXmlIOException( Messages.getString( "ServerXmlIOV152.ErrorContextEntry" ) ); //$NON-NLS-1$
}
else
{
// Getting the id of the linked bean
String linkedBeanId = contextEntryElement.getText().trim();
// Removing the '#' character at the beginning of the value
linkedBeanId = linkedBeanId.substring( 1, linkedBeanId.length() );
// Creating a 'foundBean' flag to check if we've found the associated bean
boolean foundBean = false;
// Looping on all 'bean' tags
for ( Iterator<?> i = element.getDocument().getRootElement().elementIterator( ServerXmlIOV152.ELEMENT_BEAN ); i
.hasNext(); )
{
// Getting the bean element
Element beanElement = ( Element ) i.next();
// Getting the id attribute
org.dom4j.Attribute idAttribute = beanElement.attribute( ServerXmlIOV152.ATTRIBUTE_ID );
if ( idAttribute != null )
{
// Checking if we've found the correct bean
if ( linkedBeanId.equalsIgnoreCase( idAttribute.getValue() ) )
{
// Setting the 'foundBean' flag to true
foundBean = true;
// Creating a 'foundProperty' flag to check if we've found the associated bean
boolean foundProperty = false;
// Looping on all 'property' tags
for ( Iterator<?> i2 = beanElement.elementIterator( ServerXmlIOV152.ELEMENT_PROPERTY ); i2
.hasNext(); )
{
// Getting the property element
Element propertyElement = ( Element ) i2.next();
// Getting the name attribute
org.dom4j.Attribute nameAttribute = propertyElement
.attribute( ServerXmlIOV152.ATTRIBUTE_NAME );
if ( nameAttribute != null )
{
if ( nameAttribute.getValue().equalsIgnoreCase( ServerXmlIOV152.VALUE_ARGUMENTS ) )
{
// Setting the 'foundProperty' flag to true
foundProperty = true;
// Getting the list element
Element listElement = propertyElement.element( ServerXmlIOV152.ELEMENT_LIST );
if ( listElement != null )
{
// Looping on all 'value' tags
for ( Iterator<?> i3 = listElement
.elementIterator( ServerXmlIOV152.ELEMENT_VALUE ); i3.hasNext(); )
{
// Getting the value element
Element valueElement = ( Element ) i3.next();
// Getting the text value
String value = valueElement.getText().trim();
// We are looking for LDIF, so let's look if the text value
// contains any ':'
if ( value.indexOf( ':' ) != -1 )
{
// Returning the LDIF converted to JNDI Attributes
return readContextEntry( valueElement.getText().trim() );
}
}
}
}
}
}
// Checking if we have found the associated property
// If not, we throw an error
if ( !foundProperty )
{
// If the correct property element does not exists,
// we throw an exception
throw new ServerXmlIOException( Messages.getString( "ServerXmlIOV152.ErrorArguments" ) ); //$NON-NLS-1$
}
}
}
}
// Checking if we have found the associated bean
// If not, we throw an error
if ( !foundBean )
{
// If the correct bean element does not exists,
// we throw an exception
throw new ServerXmlIOException( NLS.bind(
Messages.getString( "ServerXmlIOV152.ErrorBean" ), new String[] { linkedBeanId } ) ); //$NON-NLS-1$
}
}
return null;