You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2009/05/25 07:55:42 UTC

svn commit: r778288 - in /ofbiz/branches/release09.04: ./ applications/party/script/org/ofbiz/party/communication/ applications/party/src/org/ofbiz/party/communication/ applications/party/webapp/partymgr/communication/ applications/party/widget/partymgr/

Author: hansbak
Date: Mon May 25 05:55:41 2009
New Revision: 778288

URL: http://svn.apache.org/viewvc?rev=778288&view=rev
Log:
merge from trunk 777768,777792,777893 corrections on communicationevent handling

Modified:
    ofbiz/branches/release09.04/   (props changed)
    ofbiz/branches/release09.04/applications/party/script/org/ofbiz/party/communication/CommunicationEventServices.xml
    ofbiz/branches/release09.04/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java
    ofbiz/branches/release09.04/applications/party/webapp/partymgr/communication/CommForms.xml
    ofbiz/branches/release09.04/applications/party/widget/partymgr/PartyMenus.xml

Propchange: ofbiz/branches/release09.04/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 25 05:55:41 2009
@@ -1 +1 @@
-/ofbiz/trunk:765933,766011,766015,766293,766307,766316,766325,766462,766522,766800,767060,767072,767093,767098-767099,767102,767123,767125,767127,767279,767287,767671,767688,767694,767822,767845,768358,768490,768550,768675,768686,768705,768811,768815,768960,769030,769500,770272,770997,771073,772401,772464-772465,773076,773557,773628,773659,773697,774014,774632,774661,774995,775292,775667,776227,776594,776620,776922,777004,777020,777947,778278,778280
+/ofbiz/trunk:765933,766011,766015,766293,766307,766316,766325,766462,766522,766800,767060,767072,767093,767098-767099,767102,767123,767125,767127,767279,767287,767671,767688,767694,767822,767845,768358,768490,768550,768675,768686,768705,768811,768815,768960,769030,769500,770272,770997,771073,772401,772464-772465,773076,773557,773628,773659,773697,774014,774632,774661,774995,775292,775667,776227,776594,776620,776922,777004,777020,777768,777792,777893,777947,778278,778280

Modified: ofbiz/branches/release09.04/applications/party/script/org/ofbiz/party/communication/CommunicationEventServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/release09.04/applications/party/script/org/ofbiz/party/communication/CommunicationEventServices.xml?rev=778288&r1=778287&r2=778288&view=diff
==============================================================================
--- ofbiz/branches/release09.04/applications/party/script/org/ofbiz/party/communication/CommunicationEventServices.xml (original)
+++ ofbiz/branches/release09.04/applications/party/script/org/ofbiz/party/communication/CommunicationEventServices.xml Mon May 25 05:55:41 2009
@@ -33,19 +33,21 @@
     </simple-method>
 
     <simple-method method-name="createCommunicationEvent" short-description="Create a CommunicationEvent with or w/o permission check">
-        <!-- check for forward -->
-        <if-not-empty field="parameters.origCommEventId">
-            <entity-one entity-name="CommunicationEvent" value-field="newEntity">
-                <field-map field-name="communicationEventId" from-field="parameters.origCommEventId"/>
-            </entity-one>
-            <clear-field field="newEntity.communicationEventId"/>
-            <clear-field field="newEntity.partyIdFrom"/>
-            <clear-field field="newEntity.partyIdTo"/>
-            <set field="newEntity.subject" value="Forw: ${newEntity.subject}"/>
-            <else><!-- if not create empty one -->
-                <make-value value-field="newEntity" entity-name="CommunicationEvent"/>
-            </else>
-        </if-not-empty>
+        <!-- check for forward only if created by a user and not incoming email by system-->
+        <if-compare field="parameters.userLogin.userLoginId" value="system" operator="not-equals">
+            <if-not-empty field="parameters.origCommEventId">
+                <entity-one entity-name="CommunicationEvent" value-field="newEntity">
+                    <field-map field-name="communicationEventId" from-field="parameters.origCommEventId"/>
+                </entity-one>
+                <clear-field field="newEntity.communicationEventId"/>
+                <clear-field field="newEntity.partyIdTo"/>
+                <set field="newEntity.partyIdFrom" from-field="parameters.partyIdFrom"/>
+                <set field="newEntity.subject" value="Forw: ${newEntity.subject}"/>
+            </if-not-empty>
+        </if-compare>
+        <if-empty field="newEntity">
+            <make-value value-field="newEntity" entity-name="CommunicationEvent"/>
+        </if-empty>
         
         <set-nonpk-fields map="parameters" value-field="newEntity"/>
         
@@ -58,25 +60,26 @@
         <field-to-result field="newEntity.communicationEventId" result-name="communicationEventId"/>
 
         <!-- check for reply -->
