svn commit: r462613 - /incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java

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

svn commit: r462613 - /incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java

sichen
Author: sichen
Date: Tue Oct 10 15:33:23 2006
New Revision: 462613

URL: http://svn.apache.org/viewvc?view=rev&rev=462613
Log:
refactored createOrderNote to use the dispatcher to call a service

Modified:
    incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java

Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?view=diff&rev=462613&r1=462612&r2=462613
==============================================================================
--- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Tue Oct 10 15:33:23 2006
@@ -2358,6 +2358,7 @@
     public static Map createOrderNote(DispatchContext dctx, Map context) {
         Map result = new HashMap();
         GenericDelegator delegator = dctx.getDelegator();
+        LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         String noteString = (String) context.get("note");
         String orderId = (String) context.get("orderId");
@@ -2365,20 +2366,20 @@
         Map noteCtx = UtilMisc.toMap("note", noteString, "userLogin", userLogin);
         Locale locale = (Locale) context.get("locale");
 
-        // Store the note.
-        Map noteRes = org.ofbiz.common.CommonServices.createNote(dctx, noteCtx);
+        try {
+            // Store the note.
+            Map noteRes = dispatcher.runSync("createNote", noteCtx);
 
-        if (noteRes.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_ERROR))
-            return noteRes;
+            if (ServiceUtil.isError(noteRes))
+                return noteRes;
 
-        String noteId = (String) noteRes.get("noteId");
+            String noteId = (String) noteRes.get("noteId");
 
-        if (noteId == null || noteId.length() == 0) {
-            return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderProblemCreatingTheNoteNoNoteIdReturned", locale));
-        }
+            if (noteId == null || noteId.length() == 0) {
+                return ServiceUtil.returnError(UtilProperties.getMessage(resource_error,"OrderProblemCreatingTheNoteNoNoteIdReturned", locale));
+            }
 
-        // Set the order info
-        try {
+            // Set the order info
             Map fields = UtilMisc.toMap("orderId", orderId, "noteId", noteId, "internalNote", internalNote);
             GenericValue v = delegator.makeValue("OrderHeaderNote", fields);
 
@@ -2387,8 +2388,12 @@
             Debug.logError(ee, module);
             result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR);
             result.put(ModelService.ERROR_MESSAGE, "Problem associating note with order (" + ee.getMessage() + ").");
+        } catch (GenericServiceException se) {
+            Debug.logError(se, module);
+            result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR);
+            result.put(ModelService.ERROR_MESSAGE, "Problem associating note with order (" + se.getMessage() + ").");
         }
-
+                
         return result;
     }