[ 
https://issues.apache.org/jira/browse/OFBIZ-5157?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16333180#comment-16333180
 ] 

Jacques Le Roux commented on OFBIZ-5157:
----------------------------------------

Hi Dennis,

I had a quick look. Adding
{code:xml}
Index: ShoppingListServices.xml
===================================================================
--- ShoppingListServices.xml    (revision 1821740)
+++ ShoppingListServices.xml    (working copy)
@@ -236,7 +236,7 @@
         <field-to-result field="totalPrice" result-name="totalPrice"/>
     </simple-method>

-    <simple-method method-name="checkShoppingListSecurity" 
short-description="Checks security on a ShoppingList">
+    <simple-method method-name="checkShoppingListSecurity" 
short-description="Checks security on a ShoppingList" login-required="false">
         <set field="hasPermission" value="false" type="Boolean"/>
         <if>
             <condition>
@@ -257,7 +257,7 @@
         </if>
         <field-to-result field="hasPermission"/>
     </simple-method>
-    <simple-method method-name="checkShoppingListItemSecurity" 
short-description="Checks security on a ShoppingListItem">
+    <simple-method method-name="checkShoppingListItemSecurity" 
short-description="Checks security on a ShoppingListItem" 
login-required="false">
         <set field="hasPermission" value="false" type="Boolean"/>
         <entity-one entity-name="ShoppingList" value-field="shoppingList"/>
         <if>
{code}

is not enough. You get this error
{code}
  at java.lang.Thread.run(Thread.java:745) [?:1.8.0_112]
2018-01-20 13:51:31,782 |jsse-nio-8443-exec-6 |ShoppingListEvents            
|E| null
org.apache.ofbiz.service.ServiceAuthException: User authorization is required 
for this service: createShoppingList
{code}

I let you discover the the whole log error. Jira now limits the number of chars 
in comments and also don't limit the size of the code block shown in visual 
mode, some find it better, I don't.

Actually it comes from the authorisation in checkShoppingListSecurity and 
checkShoppingListItemSecurity. So to work you need to tweak this part, this 
works
{code:xml}
Index: servicedef/services_shoppinglist.xml
===================================================================
--- servicedef/services_shoppinglist.xml        (revision 1821740)
+++ servicedef/services_shoppinglist.xml        (working copy)
@@ -33,7 +33,7 @@
     <service name="createShoppingList" engine="simple" auth="false"
             
location="component://order/minilang/shoppinglist/ShoppingListServices.xml" 
invoke="createShoppingList">
         <description>Create a shopping list entity</description>
-        <permission-service service-name="checkShoppingListSecurity" 
main-action="CREATE"/>
+        <!-- <permission-service service-name="checkShoppingListSecurity" 
main-action="CREATE"/> -->
         <implements service="createShoppingListRecurrence"/>
         <implements service="shoppingListInterface"/>
         <attribute name="shoppingListId" type="String" mode="OUT" 
optional="false"/>
@@ -120,7 +120,7 @@
     <service name="createShoppingListItem" engine="simple" auth="false"
             
location="component://order/minilang/shoppinglist/ShoppingListServices.xml" 
invoke="createShoppingListItem">
         <description>Create a shopping list item</description>
-        <permission-service service-name="checkShoppingListItemSecurity" 
main-action="CREATE"/>
+        <!-- <permission-service service-name="checkShoppingListItemSecurity" 
main-action="CREATE"/> -->
         <implements service="shoppingListItemInterface"/>
         <attribute name="shoppingListId" type="String" mode="IN" 
optional="true"/>
         <attribute name="productStoreId" type="String" mode="INOUT" 
optional="true"/>
{code}
But is of course not what we want ;) I did not digg deeper...

> Error on createShoppingListItem when adding item to cart as anonymous
> ---------------------------------------------------------------------
>
>                 Key: OFBIZ-5157
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-5157
>             Project: OFBiz
>          Issue Type: Bug
>          Components: order
>    Affects Versions: Release Branch 12.04
>            Reporter: Mirko Vogelsmeier
>            Assignee: Jacques Le Roux
>            Priority: Major
>             Fix For: Release Branch 12.04
>
>         Attachments: OFBIZ-5157-CodeCleanup.patch, 
> OFBIZ-5157-ShoppingListServices.patch
>
>
> When we add items to cart as a non-logged in user (ProductStore setting 
> autoSaveCart on 'Y') ofbiz adds that item to ShoppingList as well. Following 
> security error occures:
> {code}
>  [java] 2013-03-19 17:56:15,713 (http-bio-0.0.0.0-8080-exec-4) [     
> UtilProperties.java:1063:INFO ] ResourceBundle MiniLangErrorUiLabels (en) 
> created in 0.031s with 4 properties
>      [java] 2013-03-19 17:56:15,713 (http-bio-0.0.0.0-8080-exec-4) [    
> TransactionUtil.java:379:WARN ]
>      [java] ---- exception report 
> ----------------------------------------------------------
>      [java] [TransactionUtil.setRollbackOnly] Calling transaction 
> setRollbackOnly; this stack trace shows where this is happening:
>      [java] Exception: java.lang.Exception
>      [java] Message: Error in simple-method [Create a ShoppingList Item 
> [file:/D:/Workspace/ofbiz/applications/order/script/org/ofbiz/order/shoppinglist/ShoppingListServices.xml#createShoppingListItem]]:
>      [java] ---- stack trace 
> ---------------------------------------------------------------
>      [java] java.lang.Exception: Error in simple-method [Create a 
> ShoppingList Item 
> [file:/D:/Workspace/ofbiz/applications/order/script/org/ofbiz/order/shoppinglist/ShoppingListServices.xml#createShoppingListItem]]:
>      [java] 
> org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:379)
>      [java] 
> org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:320)
>      [java] org.ofbiz.minilang.SimpleMethod.exec(SimpleMethod.java:582)
>      [java] 
> org.ofbiz.minilang.SimpleMethod.runSimpleMethod(SimpleMethod.java:275)
>      [java] 
> org.ofbiz.minilang.SimpleMethod.runSimpleService(SimpleMethod.java:294)
>      [java] 
> org.ofbiz.minilang.SimpleServiceEngine.serviceInvoker(SimpleServiceEngine.java:79)
>      [java] 
> org.ofbiz.minilang.SimpleServiceEngine.runSync(SimpleServiceEngine.java:48)
>      [java] 
> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:390)
>      [java] 
> org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:225)
>      [java] 
> org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:163)
>      [java] 
> org.ofbiz.order.shoppinglist.ShoppingListEvents.addBulkFromCart(ShoppingListEvents.java:167)
>      [java] 
> org.ofbiz.order.shoppinglist.ShoppingListEvents.fillAutoSaveList(ShoppingListEvents.java:425)
>      [java] 
> org.ofbiz.order.shoppingcart.ShoppingCartItem.setQuantity(ShoppingCartItem.java:1059)
>      [java] 
> org.ofbiz.order.shoppingcart.ShoppingCartItem.makeItem(ShoppingCartItem.java:578)
>      [java] 
> org.ofbiz.order.shoppingcart.ShoppingCartItem.makeItem(ShoppingCartItem.java:359)
>      [java] 
> org.ofbiz.order.shoppingcart.ShoppingCart.addOrIncreaseItem(ShoppingCart.java:583)
>      [java] 
> org.ofbiz.order.shoppingcart.ShoppingCartHelper.addToCart(ShoppingCartHelper.java:246)
>      [java] 
> org.ofbiz.order.shoppingcart.ShoppingCartEvents.addToCart(ShoppingCartEvents.java:586)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to