manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1593197 - /manifoldcf/branches/CONNECTORS-916/connectors/amazoncloudsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/amazoncloudsearch/AmazonCloudSearchConnector.java
Date Thu, 08 May 2014 07:34:32 GMT
Author: kwright
Date: Thu May  8 07:34:32 2014
New Revision: 1593197

URL: http://svn.apache.org/r1593197
Log:
Hook up new structure in actual indexing method

Modified:
    manifoldcf/branches/CONNECTORS-916/connectors/amazoncloudsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/amazoncloudsearch/AmazonCloudSearchConnector.java

Modified: manifoldcf/branches/CONNECTORS-916/connectors/amazoncloudsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/amazoncloudsearch/AmazonCloudSearchConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-916/connectors/amazoncloudsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/amazoncloudsearch/AmazonCloudSearchConnector.java?rev=1593197&r1=1593196&r2=1593197&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-916/connectors/amazoncloudsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/amazoncloudsearch/AmazonCloudSearchConnector.java
(original)
+++ manifoldcf/branches/CONNECTORS-916/connectors/amazoncloudsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/amazoncloudsearch/AmazonCloudSearchConnector.java
Thu May  8 07:34:32 2014
@@ -345,9 +345,7 @@ public class AmazonCloudSearchConnector 
     // Establish a session
     getSession();
     
-    Map<String, List<String>> sourceTargets = new HashMap<String, List<String>>();
-    boolean keepAllMetadata = true;
-    keepAllMetadata = readConfigurationDescription(outputDescription, sourceTargets);
+    SpecPacker sp = new SpecPacker(outputDescription);
     
     String jsondata = "";
     try {
@@ -365,17 +363,14 @@ public class AmazonCloudSearchConnector 
       {
         String fName = itr.next();
         Object[] value = document.getField(fName);
-        if(sourceTargets.get(fName)!=null)
+        String target = sp.getMapping(fName);
+        if(target!=null)
         {
-          List<String> fnameList = sourceTargets.get(fName);
-          for(String newName : fnameList)
-          {
-            fields.put(newName, value);
-          }
+          fields.put(target, value);
         }
         else
         {
-          if(keepAllMetadata)
+          if(sp.keepAllMetadata())
           {
             fields.put(fName, value);
           }
@@ -386,17 +381,14 @@ public class AmazonCloudSearchConnector 
       String[] metaNames = metadata.names();
       for(String mName : metaNames){
         String value = metadata.get(mName);
-        if(sourceTargets.get(mName)!=null)
+        String target = sp.getMapping(mName);
+        if(target!=null)
         {
-          List<String> nameList = sourceTargets.get(mName);
-          for(String newName : nameList)
-          {
-            fields.put(newName, value);
-          }
+          fields.put(target, value);
         }
         else
         {
-          if(keepAllMetadata)
+          if(sp.keepAllMetadata())
           {
             fields.put(mName, value);
           }
@@ -441,49 +433,6 @@ public class AmazonCloudSearchConnector 
     }
   }
 
-  private boolean readConfigurationDescription(String outputDescription,
-      Map<String, List<String>> sourceTargets)
-      throws ManifoldCFException {
-    ObjectMapper mapper = new ObjectMapper();
-    
-    boolean keepAllMetadata = true;
-    try
-    {
-      JsonNode node = mapper.readTree(outputDescription);
-      Iterator<String> ir = node.fieldNames();
-      while(ir.hasNext()){
-        String fieldName = ir.next();
-        if("fieldMappings".equals(fieldName))
-        {
-          JsonNode fm = node.path(fieldName);
-          Iterator<String> itr = fm.fieldNames();
-          while(itr.hasNext())
-          {
-            String from = itr.next();
-            String to = fm.path(from).asText();
-            
-            List<String> list = sourceTargets.get(from);
-            if (list == null) {
-              list = new ArrayList<String>();
-              sourceTargets.put(from, list);
-            }
-            list.add(to);
-          }
-        }
-        else if("keepAllMetadata".equals(fieldName)){
-          String meta = node.path(fieldName).toString();
-          keepAllMetadata = Boolean.getBoolean(meta);
-        }
-      }
-      return keepAllMetadata;
-      
-    } catch (JsonProcessingException e) {
-      throw new ManifoldCFException(e);
-    } catch (IOException e) {
-      throw new ManifoldCFException(e);
-    }
-  }
-
   private Metadata extractBinaryFile(RepositoryDocument document, HashMap fields)
       throws IOException, SAXException, TikaException {
     
@@ -1052,6 +1001,13 @@ public class AmazonCloudSearchConnector 
       return extensions.contains(extension);
     }
     
+    public String getMapping(String source) {
+      return sourceTargets.get(source);
+    }
+    
+    public boolean keepAllMetadata() {
+      return keepAllMetadata;
+    }
   }
   
 }



Mime
View raw message