Author: bfoster
Date: Fri Oct 10 08:07:00 2014
New Revision: 1630710

URL: http://svn.apache.org/r1630710
Log:
- Allow for pushpull fileretriction parsered metadata to be used in renaming 
convention
-----------
OODT-760

Modified:
    
oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/renamingconventions/RenamingConvention.java
    
oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/FileRetrievalSystem.java
    oodt/trunk/pushpull/src/main/resources/push_pull_framework.properties

Modified: 
oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/renamingconventions/RenamingConvention.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/renamingconventions/RenamingConvention.java?rev=1630710&r1=1630709&r2=1630710&view=diff
==============================================================================
--- 
oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/renamingconventions/RenamingConvention.java
 (original)
+++ 
oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/renamingconventions/RenamingConvention.java
 Fri Oct 10 08:07:00 2014
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-
 package org.apache.oodt.cas.pushpull.filerestrictions.renamingconventions;
 
 //JDK imports
@@ -26,8 +25,7 @@ import java.util.regex.Pattern;
 
 //OODT imports
 import org.apache.oodt.cas.metadata.util.PathUtils;
-import org.apache.oodt.cas.protocol.ProtocolFile;
-import org.apache.oodt.cas.pushpull.protocol.RemoteSiteFile;
+import org.apache.oodt.cas.pushpull.retrievalsystem.RemoteFile;
 
 /**
  * 
@@ -53,26 +51,27 @@ public class RenamingConvention {
      *            The file for which a unique name will be generated
      * @return The unique file name (just the name).
      */
