Patch to retrieve success messages from services invoked thru the service-multi handler

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

Patch to retrieve success messages from services invoked thru the service-multi handler

Jacopo Cappellato
What do you think of the attached patch?

The success message list is pulled from the services (invoked thru the
service-multi handler) so that the messages returned by the services are
shown on screen: this will make the output a bit more verbose
(especially if you submit big lists of services) but I think it's worth
having.

Can I commit it?

Jacopo

Index: framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java
===================================================================
--- framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java (revision 468843)
+++ framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java (working copy)
@@ -150,8 +150,9 @@
         String messagePrefixStr = UtilProperties.getMessage("DefaultMessages", "service.message.prefix", locale);
         String messageSuffixStr = UtilProperties.getMessage("DefaultMessages", "service.message.suffix", locale);
 
-        // prepare the error message list
+        // prepare the error message and success message lists
         List errorMessages = FastList.newInstance();
+        List successMessages = FastList.newInstance();
 
         // big try/finally to make sure commit or rollback are run
         boolean beganTrans = false;
@@ -296,7 +297,16 @@
                 if (UtilValidate.isNotEmpty(errorMessage)) {
                     errorMessages.add(errorMessage);
                 }
-                
+
+                // get the success message
+                if (!UtilValidate.isEmpty((List)result.get(ModelService.SUCCESS_MESSAGE_LIST))) {
+                    successMessages.addAll((List)result.get(ModelService.SUCCESS_MESSAGE_LIST));
+                }
+
                 // set the results in the request
                 if ((result != null) && (result.entrySet() != null)) {
                     Iterator rmei = result.entrySet().iterator();
@@ -339,6 +349,9 @@
                     Debug.logError(e, "Could not commit transaction", module);
                     throw new EventHandlerException("Commit transaction failed");
                 }
+                if (successMessages.size() > 0) {
+                    request.setAttribute("_EVENT_MESSAGE_LIST_", successMessages);
+                }
                 returnString = "success";
             }
         }
Reply | Threaded
Open this post in threaded view
|

Re: Patch to retrieve success messages from services invoked thru the service-multi handler

David E Jones-2

Jacopo,

Yes, this makes sense. Just get and show all messages. You might want  
to filter out duplicate messages, ie the same as another message  
already in the list.

BTW, a success message could be an individual message as well as the  
list of messages.

-David


On Nov 1, 2006, at 2:06 AM, Jacopo Cappellato wrote:

> What do you think of the attached patch?
>
> The success message list is pulled from the services (invoked thru  
> the service-multi handler) so that the messages returned by the  
> services are shown on screen: this will make the output a bit more  
> verbose (especially if you submit big lists of services) but I  
> think it's worth having.
>
> Can I commit it?
>
> Jacopo
> Index: framework/webapp/src/org/ofbiz/webapp/event/
> ServiceMultiEventHandler.java
> ===================================================================
> --- framework/webapp/src/org/ofbiz/webapp/event/
> ServiceMultiEventHandler.java (revision 468843)
> +++ framework/webapp/src/org/ofbiz/webapp/event/
> ServiceMultiEventHandler.java (working copy)
> @@ -150,8 +150,9 @@
>          String messagePrefixStr = UtilProperties.getMessage
> ("DefaultMessages", "service.message.prefix", locale);
>          String messageSuffixStr = UtilProperties.getMessage
> ("DefaultMessages", "service.message.suffix", locale);
>
> -        // prepare the error message list
> +        // prepare the error message and success message lists
>          List errorMessages = FastList.newInstance();
> +        List successMessages = FastList.newInstance();
>
>          // big try/finally to make sure commit or rollback are run
>          boolean beganTrans = false;
> @@ -296,7 +297,16 @@
>                  if (UtilValidate.isNotEmpty(errorMessage)) {
>                      errorMessages.add(errorMessage);
>                  }
> -
> +
> +                // get the success message
> +                if (!UtilValidate.isEmpty((List)result.get
> (ModelService.SUCCESS_MESSAGE_LIST))) {
> +                    successMessages.addAll((List)result.get
> (ModelService.SUCCESS_MESSAGE_LIST));
> +                }
> +
>                  // set the results in the request
>                  if ((result != null) && (result.entrySet() !=  
> null)) {
>                      Iterator rmei = result.entrySet().iterator();
> @@ -339,6 +349,9 @@
>                      Debug.logError(e, "Could not commit  
> transaction", module);
>                      throw new EventHandlerException("Commit  
> transaction failed");
>                  }
> +                if (successMessages.size() > 0) {
> +                    request.setAttribute("_EVENT_MESSAGE_LIST_",  
> successMessages);
> +                }
>                  returnString = "success";
>              }
>          }

Reply | Threaded
Open this post in threaded view
|

Re: Patch to retrieve success messages from services invoked thru the service-multi handler

Jacopo Cappellato
David,

thanks for your help; I've implemented them in rev. 469851

Jacopo

David E Jones wrote:

