manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1439213 - /manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java
Date Mon, 28 Jan 2013 00:21:13 GMT
Author: kwright
Date: Mon Jan 28 00:21:13 2013
New Revision: 1439213

URL: http://svn.apache.org/viewvc?rev=1439213&view=rev
Log:
Add API support for forced metadata.

Modified:
    manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java?rev=1439213&r1=1439212&r2=1439213&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java
(original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java
Mon Jan 28 00:21:13 2013
@@ -2613,7 +2613,10 @@ public class ManifoldCF extends org.apac
   protected static final String JOBNODE_HOUROFDAY = "hourofday";
   protected static final String JOBNODE_MINUTESOFHOUR = "minutesofhour";
   protected static final String JOBNODE_ENUMVALUE = "value";
-  
+  protected static final String JOBNODE_FORCEDPARAM = "forcedparam";
+  protected static final String JOBNODE_PARAMNAME = "paramname";
+  protected static final String JOBNODE_PARAMVALUE = "paramvalue";
+
   /** Convert a node into a job description.
   *@param jobDescription is the job to be filled in.
   *@param jobNode is the configuration node corresponding to the whole job itself.
@@ -2727,6 +2730,27 @@ public class ManifoldCF extends org.apac
           throw new ManifoldCFException("Missing required field: '"+JOBNODE_COUNT+"'");
         jobDescription.addHopCountFilter(linkType,new Long(hopCount));
       }
+      else if (childType.equals(JOBNODE_FORCEDPARAM))
+      {
+        // Read the forced parameter values
+        String paramName = null;
+        String paramValue = null;
+        for (int q = 0; q < child.getChildCount(); q++)
+        {
+          ConfigurationNode cn = child.findChild(q);
+          if (cn.getType().equals(JOBNODE_PARAMNAME))
+            paramName = cn.getValue();
+          else if (cn.getType().equals(JOBNODE_PARAMVALUE))
+            paramValue = cn.getValue();
+          else
+            throw new ManifoldCFException("Found an unexpected node type: '"+cn.getType()+"'");
+        }
+        if (paramName == null)
+          throw new ManifoldCFException("Missing required field: '"+JOBNODE_PARAMNAME+"'");
+        if (paramValue == null)
+          throw new ManifoldCFException("Missing required field: '"+JOBNODE_PARAMVALUE+"'");
+        jobDescription.addForcedMetadataValue(paramName,paramValue);
+      }
       else if (childType.equals(JOBNODE_SCHEDULE))
       {
         // Create a schedule record.
@@ -2904,6 +2928,25 @@ public class ManifoldCF extends org.apac
       jobNode.addChild(jobNode.getChildCount(),child);
     }
     
+    // Forced metadata records
+    Map<String,Set<String>> forcedMetadata = job.getForcedMetadata();
+    for (String paramName : forcedMetadata.keySet())
+    {
+      Set<String> values = forcedMetadata.get(paramName);
+      for (String paramValue : values)
+      {
+        child = new ConfigurationNode(JOBNODE_FORCEDPARAM);
+        ConfigurationNode cn;
+        cn = new ConfigurationNode(JOBNODE_PARAMNAME);
+        cn.setValue(paramName);
+        child.addChild(child.getChildCount(),cn);
+        cn = new ConfigurationNode(JOBNODE_PARAMVALUE);
+        cn.setValue(paramValue);
+        child.addChild(child.getChildCount(),cn);
+        jobNode.addChild(jobNode.getChildCount(),child);
+      }
+    }
+    
     // Schedule records
     j = 0;
     while (j < job.getScheduleRecordCount())



Mime
View raw message