manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1620748 - in /manifoldcf/trunk: ./ connectors/documentfilter/connector/src/main/java/org/apache/manifoldcf/agents/transformation/documentfilter/ connectors/documentfilter/connector/src/main/native2ascii/org/apache/manifoldcf/agents/transfo...
Date Tue, 26 Aug 2014 21:54:41 GMT
Author: kwright
Date: Tue Aug 26 21:54:40 2014
New Revision: 1620748

URL: http://svn.apache.org/r1620748
Log:
Fix for CONNECTORS-1015.

Modified:
    manifoldcf/trunk/CHANGES.txt
    manifoldcf/trunk/connectors/documentfilter/connector/src/main/java/org/apache/manifoldcf/agents/transformation/documentfilter/DocumentFilter.java
    manifoldcf/trunk/connectors/documentfilter/connector/src/main/java/org/apache/manifoldcf/agents/transformation/documentfilter/DocumentFilterConfig.java
    manifoldcf/trunk/connectors/documentfilter/connector/src/main/native2ascii/org/apache/manifoldcf/agents/transformation/documentfilter/common_en_US.properties
    manifoldcf/trunk/connectors/documentfilter/connector/src/main/native2ascii/org/apache/manifoldcf/agents/transformation/documentfilter/common_ja_JP.properties
    manifoldcf/trunk/connectors/documentfilter/connector/src/main/native2ascii/org/apache/manifoldcf/agents/transformation/documentfilter/common_zh_CH.properties
    manifoldcf/trunk/connectors/documentfilter/connector/src/main/resources/org/apache/manifoldcf/agents/transformation/documentfilter/editSpecification_Contents.html
    manifoldcf/trunk/connectors/documentfilter/connector/src/main/resources/org/apache/manifoldcf/agents/transformation/documentfilter/viewSpecification.html

Modified: manifoldcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1620748&r1=1620747&r2=1620748&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Tue Aug 26 21:54:40 2014
@@ -3,6 +3,10 @@ $Id$
 
 ======================= 2.0-dev =====================
 
+CONNECTORS-1015: Add minimum file size to Allowed Documents
+transformation filter.
+(David Morana, Karl Wright)
+
 CONNECTORS-1016: Recognize non-existent user.
 (David Morana, Karl Wright)
 

Modified: manifoldcf/trunk/connectors/documentfilter/connector/src/main/java/org/apache/manifoldcf/agents/transformation/documentfilter/DocumentFilter.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/documentfilter/connector/src/main/java/org/apache/manifoldcf/agents/transformation/documentfilter/DocumentFilter.java?rev=1620748&r1=1620747&r2=1620748&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/documentfilter/connector/src/main/java/org/apache/manifoldcf/agents/transformation/documentfilter/DocumentFilter.java
(original)
+++ manifoldcf/trunk/connectors/documentfilter/connector/src/main/java/org/apache/manifoldcf/agents/transformation/documentfilter/DocumentFilter.java
Tue Aug 26 21:54:40 2014
@@ -122,6 +122,7 @@ public class DocumentFilter extends org.
   
   protected static void fillInContentsSpecificationMap(Map<String,Object> paramMap,
Specification os)
   {
+    String minFileSize = DocumentFilterConfig.MINLENGTH_DEFAULT;
     String maxFileSize = DocumentFilterConfig.MAXLENGTH_DEFAULT;
     String allowedMimeTypes = DocumentFilterConfig.MIMETYPES_DEFAULT;
     String allowedFileExtensions = DocumentFilterConfig.EXTENSIONS_DEFAULT;
@@ -130,11 +131,14 @@ public class DocumentFilter extends org.
       SpecificationNode sn = os.getChild(i);
       if (sn.getType().equals(DocumentFilterConfig.NODE_MAXLENGTH))
         maxFileSize = sn.getAttributeValue(DocumentFilterConfig.ATTRIBUTE_VALUE);
+      else if (sn.getType().equals(DocumentFilterConfig.NODE_MINLENGTH))
+        minFileSize = sn.getAttributeValue(DocumentFilterConfig.ATTRIBUTE_VALUE);
       else if (sn.getType().equals(DocumentFilterConfig.NODE_MIMETYPES))
         allowedMimeTypes = sn.getValue();
       else if (sn.getType().equals(DocumentFilterConfig.NODE_EXTENSIONS))
         allowedFileExtensions = sn.getValue();
     }
