You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by bf...@apache.org on 2011/02/18 01:02:13 UTC
svn commit: r1071838 - in /oodt/trunk: ./ crawler/src/main/assembly/
crawler/src/main/java/org/apache/oodt/cas/crawl/action/
crawler/src/main/resources/ crawler/src/main/resources/extern-scripts/
Author: bfoster
Date: Fri Feb 18 00:02:12 2011
New Revision: 1071838
URL: http://svn.apache.org/viewvc?rev=1071838&view=rev
Log:
- added ExternAction for crawler which executes given external command
------------------------
OODT-144
Added:
oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/ExternAction.java (with props)
oodt/trunk/crawler/src/main/resources/extern-scripts/
oodt/trunk/crawler/src/main/resources/extern-scripts/check-exists.sh
Modified:
oodt/trunk/CHANGES.txt
oodt/trunk/crawler/src/main/assembly/assembly.xml
oodt/trunk/crawler/src/main/resources/action-beans.xml
Modified: oodt/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1071838&r1=1071837&r2=1071838&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Fri Feb 18 00:02:12 2011
@@ -4,6 +4,8 @@ Apache OODT Change Log
Release 0.3-SNAPSHOT (in progress)
--------------------------------------------
+* OODT-144 ExternAction for crawler which executes some external command (bfoster)
+
* OODT-143 addition of fmprod context.xml and maven servlet-api
dependency scope change to provider (Shakeh Khudikyan, mattmann)
Modified: oodt/trunk/crawler/src/main/assembly/assembly.xml
URL: http://svn.apache.org/viewvc/oodt/trunk/crawler/src/main/assembly/assembly.xml?rev=1071838&r1=1071837&r2=1071838&view=diff
==============================================================================
--- oodt/trunk/crawler/src/main/assembly/assembly.xml (original)
+++ oodt/trunk/crawler/src/main/assembly/assembly.xml Fri Feb 18 00:02:12 2011
@@ -67,6 +67,11 @@ the License.
<include>*.xml</include>
</includes>
</fileSet>
+ <fileSet>
+ <directory>${basedir}/src/main/resources/extern-scripts</directory>
+ <outputDirectory>policy/extern-scripts</outputDirectory>
+ <includes/>
+ </fileSet>
</fileSets>
<dependencySets>
<dependencySet>
Added: oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/ExternAction.java
URL: http://svn.apache.org/viewvc/oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/ExternAction.java?rev=1071838&view=auto
==============================================================================
--- oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/ExternAction.java (added)
+++ oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/ExternAction.java Fri Feb 18 00:02:12 2011
@@ -0,0 +1,65 @@
+/*
+ * 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.logging.Level;
+
+//OODT imports
+import org.apache.oodt.cas.crawl.structs.exceptions.CrawlerActionException;
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.metadata.util.PathUtils;
+import org.apache.oodt.commons.exec.ExecUtils;
+
+/**
+ *
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Execute some external command as a {@link CrawlerAction} reponse
+ * </p>.
+ */
+public class ExternAction extends CrawlerAction {
+
+ private String executeCommand;
+ private String workingDir;
+
+ @Override
+ public boolean performAction(File product, Metadata productMetadata)
+ throws CrawlerActionException {
+ String currentExcecuteCommand = this.executeCommand;
+ try {
+ if (currentExcecuteCommand == null)
+ throw new Exception("Must specify execute command");
+ return ExecUtils.callProgram(currentExcecuteCommand = PathUtils.doDynamicReplacement(currentExcecuteCommand, productMetadata), LOG, new File(workingDir != null ? workingDir : product.getParent())) == 0;
+ }catch (Exception e) {
+ LOG.log(Level.SEVERE, "Failed to execute extern command '" + currentExcecuteCommand + "' : " + e.getMessage(), e);
+ return false;
+ }
+ }
+
+ public void setExecuteCommand(String executeCommand) {
+ this.executeCommand = executeCommand;
+ }
+
+ public void setWorkingDir(String workingDir) throws Exception {
+ this.workingDir = PathUtils.doDynamicReplacement(workingDir);
+ }
+
+}
Propchange: oodt/trunk/crawler/src/main/java/org/apache/oodt/cas/crawl/action/ExternAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: oodt/trunk/crawler/src/main/resources/action-beans.xml
URL: http://svn.apache.org/viewvc/oodt/trunk/crawler/src/main/resources/action-beans.xml?rev=1071838&r1=1071837&r2=1071838&view=diff
==============================================================================
--- oodt/trunk/crawler/src/main/resources/action-beans.xml (original)
+++ oodt/trunk/crawler/src/main/resources/action-beans.xml Fri Feb 18 00:02:12 2011
@@ -119,4 +119,14 @@ the License.
</property>
</bean>
+ <bean id="CheckMetFileExists" lazy-init="true" class="org.apache.oodt.cas.crawl.action.ExternAction">
+ <property name="description" value="Checks if metadata file was created -- make sure check-exists.sh is on your PATH"/>
+ <property name="executeCommand" value="./check-exists.sh [Filename].met"/>
+ <property name="phases">
+ <list>
+ <value type="java.lang.String">preIngest</value>
+ </list>
+ </property>
+ </bean>
+
</beans>
Added: oodt/trunk/crawler/src/main/resources/extern-scripts/check-exists.sh
URL: http://svn.apache.org/viewvc/oodt/trunk/crawler/src/main/resources/extern-scripts/check-exists.sh?rev=1071838&view=auto
==============================================================================
--- oodt/trunk/crawler/src/main/resources/extern-scripts/check-exists.sh (added)
+++ oodt/trunk/crawler/src/main/resources/extern-scripts/check-exists.sh Fri Feb 18 00:02:12 2011
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+if [ ! -f $1 ]; then
+ exit 1
+fi