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/03/19 22:11:12 UTC
svn commit: r1083288 - in /oodt/trunk: CHANGES.txt
filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/DirectoryProductVersioner.java
filemgr/src/test/org/apache/oodt/cas/filemgr/versioning/TestDirectoryBasedProductVersioner.java
Author: mattmann
Date: Sat Mar 19 21:11:12 2011
New Revision: 1083288
URL: http://svn.apache.org/viewvc?rev=1083288&view=rev
Log:
- fix for OODT-163 DirectoryProduct Versioner for the File Manager
Added:
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/DirectoryProductVersioner.java
oodt/trunk/filemgr/src/test/org/apache/oodt/cas/filemgr/versioning/TestDirectoryBasedProductVersioner.java
Modified:
oodt/trunk/CHANGES.txt
Modified: oodt/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1083288&r1=1083287&r2=1083288&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Sat Mar 19 21:11:12 2011
@@ -4,6 +4,8 @@ Apache OODT Change Log
Release 0.3-SNAPSHOT (in progress)
--------------------------------------------
+* OODT-163 DirectoryProduct Versioner for the File Manager (mattmann)
+
* OODT-160 Allow number of session protocol connections in
pushpull to be configurable for each site (bfoster)
Added: oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/DirectoryProductVersioner.java
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/DirectoryProductVersioner.java?rev=1083288&view=auto
==============================================================================
--- oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/DirectoryProductVersioner.java (added)
+++ oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/versioning/DirectoryProductVersioner.java Sat Mar 19 21:11:12 2011
@@ -0,0 +1,68 @@
+/**
+ * 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.filemgr.versioning;
+
+//OODT imports
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.structs.Reference;
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.filemgr.structs.exceptions.VersioningException;
+import org.apache.oodt.cas.filemgr.versioning.VersioningUtils;
+
+/**
+ * A {@link Versioner} for Hierarchical directory products.
+ *
+ * @author mattmann
+ * @version $Revision$
+ *
+ */
+public class DirectoryProductVersioner extends MetadataBasedFileVersioner {
+
+ /**
+ * <p>
+ * Default constructor
+ * </p>
+ */
+ public DirectoryProductVersioner() {
+ setFlatProducts(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.oodt.cas.filemgr.versioning.MetadataBasedFileVersioner#
+ * createDataStoreReferences(org.apache.oodt.cas.filemgr.structs.Product,
+ * org.apache.oodt.cas.metadata.Metadata)
+ */
+ public void createDataStoreReferences(Product product, Metadata metadata)
+ throws VersioningException {
+ // first generate the first correct reference
+ super.createDataStoreReferences(product, metadata);
+
+ Reference root = (Reference) product.getProductReferences().get(0);
+ if (!root.getDataStoreReference().endsWith("/")) {
+ root.setDataStoreReference(root.getDataStoreReference() + "/");
+ }
+
+ // now add the heirarchical refs
+ VersioningUtils.createBasicDataStoreRefsHierarchical(product
+ .getProductReferences());
+
+ }
+
+}
Added: oodt/trunk/filemgr/src/test/org/apache/oodt/cas/filemgr/versioning/TestDirectoryBasedProductVersioner.java
URL: http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/test/org/apache/oodt/cas/filemgr/versioning/TestDirectoryBasedProductVersioner.java?rev=1083288&view=auto
==============================================================================
--- oodt/trunk/filemgr/src/test/org/apache/oodt/cas/filemgr/versioning/TestDirectoryBasedProductVersioner.java (added)
+++ oodt/trunk/filemgr/src/test/org/apache/oodt/cas/filemgr/versioning/TestDirectoryBasedProductVersioner.java Sat Mar 19 21:11:12 2011
@@ -0,0 +1,73 @@
+/**
+ * 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.filemgr.versioning;
+
+//JDK imports
+import java.io.File;
+
+//OODT imports
+import org.apache.oodt.cas.filemgr.metadata.CoreMetKeys;
+import org.apache.oodt.cas.filemgr.structs.Product;
+import org.apache.oodt.cas.filemgr.structs.Reference;
+import org.apache.oodt.cas.metadata.Metadata;
+
+//Junit imports
+import junit.framework.TestCase;
+
+/**
+ *
+ * Test harness for the {@link DirectoryProductVersioner}.
+ *
+ * @author mattmann
+ * @version $Revision$
+ *
+ */
+public class TestDirectoryBasedProductVersioner extends TestCase {
+
+ public TestDirectoryBasedProductVersioner() {
+ System.setProperty("org.apache.oodt.cas.filemgr.mime.type.repository",
+ new File("./src/main/resources/mime-types.xml").getAbsolutePath());
+ }
+
+ public void testVersioner() {
+ DirectoryProductVersioner versioner = new DirectoryProductVersioner();
+ Product p = Product.getDefaultFlatProduct("test", "urn:oodt:GenericFile");
+ p.getProductType().setProductRepositoryPath("file:///home/files");
+ Reference r = new Reference("file:///tmp/dir1", null, 4L);
+ Reference r2 = new Reference("file:///tmp/dir1/file1.txt", null, 20L);
+ p.getProductReferences().add(r);
+ p.getProductReferences().add(r2);
+ Metadata met = new Metadata();
+ met.addMetadata(CoreMetKeys.FILENAME, "dir1");
+ try {
+ versioner.createDataStoreReferences(p, met);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ assertNotNull(p.getProductReferences());
+ assertEquals(2, p.getProductReferences().size());
+ assertEquals("file:/home/files/dir1/", p.getProductReferences().get(0)
+ .getDataStoreReference());
+ assertEquals("file:/home/files/dir1/file1.txt", p.getProductReferences()
+ .get(1).getDataStoreReference());
+
+ }
+
+}