+    paramMap.put("MINFILESIZE",minFileSize);
     paramMap.put("MAXFILESIZE",maxFileSize);
     paramMap.put("MIMETYPES",allowedMimeTypes);
     paramMap.put("EXTENSIONS",allowedFileExtensions);
@@ -230,7 +234,24 @@ public class DocumentFilter extends org.
     String seqPrefix = "s"+connectionSequenceNumber+"_";
 
     String x;
-        
+
+    x = variableContext.getParameter(seqPrefix+"minfilesize");
+    if (x != null)
+    {
+      int i = 0;
+      while (i < os.getChildCount())
+      {
+        SpecificationNode node = os.getChild(i);
+        if (node.getType().equals(DocumentFilterConfig.NODE_MINLENGTH))
+          os.removeChild(i);
+        else
+          i++;
+      }
+      SpecificationNode sn = new SpecificationNode(DocumentFilterConfig.NODE_MINLENGTH);
+      sn.setAttribute(DocumentFilterConfig.ATTRIBUTE_VALUE,x);
+      os.addChild(os.getChildCount(),sn);
+    }
+
     x = variableContext.getParameter(seqPrefix+"maxfilesize");
     if (x != null)
     {
@@ -333,9 +354,11 @@ public class DocumentFilter extends org.
     
     private final Set<String> extensions = new HashSet<String>();
     private final Set<String> mimeTypes = new HashSet<String>();
+    private final Long minLength;
     private final Long lengthCutoff;
     
     public SpecPacker(Specification os) {
+      Long minLength = null;
       Long lengthCutoff = null;
       String extensions = null;
       String mimeTypes = null;
@@ -349,8 +372,12 @@ public class DocumentFilter extends org.
         } else if (sn.getType().equals(DocumentFilterConfig.NODE_MAXLENGTH)) {
           String value = sn.getAttributeValue(DocumentFilterConfig.ATTRIBUTE_VALUE);
           lengthCutoff = new Long(value);
+        } else if (sn.getType().equals(DocumentFilterConfig.NODE_MINLENGTH)) {
+          String value = sn.getAttributeValue(DocumentFilterConfig.ATTRIBUTE_VALUE);
+          minLength = new Long(value);
         }
       }
+      this.minLength = minLength;
       this.lengthCutoff = lengthCutoff;
       fillSet(this.extensions, extensions);
       fillSet(this.mimeTypes, mimeTypes);
@@ -361,9 +388,9 @@ public class DocumentFilter extends org.
       int index = 0;
       
       // Max length
-      final StringBuilder sb = new StringBuilder();
       if (packedString.length() > index) {
         if (packedString.charAt(index++) == '+') {
+          final StringBuilder sb = new StringBuilder();
           index = unpack(sb,packedString,index,'+');
           this.lengthCutoff = new Long(sb.toString());
         } else
@@ -384,6 +411,18 @@ public class DocumentFilter extends org.
       for (String extension : extensionsBuffer) {
         this.extensions.add(extension);
       }
+      
+      // Min length
+      if (packedString.length() > index) {
+        if (packedString.charAt(index++) == '+') {
+          final StringBuilder sb = new StringBuilder();
+          index = unpack(sb,packedString,index,'+');
+          this.minLength = new Long(sb.toString());
+        } else
+          this.minLength = null;
+      } else
+        this.minLength = null;
+
     }
     
     public String toPackedString() {
@@ -415,14 +454,24 @@ public class DocumentFilter extends org.
       }
       java.util.Arrays.sort(extensions);
       packList(sb,extensions,'+');
