svn commit: r611309 - in /ofbiz/trunk/applications/product: script/org/ofbiz/product/inventory/InventoryServices.xml servicedef/services_facility.xml

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

svn commit: r611309 - in /ofbiz/trunk/applications/product: script/org/ofbiz/product/inventory/InventoryServices.xml servicedef/services_facility.xml

jleroux@apache.org
Author: jleroux
Date: Fri Jan 11 13:40:44 2008
New Revision: 611309

URL: http://svn.apache.org/viewvc?rev=611309&view=rev
Log:
A patch from Abhijit Meshram " Re-Factor Facility permissions of Product component to follow new patterns." (https://issues.apache.org/jira/browse/OFBIZ-1569) - OFBIZ-1569
There was somehting weird in the patch around <!-- Product Inventory Services --> but I was able to merge easily after an update


Modified:
    ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
    ofbiz/trunk/applications/product/servicedef/services_facility.xml

Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml?rev=611309&r1=611308&r2=611309&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml Fri Jan 11 13:40:44 2008
@@ -74,14 +74,26 @@
             </else>
         </if-empty>
     </simple-method>
+    <simple-method method-name="checkProductFacilityRelatedPermission" short-description="ProductFacility Permission Checking Logic">
+         <if-empty field-name="mainAction">
+            <set field="mainAction" from-field="parameters.mainAction"/>
+            <if-empty field-name="mainAction">
+                <add-error><fail-property resource="CommonUiLabels" property="CommonPermissionMainActionAttributeMissing"/></add-error>
+            </if-empty>
+        </if-empty>
+        <check-errors/>
+        <set field="resourceDescription" from-field="parameters.resourceDescription"/>
+        <if-empty field-name="resourceDescription">
+            <property-to-field resource="CommonUiLabels" property="CommonPermissionThisOperation" field-name="resourceDescription"/>
+        </if-empty>
+        <set field="callingMethodName" from-field="resourceDescription" />
+        <set field="checkAction" from-field="mainAction" />
+        <set field="alternatePermissionRoot" value="FACILITY"/>
+        <call-simple-method method-name="checkProductRelatedPermission" xml-resource="org/ofbiz/product/product/ProductServices.xml"/>
+    </simple-method>
 
     <!-- InventoryItem methods -->
     <simple-method method-name="createInventoryItem" short-description="Create an InventoryItem">
-        <check-permission permission="CATALOG" action="_CREATE">
-            <alt-permission permission="FACILITY" action="_CREATE"/>
-            <fail-message message="Security Error: to run createInventoryItem you must have the CATALOG_CREATE, CATALOG_ADMIN, FACILITY_CREATE, or FACILITY_ADMIN permission"/>
-        </check-permission>
-        <check-errors/>
 
         <make-value value-name="inventoryItem" entity-name="InventoryItem"/>
         <!-- TODO: make sure availableToPromiseTotal and quantityOnHandTotal are not changed -->
@@ -199,11 +211,6 @@
     </simple-method>
 
     <simple-method method-name="updateInventoryItem" short-description="Update an InventoryItem">
-        <check-permission permission="CATALOG" action="_UPDATE">
-            <alt-permission permission="FACILITY" action="_UPDATE"/>
-            <fail-message message="Security Error: to run updateInventoryItem you must have the CATALOG_UPDATE, CATALOG_ADMIN, FACILITY_UPDATE, or FACILITY_ADMIN permission"/>
-        </check-permission>
-        <check-errors/>
 
         <make-value entity-name="InventoryItem" value-name="lookupPKMap"/>
         <set-pk-fields map-name="parameters" value-name="lookupPKMap"/>
@@ -448,10 +455,6 @@
 
 
     <simple-method method-name="createInventoryItemVariance" short-description="Create an InventoryItemVariance">
-        <check-permission permission="CATALOG" action="_CREATE">
-            <alt-permission permission="FACILITY" action="_CREATE"/>
-            <fail-message message="Security Error: to run createInventoryItemVariance you must have the CATALOG_CREATE, CATALOG_ADMIN, FACILITY_CREATE, or FACILITY_ADMIN permission"/>
-        </check-permission>
 
         <!-- add changes to availableToPromise and quantityOnHand -->
         <make-value value-name="inventoryItemLookup" entity-name="InventoryItem"/>
@@ -481,11 +484,6 @@
         <!-- TODO: make sure availableToPromise is never greater than the quantityOnHand? -->
     </simple-method>
     <simple-method method-name="createPhysicalInventory" short-description="Create a PhysicalInventory">
-        <check-permission permission="CATALOG" action="_CREATE">
-            <alt-permission permission="FACILITY" action="_CREATE"/>
-            <fail-message message="Security Error: to run createPhysicalInventory you must have the CATALOG_CREATE, CATALOG_ADMIN, FACILITY_CREATE, or FACILITY_ADMIN permission"/>
-        </check-permission>
-        <check-errors/>
 
         <make-value value-name="newEntity" entity-name="PhysicalInventory"/>
         <set-nonpk-fields map-name="parameters" value-name="newEntity"/>
@@ -515,11 +513,6 @@
 
     <!-- ProductFacility methods -->
     <simple-method method-name="createProductFacility" short-description="Create a ProductFacility">
-        <set value="createProductFacility" field="callingMethodName"/>
-        <set value="CREATE" field="checkAction"/>
-        <set value="FACILITY" field="alternatePermissionRoot"/>
-        <call-simple-method method-name="checkProductRelatedPermission" xml-resource="org/ofbiz/product/product/ProductServices.xml"/>
-        <check-errors/>
 
         <make-value value-name="newEntity" entity-name="ProductFacility"/>
         <set-nonpk-fields map-name="parameters" value-name="newEntity"/>
@@ -527,11 +520,6 @@
         <create-value value-name="newEntity"/>
     </simple-method>
     <simple-method method-name="updateProductFacility" short-description="Update a ProductFacility">
-        <set value="updateProductFacility" field="callingMethodName"/>
-        <set value="UPDATE" field="checkAction"/>
-        <set value="FACILITY" field="alternatePermissionRoot"/>
-        <call-simple-method method-name="checkProductRelatedPermission" xml-resource="org/ofbiz/product/product/ProductServices.xml"/>
-        <check-errors/>
 
         <make-value entity-name="ProductFacility" value-name="lookupPKMap"/>
         <set-pk-fields map-name="parameters" value-name="lookupPKMap"/>
@@ -540,11 +528,6 @@
         <store-value value-name="lookedUpValue"/>
     </simple-method>
     <simple-method method-name="deleteProductFacility" short-description="Delete a ProductFacility">
-        <set value="deleteProductFacility" field="callingMethodName"/>
-        <set value="DELETE" field="checkAction"/>
-        <set value="FACILITY" field="alternatePermissionRoot"/>
-        <call-simple-method method-name="checkProductRelatedPermission" xml-resource="org/ofbiz/product/product/ProductServices.xml"/>
-        <check-errors/>
 
         <make-value entity-name="ProductFacility" value-name="lookupPKMap"/>
         <set-pk-fields map-name="parameters" value-name="lookupPKMap"/>
@@ -554,11 +537,6 @@
 
     <!-- ProductFacilityLocation methods -->
     <simple-method method-name="createProductFacilityLocation" short-description="Create a ProductFacilityLocation">
-        <set value="createProductFacilityLocation" field="callingMethodName"/>
-        <set value="CREATE" field="checkAction"/>
-        <set value="FACILITY" field="alternatePermissionRoot"/>
-        <call-simple-method method-name="checkProductRelatedPermission" xml-resource="org/ofbiz/product/product/ProductServices.xml"/>
-        <check-errors/>
 
         <make-value value-name="newEntity" entity-name="ProductFacilityLocation"/>
         <set-nonpk-fields map-name="parameters" value-name="newEntity"/>
@@ -566,11 +544,6 @@
         <create-value value-name="newEntity"/>
     </simple-method>
     <simple-method method-name="updateProductFacilityLocation" short-description="Update a ProductFacilityLocation">
-        <set value="updateProductFacilityLocation" field="callingMethodName"/>
-        <set value="UPDATE" field="checkAction"/>
-        <set value="FACILITY" field="alternatePermissionRoot"/>
-        <call-simple-method method-name="checkProductRelatedPermission" xml-resource="org/ofbiz/product/product/ProductServices.xml"/>
-        <check-errors/>
 
         <make-value entity-name="ProductFacilityLocation" value-name="lookupPKMap"/>
         <set-pk-fields map-name="parameters" value-name="lookupPKMap"/>
@@ -579,11 +552,6 @@
         <store-value value-name="lookedUpValue"/>
     </simple-method>
     <simple-method method-name="deleteProductFacilityLocation" short-description="Delete a ProductFacilityLocation">
-        <set value="deleteProductFacilityLocation" field="callingMethodName"/>
-        <set value="DELETE" field="checkAction"/>
-        <set value="FACILITY" field="alternatePermissionRoot"/>
-        <call-simple-method method-name="checkProductRelatedPermission" xml-resource="org/ofbiz/product/product/ProductServices.xml"/>
-        <check-errors/>
 
         <make-value entity-name="ProductFacilityLocation" value-name="lookupPKMap"/>
         <set-pk-fields map-name="parameters" value-name="lookupPKMap"/>
@@ -854,8 +822,6 @@
 
     <!-- Inventory Transfer Services -->
     <simple-method method-name="createInventoryTransfer" short-description="Create an Inventory Transfer">
-        <check-permission permission="FACILITY" action="_CREATE"><fail-message message="Security Error: to run createInventoryTransfer you must have the FACILITY_CREATE or FACILITY_ADMIN permission"/></check-permission>
-        <check-errors/>
 
         <make-value value-name="newEntity" entity-name="InventoryTransfer"/>
         <set-nonpk-fields map-name="parameters" value-name="newEntity"/>
@@ -865,10 +831,6 @@
         <create-value value-name="newEntity"/>
     </simple-method>
     <simple-method method-name="updateInventoryTransfer" short-description="Update an Inventory Transfer">
-        <check-permission permission="FACILITY" action="_UPDATE">
-            <fail-message message="Security Error: to run updateInventoryTransfer you must have the FACILITY_UPDATE or FACILITY_ADMIN permission"/>
-        </check-permission>
-        <check-errors/>
 
         <set from-field="parameters.inventoryTransferId" field="lookupPKMap.inventoryTransferId"/>
         <find-by-primary-key entity-name="InventoryTransfer" map-name="lookupPKMap" value-name="inventoryTransfer"/>
@@ -892,8 +854,6 @@
     </simple-method>
 
     <simple-method method-name="createInventoryTransfersForProduct" short-description="Create inventory transfers for the given product and quantity. Return the units not available for transfers.">
-        <check-permission permission="FACILITY" action="_CREATE"><fail-message message="Security Error: to run createInventoryTransfer you must have the FACILITY_CREATE or FACILITY_ADMIN permission"/></check-permission>
-        <check-errors/>
 
         <set from-field="parameters.productId" field="lookupFieldMap.productId"/>
         <set from-field="parameters.facilityId" field="lookupFieldMap.facilityId"/>

Modified: ofbiz/trunk/applications/product/servicedef/services_facility.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_facility.xml?rev=611309&r1=611308&r2=611309&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_facility.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_facility.xml Fri Jan 11 13:40:44 2008
@@ -29,10 +29,21 @@
         location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="facilityGenericPermission">
         <implements service="permissionInterface"/>
     </service>
+    <service name="checkFacilityRelatedPermission" engine="simple"
+            location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="checkFacilityRelatedPermission">
+        <description>Facility Permission Checking Logic</description>
+        <implements service="permissionInterface"/>
+    </service>
+    <service name="checkProductFacilityRelatedPermission" engine="simple"
+            location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="checkProductFacilityRelatedPermission">
+        <description>ProductFacility Permission Checking Logic</description>
+        <implements service="permissionInterface"/>
+    </service>
     <!-- Product Inventory Services -->
     <service name="createInventoryItem" default-entity-name="InventoryItem" engine="simple"
                 location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="createInventoryItem" auth="true">
         <description>Create an InventoryItem</description>
+        <permission-service service-name="checkFacilityRelatedPermission" main-action="CREATE"/>
         <auto-attributes include="pk" mode="OUT" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true">
             <exclude field-name="availableToPromiseTotal"/>
@@ -54,6 +65,7 @@
     <service name="updateInventoryItem" default-entity-name="InventoryItem" engine="simple"
                 location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="updateInventoryItem" auth="true">
         <description>Update an InventoryItem</description>
+        <permission-service service-name="checkFacilityRelatedPermission" main-action="UPDATE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true">
             <exclude field-name="availableToPromiseTotal"/>
@@ -109,12 +121,14 @@
     <service name="createInventoryItemVariance" default-entity-name="InventoryItemVariance" engine="simple"
                 location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="createInventoryItemVariance" auth="true">
         <description>Create an InventoryItemVariance - note that the quantityOnHand and availableToPromise are relative and will be added to the corresponding value on the given InventoryItem</description>
+        <permission-service service-name="checkFacilityRelatedPermission" main-action="CREATE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
     <service name="createPhysicalInventory" default-entity-name="PhysicalInventory" engine="simple"
                 location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="createPhysicalInventory" auth="true">
         <description>Create an PhysicalInventory</description>
+        <permission-service service-name="checkFacilityRelatedPermission" main-action="CREATE"/>
         <auto-attributes include="pk" mode="OUT" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
@@ -358,6 +372,7 @@
     <service name="createInventoryTransfer" engine="simple"
             location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="createInventoryTransfer" auth="true">
         <description>Create an inventory transfer.  Uses the prepareInventoryTransfer service; see comments there about transfer quantities and inventory items.</description>
+        <permission-service service-name="facilityGenericPermission" main-action="CREATE"/>
         <implements service="interfaceInventoryTransfer"/>
         <attribute name="xferQty" type="Double" mode="IN" optional="false"/>
         <attribute name="inventoryTransferId" type="String" mode="OUT" optional="false"/>
@@ -365,6 +380,7 @@
     <service name="updateInventoryTransfer" engine="simple"
             location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="updateInventoryTransfer" auth="true">
         <description>Update an inventory transfer record</description>
+        <permission-service service-name="facilityGenericPermission" main-action="UPDATE"/>
         <implements service="interfaceInventoryTransfer"/>
         <attribute name="inventoryTransferId" type="String" mode="IN" optional="false"/>
     </service>
@@ -388,6 +404,7 @@
     <service name="createInventoryTransfersForProduct" engine="simple"
             location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="createInventoryTransfersForProduct" auth="true">
         <description>Create inventory transfers for the given product and quantity. Return the units not available for transfers.</description>
+        <permission-service service-name="facilityGenericPermission" main-action="CREATE"/>
         <attribute name="facilityId" type="String" mode="IN" optional="false"/>
         <attribute name="containerId" type="String" mode="IN" optional="true"/>
         <attribute name="facilityIdTo" type="String" mode="IN" optional="false"/>
@@ -421,36 +438,42 @@
     <service name="createProductFacility" default-entity-name="ProductFacility" engine="simple"
                 location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="createProductFacility" auth="true">
         <description>Create an ProductFacility</description>
+        <permission-service service-name="checkProductFacilityRelatedPermission" main-action="CREATE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
     <service name="updateProductFacility" default-entity-name="ProductFacility" engine="simple"
                 location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="updateProductFacility" auth="true">
         <description>Update an ProductFacility</description>
+        <permission-service service-name="checkProductFacilityRelatedPermission" main-action="UPDATE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
     <service name="deleteProductFacility" default-entity-name="ProductFacility" engine="simple"
                 location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="deleteProductFacility" auth="true">
         <description>Delete an ProductFacility</description>
+        <permission-service service-name="checkProductFacilityRelatedPermission" main-action="DELETE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
     </service>
 
     <service name="createProductFacilityLocation" default-entity-name="ProductFacilityLocation" engine="simple"
                 location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="createProductFacilityLocation" auth="true">
         <description>Create an ProductFacilityLocation</description>
+        <permission-service service-name="checkProductFacilityRelatedPermission" main-action="CREATE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
     <service name="updateProductFacilityLocation" default-entity-name="ProductFacilityLocation" engine="simple"
                 location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="updateProductFacilityLocation" auth="true">
         <description>Update an ProductFacilityLocation</description>
+        <permission-service service-name="checkProductFacilityRelatedPermission" main-action="UPDATE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
     <service name="deleteProductFacilityLocation" default-entity-name="ProductFacilityLocation" engine="simple"
                 location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="deleteProductFacilityLocation" auth="true">
         <description>Delete an ProductFacilityLocation</description>
+        <permission-service service-name="checkProductFacilityRelatedPermission" main-action="DELETE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
     </service>