From 9b6dfe96f8d0e0c92c4fdbf3f65459271bca425c Mon Sep 17 00:00:00 2001
From: lutoff <lutoff@localhost>
Date: Mon, 07 Apr 2008 12:50:35 +0000
Subject: [PATCH] Fix for issue #2270 (export-ldif doesn't exclude operational attributes when it's a task)

---
 opends/resource/schema/02-config.ldif                           |    6 ++++++
 opends/src/server/org/opends/server/tools/ExportLDIF.java       |    9 +++++++++
 opends/src/server/org/opends/server/tasks/ExportTask.java       |    8 ++++++++
 opends/src/server/org/opends/server/types/LDIFExportConfig.java |    4 ++++
 opends/src/server/org/opends/server/config/ConfigConstants.java |    6 ++++++
 5 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/opends/resource/schema/02-config.ldif b/opends/resource/schema/02-config.ldif
index 54810e4..395e073 100644
--- a/opends/resource/schema/02-config.ldif
+++ b/opends/resource/schema/02-config.ldif
@@ -2252,6 +2252,11 @@
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
   SINGLE-VALUE
   X-ORIGIN 'OpenDS Directory Server' )
+attributeTypes: ( 1.3.6.1.4.1.26027.1.1.464
+  NAME 'ds-task-export-include-operational-attributes'
+  SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
+  SINGLE-VALUE
+  X-ORIGIN 'OpenDS Directory Server' )
 objectClasses: ( 1.3.6.1.4.1.26027.1.2.1
   NAME 'ds-cfg-access-control-handler'
   SUP top
@@ -2953,6 +2958,7 @@
         ds-task-export-wrap-column $
         ds-task-export-compress-ldif $
         ds-task-export-encrypt-ldif $
+        ds-task-export-include-operational-attributes $
         ds-task-export-sign-hash )
   X-ORIGIN 'OpenDS Directory Server' )
 objectClasses: ( 1.3.6.1.4.1.26027.1.2.69
diff --git a/opends/src/server/org/opends/server/config/ConfigConstants.java b/opends/src/server/org/opends/server/config/ConfigConstants.java
index f97d57a..1be0c38 100644
--- a/opends/src/server/org/opends/server/config/ConfigConstants.java
+++ b/opends/src/server/org/opends/server/config/ConfigConstants.java
@@ -4123,6 +4123,12 @@
   public static final String ATTR_TASK_EXPORT_WRAP_COLUMN =
        NAME_PREFIX_TASK + "export-wrap-column";
 
+  /**
+   * The name of the attribute in an export task definition that specifies
+   * that operational attributes have to be included.
+   */
+  public static final String ATTR_TASK_EXPORT_INCLUDE_OPERATIONAL_ATTRIBUTES =
+       NAME_PREFIX_TASK + "export-include-operational-attributes";
 
 
   /**
diff --git a/opends/src/server/org/opends/server/tasks/ExportTask.java b/opends/src/server/org/opends/server/tasks/ExportTask.java
index 80e6d6c..0f39887 100644
--- a/opends/src/server/org/opends/server/tasks/ExportTask.java
+++ b/opends/src/server/org/opends/server/tasks/ExportTask.java
@@ -131,6 +131,7 @@
   private boolean compressLDIF;
   private boolean encryptLDIF;
   private boolean signHash;
+  private boolean includeOperationalAttributes;
   private ArrayList<String> includeAttributeStrings;
   private ArrayList<String> excludeAttributeStrings;
   private ArrayList<String> includeFilterStrings;
@@ -189,6 +190,7 @@
     AttributeType typeIncludeBranch;
     AttributeType typeExcludeBranch;
     AttributeType typeWrapColumn;
+    AttributeType typeIncludeOperationalAttributes;
 
 
     typeLdifFile =
@@ -217,6 +219,8 @@
          getAttributeType(ATTR_TASK_EXPORT_EXCLUDE_BRANCH, true);
     typeWrapColumn =
          getAttributeType(ATTR_TASK_EXPORT_WRAP_COLUMN, true);
+    typeIncludeOperationalAttributes =
+      getAttributeType(ATTR_TASK_EXPORT_INCLUDE_OPERATIONAL_ATTRIBUTES, true);
 
 
     List<Attribute> attrList;
@@ -260,6 +264,9 @@
     attrList = taskEntry.getAttribute(typeWrapColumn);
     wrapColumn = TaskUtils.getSingleValueInteger(attrList, 0);
 
+    attrList = taskEntry.getAttribute(typeIncludeOperationalAttributes);
+    includeOperationalAttributes = TaskUtils.getBoolean(attrList, true);
+
   }
 
 
@@ -522,6 +529,7 @@
     exportConfig.setIncludeFilters(includeFilters);
     exportConfig.setSignHash(signHash);
     exportConfig.setWrapColumn(wrapColumn);
+    exportConfig.setIncludeOperationalAttributes(includeOperationalAttributes);
 
     // FIXME -- Should this be conditional?
     exportConfig.setInvokeExportPlugins(true);
diff --git a/opends/src/server/org/opends/server/tools/ExportLDIF.java b/opends/src/server/org/opends/server/tools/ExportLDIF.java
index 5e48861..9046833 100644
--- a/opends/src/server/org/opends/server/tools/ExportLDIF.java
+++ b/opends/src/server/org/opends/server/tools/ExportLDIF.java
@@ -467,6 +467,15 @@
       attributes.add(
               new LDAPAttribute(ATTR_TASK_EXPORT_WRAP_COLUMN, values));
     }
+
+    if (excludeOperationalAttrs.isPresent())
+    {
+      values = new ArrayList<ASN1OctetString>(1);
+      values.add(new ASN1OctetString("false"));
+      attributes.add(
+          new LDAPAttribute(ATTR_TASK_EXPORT_INCLUDE_OPERATIONAL_ATTRIBUTES,
+              values));
+    }
   }
 
   /**
diff --git a/opends/src/server/org/opends/server/types/LDIFExportConfig.java b/opends/src/server/org/opends/server/types/LDIFExportConfig.java
index 8d1a9b3..82f179c 100644
--- a/opends/src/server/org/opends/server/types/LDIFExportConfig.java
+++ b/opends/src/server/org/opends/server/types/LDIFExportConfig.java
@@ -69,6 +69,9 @@
   // Indicates whether the data should be encrypted as it is written.
   private boolean encryptData;
 
+  // Indicates whether we should exclude operational attributes.
+  private boolean excludeOperationalAttributes;
+
   // Indicates whether to generate a cryptographic hash of the data as
   // it is // written.
   private boolean hashData;
@@ -155,6 +158,7 @@
     includeFilters               = new ArrayList<SearchFilter>();
     compressData                 = false;
     encryptData                  = false;
+    excludeOperationalAttributes = false;
     hashData                     = false;
     includeObjectClasses         = true;
     includeOperationalAttributes = true;

--
Gitblit v1.10.0