-        <if-not-empty field="parameters.parentCommEventId">
-            <entity-one entity-name="CommunicationEvent" value-field="parentCommEvent">
-                <field-map field-name="communicationEventId" from-field="parameters.parentCommEventId"/>
-            </entity-one>
-            <entity-one entity-name="PartyNameView" value-field="partyNameView">
-                <field-map field-name="partyId" from-field="parentCommEvent.partyIdFrom"/>
-            </entity-one>
-            
-            <if-compare-field field="parentCommEvent.partyIdFrom" operator="equals" to-field="parameters.partyIdTo">
-                <set field="newEntity.partyIdTo" from-field="parentCommEvent.partyIdFrom"/>
-            </if-compare-field>
-            
-            <set field="newEntity.subject" value="RE: ${parentCommEvent.subject}"/>
-
-            <set field="newEntity.content" value="${groovy:
-                def localContent = parentCommEvent.content;
-                if (!localContent) return(&quot;&quot;);
-
-                resultLine = &quot;\n\n\n&quot; 
+        <if-compare field="parameters.userLogin.userLoginId" value="system" operator="not-equals">
+            <if-not-empty field="parameters.parentCommEventId">
+                <entity-one entity-name="CommunicationEvent" value-field="parentCommEvent">
+                    <field-map field-name="communicationEventId" from-field="parameters.parentCommEventId"/>
+                </entity-one>
+                <entity-one entity-name="PartyNameView" value-field="partyNameView">
+                    <field-map field-name="partyId" from-field="parentCommEvent.partyIdFrom"/>
+                </entity-one>
+                
+                <if-compare-field field="parentCommEvent.partyIdFrom" operator="equals" to-field="parameters.partyIdTo">
+                    <set field="newEntity.partyIdTo" from-field="parentCommEvent.partyIdFrom"/>
+                </if-compare-field>
+                
+                <set field="newEntity.subject" value="RE: ${parentCommEvent.subject}"/>
+                
+                <set field="newEntity.content" value="${groovy:
+                    def localContent = parentCommEvent.content;
+                    if (!localContent) return(&quot;&quot;);
+                    
+                    resultLine = &quot;\n\n\n&quot; 
                     + (partyNameView.firstName!=null?partyNameView.firstName:&quot;&quot;) 
                     + &quot; &quot; 
                     + (partyNameView.middleName!=null?partyNameView.middleName+&quot; &quot;:&quot;&quot;) 
@@ -84,27 +87,28 @@
                     + (partyNameView.lastName!=null?partyNameView.lastName:&quot;&quot;) 
                     + (partyNameView.groupName!=null?partyNameView.groupName:&quot;&quot;) 
                     + &quot; wrote:&quot;;
-                resultLine += &quot;\n -------------------------------------------------------------------- &quot;;
-                resultLine += &quot;\n&gt; &quot; + localContent.substring(0, localContent.indexOf(&quot;\n&quot;,0) == -1 ? localContent.length() : localContent.indexOf(&quot;\n&quot;,0));
-                startChar = localContent.indexOf(&quot;\n&quot;,0);
-                while(startChar != -1 &amp;&amp; (startChar = localContent.indexOf(&quot;\n&quot;,startChar) + 1) != 0)
+                    resultLine += &quot;\n -------------------------------------------------------------------- &quot;;
+                    resultLine += &quot;\n&gt; &quot; + localContent.substring(0, localContent.indexOf(&quot;\n&quot;,0) == -1 ? localContent.length() : localContent.indexOf(&quot;\n&quot;,0));
+                    startChar = localContent.indexOf(&quot;\n&quot;,0);
+                    while(startChar != -1 &amp;&amp; (startChar = localContent.indexOf(&quot;\n&quot;,startChar) + 1) != 0)
                     resultLine += &quot;\n&gt; &quot; + localContent.substring(startChar, localContent.indexOf(&quot;\n&quot;,startChar)==-1 ? localContent.length() : localContent.indexOf(&quot;\n&quot;,startChar));
-                return(resultLine);
-                }"/>
-
-            <!-- set rolestatus from original email to completed -->
-            <entity-and list="roles" entity-name="CommunicationEventRole">
-                <field-map field-name="communicationEventId" from-field="parentCommEvent.communicationEventId"/>
-                <field-map field-name="partyId" from-field="parentCommEvent.partyIdTo"/>
-            </entity-and>
-            <if-not-empty field="roles">
-                <first-from-list list="roles" entry="role"/>
-                <set-service-fields service-name="setCommunicationEventRoleStatus" map="role" to-map="newStat"/>
-                <set field="newStat.statusId" value="COM_ROLE_COMPLETED"/>
-                <call-service service-name="setCommunicationEventRoleStatus" in-map-name="newStat"/>
+                    return(resultLine);
+                    }"/>
+                
+                <!-- set rolestatus from original email to completed -->
+                <entity-and list="roles" entity-name="CommunicationEventRole">
+                    <field-map field-name="communicationEventId" from-field="parentCommEvent.communicationEventId"/>
+                    <field-map field-name="partyId" from-field="parentCommEvent.partyIdTo"/>
+                </entity-and>
+                <if-not-empty field="roles">
+                    <first-from-list list="roles" entry="role"/>
+                    <set-service-fields service-name="setCommunicationEventRoleStatus" map="role" to-map="newStat"/>
+                    <set field="newStat.statusId" value="COM_ROLE_COMPLETED"/>
+                    <call-service service-name="setCommunicationEventRoleStatus" in-map-name="newStat"/>
+                </if-not-empty>
             </if-not-empty>
