svn commit: r498540 - in /ofbiz/trunk/framework/common: ./ config/ data/ script/org/ofbiz/common/ script/org/ofbiz/common/datasource/ servicedef/

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

svn commit: r498540 - in /ofbiz/trunk/framework/common: ./ config/ data/ script/org/ofbiz/common/ script/org/ofbiz/common/datasource/ servicedef/

jonesde
Author: jonesde
Date: Sun Jan 21 22:07:21 2007
New Revision: 498540

URL: http://svn.apache.org/viewvc?view=rev&rev=498540
Log:
Added some Enumeration services; also refactored permissions for various of the common services to use the new permission-service pattern

Added:
    ofbiz/trunk/framework/common/data/CommonSecurityData.xml   (with props)
    ofbiz/trunk/framework/common/script/org/ofbiz/common/EnumerationServices.xml   (with props)
Modified:
    ofbiz/trunk/framework/common/config/CommonUiLabels.properties
    ofbiz/trunk/framework/common/ofbiz-component.xml
    ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml
    ofbiz/trunk/framework/common/script/org/ofbiz/common/datasource/DataSourceServices.xml
    ofbiz/trunk/framework/common/script/org/ofbiz/common/datasource/DataSourceTypeServices.xml
    ofbiz/trunk/framework/common/servicedef/services.xml

Modified: ofbiz/trunk/framework/common/config/CommonUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/CommonUiLabels.properties?view=diff&rev=498540&r1=498539&r2=498540
==============================================================================
--- ofbiz/trunk/framework/common/config/CommonUiLabels.properties (original)
+++ ofbiz/trunk/framework/common/config/CommonUiLabels.properties Sun Jan 21 22:07:21 2007
@@ -280,6 +280,7 @@
 CommonPartyID=Party Id
 CommonPassword=Password
 CommonPerform=Perform
+CommonPermissionErrorMessage=Security Error\: to run ${resourceDescription} you must have the EXAMPLE_${mainAction} or EXAMPLE_ADMIN permission
 CommonPermissionError=Permission Error
 CommonPerson=Person
 CommonPostedBy=Posted By

Added: ofbiz/trunk/framework/common/data/CommonSecurityData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/data/CommonSecurityData.xml?view=auto&rev=498540
==============================================================================
--- ofbiz/trunk/framework/common/data/CommonSecurityData.xml (added)
+++ ofbiz/trunk/framework/common/data/CommonSecurityData.xml Sun Jan 21 22:07:21 2007
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed under the Apache License, Version 2.0 (the "License"); you may not
+use this file except in compliance with the License. You may obtain a copy of
+the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+License for the specific language governing permissions and limitations
+under the License.
+-->
+
+<entity-engine-xml>
+    <!-- Common Services security -->
+    <SecurityPermission description="View operations in the Common Component." permissionId="COMMON_VIEW"/>
+    <SecurityPermission description="Create operations in the Common Component." permissionId="COMMON_CREATE"/>
+    <SecurityPermission description="Update operations in the Common Component." permissionId="COMMON_UPDATE"/>
+    <SecurityPermission description="Delete operations in the Common Component." permissionId="COMMON_DELETE"/>
+
+    <SecurityGroupPermission groupId="FULLADMIN" permissionId="COMMON_ADMIN"/>
+    <SecurityGroupPermission groupId="FLEXADMIN" permissionId="COMMON_CREATE"/>
+    <SecurityGroupPermission groupId="FLEXADMIN" permissionId="COMMON_DELETE"/>
+    <SecurityGroupPermission groupId="FLEXADMIN" permissionId="COMMON_UPDATE"/>
+    <SecurityGroupPermission groupId="FLEXADMIN" permissionId="COMMON_VIEW"/>
+
+    <SecurityGroupPermission groupId="VIEWADMIN" permissionId="COMMON_VIEW"/>
+    <SecurityGroupPermission groupId="BIZADMIN" permissionId="COMMON_ADMIN"/>
+</entity-engine-xml>

Propchange: ofbiz/trunk/framework/common/data/CommonSecurityData.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/framework/common/data/CommonSecurityData.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/framework/common/data/CommonSecurityData.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: ofbiz/trunk/framework/common/ofbiz-component.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/ofbiz-component.xml?view=diff&rev=498540&r1=498539&r2=498540
==============================================================================
--- ofbiz/trunk/framework/common/ofbiz-component.xml (original)
+++ ofbiz/trunk/framework/common/ofbiz-component.xml Sun Jan 21 22:07:21 2007
@@ -24,6 +24,7 @@
     <classpath type="dir" location="script"/>
     <entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel.xml"/>
     <entity-resource type="group" reader-name="main" loader="main" location="entitydef/entitygroup.xml"/>
