private ResourceRecord getRecord( Attributes attrs, Name relative ) throws NamingException
{
String SOA_MINIMUM = "86400";
String SOA_CLASS = "IN";
ResourceRecordModifier modifier = new ResourceRecordModifier();
Attribute attr;
// if no name, transform rdn
attr = attrs.get( DnsAttribute.NAME );
if ( attr != null )
{
modifier.setDnsName( ( String ) attr.get() );
}
else
{
relative = getDomainComponents( relative );
String dnsName;
dnsName = transformDistinguishedName( relative.toString() );
modifier.setDnsName( dnsName );
}
// type is implicit in objectclass
attr = attrs.get( DnsAttribute.TYPE );
if ( attr != null )
{
modifier.setDnsType( RecordType.valueOf( ( String ) attr.get() ) );
}
else
{
modifier.setDnsType( getType( attrs.get( SchemaConstants.OBJECT_CLASS_AT ) ) );
}
// class defaults to SOA CLASS
String dnsClass = ( attr = attrs.get( DnsAttribute.CLASS ) ) != null ? ( String ) attr.get() : SOA_CLASS;
modifier.setDnsClass( RecordClass.valueOf( dnsClass ) );
// ttl defaults to SOA MINIMUM
String dnsTtl = ( attr = attrs.get( DnsAttribute.TTL ) ) != null ? ( String ) attr.get() : SOA_MINIMUM;
modifier.setDnsTtl( Integer.parseInt( dnsTtl ) );
NamingEnumeration<String> ids = attrs.getIDs();
while ( ids.hasMore() )
{
String id = ids.next();
modifier.put( id, ( String ) attrs.get( id ).get() );
}
return modifier.getEntry();
}