-    public static String rename(RemoteSiteFile fileToGenNewNameFor,
+    public static String rename(RemoteFile fileToGenNewNameFor,
             String renamingString) {
        try {
            renamingString = grepReplace(renamingString, fileToGenNewNameFor);
            renamingString = grepRemoveReplace(renamingString, 
fileToGenNewNameFor);
                renamingString = replace(renamingString, "[FILENAME]",
-                       fileToGenNewNameFor.getName());
+                       fileToGenNewNameFor.getProtocolFile().getName());
                renamingString = replace(renamingString, "[PATH_NO_FILENAME]",
                        getParentPath(fileToGenNewNameFor));
                renamingString = replace(renamingString, "[HOST]", 
fileToGenNewNameFor
-                       .getSite().getURL().getHost());
+                       .getProtocolFile().getSite().getURL().getHost());
                renamingString = replace(renamingString, "[PARENT_FILENAME]",
                        getParentFileName(fileToGenNewNameFor));
                renamingString = replace(renamingString, 
"[PARENT_PATH_NO_FILENAME]",
                        getGrandParentPath(fileToGenNewNameFor));
                renamingString = replace(renamingString, "[URL]", 
fileToGenNewNameFor
-                       .getSite().getURL().toExternalForm());
+                       .getProtocolFile().getSite().getURL().toExternalForm());
                renamingString = replace(renamingString, "[IS_DIR]", String
-                       .valueOf(fileToGenNewNameFor.isDir()));
-               renamingString = PathUtils.doDynamicReplacement(renamingString);
+                       
.valueOf(fileToGenNewNameFor.getProtocolFile().isDir()));
+               renamingString = PathUtils.doDynamicReplacement(
+                   renamingString, fileToGenNewNameFor.getAllMetadata());
        }catch (Exception e) {
                LOG.log(Level.WARNING, "Failed to rename " + 
fileToGenNewNameFor 
                                + " : " + e.getMessage());
@@ -80,8 +79,7 @@ public class RenamingConvention {
         return renamingString;
     }
 
-    private static String grepReplace(String theString,
-            RemoteSiteFile fileToGenNewNameFor) {
+    private static String grepReplace(String theString, RemoteFile 
fileToGenNewNameFor) {
         Pattern grepPattern = Pattern.compile("\\[GREP\\(.*\\,.*\\)\\]");
         Matcher grepMatcher = grepPattern.matcher(theString);
         while (grepMatcher.find()) {
@@ -104,8 +102,7 @@ public class RenamingConvention {
         return theString;
     }
 
-    private static String grepRemoveReplace(String theString,
-            RemoteSiteFile fileToGenNewNameFor) {
+    private static String grepRemoveReplace(String theString, RemoteFile 
fileToGenNewNameFor) {
         Pattern grepPattern = Pattern.compile("\\[GREP_RM\\(.*,.*\\)\\]");
         Matcher grepMatcher = grepPattern.matcher(theString);
         while (grepMatcher.find()) {
@@ -138,28 +135,28 @@ public class RenamingConvention {
         return theString.replace(theValueToBeReplaced, whatToReplaceWith);
     }
 
-    private static String getParentPath(ProtocolFile fileToGenNewNameFor) {
+    private static String getParentPath(RemoteFile fileToGenNewNameFor) {
         String parentPath = "";
         try {
-            parentPath = fileToGenNewNameFor.getParent().getPath();
+            parentPath = 
fileToGenNewNameFor.getProtocolFile().getParent().getPath();
         } catch (Exception e) {
         }
         return parentPath;
     }
 
-    private static String getParentFileName(ProtocolFile fileToGenNewNameFor) {
+    private static String getParentFileName(RemoteFile fileToGenNewNameFor) {
         String parentFileName = "";
         try {
-            parentFileName = fileToGenNewNameFor.getParent().getName();
+            parentFileName = 
fileToGenNewNameFor.getProtocolFile().getParent().getName();
         } catch (Exception e) {
         }
         return parentFileName;
     }
 
-    private static String getGrandParentPath(ProtocolFile fileToGenNewNameFor) 
{
+    private static String getGrandParentPath(RemoteFile fileToGenNewNameFor) {
         String grandParentPath = "";
         try {
-            grandParentPath = fileToGenNewNameFor.getParent()
+            grandParentPath = fileToGenNewNameFor.getProtocolFile().getParent()
                     .getParent().getPath();
         } catch (Exception e) {
         }

Modified: 
oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/FileRetrievalSystem.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/FileRetrievalSystem.java?rev=1630710&r1=1630709&r2=1630710&view=diff
==============================================================================
--- 
oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/FileRetrievalSystem.java
 (original)
+++ 
oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/retrievalsystem/FileRetrievalSystem.java
 Fri Oct 10 08:07:00 2014
@@ -467,7 +467,7 @@ public class FileRetrievalSystem {
         remoteFile.addMetadata(RemoteFile.DOWNLOAD_TO_DIR, 
downloadToDir.getAbsolutePath());
 
        if (remoteFile.getMetadata(RemoteFile.PRODUCT_NAME_GENERATOR) != null) {
-               remoteFile.addMetadata(RemoteFile.PRODUCT_NAME, 
RenamingConvention.rename(remoteFile.getProtocolFile(), 
remoteFile.getMetadata(RemoteFile.PRODUCT_NAME_GENERATOR)));
+               remoteFile.addMetadata(RemoteFile.PRODUCT_NAME, 
RenamingConvention.rename(remoteFile, 
remoteFile.getMetadata(RemoteFile.PRODUCT_NAME_GENERATOR)));
        }else {
                remoteFile.setUniqueMetadataElement(uniqueMetadataElement == 
null ? RemoteFile.FILENAME : uniqueMetadataElement);
        }
@@ -568,8 +568,7 @@ public class FileRetrievalSystem {
             File newFile = new File(remoteFile
                     .getMetadata(RemoteFile.DOWNLOAD_TO_DIR)
                     + "/"
-                    + RenamingConvention.rename(remoteFile.getProtocolFile(),
-                            renamingString));
+                    + RenamingConvention.rename(remoteFile, renamingString));
             if (!newFile.getParentFile().equals(
                     remoteFile.getMetadata(RemoteFile.DOWNLOAD_TO_DIR)))
                 newFile.getParentFile().mkdirs();

Modified: oodt/trunk/pushpull/src/main/resources/push_pull_framework.properties
URL: 
http://svn.apache.org/viewvc/oodt/trunk/pushpull/src/main/resources/push_pull_framework.properties?rev=1630710&r1=1630709&r2=1630710&view=diff
==============================================================================
--- oodt/trunk/pushpull/src/main/resources/push_pull_framework.properties 
(original)
+++ oodt/trunk/pushpull/src/main/resources/push_pull_framework.properties Fri 
Oct 10 08:07:00 2014
@@ -102,3 +102,5 @@ org.apache.oodt.cas.pushpull.filerestric
 org.apache.oodt.cas.pushpull.generic.email.parser.file.pattern=Wav File: 
([^\\s]+)
 org.apache.oodt.cas.pushpull.generic.email.parser.check.for.pattern=Pattern to 
valid email has expected text
 org.apache.oodt.cas.pushpull.generic.email.parser.path.to.root=/some/root/path
+org.apache.oodt.cas.pushpull.generic.email.parser.metadata.keys=MasterInContactId
+org.apache.oodt.cas.pushpull.generic.email.parser.metadata.MasterInContactId=Master
 ContactID (\d+?)\n


Reply via email to