Author: goodale
Date: Wed Aug 29 15:38:26 2012
New Revision: 1378613

URL: http://svn.apache.org/viewvc?rev=1378613&view=rev
Log:
OODT-487 MetadataBasedProductMover to handle when the source and destinations 
match

Modified:
    oodt/trunk/CHANGES.txt
    
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataBasedProductMover.java

Modified: oodt/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1378613&r1=1378612&r2=1378613&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Wed Aug 29 15:38:26 2012
@@ -3,6 +3,8 @@ Apache OODT Change Log
 
 Release 0.5
 --------------------------------------------
+* OODT-487: MetadataBasedProductMover to handle when the source and 
destinations match (cgoodale)
+
 * OODT-488: Enhanced Solr Indexer capabilities (pramirez)
 
 * OODT-390: Removal of optimize call in Lucene Workflow Instance Repository 
(pramirez)

Modified: 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataBasedProductMover.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataBasedProductMover.java?rev=1378613&r1=1378612&r2=1378613&view=diff
==============================================================================
--- 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataBasedProductMover.java
 (original)
+++ 
oodt/trunk/filemgr/src/main/java/org/apache/oodt/cas/filemgr/tools/MetadataBasedProductMover.java
 Wed Aug 29 15:38:26 2012
@@ -99,7 +99,12 @@ public class MetadataBasedProductMover {
                     Reference r = ((Reference) 
p.getProductReferences().get(0));
                     String newLocPath = PathUtils.replaceEnvVariables(
                             this.pathSpec, met);
-
+                    
+                    if (locationsMatch(r.getDataStoreReference(), newLocPath)) 
{
+                       LOG.log(Level.INFO, "Current and New locations match. 
"+p.getProductName()+" was not moved.");
+                       continue;
+                    }
+                    
                     LOG.log(Level.INFO, "Moving product: ["
                             + p.getProductName() + "] from: ["
                             + new File(new URI(r.getDataStoreReference()))
@@ -120,6 +125,19 @@ public class MetadataBasedProductMover {
         }
     }
 
+    private boolean locationsMatch(String currentLocation, String newLocation) 
throws java.net.URISyntaxException {
+       String currentLocationURI = new 
URI(currentLocation).getSchemeSpecificPart();
+       String newLocationURI = new URI(newLocation).getSchemeSpecificPart();
+
+       if (currentLocationURI.equals(newLocationURI)) {
+               return true;
+       }
+       else {
+               return false;
+       }
+       
+    }
+    
     public void moveProducts(String typeName) throws Exception {
         moveProducts(fmgrClient.getProductTypeByName(typeName));
     }


Reply via email to