svn commit: r547934 - in /ofbiz/trunk/applications/product: config/ProductUiLabels.properties 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: r547934 - in /ofbiz/trunk/applications/product: config/ProductUiLabels.properties script/org/ofbiz/product/inventory/InventoryServices.xml servicedef/services_facility.xml

jacopoc
Author: jacopoc
Date: Sat Jun 16 08:54:22 2007
New Revision: 547934

URL: http://svn.apache.org/viewvc?view=rev&rev=547934
Log:
Generic permission service for the facility component.
CRUD services for the new InventoryItemLabel and InventoryItemLabelAppl entities.

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

Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels.properties?view=diff&rev=547934&r1=547933&r2=547934
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductUiLabels.properties (original)
+++ ofbiz/trunk/applications/product/config/ProductUiLabels.properties Sat Jun 16 08:54:22 2007
@@ -581,6 +581,7 @@
 ProductFacilityRoleMemberMaintenance=Facility Role Member Maintenance
 ProductFacilityType=Facility Type
 ProductFacilityTypeId=Facility Type ID
+ProductFacilityPermissionError=Security Error\: to run ${resourceDescription} you must have the CATALOG_${mainAction} or CATALOG_ADMIN or FACILITY_${mainAction} or FACILITY_ADMIN permission
 ProductFacilityViewPermissionError=You do not have permission to view this page. ("FACILITY_VIEW" or "FACILITY_ADMIN" needed)
 ProductFacilityDefaultWeightUnit=Default Weight Unit
 ProductFastLoadCatalogIntoCache=Fast Load Catalog into Cache

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?view=diff&rev=547934&r1=547933&r2=547934
==============================================================================
--- ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml (original)
+++ ofbiz/trunk/applications/product/script/org/ofbiz/product/inventory/InventoryServices.xml Sat Jun 16 08:54:22 2007
@@ -20,6 +20,59 @@
 
 <simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
+
+    <!-- a method to centralize facility security code, meant to be called in-line with
+        call-simple-method, and the checkAction and callingMethodName attributes should be in the method context -->
+    <simple-method method-name="checkFacilityRelatedPermission" short-description="Check Facility Related Permission">
+        <if-empty field-name="callingMethodName">
+            <set value="this operation" field="callingMethodName"/>
+        </if-empty>
+        <if-empty field-name="checkAction">
+            <set value="UPDATE" field="checkAction"/>
+        </if-empty>
+        
+        <if>
+            <condition>
+                <not>
+                    <or>
+                        <if-has-permission permission="CATALOG" action="_${checkAction}"/>
+                        <if-has-permission permission="FACILITY" action="_${checkAction}"/>
+                        <and>
+                            <not><if-empty field-name="alternatePermissionRoot"/></not>
+                            <if-has-permission permission="${alternatePermissionRoot}" action="_${checkAction}"/>
+                        </and>
+                    </or>
+                </not>
+            </condition>
+            <then>
+                <add-error><fail-message message="Security Error: to run ${callingMethodName} you must have the CATALOG_${checkAction} or CATALOG_ADMIN or FACILITY_${checkAction} or FACILITY_ADMIN permission."/></add-error>
+            </then>
+        </if>
+    </simple-method>
+    <simple-method method-name="facilityGenericPermission" short-description="Main permission logic">
+        <set field="mainAction" from-field="parameters.mainAction"/>
+        <if-empty field-name="mainAction">
+            <add-error><fail-message message="In the permission-service element for the facilityGenericPermission service the main-action attribute was missing but is required"/></add-error>
+            <check-errors/>
+        </if-empty>
+
+        <set field="callingMethodName" from-field="parameters.resourceDescription"/>
+        <set field="checkAction" from-field="parameters.mainAction"/>
+        <call-simple-method method-name="checkFacilityRelatedPermission"/>
+        
+        <if-empty field-name="error_list">
+            <set field="hasPermission" type="Boolean" value="true"/>
+            <field-to-result field-name="hasPermission"/>
+
+            <else>
+                <property-to-field resource="ProductUiLabels" property="ProductFacilityPermissionError" field-name="failMessage"/>
+                <set field="hasPermission" type="Boolean" value="false"/>
+                <field-to-result field-name="hasPermission"/>
+                <field-to-result field-name="failMessage"/>
+            </else>
+        </if-empty>
+    </simple-method>
+
     <!-- InventoryItem methods -->
     <simple-method method-name="createInventoryItem" short-description="Create an InventoryItem">
         <check-permission permission="CATALOG" action="_CREATE">
@@ -721,5 +774,37 @@
 
         <set-nonpk-fields map-name="parameters" value-name="inventoryTransfer"/>
         <store-value value-name="inventoryTransfer"/>
