You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2005/03/01 09:00:54 UTC
svn commit: r155760 - in incubator/directory/protocols/dns/trunk: ./ core/
core/src/java/org/apache/dns/store/
core/src/java/org/apache/dns/store/DnsRecordStateFactory.java
Author: akarasulu
Date: Tue Mar 1 00:00:52 2005
New Revision: 155760
URL: http://svn.apache.org/viewcvs?view=rev&rev=155760
Log:
changes ...
o added start of a state factory for use in building a store
o not used and stoped until getters on records are enabled
Added:
incubator/directory/protocols/dns/trunk/core/src/java/org/apache/dns/store/
incubator/directory/protocols/dns/trunk/core/src/java/org/apache/dns/store/DnsRecordStateFactory.java
Modified:
incubator/directory/protocols/dns/trunk/ (props changed)
incubator/directory/protocols/dns/trunk/core/ (props changed)
Propchange: incubator/directory/protocols/dns/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Mar 1 00:00:52 2005
@@ -4,3 +4,6 @@
classes
.classpath
.profile
+*.ipr
+*.iws
+*.log
Propchange: incubator/directory/protocols/dns/trunk/core/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Mar 1 00:00:52 2005
@@ -4,3 +4,5 @@
classes
.classpath
.project
+*.iml
+*.log
Added: incubator/directory/protocols/dns/trunk/core/src/java/org/apache/dns/store/DnsRecordStateFactory.java
URL: http://svn.apache.org/viewcvs/incubator/directory/protocols/dns/trunk/core/src/java/org/apache/dns/store/DnsRecordStateFactory.java?view=auto&rev=155760
==============================================================================
--- incubator/directory/protocols/dns/trunk/core/src/java/org/apache/dns/store/DnsRecordStateFactory.java (added)
+++ incubator/directory/protocols/dns/trunk/core/src/java/org/apache/dns/store/DnsRecordStateFactory.java Tue Mar 1 00:00:52 2005
@@ -0,0 +1,112 @@
+package org.apache.dns.store;
+
+import org.apache.dns.records.ResourceRecord;
+import org.apache.dns.records.Record;
+import org.apache.dns.records.standard.PointerRecord;
+import org.apache.dns.records.standard.NameServerRecord;
+import org.apache.dns.records.standard.StartOfAuthorityRecord;
+import org.apache.dns.records.internet.AddressRecord;
+
+import javax.naming.spi.DirStateFactory;
+import javax.naming.Name;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.BasicAttribute;
+import java.util.Hashtable;
+
+
+/**
+ * A state factory which produces the state to be stored in an entry of a DNS record
+ * of any type.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DnsRecordStateFactory implements DirStateFactory
+{
+ public Result getStateToBind( Object obj, Name name, Context nameCtx, Hashtable environment, Attributes inAttrs ) throws NamingException
+ {
+ ResourceRecord rec = ( ResourceRecord ) obj;
+
+ Attributes outAttrs = new BasicAttributes();
+
+ if ( inAttrs != null )
+ {
+ NamingEnumeration list = inAttrs.getIDs();
+
+ while ( list.hasMore() )
+ {
+ String id = ( String ) list.next();
+
+ outAttrs.put( ( Attribute ) inAttrs.get( id ).clone() );
+ }
+ }
+
+ // process the objectClass attribute
+
+ Attribute attr = outAttrs.get( "objectClass" );
+
+ if ( attr == null )
+ {
+ attr = new BasicAttribute( "objectClass" );
+
+ outAttrs.put( attr );
+ }
+
+ if ( ! attr.contains( "top" ) )
+ {
+ attr.add( "top" );
+ }
+
+ // add the generic stuff that is part of every record if it does not exist
+
+ if ( outAttrs.get( "apacheDNSTTL" ) == null )
+ {
+ // cap this off after the getters are setup on the objects
+// outAttrs.put( "apacheDNSTTL", rec. );
+ }
+
+ if ( rec instanceof AddressRecord )
+ {
+ if ( ! attr.contains( "apacheAddressRecord" ) )
+ {
+ attr.add( "apacheAddressRecord" );
+ }
+ }
+ else if ( rec instanceof PointerRecord )
+ {
+ if ( ! attr.contains( "apachePointerRecord" ) )
+ {
+ attr.add( "apachePointerRecord" );
+ }
+ }
+ else if ( rec instanceof NameServerRecord )
+ {
+ if ( ! attr.contains( "apacheNameServerRecord" ) )
+ {
+ attr.add( "apacheNameServerRecord" );
+ }
+ }
+ else if ( rec instanceof StartOfAuthorityRecord )
+ {
+ if ( ! attr.contains( "apacheStartOfAuthorityRecord" ) )
+ {
+ attr.add( "apacheStartOfAuthorityRecord" );
+ }
+ }
+
+ Result r = new Result( obj, outAttrs );
+
+ return r;
+ }
+
+
+ public Object getStateToBind( Object obj, Name name, Context nameCtx, Hashtable environment ) throws NamingException
+ {
+ throw new UnsupportedOperationException( "Structural objectClass needed for safehausProfile within additional attributes!" );
+ }
+}