+    <entity-resource type="data" reader-name="seed" loader="main" location="data/CommonSecurityData.xml"/>
     <entity-resource type="data" reader-name="seed" loader="main" location="data/CommonTypeData.xml"/>
     <entity-resource type="data" reader-name="seed" loader="main" location="data/CountryCodeData.xml"/>
     <entity-resource type="data" reader-name="seed" loader="main" location="data/CurrencyData.xml"/>

Modified: ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml?view=diff&rev=498540&r1=498539&r2=498540
==============================================================================
--- ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml (original)
+++ ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml Sun Jan 21 22:07:21 2007
@@ -18,6 +18,24 @@
 
 <simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/simple-methods.xsd">
+    <simple-method method-name="commonGenericPermission" 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 commonGenericPermission service the main-action attribute was missing but is required"/></add-error>
+            <check-errors/>
+        </if-empty>
+        <if-has-permission permission="COMMON" action="_${parameters.mainAction}">
+            <set field="hasPermission" type="Boolean" value="true"/>
+            <field-to-result field-name="hasPermission"/>
+            <else>
+                <property-to-field resource="CommonUiLabels" property="CommonPermissionErrorMessage" field-name="failMessage"/>
+                <set field="hasPermission" type="Boolean" value="false"/>
+                <field-to-result field-name="hasPermission"/>
+                <field-to-result field-name="failMessage"/>
+            </else>
+        </if-has-permission>
+    </simple-method>
+    
     <simple-method method-name="createKeywordThesaurus" short-description="Create a KeywordThesaurus">
         <check-permission permission="CATALOG" action="_CREATE"><fail-message message="Security Error: to run createKeywordThesaurus you must have the CATALOG_CREATE or CATALOG_ADMIN permission"/></check-permission>
         <check-errors/>
@@ -146,7 +164,5 @@
             </call-service>
         </else>
         </if-empty>
-
     </simple-method>
-
 </simple-methods>

Added: ofbiz/trunk/framework/common/script/org/ofbiz/common/EnumerationServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/script/org/ofbiz/common/EnumerationServices.xml?view=auto&rev=498540
==============================================================================
--- ofbiz/trunk/framework/common/script/org/ofbiz/common/EnumerationServices.xml (added)
+++ ofbiz/trunk/framework/common/script/org/ofbiz/common/EnumerationServices.xml Sun Jan 21 22:07:21 2007
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed under the Apache License, Version 2.0 (the "License"); you may not
+use this file except in compliance with the License. You may obtain a copy of
+the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+License for the specific language governing permissions and limitations
+under the License.
+-->
+
+<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/simple-methods.xsd">
+    <!-- Enumeration methods -->
+    <simple-method method-name="createEnumeration" short-description="create a Enumeration">
+        <make-value entity-name="Enumeration" value-name="newEntity"/>
+        <sequenced-id-to-env sequence-name="Enumeration" env-name="newEntity.enumId"/> <!-- get the next sequenced ID -->
+        <field-to-result field-name="newEntity.enumId" result-name="enumId"/>
+        <set-nonpk-fields map-name="parameters" value-name="newEntity"/>
+        <create-value value-name="newEntity"/>
+    </simple-method>  
+    <simple-method method-name="updateEnumeration" short-description="update a Enumeration">
+        <entity-one entity-name="Enumeration" value-name="lookedUpValue"/>
+        <set-nonpk-fields map-name="parameters" value-name="lookedUpValue"/>
+        <store-value value-name="lookedUpValue"/>
+    </simple-method>
+</simple-methods>

Propchange: ofbiz/trunk/framework/common/script/org/ofbiz/common/EnumerationServices.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/framework/common/script/org/ofbiz/common/EnumerationServices.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/framework/common/script/org/ofbiz/common/EnumerationServices.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: ofbiz/trunk/framework/common/script/org/ofbiz/common/datasource/DataSourceServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/script/org/ofbiz/common/datasource/DataSourceServices.xml?view=diff&rev=498540&r1=498539&r2=498540
==============================================================================
--- ofbiz/trunk/framework/common/script/org/ofbiz/common/datasource/DataSourceServices.xml (original)
+++ ofbiz/trunk/framework/common/script/org/ofbiz/common/datasource/DataSourceServices.xml Sun Jan 21 22:07:21 2007
@@ -20,10 +20,6 @@
         xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/simple-methods.xsd">
     <!-- DataSource methods -->
     <simple-method method-name="createDataSource" short-description="Create an DataSource">
