directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r289962 [3/3] - in /directory/protocol-providers/dns/trunk/src: java/org/apache/dns/io/ java/org/apache/dns/io/decoder/ java/org/apache/dns/io/encoder/ java/org/apache/dns/messages/ java/org/apache/dns/protocol/ java/org/apache/dns/service/...
Date Sun, 18 Sep 2005 19:48:12 GMT
Modified: directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/operations/GetRecord.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/operations/GetRecord.java?rev=289962&r1=289961&r2=289962&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/operations/GetRecord.java
(original)
+++ directory/protocol-providers/dns/trunk/src/java/org/apache/dns/store/operations/GetRecord.java
Sun Sep 18 12:47:47 2005
@@ -25,11 +25,13 @@
 import javax.naming.directory.DirContext;
 import javax.naming.directory.SearchResult;
 
-import org.apache.dns.records.QuestionRecord;
+import org.apache.dns.messages.QuestionRecord;
+import org.apache.dns.messages.RecordClass;
+import org.apache.dns.messages.RecordType;
+import org.apache.dns.messages.ResourceRecord;
+import org.apache.dns.messages.ResourceRecordModifier;
 import org.apache.dns.store.ContextOperation;
 import org.apache.dns.store.DnsAttribute;
-import org.apache.dns.store.RecordStoreEntry;
-import org.apache.dns.store.RecordStoreEntryModifier;
 
 /**
  * Encapsulates the action of looking up a Resource Record from an embedded JNDI provider.
@@ -54,50 +56,38 @@
      * Note that the base is a relative path from the exiting context.
      * It is not a DN.
      */
-    public Object execute( DirContext ctx, Name base )
+    public Object execute( DirContext ctx, Name base ) throws Exception
     {
         if ( question == null )
         {
             return null;
         }
 
-        String[] attrIDs = { DnsAttribute.CLASS, DnsAttribute.TTL,
-                DnsAttribute.NAME, DnsAttribute.ZONE_NAME, DnsAttribute.IP_ADDRESS };
-
         Attributes matchAttrs = new BasicAttributes( false ); // case-sensitive
 
         matchAttrs.put( new BasicAttribute( DnsAttribute.NAME, question.getDomainName() )
);
+        matchAttrs.put( new BasicAttribute( DnsAttribute.TYPE, question.getRecordType().getCode()
) );
+        matchAttrs.put( new BasicAttribute( DnsAttribute.CLASS, question.getRecordClass().getCode()
) );
+
+        ResourceRecord record = null;
 
-        RecordStoreEntry entry = null;
+        NamingEnumeration answer = ctx.search( base, matchAttrs );
 
-        try
+        if ( answer.hasMore() )
         {
-            // Search for objects that have those matching attributes
+            SearchResult result = (SearchResult) answer.next();
 
-            NamingEnumeration answer = ctx.search( base, matchAttrs, attrIDs );
+            Attributes attrs = result.getAttributes();
 
-            if ( answer.hasMore() )
+            if ( attrs == null )
             {
-                SearchResult result = (SearchResult) answer.next();
-
-                Attributes attrs = result.getAttributes();
-
-                if ( attrs == null )
-                {
-                    return null;
-                }
-
-                entry = getEntry( attrs );
+                return null;
             }
-        }
-        catch ( NamingException e )
-        {
-            e.printStackTrace();
 
-            return null;
+            record = getRecord( attrs );
         }
 
-        return entry;
+        return record;
     }
 
     /**
@@ -107,21 +97,27 @@
      * @return the entry for the question
      * @throws NamingException if there are any access problems
      */
-    private RecordStoreEntry getEntry( Attributes attrs ) throws NamingException
+    private ResourceRecord getRecord( Attributes attrs ) throws NamingException
     {
-        RecordStoreEntryModifier modifier = new RecordStoreEntryModifier();
+        ResourceRecordModifier modifier = new ResourceRecordModifier();
 
+        String dnsName = (String) attrs.get( DnsAttribute.NAME ).get();
+        String dnsType = (String) attrs.get( DnsAttribute.TYPE ).get();
         String dnsClass = (String) attrs.get( DnsAttribute.CLASS ).get();
         String dnsTtl = (String) attrs.get( DnsAttribute.TTL ).get();
-        String dnsZoneName = (String) attrs.get( DnsAttribute.ZONE_NAME ).get();
-        String dnsName = (String) attrs.get( DnsAttribute.NAME ).get();
-        String dnsIpAddress = (String) attrs.get( DnsAttribute.IP_ADDRESS ).get();
 
-        modifier.setDnsClass( dnsClass );
-        modifier.setDnsTtl( dnsTtl );
-        modifier.setDnsZoneName( dnsZoneName );
         modifier.setDnsName( dnsName );
-        modifier.setDnsIpAddress( dnsIpAddress );
+        modifier.setDnsType( RecordType.getTypeByName( dnsType ) );
+        modifier.setDnsClass( RecordClass.getTypeByName( dnsClass ) );
+        modifier.setDnsTtl( Integer.parseInt( dnsTtl ) );
+
+        NamingEnumeration ids = attrs.getIDs();
+
+        while ( ids.hasMore() )
+        {
+            String id = (String) ids.next();
+            modifier.put( id, (String) attrs.get( id ).get() );
+        }
 
         return modifier.getEntry();
     }

