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/06/18 04:06:00 UTC
svn commit: r1137115 - in /oodt/trunk: ./
filemgr/src/main/java/org/apache/oodt/cas/filemgr/metadata/extractors/examples/
filemgr/src/test/org/apache/oodt/cas/filemgr/metadata/extractors/examples/
Author: mattmann
Date: Sat Jun 18 02:06:00 2011
New Revision: 1137115
URL: http://svn.apache.org/viewvc?rev=1137115&view=rev
Log:
- fix for OODT-200 FinalFileLocationExtractor chokes on Hierarchical products
Modified:
oodt/trunk/CHANGES.txt
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/metadata/extractors/examples/FinalFileLocationExtractor.java
oodt/trunk/filemgr/src/test/org/apache/oodt/cas/filemgr/metadata/extractors/examples/TestFinalFileLocationExtractor.java
Modified: oodt/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1137115&r1=1137114&r2=1137115&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Sat Jun 18 02:06:00 2011
@@ -4,6 +4,9 @@ Apache OODT Change Log
Release 0.3-SNAPSHOT (in progress)
--------------------------------------------
+* OODT-200 FinalFileLocationExtractor chokes on Hierarchical products
+ (mattmann)
+
* OODT-186 Common base library for modular OODT web applications built
using PHP (ahart, Gabe Resneck, Shakeh Khudikyan)
Modified: oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/metadata/extractors/examples/FinalFileLocationExtractor.java
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/metadata/extractors/examples/FinalFileLocationExtractor.java?rev=1137115&r1=1137114&r2=1137115&view=diff
==============================================================================
--- oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/metadata/extractors/examples/FinalFileLocationExtractor.java (original)
+++ oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/metadata/extractors/examples/FinalFileLocationExtractor.java Sat Jun 18 02:06:00 2011
@@ -83,33 +83,28 @@ public class FinalFileLocationExtractor
"Unable to generate final FileLocation: Reason: " + e.getMessage());
}
- if (product.getProductStructure().equals(Product.STRUCTURE_FLAT)) {
- Reference r = product.getProductReferences().get(0);
- String finalLocation = VersioningUtils.getAbsolutePathFromUri(r
- .getDataStoreReference());
- if (this.replaceLocation) {
- extractMet.replaceMetadata(FILE_LOCATION, new File(finalLocation)
- .getParent());
- } else {
- extractMet.addMetadata(FILE_LOCATION, new File(finalLocation)
- .getParent());
- }
-
- } else
- throw new MetExtractionException(
- "Unable to extract final file location from "
- + Product.STRUCTURE_HIERARCHICAL + " products!");
-
+ Reference r = product.getProductReferences().get(0);
+ String finalLocation = VersioningUtils.getAbsolutePathFromUri(r
+ .getDataStoreReference());
+ if (this.replaceLocation) {
+ extractMet.replaceMetadata(FILE_LOCATION,
+ new File(finalLocation).getParent());
+ } else {
+ extractMet
+ .addMetadata(FILE_LOCATION, new File(finalLocation).getParent());
+ }
+
this.scrubRefs(product);
-
+
return extractMet;
}
-
- private void scrubRefs(Product p){
- if(p.getProductReferences() == null) return;
-
- for(Reference r: p.getProductReferences()){
+
+ private void scrubRefs(Product p) {
+ if (p.getProductReferences() == null)
+ return;
+
+ for (Reference r : p.getProductReferences()) {
r.setDataStoreReference("");
}
}
Modified: oodt/trunk/filemgr/src/test/org/apache/oodt/cas/filemgr/metadata/extractors/examples/TestFinalFileLocationExtractor.java
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/test/org/apache/oodt/cas/filemgr/metadata/extractors/examples/TestFinalFileLocationExtractor.java?rev=1137115&r1=1137114&r2=1137115&view=diff
==============================================================================
--- oodt/trunk/filemgr/src/test/org/apache/oodt/cas/filemgr/metadata/extractors/examples/TestFinalFileLocationExtractor.java (original)
+++ oodt/trunk/filemgr/src/test/org/apache/oodt/cas/filemgr/metadata/extractors/examples/TestFinalFileLocationExtractor.java Sat Jun 18 02:06:00 2011
@@ -69,8 +69,8 @@ public class TestFinalFileLocationExtrac
assertEquals("expected final location: [" + expectedFinalLocation
+ "] is not equal to generated location: ["
+ extractMet.getAllMetadata(CoreMetKeys.FILE_LOCATION).get(1) + "]",
- expectedFinalLocation, extractMet.getAllMetadata(
- CoreMetKeys.FILE_LOCATION).get(1));
+ expectedFinalLocation,
+ extractMet.getAllMetadata(CoreMetKeys.FILE_LOCATION).get(1));
// ensure that the data store ref is blank
assertEquals("", p.getProductReferences().get(0).getDataStoreReference());
@@ -88,8 +88,73 @@ public class TestFinalFileLocationExtrac
assertNotNull(extractMet);
assertTrue(extractMet.containsKey(CoreMetKeys.FILE_LOCATION));
assertEquals(1, extractMet.getAllMetadata(CoreMetKeys.FILE_LOCATION).size());
- assertEquals(expectedFinalLocation, extractMet
- .getMetadata(CoreMetKeys.FILE_LOCATION));
+ assertEquals(expectedFinalLocation,
+ extractMet.getMetadata(CoreMetKeys.FILE_LOCATION));
+
+ // ensure that the data store ref is blank
+ assertEquals("", p.getProductReferences().get(0).getDataStoreReference());
+
+ }
+
+ /**
+ * @since OODT-200
+ */
+ public void testExtractHierarchical() {
+ String expectedFinalLocation = "/archive/dirs";
+ Product p = Product.getDefaultFlatProduct("test", "urn:oodt:GenericFile");
+ p.setProductStructure(Product.STRUCTURE_HIERARCHICAL);
+ p.setProductName("somedir");
+ p.getProductType().setProductRepositoryPath("file:///archive/dirs");
+ p.getProductType().setVersioner(
+ "org.apache.oodt.cas.filemgr.versioning.DirectoryProductVersioner");
+ p.getProductReferences()
+ .add(new Reference("file:///tmp/somedir", null, 4L));
+ p.getProductReferences().add(
+ new Reference("file:///tmp/somedir/file1.txt", null, 8L));
+ p.getProductReferences().add(
+ new Reference("file:///tmp/somedir/file2.txt", null, 8L));
+ Properties config = new Properties();
+ config.setProperty("replace", "false");
+ Metadata met = new Metadata();
+ met.addMetadata(CoreMetKeys.FILE_LOCATION, "/tmp");
+ FinalFileLocationExtractor extractor = new FinalFileLocationExtractor();
+ extractor.configure(config);
+ Metadata extractMet = new Metadata();
+
+ try {
+ extractMet = extractor.doExtract(p, met);
+ } catch (MetExtractionException e) {
+ fail(e.getMessage());
+ }
+
+ assertNotNull(extractMet);
+ assertTrue(extractMet.containsKey(CoreMetKeys.FILE_LOCATION));
+ assertEquals(2, extractMet.getAllMetadata(CoreMetKeys.FILE_LOCATION).size());
+ assertEquals("/tmp", extractMet.getMetadata(CoreMetKeys.FILE_LOCATION));
+ assertEquals("expected final location: [" + expectedFinalLocation
+ + "] is not equal to generated location: ["
+ + extractMet.getAllMetadata(CoreMetKeys.FILE_LOCATION).get(1) + "]",
+ expectedFinalLocation,
+ extractMet.getAllMetadata(CoreMetKeys.FILE_LOCATION).get(1));
+
+ // ensure that the data store ref is blank
+ assertEquals("", p.getProductReferences().get(0).getDataStoreReference());
+
+ // reconfigure to replace
+ config.setProperty("replace", "true");
+ extractor.configure(config);
+
+ try {
+ extractMet = extractor.doExtract(p, met);
+ } catch (MetExtractionException e) {
+ fail(e.getMessage());
+ }
+
+ assertNotNull(extractMet);
+ assertTrue(extractMet.containsKey(CoreMetKeys.FILE_LOCATION));
+ assertEquals(1, extractMet.getAllMetadata(CoreMetKeys.FILE_LOCATION).size());
+ assertEquals(expectedFinalLocation,
+ extractMet.getMetadata(CoreMetKeys.FILE_LOCATION));
// ensure that the data store ref is blank
assertEquals("", p.getProductReferences().get(0).getDataStoreReference());