-        <!-- DEJ 2002-10-19: MARKETING may not be the best place to put this, but it'll do for now -->
-        <check-permission permission="MARKETING" action="_CREATE"><fail-message message="Security Error: to run createDataSource you must have the MARKETING_CREATE or MARKETING_ADMIN permission"/></check-permission>
-        <check-errors/>
-
         <make-value value-name="newEntity" entity-name="DataSource"/>
         <set-nonpk-fields map-name="parameters" value-name="newEntity"/>
         <set-pk-fields map-name="parameters" value-name="newEntity"/>
@@ -31,9 +27,6 @@
         <create-value value-name="newEntity"/>
     </simple-method>
     <simple-method method-name="updateDataSource" short-description="Update an DataSource">
-        <check-permission permission="MARKETING" action="_UPDATE"><fail-message message="Security Error: to run updateDataSource you must have the MARKETING_UPDATE or MARKETING_ADMIN permission"/></check-permission>
-        <check-errors/>
-
         <make-value entity-name="DataSource" value-name="lookupPKMap"/>
         <set-pk-fields map-name="parameters" value-name="lookupPKMap"/>
         <find-by-primary-key entity-name="DataSource" map-name="lookupPKMap" value-name="lookedUpValue"/>
@@ -41,9 +34,6 @@
         <store-value value-name="lookedUpValue"/>
     </simple-method>
     <simple-method method-name="deleteDataSource" short-description="Delete an DataSource">
-        <check-permission permission="MARKETING" action="_DELETE"><fail-message message="Security Error: to run deleteDataSource you must have the MARKETING_DELETE or MARKETING_ADMIN permission"/></check-permission>
-        <check-errors/>
-
         <make-value entity-name="DataSource" value-name="lookupPKMap"/>
         <set-pk-fields map-name="parameters" value-name="lookupPKMap"/>
         <find-by-primary-key entity-name="DataSource" map-name="lookupPKMap" value-name="lookedUpValue"/>

Modified: ofbiz/trunk/framework/common/script/org/ofbiz/common/datasource/DataSourceTypeServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/script/org/ofbiz/common/datasource/DataSourceTypeServices.xml?view=diff&rev=498540&r1=498539&r2=498540
==============================================================================
--- ofbiz/trunk/framework/common/script/org/ofbiz/common/datasource/DataSourceTypeServices.xml (original)
+++ ofbiz/trunk/framework/common/script/org/ofbiz/common/datasource/DataSourceTypeServices.xml Sun Jan 21 22:07:21 2007
@@ -20,20 +20,12 @@
         xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/simple-methods.xsd">
     <!-- DataSourceType methods -->
     <simple-method method-name="createDataSourceType" short-description="Create an DataSourceType">
-        <!-- DEJ 2002-10-19: MARKETING may not be the best place to put this, but it'll do for now -->
-        <check-permission permission="MARKETING" action="_CREATE"><fail-message message="Security Error: to run createDataSourceType you must have the MARKETING_CREATE or MARKETING_ADMIN permission"/></check-permission>
-        <check-errors/>
-
         <make-value value-name="newEntity" entity-name="DataSourceType"/>
         <set-nonpk-fields map-name="parameters" value-name="newEntity"/>
         <set-pk-fields map-name="parameters" value-name="newEntity"/>
-
         <create-value value-name="newEntity"/>
     </simple-method>
     <simple-method method-name="updateDataSourceType" short-description="Update an DataSourceType">
-        <check-permission permission="MARKETING" action="_UPDATE"><fail-message message="Security Error: to run updateDataSourceType you must have the MARKETING_UPDATE or MARKETING_ADMIN permission"/></check-permission>
-        <check-errors/>
-
         <make-value entity-name="DataSourceType" value-name="lookupPKMap"/>
         <set-pk-fields map-name="parameters" value-name="lookupPKMap"/>
         <find-by-primary-key entity-name="DataSourceType" map-name="lookupPKMap" value-name="lookedUpValue"/>
@@ -41,9 +33,6 @@
         <store-value value-name="lookedUpValue"/>
     </simple-method>
     <simple-method method-name="deleteDataSourceType" short-description="Delete an DataSourceType">
-        <check-permission permission="MARKETING" action="_DELETE"><fail-message message="Security Error: to run deleteDataSourceType you must have the MARKETING_DELETE or MARKETING_ADMIN permission"/></check-permission>
-        <check-errors/>
-
         <make-value entity-name="DataSourceType" value-name="lookupPKMap"/>
         <set-pk-fields map-name="parameters" value-name="lookupPKMap"/>
         <find-by-primary-key entity-name="DataSourceType" map-name="lookupPKMap" value-name="lookedUpValue"/>