+
+      // Min length
+      if (minLength == null)
+        sb.append('-');
+      else {
+        sb.append('+');
+        pack(sb,minLength.toString(),'+');
+      }
       
       return sb.toString();
     }
     
     public boolean checkLengthIndexable(long length) {
-      if (lengthCutoff == null)
-        return true;
-      return (length <= lengthCutoff.longValue());
+      if (minLength != null && length < minLength.longValue())
+        return false;
+      if (lengthCutoff != null && length > lengthCutoff.longValue())
+        return false;
+      return true;
     }
     
     public boolean checkMimeType(String mimeType) {

Modified: manifoldcf/trunk/connectors/documentfilter/connector/src/main/java/org/apache/manifoldcf/agents/transformation/documentfilter/DocumentFilterConfig.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/documentfilter/connector/src/main/java/org/apache/manifoldcf/agents/transformation/documentfilter/DocumentFilterConfig.java?rev=1620748&r1=1620747&r2=1620748&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/documentfilter/connector/src/main/java/org/apache/manifoldcf/agents/transformation/documentfilter/DocumentFilterConfig.java
(original)
+++ manifoldcf/trunk/connectors/documentfilter/connector/src/main/java/org/apache/manifoldcf/agents/transformation/documentfilter/DocumentFilterConfig.java
Tue Aug 26 21:54:40 2014
@@ -26,6 +26,8 @@ public class DocumentFilterConfig {
   // Configuration parameters
   
   // Specification nodes and values
+  public static final String NODE_MINLENGTH = "minlength";
+  public static final String MINLENGTH_DEFAULT = "0";
   public static final String NODE_MAXLENGTH = "maxlength";
   public static final String MAXLENGTH_DEFAULT = "16777216";
   public static final String NODE_MIMETYPES = "mimetypes";

Modified: manifoldcf/trunk/connectors/documentfilter/connector/src/main/native2ascii/org/apache/manifoldcf/agents/transformation/documentfilter/common_en_US.properties
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/documentfilter/connector/src/main/native2ascii/org/apache/manifoldcf/agents/transformation/documentfilter/common_en_US.properties?rev=1620748&r1=1620747&r2=1620748&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/documentfilter/connector/src/main/native2ascii/org/apache/manifoldcf/agents/transformation/documentfilter/common_en_US.properties
(original)
+++ manifoldcf/trunk/connectors/documentfilter/connector/src/main/native2ascii/org/apache/manifoldcf/agents/transformation/documentfilter/common_en_US.properties
Tue Aug 26 21:54:40 2014
@@ -14,6 +14,7 @@
 # limitations under the License.
 
 DocumentFilter.ContentsTabName=Allowed contents
+DocumentFilter.MinFileSizeBytesColon=Min file size (bytes):
 DocumentFilter.MaxFileSizeBytesColon=Max file size (bytes):
 DocumentFilter.AllowedMIMETypesColon=Allowed MIME types:
 DocumentFilter.AllowedFileExtensionsColon=Allowed file extensions:

Modified: manifoldcf/trunk/connectors/documentfilter/connector/src/main/native2ascii/org/apache/manifoldcf/agents/transformation/documentfilter/common_ja_JP.properties
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/documentfilter/connector/src/main/native2ascii/org/apache/manifoldcf/agents/transformation/documentfilter/common_ja_JP.properties?rev=1620748&r1=1620747&r2=1620748&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/documentfilter/connector/src/main/native2ascii/org/apache/manifoldcf/agents/transformation/documentfilter/common_ja_JP.properties
(original)
+++ manifoldcf/trunk/connectors/documentfilter/connector/src/main/native2ascii/org/apache/manifoldcf/agents/transformation/documentfilter/common_ja_JP.properties
Tue Aug 26 21:54:40 2014
@@ -14,6 +14,7 @@
 # limitations under the License.
 
 DocumentFilter.ContentsTabName=コンテンツ
+DocumentFilter.MinFileSizeBytesColon=Min file size (バイト):
 DocumentFilter.MaxFileSizeBytesColon=最大ファイルサイズ
(バイト):
 DocumentFilter.AllowedMIMETypesColon=利用可能なMIMEタイプ:
 DocumentFilter.AllowedFileExtensionsColon=利用可能なファイル拡張子:

Modified: manifoldcf/trunk/connectors/documentfilter/connector/src/main/native2ascii/org/apache/manifoldcf/agents/transformation/documentfilter/common_zh_CH.properties
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/documentfilter/connector/src/main/native2ascii/org/apache/manifoldcf/agents/transformation/documentfilter/common_zh_CH.properties?rev=1620748&r1=1620747&r2=1620748&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/documentfilter/connector/src/main/native2ascii/org/apache/manifoldcf/agents/transformation/documentfilter/common_zh_CH.properties
(original)
+++ manifoldcf/trunk/connectors/documentfilter/connector/src/main/native2ascii/org/apache/manifoldcf/agents/transformation/documentfilter/common_zh_CH.properties
Tue Aug 26 21:54:40 2014
@@ -14,6 +14,7 @@
 # limitations under the License.
 
 DocumentFilter.ContentsTabName=Allowed contents
+DocumentFilter.MinFileSizeBytesColon=Min file size (bytes):
 DocumentFilter.MaxFileSizeBytesColon=Max file size (bytes):
 DocumentFilter.AllowedMIMETypesColon=Allowed MIME types:
 DocumentFilter.AllowedFileExtensionsColon=Allowed file extensions:

Modified: manifoldcf/trunk/connectors/documentfilter/connector/src/main/resources/org/apache/manifoldcf/agents/transformation/documentfilter/editSpecification_Contents.html
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/documentfilter/connector/src/main/resources/org/apache/manifoldcf/agents/transformation/documentfilter/editSpecification_Contents.html?rev=1620748&r1=1620747&r2=1620748&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/documentfilter/connector/src/main/resources/org/apache/manifoldcf/agents/transformation/documentfilter/editSpecification_Contents.html
(original)
+++ manifoldcf/trunk/connectors/documentfilter/connector/src/main/resources/org/apache/manifoldcf/agents/transformation/documentfilter/editSpecification_Contents.html
Tue Aug 26 21:54:40 2014
@@ -20,6 +20,13 @@
 <table class="displaytable">
   <tr>
     <td class="description">
+      <nobr>$Encoder.bodyEscape($ResourceBundle.getString('DocumentFilter.MinFileSizeBytesColon'))</nobr>
+    </td>
+    <td class="value"><input name="s${SEQNUM}_minfilesize" type="text"
+      value="$Encoder.attributeEscape($MINFILESIZE)" size="24" /></td>
+  </tr>
+  <tr>
+    <td class="description">
       <nobr>$Encoder.bodyEscape($ResourceBundle.getString('DocumentFilter.MaxFileSizeBytesColon'))</nobr>
     </td>
     <td class="value"><input name="s${SEQNUM}_maxfilesize" type="text"
@@ -43,6 +50,7 @@
 
 #else
 
+<input type="hidden" name="s${SEQNUM}_minfilesize" value="$Encoder.attributeEscape($MINFILESIZE)"
/>
 <input type="hidden" name="s${SEQNUM}_maxfilesize" value="$Encoder.attributeEscape($MAXFILESIZE)"
/>
 <input type="hidden" name="s${SEQNUM}_mimetypes" value="$Encoder.attributeEscape($MIMETYPES)"
/>
 <input type="hidden" name="s${SEQNUM}_extensions" value="$Encoder.attributeEscape($EXTENSIONS)"
/>

Modified: manifoldcf/trunk/connectors/documentfilter/connector/src/main/resources/org/apache/manifoldcf/agents/transformation/documentfilter/viewSpecification.html
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/documentfilter/connector/src/main/resources/org/apache/manifoldcf/agents/transformation/documentfilter/viewSpecification.html?rev=1620748&r1=1620747&r2=1620748&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/documentfilter/connector/src/main/resources/org/apache/manifoldcf/agents/transformation/documentfilter/viewSpecification.html
(original)
+++ manifoldcf/trunk/connectors/documentfilter/connector/src/main/resources/org/apache/manifoldcf/agents/transformation/documentfilter/viewSpecification.html
Tue Aug 26 21:54:40 2014
@@ -17,6 +17,10 @@
 
 <table class="displaytable">
   <tr>
+    <td class="description"><nobr>$Encoder.bodyEscape($ResourceBundle.getString('DocumentFilter.MinFileSizeBytesColon'))</nobr></td>
+    <td class="value">$Encoder.bodyEscape($MINFILESIZE)</td>
+  </tr>
+  <tr>
     <td class="description"><nobr>$Encoder.bodyEscape($ResourceBundle.getString('DocumentFilter.MaxFileSizeBytesColon'))</nobr></td>
     <td class="value">$Encoder.bodyEscape($MAXFILESIZE)</td>
   </tr>



Mime
View raw message