manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1649795 - in /manifoldcf/branches/dev_1x: ./ connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/ connectors/forcedmetadata/connector/src/test/java/org/apache/manifoldcf/agents/trans...
Date Tue, 06 Jan 2015 12:36:23 GMT
Author: kwright
Date: Tue Jan  6 12:36:22 2015
New Revision: 1649795

URL: http://svn.apache.org/r1649795
Log:
Refactor for clarity

Added:
    manifoldcf/branches/dev_1x/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/FieldDataFactory.java
      - copied unchanged from r1649794, manifoldcf/trunk/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/FieldDataFactory.java
    manifoldcf/branches/dev_1x/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/FieldSource.java
      - copied unchanged from r1649794, manifoldcf/trunk/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/FieldSource.java
    manifoldcf/branches/dev_1x/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/IDataSource.java
      - copied unchanged from r1649794, manifoldcf/trunk/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/IDataSource.java
    manifoldcf/branches/dev_1x/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/StringSource.java
      - copied unchanged from r1649794, manifoldcf/trunk/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/StringSource.java
Modified:
    manifoldcf/branches/dev_1x/   (props changed)
    manifoldcf/branches/dev_1x/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/ForcedMetadataConnector.java
    manifoldcf/branches/dev_1x/connectors/forcedmetadata/connector/src/test/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/ExpressionTest.java

Propchange: manifoldcf/branches/dev_1x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan  6 12:36:22 2015
@@ -121,4 +121,4 @@
 /manifoldcf/branches/CONNECTORS-981:1605049-1605773
 /manifoldcf/branches/CONNECTORS-989:1611600-1612101
 /manifoldcf/branches/CONNECTORS-990:1610284-1610707
-/manifoldcf/trunk:1620703,1620748,1620812,1620862,1621449,1621613,1621855,1622213,1622740,1622850,1622853-1622854,1623249,1623251,1623314,1623599,1623951,1623953-1623954,1623956,1623972,1624058,1624085,1624174,1624236,1624377,1624384,1624399,1624449,1624464,1624504,1624729-1624731,1624906,1624909-1624910,1624982,1625023,1625095,1625103,1625108,1625264,1625270,1625394,1625400,1625910,1626090,1626097,1626102,1626638-1626639,1626973,1627687,1627690,1627959,1628046,1628066,1628106,1628168,1628188,1628699,1628798,1628808,1628845,1628905,1629122,1629374-1629375,1629379,1629541,1629994,1630188,1630535,1630623,1630671,1630812,1630885,1631039,1631162,1631164,1631252,1631750,1631953,1632013,1632225,1632289,1632562,1632844,1632847,1632854,1633062-1633063,1633108,1633193,1633202,1633282,1633284,1633295,1633336,1633339,1633345,1633348,1633364,1633378,1633383,1633432,1633546,1633590,1633634,1633668,1633727,1633760,1633764,1633786,1633910,1633923,1634021,1634028,1634067,1634132,1634145,1634148,163
 4155,1634188,1634202,1634264,1634373,1634530,1634688,1634850,1634857,1635103,1635116,1635421,1635438,1635478,1635481,1635484,1635490,1635809,1635939,1636146,1636167,1636180,1636207,1636215,1636232,1636334,1636519,1636570,1636684,1636940,1637011,1637310,1637350,1637364,1637373,1637378,1639259,1639593,1639600,1640018,1640101,1640199,1640204,1640208,1640314,1640319,1640749,1640772,1640805,1640888,1640925,1640941-1640942,1641222,1641328,1641557,1641559,1641629,1641633,1641724,1641754,1641911,1642163,1642255,1642318,1642531,1642650,1642658,1642673,1642716,1644197,1644399,1644538,1644920,1644931,1646317,1646397,1646403,1646408,1646640,1646947,1647574,1647585,1647608,1648686,1648976,1649201,1649203,1649529,1649605,1649628
