svn commit: r611311 - in /ofbiz/trunk/applications/product: script/org/ofbiz/product/catalog/CatalogServices.xml servicedef/services.xml

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

svn commit: r611311 - in /ofbiz/trunk/applications/product: script/org/ofbiz/product/catalog/CatalogServices.xml servicedef/services.xml

jleroux@apache.org
Author: jleroux
Date: Fri Jan 11 13:51:05 2008
New Revision: 611311

URL: http://svn.apache.org/viewvc?rev=611311&view=rev
Log:
A patch from Shubham Goyal "Refactor the Catalog Permission as per the new pattern" (https://issues.apache.org/jira/browse/OFBIZ-1570) - OFBIZ-1570


Modified:
    ofbiz/trunk/applications/product/script/org/ofbiz/product/catalog/CatalogServices.xml
    ofbiz/trunk/applications/product/servicedef/services.xml

Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/catalog/CatalogServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/catalog/CatalogServices.xml?rev=611311&r1=611310&r2=611311&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/catalog/CatalogServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/catalog/CatalogServices.xml Fri Jan 11 13:51:05 2008
@@ -21,9 +21,6 @@
 <simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
     <simple-method method-name="createProdCatalog" short-description="Create an ProdCatalog">
-        <check-permission permission="CATALOG" action="_CREATE"><fail-message message="Security Error: to run createProdCatalog you must have the CATALOG_CREATE or CATALOG_ADMIN permission"/></check-permission>
-        <check-errors/>
-
         <make-value value-name="newEntity" entity-name="ProdCatalog"/>
         <set-nonpk-fields map-name="parameters" value-name="newEntity"/>
         <set-pk-fields map-name="parameters" value-name="newEntity"/>
@@ -31,23 +28,16 @@
         <create-value value-name="newEntity"/>
     </simple-method>
     <simple-method method-name="updateProdCatalog" short-description="Update an ProdCatalog">
-        <check-permission permission="CATALOG" action="_UPDATE"><fail-message message="Security Error: to run updateProdCatalog you must have the CATALOG_UPDATE or CATALOG_ADMIN permission"/></check-permission>
-        <check-errors/>
-
         <entity-one entity-name="ProdCatalog"  value-name="prodCatalog"/>
         <set-nonpk-fields map-name="parameters" value-name="prodCatalog"/>
         <store-value value-name="prodCatalog"/>
     </simple-method>
     <simple-method method-name="deleteProdCatalog" short-description="Delete an ProdCatalog">
-        <check-permission permission="CATALOG" action="_DELETE"><fail-message message="Security Error: to run deleteProdCatalog you must have the CATALOG_DELETE or CATALOG_ADMIN permission"/></check-permission>
-        <check-errors/>
-
         <entity-one entity-name="ProdCatalog"  value-name="prodCatalog"/>
         <remove-value value-name="prodCatalog"/>
     </simple-method>
 
     <simple-method method-name="addProductCategoryToProdCatalog" short-description="Add Category To ProdCatalog">
-        <check-permission permission="CATALOG" action="_CREATE"><fail-message message="Security Error: to run addProductCategoryToProdCatalog you must have the CATALOG_CREATE or CATALOG_ADMIN permission"/></check-permission>
         <!-- Check that the ProductCategory exists -->
         <entity-one entity-name="ProductCategory" value-name="productCategory"/>
         <if-empty field-name="productCategory">
@@ -67,8 +57,6 @@
         <create-value value-name="newEntity"/>
     </simple-method>
     <simple-method method-name="updateProductCategoryToProdCatalog" short-description="Remove ContactMech From ProdCatalog">
-        <check-permission permission="CATALOG" action="_UPDATE"><fail-message message="Security Error: to run updateProductCategoryToProdCatalog you must have the CATALOG_UPDATE or CATALOG_ADMIN permission"/></check-permission>
-        <check-errors/>
 
         <make-value value-name="lookupPKMap" entity-name="ProdCatalogCategory"/>
         <set-pk-fields map-name="parameters" value-name="lookupPKMap"/>
@@ -77,8 +65,6 @@
         <store-value value-name="prodCatalogCategory"/>
     </simple-method>
     <simple-method method-name="removeProductCategoryFromProdCatalog" short-description="Remove ContactMech From ProdCatalog">
-        <check-permission permission="CATALOG" action="_DELETE"><fail-message message="Security Error: to run removeProductCategoryFromProdCatalog you must have the CATALOG_DELETE or CATALOG_ADMIN permission"/></check-permission>
-        <check-errors/>
 
         <make-value value-name="lookupPKMap" entity-name="ProdCatalogCategory"/>
         <set-pk-fields map-name="parameters" value-name="lookupPKMap"/>
@@ -88,12 +74,6 @@
 
     <!-- Party and Catalog services -->
     <simple-method method-name="addProdCatalogToParty" short-description="Add ProdCatalog To Party">
-        <check-permission permission="CATALOG" action="_CREATE">
-            <alt-permission permission="PARTYMGR" action="_CREATE"/>
-            <fail-message message="Security Error: to run addProdCatalogToParty you must have the CATALOG_CREATE or CATALOG_ADMIN permission"/>
-        </check-permission>
-        <check-errors/>
-
         <make-value value-name="newEntity" entity-name="ProdCatalogRole"/>
         <set-pk-fields map-name="parameters" value-name="newEntity"/>
         <set-nonpk-fields map-name="parameters" value-name="newEntity"/>
@@ -105,12 +85,6 @@
         <create-value value-name="newEntity"/>
     </simple-method>
     <simple-method method-name="updateProdCatalogToParty" short-description="Update ProdCatalog To Party">
-        <check-permission permission="CATALOG" action="_UPDATE">
-            <alt-permission permission="PARTYMGR" action="_UPDATE"/>
-            <fail-message message="Security Error: to run updateProdCatalogToParty you must have the CATALOG_UPDATE or CATALOG_ADMIN permission"/>
-        </check-permission>
-        <check-errors/>
-
         <make-value value-name="lookupPKMap" entity-name="ProdCatalogRole"/>
         <set-pk-fields map-name="parameters" value-name="lookupPKMap"/>
         <find-by-primary-key entity-name="ProdCatalogRole" map-name="lookupPKMap" value-name="lookedUpValue"/>
@@ -118,12 +92,6 @@
         <store-value value-name="lookedUpValue"/>
     </simple-method>
     <simple-method method-name="removeProdCatalogFromParty" short-description="Remove ProdCatalog From Party">
-        <check-permission permission="CATALOG" action="_DELETE">
-            <alt-permission permission="PARTYMGR" action="_DELETE"/>
-            <fail-message message="Security Error: to run removeProdCatalogFromParty you must have the CATALOG_DELETE or CATALOG_ADMIN permission"/>
-        </check-permission>
-        <check-errors/>
-
         <make-value value-name="lookupPKMap" entity-name="ProdCatalogRole"/>
         <set-pk-fields map-name="parameters" value-name="lookupPKMap"/>
         <find-by-primary-key entity-name="ProdCatalogRole" map-name="lookupPKMap" value-name="lookedUpValue"/>
@@ -531,4 +499,15 @@
         </if-not-empty>  
         <field-to-result result-name="isExists" field-name="isExists"/>
     </simple-method>
+    
+    <simple-method method-name="catalogPermissionCheck" short-description="Catalog permission logic">
+        <set field="primaryPermission" value="CATALOG"/>
+        <call-simple-method method-name="genericBasePermissionCheck" xml-resource="component://common/script/org/ofbiz/common/permission/CommonPermissionServices.xml"/>
+    </simple-method>
+    
+    <simple-method method-name="prodCatalogToPartyPermissionCheck" short-description="ProdCatalogToParty permission logic">
+        <set field="altPermission" value="PARTYMGR"/>
+        <call-simple-method method-name="catalogPermissionCheck"/>
+    </simple-method>
+    
 </simple-methods>

Modified: ofbiz/trunk/applications/product/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services.xml?rev=611311&r1=611310&r2=611311&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services.xml Fri Jan 11 13:51:05 2008
@@ -546,6 +546,7 @@
     <service name="createProdCatalog" default-entity-name="ProdCatalog" engine="simple"
                 location="org/ofbiz/product/catalog/CatalogServices.xml" invoke="createProdCatalog" auth="true">
         <description>Create a ProdCatalog</description>
+        <permission-service service-name="catalogPermissionCheck" main-action="CREATE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
         <override name="catalogName" optional="false"/>
@@ -553,6 +554,7 @@
     <service name="updateProdCatalog" default-entity-name="ProdCatalog" engine="simple"
                 location="org/ofbiz/product/catalog/CatalogServices.xml" invoke="updateProdCatalog" auth="true">
         <description>Update an ProdCatalog</description>
+        <permission-service service-name="catalogPermissionCheck" main-action="UPDATE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
         <override name="catalogName" optional="false"/>
@@ -560,12 +562,14 @@
     <service name="deleteProdCatalog" default-entity-name="ProdCatalog" engine="simple"
                 location="org/ofbiz/product/catalog/CatalogServices.xml" invoke="deleteProdCatalog" auth="true">
         <description>Delete an ProdCatalog</description>
+        <permission-service service-name="catalogPermissionCheck" main-action="DELETE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
     </service>
 
     <service name="addProductCategoryToProdCatalog" default-entity-name="ProdCatalogCategory" engine="simple"
                 location="org/ofbiz/product/catalog/CatalogServices.xml" invoke="addProductCategoryToProdCatalog" auth="true">
         <description>Add ProductCategory To ProdCatalog</description>
+        <permission-service service-name="catalogPermissionCheck" main-action="CREATE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
         <override name="fromDate" optional="true"/>
@@ -573,6 +577,7 @@
     <service name="updateProductCategoryToProdCatalog" default-entity-name="ProdCatalogCategory" engine="simple"
                 location="org/ofbiz/product/catalog/CatalogServices.xml" invoke="updateProductCategoryToProdCatalog" auth="true">
         <description>Add ProductCategory To ProdCatalog</description>
+        <permission-service service-name="catalogPermissionCheck" main-action="UPDATE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
         <override name="prodCatalogCategoryTypeId" optional="false"/>
@@ -580,12 +585,14 @@
     <service name="removeProductCategoryFromProdCatalog" default-entity-name="ProdCatalogCategory" engine="simple"
                 location="org/ofbiz/product/catalog/CatalogServices.xml" invoke="removeProductCategoryFromProdCatalog" auth="true">
         <description>Remove ProductCategory From ProdCatalog</description>
+        <permission-service service-name="catalogPermissionCheck" main-action="DELETE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
     </service>
 
     <service name="addProdCatalogToParty" default-entity-name="ProdCatalogRole" engine="simple"
                 location="org/ofbiz/product/catalog/CatalogServices.xml" invoke="addProdCatalogToParty" auth="true">
         <description>Add ProdCatalog To Party</description>
+        <permission-service service-name="prodCatalogToPartyPermissionCheck" main-action="CREATE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
         <override name="fromDate" optional="true"/>
@@ -593,12 +600,14 @@
     <service name="updateProdCatalogToParty" default-entity-name="ProdCatalogRole" engine="simple"
                 location="org/ofbiz/product/catalog/CatalogServices.xml" invoke="updateProdCatalogToParty" auth="true">
         <description>Add ProdCatalog To Party</description>
+        <permission-service service-name="prodCatalogToPartyPermissionCheck" main-action="UPDATE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
     <service name="removeProdCatalogFromParty" default-entity-name="ProdCatalogRole" engine="simple"
                 location="org/ofbiz/product/catalog/CatalogServices.xml" invoke="removeProdCatalogFromParty" auth="true">
         <description>Remove ProdCatalog From Party</description>
+        <permission-service service-name="prodCatalogToPartyPermissionCheck" main-action="DELETE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
     </service>
 
@@ -1182,5 +1191,17 @@
                 location="org/ofbiz/product/product/ProductServices.xml" invoke="deleteProductCategoryGlAccount" auth="true">
         <description>Delete a ProductCategoryGlAccount</description>
         <auto-attributes include="pk" mode="IN" optional="false"/>
+    </service>
+    
+    <service name="catalogPermissionCheck" engine="simple"
+        location="org/ofbiz/product/catalog/CatalogServices.xml" invoke="catalogPermissionCheck" auth="true">
+        <description>Catalog Permission Checking Logic</description>
+        <implements service="permissionInterface"/>
+    </service>
+    
+    <service name="prodCatalogToPartyPermissionCheck" engine="simple"
+            location="org/ofbiz/product/catalog/CatalogServices.xml" invoke="prodCatalogToPartyPermissionCheck">
+        <description>ProdCatalogToParty Permission Checking Logic</description>
+        <implements service="permissionInterface"/>
     </service>
 </services>