directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r602749 - in /directory/studio/trunk: studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/ studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/ studio-ldif-parser/src...
Date Sun, 09 Dec 2007 22:58:17 GMT
Author: seelmann
Date: Sun Dec  9 14:58:16 2007
New Revision: 602749

URL: http://svn.apache.org/viewvc?rev=602749&view=rev
Log:
Fix for DIRSTUDIO-249: added request controls to modification log

Modified:
    directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java
    directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/Control.java
    directory/studio/trunk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifControlLine.java

Modified: directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java?rev=602749&r1=602748&r2=602749&view=diff
==============================================================================
--- directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java
(original)
+++ directory/studio/trunk/studio-connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/LdifModificationLogger.java
Sun Dec  9 14:58:16 2007
@@ -57,10 +57,14 @@
 import org.apache.directory.studio.ldifparser.model.container.LdifChangeDeleteRecord;
 import org.apache.directory.studio.ldifparser.model.container.LdifChangeModDnRecord;
 import org.apache.directory.studio.ldifparser.model.container.LdifChangeModifyRecord;
+import org.apache.directory.studio.ldifparser.model.container.LdifChangeRecord;
 import org.apache.directory.studio.ldifparser.model.container.LdifModSpec;
 import org.apache.directory.studio.ldifparser.model.lines.LdifAttrValLine;
+import org.apache.directory.studio.ldifparser.model.lines.LdifChangeTypeLine;
 import org.apache.directory.studio.ldifparser.model.lines.LdifCommentLine;
+import org.apache.directory.studio.ldifparser.model.lines.LdifControlLine;
 import org.apache.directory.studio.ldifparser.model.lines.LdifDeloldrdnLine;
+import org.apache.directory.studio.ldifparser.model.lines.LdifDnLine;
 import org.apache.directory.studio.ldifparser.model.lines.LdifModSpecSepLine;
 import org.apache.directory.studio.ldifparser.model.lines.LdifNewrdnLine;
 import org.apache.directory.studio.ldifparser.model.lines.LdifNewsuperiorLine;
@@ -70,8 +74,6 @@
 /**
  * The ModificationLogger is used to log modifications in LDIF format into a file.
  *
- * TODO: log controls
- *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
@@ -221,8 +223,9 @@
     {
         try
         {
-            LdifChangeAddRecord record = LdifChangeAddRecord.create( dn );
-            //record.addControl( controlLine );
+            LdifChangeAddRecord record = new LdifChangeAddRecord( LdifDnLine.create( dn )
);
+            addControlLines( record, controls );
+            record.setChangeType( LdifChangeTypeLine.createAdd() );
             NamingEnumeration<? extends Attribute> attributeEnumeration = attributes.getAll();
             while ( attributeEnumeration.hasMore() )
             {
@@ -259,8 +262,9 @@
     public void logChangetypeDelete( Connection connection, final String dn, final Control[]
controls,
         NamingException ex )
     {
-        LdifChangeDeleteRecord record = LdifChangeDeleteRecord.create( dn );
-        //record.addControl( controlLine );
+        LdifChangeDeleteRecord record = new LdifChangeDeleteRecord( LdifDnLine.create( dn
) );
+        addControlLines( record, controls );
+        record.setChangeType( LdifChangeTypeLine.createDelete() );
         record.finish( LdifSepLine.create() );
 
         String formattedString = record.toFormattedString( LdifFormatParameters.DEFAULT );
@@ -276,8 +280,9 @@
     {
         try
         {
-            LdifChangeModifyRecord record = LdifChangeModifyRecord.create( dn );
-            //record.addControl( controlLine );
+            LdifChangeModifyRecord record = new LdifChangeModifyRecord( LdifDnLine.create(
dn ) );
+            addControlLines( record, controls );
+            record.setChangeType( LdifChangeTypeLine.createModify() );
             for ( ModificationItem item : modificationItems )
             {
                 Attribute attribute = item.getAttribute();
@@ -337,8 +342,9 @@
             Rdn newrdn = dn.getRdn();
             LdapDN newsuperior = DnUtils.getParent( dn );
 
-            LdifChangeModDnRecord record = LdifChangeModDnRecord.create( oldDn );
-            //record.addControl( controlLine );
+            LdifChangeModDnRecord record = new LdifChangeModDnRecord( LdifDnLine.create(
oldDn ) );
+            addControlLines( record, controls );
+            record.setChangeType( LdifChangeTypeLine.createModDn() );
             record.setNewrdn( LdifNewrdnLine.create( newrdn.getUpName() ) );
             record.setDeloldrdn( deleteOldRdn ? LdifDeloldrdnLine.create1() : LdifDeloldrdnLine.create0()
);
             record.setNewsuperior( LdifNewsuperiorLine.create( newsuperior.getUpName() )
);
@@ -349,6 +355,28 @@
         }
         catch ( InvalidNameException e )
         {
+        }
+    }
+
+
+    /**
+     * Adds control lines to the record
+     *
+     * @param record the recored
+     * @param controls the controls
+     */
+    private static void addControlLines( LdifChangeRecord record, Control[] controls )
+    {
+        if ( controls != null )
+        {
+            for ( Control control : controls )
+            {
+                String oid = control.getID();
+                boolean isCritical = control.isCritical();
+                byte[] controlValue = control.getEncodedValue();
+                LdifControlLine controlLine = LdifControlLine.create( oid, isCritical, controlValue
);
+                record.addControl( controlLine );
+            }
         }
     }
 

Modified: directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/Control.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/Control.java?rev=602749&r1=602748&r2=602749&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/Control.java
(original)
+++ directory/studio/trunk/studio-ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/Control.java
Sun Dec  9 14:58:16 2007
@@ -157,7 +157,7 @@
             return "";
         }
 
-        LdifControlLine line = LdifControlLine.create( getOid(), isCritical() ? " true" :
" false", getControlValue() );
+        LdifControlLine line = LdifControlLine.create( getOid(), isCritical(), getControlValue()
);
         String s = line.toRawString();
         s = s.substring( line.getRawControlSpec().length(), s.length() );
         s = s.substring( line.getRawControlType().length(), s.length() );

Modified: directory/studio/trunk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifControlLine.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifControlLine.java?rev=602749&r1=602748&r2=602749&view=diff
==============================================================================
--- directory/studio/trunk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifControlLine.java
(original)
+++ directory/studio/trunk/studio-ldif-parser/src/main/java/org/apache/directory/studio/ldifparser/model/lines/LdifControlLine.java
Sun Dec  9 14:58:16 2007
@@ -232,7 +232,7 @@
         {
             LdifControlLine controlLine = new LdifControlLine( 0, "control", ":", oid, criticality,
                 controlValue != null ? ":" : null, controlValue != null ? controlValue :
null,
-                    LdifParserConstants.LINE_SEPARATOR );
+                LdifParserConstants.LINE_SEPARATOR );
             return controlLine;
         }
     }
@@ -244,6 +244,18 @@
             && controlValue.length > 0 ? "::" : null, controlValue != null &&
controlValue.length > 0 ? LdifUtils
             .base64encode( controlValue ) : null, LdifParserConstants.LINE_SEPARATOR );
         return controlLine;
+    }
+
+
+    public static LdifControlLine create( String oid, boolean isCritical, String controlValue
)
+    {
+        return create( oid, isCritical ? " true" : " false", controlValue );
+    }
+
+
+    public static LdifControlLine create( String oid, boolean isCritical, byte[] controlValue
)
+    {
+        return create( oid, isCritical ? " true" : " false", controlValue );
     }
 
 }



Mime
View raw message