[jbpm-commits] JBoss JBPM SVN: r4504 - jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Apr 8 16:27:20 EDT 2009


Author: bradsdavis
Date: 2009-04-08 16:27:20 -0400 (Wed, 08 Apr 2009)
New Revision: 4504

Modified:
   jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java
Log:
Added comments.

Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java	2009-04-08 20:20:16 UTC (rev 4503)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java	2009-04-08 20:27:20 UTC (rev 4504)
@@ -52,19 +52,26 @@
 		email.setTextMsg(this.body);
 		email.setSubject(this.subject);
 		
-		
+		//Keep track of the CIDs that have replaced SRCs to reduce
+		//calls to replace.  Should improve efficiency.
 		Set<String> cidSet = new HashSet<String>();
+		//Create a matcher based on our regex.
 		Matcher imgMatcher = imgSrcPattern.matcher(html);
+		
+		//While there are matches, loop through them.
 		while(imgMatcher.find())
 		{
+			//Embed the SRC image, and get a reference to the embedded CID.
 			String replace = embedImage(email,imgMatcher.group(2));
 			if(replace==null)
 			{
 				log.warn("The image source is not provided.  Skipping: "+imgMatcher.group());
 				continue;
 			}
+			//If this CID has not replaced a URL in the past, replace it now.
 			if(cidSet.add(replace))
 			{
+				//Replace the original SRC URL with the CID SRC URL.
 				this.html=this.html.replace(imgMatcher.group(2), replace);
 			}
 			else
@@ -73,7 +80,6 @@
 				{
 					log.debug("Skipped replace as the image has been handled before: "+imgMatcher.group(2));
 				}
-				
 			}
 				
 		}
@@ -113,6 +119,8 @@
 		{
 			return imageSrc;
 		}
+		
+		//If the image hasn't been embedded yet, embed it.
 		String src = imageSrc;
 		String hashName = Integer.toString(src.hashCode());
 		String cid = null; 
@@ -124,6 +132,7 @@
 			log.error("Error fetching image.",e);
 			return imageSrc;
 		}
+		//Return the embedded name to replace the src.
 		return "cid:"+cid;
 		
 	}




More information about the jbpm-commits mailing list