+/manifoldcf/trunk:1620703,1620748,1620812,1620862,1621449,1621613,1621855,1622213,1622740,1622850,1622853-1622854,1623249,1623251,1623314,1623599,1623951,1623953-1623954,1623956,1623972,1624058,1624085,1624174,1624236,1624377,1624384,1624399,1624449,1624464,1624504,1624729-1624731,1624906,1624909-1624910,1624982,1625023,1625095,1625103,1625108,1625264,1625270,1625394,1625400,1625910,1626090,1626097,1626102,1626638-1626639,1626973,1627687,1627690,1627959,1628046,1628066,1628106,1628168,1628188,1628699,1628798,1628808,1628845,1628905,1629122,1629374-1629375,1629379,1629541,1629994,1630188,1630535,1630623,1630671,1630812,1630885,1631039,1631162,1631164,1631252,1631750,1631953,1632013,1632225,1632289,1632562,1632844,1632847,1632854,1633062-1633063,1633108,1633193,1633202,1633282,1633284,1633295,1633336,1633339,1633345,1633348,1633364,1633378,1633383,1633432,1633546,1633590,1633634,1633668,1633727,1633760,1633764,1633786,1633910,1633923,1634021,1634028,1634067,1634132,1634145,1634148,163
 4155,1634188,1634202,1634264,1634373,1634530,1634688,1634850,1634857,1635103,1635116,1635421,1635438,1635478,1635481,1635484,1635490,1635809,1635939,1636146,1636167,1636180,1636207,1636215,1636232,1636334,1636519,1636570,1636684,1636940,1637011,1637310,1637350,1637364,1637373,1637378,1639259,1639593,1639600,1640018,1640101,1640199,1640204,1640208,1640314,1640319,1640749,1640772,1640805,1640888,1640925,1640941-1640942,1641222,1641328,1641557,1641559,1641629,1641633,1641724,1641754,1641911,1642163,1642255,1642318,1642531,1642650,1642658,1642673,1642716,1644197,1644399,1644538,1644920,1644931,1646317,1646397,1646403,1646408,1646640,1646947,1647574,1647585,1647608,1648686,1648976,1649201,1649203,1649529,1649605,1649628,1649794

Modified: manifoldcf/branches/dev_1x/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/ForcedMetadataConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/dev_1x/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/ForcedMetadataConnector.java?rev=1649795&r1=1649794&r2=1649795&view=diff
==============================================================================
--- manifoldcf/branches/dev_1x/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/ForcedMetadataConnector.java
(original)
+++ manifoldcf/branches/dev_1x/connectors/forcedmetadata/connector/src/main/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/ForcedMetadataConnector.java
Tue Jan  6 12:36:22 2015
@@ -629,70 +629,6 @@ public class ForcedMetadataConnector ext
     return input;
   }
   
-  public interface IDataSource {
-    public int getSize() throws IOException, ManifoldCFException;
-    public Object[] getRawForm() throws IOException, ManifoldCFException;
-    public String[] getStringForm() throws IOException, ManifoldCFException;
-  }
-  
-  protected static class StringSource implements IDataSource {
-    protected final String[] data;
-    
-    public StringSource(String data) {
-      this.data = new String[]{data};
-    }
-    
-    public StringSource(String[] data) {
-      this.data = data;
-    }
-    
-    @Override
-    public int getSize() {
-      return data.length;
-    }
-    
-    @Override
-    public Object[] getRawForm() {
-      return data;
-    }
-    
-    @Override
-    public String[] getStringForm() {
-      return data;
-    }
-  }
-  
-  protected static class FieldSource implements IDataSource {
-    
-    protected final FieldDataFactory rd;
-    protected final String fieldName;
-    
-    public FieldSource(FieldDataFactory rd, String fieldName) {
-      this.rd = rd;
-      this.fieldName = fieldName;
-    }
-    
-    @Override
-    public int getSize()
-      throws IOException, ManifoldCFException {
-      Object[] rawForm = getRawForm();
-      if (rawForm == null)
-        return 0;
-      return rawForm.length;
-    }
-    
-    @Override
-    public Object[] getRawForm()
-      throws IOException, ManifoldCFException {
-      return rd.getField(fieldName);
-    }
-    
-    @Override
-    public String[] getStringForm()
-      throws IOException, ManifoldCFException {
-      return rd.getFieldAsStrings(fieldName);
-    }
-  }
   
   protected static IDataSource append(IDataSource currentValues, IDataSource data)
     throws IOException, ManifoldCFException {
@@ -874,117 +810,6 @@ public class ForcedMetadataConnector ext
     }
   }
   
