svn commit: r813362 - in /ofbiz/trunk/applications/marketing: servicedef/services.xml src/org/ofbiz/marketing/marketing/MarketingServices.java

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

svn commit: r813362 - in /ofbiz/trunk/applications/marketing: servicedef/services.xml src/org/ofbiz/marketing/marketing/MarketingServices.java

ashish-18
Author: ashish
Date: Thu Sep 10 10:47:18 2009
New Revision: 813362

URL: http://svn.apache.org/viewvc?rev=813362&view=rev
Log:
Applied patch from jira issue OFBIZ-2922 - Update Sign up for Contact List (signUpForContactList) service.
Thanks Surya & Sumit for the contribution.

Modified:
    ofbiz/trunk/applications/marketing/servicedef/services.xml
    ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java

Modified: ofbiz/trunk/applications/marketing/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/marketing/servicedef/services.xml?rev=813362&r1=813361&r2=813362&view=diff
==============================================================================
--- ofbiz/trunk/applications/marketing/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/marketing/servicedef/services.xml Thu Sep 10 10:47:18 2009
@@ -76,6 +76,7 @@
             The intent is for anonymous sign ups to email lists.  Also validates email format.</description>
         <attribute name="contactListId" type="String" mode="IN" optional="false"/>
         <attribute name="email" type="String" mode="IN" optional="false"/>
+        <attribute name="partyId" type="String" mode="IN" optional="true"/>
     </service>
 
     <!-- MarketingCampaignRole Services -->

Modified: ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java?rev=813362&r1=813361&r2=813362&view=diff
==============================================================================
--- ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java (original)
+++ ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java Thu Sep 10 10:47:18 2009
@@ -54,6 +54,7 @@
         Timestamp fromDate = UtilDateTime.nowTimestamp();
         String contactListId = (String) context.get("contactListId");
         String email = (String) context.get("email");
+        String partyId = (String) context.get("partyId");
 
         if (!UtilValidate.isEmail(email)) {
             String error = UtilProperties.getMessage(resourceMarketing, "MarketingCampaignInvalidEmailInput", locale);
@@ -73,16 +74,18 @@
             GenericValue userLogin = delegator.findByPrimaryKeyCache("UserLogin", UtilMisc.toMap("userLoginId", "system"));
 
             // associate the email with anonymous user TODO: do we need a custom contact mech purpose type, say MARKETING_EMAIL?
-            input = UtilMisc.toMap("userLogin", userLogin, "emailAddress", email, "partyId", "_NA_", "fromDate", fromDate, "contactMechPurposeTypeId", "OTHER_EMAIL");
+            if (partyId == null) {
+                partyId = "_NA_";
+            }
+            input = UtilMisc.toMap("userLogin", userLogin, "emailAddress", email, "partyId", partyId, "fromDate", fromDate, "contactMechPurposeTypeId", "OTHER_EMAIL");
             Map<String, Object> serviceResults = dispatcher.runSync("createPartyEmailAddress", input);
             if (ServiceUtil.isError(serviceResults)) {
                 throw new GenericServiceException(ServiceUtil.getErrorMessage(serviceResults));
             }
             String contactMechId = (String) serviceResults.get("contactMechId");
-
             // create a new association at this fromDate to the anonymous party with status accepted
             input = UtilMisc.toMap("userLogin", userLogin, "contactListId", contactList.get("contactListId"),
-                    "partyId", "_NA_", "fromDate", fromDate, "statusId", "CLPT_ACCEPTED", "preferredContactMechId", contactMechId);
+                    "partyId", partyId, "fromDate", fromDate, "statusId", "CLPT_ACCEPTED", "preferredContactMechId", contactMechId);
             serviceResults = dispatcher.runSync("createContactListParty", input);
             if (ServiceUtil.isError(serviceResults)) {
                 throw new GenericServiceException(ServiceUtil.getErrorMessage(serviceResults));