You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2008/01/27 12:16:45 UTC
svn commit: r615574 - in /directory/apacheds/branches/bigbang:
core-entry/src/main/java/org/apache/directory/server/core/entry/
core-entry/src/test/java/org/apache/directory/server/core/entry/
core/src/main/java/org/apache/directory/server/core/interce...
Author: elecharny
Date: Sun Jan 27 03:16:34 2008
New Revision: 615574
URL: http://svn.apache.org/viewvc?rev=615574&view=rev
Log:
o Removed Atributes for the Modify operation
o Fixed a lot of issues in the ServerEntry API
Modified:
directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/AbstractServerAttribute.java
directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/ModifyOperationContext.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddAttributeOperation.java
directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/DeleteAttributeOperation.java
directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/ReplaceAttributeOperation.java
Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/AbstractServerAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/AbstractServerAttribute.java?rev=615574&r1=615573&r2=615574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/AbstractServerAttribute.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/AbstractServerAttribute.java Sun Jan 27 03:16:34 2008
@@ -263,8 +263,11 @@
}
}
- values.add( val );
- nbAdded ++;
+ if ( !values.contains( val ) )
+ {
+ values.add( val );
+ nbAdded ++;
+ }
}
return nbAdded;
@@ -291,7 +294,13 @@
{
if ( attributeType.getSyntax().isHumanReadable() )
{
- values.add( new ServerStringValue( attributeType, val ) );
+ ServerStringValue ssv = new ServerStringValue( attributeType, val );
+
+ if ( !values.contains( ssv ) )
+ {
+ values.add( ssv );
+ nbAdded ++;
+ }
}
else
{
@@ -299,8 +308,6 @@
LOG.error( message );
throw new InvalidAttributeValueException( message );
}
-
- nbAdded ++;
}
return nbAdded;
@@ -357,10 +364,14 @@
}
else
{
- values.add( new ServerBinaryValue( attributeType, val ) );
+ ServerBinaryValue sbv = new ServerBinaryValue( attributeType, val );
+
+ if ( !values.contains( sbv ) )
+ {
+ values.add( sbv );
+ nbAdded ++;
+ }
}
-
- nbAdded ++;
}
return nbAdded;
Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java?rev=615574&r1=615573&r2=615574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerEntry.java Sun Jan 27 03:16:34 2008
@@ -43,6 +43,7 @@
import org.slf4j.LoggerFactory;
import javax.naming.NamingException;
+import javax.naming.directory.InvalidAttributeValueException;
/**
@@ -391,14 +392,11 @@
* @param objectClassAttribute The instance of ObjectClassAttribute
* @return The previously stored ObjectClassAttribute, if any
*/
- private ServerAttribute setObjectClassAttribute( ObjectClassAttribute objectClassAttribute )
+ private void setObjectClassAttribute( ObjectClassAttribute objectClassAttribute )
{
assert objectClassAttribute != null : "The ObjectClass Attribute should not be null";
this.objectClassAttribute = objectClassAttribute;
- ServerAttribute previous = serverAttributeMap.put( OBJECT_CLASS_AT, objectClassAttribute );
-
- return previous;
}
@@ -429,13 +427,24 @@
public boolean addObjectClass( ObjectClass objectClass, String alias ) throws NamingException
{
- return objectClassAttribute.addObjectClass( objectClass, alias );
+ boolean exists = objectClassAttribute.addObjectClass( objectClass, alias );
+
+ if ( !exists )
+ {
+ // The ObjectClass is a new one : update the vaules
+ }
+
+ ServerAttribute existing = serverAttributeMap.get( OBJECT_CLASS_AT );
+
+ existing.add( alias );
+
+ return exists;
}
public boolean addObjectClass( ObjectClass objectClass ) throws NamingException
{
- return objectClassAttribute.addObjectClass( objectClass );
+ return addObjectClass( objectClass, objectClass.getName() );
}
@@ -445,9 +454,16 @@
ServerAttribute currentOc = serverAttributeMap.get( objectClassAttribute.getType() );
- for ( ServerValue<?> value:objectClassAttribute )
+ if ( currentOc != null )
+ {
+ for ( ServerValue<?> value:objectClassAttribute )
+ {
+ currentOc.add( value );
+ }
+ }
+ else
{
- currentOc.add( value );
+ serverAttributeMap.put( OBJECT_CLASS_AT, objectClassAttribute );
}
}
@@ -578,7 +594,7 @@
*/
public ServerAttribute put( String upId, byte[]... values ) throws NamingException
{
- return put( getAttributeType( upId ), values );
+ return put( upId, getAttributeType( upId ), values );
}
@@ -617,6 +633,8 @@
{
// Just do nothing but clear the ObjectClass values
objectClassAttribute.clear();
+ ServerAttribute newAttribute = new ObjectClassAttribute( registries );
+ serverAttributeMap.put( attributeType, newAttribute );
}
else
{
@@ -667,11 +685,15 @@
if ( serverAttribute.getType().equals( OBJECT_CLASS_AT ) )
{
+ ServerAttribute removed = null;
+
// The objectClass attributeType is special
if ( serverAttribute instanceof ObjectClassAttribute )
{
- ServerAttribute removed = setObjectClassAttribute( ( ObjectClassAttribute ) serverAttribute );
+ removed = this.objectClassAttribute;
+ this.objectClassAttribute = (ObjectClassAttribute)serverAttribute;
+ serverAttributeMap.put( OBJECT_CLASS_AT, serverAttribute );
previous.add( removed );
}
else
@@ -679,8 +701,19 @@
// Here, the attributeType is ObjectClass, but the Attribute itself is
// not a instance of the ObjectClassAttribute. We will store all of
// its values into a new instance of ObjectClassAttribute.
- ObjectClassAttribute objectClassAttribute = new ObjectClassAttribute( registries, serverAttribute );
- ServerAttribute removed = setObjectClassAttribute( objectClassAttribute );
+ if ( serverAttribute.getType().getSyntax().isHumanReadable() )
+ {
+ ObjectClassAttribute objectClassAttribute = new ObjectClassAttribute( registries, serverAttribute );
+ this.objectClassAttribute = objectClassAttribute;
+ removed = serverAttributeMap.put( OBJECT_CLASS_AT, objectClassAttribute );
+ }
+ else
+ {
+ // The attribute must be a String
+ String message = "Only String values supported for objectClass attribute";
+ LOG.error( message );
+ throw new UnsupportedOperationException( message );
+ }
previous.add( removed );
}
@@ -773,32 +806,7 @@
*/
public ServerAttribute put( AttributeType attributeType, ServerValue<?>... values ) throws NamingException
{
- if ( attributeType == null )
- {
- String message = "The attributeType should not be null";
- LOG.error( message );
- throw new IllegalArgumentException( message );
- }
-
- ServerAttribute existing = serverAttributeMap.get( attributeType );
-
- if ( existing != null )
- {
- // We have an existing attribute : clone it and return it
- ServerAttribute previous = (ServerAttribute)existing.clone();
-
- // Stores the new values into the attribute
- existing.put( values );
-
- return previous;
- }
- else
- {
- ServerAttribute serverAttribute = new DefaultServerAttribute( attributeType, values );
- put( serverAttribute );
-
- return null;
- }
+ return put( null, attributeType, values );
}
@@ -817,22 +825,19 @@
upId = getUpId( upId, attributeType );
attributeType = getAttributeType( upId, attributeType );
- ServerAttribute serverAttribute = new DefaultServerAttribute( upId, attributeType );
-
if ( attributeType.equals( OBJECT_CLASS_AT ) )
{
- // If the AttributeType is the ObjectClass AttributeType, then
- // we don't add it to the entry, as it has already been added
- // before. But we have to store the upId.
- ServerAttribute previous = objectClassAttribute.clone();
- objectClassAttribute.setUpId( upId, OBJECT_CLASS_AT );
- objectClassAttribute.put( values );
+ // Create a new ObjectclassAttribute and return the previous one
+ ServerAttribute previous = this.objectClassAttribute;
+
+ objectClassAttribute = new ObjectClassAttribute( registries, upId, values );
+ serverAttributeMap.put( OBJECT_CLASS_AT, objectClassAttribute );
return previous;
}
else
{
// We simply have to set the current attribute values
- serverAttribute.put( values );
+ ServerAttribute serverAttribute = new DefaultServerAttribute( upId, attributeType, values );
return serverAttributeMap.put( attributeType, serverAttribute );
}
}
@@ -863,38 +868,13 @@
* we will try to convert values from String to byte[]
*
* @param attributeType The attributeType
- * @param vals The String values to add to the attribute
+ * @param values The String values to add to the attribute
* @return The existing ServerAttribute which has been replaced, if any
* @throws NamingException If some values conflict with the attributeType
*/
- public ServerAttribute put( AttributeType attributeType, String... vals ) throws NamingException
+ public ServerAttribute put( AttributeType attributeType, String... values ) throws NamingException
{
- if ( attributeType == null )
- {
- String message = "The attributeType should not be null";
- LOG.error( message );
- throw new IllegalArgumentException( message );
- }
-
- ServerAttribute existing = serverAttributeMap.get( attributeType );
-
- if ( existing != null )
- {
- ServerAttribute previous = (ServerAttribute)existing.clone();
- existing.put( vals );
- return previous;
- }
- else
- {
- if ( attributeType.equals( OBJECT_CLASS_AT ) )
- {
- return setObjectClassAttribute( new ObjectClassAttribute( registries, OBJECT_CLASS_AT.getName(), vals ) );
- }
- else
- {
- return put( null, attributeType, vals );
- }
- }
+ return put( null, attributeType, values );
}
@@ -920,9 +900,9 @@
// If the AttributeType is the ObjectClass AttributeType, then
// we don't add it to the entry, as it has already been added
// before. But we have to store the upId.
- ServerAttribute previous = objectClassAttribute.clone();
- objectClassAttribute.setUpId( upId, OBJECT_CLASS_AT );
- objectClassAttribute.put( values );
+ ServerAttribute previous = objectClassAttribute;
+ objectClassAttribute = new ObjectClassAttribute( registries, upId, values );
+ serverAttributeMap.put( OBJECT_CLASS_AT, objectClassAttribute );
return previous;
}
else
@@ -940,36 +920,13 @@
* The values are byte[], so the attributeType must be non-humanReadable.
*
* @param attributeType The attributeType
- * @param vals The byte[] values to add to the attribute
+ * @param values The byte[] values to add to the attribute
* @return The existing ServerAttribute which has been replaced, if any
* @throws NamingException If some values conflict with the attributeType
*/
- public ServerAttribute put( AttributeType attributeType, byte[]... vals ) throws NamingException
+ public ServerAttribute put( AttributeType attributeType, byte[]... values ) throws NamingException
{
- if ( attributeType == null )
- {
- String message = "The attributeType should not be null";
- LOG.error( message );
- throw new IllegalArgumentException( message );
- }
-
- if ( attributeType.equals( OBJECT_CLASS_AT ) )
- {
- throw new UnsupportedOperationException( "Only String values supported for objectClass attribute" );
- }
-
- ServerAttribute existing = serverAttributeMap.get( attributeType );
-
- if ( existing != null )
- {
- ServerAttribute previous = (ServerAttribute)existing.clone();
- existing.put( vals );
- return previous;
- }
- else
- {
- return put( null, attributeType, vals );
- }
+ return put( null, attributeType, values );
}
@@ -985,6 +942,13 @@
*/
public ServerAttribute put( String upId, AttributeType attributeType, byte[]... values ) throws NamingException
{
+ if ( attributeType == null )
+ {
+ String message = "The attributeType should not be null";
+ LOG.error( message );
+ throw new IllegalArgumentException( message );
+ }
+
upId = getUpId( upId, attributeType );
attributeType = getAttributeType( upId, attributeType );
@@ -1012,16 +976,9 @@
for ( AttributeType attributeType:attributeTypes )
{
- if ( attributeType.equals( OBJECT_CLASS_AT ) )
+ if ( serverAttributeMap.containsKey( attributeType ) )
{
- attributes.add( setObjectClassAttribute( new ObjectClassAttribute( registries ) ) );
- }
- else
- {
- if ( serverAttributeMap.containsKey( attributeType ) )
- {
- attributes.add( serverAttributeMap.remove( attributeType ) );
- }
+ attributes.add( serverAttributeMap.remove( attributeType ) );
}
}
@@ -1044,14 +1001,7 @@
{
AttributeType attributeType = registries.getAttributeTypeRegistry().lookup( upId );
- if ( attributeType.equals( OBJECT_CLASS_AT ) )
- {
- attributes.add( setObjectClassAttribute( new ObjectClassAttribute( registries ) ) );
- }
- else
- {
- attributes.add( serverAttributeMap.remove( attributeType ) );
- }
+ attributes.add( serverAttributeMap.remove( attributeType ) );
}
return attributes;
@@ -1316,6 +1266,118 @@
/**
+ * Add a new ObjectClass, with its upId. If the upId is null,
+ * default to "objectClass".
+ *
+ * Updates the objectClassAttribute and the serverAttributeMap.
+ */
+ private void addObjectClass( String upId, String... values ) throws NamingException, InvalidAttributeValueException
+ {
+ ServerAttribute attribute = serverAttributeMap.get( OBJECT_CLASS_AT );
+
+ if ( objectClassAttribute == null )
+ {
+ objectClassAttribute = new ObjectClassAttribute( registries, upId, values );
+ serverAttributeMap.put( OBJECT_CLASS_AT, objectClassAttribute );
+ }
+ else
+ {
+ objectClassAttribute.add( values );
+ attribute.add( values );
+ }
+ }
+
+
+ /**
+ * Add a new ObjectClass, with its upId. If the upId is null,
+ * default to "objectClass".
+ *
+ * Updates the objectClassAttribute and the serverAttributeMap.
+ */
+ private void addObjectClass( String upId, ServerValue<?>... values ) throws NamingException, InvalidAttributeValueException
+ {
+ ServerAttribute attribute = serverAttributeMap.get( OBJECT_CLASS_AT );
+
+ if ( objectClassAttribute == null )
+ {
+ objectClassAttribute = new ObjectClassAttribute( registries, upId, values );
+ serverAttributeMap.put( OBJECT_CLASS_AT, attribute );
+ }
+ else
+ {
+ objectClassAttribute.add( values );
+ attribute.add( values );
+ }
+ }
+
+
+ /**
+ * Add a new ServerAttribute, with its upId. If the upId is null,
+ * default to the AttributeType name.
+ *
+ * Updates the serverAttributeMap.
+ */
+ private void createAttribute( String upId, AttributeType attributeType, ServerValue<?>... values ) throws NamingException, InvalidAttributeValueException
+ {
+ ServerAttribute attribute = new DefaultServerAttribute( attributeType, values );
+ attribute.setUpId( upId, attributeType );
+ serverAttributeMap.put( attributeType, attribute );
+ }
+
+
+ /**
+ * Add a new ServerAttribute, with its upId. If the upId is null,
+ * default to the AttributeType name.
+ *
+ * Updates the serverAttributeMap.
+ */
+ private void createAttribute( String upId, AttributeType attributeType, String... values ) throws NamingException, InvalidAttributeValueException
+ {
+ ServerAttribute attribute = new DefaultServerAttribute( attributeType, values );
+ attribute.setUpId( upId, attributeType );
+ serverAttributeMap.put( attributeType, attribute );
+ }
+
+
+ /**
+ * Add a new ServerAttribute, with its upId. If the upId is null,
+ * default to the AttributeType name.
+ *
+ * Updates the serverAttributeMap.
+ */
+ private void createAttribute( String upId, AttributeType attributeType, byte[]... values ) throws NamingException, InvalidAttributeValueException
+ {
+ ServerAttribute attribute = new DefaultServerAttribute( attributeType, values );
+ attribute.setUpId( upId, attributeType );
+ serverAttributeMap.put( attributeType, attribute );
+ }
+
+
+ /*-------------------------------------------------------------------------
+ *
+ * Add an attribute into this entry. We have many different cases.
+ * 1) We are adding a value to an ObjectClass or an ObjectClass to the
+ * entry
+ * 2) We are adding an attribute or a value to an attribute which is not
+ * an ObjectClass
+ *
+ * For (1), we will have to check :
+ * - that the value is not binary
+ * - we won't add an existing objectClass
+ * - and the ObjectClass must be valid
+ *
+ * If everything is fine, we will proceed accordingly to the existence
+ * of the ObjectClass attribute :
+ * - if the ObjectClass attribute has already been created, we will
+ * create the ObjectClass, set its value and add an Attribute into
+ * the values Map
+ * - otherwise, we will just add the value to the Values Map
+ *
+ * For (2), we just have to update the values Map :
+ * - if the attribute already exists, we add the value (no duplicate)
+ * - or we just add a new attribute to the Map
+ *-----------------------------------------------------------------------*/
+ /**
* Add an attribute (represented by its ID and some String values) into an
* entry.
* <p>
@@ -1334,21 +1396,26 @@
throw new IllegalArgumentException( message );
}
- ServerAttribute existing = serverAttributeMap.get( attributeType );
-
- if ( existing != null )
+ if ( attributeType.equals( OBJECT_CLASS_AT ) )
{
- existing.add( values );
+ // This is an objectClass, call the appropriate method
+ addObjectClass( null, values );
}
else
{
- if ( attributeType.equals( OBJECT_CLASS_AT ) )
+ ServerAttribute attribute = serverAttributeMap.get( attributeType );
+
+ if ( attribute != null )
{
- setObjectClassAttribute( new ObjectClassAttribute( registries, OBJECT_CLASS_AT.getName(), values ) );
+ // This Attribute already exist, we add the values
+ // into it
+ attribute.add( values );
}
else
{
- put( null, attributeType, values );
+ // We have to create a new Attribute and set the values
+ // and the upId
+ createAttribute( null, attributeType, values );
}
}
}
@@ -1373,24 +1440,27 @@
throw new IllegalArgumentException( message );
}
- ServerAttribute existing = serverAttributeMap.get( attributeType );
+ // ObjectClass with binary values are not allowed
+ if ( attributeType.equals( OBJECT_CLASS_AT ) )
+ {
+ String message = "Only String values supported for objectClass attribute";
+ LOG.error( message );
+ throw new UnsupportedOperationException( message );
+ }
- if ( existing != null )
+ ServerAttribute attribute = serverAttributeMap.get( attributeType );
+
+ if ( attribute != null )
{
- existing.add( values );
+ // This Attribute already exist, we add the values
+ // into it
+ attribute.add( values );
}
else
{
- if ( attributeType.equals( OBJECT_CLASS_AT ) )
- {
- String message = "Only String values supported for objectClass attribute";
- LOG.error( message );
- throw new UnsupportedOperationException( message );
- }
- else
- {
- put( null, attributeType, values );
- }
+ // We have to create a new Attribute and set the values
+ // and the upId
+ createAttribute( null, attributeType, values );
}
}
@@ -1413,17 +1483,25 @@
throw new IllegalArgumentException( message );
}
- ServerAttribute existing = serverAttributeMap.get( attributeType );
-
- if ( existing != null )
+ if ( attributeType.equals( OBJECT_CLASS_AT ) )
{
- // Adds the new values into the attribute
- existing.add( values );
+ // This is an objectClass, call the appropriate method
+ addObjectClass( null, values );
}
else
{
- ServerAttribute serverAttribute = new DefaultServerAttribute( attributeType, values );
- put( serverAttribute );
+ ServerAttribute attribute = serverAttributeMap.get( attributeType );
+
+ if ( attribute != null )
+ {
+ // This Attribute already exist, we add the values
+ // into it
+ attribute.add( values );
+ }
+ else
+ {
+ createAttribute( null, attributeType, values );
+ }
}
}
@@ -1478,31 +1556,36 @@
*/
public void add( String upId, AttributeType attributeType, String... values ) throws NamingException
{
- upId = getUpId( upId, attributeType );
- attributeType = getAttributeType( upId, attributeType );
-
- ServerAttribute existing = serverAttributeMap.get( attributeType );
+ if ( attributeType == null )
+ {
+ String message = "The attributeType should not be null";
+ LOG.error( message );
+ throw new IllegalArgumentException( message );
+ }
- if ( existing == null )
+ upId = getUpId( upId, attributeType );
+
+ if ( attributeType.equals( OBJECT_CLASS_AT ) )
{
- put( upId, attributeType, values );
+ // This is an objectClass, call the appropriate method
+ addObjectClass( upId, values );
}
else
{
- if ( attributeType.equals( OBJECT_CLASS_AT ) )
+ ServerAttribute attribute = serverAttributeMap.get( attributeType );
+
+ if ( attribute != null )
{
- // If the AttributeType is the ObjectClass AttributeType, then
- // we don't add it to the entry, as it has already been added
- // before. But we have to store the upId.
- objectClassAttribute.setUpId( upId, OBJECT_CLASS_AT );
- objectClassAttribute.add( values );
+ // This Attribute already exist, we add the values
+ // into it
+ attribute.add( values );
+ attribute.setUpId( upId, attributeType );
}
else
{
- // We simply have to set the current attribute values
- // and to change its upId
- existing.add( values );
- existing.setUpId( upId, attributeType );
+ // We have to create a new Attribute and set the values
+ // and the upId
+ createAttribute( upId, attributeType, values );
}
}
}
@@ -1519,30 +1602,30 @@
*/
public void add( String upId, AttributeType attributeType, byte[]... values ) throws NamingException
{
- upId = getUpId( upId, attributeType );
- attributeType = getAttributeType( upId, attributeType );
+ // ObjectClass with binary values are not allowed
+ if ( attributeType.equals( OBJECT_CLASS_AT ) )
+ {
+ String message = "Only String values supported for objectClass attribute";
+ LOG.error( message );
+ throw new UnsupportedOperationException( message );
+ }
+
+ ServerAttribute attribute = serverAttributeMap.get( attributeType );
- ServerAttribute existing = serverAttributeMap.get( attributeType );
+ upId = getUpId( upId, attributeType );
- if ( existing == null )
+ if ( attribute != null )
{
- put( upId, attributeType, values );
+ // This Attribute already exist, we add the values
+ // into it
+ attribute.add( values );
+ attribute.setUpId( upId, attributeType );
}
else
{
- if ( attributeType.equals( OBJECT_CLASS_AT ) )
- {
- String message = "Only String values supported for objectClass attribute";
- LOG.error( message );
- throw new UnsupportedOperationException( message );
- }
- else
- {
- // We simply have to set the current attribute values
- // and to change its upId
- existing.add( values );
- existing.setUpId( upId, attributeType );
- }
+ // We have to create a new Attribute and set the values
+ // and the upId
+ createAttribute( upId, attributeType, values );
}
}
@@ -1558,31 +1641,34 @@
*/
public void add( String upId, AttributeType attributeType, ServerValue<?>... values ) throws NamingException
{
- upId = getUpId( upId, attributeType );
- attributeType = getAttributeType( upId, attributeType );
+ if ( attributeType == null )
+ {
+ String message = "The attributeType should not be null";
+ LOG.error( message );
+ throw new IllegalArgumentException( message );
+ }
- ServerAttribute existing = serverAttributeMap.get( attributeType );
+ upId = getUpId( upId, attributeType );
- if ( existing == null )
+ if ( attributeType.equals( OBJECT_CLASS_AT ) )
{
- put( upId, attributeType, values );
+ // This is an objectClass, call the appropriate method
+ addObjectClass( upId, values );
}
else
{
- if ( attributeType.equals( OBJECT_CLASS_AT ) )
+ ServerAttribute attribute = serverAttributeMap.get( attributeType );
+
+ if ( attribute != null )
{
- // If the AttributeType is the ObjectClass AttributeType, then
- // we don't add it to the entry, as it has already been added
- // before. But we have to store the upId.
- objectClassAttribute.setUpId( upId, OBJECT_CLASS_AT );
- objectClassAttribute.add( values );
+ // This Attribute already exist, we add the values
+ // into it
+ attribute.add( values );
+ attribute.setUpId( upId, attributeType );
}
else
{
- // We simply have to set the current attribute values
- // and to change its upId
- existing.add( values );
- existing.setUpId( upId, attributeType );
+ createAttribute( upId, attributeType, values );
}
}
}
Modified: directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java?rev=615574&r1=615573&r2=615574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java Sun Jan 27 03:16:34 2008
@@ -389,7 +389,7 @@
ServerAttribute sa = new DefaultServerAttribute( atL, "france" );
entry.put( sa );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertNotNull( entry.get( "l" ) );
assertEquals( "france", entry.get( "l" ).get().get() );
@@ -398,7 +398,7 @@
ServerAttribute sd = new DefaultServerAttribute( atStreet, "testStreet" );
entry.put( sb, sc, sd );
- assertEquals( 5, entry.size() );
+ assertEquals( 4, entry.size() );
assertNotNull( entry.get( atC ) );
assertEquals( "countryTest", entry.get( atC ).get().get() );
assertNotNull( entry.get( atGN ) );
@@ -414,7 +414,7 @@
assertEquals( 2, result.size() );
assertEquals( "countryTest", result.get(0).get().get() );
assertEquals( "test", result.get(1).get().get() );
- assertEquals( 5, entry.size() );
+ assertEquals( 4, entry.size() );
assertNotNull( entry.get( atC ) );
assertEquals( "countryTestTest", entry.get( atC ).get().get() );
assertNotNull( entry.get( atGN ) );
@@ -455,7 +455,7 @@
// Test an empty AT
entry.put( atCN, (String)null );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "cn", entry.get( atCN ).getUpId() );
assertNull( entry.get( atCN ).get().get() );
@@ -474,7 +474,7 @@
atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
entry.put( atCN, "test" );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "cn", entry.get( atCN ).getUpId() );
assertEquals( 1, entry.get( atCN ).size() );
assertEquals( "test", entry.get( atCN ).get().get() );
@@ -482,7 +482,7 @@
// Add more than one value
entry.put( atCN, "test1", "test2", "test3" );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "cn", entry.get( atCN ).getUpId() );
assertEquals( 3, entry.get( atCN ).size() );
assertTrue( entry.contains( "cn", "test1" ) );
@@ -494,7 +494,7 @@
assertEquals( 3, sa.size() );
assertTrue( sa.contains( "test1", "test2", "test3" ) );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "cn", entry.get( atCN ).getUpId() );
assertEquals( 2, entry.get( atCN ).size() );
assertTrue( entry.contains( "cn", "test1" ) );
@@ -514,7 +514,7 @@
// Test an empty AT
entry.put( atPwd, (byte[])null );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "userPassword", entry.get( atPwd ).getUpId() );
assertNull( entry.get( atPwd ).get().get() );
@@ -538,7 +538,7 @@
atPwd = registries.getAttributeTypeRegistry().lookup( "userPassword" );
entry.put( atPwd, password );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "userPassword", entry.get( atPwd ).getUpId() );
assertEquals( 1, entry.get( atPwd ).size() );
assertTrue( Arrays.equals( password, (byte[])entry.get( atPwd ).get().get() ) );
@@ -546,7 +546,7 @@
// Add more than one value
entry.put( atPwd, test1, test2, test3 );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "userPassword", entry.get( atPwd ).getUpId() );
assertEquals( 3, entry.get( atPwd ).size() );
assertTrue( entry.contains( "userpassword", test1 ) );
@@ -558,7 +558,7 @@
assertEquals( 3, sa.size() );
assertTrue( sa.contains( test1, test2, test3 ) );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "userPassword", entry.get( atPwd ).getUpId() );
assertEquals( 2, entry.get( atPwd ).size() );
assertTrue( entry.contains( "userpassword", test1 ) );
@@ -578,7 +578,7 @@
AttributeType atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
entry.put( atCN, (ServerValue<?>)null );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "cn", entry.get( atCN ).getUpId() );
// Check that we can't use invalid arguments
@@ -597,7 +597,7 @@
ServerValue<?> ssv = new ServerStringValue( atCN, "test" );
entry.put( atCN, ssv );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "cn", entry.get( atCN ).getUpId() );
assertEquals( 1, entry.get( atCN ).size() );
assertEquals( "test", entry.get( atCN ).get().get() );
@@ -607,7 +607,7 @@
new ServerStringValue( atCN, "test2" ),
new ServerStringValue( atCN, "test3" ));
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "cn", entry.get( atCN ).getUpId() );
assertEquals( 3, entry.get( atCN ).size() );
assertTrue( entry.contains( "cn", "test1" ) );
@@ -621,7 +621,7 @@
assertEquals( 3, sa.size() );
assertTrue( sa.contains( "test1", "test2", "test3" ) );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "cn", entry.get( atCN ).getUpId() );
assertEquals( 2, entry.get( atCN ).size() );
assertTrue( entry.contains( "cn", "test1" ) );
@@ -642,7 +642,7 @@
// Adding a null value should be possible
entry.put( "cn", (String)null );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "cn", entry.get( atCN ).getUpId() );
assertNull( entry.get( atCN ).get().get() );
@@ -661,7 +661,7 @@
atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
entry.put( "cn", "test" );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "cn", entry.get( atCN ).getUpId() );
assertEquals( 1, entry.get( atCN ).size() );
assertEquals( "test", entry.get( atCN ).get().get() );
@@ -669,7 +669,7 @@
// Add more than one value
entry.put( "cn", "test1", "test2", "test3" );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "cn", entry.get( atCN ).getUpId() );
assertEquals( 3, entry.get( atCN ).size() );
assertTrue( entry.contains( "cn", "test1" ) );
@@ -681,7 +681,7 @@
assertEquals( 3, sa.size() );
assertTrue( sa.contains( "test1", "test2", "test3" ) );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "cn", entry.get( atCN ).getUpId() );
assertEquals( 2, entry.get( atCN ).size() );
assertTrue( entry.contains( "cn", "test1" ) );
@@ -705,7 +705,7 @@
// Adding a null value should be possible
entry.put( "userPassword", (byte[])null );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
assertNull( entry.get( atPassword ).get().get() );
@@ -728,7 +728,7 @@
entry.put( "userPassword", test );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
assertEquals( 1, entry.get( atPassword ).size() );
assertTrue( Arrays.equals( test, (byte[])entry.get( atPassword ).get().get() ) );
@@ -736,7 +736,7 @@
// Add more than one value
entry.put( "userPassword", test1, test2, test3 );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
assertEquals( 3, entry.get( atPassword ).size() );
assertTrue( entry.contains( "userPassword", test1 ) );
@@ -748,7 +748,7 @@
assertEquals( 3, sa.size() );
assertTrue( sa.contains( test1, test2, test3 ) );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
assertEquals( 2, entry.get( atPassword ).size() );
assertTrue( entry.contains( "userPassword", test1 ) );
@@ -779,21 +779,21 @@
// Test an empty AT
entry.put( "commonName", atCN, (String)null );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "commonName", entry.get( atCN ).getUpId() );
assertEquals( "cn", entry.get( atCN ).getType().getName() );
assertNull( entry.get( atCN ).get().get() );
// Check that we can use a null AttributeType
entry.put( "commonName", (AttributeType)null, (String)null );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "commonName", entry.get( atCN ).getUpId() );
assertEquals( "cn", entry.get( atCN ).getType().getName() );
assertNull( entry.get( atCN ).get().get() );
// Test that we can use a null upId
entry.put( null, atCN, (String)null );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "cn", entry.get( atCN ).getUpId() );
assertEquals( "cn", entry.get( atCN ).getType().getName() );
assertNull( entry.get( atCN ).get().get() );
@@ -814,7 +814,7 @@
ServerAttribute result = entry.put( "CN", atCN, "test1", "test2", "test3" );
assertNotNull( result );
assertEquals( "cn", result.getUpId() );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "CN", entry.get( atCN ).getUpId() );
assertNotNull( entry.get( atCN ).get() );
assertTrue( entry.contains( "cn", "test1" ) );
@@ -846,21 +846,30 @@
// Test an empty AT
entry.put( "userPassword", atPassword, (byte[])null );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
assertEquals( "userPassword", entry.get( atPassword ).getType().getName() );
assertNull( entry.get( atPassword ).get().get() );
// Check that we can use a null AttributeType
- entry.put( "userPassword", (AttributeType)null, (byte[])null );
- assertEquals( 2, entry.size() );
+ try
+ {
+ entry.put( "userPassword", (AttributeType)null, (byte[])null );
+ fail();
+ }
+ catch ( IllegalArgumentException iae )
+ {
+ assertTrue( true );
+ }
+
+ assertEquals( 1, entry.size() );
assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
assertEquals( "userPassword", entry.get( atPassword ).getType().getName() );
assertNull( entry.get( atPassword ).get().get() );
// Test that we can use a null upId
entry.put( null, atPassword, (byte[])null );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
assertEquals( "userPassword", entry.get( atPassword ).getType().getName() );
assertNull( entry.get( atPassword ).get().get() );
@@ -885,7 +894,7 @@
ServerAttribute result = entry.put( "UserPassword", atPassword, test1, test2, test3 );
assertNotNull( result );
assertEquals( "userPassword", result.getUpId() );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "UserPassword", entry.get( atPassword ).getUpId() );
assertNotNull( entry.get( atPassword ).get() );
assertEquals( 3, entry.get( atPassword ).size() );
@@ -918,21 +927,21 @@
// Test an empty AT
entry.put( "commonName", atCN, (ServerValue<?>)null );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "commonName", entry.get( atCN ).getUpId() );
assertEquals( "cn", entry.get( atCN ).getType().getName() );
assertNull( entry.get( atCN ).get().get() );
// Check that we can use a null AttributeType
entry.put( "commonName", (AttributeType)null, (ServerValue<?>)null );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "commonName", entry.get( atCN ).getUpId() );
assertEquals( "cn", entry.get( atCN ).getType().getName() );
assertNull( entry.get( atCN ).get().get() );
// Test that we can use a null upId
entry.put( null, atCN, (ServerValue<?>)null );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "cn", entry.get( atCN ).getUpId() );
assertEquals( "cn", entry.get( atCN ).getType().getName() );
assertNull( entry.get( atCN ).get().get() );
@@ -957,7 +966,7 @@
ServerAttribute result = entry.put( "CN", atCN, test1, test2, test3 );
assertNotNull( result );
assertEquals( "cn", result.getUpId() );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "CN", entry.get( atCN ).getUpId() );
assertNotNull( entry.get( atCN ).get() );
assertTrue( entry.contains( "cn", "test1" ) );
@@ -989,7 +998,7 @@
// Test an null valued AT
entry.put( "commonName", (ServerValue<?>)null );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "commonName", entry.get( atCN ).getUpId() );
assertEquals( "cn", entry.get( atCN ).getType().getName() );
assertNull( entry.get( atCN ).get().get() );
@@ -1002,7 +1011,7 @@
ServerAttribute result = entry.put( "CN", test1, test2, test3 );
assertNotNull( result );
assertEquals( "commonName", result.getUpId() );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertEquals( "CN", entry.get( atCN ).getUpId() );
assertNotNull( entry.get( atCN ).get() );
assertTrue( entry.contains( "cn", "test1" ) );
@@ -1752,23 +1761,23 @@
// Test a simple removal
entry.add( "cN", atCN, test1 );
- assertEquals( 2, entry.size() );
+ assertEquals( 1, entry.size() );
assertNotNull( entry.get( atCN ) );
entry.remove( "CN" );
- assertEquals( 1, entry.size() );
+ assertEquals( 0, entry.size() );
assertNull( entry.get( atCN ) );
// Test a removal of many elements
entry.put( "CN", test1, test2 );
entry.put( "userPassword", testB1, testB2 );
- assertEquals( 3, entry.size() );
+ assertEquals( 2, entry.size() );
assertNotNull( entry.get( atCN ) );
assertNotNull( entry.get( atPassword ) );
AttributeType OBJECT_CLASS_AT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT );
entry.remove( "cN", "UsErPaSsWoRd" );
- assertEquals( 1, entry.size() );
+ assertEquals( 0, entry.size() );
assertNull( entry.get( atCN ) );
assertNull( entry.get( atPassword ) );
assertFalse( entry.contains( OBJECT_CLASS_AT, "top" ) );
@@ -1776,7 +1785,7 @@
// test the removal of a bad Attribute
entry.put( "CN", test1, test2 );
entry.put( "userPassword", testB1, testB2 );
- assertEquals( 3, entry.size() );
+ assertEquals( 2, entry.size() );
assertNotNull( entry.get( atCN ) );
assertNotNull( entry.get( atPassword ) );
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/ModifyOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/ModifyOperationContext.java?rev=615574&r1=615573&r2=615574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/ModifyOperationContext.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/ModifyOperationContext.java Sun Jan 27 03:16:34 2008
@@ -22,12 +22,12 @@
import java.util.ArrayList;
import java.util.List;
-import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
import javax.naming.directory.ModificationItem;
+import org.apache.directory.server.core.entry.ServerAttribute;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerEntryUtils;
import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.shared.ldap.message.ModificationItemImpl;
import org.apache.directory.shared.ldap.name.LdapDN;
@@ -54,7 +54,7 @@
*/
public ModifyOperationContext( Registries registries )
{
- super( registries );
+ super( registries );
}
@@ -104,15 +104,13 @@
}
- @SuppressWarnings( value = "unchecked" )
- public static List<ModificationItemImpl> createModItems( Attributes attributes, int modOp ) throws NamingException
+ public static List<ModificationItemImpl> createModItems( ServerEntry serverEntry, int modOp ) throws NamingException
{
- List<ModificationItemImpl> items = new ArrayList<ModificationItemImpl>( attributes.size() );
- NamingEnumeration<Attribute> e = ( NamingEnumeration<Attribute> ) attributes.getAll();
+ List<ModificationItemImpl> items = new ArrayList<ModificationItemImpl>( serverEntry.size() );
- while ( e.hasMore() )
+ for ( ServerAttribute attribute:serverEntry )
{
- items.add( new ModificationItemImpl( modOp, e.next() ) );
+ items.add( new ModificationItemImpl( modOp, ServerEntryUtils.toAttributeImpl( attribute ) ) );
}
return items;
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?rev=615574&r1=615573&r2=615574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java Sun Jan 27 03:16:34 2008
@@ -351,7 +351,8 @@
// Now remove the ObjectClass attribute if it has not been requested
if ( ( opCtx.getAttrsId() != null ) && ( opCtx.getAttrsId().size() != 0 ) )
{
- if ( serverEntry.get( SchemaConstants.OBJECT_CLASS_AT ).size() == 0 )
+ if ( ( serverEntry.get( SchemaConstants.OBJECT_CLASS_AT ) != null ) &&
+ (serverEntry.get( SchemaConstants.OBJECT_CLASS_AT ).size() == 0 ) )
{
result.remove( SchemaConstants.OBJECT_CLASS_AT );
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java?rev=615574&r1=615573&r2=615574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java Sun Jan 27 03:16:34 2008
@@ -27,6 +27,7 @@
import org.apache.directory.server.constants.ApacheSchemaConstants;
import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
import org.apache.directory.server.core.entry.ServerAttribute;
import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.server.core.entry.ServerEntryUtils;
@@ -51,7 +52,6 @@
import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
import org.apache.directory.shared.ldap.message.ModificationItemImpl;
import org.apache.directory.shared.ldap.name.AttributeTypeAndValue;
import org.apache.directory.shared.ldap.name.LdapDN;
@@ -63,7 +63,6 @@
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
@@ -219,21 +218,16 @@
nextInterceptor.rename( opContext );
// add operational attributes after call in case the operation fails
- Attributes attributes = new AttributesImpl( true );
- Attribute attribute = new AttributeImpl( SchemaConstants.MODIFIERS_NAME_AT );
- attribute.add( getPrincipal().getName() );
- attributes.put( attribute );
-
- attribute = new AttributeImpl( SchemaConstants.MODIFY_TIMESTAMP_AT );
- attribute.add( DateUtils.getGeneralizedTime() );
- attributes.put( attribute );
+ ServerEntry serverEntry = new DefaultServerEntry( registries, opContext.getDn() );
+ serverEntry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal().getName() );
+ serverEntry.put( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
LdapDN newDn = ( LdapDN ) opContext.getDn().clone();
newDn.remove( opContext.getDn().size() - 1 );
newDn.add( opContext.getNewRdn() );
newDn.normalize( atRegistry.getNormalizerMapping() );
- List<ModificationItemImpl> items = ModifyOperationContext.createModItems( attributes, DirContext.REPLACE_ATTRIBUTE );
+ List<ModificationItemImpl> items = ModifyOperationContext.createModItems( serverEntry, DirContext.REPLACE_ATTRIBUTE );
ModifyOperationContext newModify = new ModifyOperationContext( registries, newDn, items );
@@ -246,16 +240,11 @@
nextInterceptor.move( opContext );
// add operational attributes after call in case the operation fails
- Attributes attributes = new AttributesImpl( true );
- Attribute attribute = new AttributeImpl( SchemaConstants.MODIFIERS_NAME_AT );
- attribute.add( getPrincipal().getName() );
- attributes.put( attribute );
+ ServerEntry serverEntry = new DefaultServerEntry( registries, opContext.getDn() );
+ serverEntry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal().getName() );
+ serverEntry.put( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
- attribute = new AttributeImpl( SchemaConstants.MODIFY_TIMESTAMP_AT );
- attribute.add( DateUtils.getGeneralizedTime() );
- attributes.put( attribute );
-
- List<ModificationItemImpl> items = ModifyOperationContext.createModItems( attributes, DirContext.REPLACE_ATTRIBUTE );
+ List<ModificationItemImpl> items = ModifyOperationContext.createModItems( serverEntry, DirContext.REPLACE_ATTRIBUTE );
ModifyOperationContext newModify =
@@ -271,20 +260,15 @@
nextInterceptor.moveAndRename( opContext );
// add operational attributes after call in case the operation fails
- Attributes attributes = new AttributesImpl( true );
- Attribute attribute = new AttributeImpl( SchemaConstants.MODIFIERS_NAME_AT );
- attribute.add( getPrincipal().getName() );
- attributes.put( attribute );
-
- attribute = new AttributeImpl( SchemaConstants.MODIFY_TIMESTAMP_AT );
- attribute.add( DateUtils.getGeneralizedTime() );
- attributes.put( attribute );
+ ServerEntry serverEntry = new DefaultServerEntry( registries, opContext.getDn() );
+ serverEntry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal().getName() );
+ serverEntry.put( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
- List<ModificationItemImpl> items = ModifyOperationContext.createModItems( attributes, DirContext.REPLACE_ATTRIBUTE );
+ List<ModificationItemImpl> items = ModifyOperationContext.createModItems( serverEntry, DirContext.REPLACE_ATTRIBUTE );
ModifyOperationContext newModify =
new ModifyOperationContext( registries,
- opContext.getParent(), items );
+ opContext.getParent(), items );
service.getPartitionNexus().modify( newModify );
}
@@ -464,8 +448,8 @@
}
else if ( rdn.size() == 1 )
{
- String name = atRegistry.lookup( rdn.getNormType() ).getName();
- String value = (String)rdn.getAtav().getValue();
+ String name = atRegistry.lookup( rdn.getNormType() ).getName();
+ String value = (String)rdn.getAtav().getValue();
newDn.add( new Rdn( name, name, value, value ) );
continue;
}
Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddAttributeOperation.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddAttributeOperation.java?rev=615574&r1=615573&r2=615574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddAttributeOperation.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/AddAttributeOperation.java Sun Jan 27 03:16:34 2008
@@ -21,16 +21,17 @@
import org.apache.directory.mitosis.common.CSN;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerEntryUtils;
import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
import org.apache.directory.server.core.partition.PartitionNexus;
import org.apache.directory.server.schema.registries.Registries;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
import org.apache.directory.shared.ldap.message.ModificationItemImpl;
import org.apache.directory.shared.ldap.name.LdapDN;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import java.util.List;
@@ -64,9 +65,10 @@
protected void execute1( PartitionNexus nexus, Registries registries ) throws NamingException
{
- Attributes attrs = new AttributesImpl( true );
- attrs.put( getAttribute() );
- List<ModificationItemImpl> items = ModifyOperationContext.createModItems( attrs, DirContext.ADD_ATTRIBUTE );
+ ServerEntry serverEntry = new DefaultServerEntry( registries, LdapDN.EMPTY_LDAPDN );
+ Attribute attribute = getAttribute();
+ serverEntry.put( ServerEntryUtils.toServerAttribute( attribute, registries.getAttributeTypeRegistry().lookup( attribute.getID() ) ) );
+ List<ModificationItemImpl> items = ModifyOperationContext.createModItems( serverEntry, DirContext.ADD_ATTRIBUTE );
nexus.modify( new ModifyOperationContext( registries, getName(), items ) );
}
}
Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/DeleteAttributeOperation.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/DeleteAttributeOperation.java?rev=615574&r1=615573&r2=615574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/DeleteAttributeOperation.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/DeleteAttributeOperation.java Sun Jan 27 03:16:34 2008
@@ -21,16 +21,17 @@
import org.apache.directory.mitosis.common.CSN;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerEntryUtils;
import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
import org.apache.directory.server.core.partition.PartitionNexus;
import org.apache.directory.server.schema.registries.Registries;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
import org.apache.directory.shared.ldap.message.ModificationItemImpl;
import org.apache.directory.shared.ldap.name.LdapDN;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import java.util.List;
@@ -64,9 +65,10 @@
protected void execute1( PartitionNexus nexus, Registries registries ) throws NamingException
{
- Attributes attrs = new AttributesImpl( true );
- attrs.put( getAttribute() );
- List<ModificationItemImpl> items = ModifyOperationContext.createModItems( attrs, DirContext.REMOVE_ATTRIBUTE );
+ ServerEntry serverEntry = new DefaultServerEntry( registries, LdapDN.EMPTY_LDAPDN );
+ Attribute attribute = getAttribute();
+ serverEntry.put( ServerEntryUtils.toServerAttribute( attribute, registries.getAttributeTypeRegistry().lookup( attribute.getID() ) ) );
+ List<ModificationItemImpl> items = ModifyOperationContext.createModItems( serverEntry, DirContext.REMOVE_ATTRIBUTE );
nexus.modify( new ModifyOperationContext( registries, getName(), items ) );
}
Modified: directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/ReplaceAttributeOperation.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/ReplaceAttributeOperation.java?rev=615574&r1=615573&r2=615574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/ReplaceAttributeOperation.java (original)
+++ directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/ReplaceAttributeOperation.java Sun Jan 27 03:16:34 2008
@@ -21,16 +21,17 @@
import org.apache.directory.mitosis.common.CSN;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerEntryUtils;
import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
import org.apache.directory.server.core.partition.PartitionNexus;
import org.apache.directory.server.schema.registries.Registries;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
import org.apache.directory.shared.ldap.message.ModificationItemImpl;
import org.apache.directory.shared.ldap.name.LdapDN;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import java.util.List;
@@ -66,9 +67,10 @@
protected void execute1( PartitionNexus nexus, Registries registries ) throws NamingException
{
- Attributes attrs = new AttributesImpl( true );
- attrs.put( getAttribute() );
- List<ModificationItemImpl> items = ModifyOperationContext.createModItems( attrs, DirContext.REPLACE_ATTRIBUTE );
+ ServerEntry serverEntry = new DefaultServerEntry( registries, LdapDN.EMPTY_LDAPDN );
+ Attribute attribute = getAttribute();
+ serverEntry.put( ServerEntryUtils.toServerAttribute( attribute, registries.getAttributeTypeRegistry().lookup( attribute.getID() ) ) );
+ List<ModificationItemImpl> items = ModifyOperationContext.createModItems( serverEntry, DirContext.REPLACE_ATTRIBUTE );
nexus.modify( new ModifyOperationContext( registries, getName(), items ) );
}