-  /** This class provides unique Reader and other field instances, when requested, based
-  * on an input RepositoryDocument.  It does this by pulling the values of the field into
-  * a CharacterInput implementation, thus making a temporary file copy.  So it is imperative
-  * that this object is closed when it is no longer needed.
-  */
-  public static class FieldDataFactory {
-    
-    protected final RepositoryDocument sourceDocument;
-    
-    // Readers (organized by metadata)
-    protected final Map<String,CharacterInput[]> metadataReaders = new HashMap<String,CharacterInput[]>();
-
-    public FieldDataFactory(RepositoryDocument sourceDocument) {
-      this.sourceDocument = sourceDocument;
-    }
-    
-    public void close()
-      throws ManifoldCFException
-    {
-      for (String key : metadataReaders.keySet())
-      {
-        CharacterInput[] rt = metadataReaders.get(key);
-        for (CharacterInput r : rt)
-        {
-          r.discard();
-        }
-      }
-    }
-    
-    public Object[] getField(String fieldName)
-      throws IOException, ManifoldCFException {
-      CharacterInput[] inputs = metadataReaders.get(fieldName);
-      if (inputs == null) {
-        // Either never seen the field before, or it's not a Reader
-        Object[] fieldValues = sourceDocument.getField(fieldName);
-        if (fieldValues == null)
-          return fieldValues;
-        if (fieldValues instanceof Reader[]) {
-          // Create a copy
-          CharacterInput[] newValues = new CharacterInput[fieldValues.length];
-          try {
-            // Populate newValues
-            for (int i = 0; i < newValues.length; i++)
-            {
-              newValues[i] = new TempFileCharacterInput((Reader)fieldValues[i]);
-            }
-            metadataReaders.put(fieldName,newValues);
-            inputs = newValues;
-          } catch (Throwable e) {
-            for (CharacterInput r : newValues)
-            {
-              if (r != null)
-                r.discard();
-            }
-            if (e instanceof IOException)
-              throw (IOException)e;
-            else if (e instanceof RuntimeException)
-              throw (RuntimeException)e;
-            else if (e instanceof Error)
-              throw (Error)e;
-            else
-              throw new RuntimeException("Unknown exception type: "+e.getClass().getName()+":
"+e.getMessage(),e);
-          }
-        } else {
-          return fieldValues;
-        }
-      }
-        
-      Reader[] newReaders = new Reader[inputs.length];
-      for (int i = 0; i < inputs.length; i++)
-      {
-        inputs[i].doneWithStream();
-        newReaders[i] = inputs[i].getStream();
-      }
-      return newReaders;
-    }
-    
-    public String[] getFieldAsStrings(String fieldName)
-      throws IOException, ManifoldCFException {
-      CharacterInput[] cilist = metadataReaders.get(fieldName);
-      if (cilist == null)
-        return sourceDocument.getFieldAsStrings(fieldName);
-      
-      // We've created a local array of CharacterInputs from this field.  We'll need to convert
these
-      // to strings.
-      char[] buffer = new char[65536];
-      String[] rval = new String[cilist.length];
-      for (int i = 0; i < rval.length; i++) {
-        CharacterInput ci = cilist[i];
-        ci.doneWithStream();
-        Reader r = ci.getStream();
-        // Read into a buffer
-        StringBuilder newValue = new StringBuilder();
-        while (true)
-        {
-          int amt = r.read(buffer);
-          if (amt == -1)
-            break;
-          newValue.append(buffer,0,amt);
-        }
-        rval[i] = newValue.toString();
-      }
-      sourceDocument.addField(fieldName,rval);
-      metadataReaders.remove(fieldName);
-      for (CharacterInput ci : cilist) {
-        ci.discard();
-      }
-      return rval;
-    }
-  }
-  
 }
 
 

Modified: manifoldcf/branches/dev_1x/connectors/forcedmetadata/connector/src/test/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/ExpressionTest.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/dev_1x/connectors/forcedmetadata/connector/src/test/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/ExpressionTest.java?rev=1649795&r1=1649794&r2=1649795&view=diff
==============================================================================
--- manifoldcf/branches/dev_1x/connectors/forcedmetadata/connector/src/test/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/ExpressionTest.java
(original)
+++ manifoldcf/branches/dev_1x/connectors/forcedmetadata/connector/src/test/java/org/apache/manifoldcf/agents/transformation/forcedmetadata/ExpressionTest.java
Tue Jan  6 12:36:22 2015
@@ -36,7 +36,7 @@ public class ExpressionTest
     inputDoc.addField("stringfield",new String[]{"stringa","stringb","stringc"});
     inputDoc.addField("readerfield",new Reader[]{new StringReader("readera"),new StringReader("readerb")});
     inputDoc.addField("datefield",new Date[]{new Date(0L), new Date(100000000L)});
-    ForcedMetadataConnector.FieldDataFactory fdf = new ForcedMetadataConnector.FieldDataFactory(inputDoc);
+    FieldDataFactory fdf = new FieldDataFactory(inputDoc);
     try {
       arrayEquals(new String[]{"stringa","stringb","stringc"}, (String[])(ForcedMetadataConnector.processExpression("${stringfield}",
fdf).getRawForm()));
       arrayEquals(new String[]{"prefixstringapostfix","prefixstringbpostfix","prefixstringcpostfix"},
(String[])(ForcedMetadataConnector.processExpression("prefix${stringfield}postfix", fdf).getRawForm()));



Mime
View raw message