+    </simple-method>
+
+    <!-- Inventory Label Services -->
+    <simple-method method-name="createInventoryItemLabel" short-description="Create an InventoryItemLabel">
+        <make-value entity-name="InventoryItemLabel" value-name="newEntity"/>
+        <set-pk-fields map-name="parameters" value-name="newEntity"/>
+        <set-nonpk-fields map-name="parameters" value-name="newEntity"/>
+        <create-value value-name="newEntity"/>
+    </simple-method>  
+    <simple-method method-name="updateInventoryItemLabel" short-description="Update an InventoryItemLabel">
+        <entity-one entity-name="InventoryItemLabel" value-name="lookedUpValue"/>
+        <set-nonpk-fields map-name="parameters" value-name="lookedUpValue"/>
+        <store-value value-name="lookedUpValue"/>
+    </simple-method>
+    <simple-method method-name="deleteInventoryItemLabel" short-description="Delete an InventoryItemLabel">
+        <entity-one entity-name="InventoryItemLabel" value-name="lookedUpValue"/>
+        <remove-value value-name="lookedUpValue"/>
+    </simple-method>
+    <simple-method method-name="createInventoryItemLabelAppl" short-description="Create an InventoryItemLabelAppl">
+        <make-value entity-name="InventoryItemLabelAppl" value-name="newEntity"/>
+        <set-pk-fields map-name="parameters" value-name="newEntity"/>
+        <set-nonpk-fields map-name="parameters" value-name="newEntity"/>
+        <create-value value-name="newEntity"/>
+    </simple-method>  
+    <simple-method method-name="updateInventoryItemLabelAppl" short-description="Update an InventoryItemLabel">
+        <entity-one entity-name="InventoryItemLabelAppl" value-name="lookedUpValue"/>
+        <set-nonpk-fields map-name="parameters" value-name="lookedUpValue"/>
+        <store-value value-name="lookedUpValue"/>
+    </simple-method>
+    <simple-method method-name="deleteInventoryItemLabelAppl" short-description="Delete an InventoryItemLabel">
+        <entity-one entity-name="InventoryItemLabelAppl" value-name="lookedUpValue"/>
+        <remove-value value-name="lookedUpValue"/>
     </simple-method>
 </simple-methods>

Modified: ofbiz/trunk/applications/product/servicedef/services_facility.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_facility.xml?view=diff&rev=547934&r1=547933&r2=547934
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_facility.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_facility.xml Sat Jun 16 08:54:22 2007
@@ -24,6 +24,11 @@
     <vendor>OFBiz</vendor>
     <version>1.0</version>
 
+    <!-- Permission Services -->    
+    <service name="facilityGenericPermission" engine="simple"
+        location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="facilityGenericPermission">
+        <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">
@@ -700,5 +705,48 @@
         <attribute name="targetLocationSeqId" type="String" mode="IN" optional="false"/>
         <attribute name="quantityMoved" type="Double" mode="IN" optional="false"/>
         <attribute name="warningMessageList" type="List" mode="INOUT" optional="true"/>
+    </service>
+    <!-- Inventory Label Services -->
+    <service name="createInventoryItemLabel" default-entity-name="InventoryItemLabel" engine="simple"
+                location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="createInventoryItemLabel" auth="true">
+        <description>Create an InventoryItemLabel</description>
+        <permission-service service-name="facilityGenericPermission" main-action="CREATE"/>
+        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+        <override name="inventoryItemLabelTypeId" optional="false"/>
+    </service>
+    <service name="updateInventoryItemLabel" default-entity-name="InventoryItemLabel" engine="simple"
+                location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="updateInventoryItemLabel" auth="true">
+        <description>Update an InventoryItemLabel</description>
+        <permission-service service-name="facilityGenericPermission" main-action="UPDATE"/>
+        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+    </service>
+    <service name="deleteInventoryItemLabel" default-entity-name="InventoryItemLabel" engine="simple"
+                location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="deleteInventoryItemLabel" auth="true">
+        <description>Delete an InventoryItemLabel</description>
+        <permission-service service-name="facilityGenericPermission" main-action="DELETE"/>
+        <auto-attributes include="pk" mode="IN" optional="false"/>
+    </service>
+    <service name="createInventoryItemLabelAppl" default-entity-name="InventoryItemLabelAppl" engine="simple"
+                location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="createInventoryItemLabelAppl" auth="true">
+        <description>Create an InventoryItemLabelAppl</description>
+        <permission-service service-name="facilityGenericPermission" main-action="CREATE"/>
+        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+        <override name="inventoryItemLabelId" optional="false"/>
+    </service>
+    <service name="updateInventoryItemLabelAppl" default-entity-name="InventoryItemLabelAppl" engine="simple"
+                location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="updateInventoryItemLabelAppl" auth="true">
+        <description>Update an InventoryItemLabelAppl</description>
+        <permission-service service-name="facilityGenericPermission" main-action="UPDATE"/>
+        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+    </service>
+    <service name="deleteInventoryItemLabelAppl" default-entity-name="InventoryItemLabelAppl" engine="simple"
+                location="org/ofbiz/product/inventory/InventoryServices.xml" invoke="deleteInventoryItemLabelAppl" auth="true">
+        <description>Delete an InventoryItemLabelAppl</description>
+        <permission-service service-name="facilityGenericPermission" main-action="DELETE"/>
+        <auto-attributes include="pk" mode="IN" optional="false"/>
     </service>
 </services>