added examples of using new service based security; removed all security calls from the simple methods, added the security line to the definitions, implemented a generic simple permission example

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@494720 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Zeneski
2007-01-10 05:31:37 +00:00
parent 267c82dc48
commit 30d8e24db3
4 changed files with 70 additions and 40 deletions
@@ -0,0 +1,37 @@
<!--
~ Copyright 2001-2007 The Apache Software Foundation
~
~ 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">
<simple-method method-name="exampleGenericPermission" short-description="Main permission logic">
<set field="mainAction" from-field="parameters.mainAction"/>
<if-empty field-name="mainAction">
<add-error><fail-message message="Generic Example Permission request the main-action attribute"/></add-error>
<check-errors/>
</if-empty>
<if-has-permission permission="EXAMPLE" action="_${parameters.mainAction}">
<set field="hasPermission" type="Boolean" value="true"/>
<field-to-result field-name="hasPermission"/>
<else>
<property-to-field resource="ExampleUiLabels" property="ExamplePermissionError" 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-methods>
@@ -19,10 +19,6 @@ under the License.
xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/simple-methods.xsd">
<!-- Example methods -->
<simple-method method-name="createExample" short-description="create a Example">
<set value="_CREATE" field="securityAction"/>
<check-permission permission="EXAMPLE" action="${securityAction}"><fail-property resource="ExampleUiLabels" property="ExamplePermissionError"/></check-permission>
<check-errors/>
<make-value entity-name="Example" value-name="newEntity"/>
<sequenced-id-to-env sequence-name="Example" env-name="newEntity.exampleId"/> <!-- get the next sequenced ID -->
<field-to-result field-name="newEntity.exampleId" result-name="exampleId"/>
@@ -33,10 +29,6 @@ under the License.
<call-service service-name="createExampleStatus" in-map-name="createExampleStatusMap"/>
</simple-method>
<simple-method method-name="updateExample" short-description="update a Example">
<set value="_UPDATE" field="securityAction"/>
<check-permission permission="EXAMPLE" action="${securityAction}"><fail-property resource="ExampleUiLabels" property="ExamplePermissionError"/></check-permission>
<check-errors/>
<entity-one entity-name="Example" value-name="lookedUpValue"/>
<!-- handle statusId change stuff; first put the current statusId in the oldStatusId result -->
@@ -65,16 +57,10 @@ under the License.
<store-value value-name="lookedUpValue"/>
</simple-method>
<simple-method method-name="deleteExample" short-description="delete a Example">
<set value="_DELETE" field="securityAction"/>
<check-permission permission="EXAMPLE" action="${securityAction}"><fail-property resource="ExampleUiLabels" property="ExamplePermissionError"/></check-permission>
<check-errors/>
<entity-one entity-name="Example" value-name="lookedUpValue"/>
<remove-value value-name="lookedUpValue"/>
</simple-method>
<simple-method method-name="createExampleStatus" short-description="create a ExampleItem">
<set value="_CREATE" field="securityAction"/>
<check-permission permission="EXAMPLE" action="${securityAction}"><fail-property resource="ExampleUiLabels" property="ExamplePermissionError"/></check-permission>
<check-errors/>
<make-value entity-name="ExampleStatus" value-name="newEntity"/>
<set-pk-fields map-name="parameters" value-name="newEntity"/>
<set-nonpk-fields map-name="parameters" value-name="newEntity"/>
@@ -84,10 +70,6 @@ under the License.
<!-- ExampleItem methods -->
<simple-method method-name="createExampleItem" short-description="create a ExampleItem">
<set value="_CREATE" field="securityAction"/>
<check-permission permission="EXAMPLE" action="${securityAction}"><fail-property resource="ExampleUiLabels" property="ExamplePermissionError"/></check-permission>
<check-errors/>
<make-value entity-name="ExampleItem" value-name="newEntity"/>
<set-pk-fields map-name="parameters" value-name="newEntity"/>
<make-next-seq-id value-name="newEntity" seq-field-name="exampleItemSeqId"/> <!-- this finds the next sub-sequence ID -->
@@ -96,19 +78,11 @@ under the License.
<create-value value-name="newEntity"/>
</simple-method>
<simple-method method-name="updateExampleItem" short-description="update a ExampleItem">
<set value="_UPDATE" field="securityAction"/>
<check-permission permission="EXAMPLE" action="${securityAction}"><fail-property resource="ExampleUiLabels" property="ExamplePermissionError"/></check-permission>
<check-errors/>
<entity-one entity-name="ExampleItem" value-name="lookedUpValue"/>
<set-nonpk-fields value-name="lookedUpValue" map-name="parameters"/>
<store-value value-name="lookedUpValue"/>
</simple-method>
<simple-method method-name="deleteExampleItem" short-description="delete a ExampleItem">
<set value="_DELETE" field="securityAction"/>
<check-permission permission="EXAMPLE" action="${securityAction}"><fail-property resource="ExampleUiLabels" property="ExamplePermissionError"/></check-permission>
<check-errors/>
<simple-method method-name="deleteExampleItem" short-description="delete a ExampleItem">
<entity-one entity-name="ExampleItem" value-name="lookedUpValue"/>
<remove-value value-name="lookedUpValue"/>
</simple-method>