stephan 2002/08/16 05:42:56 Modified: src/scratchpad/src/org/apache/cocoon/acting SourceMultiAction.java src/scratchpad/src/org/apache/cocoon/components/source TraversableSource.java src/scratchpad/webapp/samples/slide description2html4permissions.xsl sitemap.xmap Log: Changes make possible grant permissions of the list of users. Revision Changes Path 1.7 +51 -1 xml-cocoon2/src/scratchpad/src/org/apache/cocoon/acting/SourceMultiAction.java Index: SourceMultiAction.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/acting/SourceMultiAction.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- SourceMultiAction.java 14 Aug 2002 15:15:28 -0000 1.6 +++ SourceMultiAction.java 16 Aug 2002 12:42:56 -0000 1.7 @@ -98,6 +98,7 @@ public final static String SOURCE_PROPERTY_NAME = "cocoon-source-property-name"; public final static String SOURCE_PROPERTY_VALUE = "cocoon-source-property-value"; public final static String SOURCE_PERMISSION_PRINCIPAL = "cocoon-source-permission-principal"; + public final static String SOURCE_PERMISSION_PRINCIPAL_GROUP = "cocoon-source-permission-principal-group"; public final static String SOURCE_PERMISSION_PRIVILEGE = "cocoon-source-permission-privilege"; public final static String SOURCE_PERMISSION_INHERITABLE = "cocoon-source-permission-inheritable"; public final static String SOURCE_PERMISSION_NEGATIVE = "cocoon-source-permission-negative"; @@ -340,6 +341,55 @@ SourcePermission permission = new PrincipalSourcePermission(subject, privilege, inheritable, negative); + + restrictablesource.setSourcePermission(permission); + } else + throw new ProcessingException("Source isn't restrictable"); + } catch (SourceException se) { + if (getLogger().isDebugEnabled()) + getLogger().debug("Exception occurs while modifying the source", se); + throw new ProcessingException("Exception occurs while modifying the source", se); + } + + return EMPTY_MAP; + } + + public Map doSetPrincipalGroupPermission(Redirector redirector, + SourceResolver resolver, + Map objectModel, + String src, + Parameters parameters) throws Exception { + + getLogger().debug("add principal group permission called"); + + Request request = ObjectModelHelper.getRequest(objectModel); + + String uri = parameters.getParameter(SOURCE_URI, request.getParameter(SOURCE_URI)); + String subject = parameters.getParameter(SOURCE_PERMISSION_PRINCIPAL_GROUP, + request.getParameter(SOURCE_PERMISSION_PRINCIPAL_GROUP)); + String privilege = parameters.getParameter(SOURCE_PERMISSION_PRIVILEGE, + request.getParameter(SOURCE_PERMISSION_PRIVILEGE)); + boolean inheritable = Boolean.getBoolean(parameters.getParameter(SOURCE_PERMISSION_INHERITABLE, + request.getParameter(SOURCE_PERMISSION_INHERITABLE))); + boolean negative = Boolean.getBoolean(parameters.getParameter(SOURCE_PERMISSION_NEGATIVE, + request.getParameter(SOURCE_PERMISSION_NEGATIVE))); + + String principal = parameters.getParameter(PRINCIPAL, + request.getParameter(PRINCIPAL)); + String password = parameters.getParameter(PASSWORD, + request.getParameter(PASSWORD)); + + try { + + Source source = resolver.resolveURI(uri); + + if (source instanceof RestrictableSource) { + RestrictableSource restrictablesource = (RestrictableSource)source; + + restrictablesource.setSourceCredential(new SourceCredential(principal, password)); + + SourcePermission permission = + new GroupSourcePermission(subject, privilege, inheritable, negative); restrictablesource.setSourcePermission(permission); } else 1.3 +2 -2 xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/TraversableSource.java Index: TraversableSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/source/TraversableSource.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TraversableSource.java 5 Aug 2002 09:05:42 -0000 1.2 +++ TraversableSource.java 16 Aug 2002 12:42:56 -0000 1.3 @@ -61,7 +61,7 @@ import java.util.Enumeration; /** - * A source, which can a directory or collection of sources. + * A source, which can be a directory or collection of sources. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a> * @version $Id$ 1.3 +32 -24 xml-cocoon2/src/scratchpad/webapp/samples/slide/description2html4permissions.xsl Index: description2html4permissions.xsl =================================================================== RCS file: /home/cvs/xml-cocoon2/src/scratchpad/webapp/samples/slide/description2html4permissions.xsl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- description2html4permissions.xsl 14 Aug 2002 09:07:56 -0000 1.2 +++ description2html4permissions.xsl 16 Aug 2002 12:42:56 -0000 1.3 @@ -2,7 +2,8 @@ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:source="http://xml.apache.org/cocoon/source/2.0" - xmlns:dav="DAV:"> + xmlns:dav="DAV:" + xmlns:pl="http://xml.apache.org/cocoon/PrincipalListGenerator"> <xsl:output indent="yes"/> @@ -51,7 +52,7 @@ </tr> </table> - <xsl:apply-templates select="source:source"/> + <xsl:apply-templates select="document/source:source"/> <p align="center"> <font size="-1"> @@ -141,18 +142,18 @@ <xsl:for-each select="source:permissions/source:permission[@principal]"> <tr> - <td align="left"><xsl:value-of select="@principal"/><xsl:value-of select="@group"/></td> + <td align="left"><xsl:value-of select="@principal"/></td> <td align="left"><xsl:value-of select="@privilege"/></td> <td align="left"><xsl:value-of select="@inheritable"/></td> <td align="left"><xsl:value-of select="@negative"/></td> <td align="right"> <form action="" method="post"> - <input type="hidden" name="method" value="doDeletePermission"/> + <input type="hidden" name="method" value="doDeletePrincipalPermission"/> <input type="hidden" name="cocoon-source-uri" value="{../../@source:systemid}"/> - <input type="hidden" name="cocoon-permission-principal" value="{@subject}"/> - <input type="hidden" name="cocoon-permission-privilege" value="{@action}"/> + <input type="hidden" name="cocoon-source-permission-principal" value="{@principal}"/> + <input type="hidden" name="cocoon-source-permission-privilege" value="{@privilege}"/> - <input type="submit" name="cocoon-action-deletepermission" value="Delete"/> + <input type="submit" name="doDeletePrincipalPermission" value="Delete"/> </form> </td> </tr> @@ -160,17 +161,20 @@ <tr> <form action="" method="post"> - <input type="hidden" name="method" value="doAddPermission"/> + <input type="hidden" name="method" value="doSetPrincipalPermission"/> <input type="hidden" name="cocoon-source-uri" value="{@source:systemid}"/> <td align="left"> - <select name="cocoon-permisson-principal"> + <select name="cocoon-source-permission-principal-group"> <option>ALL</option> <option>SELF</option> <option>GUEST</option> + <xsl:for-each select="/document/pl:list/pl:principal"> + <option><xsl:value-of select="@pl:name"/></option> + </xsl:for-each> </select> </td> <td align="left"> - <select name="cocoon-permisson-privilege"> + <select name="cocoon-source-permission-privilege"> <option>all</option> <option>read</option> <option>write</option> @@ -194,19 +198,19 @@ </select> </td> <td align="left"> - <select name="cocoon-permisson-inheritable"> + <select name="cocoon-source-permission-inheritable"> <option>true</option> <option>false</option> </select> </td> <td align="left"> - <select name="cocoon-permisson-negative"> + <select name="cocoon-source-permission-negative"> <option>true</option> <option>false</option> </select> </td> <td align="right"> - <input type="submit" name="cocoon-action-addpermission" value="Add/Modify"/> + <input type="submit" name="doSetPrincipalPermission" value="Add/Modify"/> </td> </form> </tr> @@ -246,15 +250,16 @@ <xsl:for-each select="source:permissions/source:permission[@group]"> <tr> - <td align="left"><xsl:value-of select="@principal"/><xsl:value-of select="@group"/></td> + <td align="left"><xsl:value-of select="@group"/></td> <td align="left"><xsl:value-of select="@privilege"/></td> <td align="left"><xsl:value-of select="@inheritable"/></td> <td align="left"><xsl:value-of select="@negative"/></td> <td align="right"> <form action="" method="post"> - <input type="hidden" name="uri" value="{../../@source:systemid}"/> - <input type="hidden" name="permissionprincipal" value="{@subject}"/> - <input type="hidden" name="permissionprivilege" value="{@action}"/> + <input type="hidden" name="method" value="doDeletePrincipalGroupPermission"/> + <input type="hidden" name="cocoon-source-uri" value="{../../@source:systemid}"/> + <input type="hidden" name="cocoon-source-permission-principal-group" value="{@group}"/> + <input type="hidden" name="cocoon-source-permission-privilege" value="{@privilege}"/> <input type="submit" name="cocoon-action-deletepermission" value="Delete"/> </form> @@ -264,14 +269,17 @@ <tr> <form action="" method="post"> - <input type="hidden" name="uri" value="{@source:systemid}"/> + <input type="hidden" name="method" value="doSetPrincipalGroupPermission"/> + <input type="hidden" name="cocoon-source-uri" value="{@source:systemid}"/> <td align="left"> - <select name="permissongroup"> - <option>groupA</option> + <select name="cocoon-source-permission-principal-group"> + <xsl:for-each select="/document/pl:list/pl:group"> + <option><xsl:value-of select="@pl:name"/></option> + </xsl:for-each> </select> </td> <td align="left"> - <select name="permissonprivilege"> + <select name="cocoon-source-permission-privilege"> <option>all</option> <option>read</option> <option>write</option> @@ -295,19 +303,19 @@ </select> </td> <td align="left"> - <select name="permissoninheritable"> + <select name="cocoon-source-permission-inheritable"> <option>true</option> <option>false</option> </select> </td> <td align="left"> - <select name="permissondeny"> + <select name="cocoon-source-permission-negative"> <option>true</option> <option>false</option> </select> </td> <td align="right"> - <input type="submit" name="cocoon-action-addpermission" value="Add/Modify"/> + <input type="submit" name="doSetPrincipalPermission" value="Add/Modify"/> </td> </form> </tr> 1.11 +14 -7 xml-cocoon2/src/scratchpad/webapp/samples/slide/sitemap.xmap Index: sitemap.xmap =================================================================== RCS file: /home/cvs/xml-cocoon2/src/scratchpad/webapp/samples/slide/sitemap.xmap,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- sitemap.xmap 13 Aug 2002 16:09:06 -0000 1.10 +++ sitemap.xmap 16 Aug 2002 12:42:56 -0000 1.11 @@ -82,12 +82,18 @@ </authentication-manager> </map:component-configurations> - <map:pipeline> - <map:match pattern="repository-authuser"> + <map:pipeline><!-- internal-only="true">--> + + <map:match pattern="principallist"> <map:generate type="principallist"> <map:parameter name="principalprovider" value="slide"/> <map:parameter name="principalcaller" value="root"/> </map:generate> + <map:serialize type="xml"/> + </map:match> + + <map:match pattern="repository-authuser"> + <map:generate src="cocoon:/principallist"/> <map:transform src="principal2auth.xsl"> <map:parameter name="use-request-parameters" value="true"/> @@ -97,10 +103,7 @@ </map:match> <map:match pattern="repository-authlist"> - <map:generate type="principallist"> - <map:parameter name="principalprovider" value="slide"/> - <map:parameter name="principalcaller" value="root"/> - </map:generate> + <map:generate src="cocoon:/principallist"/> <map:transform src="context://samples/common/style/xsl/html/simple-xml2html.xsl"/> @@ -192,7 +195,11 @@ <map:parameter name="cocoon-principal" value="{../ID}"/> </map:act> - <map:generate src="cocoon:/description/{1}"/> + <map:aggregate element="document"> + <map:part src="cocoon:/description/{1}"/> + <map:part src="cocoon:/principallist"/> + </map:aggregate> + <map:transform src="description2html4permissions.xsl"/> <map:serialize type="html"/> </map:match>
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]