You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2008/10/23 22:34:20 UTC
svn commit: r707469 - in
/directory/sandbox/kayyagari/apacheds-olm/src/main/resources:
AttributeClass.st ObjectClass.st
Author: kayyagari
Date: Thu Oct 23 13:34:20 2008
New Revision: 707469
URL: http://svn.apache.org/viewvc?rev=707469&view=rev
Log:
added support for auxiliary classes
updated the getAttrName method of attributeclass template
Modified:
directory/sandbox/kayyagari/apacheds-olm/src/main/resources/AttributeClass.st
directory/sandbox/kayyagari/apacheds-olm/src/main/resources/ObjectClass.st
Modified: directory/sandbox/kayyagari/apacheds-olm/src/main/resources/AttributeClass.st
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/apacheds-olm/src/main/resources/AttributeClass.st?rev=707469&r1=707468&r2=707469&view=diff
==============================================================================
--- directory/sandbox/kayyagari/apacheds-olm/src/main/resources/AttributeClass.st (original)
+++ directory/sandbox/kayyagari/apacheds-olm/src/main/resources/AttributeClass.st Thu Oct 23 13:34:20 2008
@@ -39,13 +39,19 @@
public static final String OID = "$oid$";
+ public static final String ATTRIBUTE_NAME = "$paramName$";
+
//TODO
// may be here needs a reference to the corresponding object class to apply the changes done to this
// attribute transparently. This reference should be injected at runtime through byte code manipulation
- // TODO this constructor needs to be dynamically injected
public $className$() {}
+ /**
+ *
+ * Creates a new instance of with the MUST fields.
+ *
+ */
public $className$( $argType$ $paramName$ )
{
$if(singleValue)$
@@ -138,7 +144,7 @@
public String getAttrName()
{
- return "$paramName$";
+ return ATTRIBUTE_NAME;
}
Modified: directory/sandbox/kayyagari/apacheds-olm/src/main/resources/ObjectClass.st
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/apacheds-olm/src/main/resources/ObjectClass.st?rev=707469&r1=707468&r2=707469&view=diff
==============================================================================
--- directory/sandbox/kayyagari/apacheds-olm/src/main/resources/ObjectClass.st (original)
+++ directory/sandbox/kayyagari/apacheds-olm/src/main/resources/ObjectClass.st Thu Oct 23 13:34:20 2008
@@ -22,15 +22,29 @@
import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
import java.util.Set;
import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Collections;
public $if(abstract)$ abstract $endif$ class $className$ implements Entry
{
+
$allAttrs: { attr | private $attr.className$ $attr.name$;}; separator="\n\n"$
private String dn;
- private String[] objClassSuperiors = { $superiorClassNames: { s | "$s$"}; separator=", "$ };
+ // contains other entries of type abstract/auxiliary/extensible objectclasses
+ private Set<Entry> additionalEntries;
+
+ // contains the dSAOperation specific attributes
+ private Set<Attribute> opAttributes;
+
+ private static final String[] SUPERIORS = { $superiorClassNames: { s | "$s$"}; separator=", "$ };
+
+ public static final String OID = "$oid$";
+
+ public static final String OBJCLASS_NAME = "$objClassName$";
+
public $className$() { }
$if(mustAttrs)$
@@ -40,7 +54,6 @@
}
$endif$
-
$allAttrs: { attr | public void set$attr.classSimpleName$( $attr.javaType$ $attr.name$ )
{
this.$attr.name$ = new $attr.className$( $attr.name$ );
@@ -56,13 +69,13 @@
public String getName()
{
- return "$objClassName$";
+ return OBJCLASS_NAME;
}
public String getOid()
{
- return "$oid$";
+ return OID;
}
public ObjectClassTypeEnum getType()
@@ -84,6 +97,14 @@
}
}
+ if( opAttributes != null )
+ {
+ for( Attribute attr : opAttributes )
+ {
+ allAttrs.add( attr );
+ }
+ }
+
return allAttrs;
}
@@ -110,4 +131,101 @@
{
return dn;
}
+
+
+ public Entry getEntry( String name )
+ {
+ if( name != null )
+ {
+ if( additionalEntries != null )
+ {
+ for( Entry e : additionalEntries )
+ {
+ if( e.getName().equals( name ) )
+ {
+ return e;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+
+ private void addAttribute( Attribute attr )
+ {
+ if( attr == null || ( ! attr.isNoUserModification() ) )
+ {
+ throw new IllegalArgumentException( "Invalid Attribute, cannot add " + attr );
+ }
+
+ if( opAttributes == null )
+ {
+ opAttributes = new HashSet<Attribute>();
+ }
+
+ opAttributes.add( attr );
+ }
+
+
+ public void addEntry( Entry entry )
+ {
+ if( entry == null )
+ {
+ throw new IllegalArgumentException( "Entry value cannot be null" );
+ }
+
+ if( getType() == ObjectClassTypeEnum.STRUCTURAL
+ && entry.getType() == ObjectClassTypeEnum.STRUCTURAL )
+ {
+ throw new IllegalArgumentException( "A entry cannot contain two structural entries" );
+ }
+
+ boolean alreadyExists = false;
+
+ for( String s : SUPERIORS )
+ {
+ if( s.equals( entry.getName() ) )
+ {
+ alreadyExists = true;
+ break;
+ }
+ }
+
+ if( ! alreadyExists && ( additionalEntries != null ) )
+ {
+ for( Entry e : additionalEntries )
+ {
+ if( e.getName().equals( entry.getName() ) )
+ {
+ alreadyExists = true;
+ break;
+ }
+ }
+ }
+
+ if( alreadyExists )
+ {
+ throw new IllegalArgumentException( "Entry with name " + entry.getName() + " already exists" );
+ }
+
+ if( additionalEntries == null )
+ {
+ additionalEntries = new HashSet<Entry>();
+ }
+
+ additionalEntries.add( entry );
+ }
+
+ public Iterator<Entry> getAdditionalEntries()
+ {
+ if( additionalEntries == null )
+ {
+ // to avoid ugly null check in the caller
+ return Collections.EMPTY_SET.iterator();
+ }
+
+ return additionalEntries.iterator();
+ }
}
\ No newline at end of file