Author: bfoster
Date: Sat Apr 19 10:59:43 2014
New Revision: 1588634

URL: http://svn.apache.org/r1588634
Log:
- Added new GenericEmailParser 

Modified:
    
oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/GenericEmailParser.java
    
oodt/trunk/pushpull/src/test/org/apache/oodt/cas/pushpull/filerestrictions/parsers/GenericEmailParserTest.java

Modified: 
oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/GenericEmailParser.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/GenericEmailParser.java?rev=1588634&r1=1588633&r2=1588634&view=diff
==============================================================================
--- 
oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/GenericEmailParser.java
 (original)
+++ 
oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/GenericEmailParser.java
 Sat Apr 19 10:59:43 2014
@@ -50,18 +50,23 @@ public class GenericEmailParser implemen
       "org.apache.oodt.cas.pushpull.generic.email.parser.file.pattern";
   public static final String CHECK_FOR_PATTERN_PROPERTY_NAME =
       "org.apache.oodt.cas.pushpull.generic.email.parser.check.for.pattern";
+  public static final String PATH_TO_ROOT_PROPERTY_NAME =
+      "org.apache.oodt.cas.pushpull.generic.email.parser.path.to.root";
 
   private final String filePattern;
   private final String checkForPattern;
+  private final String pathToRoot;
 
   public GenericEmailParser() {
     filePattern = loadFilePattern();
     checkForPattern = loadCheckForPattern();
+    pathToRoot = loadPathToRoot();
   }
  
-  public GenericEmailParser(String filePattern, String checkForPattern) {
+  public GenericEmailParser(String filePattern, String checkForPattern, String 
pathToRoot) {
     this.filePattern = filePattern;
     this.checkForPattern = checkForPattern;
+    this.pathToRoot = pathToRoot;
   }
 
   @Override
@@ -80,7 +85,7 @@ public class GenericEmailParser implemen
       new VirtualFile(root, filePath, false);
     }
 
-    return new VirtualFileStructure(null, "/", root);
+    return new VirtualFileStructure(pathToRoot != null ? pathToRoot : "/", 
root);
   }
 
   private String readEmail(FileInputStream emailFile) {
@@ -119,4 +124,8 @@ public class GenericEmailParser implemen
   private String loadCheckForPattern() {
     return System.getProperty(CHECK_FOR_PATTERN_PROPERTY_NAME);    
   }
+  
+  private String loadPathToRoot() {
+    return System.getProperty(PATH_TO_ROOT_PROPERTY_NAME);
+  }
 }

Modified: 
oodt/trunk/pushpull/src/test/org/apache/oodt/cas/pushpull/filerestrictions/parsers/GenericEmailParserTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/pushpull/src/test/org/apache/oodt/cas/pushpull/filerestrictions/parsers/GenericEmailParserTest.java?rev=1588634&r1=1588633&r2=1588634&view=diff
==============================================================================
--- 
oodt/trunk/pushpull/src/test/org/apache/oodt/cas/pushpull/filerestrictions/parsers/GenericEmailParserTest.java
 (original)
+++ 
oodt/trunk/pushpull/src/test/org/apache/oodt/cas/pushpull/filerestrictions/parsers/GenericEmailParserTest.java
 Sat Apr 19 10:59:43 2014
@@ -56,7 +56,7 @@ public class GenericEmailParserTest {
   @Test
   public void testGenericEmailParser() throws ParserException, 
FileNotFoundException {
     GenericEmailParser parser = new GenericEmailParser(
-        "Wav File: ([^\\s]+)", "Dear Lousy Customer,");
+        "Wav File: ([^\\s]+)", "Dear Lousy Customer,", null);
     VirtualFileStructure vfs = parser.parse(new FileInputStream(emailFile));
     List<String> filePaths = 
FileRestrictions.toStringList(vfs.getRootVirtualFile());
     assertThat(filePaths.size(), Matchers.is(1));
@@ -66,7 +66,7 @@ public class GenericEmailParserTest {
   @Test (expected = ParserException.class)
   public void testFailedValidEmailCheck() throws ParserException, 
FileNotFoundException {
     GenericEmailParser parser = new GenericEmailParser(
-        "Wav File: ([^\\s]+)", "Phrase Not Found");
+        "Wav File: ([^\\s]+)", "Phrase Not Found", null);
     parser.parse(new FileInputStream(emailFile));
   }
 }


Reply via email to