>
> Jacopo,
>
> Yes, this makes sense. Just get and show all messages. You might want to
> filter out duplicate messages, ie the same as another message already in
> the list.
>
> BTW, a success message could be an individual message as well as the
> list of messages.
>
> -David
>
>
> On Nov 1, 2006, at 2:06 AM, Jacopo Cappellato wrote:
>
>> What do you think of the attached patch?
>>
>> The success message list is pulled from the services (invoked thru the
>> service-multi handler) so that the messages returned by the services
>> are shown on screen: this will make the output a bit more verbose
>> (especially if you submit big lists of services) but I think it's
>> worth having.
>>
>> Can I commit it?
>>
>> Jacopo
>> Index:
>> framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java
>> ===================================================================
>> ---
>> framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java    
>> (revision 468843)
>> +++
>> framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java    
>> (working copy)
>> @@ -150,8 +150,9 @@
>>          String messagePrefixStr =
>> UtilProperties.getMessage("DefaultMessages", "service.message.prefix",
>> locale);
>>          String messageSuffixStr =
>> UtilProperties.getMessage("DefaultMessages", "service.message.suffix",
>> locale);
>>
>> -        // prepare the error message list
>> +        // prepare the error message and success message lists
>>          List errorMessages = FastList.newInstance();
>> +        List successMessages = FastList.newInstance();
>>
>>          // big try/finally to make sure commit or rollback are run
>>          boolean beganTrans = false;
>> @@ -296,7 +297,16 @@
>>                  if (UtilValidate.isNotEmpty(errorMessage)) {
>>                      errorMessages.add(errorMessage);
>>                  }
>> -
>> +
>> +                // get the success message
>> +                if
>> (!UtilValidate.isEmpty((List)result.get(ModelService.SUCCESS_MESSAGE_LIST)))
>> {
>> +                    
>> successMessages.addAll((List)result.get(ModelService.SUCCESS_MESSAGE_LIST));
>>
>> +                }
>> +
>>                  // set the results in the request
>>                  if ((result != null) && (result.entrySet() != null)) {
>>                      Iterator rmei = result.entrySet().iterator();
>> @@ -339,6 +349,9 @@
>>                      Debug.logError(e, "Could not commit transaction",
>> module);
>>                      throw new EventHandlerException("Commit
>> transaction failed");
>>                  }
>> +                if (successMessages.size() > 0) {
>> +                    request.setAttribute("_EVENT_MESSAGE_LIST_",
>> successMessages);
>> +                }
>>                  returnString = "success";
>>              }
>>          }

Reply | Threaded
Open this post in threaded view
|

Re: Patch to retrieve success messages from services invoked thru the service-multi handler

David E Jones-2

Thanks for working on this Jacopo, it looks good.

-David


On Nov 1, 2006, at 3:44 AM, Jacopo Cappellato wrote:

> David,
>
> thanks for your help; I've implemented them in rev. 469851
>
> Jacopo
>
> David E Jones wrote:
>> Jacopo,
>> Yes, this makes sense. Just get and show all messages. You might  
>> want to filter out duplicate messages, ie the same as another  
>> message already in the list.
>> BTW, a success message could be an individual message as well as  
>> the list of messages.
>> -David
>> On Nov 1, 2006, at 2:06 AM, Jacopo Cappellato wrote:
>>> What do you think of the attached patch?
>>>
>>> The success message list is pulled from the services (invoked  
>>> thru the service-multi handler) so that the messages returned by  
>>> the services are shown on screen: this will make the output a bit  
>>> more verbose (especially if you submit big lists of services) but  
>>> I think it's worth having.
>>>
>>> Can I commit it?
>>>
>>> Jacopo
>>> Index: framework/webapp/src/org/ofbiz/webapp/event/
>>> ServiceMultiEventHandler.java
>>> ===================================================================
>>> --- framework/webapp/src/org/ofbiz/webapp/event/
>>> ServiceMultiEventHandler.java    (revision 468843)
>>> +++ framework/webapp/src/org/ofbiz/webapp/event/
>>> ServiceMultiEventHandler.java    (working copy)
>>> @@ -150,8 +150,9 @@
>>>          String messagePrefixStr = UtilProperties.getMessage
>>> ("DefaultMessages", "service.message.prefix", locale);
>>>          String messageSuffixStr = UtilProperties.getMessage
>>> ("DefaultMessages", "service.message.suffix", locale);
>>>
>>> -        // prepare the error message list
>>> +        // prepare the error message and success message lists
>>>          List errorMessages = FastList.newInstance();
>>> +        List successMessages = FastList.newInstance();
>>>
>>>          // big try/finally to make sure commit or rollback are run
>>>          boolean beganTrans = false;
>>> @@ -296,7 +297,16 @@
>>>                  if (UtilValidate.isNotEmpty(errorMessage)) {
>>>                      errorMessages.add(errorMessage);
>>>                  }
>>> -
>>> +
>>> +                // get the success message
>>> +                if (!UtilValidate.isEmpty((List)result.get
>>> (ModelService.SUCCESS_MESSAGE_LIST))) {
>>> +                    successMessages.addAll((List)result.get
>>> (ModelService.SUCCESS_MESSAGE_LIST));
>>> +                }
>>> +
>>>                  // set the results in the request
>>>                  if ((result != null) && (result.entrySet() !=  
>>> null)) {
>>>                      Iterator rmei = result.entrySet().iterator();
>>> @@ -339,6 +349,9 @@
>>>                      Debug.logError(e, "Could not commit  
>>> transaction", module);
>>>                      throw new EventHandlerException("Commit  
>>> transaction failed");
>>>                  }
>>> +                if (successMessages.size() > 0) {
>>> +                    request.setAttribute("_EVENT_MESSAGE_LIST_",  
>>> successMessages);
>>> +                }
>>>                  returnString = "success";
>>>              }
>>>          }
>