You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by ma...@apache.org on 2011/10/05 18:32:47 UTC

svn commit: r1179307 - in /oodt/trunk: CHANGES.txt crawler/src/main/java/org/apache/oodt/cas/crawl/action/GroupAction.java

Author: mattmann
Date: Wed Oct  5 16:32:47 2011
New Revision: 1179307

URL: http://svn.apache.org/viewvc?rev=1179307&view=rev
Log:
- fix for OODT-37 Create an Action to Group other Actions Together

Added:
    oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/GroupAction.java   (with props)
Modified:
    oodt/trunk/CHANGES.txt

Modified: oodt/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1179307&r1=1179306&r2=1179307&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Wed Oct  5 16:32:47 2011
@@ -4,6 +4,8 @@ Apache OODT Change Log
 Release 0.4: Current Development
 --------------------------------------------
 
+* OODT-37 Create an Action to Group other Actions Together (pramirez, mattmann)
+
 * OODT-36 Create an Action to Support Simple Branching (pramirez, mattmann)
 
 * OODT-150 ToggleAction addition to crawler (bfoster, mattmann)

Added: oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/GroupAction.java
URL: http://svn.apache.org/viewvc/oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/GroupAction.java?rev=1179307&view=auto
==============================================================================
--- oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/GroupAction.java (added)
+++ oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/GroupAction.java Wed Oct  5 16:32:47 2011
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.cas.crawl.action;
+
+//JDK imports
+import java.io.File;
+import java.util.List;
+
+//OODT imports
+import org.apache.oodt.cas.crawl.action.CrawlerAction;
+import org.apache.oodt.cas.crawl.structs.exceptions.CrawlerActionException;
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * 
+ * 
+ * Support of a GroupAction could go a ways to simplify command line
+ * specification of actions to run. Instead of having to list actions to run one
+ * would simply end up referencing the group. In addition, this may end up
+ * opening up the possibility to customize the behavior of GroupActions such as
+ * not continuing to run actions if one failed. Currently, the crawler continues
+ * executing actions even if an action fails this could be a way to tailor that
+ * behavior.
+ * 
+ */
+public class GroupAction extends CrawlerAction {
+  private List<CrawlerAction> actionsToCall;
+
+  @Override
+  public boolean performAction(File product, Metadata metadata)
+      throws CrawlerActionException {
+    boolean allSucceeded = true;
+    for (CrawlerAction action : actionsToCall) {
+      try {
+        LOG.info("Performing action (id = " + action.getId()
+            + " : description = " + action.getDescription() + ")");
+        if (!action.performAction(product, metadata))
+          throw new Exception("Action (id = " + action.getId()
+              + " : description = " + action.getDescription()
+              + ") returned false");
+      } catch (Exception e) {
+        allSucceeded = false;
+        LOG.warning("Failed to perform crawler action : " + e.getMessage());
+      }
+
+    }
+    return allSucceeded;
+  }
+
+  public void setActionsToCall(List<CrawlerAction> actionsToCall) {
+    this.actionsToCall = actionsToCall;
+  }
+
+}

Propchange: oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/GroupAction.java
------------------------------------------------------------------------------
    svn:executable = *