svn commit: r928176 - /ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/communication/getPartyEmailFromCommEventInfo.groovy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r928176 - /ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/communication/getPartyEmailFromCommEventInfo.groovy

ashish-18
Author: ashish
Date: Sat Mar 27 09:17:14 2010
New Revision: 928176

URL: http://svn.apache.org/viewvc?rev=928176&view=rev
Log:
It may happen that the value returned from communicationEvent.note.indexOf(nameString) is -1.
So if this is the case then we should not do anything. The previous code was giving unexpected values in email address, lastname & firstname text box and it may create confusion for the end user.

I observed this case when: I was fetching emails from my personal account inside OFBiz using JavaMailContainer Api. And my personal email was not available in the system so the values fetched in the above mentioned field was not correct.

Modified:
    ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/communication/getPartyEmailFromCommEventInfo.groovy

Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/communication/getPartyEmailFromCommEventInfo.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/communication/getPartyEmailFromCommEventInfo.groovy?rev=928176&r1=928175&r2=928176&view=diff
==============================================================================
--- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/communication/getPartyEmailFromCommEventInfo.groovy (original)
+++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/communication/getPartyEmailFromCommEventInfo.groovy Sat Mar 27 09:17:14 2010
@@ -25,12 +25,16 @@ communicationEvent = delegator.findOne("
 
 if (!communicationEvent.note) return;
 nameString = "Sent from: ";
-int startEmail = communicationEvent.note.indexOf(nameString) + nameString.length();
+nameStringIndexValue = communicationEvent.note.indexOf(nameString);
+if (nameStringIndexValue == -1) return;
+int startEmail = nameStringIndexValue + nameString.length();
 int endEmail = communicationEvent.note.indexOf(";", startEmail);
 context.emailAddress = communicationEvent.note.substring(startEmail, endEmail);
 
 nameString = "Sent Name from: ";
-int startName = communicationEvent.note.indexOf(nameString) + nameString.length();
+nameStringIndexValue = communicationEvent.note.indexOf(nameString);
+if (nameStringIndexValue == -1) return;
+int startName = nameStringIndexValue + nameString.length();
 int endName = communicationEvent.note.indexOf(";", startName);
 name = communicationEvent.note.substring(startName, endName);
 if (name) {