Modified: ofbiz/trunk/framework/common/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/servicedef/services.xml?view=diff&rev=498540&r1=498539&r2=498540
==============================================================================
--- ofbiz/trunk/framework/common/servicedef/services.xml (original)
+++ ofbiz/trunk/framework/common/servicedef/services.xml Sun Jan 21 22:07:21 2007
@@ -22,6 +22,12 @@
     <vendor>OFBiz</vendor>
     <version>1.0</version>
 
+    <!-- Common Permission Service -->    
+    <service name="commonGenericPermission" engine="simple"
+        location="org/ofbiz/common/CommonServices.xml" invoke="commonGenericPermission">
+        <implements service="permissionInterface"/>
+    </service>
+
     <service name="echoService" engine="java" validate="false"
             location="org.ofbiz.common.CommonServices" invoke="echoService">
         <description>Echos back all passed parameters</description>
@@ -74,6 +80,26 @@
         </required-permissions>
     </service>
 
+    <!-- Enumeration Services -->
+    <service name="createEnumeration" default-entity-name="Enumeration" engine="simple"
+        location="org/ofbiz/common/EnumerationServices.xml" invoke="createEnumeration" auth="true">
+        <description>Create a Enumeration</description>
+        <permission-service service-name="commonGenericPermission" main-action="CREATE"/>
+        <auto-attributes include="pk" mode="OUT" optional="false"/>
+        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+        <override name="enumTypeId" optional="false"/>
+        <override name="description" optional="false"/>
+    </service>
+    <service name="updateEnumeration" default-entity-name="Enumeration" engine="simple"
+        location="org/ofbiz/common/EnumerationServices.xml" invoke="updateEnumeration" auth="true">
+        <description>Update a Enumeration</description>
+        <permission-service service-name="commonGenericPermission" main-action="UPDATE"/>
+        <auto-attributes include="pk" mode="IN" optional="false"/>
+        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+        <override name="enumTypeId" optional="false"/>
+        <override name="description" optional="false"/>
+    </service>
+
     <!-- DataSource Services -->
     <service name="interfaceDataSource" engine="interface" location="" invoke="">
         <attribute name="dataSourceId" type="String" mode="IN" optional="false"/>
@@ -83,16 +109,19 @@
     <service name="createDataSource" engine="simple"
             location="org/ofbiz/common/datasource/DataSourceServices.xml" invoke="createDataSource" auth="true">
         <description>Create a DataSource record</description>
+        <permission-service service-name="commonGenericPermission" main-action="CREATE"/>
         <implements service="interfaceDataSource"/>
     </service>
     <service name="updateDataSource" engine="simple"
             location="org/ofbiz/common/datasource/DataSourceServices.xml" invoke="updateDataSource" auth="true">
         <description>Update a DataSource record</description>
+        <permission-service service-name="commonGenericPermission" main-action="UPDATE"/>
         <implements service="interfaceDataSource"/>
     </service>
     <service name="deleteDataSource" engine="simple"
             location="org/ofbiz/common/datasource/DataSourceServices.xml" invoke="deleteDataSource" auth="true">
         <description>Delete a DataSource record</description>
+        <permission-service service-name="commonGenericPermission" main-action="DELETE"/>
         <attribute name="dataSourceId" type="String" mode="IN" optional="false"/>
     </service>
 
@@ -104,16 +133,19 @@
     <service name="createDataSourceType" engine="simple"
             location="org/ofbiz/common/datasource/DataSourceTypeServices.xml" invoke="createDataSourceType" auth="true">
         <description>Create a DataSourceType record</description>
+        <permission-service service-name="commonGenericPermission" main-action="CREATE"/>
         <implements service="interfaceDataSourceType"/>
     </service>
     <service name="updateDataSourceType" engine="simple"
             location="org/ofbiz/common/datasource/DataSourceTypeServices.xml" invoke="updateDataSourceType" auth="true">
         <description>Update a DataSourceType record</description>
+        <permission-service service-name="commonGenericPermission" main-action="UPDATE"/>
         <implements service="interfaceDataSourceType"/>
     </service>
     <service name="deleteDataSourceType" engine="simple"
             location="org/ofbiz/common/datasource/DataSourceTypeServices.xml" invoke="deleteDataSourceType" auth="true">
         <description>Delete a DataSourceType record</description>
+        <permission-service service-name="commonGenericPermission" main-action="DELETE"/>
         <attribute name="dataSourceTypeId" type="String" mode="IN" optional="false"/>
     </service>