Modified: directory/protocol-providers/dns/trunk/src/test/org/apache/dns/AbstractDnsTestCase.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/test/org/apache/dns/AbstractDnsTestCase.java?rev=289962&r1=289961&r2=289962&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/test/org/apache/dns/AbstractDnsTestCase.java
(original)
+++ directory/protocol-providers/dns/trunk/src/test/org/apache/dns/AbstractDnsTestCase.java
Sun Sep 18 12:47:47 2005
@@ -19,13 +19,13 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.nio.ByteBuffer;
 
 import junit.framework.TestCase;
 
 import org.apache.dns.messages.DnsMessage;
-import org.apache.dns.records.QuestionRecord;
-import org.apache.dns.records.ResourceRecord;
+import org.apache.dns.messages.QuestionRecords;
+import org.apache.dns.messages.ResourceRecords;
+import org.apache.mina.common.ByteBuffer;
 
 public abstract class AbstractDnsTestCase extends TestCase
 {
@@ -42,33 +42,17 @@
         System.out.println( message.isRecursionAvailable() );
         System.out.println( message.getResponseCode() );
 
-        QuestionRecord[] questions = message.getQuestionRecords();
-        printQuestionRecords( questions );
+        QuestionRecords questions = message.getQuestionRecords();
+        System.out.println( questions );
 
-        ResourceRecord[] records = message.getAnswerRecords();
-        printResourceRecords( records );
+        ResourceRecords records = message.getAnswerRecords();
+        System.out.println( records );
 
         records = message.getAuthorityRecords();
-        printResourceRecords( records );
+        System.out.println( records );
 
         records = message.getAdditionalRecords();
-        printResourceRecords( records );
-    }
-
-    protected void printQuestionRecords( QuestionRecord[] records )
-    {
-        for ( int ii = 0; ii < records.length; ii++ )
-        {
-            System.out.println( records[ ii ] );
-        }
-    }
-
-    protected void printResourceRecords( ResourceRecord[] records )
-    {
-        for ( int ii = 0; ii < records.length; ii++ )
-        {
-            System.out.println( records[ ii ] );
-        }
+        System.out.println( records );
     }
 
     protected ByteBuffer getByteBufferFromFile( String file ) throws IOException

Copied: directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DNS-QUERY.pdu
(from r289702, directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DNS-QUERY.pdu)
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DNS-QUERY.pdu?p2=directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DNS-QUERY.pdu&p1=directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DNS-QUERY.pdu&r1=289702&r2=289962&rev=289962&view=diff
==============================================================================
Binary files - no diff available.

Copied: directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DNS-RESPONSE.pdu
(from r289702, directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DNS-RESPONSE.pdu)
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DNS-RESPONSE.pdu?p2=directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DNS-RESPONSE.pdu&p1=directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DNS-RESPONSE.pdu&r1=289702&r2=289962&rev=289962&view=diff
==============================================================================
Binary files - no diff available.

Copied: directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DNS-TRAFFIC.libpcap
(from r289702, directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DNS-TRAFFIC.libpcap)
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DNS-TRAFFIC.libpcap?p2=directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DNS-TRAFFIC.libpcap&p1=directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DNS-TRAFFIC.libpcap&r1=289702&r2=289962&rev=289962&view=diff
==============================================================================
Binary files - no diff available.

Copied: directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DnsMessageDecoderTest.java
(from r289702, directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DnsMessageDecoderTest.java)
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DnsMessageDecoderTest.java?p2=directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DnsMessageDecoderTest.java&p1=directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DnsMessageDecoderTest.java&r1=289702&r2=289962&rev=289962&view=diff
==============================================================================
--- directory/protocol-providers/dns/trunk/src/test/org/apache/dns/DnsMessageDecoderTest.java
(original)
+++ directory/protocol-providers/dns/trunk/src/test/org/apache/dns/protocol/DnsMessageDecoderTest.java
Sun Sep 18 12:47:47 2005
@@ -15,12 +15,11 @@
  *
  */
 
-package org.apache.dns;
+package org.apache.dns.protocol;
 
-import java.nio.ByteBuffer;
-
-import org.apache.dns.io.DnsMessageDecoder;
+import org.apache.dns.AbstractDnsTestCase;
 import org.apache.dns.messages.DnsMessage;
+import org.apache.mina.common.ByteBuffer;
 
 public class DnsMessageDecoderTest extends AbstractDnsTestCase
 {
@@ -30,7 +29,7 @@
     {
         requestByteBuffer = getByteBufferFromFile( "DNS-QUERY.pdu" );
 
-        DnsMessageDecoder decoder = new DnsMessageDecoder();
+        DnsDecoder decoder = new DnsDecoder();
         DnsMessage dnsRequest = decoder.decode( requestByteBuffer );
 
         print( dnsRequest );
@@ -40,7 +39,7 @@
     {
         requestByteBuffer = getByteBufferFromFile( "DNS-RESPONSE.pdu" );
 
-        DnsMessageDecoder decoder = new DnsMessageDecoder();
+        DnsDecoder decoder = new DnsDecoder();
         DnsMessage dnsRequest = decoder.decode( requestByteBuffer );
 
         print( dnsRequest );



Mime
View raw message