You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2007/01/10 09:18:54 UTC
svn commit: r494762 - in /ofbiz/trunk/framework: example/config/
example/script/org/ofbiz/example/ service/dtd/ service/servicedef/
service/src/org/ofbiz/service/
Author: jonesde
Date: Wed Jan 10 00:18:50 2007
New Revision: 494762
URL: http://svn.apache.org/viewvc?view=rev&rev=494762
Log:
Added resource-description attribute to permission-service element, which if not specified will default to the service-name for the main service; this is then passed to the permission service for use in error messages, etc; added example to this in the example component; also updated the header on the ExamplePermissionServices.xml file to make it more consistent
Modified:
ofbiz/trunk/framework/example/config/ExampleUiLabels.properties
ofbiz/trunk/framework/example/script/org/ofbiz/example/ExamplePermissionServices.xml
ofbiz/trunk/framework/service/dtd/services.xsd
ofbiz/trunk/framework/service/servicedef/services.xml
ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java
ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java
Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.properties?view=diff&rev=494762&r1=494761&r2=494762
==============================================================================
--- ofbiz/trunk/framework/example/config/ExampleUiLabels.properties (original)
+++ ofbiz/trunk/framework/example/config/ExampleUiLabels.properties Wed Jan 10 00:18:50 2007
@@ -35,7 +35,7 @@
ExampleNewExampleFeature=New Example Feature
ExampleErrorNoExampleStatusValidChange=Error\: status change from [${lookedUpValue.statusId}] to [${parameters.statusId}] is not allowed.
-ExamplePermissionError=Security Error\: to run ${methodShortDescription} you must have the EXAMPLE_${mainAction} or EXAMPLE_ADMIN permission
+ExamplePermissionError=Security Error\: to run ${resourceDescription} you must have the EXAMPLE_${mainAction} or EXAMPLE_ADMIN permission
ExampleViewPermissionError=You do not have permission to view this page. ("EXAMPLE_VIEW" or "EXAMPLE_ADMIN" needed)
ExampleWelcome=Welcome to the Example application!
Modified: ofbiz/trunk/framework/example/script/org/ofbiz/example/ExamplePermissionServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/script/org/ofbiz/example/ExamplePermissionServices.xml?view=diff&rev=494762&r1=494761&r2=494762
==============================================================================
--- ofbiz/trunk/framework/example/script/org/ofbiz/example/ExamplePermissionServices.xml (original)
+++ ofbiz/trunk/framework/example/script/org/ofbiz/example/ExamplePermissionServices.xml Wed Jan 10 00:18:50 2007
@@ -1,18 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
- ~ 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.
- -->
+Copyright 2001-2006 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">
@@ -34,4 +35,4 @@
</else>
</if-has-permission>
</simple-method>
-</simple-methods>
\ No newline at end of file
+</simple-methods>
Modified: ofbiz/trunk/framework/service/dtd/services.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/dtd/services.xsd?view=diff&rev=494762&r1=494761&r2=494762
==============================================================================
--- ofbiz/trunk/framework/service/dtd/services.xsd (original)
+++ ofbiz/trunk/framework/service/dtd/services.xsd Wed Jan 10 00:18:50 2007
@@ -116,6 +116,9 @@
</xs:element>
<xs:attributeGroup name="attlist.permission-service">
<xs:attribute type="xs:string" name="service-name" use="required"/>
+ <xs:attribute type="xs:string" name="resource-description" use="optional">
+ <xs:annotation><xs:documentation>This will be used in error messages, et cetera. If not specified will default to a service name.</xs:documentation></xs:annotation>
+ </xs:attribute>
<xs:attribute name="main-action" use="optional">
<xs:simpleType>
<xs:restriction base="xs:token">
Modified: ofbiz/trunk/framework/service/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/servicedef/services.xml?view=diff&rev=494762&r1=494761&r2=494762
==============================================================================
--- ofbiz/trunk/framework/service/servicedef/services.xml (original)
+++ ofbiz/trunk/framework/service/servicedef/services.xml Wed Jan 10 00:18:50 2007
@@ -54,6 +54,9 @@
<service name="permissionInterface" engine="interface">
<description>Interface to describe base parameters for Permission Services</description>
<attribute name="mainAction" type="String" mode="IN" optional="true"/>
+ <attribute name="resourceDescription" type="String" mode="IN" optional="false">
+ <!-- Note that this will be filled in either with what the user specifies in the service definition, or will default to the service name. -->
+ </attribute>
<attribute name="hasPermission" type="Boolean" mode="OUT" optional="false"/>
<attribute name="failMessage" type="String" mode="OUT" optional="true"/>
</service>
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java?view=diff&rev=494762&r1=494761&r2=494762
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java Wed Jan 10 00:18:50 2007
@@ -126,6 +126,9 @@
/** Permission service main-action */
public String permissionMainAction;
+ /** Permission service resource-description */
+ public String permissionResourceDescription;
+
/** Set of services this service implements */
public Set implServices = new ListOrderedSet();
@@ -757,8 +760,10 @@
*/
public Map evalPermission(DispatchContext dctx, Map context) {
if (UtilValidate.isNotEmpty(this.permissionServiceName)) {
+ ModelService thisService;
ModelService permission;
try {
+ thisService = dctx.getModelService(dctx.getName());
permission = dctx.getModelService(this.permissionServiceName);
} catch (GenericServiceException e) {
Map result = ServiceUtil.returnSuccess();
@@ -770,6 +775,11 @@
Map ctx = permission.makeValid(context, ModelService.IN_PARAM);
if (UtilValidate.isNotEmpty(this.permissionMainAction)) {
ctx.put("mainAction", this.permissionMainAction);
+ }
+ if (UtilValidate.isNotEmpty(this.permissionMainAction)) {
+ ctx.put("resourceDescription", this.permissionResourceDescription);
+ } else if (thisService != null) {
+ ctx.put("resourceDescription", thisService.name);
}
LocalDispatcher dispatcher = dctx.getDispatcher();
Map resp;
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java?view=diff&rev=494762&r1=494761&r2=494762
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java Wed Jan 10 00:18:50 2007
@@ -363,6 +363,7 @@
if (e != null) {
model.permissionServiceName = e.getAttribute("service-name");
model.permissionMainAction = e.getAttribute("main-action");
+ model.permissionResourceDescription = e.getAttribute("resource-description");
model.auth = true; // auth is always required when permissions are set
}
}