-        </if-not-empty>
-
+        </if-compare>
+        
         <if-empty field="parameters.statusId">
             <set value="COM_ENTERED" field="parameters.statusId"/>
         </if-empty>
@@ -191,6 +195,7 @@
     <simple-method method-name="updateCommunicationEvent"
         short-description="Update a CommunicationEvent">
         <entity-one entity-name="CommunicationEvent" value-field="event"/>
+        <log level="always" message="====Udating communication event: ${communicationEvent.communicationEventId} with subject: ${communicationEvent.subject}"></log>
         <if-compare-field to-field="parameters.statusId" operator="not-equals" field="event.statusId">
             <call-simple-method method-name="setCommunicationEventStatus"/>
         </if-compare-field>

Modified: ofbiz/branches/release09.04/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release09.04/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java?rev=778288&r1=778287&r2=778288&view=diff
==============================================================================
--- ofbiz/branches/release09.04/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java (original)
+++ ofbiz/branches/release09.04/applications/party/src/org/ofbiz/party/communication/CommunicationEventServices.java Mon May 25 05:55:41 2009
@@ -33,6 +33,7 @@
 import java.util.TreeSet;
 
 import javax.mail.Address;
+import javax.mail.BodyPart;
 import javax.mail.MessagingException;
 import javax.mail.Multipart;
 import javax.mail.Part;
@@ -521,12 +522,9 @@
             }
             if (!commEvents.isEmpty()) {
                 Debug.logInfo("Ignoring Duplicate Email: " + aboutThisEmail, module);
-                return ServiceUtil.returnSuccess(" Message Ignored: deplicate messageId");
-            } else {
-                Debug.logInfo("Persisting New Email: " + aboutThisEmail, module);
+                return ServiceUtil.returnSuccess(" Message Ignored: duplicate messageId");
             }
 
-
             // get the related partId's
             List toParties = buildListOfPartyInfoFromEmailAddresses(addressesTo, userLogin, dispatcher);
             List ccParties = buildListOfPartyInfoFromEmailAddresses(addressesCC, userLogin, dispatcher);
@@ -595,6 +593,24 @@
                 contentIndex = "";
                 commEventMap = addMessageBody(commEventMap, (Multipart) messageContent);
             }
+            
+            // select the plain text bodypart
+            String messageBody = null;
+            if (wrapper.getMainPartCount() > 1) {
+            	for (int ind=0; ind < wrapper.getMainPartCount(); ind++) {
+            		BodyPart p = wrapper.getPart(ind + "");
+            		if (p.getContentType().toLowerCase().indexOf("text/plain") > -1) {
+            			messageBody = (String) p.getContent();
+            		}
+            	}
+            }
+            
+            if (messageBody == null ) {
+            	messageBody = wrapper.getMessageBody();
+            }
+                        
+            commEventMap.put("content", messageBody);
+            commEventMap.put("contentMimeTypeId", messageBodyContentType.toLowerCase());            
 
             // check for for a reply to communication event (using in-reply-to the parent messageID)
             String[] inReplyTo = message.getHeader("In-Reply-To");
@@ -693,6 +709,7 @@
 
             result = dispatcher.runSync("createCommunicationEvent", commEventMap);
             communicationEventId = (String)result.get("communicationEventId");
