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/05/03 23:31:14 UTC
svn commit: r1099268 - in /oodt/trunk: CHANGES.txt
metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/EndsWithComparator.java
metadata/src/main/resources/examples/met_extr_preconditions.xml
Author: mattmann
Date: Tue May 3 21:31:14 2011
New Revision: 1099268
URL: http://svn.apache.org/viewvc?rev=1099268&view=rev
Log:
- fix for OODT-188 Precondition Comparator to ignore files with a particular extension
Added:
oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/EndsWithComparator.java
Modified:
oodt/trunk/CHANGES.txt
oodt/trunk/metadata/src/main/resources/examples/met_extr_preconditions.xml
Modified: oodt/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1099268&r1=1099267&r2=1099268&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Tue May 3 21:31:14 2011
@@ -4,6 +4,9 @@ Apache OODT Change Log
Release 0.3-SNAPSHOT (in progress)
--------------------------------------------
+* OODT-188 Precondition Comparator to ignore files with
+ a particular extension (mattmann)
+
* OODT-129 Integrate with Maven Central (mattmann)
* OODT-177 PHP implementation of sso (ahart)
Added: oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/EndsWithComparator.java
URL: http://svn.apache.org/viewvc/oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/EndsWithComparator.java?rev=1099268&view=auto
==============================================================================
--- oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/EndsWithComparator.java (added)
+++ oodt/trunk/metadata/src/main/java/org/apache/oodt/cas/metadata/preconditions/EndsWithComparator.java Tue May 3 21:31:14 2011
@@ -0,0 +1,52 @@
+/**
+ * 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.metadata.preconditions;
+
+//JDK imports
+import java.io.File;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.exceptions.PreconditionComparatorException;
+import org.apache.oodt.cas.metadata.preconditions.PreConditionComparator;
+
+/**
+ *
+ * A {@link PreConditionComparator} that checks a file's extension and then
+ * skips extracting metadata from files that don't match this extension.
+ *
+ * @author mattmann
+ * @version $Revision$
+ *
+ */
+public class EndsWithComparator extends PreConditionComparator<String> {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.oodt.cas.metadata.preconditions.PreConditionComparator#performCheck
+ * (java.io.File, java.lang.Object)
+ */
+ @Override
+ protected int performCheck(File file, String ext)
+ throws PreconditionComparatorException {
+ return file.getName().substring(file.getName().lastIndexOf(".") + 1)
+ .compareTo(ext);
+ }
+
+}
Modified: oodt/trunk/metadata/src/main/resources/examples/met_extr_preconditions.xml
URL: http://svn.apache.org/viewvc/oodt/trunk/metadata/src/main/resources/examples/met_extr_preconditions.xml?rev=1099268&r1=1099267&r2=1099268&view=diff
==============================================================================
--- oodt/trunk/metadata/src/main/resources/examples/met_extr_preconditions.xml (original)
+++ oodt/trunk/metadata/src/main/resources/examples/met_extr_preconditions.xml Tue May 3 21:31:14 2011
@@ -24,6 +24,14 @@ the License.
<!-- Precondition Comparators -->
<bean id="PreconditionComparator" lazy-init="true" abstract="true" class="org.apache.oodt.cas.metadata.preconditions.PreConditionComparator"/>
+ <bean id="OnlyExtractFileType" lazy-init="true" class="org.apache.oodt.cas.metadata.preconditions.EndsWithComparator">
+ <property name="description" value="Checks the file extension and only extracts met from those files."/>
+ <property name="compareItem">
+ <value type="java.lang.String">file_ext</value>
+ </property>
+ <property name="type" value="equal_to"/>
+ </bean>
+
<bean id="CheckThatDataFileSizeIsGreaterThanZero" lazy-init="true" parent="PreconditionComparator" class="org.apache.oodt.cas.metadata.preconditions.FileSizeComparator">
<property name="description" value="Check if the current data file size is greater than zero"/>