+            Debug.logInfo("Persisting New Email: " + aboutThisEmail + " into CommunicationEventId: " + communicationEventId, module);
 
             if (messageContent instanceof Multipart) {
                 Debug.logInfo("===message has attachments=====", module);

Modified: ofbiz/branches/release09.04/applications/party/webapp/partymgr/communication/CommForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/release09.04/applications/party/webapp/partymgr/communication/CommForms.xml?rev=778288&r1=778287&r2=778288&view=diff
==============================================================================
--- ofbiz/branches/release09.04/applications/party/webapp/partymgr/communication/CommForms.xml (original)
+++ ofbiz/branches/release09.04/applications/party/webapp/partymgr/communication/CommForms.xml Mon May 25 05:55:41 2009
@@ -714,6 +714,7 @@
         <field name="subject" widget-style="buttontext" widget-area-style="fieldWidth300">
             <hyperlink description="${subject}" target="ViewCommunicationEvent">
                 <parameter param-name="communicationEventId"/>
+                <parameter param-name="partyId"/>
                 <parameter param-name="my" value="My"/>
             </hyperlink>
         </field>
@@ -781,6 +782,7 @@
         <field name="subject">
             <hyperlink description="${subject}" target="EditCommunicationEvent">
                 <parameter param-name="communicationEventId"/>
+                <parameter param-name="partyId"/>
                 <parameter param-name="my"/>
             </hyperlink>
         </field>

Modified: ofbiz/branches/release09.04/applications/party/widget/partymgr/PartyMenus.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/release09.04/applications/party/widget/partymgr/PartyMenus.xml?rev=778288&r1=778287&r2=778288&view=diff
==============================================================================
--- ofbiz/branches/release09.04/applications/party/widget/partymgr/PartyMenus.xml (original)
+++ ofbiz/branches/release09.04/applications/party/widget/partymgr/PartyMenus.xml Mon May 25 05:55:41 2009
@@ -423,6 +423,7 @@
                     <not><if-empty field="communicationEvent.partyIdFrom"/></not>
                     <if-compare field="communicationEvent.statusId" operator="not-equals" value="COM_PENDING"/>
                     <if-has-permission permission="ORDERMGR_CRQ_CREATE"/>
+                    <if-compare field="communicationEvent.statusId" operator="equals" value="COM_ENTERED"/>
                 </and>
             </condition>
             <link target="editRequestFromCommEvent">
@@ -430,12 +431,29 @@
                 <parameter param-name="my" from-field="parameters.my"/>
             </link>
         </menu-item>
+        <menu-item name="createRequestFromCommEvent1" title="${uiLabelMap.PartyCreateRequestFromCommEvent}">
+            <condition>
+                <and>
+                    <not><if-empty field="communicationEvent"/></not>
+                    <not><if-empty field="communicationEvent.partyIdFrom"/></not>
+                    <if-compare field="communicationEvent.statusId" operator="not-equals" value="COM_PENDING"/>
+                    <if-has-permission permission="ORDERMGR_CRQ_CREATE"/>
+                    <if-compare field="projectMgrExists" operator="equals" value="true"/> 
+                    <if-compare field="communicationEvent.statusId" operator="equals" value="COM_ENTERED"/>
+                </and>
+            </condition>
+            <link target="newrequest">
+                <parameter param-name="communicationEventId" from-field="communicationEvent.communicationEventId"/>
+                <parameter param-name="my" from-field="parameters.my"/>
+            </link>
+        </menu-item>
         <menu-item name="close" title="${uiLabelMap.CommonClose}">
             <condition>
                 <and>
                     <not><if-empty field="communicationEvent"/></not>
                     <if-compare field="myCommunicationEventRole.roleStatusId" operator="equals" value="COM_ROLE_READ"/>
                     <if-has-permission permission="PARTYMGR_CME-EMAIL_UPDATE"/>
+                    <if-compare field="communicationEvent.statusId" operator="not-equals" value="COM_UNKNOWN_PARTY"/>
                 </and>
             </condition>
             <link target="setCommunicationEventRoleStatus">
@@ -556,6 +574,7 @@
                     <not><if-empty field="parameters.communicationEventId"/></not>
                     <not><if-empty field="communicationEvent.partyIdFrom"/></not>
                     <if-compare field="communicationEvent.partyIdFrom" operator="not-equals" value="${userLogin.partyId}"/>
+                    <if-compare field="communicationEvent.statusId" operator="not-equals" value="COM_UNKNOWN_PARTY"/>
                 </and>
             </condition>
             <link target="EditCommunicationEvent">
@@ -568,6 +587,7 @@
                     <not><if-empty field="parameters.communicationEventId"/></not>
                     <not><if-empty field="communicationEvent.partyIdFrom"/></not>
                     <if-compare field="communicationEvent.partyIdFrom" operator="not-equals" value="${userLogin.partyId}"/>
+                    <if-compare field="communicationEvent.statusId" operator="not-equals" value="COM_UNKNOWN_PARTY"/>
                 </and>
             </condition>
             <link target="EditCommunicationEvent">
@@ -580,6 +600,7 @@
                     <not><if-empty field="parameters.communicationEventId"/></not>
                     <not><if-empty field="communicationEvent.partyIdFrom"/></not>
                     <if-has-permission permission="ORDERMGR_CRQ_CREATE"/>
+                    <if-compare field="communicationEvent.statusId" operator="equals" value="COM_ENTERED"/>
                 </and>
             </condition>
             <link target="editRequestFromCommEvent">