stephan 2003/01/31 10:08:48
Modified: . build.xml project-info.xml properties.xml
lib jars.xml
src/scratchpad/webapp/samples scratchpad-samples.xml
src/webapp/samples sitemap.xmap
tools/src blocks-build.xsl
Added: legal LICENSE.jakarta-slide LICENSE.jdom
lib/optional jdom-dev-20020131.jar slide-kernel-20020130.jar
slide-roles-20020130.jar slide-stores-20020130.jar
slide-webdavservlet-20020131.jar
src/blocks/slide README web.xml
src/blocks/slide/conf slide-action.xmap slide-generator.xmap
slide-inspector.xroles slide-repository.xconf
slide-repository.xroles slide-source.xconf
slide-sourceinspector.xconf slide.xsamples
src/blocks/slide/java/org/apache/cocoon/acting
PrincipalMultiAction.java SourceMultiAction.java
src/blocks/slide/java/org/apache/cocoon/components/repository
Principal.java PrincipalGroup.java
PrincipalProvider.java Repository.java
src/blocks/slide/java/org/apache/cocoon/components/repository/impl
SlideConfigurationAdapter.java
SlideLoggerAdapter.java SlidePrincipalProvider.java
SlideRepository.java
src/blocks/slide/java/org/apache/cocoon/components/source
InspectableSource.java LockableSource.java
ModifiableTraversableSource.java
RestrictableSource.java SourceInspector.java
TraversableSource.java VersionableSource.java
src/blocks/slide/java/org/apache/cocoon/components/source/helpers
AbstractSourcePermission.java
GroupSourcePermission.java
PrincipalSourcePermission.java SourceLock.java
SourcePermission.java SourceProperty.java
src/blocks/slide/java/org/apache/cocoon/components/source/impl
GIFSourceInspector.java JPEGSourceInspector.java
SlideSource.java SlideSourceFactory.java
SourceInspectorManager.java
XPathSourceInspector.java
src/blocks/slide/java/org/apache/cocoon/generation
PrincipalListGenerator.java
SourceDescriptionGenerator.java
src/blocks/slide/samples description2html4content.xsl
description2html4locks.xsl
description2html4permissions.xsl
description2html4properties.xsl login-failed.html
login.html logout.html principal2auth.xsl
principal2html4users.xsl redirect4login.xsl
sitemap.xmap slide.xconf
src/mocks/javax/transaction HeuristicMixedException.java
HeuristicRollbackException.java
NotSupportedException.java RollbackException.java
SystemException.java UserTransaction.java
Removed: src/scratchpad/mocks/javax/transaction
HeuristicMixedException.java
HeuristicRollbackException.java
NotSupportedException.java RollbackException.java
SystemException.java UserTransaction.java
src/scratchpad/src/org/apache/cocoon/acting
PrincipalMultiAction.java SourceMultiAction.java
SourceUploadAction.java slide.xmap
src/scratchpad/src/org/apache/cocoon/components/repository
Principal.java PrincipalGroup.java
PrincipalProvider.java Repository.java
principalprovider.roles
src/scratchpad/src/org/apache/cocoon/components/repository/impl
SlideConfigurationAdapter.java
SlideLoggerAdapter.java SlidePrincipalProvider.java
SlideRepository.java slide.xconf slide.xroles
src/scratchpad/src/org/apache/cocoon/components/source
InspectableSource.java LockableSource.java
ModifiableTraversableSource.java
RestrictableSource.java SourceInspector.java
TraversableSource.java VersionableSource.java
src/scratchpad/src/org/apache/cocoon/components/source/helpers
AbstractSourcePermission.java
GroupSourcePermission.java
PrincipalSourcePermission.java SourceLock.java
SourcePermission.java SourceProperty.java
src/scratchpad/src/org/apache/cocoon/components/source/impl
GIFSourceInspector.java JPEGSourceInspector.java
SlideSource.java SlideSourceFactory.java
SourceInspectorManager.java
XPathSourceInspector.java slide.xconf
sourceinspector.xconf sourceinspector.xroles
src/scratchpad/src/org/apache/cocoon/generation
PrincipalListGenerator.java
SourceDescriptionGenerator.java slide.xmap
src/scratchpad/webapp/samples/slide README
description2html4content.xsl
description2html4locks.xsl
description2html4permissions.xsl
description2html4properties.xsl login-failed.html
login.html logout.html principal2auth.xsl
principal2html4users.xsl redirect4login.xsl
sitemap.xmap slide.xconf web.xml
Log:
Moved the Slide example into a own block, also
moved the transaction mocks into the main trunk to share
with the slide example.
Revision Changes Path
1.314 +1 -5 xml-cocoon2/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/build.xml,v
retrieving revision 1.313
retrieving revision 1.314
diff -u -r1.313 -r1.314
--- build.xml 31 Jan 2003 01:39:30 -0000 1.313
+++ build.xml 31 Jan 2003 18:08:41 -0000 1.314
@@ -1033,8 +1033,6 @@
<exclude name="**/reading/AxisRPCReader.java"
unless="activation.present"/>
<exclude name="**/webservices/**" unless="activation.present"/>
- <exclude name="**/Slide*" unless="transaction.present"/>
- <exclude name="**/slide*" unless="transaction.present"/>
<exclude name="**/mail/**" unless="mail.present"/>
</fileset>
</copy>
@@ -1595,8 +1593,6 @@
<fileset dir="${scratchpad.lib}">
<include name="*.jar"/>
<exclude name="servlet*.jar"/>
-
- <exclude name="slide*.jar" unless="transaction.present"/>
</fileset>
</copy>
</then>
1.7 +20 -2 xml-cocoon2/project-info.xml
Index: project-info.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/project-info.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- project-info.xml 22 Jan 2003 13:15:44 -0000 1.6
+++ project-info.xml 31 Jan 2003 18:08:41 -0000 1.7
@@ -32,7 +32,7 @@
<depend project="excalibur-naming" version="supplied"/>
<depend project="excalibur-sourceresolve" version="supplied"/>
<depend project="excalibur-xmlutil" version="supplied"/>
- <depend project="excalibur-store" version="supplied"/>
+ <depend project="excalibur-store" version="sepplied"/>
<depend project="jakarta-regexp" version="supplied"/>
<depend project="commons-httpclient" version="supplied"/>
<depend project="commons-collections" version="supplied"/>
@@ -133,7 +133,7 @@
<jar name="chaperon-block.jar"/>
- <nag from="Nicola Ken Barozzi <[EMAIL PROTECTED]>"
+ <nag from="Stephan Michels <[EMAIL PROTECTED]>"
to="[email protected]"/>
</project>
@@ -559,6 +559,24 @@
<jar name="web3-block.jar"/>
<nag from="Christian Haul <[EMAIL PROTECTED]>"
+ to="[email protected]"/>
+ </project>
+
+ <project name="slide-block">
+ <package>org.apache.cocoon</package>
+
+ <ant target="block">
+ <property name="block-name" value="slide"/>
+ </ant>
+
+ <depend project="xml-cocoon2"/>
+
+ <work nested="tools/anttasks"/>
+ <home nested="build/cocoon"/>
+
+ <jar name="slide-block.jar"/>
+
+ <nag from="Stephan <[EMAIL PROTECTED]>"
to="[email protected]"/>
</project>
1.29 +1 -0 xml-cocoon2/properties.xml
Index: properties.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/properties.xml,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- properties.xml 22 Jan 2003 13:15:44 -0000 1.28
+++ properties.xml 31 Jan 2003 18:08:41 -0000 1.29
@@ -143,6 +143,7 @@
<profiler include="true"/>
<velocity include="true"/>
<web3 include="true"/><!-- SAP R/3 connectivity -->
+ <slide include="true"/>
</blocks>
<!-- Specify what should be included in the web application (war) file
-->
1.1 xml-cocoon2/legal/LICENSE.jakarta-slide
Index: LICENSE.jakarta-slide
===================================================================
/* ========================================================================= *
* *
* The Apache Software License, Version 1.1 *
* *
* Copyright (c) 1999, 2000, 2001 The Apache Software Foundation. *
* All rights reserved. *
* *
* ========================================================================= *
* *
* Redistribution and use in source and binary forms, with or without modi- *
* fication, are permitted provided that the following conditions are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice *
* notice, this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. The end-user documentation included with the redistribution, if any, *
* must include the following acknowlegement: *
* *
* "This product includes software developed by the Apache Software *
* Foundation <http://www.apache.org/>." *
* *
* Alternately, this acknowlegement may appear in the software itself, if *
* and wherever such third-party acknowlegements normally appear. *
* *
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software *
* Foundation" must not be used to endorse or promote products derived *
* from this software without prior written permission. For written *
* permission, please contact <[EMAIL PROTECTED]>. *
* *
* 5. Products derived from this software may not be called "Apache" nor may *
* "Apache" appear in their names without prior written permission of the *
* Apache Software Foundation. *
* *
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES *
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY *
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY *
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS *
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, *
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN *
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
* ========================================================================= *
* *
* This software consists of voluntary contributions made by many indivi- *
* duals on behalf of the Apache Software Foundation. For more information *
* on the Apache Software Foundation, please see <http://www.apache.org/>. *
* *
* =========================================================================
*/
1.1 xml-cocoon2/legal/LICENSE.jdom
Index: LICENSE.jdom
===================================================================
/*--
$Id: LICENSE.jdom,v 1.1 2003/01/31 18:08:41 stephan Exp $
Copyright (C) 2000-2002 Brett McLaughlin & Jason Hunter.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions, and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions, and the disclaimer that follows
these conditions in the documentation and/or other materials
provided with the distribution.
3. The name "JDOM" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact [EMAIL PROTECTED]
4. Products derived from this software may not be called "JDOM", nor
may "JDOM" appear in their name, without prior written permission
from the JDOM Project Management ([EMAIL PROTECTED]).
In addition, we request (but do not require) that you include in the
end-user documentation provided with the redistribution and/or in the
software itself an acknowledgement equivalent to the following:
"This product includes software developed by the
JDOM Project (http://www.jdom.org/)."
Alternatively, the acknowledgment may be graphical using the logos
available at http://www.jdom.org/images/logos.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
This software consists of voluntary contributions made by many
individuals on behalf of the JDOM Project and was originally
created by Brett McLaughlin <[EMAIL PROTECTED]> and
Jason Hunter <[EMAIL PROTECTED]>. For more information on the
JDOM Project, please see <http://www.jdom.org/>.
*/
1.71 +35 -1 xml-cocoon2/lib/jars.xml
Index: jars.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/lib/jars.xml,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- jars.xml 30 Jan 2003 09:01:31 -0000 1.70
+++ jars.xml 31 Jan 2003 18:08:42 -0000 1.71
@@ -536,6 +536,40 @@
<lib>optional/saxpath-1.0-FCS.jar</lib>
<homepage>http://sourceforge.net/projects/saxpath/</homepage>
</file>
-
+ <file name="slide-kernel">
+ <title>Slide kernel</title>
+ <description>The Jakarta Slide kernel API.</description>
+ <used-by>Slide block</used-by>
+ <lib>optional/slide-kernel-20020130.jar</lib>
+ <homepage>http://jakarta.apache.org/slide/</homepage>
+ </file>
+ <file name="slide-roles">
+ <title>Slide roles</title>
+ <description>The Jakarta Slide roles implementation.</description>
+ <used-by>Slide block</used-by>
+ <lib>optional/slide-roles-20020130.jar</lib>
+ <homepage>http://jakarta.apache.org/slide/</homepage>
+ </file>
+ <file name="slide-store">
+ <title>Slide stores</title>
+ <description>The Jakarta Slide stores implementation.</description>
+ <used-by>Slide block</used-by>
+ <lib>optional/slide-stores-20020130.jar</lib>
+ <homepage>http://jakarta.apache.org/slide/</homepage>
+ </file>
+ <file name="slide-webdavservlet">
+ <title>Slide kernel</title>
+ <description>The Jakarta Slide WebDAV servlet.</description>
+ <used-by>Slide block</used-by>
+ <lib>optional/slide-webdavservlet-20020131.jar</lib>
+ <homepage>http://jakarta.apache.org/slide/</homepage>
+ </file>
+ <file name="jdom">
+ <title>JDOM</title>
+ <description>JDOM</description>
+ <used-by>Slide block</used-by>
+ <lib>optional/jdom-dev-20020131.jar</lib>
+ <homepage>http://www.jdom.org/</homepage>
+ </file>
</jars>
1.1 xml-cocoon2/lib/optional/jdom-dev-20020131.jar
<<Binary file>>
1.1 xml-cocoon2/lib/optional/slide-kernel-20020130.jar
<<Binary file>>
1.1 xml-cocoon2/lib/optional/slide-roles-20020130.jar
<<Binary file>>
1.1 xml-cocoon2/lib/optional/slide-stores-20020130.jar
<<Binary file>>
1.1 xml-cocoon2/lib/optional/slide-webdavservlet-20020131.jar
<<Binary file>>
1.1 xml-cocoon2/src/blocks/slide/README
Index: README
===================================================================
====================================
Using Jakarta Slide with Cocoon
====================================
1. Copy the Java Transaction API (JTA) jar into
lib/local.
2. Install the Web Application via in Tomcat
./build.sh -Dinclude.webapp.libs=yes -Dinstall.war=$TOMCAT_HOME/webapps
-Dinclude.scratchpad.libs=yes install
3. Start Tomcat
$TOMCAT_HOME/bin/catalina.sh run
4. Access the slide repository via Cocoon
http://localhost:8080/cocoon/samples/slide/
[OPTIONAL]
5. If you want an access via WebDAV copy the web.xml into WEB-INF/
This file includes the WebDAV Servlet from Slide.
6. Add users to tomcat-users.xml for the MemoryRealm
<role rolename="user"/>
<role rolename="root"/>
<user username="john" password="john" roles="user"/>
<user username="root" password="root" roles="root,user"/>
You can use the SlideRealm instead of the MemoryRealm.
7. Access WebDAV via MS WebFolders, Cadaver or whatever
http://localhost:8080/cocoon/webdav/
(The Slide initialization will take the configuration, which
the web.xml file specify)
Have fun, Stephan Michels <[EMAIL PROTECTED]>
Some things must be fixed:
* The base directory for the content stores should be set. At the moment
there isn't a way to respect the context path.
* The links of directory browsing doesn't work properly, because of the
servlet mapping.
* The support of the locking mechanism within the sources is in a alpha state.
1.1 xml-cocoon2/src/blocks/slide/web.xml
Index: web.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
This is the web-app configurations that allow Cocoon to work under
Apache Tomcat. Please, follow the installation section of the
documentation for more information about installing Cocoon on Tomcat
-->
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<display-name>Cocoon2 Demo</display-name>
<description>Demo application for Cocoon2</description>
<servlet>
<servlet-name>Cocoon2</servlet-name>
<display-name>Cocoon2</display-name>
<description>The main Cocoon2 servlet</description>
<!--
In cases you're facing class loader problems you can alternatively
use the following servlet-class instead of the normal one
<servlet-class>org.apache.cocoon.servlet.ParanoidCocoonServlet</servlet-class>
-->
<servlet-class>org.apache.cocoon.servlet.CocoonServlet</servlet-class>
<!--
This parameter points to the main configuration file for Cocoon.
Note that the path is specified in absolute notation but it will be
resolved relative to the servlets webapp context path
-->
<init-param>
<param-name>configurations</param-name>
<param-value>/WEB-INF/cocoon.xconf</param-value>
</init-param>
<!--
This parameter tells cocoon to set the thread's context classloader to
its own classloader. If you experience strange classloader issues,
try setting this parameter to "true" or using ParanoidCocoonServlet.
-->
<init-param>
<param-name>init-classloader</param-name>
<param-value>false</param-value>
</init-param>
<!--
This parameter indicates the configuration file of the LogKit management
-->
<init-param>
<param-name>logkit-config</param-name>
<param-value>/WEB-INF/logkit.xconf</param-value>
</init-param>
<!--
This parameter indicates the category id of the logger from the LogKit
configuration used by the CocoonServlet.
-->
<init-param>
<param-name>servlet-logger</param-name>
<param-value>access</param-value>
</init-param>
<!--
This parameter indicates the category id of the logger from the LogKit
management configuration for the Cocoon engine.
This logger is used for all components described in the cocoon.xconf
and sitemap.xmap file not having specified a logger with the
logger="..." attribute in the component configuration file.
-->
<init-param>
<param-name>cocoon-logger</param-name>
<param-value>core</param-value>
</init-param>
<!--
This parameter indicates the log level to use throughout startup of the
system.
As soon as the logkit.xconf the setting of the logkit.xconf
configuration is
used instead! Only for startup and if the logkit.xconf is not
readable/available
this log level is of importance.
Available levels are:
DEBUG: prints all level of log messages.
INFO: prints all level of log messages except DEBUG ones.
WARN: prints all level of log messages except DEBUG and INFO
ones.
ERROR: prints all level of log messages except DEBUG, INFO and
WARN ones.
FATAL_ERROR: prints only log messages of this level
-->
<init-param>
<param-name>log-level</param-name>
<param-value>DEBUG</param-value>
</init-param>
<!--
Allow reinstantiating (reloading) of the cocoon instance. If this is
set to "yes" or "true", a new cocoon instance can be created using
the request parameter "cocoon-reload".
-->
<init-param>
<param-name>allow-reload</param-name>
<param-value>yes</param-value>
</init-param>
<!--
This parameter is used to list classes that should be loaded
at initialization time of the servlet.
Usually this classes are JDBC Drivers used
-->
<init-param>
<param-name>load-class</param-name>
<param-value>
<!-- For IBM WebSphere:
com.ibm.servlet.classloader.Handler -->
<!-- For Database Driver: -->
org.hsqldb.jdbcDriver
<!-- For PostgeSQL Database:
org.postgresql.Driver -->
<!-- For Oracle Database:
oracle.jdbc.driver.OracleDriver -->
<!-- ODBC
sun.jdbc.odbc.JdbcOdbcDriver -->
<!-- For parent ComponentManager sample:
org.apache.cocoon.samples.parentcm.Configurator
-->
</param-value>
</init-param>
<!--
This parameter allows to specify where Cocoon should put uploaded files.
The path specified can be either absolute or relative to the context
path of the servlet. On windows platform, absolute directory must start
with volume: C:\Path\To\Upload\Directory
The default directory is "upload-dir" in the work-directory
<init-param>
<param-name>upload-directory</param-name>
<param-value>WEB-INF/work/upload-dir</param-value>
</init-param>
-->
<!--
Causes all files in multipart requests to be saved to upload-dir.
Default is true. Unsupported values will be interpreted as false.
-->
<init-param>
<param-name>autosave-uploads</param-name>
<param-value>false</param-value>
</init-param>
<!--
Specify handling of name conflicts when saving uploaded files
to disk. Acceptable values are deny, allow, rename (default).
Files are renamed x_filename where x is an integer value incremented
to make the new filename unique.
-->
<init-param>
<param-name>overwrite-uploads</param-name>
<param-value>rename</param-value>
</init-param>
<!--
Specify maximum allowed size of the upload. Defaults to 10 Mb.
<init-param>
<param-name>upload-max-size</param-name>
<param-value>10000000</param-value>
</init-param>
-->
<!--
This parameter allows to specify where Cocoon should create its page
and other objects cache. The path specified can be either absolute or
relative to the context path of the servlet. On windows platform,
absolute directory must start with volume: C:\Path\To\Cache\Directory
The default directory is "cache-dir" in the work-directory
<init-param>
<param-name>cache-directory</param-name>
<param-value>WEB-INF/work/cache-dir</param-value>
</init-param>
-->
<!--
This parameter allows to specify where Cocoon should put it's
working files. The path specified is either absolute or relative
to the context path of the Cocoon servlet. On windows platform,
absolute directory must start with volume: C:\Path\To\Work\Directory
The default directory is "cocoon-files" directory in the servlet
context's temp directory (context property
javax.servlet.context.tempdir).
<init-param>
<param-name>work-directory</param-name>
<param-value>WEB-INF/work</param-value>
</init-param>
-->
<!--
This parameter allows to specify additional directories or jars
which Cocoon should put into it's own classpath.
Note that you must separate them using the platforms path.separator
(":" for *nix and ";" for Windows systems). Also note that absolute
pathes are take as such but relative pathes are rooted at the context
root of the Cocoon servlet.
<init-param>
<param-name>extra-classpath</param-name>
<param-value>WEB-INF/extra-classes1:/[YOU-ABSOLUTE-PATH-TO]/own.jar</param-value>
</init-param>
-->
<!--
This parameter allows you to select the parent component manager.
The class will be instantiated via the constructor that takes a single
String as a parameter. That String will be equal to the text after the
'/'.
Cocoon honors the LogEnabled and Initializable interfaces for this
class,
if it implements them.
If you uncomment the following lines the parent CM is set to the Parent
CM sample, which will look up
a configuration via JNDI at
org/apache/cocoon/samples/parentcm/ParentCMConfiguration
and use it.
<init-param>
<param-name>parent-component-manager</param-name>
<param-value>org.apache.cocoon.samples.parentcm.ParentComponentManager/org/apache/cocoon/samples/parentcm/ParentCMConfiguration</param-value>
</init-param>
-->
<!--
This parameter allows you to select the request factory. Possible
choices are as follows:
- org.apache.cocoon.components.request.MultipartRequestFactoryImpl
This is the default factory.
- org.apache.cocoon.components.request.MaybeUploadRequestFactoryImpl
You can opt in for this factory if maybeupload.jar is
present.
- org.apache.cocoon.components.request.SimpleRequestFactoryImpl
This factory does not allow uploads.
-->
<init-param>
<param-name>request-factory</param-name>
<param-value>org.apache.cocoon.components.request.MultipartRequestFactoryImpl</param-value>
</init-param>
<!--
If you set this parameter to 'true' or 'yes', Cocoon will add processing
time to the end of each response. Value 'hide' adds processing time as
an HTML
comment. By default, processing time is not added (corresponds to value
'no').
<init-param>
<param-name>show-time</param-name>
<param-value>hide</param-value>
</init-param>
-->
<!--
If true or not set, this class will try to catch and handle all Cocoon
exceptions.
If false, it will rethrow them to the servlet container.
-->
<init-param>
<param-name>manage-exceptions</param-name>
<param-value>true</param-value>
</init-param>
<!--
If true, Avalon Excalibur instrumentation will be enabled on all
Instrumentable
components with Cocoon and your Cocoon application.
<init-param>
<param-name>enable-instrumentation</param-name>
<param-value>true</param-value>
</init-param>
-->
<!--
This defines the location of the instrument manager configuration,
only used
if the init-param enable-instrumentation is enabled.
<init-param>
<param-name>instrumentation-config</param-name>
<param-value>/WEB-INF/instrumentation.xconf</param-value>
</init-param>
-->
<!--
Set encoding used by the container. If not set the ISO-8859-1 encoding
will be assumed.
-->
<!--
<init-param>
<param-name>container-encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
-->
<!--
Set form encoding. This will be the character set used to decode
request parameters
-->
<!--
<init-param>
<param-name>form-encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
-->
<!--
This parameter allows you to startup Cocoon2 immediately after startup
of your servlet engine.
-->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>WebDAV</servlet-name>
<display-name>WebDAV</display-name>
<description>The WebDAV servlet</description>
<servlet-class>org.apache.slide.webdav.WebdavServlet</servlet-class>
<init-param>
<param-name>scope</param-name>
<param-value>/files</param-value>
<description>
Scope of the Slide namespace that should be exposed by this servlet.
For example, if you want to expose only the /files collection via
WebDAV, set this parameter to '/files'. In that case, any URLs of the
form '/context-path/servlet-path/*' will be mapped to '/files/*'
in the Slide namespace.
The default value is an empty string.
</description>
</init-param>
<init-param>
<param-name>depth-limit</param-name>
<param-value>3</param-value>
<description>
This init-parameter determines the depth limit for PROPFIND and other
methods, to avoid performance hits on the server for requests with
infinite depth.
The default value is '3'.
</description>
</init-param>
<init-param>
<param-name>default-mime-type</param-name>
<param-value>application/octet-stream</param-value>
<description>
The MIME type that should be used for resources of unknown type. For
example, if a WebDAV client uploads a file (via PUT) without
specifying
the Content-Type header, the MIME type defined here will be used.
The default value is 'application/octet-stream'.
</description>
</init-param>
<init-param>
<param-name>default-servlet</param-name>
<param-value>false</param-value>
<description>
By default, the WebDAV servlet is mapped as default servlet of the
web application context (the url-pattern in servlet-mapping is '/').
If you want to change that mapping so the servlet is no longer the
default servlet, you must change this initialization parameter to
indicate the situation to the servlet, by setting it to 'false'.
The default value is 'true'.
</description>
</init-param>
<init-param>
<param-name>domain</param-name>
<param-value>/samples/slide/slide.xconf</param-value>
<description>
Path to the domain configuration file, relative to the path of the
web application.
The default is '/Domain.xml'.
</description>
</init-param>
<init-param>
<param-name>namespace</param-name>
<param-value>myrepository</param-value>
<description>
Name of the Slide namespace that should be accessed by this servlet.
If this parameter is provided, make sure the corresponding namespace
is defined in the domain configuration file. Otherwise, the default
namespace will be used, if one exists.
</description>
</init-param>
<init-param>
<param-name>directory-browsing</param-name>
<param-value>true</param-value>
<description>
Use the 'directory-browsing' init-parameter to turn off generation of
HTML index pages that enable browsing of collections.
The default value is 'true'.
</description>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!--
Cocoon handles all the URL space assigned to the webapp using its sitemap.
It is recommended to leave it unchanged. Under some circumstances though
(like integration with proprietary webapps or servlets) you might have
to change this parameter.
-->
<servlet-mapping>
<servlet-name>Cocoon2</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!--
Some servlet engines (Tomcat) have defaults which are not overriden
by '/' mapping, but must be overriden explicitly.
-->
<servlet-mapping>
<servlet-name>Cocoon2</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<!--
Some servlet engines (WebLogic) have defaults which are not overriden
by '/' mapping, but must be overriden explicitly.
-->
<servlet-mapping>
<servlet-name>Cocoon2</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>WebDAV</servlet-name>
<url-pattern>/webdav/*</url-pattern>
</servlet-mapping>
<mime-mapping>
<extension>css</extension>
<mime-type>text/css</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xml</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xsl</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xconf</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xmap</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ent</extension>
<mime-type>text/plain</mime-type>
</mime-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>DAV resource</web-resource-name>
<url-pattern>/webdav/*</url-pattern>
<http-method>COPY</http-method>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>HEAD</http-method>
<http-method>LOCK</http-method>
<http-method>MKCOL</http-method>
<http-method>MOVE</http-method>
<http-method>OPTIONS</http-method>
<http-method>POST</http-method>
<http-method>PROPFIND</http-method>
<http-method>PROPPATCH</http-method>
<http-method>PUT</http-method>
<http-method>UNLOCK</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>root</role-name>
<role-name>guest</role-name>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Slide DAV Server</realm-name>
</login-config>
</web-app>
1.1 xml-cocoon2/src/blocks/slide/conf/slide-action.xmap
Index: slide-action.xmap
===================================================================
<?xml version="1.0"?>
<xmap xpath="/sitemap/components/actions" unless="[EMAIL PROTECTED]'source']">
<map:action logger="sitemap.action.source" name="source"
src="org.apache.cocoon.acting.SourceMultiAction"/>
<map:action logger="sitemap.action.principal" name="principal"
src="org.apache.cocoon.acting.PrincipalMultiAction"/>
</xmap>
1.1 xml-cocoon2/src/blocks/slide/conf/slide-generator.xmap
Index: slide-generator.xmap
===================================================================
<?xml version="1.0"?>
<xmap xpath="/sitemap/components/generators" unless="[EMAIL
PROTECTED]'sourcedescription']">
<map:generator label="content,data"
logger="sitemap.generator.sourcedescription" name="sourcedescription"
src="org.apache.cocoon.generation.SourceDescriptionGenerator"/>
<map:generator label="content,data"
logger="sitemap.generator.principallist" name="principallist"
src="org.apache.cocoon.generation.PrincipalListGenerator"/>
</xmap>
1.1 xml-cocoon2/src/blocks/slide/conf/slide-inspector.xroles
Index: slide-inspector.xroles
===================================================================
<?xml version="1.0"?>
<xroles xpath="/role-list" unless="[EMAIL
PROTECTED]'org.apache.cocoon.components.source.SourceInspector']">
<role name="org.apache.cocoon.components.source.SourceInspector"
shorthand="source-inspectors"
default-class="org.apache.cocoon.components.source.impl.SourceInspectorManager"/>
</xroles>
1.1 xml-cocoon2/src/blocks/slide/conf/slide-repository.xconf
Index: slide-repository.xconf
===================================================================
<?xml version="1.0"?>
<xconf xpath="/cocoon" unless="[EMAIL
PROTECTED]'org.apache.cocoon.components.repository.SourceRepositorySelector']">
<!-- Source repositories:
Each source repository handles serveral sources sorted in namspaces. Which
can be access via the RepositorySourceFactory.
-->
<component
role="org.apache.cocoon.components.repository.SourceRepositorySelector"
class="org.apache.cocoon.components.ExtendedComponentSelector"
logger="core.repositories"
default="slide">
<!-- Default implementation via Jakarta Slide -->
<component-instance
class="org.apache.cocoon.components.repository.impl.SlideRepository"
name="slide"
logger="core.repositories.slide"
file="context://samples/slide/slide.xconf"/>
</component>
<!-- Principal providers:
The principal providers handles principals/users, they should use for user
management,
-->
<component
role="org.apache.cocoon.components.repository.PrincipalProviderSelector"
class="org.apache.cocoon.components.ExtendedComponentSelector"
logger="core.repositories.principalprovider" default="slide">
<!-- Default implementation via Jakarta Slide -->
<component-instance
class="org.apache.cocoon.components.repository.impl.SlidePrincipalProvider"
name="slide"
logger="core.repositories.principalprovider.slide"
repository="slide" namespace="myrepository"/>
</component>
</xconf>
1.1 xml-cocoon2/src/blocks/slide/conf/slide-repository.xroles
Index: slide-repository.xroles
===================================================================
<?xml version="1.0"?>
<xroles xpath="/role-list" unless="[EMAIL
PROTECTED]'org.apache.cocoon.components.repository.RepositorySelector']">
<role name="org.apache.cocoon.components.repository.RepositorySelector"
shorthand="repositories"
default-class="org.apache.cocoon.components.ExtendedComponentSelector">
<hint shorthand="slide"
class="org.apache.cocoon.components.repository.impl.SlideRepository"/>
</role>
<role
name="org.apache.cocoon.components.repository.PrincipalProviderSelector"
shorthand="principal-provider"
default-class="org.apache.cocoon.components.ExtendedComponentSelector">
<hint shorthand="slide"
class="org.apache.cocoon.components.repository.impl.SlidePrincipalProvider"/>
</role>
</xroles>
1.1 xml-cocoon2/src/blocks/slide/conf/slide-source.xconf
Index: slide-source.xconf
===================================================================
<?xml version="1.0"?>
<xconf xpath="/cocoon/source-factories" unless="[EMAIL PROTECTED]'slide']">
<!-- pseudo protocol for Jakarta Slide repositories -->
<component-instance name="slide"
class="org.apache.cocoon.components.source.impl.SlideSourceFactory"/>
</xconf>
1.1
xml-cocoon2/src/blocks/slide/conf/slide-sourceinspector.xconf
Index: slide-sourceinspector.xconf
===================================================================
<?xml version="1.0"?>
<xconf xpath="/cocoon" unless="[EMAIL
PROTECTED]'org.apache.cocoon.components.source.SourceInspector']">
<!-- Source inspectors:
Each source inspectors helps to retrieve properties from sources
-->
<component role="org.apache.cocoon.components.source.SourceInspector"
class="org.apache.cocoon.components.source.impl.SourceInspectorManager"
logger="core.source.sourceinspector">
<sourceinspector
class="org.apache.cocoon.components.source.impl.XPathSourceInspector">
<parameter name="namespace" value="http://xml.apache.org/cocoon/xdoc/1.0"/>
<parameter name="name" value="title"/>
<parameter name="extension" value=".xdoc"/>
<parameter name="xpath" value="/document/header/title"/>
</sourceinspector>
<sourceinspector
class="org.apache.cocoon.components.source.impl.JPEGSourceInspector"/>
<sourceinspector
class="org.apache.cocoon.components.source.impl.GIFSourceInspector"/>
</component>
</xconf>
1.1 xml-cocoon2/src/blocks/slide/conf/slide.xsamples
Index: slide.xsamples
===================================================================
<?xml version="1.0"?>
<xsamples xpath="/samples" unless="[EMAIL PROTECTED]'slide']">
<group name="slide">
<sample name="Slide Integration" href="slide/">
Shows an example of how it could be possible to integrate a
Content Management System, like Jakarta Slide, into Cocoon.
</sample>
</group>
</xsamples>
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/acting/PrincipalMultiAction.java
Index: PrincipalMultiAction.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.acting;
import java.util.Map;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentSelector;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.repository.Principal;
import org.apache.cocoon.components.repository.PrincipalGroup;
import org.apache.cocoon.components.repository.PrincipalProvider;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
/**
* Multiple actions for to add, to removing and to modify principals or
principal groups.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version CVS $Id: PrincipalMultiAction.java,v 1.1 2003/01/31 18:08:43
stephan Exp $
*/
public class PrincipalMultiAction extends AbstractMultiAction implements
ThreadSafe {
public final static String CALLER_PRINCIPAL_NAME =
"cocoon-caller-principal-name";
public final static String CALLER_PRINCIPAL_PASSWORD =
"cocooon-caller-principal-password";
public final static String PRINCIPAL_PROVIDER =
"cocoon-principal-provider";
public final static String PRINCIPAL_NAME = "cocoon-principal-name";
public final static String PRINCIPAL_ROLE = "cocoon-principal-role";
public final static String PRINCIPAL_PASSWORD =
"cocoon-principal-password";
public final static String PRINCIPAL_GROUP_NAME =
"cocoon-principal-group-name";
public Map doAddPrincipal(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws Exception {
getLogger().debug("add principal called");
Request request = ObjectModelHelper.getRequest(objectModel);
String principal_provider =
parameters.getParameter(PRINCIPAL_PROVIDER,
request.getParameter(PRINCIPAL_PROVIDER));
String caller_principal_name =
parameters.getParameter(CALLER_PRINCIPAL_NAME,
request.getParameter(CALLER_PRINCIPAL_NAME));
String caller_principal_password =
parameters.getParameter(CALLER_PRINCIPAL_PASSWORD,
request.getParameter(CALLER_PRINCIPAL_PASSWORD));
String principal_name = parameters.getParameter(PRINCIPAL_NAME,
request.getParameter(PRINCIPAL_NAME));
String principal_role = parameters.getParameter(PRINCIPAL_ROLE,
request.getParameter(PRINCIPAL_ROLE));
String principal_password =
parameters.getParameter(PRINCIPAL_PASSWORD,
request.getParameter(PRINCIPAL_PASSWORD));
ComponentSelector principalproviders = null;
PrincipalProvider principalprovider = null;
try {
principalproviders =
(ComponentSelector)this.manager.lookup(PrincipalProvider.ROLE+"Selector");
principalprovider =
(PrincipalProvider)principalproviders.select(principal_provider);
Principal caller = new Principal(caller_principal_name,
caller_principal_password);
Principal principal = new Principal(principal_name,
principal_role, principal_password);
principalprovider.addPrincipal(caller, principal);
} catch (ComponentException ce) {
if (getLogger().isDebugEnabled())
getLogger().debug("Could not lookup for component.", ce);
throw new ProcessingException("Could not lookup for component.",
ce);
} finally {
if (principalprovider!=null)
principalproviders.release(principalprovider);
principalprovider = null;
if (principalproviders!=null)
this.manager.release(principalproviders);
principalproviders = null;
}
return EMPTY_MAP;
}
public Map doRemovePrincipal(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws Exception {
getLogger().debug("remove principal called");
Request request = ObjectModelHelper.getRequest(objectModel);
String principal_provider =
parameters.getParameter(PRINCIPAL_PROVIDER,
request.getParameter(PRINCIPAL_PROVIDER));
String caller_principal_name =
parameters.getParameter(CALLER_PRINCIPAL_NAME,
request.getParameter(CALLER_PRINCIPAL_NAME));
String caller_principal_password =
parameters.getParameter(CALLER_PRINCIPAL_PASSWORD,
request.getParameter(CALLER_PRINCIPAL_PASSWORD));
String principal_name = parameters.getParameter(PRINCIPAL_NAME,
request.getParameter(PRINCIPAL_NAME));
ComponentSelector principalproviders = null;
PrincipalProvider principalprovider = null;
try {
principalproviders =
(ComponentSelector)this.manager.lookup(PrincipalProvider.ROLE+"Selector");
principalprovider =
(PrincipalProvider)principalproviders.select(principal_provider);
Principal caller = new Principal(caller_principal_name,
caller_principal_password);
Principal principal = new Principal(principal_name);
principalprovider.removePrincipal(caller, principal);
} catch (ComponentException ce) {
if (getLogger().isDebugEnabled())
getLogger().debug("Could not lookup for component.", ce);
throw new ProcessingException("Could not lookup for component.",
ce);
} finally {
if (principalprovider!=null)
principalproviders.release(principalprovider);
principalprovider = null;
if (principalproviders!=null)
this.manager.release(principalproviders);
principalproviders = null;
}
return EMPTY_MAP;
}
public Map doAddPrincipalGroup(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws Exception {
getLogger().debug("add principal group called");
Request request = ObjectModelHelper.getRequest(objectModel);
String principal_provider =
parameters.getParameter(PRINCIPAL_PROVIDER,
request.getParameter(PRINCIPAL_PROVIDER));
String caller_principal_name =
parameters.getParameter(CALLER_PRINCIPAL_NAME,
request.getParameter(CALLER_PRINCIPAL_NAME));
String caller_principal_password =
parameters.getParameter(CALLER_PRINCIPAL_PASSWORD,
request.getParameter(CALLER_PRINCIPAL_PASSWORD));
String principal_group_name =
parameters.getParameter(PRINCIPAL_GROUP_NAME,
request.getParameter(PRINCIPAL_GROUP_NAME));
ComponentSelector principalproviders = null;
PrincipalProvider principalprovider = null;
try {
principalproviders =
(ComponentSelector)this.manager.lookup(PrincipalProvider.ROLE+"Selector");
principalprovider =
(PrincipalProvider)principalproviders.select(principal_provider);
Principal caller = new Principal(caller_principal_name,
caller_principal_password);
PrincipalGroup principalgroup = new
PrincipalGroup(principal_group_name);
principalprovider.addPrincipalGroup(caller, principalgroup);
} catch (ComponentException ce) {
if (getLogger().isDebugEnabled())
getLogger().debug("Could not lookup for component.", ce);
throw new ProcessingException("Could not lookup for component.",
ce);
} finally {
if (principalprovider!=null)
principalproviders.release(principalprovider);
principalprovider = null;
if (principalproviders!=null)
this.manager.release(principalproviders);
principalproviders = null;
}
return EMPTY_MAP;
}
public Map doRemovePrincipalGroup(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws Exception
{
getLogger().debug("remove principal group called");
Request request = ObjectModelHelper.getRequest(objectModel);
String principal_provider =
parameters.getParameter(PRINCIPAL_PROVIDER,
request.getParameter(PRINCIPAL_PROVIDER));
String caller_principal_name =
parameters.getParameter(CALLER_PRINCIPAL_NAME,
request.getParameter(CALLER_PRINCIPAL_NAME));
String caller_principal_password =
parameters.getParameter(CALLER_PRINCIPAL_PASSWORD,
request.getParameter(CALLER_PRINCIPAL_PASSWORD));
String principal_group_name =
parameters.getParameter(PRINCIPAL_GROUP_NAME,
request.getParameter(PRINCIPAL_GROUP_NAME));
ComponentSelector principalproviders = null;
PrincipalProvider principalprovider = null;
try {
principalproviders =
(ComponentSelector)this.manager.lookup(PrincipalProvider.ROLE+"Selector");
principalprovider =
(PrincipalProvider)principalproviders.select(principal_provider);
Principal caller = new Principal(caller_principal_name,
caller_principal_password);
PrincipalGroup principalgroup = new
PrincipalGroup(principal_group_name);
principalprovider.removePrincipalGroup(caller, principalgroup);
} catch (ComponentException ce) {
if (getLogger().isDebugEnabled())
getLogger().debug("Could not lookup for component.", ce);
throw new ProcessingException("Could not lookup for component.",
ce);
} finally {
if (principalprovider!=null)
principalproviders.release(principalprovider);
principalprovider = null;
if (principalproviders!=null)
this.manager.release(principalproviders);
principalproviders = null;
}
return EMPTY_MAP;
}
public Map doAddPrincipalGroupMember(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws
Exception {
getLogger().debug("add principal group member called");
Request request = ObjectModelHelper.getRequest(objectModel);
String principal_provider =
parameters.getParameter(PRINCIPAL_PROVIDER,
request.getParameter(PRINCIPAL_PROVIDER));
String caller_principal_name =
parameters.getParameter(CALLER_PRINCIPAL_NAME,
request.getParameter(CALLER_PRINCIPAL_NAME));
String caller_principal_password =
parameters.getParameter(CALLER_PRINCIPAL_PASSWORD,
request.getParameter(CALLER_PRINCIPAL_PASSWORD));
String principal_group_name =
parameters.getParameter(PRINCIPAL_GROUP_NAME,
request.getParameter(PRINCIPAL_GROUP_NAME));
String principal_name = parameters.getParameter(PRINCIPAL_NAME,
request.getParameter(PRINCIPAL_NAME));
ComponentSelector principalproviders = null;
PrincipalProvider principalprovider = null;
try {
principalproviders =
(ComponentSelector)this.manager.lookup(PrincipalProvider.ROLE+"Selector");
principalprovider =
(PrincipalProvider)principalproviders.select(principal_provider);
Principal caller = new Principal(caller_principal_name,
caller_principal_password);
PrincipalGroup principalgroup = new
PrincipalGroup(principal_group_name);
Principal principal = new Principal(principal_name);
principalprovider.addMember(caller, principalgroup, principal);
} catch (ComponentException ce) {
if (getLogger().isDebugEnabled())
getLogger().debug("Could not lookup for component.", ce);
throw new ProcessingException("Could not lookup for component.",
ce);
} finally {
if (principalprovider!=null)
principalproviders.release(principalprovider);
principalprovider = null;
if (principalproviders!=null)
this.manager.release(principalproviders);
principalproviders = null;
}
return EMPTY_MAP;
}
public Map doRemovePrincipalGroupMember(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws
Exception {
getLogger().debug("add principal group member called");
Request request = ObjectModelHelper.getRequest(objectModel);
String principal_provider =
parameters.getParameter(PRINCIPAL_PROVIDER,
request.getParameter(PRINCIPAL_PROVIDER));
String caller_principal_name =
parameters.getParameter(CALLER_PRINCIPAL_NAME,
request.getParameter(CALLER_PRINCIPAL_NAME));
String caller_principal_password =
parameters.getParameter(CALLER_PRINCIPAL_PASSWORD,
request.getParameter(CALLER_PRINCIPAL_PASSWORD));
String principal_group_name =
parameters.getParameter(PRINCIPAL_GROUP_NAME,
request.getParameter(PRINCIPAL_GROUP_NAME));
String principal_name = parameters.getParameter(PRINCIPAL_NAME,
request.getParameter(PRINCIPAL_NAME));
ComponentSelector principalproviders = null;
PrincipalProvider principalprovider = null;
try {
principalproviders =
(ComponentSelector)this.manager.lookup(PrincipalProvider.ROLE+"Selector");
principalprovider =
(PrincipalProvider)principalproviders.select(principal_provider);
Principal caller = new Principal(caller_principal_name,
caller_principal_password);
PrincipalGroup principalgroup = new
PrincipalGroup(principal_group_name);
Principal principal = new Principal(principal_name);
principalprovider.removeMember(caller, principalgroup, principal);
} catch (ComponentException ce) {
if (getLogger().isDebugEnabled())
getLogger().debug("Could not lookup for component.", ce);
throw new ProcessingException("Could not lookup for component.",
ce);
} finally {
if (principalprovider!=null)
principalproviders.release(principalprovider);
principalprovider = null;
if (principalproviders!=null)
this.manager.release(principalproviders);
principalproviders = null;
}
return EMPTY_MAP;
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/acting/SourceMultiAction.java
Index: SourceMultiAction.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.acting;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.request.multipart.FilePart;
import org.apache.cocoon.components.source.InspectableSource;
import org.apache.cocoon.components.source.ModifiableTraversableSource;
import org.apache.cocoon.components.source.RestrictableSource;
import org.apache.cocoon.components.source.WriteableSource;
import org.apache.cocoon.components.source.helpers.GroupSourcePermission;
import org.apache.cocoon.components.source.helpers.PrincipalSourcePermission;
import org.apache.cocoon.components.source.helpers.SourceCredential;
import org.apache.cocoon.components.source.helpers.SourcePermission;
import org.apache.cocoon.components.source.helpers.SourceProperty;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
/**
* Multiple actions for upload files, change properties and permissions.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version CVS $Id: SourceMultiAction.java,v 1.1 2003/01/31 18:08:43 stephan
Exp $
*/
public class SourceMultiAction extends AbstractMultiAction implements
ThreadSafe {
public final static String SOURCE_URI = "cocoon-source-uri";
public final static String SOURCE_PROPERTY_NAMESPACE =
"cocoon-source-property-namespace";
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";
public final static String PRINCIPAL = "cocoon-source-principal";
public final static String PASSWORD = "cocoon-source-password";
public final static String UPLOAD_FILE = "cocoon-upload-file";
public final static String SOURCE_NAME = "cocoon-source-name";
public Map doUploadSource(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws Exception {
Request request = ObjectModelHelper.getRequest(objectModel);
String uri = parameters.getParameter(SOURCE_URI,
request.getParameter(SOURCE_URI));
String filename = parameters.getParameter(SOURCE_NAME,
request.getParameter(SOURCE_NAME));
if (filename!=null)
filename = filename.trim();
String principal = parameters.getParameter(PRINCIPAL,
request.getParameter(PRINCIPAL));
String password = parameters.getParameter(PASSWORD,
request.getParameter(PASSWORD));
getLogger().info("upload source called by '"+principal+"' for
'"+uri+"'");
if ((request.get(UPLOAD_FILE)!=null) &&
(request.get(UPLOAD_FILE) instanceof FilePart)) {
FilePart filepart = (FilePart)request.get(UPLOAD_FILE);
try {
if ((filename==null) || (filename.length()==0)) {
filename = filepart.getFilePath();
int index = filename.lastIndexOf("/");
if (index>=0)
filename = filename.substring(index+1);
index = filename.lastIndexOf("\\");
if (index>=0)
filename = filename.substring(index+1);
}
if ((uri==null) || (uri.length()==0))
uri = filename;
else if (uri.endsWith("/"))
uri = uri+filename;
else
uri = uri+"/"+filename;
Source source = resolver.resolveURI(uri);
if (source instanceof RestrictableSource)
((RestrictableSource)source).setSourceCredential(new
SourceCredential(principal, password));
if (source instanceof WriteableSource) {
WriteableSource writeablesource = (WriteableSource)source;
OutputStream out = writeablesource.getOutputStream();
byte[] buffer = new byte[8192];
int length = -1;
InputStream in = filepart.getInputStream();
while ((length = in.read(buffer)) > -1) {
out.write(buffer, 0, length);
getLogger().debug("="+length);
}
in.close();
out.flush();
out.close();
} else
throw new ProcessingException("Source isn't writeable");
} catch (SourceException se) {
if (getLogger().isDebugEnabled())
getLogger().debug("Exception occurs while storing the
content", se);
throw new ProcessingException("Exception occurs while storing
the content", se);
} catch (IOException ioe) {
if (getLogger().isDebugEnabled())
getLogger().debug("Exception occurs while storing the
content", ioe);
throw new ProcessingException("Exception occurs while storing
the content", ioe);
}
} else {
getLogger().debug("Couldn't get upload file");
}
return EMPTY_MAP;
}
public Map doCreateCollection(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws Exception {
Request request = ObjectModelHelper.getRequest(objectModel);
String uri = parameters.getParameter(SOURCE_URI,
request.getParameter(SOURCE_URI));
String collectionname = parameters.getParameter(SOURCE_NAME,
request.getParameter(SOURCE_NAME));
String principal = parameters.getParameter(PRINCIPAL,
request.getParameter(PRINCIPAL));
String password = parameters.getParameter(PASSWORD,
request.getParameter(PASSWORD));
getLogger().info("create collection called by '"+principal+"' for
'"+uri+"'");
try {
Source source = resolver.resolveURI(uri);
if (source instanceof RestrictableSource)
((RestrictableSource)source).setSourceCredential(new
SourceCredential(principal, password));
if (source instanceof ModifiableTraversableSource) {
ModifiableTraversableSource modifiabletraversablesource =
(ModifiableTraversableSource)source;
modifiabletraversablesource.createCollection(collectionname);
} else
throw new ProcessingException("Source isn't writeable");
} catch (SourceException se) {
if (getLogger().isDebugEnabled())
getLogger().debug("Exception occurs while creation of a
collection", se);
throw new ProcessingException("Exception occurs while creation of
a collection", se);
}
return EMPTY_MAP;
}
public Map doDeleteSource(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws Exception {
Request request = ObjectModelHelper.getRequest(objectModel);
String uri = parameters.getParameter(SOURCE_URI,
request.getParameter(SOURCE_URI));
String principal = parameters.getParameter(PRINCIPAL,
request.getParameter(PRINCIPAL));
String password = parameters.getParameter(PASSWORD,
request.getParameter(PASSWORD));
getLogger().info("delete source called by '"+principal+"' for
'"+uri+"'");
try {
Source source = resolver.resolveURI(uri);
if (source instanceof RestrictableSource)
((RestrictableSource)source).setSourceCredential(new
SourceCredential(principal, password));
if (source instanceof WriteableSource) {
WriteableSource writeablesource = (WriteableSource)source;
writeablesource.delete();
} else
throw new ProcessingException("Source isn't writeable");
} 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 doAddProperty(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws Exception {
Request request = ObjectModelHelper.getRequest(objectModel);
String uri = parameters.getParameter(SOURCE_URI,
request.getParameter(SOURCE_URI));
String namespace = parameters.getParameter(SOURCE_PROPERTY_NAMESPACE,
request.getParameter(SOURCE_PROPERTY_NAMESPACE));
String name = parameters.getParameter(SOURCE_PROPERTY_NAME,
request.getParameter(SOURCE_PROPERTY_NAME));
String value = parameters.getParameter(SOURCE_PROPERTY_VALUE,
request.getParameter(SOURCE_PROPERTY_VALUE));
String principal = parameters.getParameter(PRINCIPAL,
request.getParameter(PRINCIPAL));
String password = parameters.getParameter(PASSWORD,
request.getParameter(PASSWORD));
getLogger().info("add property called by '"+principal+"' for
'"+uri+"'");
try {
Source source = resolver.resolveURI(uri);
if (source instanceof RestrictableSource)
((RestrictableSource)source).setSourceCredential(new
SourceCredential(principal, password));
if (source instanceof InspectableSource) {
InspectableSource inspectablesource =
(InspectableSource)source;
SourceProperty property = new SourceProperty(namespace, name,
value);
inspectablesource.setSourceProperty(property);
} else
throw new ProcessingException("Source isn't inspectable");
} 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 doDeleteProperty(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws Exception {
Request request = ObjectModelHelper.getRequest(objectModel);
String uri = parameters.getParameter(SOURCE_URI,
request.getParameter(SOURCE_URI));
String namespace = parameters.getParameter(SOURCE_PROPERTY_NAMESPACE,
request.getParameter(SOURCE_PROPERTY_NAMESPACE));
String name = parameters.getParameter(SOURCE_PROPERTY_NAME,
request.getParameter(SOURCE_PROPERTY_NAME));
String principal = parameters.getParameter(PRINCIPAL,
request.getParameter(PRINCIPAL));
String password = parameters.getParameter(PASSWORD,
request.getParameter(PASSWORD));
getLogger().info("delete property called by '"+principal+"' for
'"+uri+"'");
try {
Source source = resolver.resolveURI(uri);
if (source instanceof RestrictableSource)
((RestrictableSource)source).setSourceCredential(new
SourceCredential(principal, password));
if (source instanceof InspectableSource) {
InspectableSource inspectablesource =
(InspectableSource)source;
inspectablesource.removeSourceProperty(namespace, name);
} else
throw new ProcessingException("Source isn't inspectable");
} 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 doAddPrincipalPermission(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws Exception {
Request request = ObjectModelHelper.getRequest(objectModel);
String uri = parameters.getParameter(SOURCE_URI,
request.getParameter(SOURCE_URI));
String subject = parameters.getParameter(SOURCE_PERMISSION_PRINCIPAL,
request.getParameter(SOURCE_PERMISSION_PRINCIPAL));
String privilege =
parameters.getParameter(SOURCE_PERMISSION_PRIVILEGE,
request.getParameter(SOURCE_PERMISSION_PRIVILEGE));
boolean inheritable =
Boolean.valueOf(parameters.getParameter(SOURCE_PERMISSION_INHERITABLE,
request.getParameter(SOURCE_PERMISSION_INHERITABLE))).booleanValue();
boolean negative =
Boolean.valueOf(parameters.getParameter(SOURCE_PERMISSION_NEGATIVE,
request.getParameter(SOURCE_PERMISSION_NEGATIVE))).booleanValue();
String principal = parameters.getParameter(PRINCIPAL,
request.getParameter(PRINCIPAL));
String password = parameters.getParameter(PASSWORD,
request.getParameter(PASSWORD));
getLogger().info("add principal permission called by '"+principal+"'
for '"+uri+"'");
try {
Source source = resolver.resolveURI(uri);
if (source instanceof RestrictableSource) {
RestrictableSource restrictablesource =
(RestrictableSource)source;
restrictablesource.setSourceCredential(new
SourceCredential(principal, password));
SourcePermission permission =
new PrincipalSourcePermission(subject, privilege,
inheritable, negative);
restrictablesource.addSourcePermission(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 doRemovePrincipalPermission(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws Exception {
Request request = ObjectModelHelper.getRequest(objectModel);
String uri = parameters.getParameter(SOURCE_URI,
request.getParameter(SOURCE_URI));
String subject = parameters.getParameter(SOURCE_PERMISSION_PRINCIPAL,
request.getParameter(SOURCE_PERMISSION_PRINCIPAL));
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));
getLogger().info("remove principal permission called by
'"+principal+"' for '"+uri+"'");
try {
Source source = resolver.resolveURI(uri);
if (source instanceof RestrictableSource) {
RestrictableSource restrictablesource =
(RestrictableSource)source;
restrictablesource.setSourceCredential(new
SourceCredential(principal, password));
SourcePermission permission =
new PrincipalSourcePermission(subject, privilege,
inheritable, negative);
restrictablesource.removeSourcePermission(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 doAddPrincipalGroupPermission(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws Exception {
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.valueOf(parameters.getParameter(SOURCE_PERMISSION_INHERITABLE,
request.getParameter(SOURCE_PERMISSION_INHERITABLE))).booleanValue();
boolean negative =
Boolean.valueOf(parameters.getParameter(SOURCE_PERMISSION_NEGATIVE,
request.getParameter(SOURCE_PERMISSION_NEGATIVE))).booleanValue();
String principal = parameters.getParameter(PRINCIPAL,
request.getParameter(PRINCIPAL));
String password = parameters.getParameter(PASSWORD,
request.getParameter(PASSWORD));
getLogger().info("add principal group permission called by
'"+principal+"' for '"+uri+"'");
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.addSourcePermission(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 doRemovePrincipalGroupPermission(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String src,
Parameters parameters) throws Exception {
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));
getLogger().info("remove principal group permission called by
'"+principal+"' for '"+uri+"'");
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.removeSourcePermission(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;
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/repository/Principal.java
Index: Principal.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.repository;
/**
* This class represents a principal. The implementation is based
* on the interface java.security.Principal.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: Principal.java,v 1.1 2003/01/31 18:08:43 stephan Exp $
*/
public class Principal implements java.security.Principal {
private String name = null;
private String role = null;
private String password = null;
public Principal(String name) {
this.name = name;
}
public Principal(String name, String password) {
this.name = name;
this.password = password;
}
public Principal(String name, String role, String password) {
this.name = name;
this.role = role;
this.password = password;
}
/**
* Returns the name of the principal
*
* @return Name of principal
*/
public String getName() {
return this.name;
}
/**
* Sets the name
*
* @param name Name of principal
*/
public void setName(String name) {
this.name = name;
}
/**
* Returns the role of the principal
*
* @return Role of the principal
*/
public String getRole() {
return this.role;
}
/**
* Sets the role of the user
*
* @param Role of the principal
*/
public void setRole(String role) {
this.role = role;
}
/**
* Returns the password of the principal
*
* @return Password of the principal
*/
public String getPassword() {
return this.password;
}
/**
* Sets the password of the user
*
* @param password Password of the principal
*/
public void setPassword(String password) {
this.password = password;
}
/**
* Compares this principal to the specified object. Returns true
* if the object passed in matches the principal.
*
* @param another Principal to compare with.
* @return True if the principal passed in is the same as that
* encapsulated by this principal, and false otherwise.
*/
public boolean equals(Object another) {
if (another instanceof java.security.Principal)
return
this.name.equals(((java.security.Principal)another).getName());
return false;
}
/**
* Returns a string representation of this principal.
*
* @return A string representation of this principal.
*/
public String toString() {
return this.name;
}
/**
* Returns a hashcode for this principal.
*
* @return A hashcode for this principal.
*/
public int hashCode() {
return this.name.hashCode();
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/repository/PrincipalGroup.java
Index: PrincipalGroup.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.repository;
/**
* This class represents a group of principals.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: PrincipalGroup.java,v 1.1 2003/01/31 18:08:43 stephan Exp $
*/
public class PrincipalGroup {
private String name = null;
public PrincipalGroup(String name) {
this.name = name;
}
/**
* Returns the name of the group.
*
* @return Name of the group.
*/
public String getName() {
return this.name;
}
/**
* Sets the name of the group.
*
* @param Name of the group.
*/
public void setName(String name) {
this.name = name;
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/repository/PrincipalProvider.java
Index: PrincipalProvider.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.repository;
import org.apache.avalon.framework.component.Component;
import org.apache.cocoon.ProcessingException;
/**
* Manager for principals and grop of users. The implementation
* is similar to the classes java.security.* .
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: PrincipalProvider.java,v 1.1 2003/01/31 18:08:43 stephan Exp
$
*/
public interface PrincipalProvider extends Component {
/** Role for the component */
public final static String ROLE =
"org.apache.cocoon.components.repository.PrincipalProvider";
/**
* Return all users.
*
* @param caller The principal, which should do the operation
* @return List of all principals
*/
public Principal[] getPrincipals(Principal caller)
throws ProcessingException;
/**
* Add or modify a given principal.
*
* @param caller The principal, which should do the operation.
* @param principal The Principal, which should be add/modified.
*/
public void addPrincipal(Principal caller, Principal principal)
throws ProcessingException;
/**
* Remove a given principal.
*
* @param caller The principal, which should do the operation.
* @param principal The Principal, which should be removed.
*/
public void removePrincipal(Principal caller, Principal principal)
throws ProcessingException;
/**
* Return all groups.
*
* @param caller The principal, which should do the operation.
* @return List of all groups.
*/
public PrincipalGroup[] getPrincipalGroups(Principal caller)
throws ProcessingException;
/**
* Add or modify a given group.
*
* @param caller The principal, which should do the operation.
* @param group The group, which shoud be add/modified.
*/
public void addPrincipalGroup(Principal caller, PrincipalGroup group)
throws ProcessingException;
/**
* Remove a given group.
*
* @param caller The principal, which should do the operation.
* @param group The group, which shoud be removed.
*/
public void removePrincipalGroup(Principal caller, PrincipalGroup group)
throws ProcessingException;
/**
* Adds the specified member to the group.
*
* @param caller The principal, which should do the operation
* @param group The given group.
* @param user The principal to add to this group.
*/
public void addMember(Principal caller, PrincipalGroup group, Principal
user)
throws ProcessingException;
/**
* Returns true if the passed principal is a member of the group.
*
* @param caller The principal, which should do the operation
* @param group The given group.
* @param member The principal whose membership is to be checked.
* @return True if the principal is a member of this group, false
otherwise.
*/
public boolean isMember(Principal caller, PrincipalGroup group, Principal
member)
throws ProcessingException;
/**
* Returns an array of the members in the group. The
* returned objects are instances of Principal
*
* @param caller The principal, which should do the operation
* @param group The given group.
* @return An array of the group members.
*/
public Principal[] members(Principal caller, PrincipalGroup group)
throws ProcessingException;
/**
* Removes the specified member from the group.
*
* @param caller The principal, which should do the operation
* @param group The given group.
* @param principal The principal to remove from this group.
*/
public void removeMember(Principal caller, PrincipalGroup group,
Principal principal)
throws ProcessingException;
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/repository/Repository.java
Index: Repository.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.repository;
import org.apache.avalon.framework.component.Component;
/**
* This interface represents a repository from a CMS.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: Repository.java,v 1.1 2003/01/31 18:08:43 stephan Exp $
*/
public interface Repository extends Component {
/** Role for the component */
public final static String ROLE =
"org.apache.cocoon.components.repository.SourceRepository";
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/repository/impl/SlideConfigurationAdapter.java
Index: SlideConfigurationAdapter.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.repository.impl;
import org.apache.slide.util.conf.Configuration;
import org.apache.slide.util.conf.ConfigurationException;
import java.util.*;
/**
* The class represent an adapter for the configuration class from jakarta
slide
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: SlideConfigurationAdapter.java,v 1.1 2003/01/31 18:08:43
stephan Exp $
*/
public class SlideConfigurationAdapter implements Configuration {
private org.apache.avalon.framework.configuration.Configuration
configuration;
public
SlideConfigurationAdapter(org.apache.avalon.framework.configuration.Configuration
configuration) {
this.configuration = configuration;
}
/**
* Return the name of the node.
*
* @post getName() != null
*
* @returns name of the <code>Configuration</code> node.
*/
public String getName() {
return this.configuration.getName();
}
/**
* Return a new <code>Configuration</code> instance encapsulating the
* specified child node.
*
* @pre child != null
* @post getConfiguration() != null
* @param child The name of the child node.
*
* @returns Configuration
*
* @exception ConfigurationException If no child with that name exists.
*/
public Configuration getConfiguration(String child)
throws ConfigurationException {
return new
SlideConfigurationAdapter(this.configuration.getChild(child));
}
/**
* Return an <code>Enumeration</code> of <code>Configuration<code>
* elements containing all node children with the specified name.
*
* @pre name != null
* @post getConfigurations() != null
* @param name The name of the children to get.
*
* @returns Enumeration. The <code>Enumeration</code> will be
* empty if there are no nodes by the specified name.
*/
public Enumeration getConfigurations(String name) {
Vector configurations = new Vector();
org.apache.avalon.framework.configuration.Configuration[] childs =
this.configuration.getChildren(name);
for (int i=0; i<childs.length; i++) {
configurations.addElement(new
SlideConfigurationAdapter(childs[i]));
}
return configurations.elements();
}
/**
* Return the value of specified attribute.
*
* @pre paramName != null
* @post getAttribute != null
* @param paramName The name of the parameter you ask the value of.
*
* @returns String value of attribute.
*
* @exception ConfigurationException If no attribute with that name
exists.
*/
public String getAttribute(String paramName)
throws ConfigurationException {
try {
return this.configuration.getAttribute(paramName);
} catch
(org.apache.avalon.framework.configuration.ConfigurationException ce) {
throw new ConfigurationException(ce.getMessage(), this);
}
}
/**
* Return the <code>int</code> value of the specified attribute contained
* in this node.
*
* @pre paramName != null
* @post getAttributeAsInt() != null
* @param paramName The name of the parameter you ask the value of.
*
* @returns int value of attribute
*
* @exception ConfigurationException If no parameter with that name
exists.
* or if conversion to <code>int</code>
fails.
*/
public int getAttributeAsInt(String paramName)
throws ConfigurationException {
try {
return this.configuration.getAttributeAsInteger(paramName);
} catch
(org.apache.avalon.framework.configuration.ConfigurationException ce) {
throw new ConfigurationException(ce.getMessage(), this);
}
}
/**
* Returns the value of the attribute specified by its name as a
* <code>long</code>.
*
* @pre paramName != null
* @post getAttributeAsLong() != null
* @param paramName The name of the parameter you ask the value of.
*
* @returns long value of attribute
*
* @exception ConfigurationException If no parameter with that name
exists.
* or if conversion to
<code>long</code> fails.
*/
public long getAttributeAsLong(String name)
throws ConfigurationException {
try {
return this.configuration.getAttributeAsLong(name);
} catch
(org.apache.avalon.framework.configuration.ConfigurationException ce) {
throw new ConfigurationException(ce.getMessage(), this);
}
}
/**
* Return the <code>float</code> value of the specified parameter
contained
* in this node.
*
* @pre paramName != null
* @post getAttributeAsFloat() != null
* @param paramName The name of the parameter you ask the value of.
*
* @returns float value of attribute
*
* @exception ConfigurationException If no parameter with that name
exists.
* or if conversion to
<code>float</code> fails.
*/
public float getAttributeAsFloat(String paramName)
throws ConfigurationException {
try {
return this.configuration.getAttributeAsFloat(paramName);
} catch
(org.apache.avalon.framework.configuration.ConfigurationException ce) {
throw new ConfigurationException(ce.getMessage(), this);
}
}
/**
* Return the <code>boolean</code> value of the specified parameter
contained
* in this node.<br>
*
* @pre paramName != null
* @post getAttributeAsBoolean() != null
* @param paramName The name of the parameter you ask the value of.
*
* @returns boolean value of attribute
*
* @exception ConfigurationException If no parameter with that name
exists.
* or if conversion to
<code>boolean</code> fails.
*/
public boolean getAttributeAsBoolean(String paramName)
throws ConfigurationException {
try {
return this.configuration.getAttributeAsBoolean(paramName);
} catch
(org.apache.avalon.framework.configuration.ConfigurationException ce) {
throw new ConfigurationException(ce.getMessage(), this);
}
}
/**
* Return the <code>String</code> value of the node.
*
* @post getValue() != null
*
* @returns the value of the node.
*/
public String getValue() {
try {
return this.configuration.getValue();
} catch
(org.apache.avalon.framework.configuration.ConfigurationException ce) {
return "";
}
}
/**
* Return the <code>int</code> value of the node.
*
* @post getValueAsInt() != null
*
* @returns the value of the node.
*
* @exception ConfigurationException If conversion to <code>int</code>
fails.
*/
public int getValueAsInt()
throws ConfigurationException {
try {
return this.configuration.getValueAsInteger();
} catch
(org.apache.avalon.framework.configuration.ConfigurationException ce) {
throw new ConfigurationException(ce.getMessage(), this);
}
}
/**
* Return the <code>float</code> value of the node.
*
* @post getValueAsFloat() != null
*
* @returns the value of the node.
*
* @exception ConfigurationException If conversion to <code>float</code>
fails.
*/
public float getValueAsFloat()
throws ConfigurationException {
try {
return this.configuration.getValueAsFloat();
} catch
(org.apache.avalon.framework.configuration.ConfigurationException ce) {
throw new ConfigurationException(ce.getMessage(), this);
}
}
/**
* Return the <code>boolean</code> value of the node.
*
* @post getValueAsBoolean() != null
*
* @returns the value of the node.
*
* @exception ConfigurationException If conversion to
<code>boolean</code> fails.
*/
public boolean getValueAsBoolean()
throws ConfigurationException {
try {
return this.configuration.getValueAsBoolean();
} catch
(org.apache.avalon.framework.configuration.ConfigurationException ce) {
throw new ConfigurationException(ce.getMessage(), this);
}
}
/**
* Return the <code>long</code> value of the node.<br>
*
* @post getValueAsLong() != null
*
* @returns the value of the node.
*
* @exception ConfigurationException If conversion to <code>long</code>
fails.
*/
public long getValueAsLong()
throws ConfigurationException {
try {
return this.configuration.getValueAsLong();
} catch
(org.apache.avalon.framework.configuration.ConfigurationException ce) {
throw new ConfigurationException(ce.getMessage(), this);
}
}
/**
* Returns the value of the configuration element as a
<code>String</code>.
* If the configuration value is not set, the default value will be
* used.
*
* @pre defaultValue != null
* @post getValue(defaultValue) != null
* @param defaultValue The default value desired.
*
* @returns String value of the <code>Configuration</code>, or default
* if none specified.
*/
public String getValue(String defaultValue) {
return this.configuration.getValue(defaultValue);
}
/**
* Returns the value of the configuration element as an <code>int</code>.
* If the configuration value is not set, the default value will be
* used.
*
* @pre defaultValue != null
* @post getValueAsInt(defaultValue) != null
* @param defaultValue The default value desired.
*
* @returns int value of the <code>Configuration</code>, or default
* if none specified.
*/
public int getValueAsInt(int defaultValue) {
return this.configuration.getValueAsInteger(defaultValue);
}
/**
* Returns the value of the configuration element as a <code>long</code>.
* If the configuration value is not set, the default value will be
* used.
*
* @pre defaultValue != null
* @post getValueAsLong(defaultValue) != null
* @param defaultValue The default value desired.
*
* @returns long value of the <code>Configuration</code>, or default
* if none specified.
*/
public long getValueAsLong(long defaultValue) {
return this.configuration.getValueAsLong(defaultValue);
}
/**
* Returns the value of the configuration element as a <code>float</code>.
* If the configuration value is not set, the default value will be
* used.
*
* @pre defaultValue != null
* @post getValueAsFloat(defaultValue) != null
* @param defaultValue The default value desired.
*
* @returns float value of the <code>Configuration</code>, or default
* if none specified.
*/
public float getValueAsFloat(float defaultValue) {
return this.configuration.getValueAsFloat(defaultValue);
}
/**
* Returns the value of the configuration element as a
<code>boolean</code>.
* If the configuration value is not set, the default value will be
* used.
*
* @pre defaultValue != null
* @post getValueAsBoolean(defaultValue) != null
* @param defaultValue The default value desired.
*
* @returns boolean value of the <code>Configuration</code>, or default
* if none specified.
*/
public boolean getValueAsBoolean(boolean defaultValue) {
return this.configuration.getValueAsBoolean(defaultValue);
}
/**
* Returns the value of the attribute specified by its name as a
* <code>String</code>, or the default value if no attribute by
* that name exists or is empty.
*
* @pre name != null
* @pre defaultValue != null
* @post getAttribute(name, defaultValue) != null
* @param name The name of the attribute you ask the value of.
* @param defaultValue The default value desired.
*
* @returns String value of attribute. It will return the default
* value if the named attribute does not exist, or if
* the value is not set.
*/
public String getAttribute(String name, String defaultValue) {
return this.configuration.getAttribute(name, defaultValue);
}
/**
* Returns the value of the attribute specified by its name as a
* <code>int</code>, or the default value if no attribute by
* that name exists or is empty.
*
* @pre name != null
* @pre defaultValue != null
* @post getAttributeAsInt(name, defaultValue) != null
* @param name The name of the attribute you ask the value of.
* @param defaultValue The default value desired.
*
* @returns int value of attribute. It will return the default
* value if the named attribute does not exist, or if
* the value is not set.
*/
public int getAttributeAsInt(String name, int defaultValue) {
return this.configuration.getAttributeAsInteger(name, defaultValue);
}
/**
* Returns the value of the attribute specified by its name as a
* <code>long</code>, or the default value if no attribute by
* that name exists or is empty.
*
* @pre name != null
* @pre defaultValue != null
* @post getAttributeAsLong(name, defaultValue) != null
* @param name The name of the attribute you ask the value of.
* @param defaultValue The default value desired.
*
* @returns long value of attribute. It will return the default
* value if the named attribute does not exist, or if
* the value is not set.
*/
public long getAttributeAsLong(String name, long defaultValue) {
return this.configuration.getAttributeAsLong(name, defaultValue);
}
/**
* Returns the value of the attribute specified by its name as a
* <code>float</code>, or the default value if no attribute by
* that name exists or is empty.
*
* @pre name != null
* @pre defaultValue != null
* @post getAttributeAsFloat(name, defaultValue) != null
* @param name The name of the attribute you ask the value of.
* @param defaultValue The default value desired.
*
* @returns float value of attribute. It will return the default
* value if the named attribute does not exist, or if
* the value is not set.
*/
public float getAttributeAsFloat(String name, float defaultValue) {
return this.configuration.getAttributeAsFloat(name, defaultValue);
}
/**
* Returns the value of the attribute specified by its name as a
* <code>boolean</code>, or the default value if no attribute by
* that name exists or is empty.
*
* @pre name != null
* @pre defaultValue != null
* @post getAttributeAsBoolean(name, defaultValue) != null
* @param name The name of the attribute you ask the value of.
* @param defaultValue The default value desired.
*
* @returns boolean value of attribute. It will return the default
* value if the named attribute does not exist, or if
* the value is not set.
*/
public boolean getAttributeAsBoolean(String name, boolean defaultValue) {
return this.configuration.getAttributeAsBoolean(name, defaultValue);
}
/**
* Return a <code>String</code> indicating the position of this
* configuration element in a source file or URI.
*
* @returns String if a source file or URI is specified. Otherwise
* it returns <code>null</code>
*/
public String getLocation() {
return this.configuration.getLocation();
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/repository/impl/SlideLoggerAdapter.java
Index: SlideLoggerAdapter.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.repository.impl;
import org.apache.avalon.framework.logger.Logger;
/**
* The class represent an adapter for the logger for jakarta slide
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: SlideLoggerAdapter.java,v 1.1 2003/01/31 18:08:43 stephan
Exp $
*/
public class SlideLoggerAdapter implements
org.apache.slide.util.logger.Logger {
private Logger logger;
private int currentLogLevel = ERROR;
public SlideLoggerAdapter(Logger logger) {
this.logger = logger;
}
/**
* Log an object thru the specified channel and with the specified level.
*
* @param data The object to log.
* @param channel The channel name used for logging.
* @param level The level used for logging.
*/
public void log(Object data, String channel, int level) {
if (level==CRITICAL) {
this.logger.fatalError(data.toString());
} else if (level==ERROR) {
this.logger.error(data.toString());
} else if (level==WARNING) {
this.logger.warn(data.toString());
} else if (level==INFO) {
this.logger.info(data.toString());
} else if (level==DEBUG) {
this.logger.debug(data.toString());
} else {
this.logger.error(data.toString());
}
}
/**
* Log an object with the specified level.
*
* @param data The object to log.
* @param level The level used for logging.
*/
public void log(Object data, int level) {
if (level==CRITICAL) {
this.logger.fatalError(data.toString());
} else if (level==ERROR) {
this.logger.error(data.toString());
} else if (level==WARNING) {
this.logger.warn(data.toString());
} else if (level==INFO) {
this.logger.info(data.toString());
} else if (level==DEBUG) {
this.logger.debug(data.toString());
} else {
this.logger.error(data.toString());
}
}
/**
* Log an object.
*
* @param data The object to log.
*/
public void log(Object data) {
if (currentLogLevel==CRITICAL) {
this.logger.fatalError(data.toString());
} else if (currentLogLevel==ERROR) {
this.logger.error(data.toString());
} else if (currentLogLevel==WARNING) {
this.logger.warn(data.toString());
} else if (currentLogLevel==INFO) {
this.logger.info(data.toString());
} else if (currentLogLevel==DEBUG) {
this.logger.debug(data.toString());
} else {
this.logger.error(data.toString());
}
}
/**
* Set the logger level for the default channel
*
* @param data The object to log.
*/
public void setLoggerLevel(int level) {
currentLogLevel = level;
}
/**
* Set the logger level for the specified channel
*
* @param data The object to log.
*/
public void setLoggerLevel(String channel, int level) {
currentLogLevel = level;
}
/**
* Get the logger level for the default channel
*
* @param data The object to log.
*/
public int getLoggerLevel() {
return currentLogLevel;
}
/**
* Get the logger level for the specified channel
*
* @param data The object to log.
*/
public int getLoggerLevel(String channel) {
if (this.logger.isDebugEnabled()) {
return DEBUG;
} else if (this.logger.isInfoEnabled()) {
return INFO;
} else if (this.logger.isWarnEnabled()) {
return WARNING;
} else if (this.logger.isErrorEnabled()) {
return ERROR;
} else if (this.logger.isFatalErrorEnabled() ) {
return CRITICAL;
} else {
return ERROR;
}
}
/**
* Check if the channel with the specified level is enabled for logging.
*
* @param channel The channel specification
* @param level The level specification
*/
public boolean isEnabled(String channel, int level) {
if (this.logger.isDebugEnabled()) {
return DEBUG<=level;
} else if (this.logger.isInfoEnabled()) {
return INFO<=level;
} else if (this.logger.isWarnEnabled()) {
return WARNING<=level;
} else if (this.logger.isErrorEnabled()) {
return ERROR<=level;
} else if (this.logger.isFatalErrorEnabled() ) {
return CRITICAL<=level;
} else {
return ERROR<=level;
}
}
/**
* Check if the default channel with the specified level is enabled for
logging.
*
* @param level The level specification
*/
public boolean isEnabled(int level) {
if (this.logger.isDebugEnabled()) {
return DEBUG<=level;
} else if (this.logger.isInfoEnabled()) {
return INFO<=level;
} else if (this.logger.isWarnEnabled()) {
return WARNING<=level;
} else if (this.logger.isErrorEnabled()) {
return ERROR<=level;
} else if (this.logger.isFatalErrorEnabled() ) {
return CRITICAL<=level;
} else {
return ERROR<=level;
}
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/repository/impl/SlidePrincipalProvider.java
Index: SlidePrincipalProvider.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.repository.impl;
import java.util.Date;
import java.util.Enumeration;
import java.util.Vector;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.ComponentSelector;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.repository.Principal;
import org.apache.cocoon.components.repository.PrincipalGroup;
import org.apache.cocoon.components.repository.PrincipalProvider;
import org.apache.cocoon.components.repository.Repository;
import org.apache.slide.authenticate.CredentialsToken;
import org.apache.slide.common.NamespaceAccessToken;
import org.apache.slide.common.NamespaceConfig;
import org.apache.slide.common.ServiceAccessException;
import org.apache.slide.common.SlideException;
import org.apache.slide.common.SlideToken;
import org.apache.slide.common.SlideTokenImpl;
import org.apache.slide.content.Content;
import org.apache.slide.content.NodeProperty;
import org.apache.slide.content.NodeRevisionDescriptor;
import org.apache.slide.content.NodeRevisionDescriptors;
import org.apache.slide.content.RevisionDescriptorNotFoundException;
import org.apache.slide.macro.Macro;
import org.apache.slide.macro.MacroException;
import org.apache.slide.macro.MacroParameters;
import org.apache.slide.security.Security;
import org.apache.slide.structure.GroupNode;
import org.apache.slide.structure.LinkNode;
import org.apache.slide.structure.ObjectAlreadyExistsException;
import org.apache.slide.structure.ObjectNode;
import org.apache.slide.structure.Structure;
/**
* Manger for principals and groups of principals
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: SlidePrincipalProvider.java,v 1.1 2003/01/31 18:08:43
stephan Exp $
*/
public class SlidePrincipalProvider extends AbstractLogEnabled
implements PrincipalProvider, Composable, Configurable, Initializable {
/** The component manager instance */
private ComponentManager manager = null;
/** Namespace access token. */
private NamespaceAccessToken nat;
/** Configuration of namespace */
private NamespaceConfig config;
/** Structure helper. */
private Structure structure;
/** Content helper. */
private Content content;
/** Security helper. */
private Security security;
/** Lock helper. */
// private Lock lock;
/** Macro helper. */
private Macro macro;
/** Slide token. */
// private SlideToken slidetoken;
private String repository = null;
private String namespace = null;
/**
* Set the current <code>ComponentManager</code> instance used by this
* <code>Composable</code>.
*
* @param manager
*
* @throws ComponentException
*/
public void compose(ComponentManager manager) throws ComponentException {
this.manager = manager;
}
/**
* Pass the Configuration to the Configurable class. This method must
* always be called after the constructor and before any other method.
*
* @param configuration the class configurations.
*
* @throws ConfigurationException
*/
public void configure(Configuration configuration)
throws ConfigurationException {
this.repository = configuration.getAttribute("repository", null);
this.namespace = configuration.getAttribute("namespace", null);
}
/**
* Initialialize the component. Initialization includes
* allocating any resources required throughout the
* components lifecycle.
*
* @throws Exception if an error occurs
*/
public void initialize() throws Exception {
ComponentSelector repositories = null;
Repository repository = null;
try {
repositories = (ComponentSelector)
this.manager.lookup(Repository.ROLE+
"Selector");
repository = (Repository) repositories.select(this.repository);
if ( !(repository instanceof SlideRepository)) {
getLogger().error("Can't get Slide repository");
return;
}
SlideRepository sliderepository = (SlideRepository) repository;
this.nat = sliderepository.getNamespaceToken(namespace);
if (this.nat==null) {
throw new ProcessingException("Repository with the namespace
'"+
this.namespace+
"' couldn't be found");
}
this.config = this.nat.getNamespaceConfig();
this.structure = nat.getStructureHelper();
this.content = nat.getContentHelper();
this.security = nat.getSecurityHelper();
// this.lock = nat.getLockHelper();
this.macro = nat.getMacroHelper();
} catch (ComponentException ce) {
getLogger().error("Could not lookup for component.", ce);
} finally {
if ((repository!=null) && (repository instanceof Component)) {
repositories.release((Component) repository);
}
repository = null;
if (repositories!=null) {
this.manager.release(repositories);
}
repositories = null;
}
}
/**
* Return all users.
*
* @param caller The principal, which should do the operation
* @return List of all principals
*
* @throws ProcessingException
*/
public Principal[] getPrincipals(Principal caller)
throws ProcessingException {
try {
SlideToken slidetoken = new SlideTokenImpl(new
CredentialsToken(caller));
String userspath = config.getUsersPath();
ObjectNode userobjects = structure.retrieve(slidetoken,
userspath);
Vector principals = new Vector();
String user;
ObjectNode userobject;
for (Enumeration children = userobjects.enumerateChildren();
children.hasMoreElements(); ) {
user = (String) children.nextElement();
userobject = structure.retrieve(slidetoken, user);
if ( !(userobject instanceof GroupNode)) {
String name =
userobject.getUri().substring(userspath.length()+
1);
// FIXME the CVS code from slide does only implement
getRoles
Enumeration roles = this.security.getRoles(userobject);
String role = null;
if (roles.hasMoreElements()) {
role = (String) roles.nextElement();
}
String password = null;
try {
NodeRevisionDescriptors revisionDescriptors =
content.retrieve(slidetoken,
user);
// Retrieve latest revision descriptor
NodeRevisionDescriptor revisionDescriptor =
this.content.retrieve(slidetoken,
revisionDescriptors);
if (revisionDescriptor.getProperty("password",
NodeProperty.SLIDE_NAMESPACE)!=
null) {
password = (String)
revisionDescriptor.getProperty("password",
NodeProperty.SLIDE_NAMESPACE).getValue();
}
} catch (RevisionDescriptorNotFoundException rdnfe) {
// ignore
}
principals.add(new Principal(name, role, password));
}
}
Principal[] principalArray = new Principal[principals.size()];
int i = 0;
for (Enumeration e = principals.elements(); e.hasMoreElements();
i++)
principalArray[i] = (Principal) e.nextElement();
return principalArray;
} catch (SlideException se) {
throw new ProcessingException(se);
}
}
/**
* Add or modify a given principal.
* The implementation is similar to
org.apache.slide.admin.users.AddUserAction.
*
* @param caller The principal, which should do the operation.
* @param principal The Principal, which should be add/modified.
*
* @throws ProcessingException
*/
public void addPrincipal(Principal caller,
Principal principal) throws ProcessingException {
// do the actual transaction
try {
try {
nat.begin();
SlideToken slidetoken = new SlideTokenImpl(new
CredentialsToken(caller));
String strUri = config.getUsersPath()+"/"+principal.getName();
// create the node in the structure
ObjectNode object;
object = new slideroles.basic.UserRoleImpl();
structure.create(slidetoken, object, strUri);
// create a revision with the appropriate properties set
NodeRevisionDescriptor revision = new
NodeRevisionDescriptor(0);
revision.setProperty(new NodeProperty("resourcetype",
"<collection/>", true));
revision.setCreationDate(new Date());
revision.setLastModified(new Date());
revision.setProperty(new NodeProperty("getcontentlength",
"0", true));
revision.setProperty(new NodeProperty("source", "", true));
revision.setProperty(new NodeProperty("password",
principal.getPassword(),
NodeProperty.SLIDE_NAMESPACE));
content.create(slidetoken, strUri, revision, null);
nat.commit();
} catch (ObjectAlreadyExistsException e) {
// duplicate principal
getLogger().warn("Could not create principal", e);
} catch (ServiceAccessException e) {
// low level service access failed
getLogger().warn("Could not create principal", e);
throw new ProcessingException("Could not create principal",
e);
} catch (Exception e) {
// any other errors are unanticipated
getLogger().warn("Could not create principal", e);
throw new ProcessingException("Could not create principal",
e);
}
} catch (Exception e) {
// rollback the transaction
getLogger().warn("Could not create principal", e);
try {
nat.rollback();
} catch (Exception e2) {
// ignore
getLogger().error("Could roll back the operation", e2);
}
}
}
/**
* Remove a given principal.
*
* @param caller The principal, which should do the operation.
* @param principal The Principal, which should be removed.
*
* @throws ProcessingException
*/
public void removePrincipal(Principal caller,
Principal principal)
throws ProcessingException {
if (principal.getName().length()>0) {
// get the helpers
Macro macro = nat.getMacroHelper();
SlideToken slidetoken = new SlideTokenImpl(new
CredentialsToken(caller));
// get the path of the current authenticated user
String selfUri = config.getUsersPath()+"/"+caller.getName();
String strUri = config.getUsersPath()+"/"+principal.getName();
// do the actual transaction
try {
try {
nat.begin();
// the user may not delete herself
if ( !selfUri.equals(strUri)) {
macro.delete(slidetoken, strUri,
new MacroParameters(true, false));
}
nat.commit();
} catch (MacroException e) {
// some aspect of the delete operation failed
getLogger().warn("Could not remove principal", e);
throw new ProcessingException("Could not remove
principal",
e);
}
} catch (Exception e) {
// rollback the transaction
try {
nat.rollback();
} catch (Exception e2) {
// ignore
getLogger().error("Could roll back the operation", e2);
}
}
}
}
/**
* Return all groups.
*
* @param caller The principal, which should do the operation.
* @return List of all groups.
*
* @throws ProcessingException
*/
public PrincipalGroup[] getPrincipalGroups(Principal caller)
throws ProcessingException {
try {
SlideToken slidetoken = new SlideTokenImpl(new
CredentialsToken(caller));
String userspath = config.getUsersPath();
ObjectNode userobjects = structure.retrieve(slidetoken,
userspath);
Vector principalgroups = new Vector();
String group;
ObjectNode groupobject;
for (Enumeration children = userobjects.enumerateChildren();
children.hasMoreElements(); ) {
group = (String) children.nextElement();
groupobject = structure.retrieve(slidetoken, group);
if (groupobject instanceof GroupNode) {
String name =
groupobject.getUri().substring(userspath.length()+
1);
principalgroups.add(new PrincipalGroup(name));
}
}
PrincipalGroup[] principalgroupArray = new
PrincipalGroup[principalgroups.size()];
int i = 0;
for (Enumeration e = principalgroups.elements();
e.hasMoreElements(); i++)
principalgroupArray[i] = (PrincipalGroup) e.nextElement();
return principalgroupArray;
} catch (SlideException se) {
getLogger().error("Could not retrieve principal groups", se);
throw new ProcessingException(se);
}
}
/**
* Add or modify a given group.
*
* @param caller The principal, which should do the operation.
* @param group The group, which shoud be add/modified.
*
* @throws ProcessingException
*/
public void addPrincipalGroup(Principal caller,
PrincipalGroup group)
throws ProcessingException {
// do the actual transaction
try {
try {
nat.begin();
SlideToken slidetoken = new SlideTokenImpl(new
CredentialsToken(caller));
String strUri = config.getUsersPath()+"/"+group.getName();
// create the node in the structure
ObjectNode object = new GroupNode();
structure.create(slidetoken, object, strUri);
// create a revision with the appropriate properties set
NodeRevisionDescriptor revision = new
NodeRevisionDescriptor(0);
revision.setProperty(new NodeProperty("resourcetype",
"<collection/>", true));
revision.setCreationDate(new Date());
revision.setLastModified(new Date());
revision.setProperty(new NodeProperty("getcontentlength",
"0", true));
revision.setProperty(new NodeProperty("source", "", true));
content.create(slidetoken, strUri, revision, null);
nat.commit();
} catch (ObjectAlreadyExistsException e) {
// duplicate group
getLogger().warn("Could not create group", e);
} catch (ServiceAccessException e) {
// low level service access failed
getLogger().warn("Could not create group", e);
throw new ProcessingException("Could not create group", e);
} catch (Exception e) {
// any other errors are unanticipated
getLogger().warn("Could not create group", e);
throw new ProcessingException("Could not create group", e);
}
} catch (Exception e) {
// rollback the transaction
getLogger().warn("Could not create group", e);
try {
nat.rollback();
} catch (Exception e2) {
// ignore
getLogger().error("Could roll back the operation", e2);
}
}
}
/**
* Remove a given group.
*
* @param caller The principal, which should do the operation.
* @param group The group, which shoud be removed.
*
* @throws ProcessingException
*/
public void removePrincipalGroup(Principal caller,
PrincipalGroup group)
throws ProcessingException {
if (group.getName().length()>0) {
// get the helpers
Macro macro = nat.getMacroHelper();
SlideToken slidetoken = new SlideTokenImpl(new
CredentialsToken(caller));
// get the path of the current authenticated user
String selfUri = config.getUsersPath()+"/"+caller.getName();
String strUri = config.getUsersPath()+"/"+group.getName();
// do the actual transaction
try {
try {
nat.begin();
// the user may not delete herself
if ( !selfUri.equals(strUri)) {
macro.delete(slidetoken, strUri,
new MacroParameters(true, false));
}
nat.commit();
} catch (MacroException e) {
// some aspect of the delete operation failed
getLogger().warn("Could not remove group", e);
throw new ProcessingException("Could not remove group",
e);
}
} catch (Exception e) {
// rollback the transaction
try {
nat.rollback();
} catch (Exception e2) {
// ignore
getLogger().error("Could roll back the operation", e2);
}
}
}
}
/**
* Adds the specified member to the group.
*
* @param caller The principal, which should do the operation
* @param group The given group.
* @param principal The principal to add to this group.
*
* @throws ProcessingException
*/
public void addMember(Principal caller, PrincipalGroup group,
Principal principal) throws ProcessingException {
// do the actual transaction
try {
try {
nat.begin();
SlideToken slidetoken = new SlideTokenImpl(new
CredentialsToken(caller));
String strUri = config.getUsersPath()+"/"+group.getName()+"/"+
principal.getName();
// create the node in the structure
LinkNode link = new LinkNode();
structure.createLink(slidetoken, link, strUri,
structure.retrieve(slidetoken,
config.getUsersPath()+
"/"+
principal.getName()));
// create a revision with the appropriate properties set
NodeRevisionDescriptor revision = new
NodeRevisionDescriptor(0);
revision.setProperty(new NodeProperty("resourcetype",
"<collection/>", true));
revision.setCreationDate(new Date());
revision.setLastModified(new Date());
revision.setProperty(new NodeProperty("getcontentlength",
"0", true));
revision.setProperty(new NodeProperty("source", "", true));
content.create(slidetoken, strUri, revision, null);
nat.commit();
} catch (ObjectAlreadyExistsException e) {
// duplicate member
getLogger().warn("Could not create member", e);
} catch (ServiceAccessException e) {
// low level service access failed
getLogger().warn("Could not create member", e);
throw new ProcessingException("Could not create member", e);
} catch (Exception e) {
// any other errors are unanticipated
getLogger().warn("Could not create member", e);
throw new ProcessingException("Could not create member", e);
}
} catch (Exception e) {
// rollback the transaction
getLogger().warn("Could not create member", e);
try {
nat.rollback();
} catch (Exception e2) {
// ignore
getLogger().error("Could roll back the operation", e2);
}
}
}
/**
* Returns true if the passed principal is a member of the group.
*
* @param caller The principal, which should do the operation
* @param group The given group.
* @param member The principal whose membership is to be checked.
* @return True if the principal is a member of this group, false
otherwise.
*
* @throws ProcessingException
*/
public boolean isMember(Principal caller, PrincipalGroup group,
Principal member) throws ProcessingException {
Principal[] members = members(caller, group);
for (int i = 0; i<members.length; i++)
if (members[i].equals(member)) {
return true;
}
return false;
}
/**
* Returns an enumeration of the members in the group. The returned
objects are instances of Principal
*
* @param caller The principal, which should do the operation
* @param group The given group.
* @return An enumeration of the group members.
*
* @throws ProcessingException
*/
public Principal[] members(Principal caller,
PrincipalGroup group)
throws ProcessingException {
try {
SlideToken slidetoken = new SlideTokenImpl(new
CredentialsToken(caller));
String userspath = config.getUsersPath();
ObjectNode groupobject = structure.retrieve(slidetoken,
userspath+"/"+
group.getName());
if (groupobject instanceof GroupNode) {
Vector principals = new Vector();
String user;
ObjectNode userobject;
for (Enumeration children = groupobject.enumerateChildren();
children.hasMoreElements(); ) {
user = (String) children.nextElement();
userobject = structure.retrieve(slidetoken, user);
if ( !(userobject instanceof GroupNode)) {
String name =
userobject.getUri().substring(userspath.length()+
1);
// FIXME the CVS code from slide does only implement
getRoles
Enumeration roles =
this.security.getRoles(userobject);
String role = null;
if (roles.hasMoreElements()) {
role = (String) roles.nextElement();
}
NodeRevisionDescriptors revisionDescriptors =
content.retrieve(slidetoken,
userobject.getUri());
// Retrieve latest revision descriptor
NodeRevisionDescriptor revisionDescriptor =
this.content.retrieve(slidetoken,
revisionDescriptors);
String password = null;
if ((revisionDescriptor.getProperty("password",
NodeProperty.SLIDE_NAMESPACE)!=null) &&
(revisionDescriptor.getProperty("password",
NodeProperty.SLIDE_NAMESPACE).getValue()!=
null)) {
password =
revisionDescriptor.getProperty("password",
NodeProperty.SLIDE_NAMESPACE).getValue().toString();
}
principals.add(new Principal(name /* , role */,
password));
}
}
Principal[] principalArray = new Principal[principals.size()];
int i = 0;
for (Enumeration e = principals.elements();
e.hasMoreElements(); i++)
principalArray[i] = (Principal) e.nextElement();
return principalArray;
} else {
return new Principal[0];
}
} catch (SlideException se) {
throw new ProcessingException(se);
}
}
/**
* Removes the specified member from the group.
*
* @param caller The principal, which should do the operation
* @param group The given group.
* @param principal The principal to remove from this group.
*
* @throws ProcessingException
*/
public void removeMember(Principal caller, PrincipalGroup group,
Principal principal) throws ProcessingException {
if ((group.getName().length()>0) &&
(principal.getName().length()>0)) {
// get the helpers
Macro macro = nat.getMacroHelper();
SlideToken slidetoken = new SlideTokenImpl(new
CredentialsToken(caller));
String strUri = config.getUsersPath()+"/"+group.getName()+"/"+
principal.getName();
// do the actual transaction
try {
try {
nat.begin();
macro.delete(slidetoken, strUri,
new MacroParameters(true, false));
nat.commit();
} catch (MacroException e) {
// some aspect of the delete operation failed
getLogger().warn("Could not remove member", e);
throw new ProcessingException("Could not remove member",
e);
}
} catch (Exception e) {
// rollback the transaction
try {
nat.rollback();
} catch (Exception e2) {
// ignore
getLogger().error("Could roll back the operation", e2);
}
}
}
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/repository/impl/SlideRepository.java
Index: SlideRepository.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.repository.impl;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.components.repository.Repository;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceResolver;
import org.apache.excalibur.xml.sax.SAXParser;
import org.apache.slide.common.Domain;
import org.apache.slide.common.EmbeddedDomain;
import org.apache.slide.common.NamespaceAccessToken;
import org.xml.sax.InputSource;
/**
* The class represent a manger for slide repositories
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: SlideRepository.java,v 1.1 2003/01/31 18:08:43 stephan Exp $
*/
public class SlideRepository
implements Repository, ThreadSafe, Composable, Configurable,
LogEnabled /* , Initializable */, Disposable {
/** The component manager instance */
protected ComponentManager manager = null;
/**
* The SlideRepository will handle the domain lifecycle only,
* if it is not already initialzed.
*/
private EmbeddedDomain domain = null;
private Logger logger;
private String file;
private boolean initialized = false;
/**
* Provide component with a logger.
*
* @param logger the logger
*/
public void enableLogging(Logger logger) {
this.logger = logger;
}
/**
* Set the current <code>ComponentManager</code> instance used by this
* <code>Composable</code>.
*
* @param manager Component manager.
*/
public void compose(ComponentManager manager) throws ComponentException {
this.manager = manager;
}
/**
* Pass the Configuration to the Configurable class. This method must
* always be called after the constructor and before any other method.
*
* @param configuration the class configurations.
*/
public void configure(Configuration configuration)
throws ConfigurationException {
this.file = configuration.getAttribute("file", "WEB-INF/slide.xconf");
}
/**
* Initialialize the component. Initialization includes
* allocating any resources required throughout the
* components lifecycle.
*/
public void initialize() throws Exception {
SourceResolver resolver = null;
SAXParser parser = null;
Source source = null;
Configuration configuration = null;
if (Domain.isInitialized()) {
this.logger.info("Domain already initialized.");
return;
}
this.logger.info("Initializing domain.");
this.domain = new EmbeddedDomain();
// FIXME Could not remove deprecated method, because some important
// messages were thrown over the domain logger
domain.setLogger(new SlideLoggerAdapter(this.logger));
try {
resolver = (SourceResolver)
this.manager.lookup(SourceResolver.ROLE);
parser = (SAXParser) this.manager.lookup(SAXParser.ROLE);
SAXConfigurationHandler confighandler = new
SAXConfigurationHandler();
source = resolver.resolveURI(this.file);
parser.parse(new InputSource(source.getInputStream()),
confighandler);
configuration = confighandler.getConfiguration();
} catch (Exception e) {
this.logger.error("Could not load slide configuration file", e);
return;
} finally {
if (source!=null) {
resolver.release(source);
}
if (parser!=null) {
this.manager.release((Component) parser);
}
if (resolver!=null) {
this.manager.release(resolver);
}
}
try {
domain.setDefaultNamespace(configuration.getAttribute("default",
"slide"));
this.logger.info("Initializing Domain");
Configuration[] namespaceDefinitions =
configuration.getChildren("namespace");
for (int i = 0; i<namespaceDefinitions.length; i++) {
// Initializes a new namespace based on the given
configuration data.
this.logger.info("Initializing namespace : "+
namespaceDefinitions[i].getAttribute("name"));
String name = namespaceDefinitions[i].getAttribute("name");
Configuration namespaceDefinition =
namespaceDefinitions[i].getChild("definition");
Configuration namespaceConfigurationDefinition =
namespaceDefinitions[i].getChild("configuration");
Configuration namespaceBaseDataDefinition =
namespaceDefinitions[i].getChild("data");
domain.addNamespace(name,
new
SlideLoggerAdapter(this.logger.getChildLogger(name)),
new
SlideConfigurationAdapter(namespaceDefinition),
new
SlideConfigurationAdapter(namespaceConfigurationDefinition),
new
SlideConfigurationAdapter(namespaceBaseDataDefinition));
this.logger.info("Namespace configuration complete");
}
} catch (ConfigurationException ce) {
this.logger.error("Could not configure Slide domain", ce);
return;
}
initialized = true;
if (initialized) {
try {
domain.start();
} catch (Exception e) {
this.logger.error("Could not start domain", e);
}
}
}
/**
* The dispose operation is called at the end of a components lifecycle.
* This method will be called after Startable.stop() method (if
implemented
* by component). Components use this method to release and destroy any
* resources that the Component owns.
*/
public void dispose() {
if (initialized) {
try {
domain.stop();
} catch (Exception e) {
this.logger.error("Could not stop domain", e);
}
}
}
/**
* Returns a token for the access of the default namespace.
*
* @return NamespaceAccessToken Access token to the namespace
*/
public NamespaceAccessToken getDefaultNamespaceToken() {
// Initialization on demand
if ((domain==null) && ( !initialized)) {
try {
initialize();
} catch (Exception e) {
this.logger.error("Could not initialize Slide repository", e);
}
}
if (domain!=null) {
return
this.domain.getNamespaceToken(this.domain.getDefaultNamespace());
}
return Domain.accessNamespace(null, Domain.getDefaultNamespace());
}
/**
* Returns a token for the access of a namespace.
*
* @param namespaceName Name of the namespace on which access is requested
* @return NamespaceAccessToken Access token to the namespace
*/
public NamespaceAccessToken getNamespaceToken(String namespaceName) {
// Initialization on demand
if ((domain==null) && ( !initialized)) {
try {
initialize();
} catch (Exception e) {
this.logger.error("Could not initialize Slide repository", e);
}
}
if (namespaceName==null) {
return getDefaultNamespaceToken();
}
if (domain!=null) {
return this.domain.getNamespaceToken(namespaceName);
}
return Domain.accessNamespace(null, namespaceName);
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/InspectableSource.java
Index: InspectableSource.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source;
import org.apache.cocoon.components.source.helpers.SourceProperty;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
/**
* A source, which owns meta informations in form of properties
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: InspectableSource.java,v 1.1 2003/01/31 18:08:43 stephan Exp
$
*/
public interface InspectableSource extends Source {
/**
* To get a meta information from a source
*/
public SourceProperty getSourceProperty(String namespace, String name)
throws SourceException;
/**
* To set a meta information
*/
public void setSourceProperty(SourceProperty property) throws
SourceException;
/**
* Get alll informations
*/
public SourceProperty[] getSourceProperties() throws SourceException;
/**
* Remove property
*/
public void removeSourceProperty(String namespace, String name) throws
SourceException;
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/LockableSource.java
Index: LockableSource.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.cocoon.components.source.helpers.SourceLock;
import java.util.Enumeration;
/**
* A source, which could be locked
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: LockableSource.java,v 1.1 2003/01/31 18:08:43 stephan Exp $
*/
public interface LockableSource extends Source {
/**
* Add a lock to this source
*
* @param sourcelock Lock, which should be added
*
* @throws SourceException If an exception occurs during this operation
*/
public void addSourceLocks(SourceLock sourcelock) throws SourceException;
/**
* Returns a enumeration of the existing locks
*
* @return Enumeration of SourceLock
*/
public Enumeration getSourceLocks() throws SourceException;
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/ModifiableTraversableSource.java
Index: ModifiableTraversableSource.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source;
import org.apache.excalibur.source.SourceException;
/**
* A source, which can be a directory or collection of sources, which can
* can be modfied.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: ModifiableTraversableSource.java,v 1.1 2003/01/31 18:08:43
stephan Exp $
*/
public interface ModifiableTraversableSource extends TraversableSource,
WriteableSource {
/**
* Create a collection of sources.
*
* @param collectionname Name of the collectiom, which
* should be created.
*/
void createCollection(String collectionname) throws SourceException;
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/RestrictableSource.java
Index: RestrictableSource.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source;
import org.apache.cocoon.components.source.helpers.SourceCredential;
import org.apache.cocoon.components.source.helpers.SourcePermission;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
/**
* A source, which is restrictable, which means you need a username and
password.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: RestrictableSource.java,v 1.1 2003/01/31 18:08:43 stephan
Exp $
*/
public interface RestrictableSource extends Source {
/**
* Get the current credential for the source
*/
public SourceCredential getSourceCredential() throws SourceException;
/**
* Set the credential for the source
*/
public void setSourceCredential(SourceCredential sourcecredential) throws
SourceException;
/**
* Add a permission to this source
*
* @param sourcepermission Permission, which should be set
*
* @throws SourceException If an exception occurs during this operation
**/
public void addSourcePermission(SourcePermission sourcepermission) throws
SourceException;
/**
* Remove a permission from this source
*
* @param sourcepermission Permission, which should be removed
*
* @throws SourceException If an exception occurs during this operation
**/
public void removeSourcePermission(SourcePermission sourcepermission)
throws SourceException;
/**
* Returns a list of the existing permissions
*
* @return Array of SourcePermission
*/
public SourcePermission[] getSourcePermissions() throws SourceException;
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/SourceInspector.java
Index: SourceInspector.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source;
import org.apache.avalon.framework.component.Component;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.cocoon.components.source.helpers.SourceProperty;
/**
* A source inspector helps to get properties from sources
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: SourceInspector.java,v 1.1 2003/01/31 18:08:43 stephan Exp $
*/
public interface SourceInspector extends Component {
public final static String ROLE =
"org.apache.cocoon.components.source.SourceInspector";
public SourceProperty getSourceProperty(Source source, String namespace,
String name)
throws SourceException;
public SourceProperty[] getSourceProperties(Source source) throws
SourceException;
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/TraversableSource.java
Index: TraversableSource.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
/**
* A source, which can be a directory or collection of sources.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: TraversableSource.java,v 1.1 2003/01/31 18:08:43 stephan Exp
$
*/
public interface TraversableSource extends Source {
/**
* If the source a directory or a collection
*/
public boolean isSourceCollection() throws SourceException;
/**
* Returns the count of child sources.
*/
public int getChildSourceCount() throws SourceException;
/**
* Return the system id of a child source.
*
* @param index Index of the child
*/
public String getChildSource(int index) throws SourceException;
/**
* Return the system if of the parent source. The method should return
* null if the source hasn't a parent.
*/
public String getParentSource();
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/VersionableSource.java
Index: VersionableSource.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
/**
* A source, which could exist in different versions
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: VersionableSource.java,v 1.1 2003/01/31 18:08:43 stephan Exp
$
*/
public interface VersionableSource extends Source {
/**
* If this source versioned
*/
public boolean isVersioned() throws SourceException;
/**
* Get the current revision of the source
*/
public String getSourceRevision() throws SourceException;
/**
* Sets the wanted revision of the source
*/
public void setSourceRevision(String sourcerevision) throws
SourceException;
/**
* Get the current branch of the revision from the source
*/
public String getSourceRevisionBranch() throws SourceException;
/**
* Sets the wanted branch of the revision from the source
*/
public void setSourceRevisionBranch(String sourcerevisionbranch) throws
SourceException;
/**
* Get the latest revision
*/
public String getLatestSourceRevision() throws SourceException;
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/helpers/AbstractSourcePermission.java
Index: AbstractSourcePermission.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source.helpers;
/**
* This class is an abstract implementation of a source permission
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: AbstractSourcePermission.java,v 1.1 2003/01/31 18:08:43
stephan Exp $
*/
public abstract class AbstractSourcePermission implements SourcePermission{
private String privilege;
private boolean inheritable;
private boolean negative;
/**
* Sets the privilege of the permission
*
* @param privilege Privilege of the permission
*/
public void setPrivilege(String privilege) {
this.privilege = privilege;
}
/**
* Returns the privilege of the permission
*
* @return Privilege of the permission
*/
public String getPrivilege() {
return this.privilege;
}
/**
* Sets the inheritable flag
*
* @param inheritable If the permission is inheritable
*/
public void setInheritable(boolean inheritable) {
this.inheritable = inheritable;
}
/**
* Returns the inheritable flag
*
* @return If the permission is inheritable
*/
public boolean isInheritable() {
return this.inheritable;
}
/**
* Sets the negative flag
*
* @param negative If the permission is a negative permission
*/
public void setNegative(boolean negative) {
this.negative = negative;
}
/**
* Returns the negative flag
*
* @return If the permission is a negative permission
*/
public boolean isNegative() {
return this.negative;
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/helpers/GroupSourcePermission.java
Index: GroupSourcePermission.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source.helpers;
/**
* This class represents a source permission for groups
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: GroupSourcePermission.java,v 1.1 2003/01/31 18:08:43 stephan
Exp $
*/
public class GroupSourcePermission extends AbstractSourcePermission {
private String group;
/**
* Creates a new permission
*
* @param principal Principal of the permission
* @param privilege Privilege of the permission
* @param inheritable If the permission is inheritable
* @param negative If the permission is negative
*/
public GroupSourcePermission(String group, String privilege,
boolean inheritable, boolean negative) {
this.group = group;
setPrivilege(privilege);
setInheritable(inheritable);
setNegative(negative);
}
/**
* Sets the group of users for the permission
*
* @param group Group of users
*/
public void setGroup(String group) {
this.group = group;
}
/**
* Returns the group of users for the permission
*
* @return Group of users
*/
public String getGroup() {
return this.group;
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/helpers/PrincipalSourcePermission.java
Index: PrincipalSourcePermission.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source.helpers;
/**
* This class represents a source permission for users
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: PrincipalSourcePermission.java,v 1.1 2003/01/31 18:08:43
stephan Exp $
*/
public class PrincipalSourcePermission extends AbstractSourcePermission {
public final static String PRINCIPAL_SELF = "SELF";
public final static String PRINCIPAL_ALL = "ALL";
public final static String PRINCIPAL_GUEST = "GUEST";
private String principal;
/**
* Creates a new permission
*
* @param principal Principal of the permission
* @param privilege Privilege of the permission
* @param inheritable If the permission is inheritable
* @param negative If the permission is negative
*/
public PrincipalSourcePermission(String principal, String privilege,
boolean inheritable, boolean negative) {
this.principal = principal;
setPrivilege(privilege);
setInheritable(inheritable);
setNegative(negative);
}
/**
* Sets the principal of the permission
*
* @param principal Principal of the permission
*/
public void setPrincipal(String principal) {
this.principal = principal;
}
/**
* Returns the principal of the permission
*
* @return Principal of the permission
*/
public String getPrincipal() {
return this.principal;
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/helpers/SourceLock.java
Index: SourceLock.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source.helpers;
import java.util.Date;
/**
* This interface for lock of a source
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: SourceLock.java,v 1.1 2003/01/31 18:08:43 stephan Exp $
*/
public class SourceLock {
private String subject;
private String type;
private Date expiration;
private boolean inheritable;
private boolean exclusive;
/**
* Creates a new lock for a source
*
* @param subject Which user should be locked
* @param type Type of lock
* @param expiration When the lock expires
* @param inheritable If the lock is inheritable
* @param exclusive If the lock is exclusive
*/
public SourceLock(String subject, String type, Date expiration,
boolean inheritable, boolean exclusive) {
this.subject = subject;
this.type = type;
this.expiration = expiration;
this.inheritable = inheritable;
this.exclusive = exclusive;
}
/**
* Sets the subject for this lock
*
* @param subject Which user should be locked
*/
public void setSubject(String subject) {
this.subject = subject;
}
/**
* return the subject of the lock
*
* @return Which user should be locked
*/
public String getSubject() {
return this.subject;
}
/**
* Sets the type of the lock
*
* @param type Type of lock
*/
public void setType(String type) {
this.type = type;
}
/**
* Return ths type of the lock
*
* @return Type of lock
*/
public String getType() {
return this.type;
}
/**
* Set the expiration date
*
* @param expiration Expiration date
*/
public void setExpiration(Date expiration) {
this.expiration = expiration;
}
/**
* Returns the expiration date
*
* @return Expiration date
*/
public Date getExpiration() {
return this.expiration;
}
/**
* Sets the inheritable flag
*
* @param inheritable If the lock is inheritable
*/
public void setInheritable(boolean inheritable) {
this.inheritable = inheritable;
}
/**
* Returns the inheritable flag
*
* @return If the lock is inheritable
*/
public boolean isInheritable() {
return this.inheritable;
}
/**
* Sets the exclusive flag
*
* @param exclusive If the lock is exclusive
*/
public void setExclusive(boolean exclusive) {
this.exclusive = exclusive;
}
/**
* Returns the exclusive flag
*
* @return If the lock is exclusive
*/
public boolean isExclusive() {
return this.exclusive;
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/helpers/SourcePermission.java
Index: SourcePermission.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source.helpers;
/**
* This interface represents a permission for a source
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: SourcePermission.java,v 1.1 2003/01/31 18:08:43 stephan Exp $
*/
public interface SourcePermission {
public final static String PRIVILEGE_ALL = "all";
public final static String PRIVILEGE_READ = "read";
public final static String PRIVILEGE_WRITE = "write";
public final static String PRIVILEGE_READ_ACL = "read-acl";
public final static String PRIVILEGE_WRITE_ACL = "write-acl";
public final static String PRIVILEGE_READ_SOURCE = "read-source";
public final static String PRIVILEGE_CREATE_SOURCE = "create-source";
public final static String PRIVILEGE_REMOVE_SOURCE = "remove-source";
public final static String PRIVILEGE_LOCK_SOURCE = "lock-source";
public final static String PRIVILEGE_READ_LOCKS = "read-locks";
public final static String PRIVILEGE_READ_PROPERTY = "read-property";
public final static String PRIVILEGE_CREATE_PROPERTY =
"create-property";
public final static String PRIVILEGE_MODIFY_PROPERTY =
"modify-property";
public final static String PRIVILEGE_REMOVE_PROPERTY =
"remove-property";
public final static String PRIVILEGE_READ_CONTENT = "read-content";
public final static String PRIVILEGE_CREATE_CONTENT = "create-content";
public final static String PRIVILEGE_MODIFY_CONTENT = "modify-content";
public final static String PRIVILEGE_REMOVE_CONTENT = "remove-content";
public final static String PRIVILEGE_GRANT_PERMISSION =
"grant-permission";
public final static String PRIVILEGE_REVOKE_PERMISSION =
"revoke-permission";
/**
* Sets the privilege of the permission
*
* @param privilege Privilege of the permission
*/
public void setPrivilege(String privilege);
/**
* Returns the privilege of the permission
*
* @return Privilege of the permission
*/
public String getPrivilege();
/**
* Sets the inheritable flag
*
* @param inheritable If the permission is inheritable
*/
public void setInheritable(boolean inheritable);
/**
* Returns the inheritable flag
*
* @return If the permission is inheritable
*/
public boolean isInheritable();
/**
* Sets the negative flag
*
* @param negative If the permission is a negative permission
*/
public void setNegative(boolean negative);
/**
* Returns the negative flag
*
* @return If the permission is a negative permission
*/
public boolean isNegative();
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/helpers/SourceProperty.java
Index: SourceProperty.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source.helpers;
import org.apache.cocoon.xml.dom.DOMBuilder;
import org.apache.cocoon.xml.dom.DOMStreamer;
import org.apache.excalibur.xml.sax.XMLizable;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
/**
* This interface for a property of a source
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: SourceProperty.java,v 1.1 2003/01/31 18:08:43 stephan Exp $
*/
public class SourceProperty implements XMLizable {
private String namespace;
private String name;
private Element value;
/**
* Creates a new property for a source
*
* @param namespace The namespace of the property
* @param name The name of the property
*/
public SourceProperty(String namespace, String name) {
this.namespace = namespace;
this.name = name;
}
/**
* Creates a new property for a source
*
* @param namespace The namespace of the property
* @param name The name of the property
* @param value The value of the property
*/
public SourceProperty(String namespace, String name, String value) {
this.namespace = namespace;
this.name = name;
setValue(value);
}
/**
* Creates a new property for a source
*
* @param property The property in DOM representation
*/
public SourceProperty(Element property) {
this.namespace = property.getNamespaceURI();
this.name = property.getLocalName();
this.value = property;
}
/**
* Sets the namespace for this property
*
* @param namespace The namespace of the property
*/
public void setNamespace(String namespace) {
this.namespace = namespace;
}
/**
* Return the namespace of the property
*
* @return The namespace of the property
*/
public String getNamespace() {
return this.namespace;
}
/**
* Sets the name of the property
*
* @param name Name of the property
*/
public void setName(String name) {
this.name = name;
}
/**
* Return the name of the property
*
* @return Name of the property
*/
public String getName() {
return this.name;
}
/**
* Sets the value of the property
*
* @param value Value of the property
*/
public void setValue(String value) {
//this.value = value;
try {
DOMBuilder builder = new DOMBuilder();
builder.startDocument();
builder.startElement(namespace, name, name, new AttributesImpl());
builder.characters(value.toCharArray(), 0, value.length());
builder.endElement(namespace, name, name);
builder.endDocument();
Document doc = builder.getDocument();
this.value = doc.getDocumentElement();
} catch (SAXException se) {
// do nothing
}
}
/**
* Returns the value of the property
*
* @return Value of the property
*/
public String getValueAsString() {
NodeList nodeslist = this.value.getChildNodes();
StringBuffer buffer = new StringBuffer();
for(int i=0; i<nodeslist.getLength(); i++)
if ((nodeslist.item(i).getNodeType()==Node.TEXT_NODE) ||
(nodeslist.item(i).getNodeType()==Node.CDATA_SECTION_NODE))
buffer.append(nodeslist.item(i).getNodeValue());
return buffer.toString();
}
/**
* Sets the value of the property
*
* @param value Value of the property
*/
public void setValue(Element value) {
if ((value.getLocalName().equals(name)) &&
(value.getNamespaceURI().equals(namespace)))
this.value = value;
}
/**
* Sets the value of the property
*
* @param value Value of the property
*/
public void setValue(NodeList values) {
try {
DOMBuilder builder = new DOMBuilder();
builder.startDocument();
builder.startElement(namespace, name, name, new AttributesImpl());
DOMStreamer stream = new DOMStreamer(builder);
for (int i = 0; i < values.getLength(); i++)
stream.stream(values.item(i));
builder.endElement(namespace, name, name);
builder.endDocument();
Document doc = builder.getDocument();
this.value = doc.getDocumentElement();
} catch (SAXException se) {
// do nothing
}
}
public Element getValue() {
return this.value;
}
/**
* Generates SAX events representing the object's state.<br/>
* <b>NOTE</b> : if the implementation can produce lexical events, care
should be taken
* that <code>handler</code> can actually be a [EMAIL PROTECTED]
org.apache.cocoon.xml.XMLConsumer} that accepts such
* events.
*/
public void toSAX(ContentHandler handler) throws SAXException {
DOMStreamer stream = new DOMStreamer(handler);
stream.stream(this.value);
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/impl/GIFSourceInspector.java
Index: GIFSourceInspector.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source.impl;
import java.io.BufferedInputStream;
import java.io.IOException;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.components.source.SourceInspector;
import org.apache.cocoon.components.source.helpers.SourceProperty;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
/**
* This source inspector adds extra attributes for image files.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Donald A. Ball Jr.</a>
* @version $Id: GIFSourceInspector.java,v 1.1 2003/01/31 18:08:44 stephan
Exp $
*/
public class GIFSourceInspector extends AbstractLogEnabled implements
SourceInspector, ThreadSafe {
private String PROPERTY_NS =
"http://xml.apache.org/cocoon/GIFSourceInspector";
private static String IMAGE_WIDTH_PROPERTY_NAME = "width";
private static String IMAGE_HEIGHT_PROPERTY_NAME = "height";
public SourceProperty getSourceProperty(Source source, String namespace,
String name)
throws SourceException {
if ((namespace.equals(PROPERTY_NS)) &&
((name.equals(IMAGE_WIDTH_PROPERTY_NAME)) ||
(name.equals(IMAGE_HEIGHT_PROPERTY_NAME))) &&
(source.getURI().endsWith(".gif")) && (isGIFFile(source))) {
if (name.equals(IMAGE_WIDTH_PROPERTY_NAME))
return new SourceProperty(PROPERTY_NS,
IMAGE_WIDTH_PROPERTY_NAME,
String.valueOf(getGifSize(source)[0]));
if (name.equals(IMAGE_HEIGHT_PROPERTY_NAME))
return new SourceProperty(PROPERTY_NS,
IMAGE_HEIGHT_PROPERTY_NAME,
String.valueOf(getGifSize(source)[1]));
}
return null;
}
public SourceProperty[] getSourceProperties(Source source) throws
SourceException {
if ((source.getURI().endsWith(".gif")) &&
(isGIFFile(source))) {
int[] size = getGifSize(source);
return new SourceProperty[] {
new SourceProperty(PROPERTY_NS, IMAGE_WIDTH_PROPERTY_NAME,
String.valueOf(size[0])),
new SourceProperty(PROPERTY_NS, IMAGE_HEIGHT_PROPERTY_NAME,
String.valueOf(size[1]))
};
}
return null;
}
private boolean isGIFFile(Source source) throws SourceException {
BufferedInputStream in = null;
try {
in = new BufferedInputStream(source.getInputStream());
byte[] buf = new byte[3];
int count = in.read(buf, 0, 3);
if(count < 3) return false;
if ((buf[0] == (byte)'G') &&
(buf[1] == (byte)'I') &&
(buf[2] == (byte)'F'))
return true;
} catch (IOException ioe) {
throw new SourceException("Could not read source", ioe);
} finally {
if (in != null)
try {
in.close();
} catch(Exception e) {}
}
return false;
}
/**
* Returns width as first element, height as second
*/
private int[] getGifSize(Source source) throws SourceException {
BufferedInputStream in = null;
try {
in = new BufferedInputStream(source.getInputStream());
byte[] buf = new byte[10];
int count = in.read(buf, 0, 10);
if(count < 10) throw new SourceException("Not a valid GIF file!");
if((buf[0]) != (byte)'G'
|| (buf[1]) != (byte)'I'
|| (buf[2]) != (byte)'F' )
throw new SourceException("Not a valid GIF file!");
int w1 = ((int)buf[6] & 0xff) | (buf[6] & 0x80);
int w2 = ((int)buf[7] & 0xff) | (buf[7] & 0x80);
int h1 = ((int)buf[8] & 0xff) | (buf[8] & 0x80);
int h2 = ((int)buf[9] & 0xff) | (buf[9] & 0x80);
int width = w1 + (w2 << 8);
int height = h1 + (h2 << 8);
int[] dim = { width, height };
return dim;
} catch (IOException ioe) {
throw new SourceException("Could not read source", ioe);
} finally {
if (in != null)
try {
in.close();
} catch (Exception e) {}
}
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/impl/JPEGSourceInspector.java
Index: JPEGSourceInspector.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source.impl;
import java.io.BufferedInputStream;
import java.io.IOException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.components.source.SourceInspector;
import org.apache.cocoon.components.source.helpers.SourceProperty;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
/**
* This source inspector adds extra attributes for image files.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Donald A. Ball Jr.</a>
* @version $Id: JPEGSourceInspector.java,v 1.1 2003/01/31 18:08:44 stephan
Exp $
*/
public class JPEGSourceInspector extends AbstractLogEnabled implements
SourceInspector, ThreadSafe {
private String PROPERTY_NS =
"http://xml.apache.org/cocoon/JPEGSourceInspector";
private static String IMAGE_WIDTH_PROPERTY_NAME = "width";
private static String IMAGE_HEIGHT_PROPERTY_NAME = "height";
private String propertyname = "result";
private String extension = null;
private String xpath = null;
private ComponentManager manager = null;
public SourceProperty getSourceProperty(Source source, String namespace,
String name)
throws SourceException {
if ((namespace.equals(PROPERTY_NS)) &&
((name.equals(IMAGE_WIDTH_PROPERTY_NAME)) ||
(name.equals(IMAGE_HEIGHT_PROPERTY_NAME))) &&
(source.getURI().endsWith(".jpg")) && (isJPEGFile(source))) {
if (name.equals(IMAGE_WIDTH_PROPERTY_NAME))
return new SourceProperty(PROPERTY_NS,
IMAGE_WIDTH_PROPERTY_NAME,
String.valueOf(getJpegSize(source)[0]));
if (name.equals(IMAGE_HEIGHT_PROPERTY_NAME))
return new SourceProperty(PROPERTY_NS,
IMAGE_HEIGHT_PROPERTY_NAME,
String.valueOf(getJpegSize(source)[1]));
}
return null;
}
public SourceProperty[] getSourceProperties(Source source) throws
SourceException {
if ((source.getURI().endsWith(".jpg")) &&
(isJPEGFile(source))) {
int[] size = getJpegSize(source);
return new SourceProperty[] {
new SourceProperty(PROPERTY_NS, IMAGE_WIDTH_PROPERTY_NAME,
String.valueOf(size[0])),
new SourceProperty(PROPERTY_NS, IMAGE_HEIGHT_PROPERTY_NAME,
String.valueOf(size[1]))
};
}
return null;
}
private boolean isJPEGFile(Source source) throws SourceException {
BufferedInputStream in = null;
try {
in = new BufferedInputStream(source.getInputStream());
byte[] buf = new byte[2];
int count = in.read(buf, 0, 2);
if (count < 2)
return false;
if ((buf[0] == (byte)0xFF) &&
(buf[1] == (byte)0xD8))
return true;
} catch (IOException ioe) {
throw new SourceException("Could not read source", ioe);
} finally {
if (in != null)
try {
in.close();
} catch(Exception e) {}
}
return false;
}
/**
* returns width as first element, height as second
*/
private int[] getJpegSize(Source source) throws SourceException {
BufferedInputStream in = null;
try {
in = new BufferedInputStream(source.getInputStream());
// check for "magic" header
byte[] buf = new byte[2];
int count = in.read(buf, 0, 2);
if (count < 2) throw new SourceException("Not a valid Jpeg
file!");
if((buf[0]) != (byte)0xFF
|| (buf[1]) != (byte)0xD8 )
throw new SourceException("Not a valid Jpeg file!");
int width = 0;
int height = 0;
boolean done = false;
int ch = 0;
try {
while(ch != 0xDA && !done) {
/* Find next marker (JPEG markers begin with 0xFF) */
while (ch != 0xFF) { ch = in.read(); }
/* JPEG markers can be padded with unlimited 0xFF's */
while (ch == 0xFF) { ch = in.read(); }
/* Now, ch contains the value of the marker. */
if(ch >= 0xC0 && ch <= 0xC3) {
// skip 3 bytes
in.read();
in.read();
in.read();
height = 256 * in.read();
height += in.read();
width = 256 * in.read();
width += in.read();
done = true;
} else {
/* We MUST skip variables, since FF's within variable
names
are NOT valid JPEG markers */
int length = 256 * in.read();
length += in.read();
if(length < 2) throw new RuntimeException("Erroneous
JPEG marker length");
for(int foo = 0; foo<length-2; foo++)
in.read();
}
}
} catch (Exception e) {
throw new SourceException("Not a valid Jpeg file!", e);
}
int[] dim = { width, height };
return dim;
} catch (IOException ioe) {
throw new SourceException("Could not read source", ioe);
} finally {
if (in != null)
try {
in.close();
} catch (Exception e) {}
}
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/impl/SlideSource.java
Index: SlideSource.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source.impl;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.Vector;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
import org.apache.cocoon.CascadingIOException;
import org.apache.cocoon.Constants;
import org.apache.cocoon.components.source.*;
import org.apache.cocoon.components.source.helpers.GroupSourcePermission;
import org.apache.cocoon.components.source.helpers.PrincipalSourcePermission;
import org.apache.cocoon.components.source.helpers.SourceCredential;
import org.apache.cocoon.components.source.helpers.SourceLock;
import org.apache.cocoon.components.source.helpers.SourcePermission;
import org.apache.cocoon.components.source.helpers.SourceProperty;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.validity.TimeStampValidity;
import org.apache.slide.authenticate.CredentialsToken;
import org.apache.slide.common.NamespaceAccessToken;
import org.apache.slide.common.NamespaceConfig;
import org.apache.slide.common.SlideException;
import org.apache.slide.common.SlideToken;
import org.apache.slide.common.SlideTokenImpl;
import org.apache.slide.content.*;
import org.apache.slide.lock.Lock;
import org.apache.slide.lock.NodeLock;
import org.apache.slide.macro.Macro;
import org.apache.slide.security.NodePermission;
import org.apache.slide.security.Security;
import org.apache.slide.structure.GroupNode;
import org.apache.slide.structure.ObjectNode;
import org.apache.slide.structure.ObjectNotFoundException;
import org.apache.slide.structure.Structure;
import org.apache.slide.structure.SubjectNode;
/**
* A sources from jakarta slide repositories.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: SlideSource.java,v 1.1 2003/01/31 18:08:44 stephan Exp $
*/
public class SlideSource extends AbstractLogEnabled
implements Contextualizable, Source, WriteableSource,
ModifiableTraversableSource, MoveableSource, RestrictableSource,
LockableSource, InspectableSource, VersionableSource {
/** Component context */
private Context context;
/** Namespace access token. */
private NamespaceAccessToken nat;
/** Configuration of namespace */
private NamespaceConfig config;
/** Structure helper. */
private Structure structure;
/** Content helper. */
private Content content;
/** Security helper. */
private Security security;
/** Lock helper. */
private Lock lock;
/** Macro helper. */
private Macro macro;
private CredentialsToken credToken;
/** Slide token. */
private SlideToken slideToken;
/** Pseudo scheme */
private String scheme = "slide";
/** The path of the source, which means the URI without the scheme */
private String path;
/** Uniform resource ifdentifier */
private String uri;
/** Revision number */
private NodeRevisionNumber revisionNumber;
private NodeRevisionDescriptors revisionDescriptors = null;
private NodeRevisionDescriptor revisionDescriptor = null;
// private String branch;
private SourceCredential sourcecredential = new SourceCredential("guest",
"guest");
private String sourcerevision = null;
private String sourcerevisionbranch = null;
private SourceValidity validity = null;
private SlideSourceOutputStream outputstream;
private boolean initialized = false;
/**
* Create a slide source.
*
* @param nat Namespace access token
* @param scheme Scheme of the source
* @param path Path of the source.
* @param sourcecredential Credential, which should be used.
* @param sourcerevision Revision, which should be used.
* @param sourcerevisionbranch Branch, which should be used.
*
* @throws SourceException If Exception occurs during the initialization.
*/
public SlideSource(NamespaceAccessToken nat, String scheme, String path,
SourceCredential sourcecredential,
String sourcerevision,
String sourcerevisionbranch) throws SourceException {
this.sourcecredential = sourcecredential;
this.credToken = new
CredentialsToken(this.sourcecredential.getPrincipal());
this.nat = nat;
this.config = this.nat.getNamespaceConfig();
this.scheme = scheme;
this.path = path;
this.uri = scheme+"://"+path;
this.sourcerevision = sourcerevision;
this.sourcerevisionbranch = sourcerevisionbranch;
this.structure = nat.getStructureHelper();
this.content = nat.getContentHelper();
this.security = nat.getSecurityHelper();
this.lock = nat.getLockHelper();
this.macro = nat.getMacroHelper();
this.slideToken = new SlideTokenImpl(credToken);
try {
this.revisionDescriptors = content.retrieve(this.slideToken,
this.config.getFilesPath()+
this.path);
// Retrieve latest revision descriptor
this.revisionDescriptor = content.retrieve(slideToken,
revisionDescriptors);
this.sourcerevision =
this.revisionDescriptor.getRevisionNumber().toString();
this.sourcerevisionbranch =
this.revisionDescriptor.getBranchName();
} catch (RevisionDescriptorNotFoundException rdnfe) {
//getLogger().warn("Could not retrieve revision descriptor",
rdnfe);
this.revisionDescriptor = null;
this.sourcerevision = null;
this.sourcerevisionbranch = null;
} catch (ObjectNotFoundException onfe) {
//getLogger().debug("Source doesn't exist", onfe);
// ignore
} catch (SlideException se) {
throw new SourceException("Access denied for source '"+this.uri+
"'", se);
}
}
/**
* Pass the Context to the component.
* This method is called after the LogEnabled.enableLogging() (if present)
* method and before any other method.
*
* @param context The context.
*/
public void contextualize(Context context) {
this.context = context;
}
/**
* Return an <code>InputStream</code> object to read from the source.
* This is the data at the point of invocation of this method,
* so if this is Modifiable, you might get different content
* from two different invocations.
*
* @return Input stream for the source.
*
* @throws IOException If an IO excepetion occurs.
* @throws SourceException If an exception occurs.
*/
public InputStream getInputStream() throws IOException, SourceException {
try {
ObjectNode object = structure.retrieve(this.slideToken,
this.config.getFilesPath()+
this.path);
return content.retrieve(slideToken, this.revisionDescriptors,
this.revisionDescriptor).streamContent();
} catch (SlideException se) {
throw new SourceException("Could not get source", se);
}
}
/**
* Return the unique identifer for this source
*
* @return System identifier for the source.
*/
public String getURI() {
return this.uri;
}
/**
* @see org.apache.excalibur.source.Source#getScheme()
*
* @return Scheme of the source.
*/
public String getScheme() {
return this.scheme;
}
/**
* Get the Validity object. This can either wrap the last modification
* date or the expires information or...
* If it is currently not possible to calculate such an information
* <code>null</code> is returned.
*
* @return Validity for the source.
*/
public SourceValidity getValidity() {
try {
if ((this.validity==null) && (this.revisionDescriptor!=null)) {
this.validity = new
TimeStampValidity(this.revisionDescriptor.getLastModifiedAsDate().getTime());
}
} catch (Exception e) {
getLogger().debug("Could not create SourceValidity", e);
return null;
}
return this.validity;
}
/**
* Refresh the content of this object after the underlying data
* content has changed.
*/
public void refresh() {
this.validity = null;
}
/**
* The mime-type of the content described by this object.
* If the source is not able to determine the mime-type by itself
* this can be null.
*
* @return Mime type of the source.
*/
public String getMimeType() {
if (this.revisionDescriptor!=null) {
return this.revisionDescriptor.getContentType();
}
return null;
}
/**
* Does this source actually exist ?
*
* @return true if the resource exists.
*/
public boolean exists() {
try {
structure.retrieve(this.slideToken,
this.config.getFilesPath()+this.path);
} catch (SlideException e) {
return false;
}
return true;
}
/**
* Get an <code>InputStream</code> where raw bytes can be written to.
* The signification of these bytes is implementation-dependent and
* is not restricted to a serialized XML document.
*
* @return a stream to write to
*
* @throws IOException
* @throws SourceException
*/
public OutputStream getOutputStream()
throws IOException, SourceException {
if (outputstream==null) {
outputstream = new SlideSourceOutputStream();
outputstream.enableLogging(getLogger());
}
return outputstream;
}
/**
* Can the data sent to an <code>OutputStream</code> returned by
* [EMAIL PROTECTED] #getOutputStream()} be cancelled ?
*
* @param stream The ouput stream, which should be cancelled.
* @return true if the stream can be cancelled
*/
public boolean canCancel(OutputStream stream) {
return outputstream.canCancel();
}
/**
* Cancel the data sent to an <code>OutputStream</code> returned by
* [EMAIL PROTECTED] #getOutputStream()}.
* <p>
* After cancel, the stream should no more be used.
*
* @param stream The ouput stream, which should be cancelled.
*
* @throws SourceException If the ouput stream can't be cancelled.
*/
public void cancel(OutputStream stream) throws SourceException {
if (outputstream==stream) {
try {
outputstream.cancel();
} catch (Exception e) {
throw new SourceException("Could not cancel output stream",
e);
}
}
}
/**
* A helper can the getOutputStream() method
*/
public class SlideSourceOutputStream extends ByteArrayOutputStream
implements LogEnabled {
private boolean isClosed = false;
private Logger logger = null;
/**
* Provide component with a logger.
*
* @param logger the logger
*/
public void enableLogging(Logger logger) {
this.logger = logger;
}
/**
*
*
* @throws IOException
*/
public void close() throws IOException {
super.close();
byte[] bytes = new byte[0]; // must be initialized
try {
NodeRevisionContent revisionContent = new
NodeRevisionContent();
bytes = toByteArray();
revisionContent.setContent(bytes);
if (revisionDescriptor==null) {
revisionDescriptor = new NodeRevisionDescriptor(0);
String resourceName = config.getFilesPath()+path;
int lastSlash = resourceName.lastIndexOf('/');
if (lastSlash!=-1) {
resourceName = resourceName.substring(lastSlash+1);
}
revisionDescriptor.setName(resourceName);
}
revisionDescriptor.setContentLength(bytes.length);
// Last modification date
revisionDescriptor.setLastModified(new Date());
nat.begin();
if (revisionNumber==null) {
content.create(slideToken, config.getFilesPath()+path,
revisionDescriptor, null);
}
content.store(slideToken, config.getFilesPath()+path,
revisionDescriptor, revisionContent);
try {
nat.commit();
} catch (Exception cme) {
throw new CascadingIOException("Could not commit the
transaction",
cme);
}
} catch (ObjectNotFoundException e) {
// Todo : Check to see if parent exists
SubjectNode subject = new SubjectNode();
try {
// Creating an object
structure.create(slideToken, subject,
config.getFilesPath()+path);
} catch (SlideException se) {
throw new CascadingIOException(se);
}
NodeRevisionDescriptor revisionDescriptor = new
NodeRevisionDescriptor(bytes.length);
// Resource type
revisionDescriptor.setResourceType("");
// Source
revisionDescriptor.setSource("");
// Get content language
revisionDescriptor.setContentLanguage("en");
// Get content length
revisionDescriptor.setContentLength(bytes.length);
// Get content type
String contentType = null;
try {
contentType = ((org.apache.cocoon.environment.Context)
context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT)).getMimeType(path);
} catch (ContextException ce) {
this.logger.warn("Could not get context to determine the
mime type.");
}
if (contentType==null) {
contentType = "application/octet-stream";
}
revisionDescriptor.setContentType(contentType);
// Last modification date
revisionDescriptor.setLastModified(new Date());
// Owner
revisionDescriptor.setOwner(slideToken.getCredentialsToken().getPublicCredentials());
// Creating revisionDescriptor associated with the object
NodeRevisionContent revisionContent = new
NodeRevisionContent();
revisionContent.setContent(bytes);
try {
content.create(slideToken, config.getFilesPath()+path,
revisionDescriptor, revisionContent);
try {
nat.commit();
} catch (Exception cme) {
throw new CascadingIOException("Could not commit the
transaction",
cme);
}
} catch (SlideException se) {
try {
nat.rollback();
} catch (Exception rbe) {
this.logger.warn("Could not rollback the
transaction.",
rbe);
}
throw new CascadingIOException("Could not create source",
se);
}
} catch (Exception e) {
if (e instanceof IOException) {
throw (IOException)e;
}
throw new CascadingIOException("Could not create source", e);
} finally {
this.isClosed = true;
}
}
/**
* Can the data sent to an <code>OutputStream</code> returned by
* [EMAIL PROTECTED] #getOutputStream()} be cancelled ?
*
* @return true if the stream can be cancelled
*/
public boolean canCancel() {
return !this.isClosed;
}
/**
* Cancel the data sent to an <code>OutputStream</code> returned by
* [EMAIL PROTECTED] #getOutputStream()}.
* <p>
* After cancel, the stream should no more be used.
*
*/
public void cancel() throws Exception {
if (this.isClosed) {
throw new IllegalStateException("Cannot cancel : outputstrem
is already closed");
}
this.isClosed = true;
super.close();
}
}
/**
* Move the current source to a specified destination.
*
*
* @param source
*
* @throws SourceException If an exception occurs during
* the move.
*/
public void move(Source source) throws SourceException {
if (source instanceof SlideSource) {
try {
this.macro.move(slideToken,
this.config.getFilesPath()+this.path,
this.config.getFilesPath()+
((SlideSource) source).path);
} catch (SlideException se) {
throw new SourceException("Could not move source.", se);
}
} else {
org.apache.excalibur.source.SourceUtil.move(this, source);
}
}
/**
* Copy the current source to a specified destination.
*
*
* @param source
*
* @throws SourceException If an exception occurs during
* the copy.
*/
public void copy(Source source) throws SourceException {
if (source instanceof SlideSource) {
try {
this.macro.copy(slideToken,
this.config.getFilesPath()+this.path,
this.config.getFilesPath()+
((SlideSource) source).path);
} catch (SlideException se) {
throw new SourceException("Could not move source.", se);
}
} else {
org.apache.excalibur.source.SourceUtil.copy(this, source);
}
}
/**
* Delete the source.
*
* @throws SourceException If the source could not be deleted.
*/
public void delete() throws SourceException {
try {
this.macro.delete(slideToken,
this.config.getFilesPath()+this.path);
} catch (SlideException se) {
throw new SourceException("Could not delete source.", se);
}
}
/**
* Return the content length of the content or -1 if the length is
* unknown.
*
* @return Content length of the source.
*/
public long getContentLength() {
if (revisionDescriptor!=null) {
return revisionDescriptor.getContentLength();
}
return -1;
}
/**
* Get the last modification date of the source or 0 if it
* is not possible to determine the date.
*
* @return Last modified date of the source.
*/
public long getLastModified() {
if (revisionDescriptor!=null) {
return revisionDescriptor.getLastModifiedAsDate().getTime();
}
return 0;
}
/**
* Tests whether a resource is a collection resource.
*
* @return true if the descriptor represents a collection, false otherwise
*
* @throws SourceException If an exception occurs.
*/
public boolean isSourceCollection() throws SourceException {
boolean result = false;
if (revisionDescriptor==null) {
return true;
}
NodeProperty property =
revisionDescriptor.getProperty("resourcetype");
if ((property!=null) &&
(property.getValue().equals("<collection/>"))) {
result = true;
}
return result;
}
/**
* Returns the count of child sources.
*
* @return Count of child sources.
*
* @throws SourceException If an exception occurs.
*/
public int getChildSourceCount() throws SourceException {
try {
int i = 0;
for (Enumeration children = structure.retrieve(this.slideToken,
this.config.getFilesPath()+this.path).enumerateChildren();
children.hasMoreElements(); )
if (((String)
children.nextElement()).startsWith(this.config.getFilesPath())) {
i++;
}
return i;
} catch (SlideException se) {
throw new SourceException("Could not get children", se);
}
}
/**
* Return the system id of a child source.
*
* @param index Index of the child
*
* @return System identifier of the child source.
*
* @throws SourceException If an exception occurs.
*/
public String getChildSource(int index) throws SourceException {
try {
int i = 0;
String child;
for (Enumeration children = structure.retrieve(this.slideToken,
this.config.getFilesPath()+this.path).enumerateChildren();
children.hasMoreElements(); ) {
child = (String) children.nextElement();
if (child.startsWith(this.config.getFilesPath())) {
if (i==index) {
return scheme+":/"+
child.substring(this.config.getFilesPath().length());
}
i++;
}
}
return null;
} catch (SlideException se) {
throw new SourceException("Could not get children", se);
}
}
/**
* Return the system if of the parent source. The method should return
* null if the source hasn't a parent.
*
* @return System identifier of the parent source.
*/
public String getParentSource() {
if ((this.path==null) || (this.path.length()<=1)) {
return null;
}
if (this.path.endsWith("/")) {
return scheme+":/"+
this.path.substring(0, this.path.substring(0,
this.path.length()-1).lastIndexOf("/"));
}
return scheme+":/"+this.path.substring(0, this.path.lastIndexOf("/"));
}
/**
* Create a collection of sources.
*
* @param collectionname Name of the collectiom, which
* should be created.
*
* @throws SourceException if an exception occurs.
*/
public void createCollection(String collectionname)
throws SourceException {
SubjectNode collection = new SubjectNode();
NodeRevisionDescriptor revisionDescriptor = new
NodeRevisionDescriptor(0);
// Resource type
revisionDescriptor.setResourceType("<collection/>");
// Creation date
revisionDescriptor.setCreationDate(new Date());
// Last modification date
revisionDescriptor.setLastModified(new Date());
// Content length name
revisionDescriptor.setContentLength(0);
// Source
revisionDescriptor.setSource("");
// Owner
revisionDescriptor.setOwner(slideToken.getCredentialsToken().getPublicCredentials());
try {
structure.create(slideToken, collection,
this.config.getFilesPath()+this.path+"/"+
collectionname);
content.create(slideToken,
this.config.getFilesPath()+this.path+"/"+
collectionname, revisionDescriptor, null);
} catch (SlideException se) {
throw new SourceException("Could not create collection.", se);
}
}
/**
* Get the current credential for the source
*
* @return Return the current used credential;
*
* @throws SourceException If an exception occurs.
*/
public SourceCredential getSourceCredential() throws SourceException {
return this.sourcecredential;
}
/**
* Set the credential for the source
*
* @param sourcecredential The credential, which should be used.
*
* @throws SourceException If an exception occurs.
*/
public void setSourceCredential(SourceCredential sourcecredential)
throws SourceException {
if ((sourcecredential==null) ||
(sourcecredential.getPrincipal()==null) ||
(sourcecredential.getPrincipal().length()<=0)) {
return;
}
this.sourcecredential = sourcecredential;
this.credToken = new
CredentialsToken(this.sourcecredential.getPrincipal());
this.slideToken = new SlideTokenImpl(credToken);
}
/**
* Add a permission to this source
*
* @param sourcepermission Permission, which should be set
*
* @throws SourceException If an exception occurs during this operation
**/
public void addSourcePermission(SourcePermission sourcepermission)
throws SourceException {
NamespaceConfig config = this.nat.getNamespaceConfig();
String subject = null;
if (sourcepermission instanceof PrincipalSourcePermission) {
subject = config.getUsersPath()+"/"+
((PrincipalSourcePermission)
sourcepermission).getPrincipal();
// Test if principal exists
try {
ObjectNode objectnode = structure.retrieve(this.slideToken,
subject);
if ( !(objectnode instanceof SubjectNode)) {
throw new SourceException("Principal '"+
((PrincipalSourcePermission)
sourcepermission).getPrincipal()+
"' doesn't exists");
}
} catch (SlideException se) {
throw new SourceException("Could not retrieve object for
principal '"+
((PrincipalSourcePermission)
sourcepermission).getPrincipal()+
"'", se);
}
} else if (sourcepermission instanceof GroupSourcePermission) {
subject = config.getUsersPath()+"/"+
((GroupSourcePermission) sourcepermission).getGroup();
// Test if group exists
try {
ObjectNode objectnode = structure.retrieve(this.slideToken,
subject);
if ( !(objectnode instanceof GroupNode)) {
throw new SourceException("Group '"+
((GroupSourcePermission)
sourcepermission).getGroup()+
"' doesn't exists");
}
} catch (SlideException se) {
throw new SourceException("Could not retrieve object for
group '"+
((GroupSourcePermission)
sourcepermission).getGroup()+
"'", se);
}
subject = "+"+subject; // Additional '+' to expand the group
} else {
throw new SourceException("Does't support category of
permission");
}
boolean negative = sourcepermission.isNegative();
boolean inheritable = sourcepermission.isInheritable();
if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_ALL)) {
addPermission(subject, "/", negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ)) {
addPermission(subject, config.getReadObjectAction().getUri(),
negative, inheritable);
addPermission(subject, config.getReadLocksAction().getUri(),
negative, inheritable);
addPermission(subject,
config.getReadRevisionMetadataAction().getUri(),
negative, inheritable);
addPermission(subject,
config.getReadRevisionContentAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_SOURCE))
{
addPermission(subject, config.getReadObjectAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_LOCKS))
{
addPermission(subject, config.getReadLocksAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_PROPERTY))
{
addPermission(subject,
config.getReadRevisionMetadataAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_CONTENT))
{
addPermission(subject,
config.getReadRevisionContentAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_WRITE)) {
addPermission(subject, config.getCreateObjectAction().getUri(),
negative, inheritable);
addPermission(subject, config.getRemoveObjectAction().getUri(),
negative, inheritable);
addPermission(subject, config.getLockObjectAction().getUri(),
negative, inheritable);
addPermission(subject,
config.getCreateRevisionMetadataAction().getUri(),
negative, inheritable);
addPermission(subject,
config.getModifyRevisionMetadataAction().getUri(),
negative, inheritable);
addPermission(subject,
config.getRemoveRevisionMetadataAction().getUri(),
negative, inheritable);
addPermission(subject,
config.getCreateRevisionContentAction().getUri(),
negative, inheritable);
addPermission(subject,
config.getModifyRevisionContentAction().getUri(),
negative, inheritable);
addPermission(subject,
config.getRemoveRevisionContentAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_SOURCE))
{
addPermission(subject, config.getCreateObjectAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_SOURCE))
{
addPermission(subject, config.getRemoveObjectAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_LOCK_SOURCE))
{
addPermission(subject, config.getLockObjectAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_PROPERTY))
{
addPermission(subject,
config.getCreateRevisionMetadataAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_MODIFY_PROPERTY))
{
addPermission(subject,
config.getModifyRevisionMetadataAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_PROPERTY))
{
addPermission(subject,
config.getRemoveRevisionMetadataAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_CONTENT))
{
addPermission(subject,
config.getCreateRevisionContentAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_MODIFY_CONTENT))
{
addPermission(subject,
config.getModifyRevisionContentAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_CONTENT))
{
addPermission(subject,
config.getRemoveRevisionContentAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_ACL)) {
addPermission(subject,
config.getReadPermissionsAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_WRITE_ACL)) {
addPermission(subject,
config.getGrantPermissionAction().getUri(),
negative, inheritable);
addPermission(subject,
config.getRevokePermissionAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_GRANT_PERMISSION))
{
addPermission(subject,
config.getGrantPermissionAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REVOKE_PERMISSION))
{
addPermission(subject,
config.getRevokePermissionAction().getUri(),
negative, inheritable);
}
}
/**
* Add permission to the list of permissions.
*
* @param subject Subject of the permission.
* @param action Action for the subject.
* @param negative If the permission, should be allowed or denied.
* @param inheritable If the permission is inheritable.
*
* @throws SourceException If an exception occurs.
*/
private void addPermission(String subject, String action,
boolean negative,
boolean inheritable) throws SourceException {
try {
NodePermission permission = new
NodePermission(this.config.getFilesPath()+
this.path, subject, action,
inheritable, negative);
this.security.grantPermission(this.slideToken, permission);
// Last modification date
revisionDescriptor.setLastModified(new Date());
content.store(slideToken, this.config.getFilesPath()+this.path,
revisionDescriptor, null);
} catch (SlideException se) {
throw new SourceException("Couldn't grant permission", se);
}
}
/**
* Remove a permission from this source
*
* @param sourcepermission Permission, which should be removed
*
* @throws SourceException If an exception occurs during this operation
**/
public void removeSourcePermission(SourcePermission sourcepermission)
throws SourceException {
NamespaceConfig config = this.nat.getNamespaceConfig();
String subject = null;
if (sourcepermission instanceof PrincipalSourcePermission) {
subject = config.getUsersPath()+"/"+
((PrincipalSourcePermission)
sourcepermission).getPrincipal();
// Test if principal exists
try {
ObjectNode objectnode = structure.retrieve(this.slideToken,
subject);
if ( !(objectnode instanceof SubjectNode)) {
throw new SourceException("Principal '"+
((PrincipalSourcePermission)
sourcepermission).getPrincipal()+
"' doesn't exists");
}
} catch (SlideException se) {
throw new SourceException("Could not retrieve object for
principal '"+
((PrincipalSourcePermission)
sourcepermission).getPrincipal()+
"'", se);
}
} else if (sourcepermission instanceof GroupSourcePermission) {
subject = config.getUsersPath()+"/"+
((GroupSourcePermission) sourcepermission).getGroup();
// Test if group exists
try {
ObjectNode objectnode = structure.retrieve(this.slideToken,
subject);
if ( !(objectnode instanceof GroupNode)) {
throw new SourceException("Group '"+
((GroupSourcePermission)
sourcepermission).getGroup()+
"' doesn't exists");
}
} catch (SlideException se) {
throw new SourceException("Could not retrieve object for
group '"+
((GroupSourcePermission)
sourcepermission).getGroup()+
"'", se);
}
subject = "+"+subject; // Additional '+' to expand the group
} else {
throw new SourceException("Does't support category of
permission");
}
boolean negative = sourcepermission.isNegative();
boolean inheritable = sourcepermission.isInheritable();
if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_ALL)) {
removePermission(subject, "/", negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ)) {
removePermission(subject, config.getReadObjectAction().getUri(),
negative, inheritable);
removePermission(subject, config.getReadLocksAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getReadRevisionMetadataAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getReadRevisionContentAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_SOURCE))
{
removePermission(subject, config.getReadObjectAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_LOCKS))
{
removePermission(subject, config.getReadLocksAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_PROPERTY))
{
removePermission(subject,
config.getReadRevisionMetadataAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_CONTENT))
{
removePermission(subject,
config.getReadRevisionContentAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_WRITE)) {
removePermission(subject,
config.getCreateObjectAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getRemoveObjectAction().getUri(),
negative, inheritable);
removePermission(subject, config.getLockObjectAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getCreateRevisionMetadataAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getModifyRevisionMetadataAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getRemoveRevisionMetadataAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getCreateRevisionContentAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getModifyRevisionContentAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getRemoveRevisionContentAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_SOURCE))
{
removePermission(subject,
config.getCreateObjectAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_SOURCE))
{
removePermission(subject,
config.getRemoveObjectAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_LOCK_SOURCE))
{
removePermission(subject, config.getLockObjectAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_PROPERTY))
{
removePermission(subject,
config.getCreateRevisionMetadataAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_MODIFY_PROPERTY))
{
removePermission(subject,
config.getModifyRevisionMetadataAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_PROPERTY))
{
removePermission(subject,
config.getRemoveRevisionMetadataAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_CREATE_CONTENT))
{
removePermission(subject,
config.getCreateRevisionContentAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_MODIFY_CONTENT))
{
removePermission(subject,
config.getModifyRevisionContentAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REMOVE_CONTENT))
{
removePermission(subject,
config.getRemoveRevisionContentAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_READ_ACL)) {
removePermission(subject,
config.getReadPermissionsAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_WRITE_ACL)) {
removePermission(subject,
config.getGrantPermissionAction().getUri(),
negative, inheritable);
removePermission(subject,
config.getRevokePermissionAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_GRANT_PERMISSION))
{
removePermission(subject,
config.getGrantPermissionAction().getUri(),
negative, inheritable);
} else if
(sourcepermission.getPrivilege().equals(SourcePermission.PRIVILEGE_REVOKE_PERMISSION))
{
removePermission(subject,
config.getRevokePermissionAction().getUri(),
negative, inheritable);
}
}
/**
* Remove a permission from the list of permissions.
*
* @param subject Subject of the permission.
* @param action Action for the subject.
* @param negative If the permission, should be allowed or denied.
* @param inheritable If the permission is inheritable.
*
* @throws SourceException If an exception occurs.
*/
private void removePermission(String subject, String action,
boolean negative,
boolean inheritable)
throws SourceException {
try {
NodePermission permission = new
NodePermission(this.config.getFilesPath()+
this.path, subject, action,
inheritable, negative);
this.security.revokePermission(this.slideToken, permission);
// Last modification date
revisionDescriptor.setLastModified(new Date());
content.store(slideToken, this.config.getFilesPath()+this.path,
revisionDescriptor, null);
} catch (SlideException se) {
throw new SourceException("Couldn't grant permission", se);
}
}
/**
* Returns a list of the existing permissions.
* Based on the implementation of
org.apache.slide.webdav.util.PropertyHelper .
*
* @return Array of SourcePermission
*
* @throws SourceException If an exception occurs.
**/
public SourcePermission[] getSourcePermissions() throws SourceException {
try {
NamespaceConfig config = this.nat.getNamespaceConfig();
ObjectNode current = structure.retrieve(this.slideToken,
this.config.getFilesPath()+
this.path);
security.checkCredentials(this.slideToken, current,
config.getReadPermissionsAction());
String userspath = config.getUsersPath();
// read
String readObjectUri = config.getReadObjectAction().getUri();
String readRevisionMetadataUri =
config.getReadRevisionMetadataAction().getUri();
String readRevisionContentUri =
config.getReadRevisionContentAction().getUri();
// write
String createObjectUri = config.getCreateObjectAction().getUri();
String removeObjectUri = config.getRemoveObjectAction().getUri();
String lockObjectUri = config.getLockObjectAction().getUri();
String readLocksUri = config.getReadLocksAction().getUri();
String createRevisionMetadataUri =
config.getCreateRevisionMetadataAction().getUri();
String modifyRevisionMetadataUri =
config.getModifyRevisionMetadataAction().getUri();
String removeRevisionMetadataUri =
config.getRemoveRevisionMetadataAction().getUri();
String createRevisionContentUri =
config.getCreateRevisionContentAction().getUri();
String modifyRevisionContentUri =
config.getModifyRevisionContentAction().getUri();
String removeRevisionContentUri =
config.getRemoveRevisionContentAction().getUri();
// read-acl
String readPermissionsUri =
config.getReadPermissionsAction().getUri();
// write-acl
String grantPermissionUri =
config.getGrantPermissionAction().getUri();
String revokePermissionUri =
config.getRevokePermissionAction().getUri();
boolean inheritedPermissions = false;
Vector permissions = new Vector();
ArrayList sourcepermissions = new ArrayList();
while (current!=null) {
try {
// put all permissions in a list
permissions.clear();
Enumeration aclList =
security.enumeratePermissions(this.slideToken,
current);
while (aclList.hasMoreElements()) {
NodePermission permission = (NodePermission)
aclList.nextElement();
// if we are processing inheritedPermissions (from
parent and up)
// then the permission should be inheritable
if (inheritedPermissions &&
!permission.isInheritable()) {
// continue with next permission
continue;
}
permissions.add(permission);
}
// start combining and writing the permissions
while (permissions.size()>0) {
NodePermission permission = (NodePermission)
permissions.get(0);
permissions.remove(0);
String principal = permission.getSubjectUri();
boolean negative = permission.isNegative();
String action = permission.getActionUri();
// read
boolean isReadObject =
readObjectUri.startsWith(action);
boolean isReadLocks = readLocksUri.startsWith(action);
boolean isReadRevisionMetadata =
readRevisionMetadataUri.startsWith(action);
boolean isReadRevisionContent =
readRevisionContentUri.startsWith(action);
// write
boolean isCreateObject =
createObjectUri.startsWith(action);
boolean isRemoveObject =
removeObjectUri.startsWith(action);
boolean isLockObject =
lockObjectUri.startsWith(action);
boolean isCreateRevisionMetadata =
createRevisionMetadataUri.startsWith(action);
boolean isModifyRevisionMetadata =
modifyRevisionMetadataUri.startsWith(action);
boolean isRemoveRevisionMetadata =
removeRevisionMetadataUri.startsWith(action);
boolean isCreateRevisionContent =
createRevisionContentUri.startsWith(action);
boolean isModifyRevisionContent =
modifyRevisionContentUri.startsWith(action);
boolean isRemoveRevisionContent =
removeRevisionContentUri.startsWith(action);
// read-acl
boolean isReadPermissions =
readPermissionsUri.startsWith(action);
// write-acl
boolean isGrantPermission =
grantPermissionUri.startsWith(action);
boolean isRevokePermission =
revokePermissionUri.startsWith(action);
// check the other permissions to combine them
// (if they are for the same principal/negative)
for (int i = 0; i<permissions.size(); i++) {
NodePermission otherPermission = (NodePermission)
permissions.get(i);
if
(principal.equals(otherPermission.getSubjectUri()) &&
(negative==otherPermission.isNegative())) {
permissions.remove(i);
i--; // because we removed the current one
action = otherPermission.getActionUri();
// read
isReadObject |=
readObjectUri.startsWith(action);
isReadLocks |=
readLocksUri.startsWith(action);
isReadRevisionMetadata |=
readRevisionMetadataUri.startsWith(action);
isReadRevisionContent |=
readRevisionContentUri.startsWith(action);
// write
isCreateObject |=
createObjectUri.startsWith(action);
isRemoveObject |=
removeObjectUri.startsWith(action);
isLockObject |=
lockObjectUri.startsWith(action);
isCreateRevisionMetadata |=
createRevisionMetadataUri.startsWith(action);
isModifyRevisionMetadata |=
modifyRevisionMetadataUri.startsWith(action);
isRemoveRevisionMetadata |=
removeRevisionMetadataUri.startsWith(action);
isCreateRevisionContent |=
createRevisionContentUri.startsWith(action);
isModifyRevisionContent |=
modifyRevisionContentUri.startsWith(action);
isRemoveRevisionContent |=
removeRevisionContentUri.startsWith(action);
// read-acl
isReadPermissions |=
readPermissionsUri.startsWith(action);
// write-acl
isGrantPermission |=
grantPermissionUri.startsWith(action);
isRevokePermission |=
revokePermissionUri.startsWith(action);
}
}
// WebDAV privileges
boolean isRead = isReadObject && isReadLocks &&
isReadRevisionMetadata &&
isReadRevisionContent;
boolean isWrite = isCreateObject && isRemoveObject &&
isLockObject &&
isCreateRevisionMetadata &&
isModifyRevisionMetadata &&
isRemoveRevisionMetadata &&
isCreateRevisionContent &&
isModifyRevisionContent &&
isRemoveRevisionContent;
boolean isReadAcl = isReadPermissions;
boolean isWriteAcl = isGrantPermission &&
isRevokePermission;
boolean isAll = isRead && isWrite && isReadAcl &&
isWriteAcl;
SourcePermission sourcepermission = null;
if (principal.equals("~")) {
sourcepermission = new
PrincipalSourcePermission(PrincipalSourcePermission.PRINCIPAL_SELF,
null, inheritedPermissions, negative);
} else if (principal.equals("nobody")) {
sourcepermission = new
PrincipalSourcePermission(PrincipalSourcePermission.PRINCIPAL_GUEST,
null, inheritedPermissions, negative);
} else if (principal.equals(userspath)) {
sourcepermission = new
PrincipalSourcePermission(PrincipalSourcePermission.PRINCIPAL_ALL,
null, inheritedPermissions, negative);
} else if (principal.startsWith(userspath+"/")) {
sourcepermission = new
PrincipalSourcePermission(principal.substring(userspath.length()+
1), null, inheritedPermissions, negative);
} else if (principal.startsWith("+"+userspath+"/")) {
sourcepermission = new
GroupSourcePermission(principal.substring(userspath.length()+
2), null, inheritedPermissions, negative);
} else {
sourcepermission = new
PrincipalSourcePermission(principal,
null, inheritedPermissions, negative);
}
if (isAll) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_ALL);
} else {
if (isRead) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ);
} else {
if (isReadObject) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ_SOURCE);
}
if (isReadLocks) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ_LOCKS);
}
if (isReadRevisionMetadata) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ_PROPERTY);
}
if (isReadRevisionContent) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ_CONTENT);
}
}
if (isWrite) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_WRITE);
} else {
if (isCreateObject) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_CREATE_SOURCE);
}
if (isRemoveObject) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_REMOVE_SOURCE);
}
if (isLockObject) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_LOCK_SOURCE);
}
if (isCreateRevisionMetadata) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_CREATE_PROPERTY);
}
if (isModifyRevisionMetadata) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_MODIFY_PROPERTY);
}
if (isRemoveRevisionMetadata) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_REMOVE_PROPERTY);
}
if (isCreateRevisionContent) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_CREATE_CONTENT);
}
if (isModifyRevisionContent) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_MODIFY_CONTENT);
}
if (isRemoveRevisionContent) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_REMOVE_CONTENT);
}
}
if (isReadAcl) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_READ_ACL);
}
if (isWriteAcl) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_WRITE_ACL);
} else {
if (isGrantPermission) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_GRANT_PERMISSION);
}
if (isRevokePermission) {
sourcepermission.setPrivilege(SourcePermission.PRIVILEGE_REVOKE_PERMISSION);
}
}
}
sourcepermissions.add(sourcepermission);
}
} catch (SlideException se) {
throw new SourceException("Exception eccurs while
retrieveing source permission",
se);
}
inheritedPermissions = true;
try {
current = structure.getParent(this.slideToken, current);
} catch (SlideException e) {
break;
}
}
SourcePermission[] sourcepermissionArray = new
SourcePermission[sourcepermissions.size()];
return (SourcePermission[]) sourcepermissions.toArray((Object[])
sourcepermissionArray);
} catch (SlideException se) {
throw new SourceException("Exception eccurs while retrieveing
source permission",
se);
}
}
/**
* Add a lock to this source
*
* @param sourcelock Lock, which should be added
*
* @throws SourceException If an exception occurs during this operation
*/
public void addSourceLocks(SourceLock sourcelock) throws SourceException {
throw new SourceException("Operation not yet supported");
}
/**
* Returns a enumeration of the existing locks
*
* @return Enumeration of SourceLock
*
* @throws SourceException If an exception occurs.
*/
public Enumeration getSourceLocks() throws SourceException {
try {
Vector sourcelocks = new Vector();
NodeLock lock;
for (Enumeration locks = this.lock.enumerateLocks(this.slideToken,
this.config.getFilesPath()+this.path, false);
locks.hasMoreElements(); ) {
lock = (NodeLock) locks.nextElement();
sourcelocks.addElement(new SourceLock(lock.getSubjectUri(),
lock.getTypeUri(),
lock.getExpirationDate(),
lock.isInheritable(),
lock.isExclusive()));
}
return sourcelocks.elements();
} catch (SlideException se) {
throw new SourceException("Could not retrieve locks", se);
}
}
/**
* Sets a property for a source.
*
* @param sourceproperty Property of the source
*
* @throws SourceException If an exception occurs during this operation
*/
public void setSourceProperty(SourceProperty sourceproperty)
throws SourceException {
try {
revisionDescriptor.setProperty(sourceproperty.getName(),
sourceproperty.getNamespace(),
sourceproperty.getValueAsString());
// Last modification date
revisionDescriptor.setLastModified(new Date());
content.store(slideToken, this.config.getFilesPath()+this.path,
revisionDescriptor, null);
} catch (SlideException se) {
throw new SourceException("Could not set property", se);
}
}
/**
* Returns a property from a source.
*
* @param namespace Namespace of the property
* @param name Name of the property
*
* @return Property of the source.
*
* @throws SourceException If an exception occurs.
*/
public SourceProperty getSourceProperty(String namespace,
String name)
throws SourceException {
if (revisionDescriptor==null) {
return null;
}
return new SourceProperty(namespace, name,
revisionDescriptor.getProperty(name,
namespace).getValue().toString());
}
/**
* Returns a enumeration of the properties
*
* @return Enumeration of SourceProperty
*
* @throws SourceException If an exception occurs.
*/
public SourceProperty[] getSourceProperties() throws SourceException {
if (revisionDescriptor==null) {
return new SourceProperty[0];
}
Vector sourceproperties = new Vector();
NodeProperty property;
for (Enumeration e = revisionDescriptor.enumerateProperties();
e.hasMoreElements(); ) {
property = (NodeProperty) e.nextElement();
sourceproperties.addElement(new
SourceProperty(property.getNamespace(),
property.getName(), property.getValue().toString()));
}
SourceProperty[] sourcepropertiesArray = new
SourceProperty[sourceproperties.size()];
for (int i = 0; i<sourceproperties.size(); i++)
sourcepropertiesArray[i] = (SourceProperty)
sourceproperties.elementAt(i);
return sourcepropertiesArray;
}
/**
* Remove a specified source property.
*
* @param namespace Namespace of the property.
* @param name Name of the property.
*
* @throws SourceException If an exception occurs.
*/
public void removeSourceProperty(String namespace,
String name) throws SourceException {
try {
if ((revisionDescriptor!=null) && ( !namespace.equals("DAV:"))) {
revisionDescriptor.removeProperty(name, namespace);
// Last modification date
revisionDescriptor.setLastModified(new Date());
content.store(slideToken,
this.config.getFilesPath()+this.path,
revisionDescriptor, null);
}
} catch (SlideException se) {
throw new SourceException("Could not remove property", se);
}
}
/**
* If this source versioned
*
* @return True if the current source is versioned.
*
* @throws SourceException If an exception occurs.
*/
public boolean isVersioned() throws SourceException {
try {
this.revisionDescriptors = content.retrieve(this.slideToken,
this.config.getFilesPath()+
this.path);
return this.revisionDescriptors.hasRevisions();
} catch (SlideException se) {
throw new SourceException("Could not retrieve revision
descriptor",
se);
}
}
/**
* Get the current revision of the source
*
* @return The current revision of the source
*
* @throws SourceException If an exception occurs.
*/
public String getSourceRevision() throws SourceException {
return this.sourcerevision;
}
/**
* Sets the wanted revision of the source
*
* @param sourcerevision The revision, which should be used.
*
* @throws SourceException If an exception occurs.
*/
public void setSourceRevision(String sourcerevision)
throws SourceException {
this.sourcerevision = sourcerevision;
try {
this.revisionDescriptors = content.retrieve(this.slideToken,
this.config.getFilesPath()+
this.path);
// Retrieve revision descriptor by the revision
this.revisionDescriptor = content.retrieve(slideToken,
revisionDescriptors,
new
NodeRevisionNumber(this.sourcerevision));
} catch (SlideException se) {
throw new SourceException("Could not retrieve revision
descriptor",
se);
}
}
/**
* Get the current branch of the revision from the source
*
* @return The branch of the revision
*
* @throws SourceException If an exception occurs.
*/
public String getSourceRevisionBranch() throws SourceException {
return this.sourcerevisionbranch;
}
/**
* Sets the wanted branch of the revision from the source
*
* @param sourcerevisionbranch The branch, which should be used.
*
* @throws SourceException If an exception occurs.
*/
public void setSourceRevisionBranch(String sourcerevisionbranch)
throws SourceException {
this.sourcerevisionbranch = sourcerevisionbranch;
// FIXME Retrieve the the revsion descriptor with current branch
}
/**
* Get the latest revision
*
* @return Last revision of the source.
*
* @throws SourceException If an exception occurs.
*/
public String getLatestSourceRevision() throws SourceException {
try {
this.revisionDescriptors = content.retrieve(this.slideToken,
this.config.getFilesPath()+
this.path);
return this.revisionDescriptors.getLatestRevision().toString();
} catch (SlideException se) {
throw new SourceException("Could not retrieve revision
descriptor",
se);
}
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/impl/SlideSourceFactory.java
Index: SlideSourceFactory.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source.impl;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Map;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.ComponentSelector;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.components.repository.Repository;
import org.apache.cocoon.components.repository.impl.SlideRepository;
import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.components.source.helpers.SourceCredential;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.source.SourceFactory;
import org.apache.excalibur.source.SourceParameters;
import org.apache.slide.common.NamespaceAccessToken;
/**
* A factory for sources from a Jakarta Slide repository.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: SlideSourceFactory.java,v 1.1 2003/01/31 18:08:44 stephan
Exp $
*/
public class SlideSourceFactory extends AbstractLogEnabled
implements SourceFactory, ThreadSafe, Composable, Contextualizable {
/** The component manager instance */
private ComponentManager manager = null;
private Context context;
/**
* Set the current <code>ComponentManager</code> instance used by this
* <code>Composable</code>.
*
* @param manager Component manager.
*/
public void compose(ComponentManager manager) throws ComponentException {
this.manager = manager;
}
/**
* Get a <code>Source</code> object.
*
* @param uri URI of the source.
* @param parameters This is optional.
*
* @return A new source object.
*/
public Source getSource(String uri,
Map parameters)
throws MalformedURLException, IOException,
SourceException {
this.getLogger().debug("Creating source object for '"+uri+"'");
String scheme = SourceUtil.getScheme(uri);
String path = SourceUtil.getPathWithoutAuthority(uri);
if ((path==null) || (path.length()==0)) {
path = "/";
} else if ( !path.startsWith("/")) {
path = "/"+path;
}
String query = SourceUtil.getQuery(uri);
SourceParameters queryParameters = null;
if ((query==null) || (query.length()==0)) {
queryParameters = new SourceParameters();
} else {
queryParameters = new SourceParameters(query);
}
this.getLogger().debug("Path is "+path);
this.getLogger().debug("Query is "+query);
this.getLogger().debug("Source parameters: "+
queryParameters.toString());
String repositoryname =
queryParameters.getParameter("cocoon-repository",
null);
String namespace =
queryParameters.getParameter("cocoon-repository-namespace",
null);
String principal =
queryParameters.getParameter("cocoon-source-principal",
"guest");
String password =
queryParameters.getParameter("cocoon-source-password",
null);
String revision =
queryParameters.getParameter("cocoon-source-revision",
null);
String branch = queryParameters.getParameter("cocoon-source-branch",
null);
getLogger().debug("Used prinical '"+principal+"' for source");
SourceCredential credential;
if (password!=null) {
credential = new SourceCredential(principal, password);
} else {
credential = new SourceCredential(principal);
}
if (path.length()==0) {
path = "/";
}
ComponentSelector repositories = null;
Repository repository = null;
try {
repositories = (ComponentSelector)
this.manager.lookup(Repository.ROLE+
"Selector");
repository = (Repository) repositories.select(repositoryname);
if ( !(repository instanceof SlideRepository)) {
getLogger().error("Can't get Slide repository");
return null;
}
SlideRepository sliderepository = (SlideRepository) repository;
NamespaceAccessToken nat =
sliderepository.getNamespaceToken(namespace);
if (nat==null) {
throw new SourceException("Repository with the namespace '"+
namespace+"' couldn't be found");
}
SlideSource source = new SlideSource(nat, scheme, path,
credential, revision,
branch);
source.enableLogging(getLogger());
source.contextualize(this.context);
return source;
} catch (ComponentException ce) {
getLogger().error("Could not lookup for component.", ce);
} finally {
if ((repository!=null) && (repository instanceof Component)) {
repositories.release((Component) repository);
}
repository = null;
if (repositories!=null) {
this.manager.release(repositories);
}
repositories = null;
}
return null;
}
/**
* Release a [EMAIL PROTECTED] Source} object.
*
* @param source Source, which should be released.
*/
public void release(Source source) {
if (null!=source) {
this.getLogger().debug("Releasing source "+source.getURI());
// simply do nothing
}
}
/**
* @see
org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
*
* @param context The context.
*/
public void contextualize(Context context) throws ContextException {
this.context = context;
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/impl/SourceInspectorManager.java
Index: SourceInspectorManager.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source.impl;
import java.util.ArrayList;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.components.source.SourceInspector;
import org.apache.cocoon.components.source.helpers.SourceProperty;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
/**
* This source inspector manage several source inspectors
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: SourceInspectorManager.java,v 1.1 2003/01/31 18:08:44
stephan Exp $
*/
public class SourceInspectorManager extends AbstractLogEnabled implements
SourceInspector, ThreadSafe, Contextualizable, Composable, Configurable,
Initializable, Disposable {
private ArrayList inspectors = new ArrayList();
private Context context = null;
private ComponentManager manager = null;
/**
* Get the context
*/
public void contextualize(Context context) throws ContextException {
this.context = context;
}
public void compose(ComponentManager manager) {
this.manager = manager;
}
/**
* Pass the Configuration to the Configurable class. This method must
* always be called after the constructor and before any other method.
*
* @param configuration the class configurations.
*/
public void configure(Configuration configuration)
throws ConfigurationException {
ClassLoader classloader =
Thread.currentThread().getContextClassLoader();
final Configuration[] configurations =
configuration.getChildren("sourceinspector");
for(int i=0; i<configurations.length; i++) {
String className = configurations[i].getAttribute( "class", "" );
SourceInspector inspector = null;
try {
final Class inspectorClass = classloader.loadClass(className);
inspector = (SourceInspector)inspectorClass.newInstance();
} catch (InstantiationException ie) {
throw new ConfigurationException("Could not instantiate class
"+className, ie);
} catch (ClassNotFoundException cnfe) {
throw new ConfigurationException("Could not load class
"+className, cnfe);
} catch (IllegalAccessException iae) {
throw new ConfigurationException("Could not load class
"+className, iae);
}
if (inspector instanceof Configurable)
((Configurable)inspector).configure(configurations[i]);
try {
if (inspector instanceof Parameterizable)
((Parameterizable)inspector).parameterize(Parameters.fromConfiguration(configurations[i]));
} catch (ParameterException pe) {
throw new ConfigurationException("Could not parameterize
inspector", pe);
}
inspectors.add(inspector);
}
}
/**
* Initialialize the component. Initialization includes
* allocating any resources required throughout the
* components lifecycle.
*
* @throws Exception if an error occurs
*/
public void initialize() throws Exception {
SourceInspector inspector;
for(int i=0; i<this.inspectors.size(); i++) {
inspector = (SourceInspector)this.inspectors.get(i);
if (inspector instanceof LogEnabled)
((LogEnabled)inspector).enableLogging(getLogger());
if (inspector instanceof Contextualizable)
((Contextualizable)inspector).contextualize(this.context);
if (inspector instanceof Composable)
((Composable)inspector).compose(this.manager);
if (inspector instanceof Initializable)
((Initializable)inspector).initialize();
}
}
/**
* This method should be implemented to remove all costly resources
* in object. These resources can be object references, database
connections,
* threads, etc. What is categorised as "costly" resources is determined
on
* a case by case analysis.
*/
/*public void recycle() {
SourceInspector inspector;
for(int i=0; i<this.inspectors.size(); i++) {
inspector = (SourceInspector)this.inspectors.get(i);
if (inspector instanceof Recyclable)
((Recyclable)inspector).recycle();
}
}*/
/**
* The dispose operation is called at the end of a components lifecycle.
* This method will be called after Startable.stop() method (if
implemented
* by component). Components use this method to release and destroy any
* resources that the Component owns.
*/
public void dispose() {
SourceInspector inspector;
for(int i=0; i<this.inspectors.size(); i++) {
inspector = (SourceInspector)this.inspectors.get(i);
if (inspector instanceof Disposable)
((Disposable)inspector).dispose();
}
}
public SourceProperty getSourceProperty(Source source, String namespace,
String name)
throws SourceException {
SourceInspector inspector;
SourceProperty property;
for(int i=0; i<this.inspectors.size(); i++) {
inspector = (SourceInspector)this.inspectors.get(i);
property = inspector.getSourceProperty(source, namespace, name);
if (property!=null)
return property;
}
return null;
}
public SourceProperty[] getSourceProperties(Source source) throws
SourceException {
ArrayList list = new ArrayList();
SourceInspector inspector;
SourceProperty[] properties;
SourceProperty property;
boolean propertyExists;
for(int i=0; i<this.inspectors.size(); i++) {
inspector = (SourceInspector)this.inspectors.get(i);
try {
properties = inspector.getSourceProperties(source);
if (properties!=null)
for(int j=0; j<properties.length; j++) {
propertyExists = false;
for(int k=0; k<list.size() && !propertyExists; k++) {
property = (SourceProperty)list.get(k);
if
((property.getNamespace().equals(properties[j].getNamespace())) &&
(property.getName().equals(properties[j].getName())))
propertyExists = true;
}
if (!propertyExists)
list.add(properties[j]);
}
} catch (SourceException se) {
getLogger().warn("Couldn't get properties from
'"+source.getURI()+"'", se);
}
}
properties = new SourceProperty[list.size()];
for(int i=0; i<list.size(); i++)
properties[i] = (SourceProperty)list.get(i);
return properties;
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/components/source/impl/XPathSourceInspector.java
Index: XPathSourceInspector.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache Cocoon" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cocoon.components.source.impl;
import org.apache.excalibur.xml.xpath.XPathProcessor;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.components.source.SourceInspector;
import org.apache.cocoon.components.source.helpers.SourceProperty;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.xml.dom.DOMParser;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import java.io.IOException;
/**
* This source inspector inspects XML files with a xpath expression
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version $Id: XPathSourceInspector.java,v 1.1 2003/01/31 18:08:44 stephan
Exp $
*/
public class XPathSourceInspector extends AbstractLogEnabled implements
SourceInspector, ThreadSafe, Parameterizable {
private String propertynamespace =
"http://xml.apache.org/cocoon/XPathSourceInspector";
private String propertyname = "result";
private String extension = null;
private String xpath = null;
private ComponentManager manager = null;
public void compose(ComponentManager manager) {
this.manager = manager;
}
public void parameterize(Parameters params) {
this.propertynamespace = params.getParameter("namespace",
"http://xml.apache.org/cocoon/XPathSourceInspector");
this.propertyname = params.getParameter("name", "result");
this.extension = params.getParameter("extension", ".xml");
this.xpath = params.getParameter("xpath", "/*");
}
public SourceProperty getSourceProperty(Source source, String namespace,
String name)
throws SourceException {
if ((namespace.equals(propertynamespace)) &&
(name.equals(propertyname)) &&
(source.getURI().endsWith(extension))) {
DOMParser parser = null;
Document doc = null;
try {
parser = (DOMParser)manager.lookup(DOMParser.ROLE);
doc = parser.parseDocument(new
InputSource(source.getInputStream()));
} catch (SAXException se) {
this.getLogger().error(source.getURI()
+ " is not a valid XML file");
} catch (IOException ioe) {
this.getLogger().error("Could not read file", ioe);
} catch (ComponentException ce) {
this.getLogger().error("Could not retrieve component", ce);
} finally {
if (parser!=null)
this.manager.release((Component)parser);
}
if (doc != null) {
XPathProcessor processor = null;
try {
processor =
(XPathProcessor)manager.lookup(XPathProcessor.ROLE);
NodeList nodelist =
processor.selectNodeList(doc.getDocumentElement(), this.xpath);
SourceProperty property = new
SourceProperty(this.propertynamespace, this.propertyname);
property.setValue(nodelist);
return property;
} catch (ComponentException ce) {
this.getLogger().error("Could not retrieve component",
ce);
} finally {
if ((processor!=null) && (processor instanceof Component))
this.manager.release((Component)processor);
}
}
}
return null;
}
public SourceProperty[] getSourceProperties(Source source) throws
SourceException {
SourceProperty property = getSourceProperty(source,
this.propertynamespace, this.propertyname);
if (property!=null)
return new SourceProperty[]{property};
return null;
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/generation/PrincipalListGenerator.java
Index: PrincipalListGenerator.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.generation;
import java.io.IOException;
import java.util.Map;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentSelector;
import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.excalibur.pool.Recyclable;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.components.repository.Principal;
import org.apache.cocoon.components.repository.PrincipalGroup;
import org.apache.cocoon.components.repository.PrincipalProvider;
import org.apache.cocoon.environment.SourceResolver;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
/**
* The generator generates a list of all principals and group of
* principals from a PrincipalProvider.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version CVS $Id: PrincipalListGenerator.java,v 1.1 2003/01/31 18:08:44
stephan Exp $
*/
public class PrincipalListGenerator extends ComposerGenerator
implements Recyclable {
/** Namespace of the generated list. */
private static final String PL_NS =
"http://xml.apache.org/cocoon/PrincipalListGenerator";
/** The namespace prefix of the resource description framework. */
//private static final String PL_PREFIX = "pl";
private static final String LIST_ELEMENT_NAME = "list";
private static final String PRINCIPAL_ELEMENT_NAME = "principal";
private static final String PRINCIPALGROUP_ELEMENT_NAME = "group";
private static final String NAME_ATTR_NAME = "name";
private static final String ROLE_ATTR_NAME = "role";
private static final String PASSWORD_ATTR_NAME = "password";
private Principal principalcaller = null;
private String principalprovidername = null;
public void setup(SourceResolver resolver, Map objectModel, String
location, Parameters parameters)
throws ProcessingException, SAXException, IOException {
super.setup(resolver, objectModel, location, parameters);
try {
this.principalcaller = new
Principal(parameters.getParameter("principalcaller", "guest"));
this.principalprovidername =
parameters.getParameter("principalprovider");
} catch (ParameterException pe) {
throw new ProcessingException("Could not retrieve parameters",
pe);
}
}
/**
* Generate XML data.
*/
public void generate() throws IOException, SAXException,
ProcessingException {
ComponentSelector principalproviders = null;
PrincipalProvider principalprovider = null;
try {
principalproviders =
(ComponentSelector)this.manager.lookup(PrincipalProvider.ROLE+"Selector");
principalprovider =
(PrincipalProvider)principalproviders.select(this.principalprovidername);
Principal[] principals =
principalprovider.getPrincipals(this.principalcaller);
PrincipalGroup[] principalgroups =
principalprovider.getPrincipalGroups(this.principalcaller);
this.contentHandler.startDocument();
this.contentHandler.startPrefixMapping("",PL_NS);
this.contentHandler.startElement(PL_NS, LIST_ELEMENT_NAME,
LIST_ELEMENT_NAME, new
AttributesImpl());
AttributesImpl attributes;
for(int i=0; i<principals.length; i++) {
attributes = new AttributesImpl();
attributes.addAttribute("", NAME_ATTR_NAME, NAME_ATTR_NAME,
"CDATA", principals[i].getName());
if (principals[i].getRole()!=null)
attributes.addAttribute("", ROLE_ATTR_NAME,
ROLE_ATTR_NAME, "CDATA", principals[i].getRole());
if (principals[i].getPassword()!=null)
attributes.addAttribute("", PASSWORD_ATTR_NAME,
PASSWORD_ATTR_NAME, "CDATA", principals[i].getPassword());
this.contentHandler.startElement(PL_NS,
PRINCIPAL_ELEMENT_NAME,
PRINCIPAL_ELEMENT_NAME, attributes);
this.contentHandler.endElement(PL_NS, PRINCIPAL_ELEMENT_NAME,
PRINCIPAL_ELEMENT_NAME);
}
for(int i=0; i<principalgroups.length; i++) {
attributes = new AttributesImpl();
attributes.addAttribute("", NAME_ATTR_NAME, NAME_ATTR_NAME,
"CDATA", principalgroups[i].getName());
this.contentHandler.startElement(PL_NS,
PRINCIPALGROUP_ELEMENT_NAME,
PRINCIPALGROUP_ELEMENT_NAME, attributes);
Principal[] members =
principalprovider.members(this.principalcaller, principalgroups[i]);
for(int j=0; j<members.length; j++) {
attributes = new AttributesImpl();
attributes.addAttribute("", NAME_ATTR_NAME,
NAME_ATTR_NAME, "CDATA", members[j].getName());
if (members[j].getRole()!=null)
attributes.addAttribute("", ROLE_ATTR_NAME,
ROLE_ATTR_NAME, "CDATA", members[j].getRole());
if (members[j].getPassword()!=null)
attributes.addAttribute("", PASSWORD_ATTR_NAME,
PASSWORD_ATTR_NAME, "CDATA",
members[j].getPassword());
this.contentHandler.startElement(PL_NS,
PRINCIPAL_ELEMENT_NAME,
PRINCIPAL_ELEMENT_NAME, attributes);
this.contentHandler.endElement(PL_NS,
PRINCIPAL_ELEMENT_NAME, PRINCIPAL_ELEMENT_NAME);
}
this.contentHandler.endElement(PL_NS,
PRINCIPALGROUP_ELEMENT_NAME, PRINCIPALGROUP_ELEMENT_NAME);
}
this.contentHandler.endElement(PL_NS, LIST_ELEMENT_NAME,
LIST_ELEMENT_NAME);
this.contentHandler.endPrefixMapping("");
this.contentHandler.endDocument();
} catch (ComponentException ce) {
getLogger().error("Could not lookup for component.", ce);
} finally {
if (principalprovider!=null)
principalproviders.release(principalprovider);
principalprovider = null;
if (principalproviders!=null)
this.manager.release(principalproviders);
principalproviders = null;
}
}
public void recycle() {
this.principalcaller = null;
this.principalprovidername = null;
}
}
1.1
xml-cocoon2/src/blocks/slide/java/org/apache/cocoon/generation/SourceDescriptionGenerator.java
Index: SourceDescriptionGenerator.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.generation;
import java.io.IOException;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Map;
import org.apache.avalon.excalibur.pool.Recyclable;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.caching.CacheableProcessingComponent;
import org.apache.cocoon.components.source.InspectableSource;
import org.apache.cocoon.components.source.LockableSource;
import org.apache.cocoon.components.source.RestrictableSource;
import org.apache.cocoon.components.source.SourceInspector;
import org.apache.cocoon.components.source.TraversableSource;
import org.apache.cocoon.components.source.VersionableSource;
import org.apache.cocoon.components.source.helpers.GroupSourcePermission;
import org.apache.cocoon.components.source.helpers.PrincipalSourcePermission;
import org.apache.cocoon.components.source.helpers.SourceLock;
import org.apache.cocoon.components.source.helpers.SourcePermission;
import org.apache.cocoon.components.source.helpers.SourceProperty;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.xml.IncludeXMLConsumer;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.source.SourceValidity;
import org.apache.excalibur.source.impl.validity.AggregatedValidity;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
/**
* Generates a description from a source of a repository.
* The generator is a combination of a DirectoryGenerator and a generator
* for retrieving SourceProperties, SourcePermission etc.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephan Michels</a>
* @version CVS $Id: SourceDescriptionGenerator.java,v 1.1 2003/01/31
18:08:44 stephan Exp $
*/
public class SourceDescriptionGenerator extends ComposerGenerator
implements CacheableProcessingComponent, Recyclable {
/** Namespace of the source description. */
private static final String SOURCE_NS =
"http://xml.apache.org/cocoon/source/2.0";
/** The namespace prefix of the source description. */
private static final String SOURCE_PREFIX = "source";
private static final String SOURCE_NODE_NAME = "source";
private static final String SOURCE_NODE_QNAME = SOURCE_PREFIX+":"+
SOURCE_NODE_NAME;
private static final String NAME_ATTR_NAME = "name";
private static final String URI_ATTR_NAME = "uri";
private static final String MIMETYPE_ATTR_NAME = "mime-type";
private static final String CONTENTLENGTH_ATTR_NAME = "contentlength";
private static final String LASTMODIFIED_ATTR_NAME = "lastmodified";
private static final String COLLECTION_ATTR_NAME = "collection";
private static final String PARENT_ATTR_NAME = "parent";
private static final String REVISION_ATTR_NAME = "revision";
private static final String REVISIONBRANCH_ATTR_NAME = "branch";
private static final String PROPERTIES_NODE_NAME = "properties";
private static final String PROPERTIES_NODE_QNAME = SOURCE_PREFIX+":"+
PROPERTIES_NODE_NAME;
private static final String PROPERTY_TYPE_ATTR_NAME = "type";
private static final String PERMISSIONS_NODE_NAME = "permissions";
private static final String PERMISSIONS_NODE_QNAME = SOURCE_PREFIX+":"+
PERMISSIONS_NODE_NAME;
private static final String PERMISSION_NODE_NAME = "permission";
private static final String PERMISSION_NODE_QNAME = SOURCE_PREFIX+":"+
PERMISSION_NODE_NAME;
private static final String LOCKS_NODE_NAME = "locks";
private static final String LOCKS_NODE_QNAME = SOURCE_PREFIX+":"+
LOCKS_NODE_NAME;
private static final String LOCK_NODE_NAME = "lock";
private static final String LOCK_NODE_QNAME = SOURCE_PREFIX+":"+
LOCK_NODE_NAME;
private static final String CHILDREN_NODE_NAME = "children";
private static final String CHILDREN_NODE_QNAME = SOURCE_PREFIX+":"+
CHILDREN_NODE_NAME;
private static final String PRINCIPAL_ATTR_NAME = "principal";
private static final String GROUP_ATTR_NAME = "group";
private static final String PRIVILEGE_ATTR_NAME = "privilege";
private static final String INHERITABLE_ATTR_NAME = "inheritable";
private static final String NEGATIVE_ATTR_NAME = "negative";
private static final String TYPE_ATTR_NAME = "type";
private static final String EXPIRATION_ATTR_NAME = "expiration";
private static final String EXCLUSIVE_ATTR_NAME = "exclusive";
/** Include properties into the description */
private boolean properties = true;
/** Include permissions into the description */
private boolean permissions = true;
/** Include locks into the description */
private boolean locks = true;
/** Include version into the description */
private boolean version = true;
/** How deep the generator traverse the source */
private int deep = 1;
/** Traversed source for the keys and validities */
private Hashtable cachedsources = new Hashtable();
/** The queryString of the location including the "?" */
private String queryString;
/**
* Set the <code>SourceResolver</code>, objectModel <code>Map</code>,
* the source and sitemap <code>Parameters</code> used to process the
request.
*
* @param resolver Source Resolver
* @param objectModel Object model.
* @param location Location of the source.
* @param parameters Parameters for the generator.
*/
public void setup(SourceResolver resolver, Map objectModel,
String location,
Parameters parameters)
throws ProcessingException, SAXException,
IOException {
int idx = location.indexOf('?');
if (idx!=-1) {
this.queryString = location.substring(idx);
location = location.substring(0, idx);
} else {
this.queryString = "";
}
super.setup(resolver, objectModel, location, parameters);
this.properties = parameters.getParameterAsBoolean("properties",
true);
this.permissions = parameters.getParameterAsBoolean("permissions",
true);
this.locks = parameters.getParameterAsBoolean("locks", true);
this.version = parameters.getParameterAsBoolean("version", true);
collectSources(this.cachedsources, this.source, this.deep);
}
/**
* Generate the unique key.
* This key must be unique inside the space of this component.
*
* @return The generated key hashes the src
*/
public Serializable generateKey() {
StringBuffer key = new StringBuffer();
key.append("SDG(");
Source source;
for (Enumeration e = cachedsources.elements(); e.hasMoreElements(); )
{
source = (Source) e.nextElement();
key.append(source.getURI());
if (e.hasMoreElements()) {
key.append(";");
}
}
key.append(")");
return key.toString();
}
/**
* Generate the validity object.
*
* @return The generated validity object or <code>null</code> if the
* component is currently not cacheable.
*/
public SourceValidity generateValidity() {
AggregatedValidity validity = new AggregatedValidity();
Source source;
for (Enumeration e = cachedsources.elements(); e.hasMoreElements(); )
{
source = (Source) e.nextElement();
validity.add(source.getValidity());
}
return validity;
}
/**
* Traverse the source tree and retrieve all sources.
*
* @param sources Collection of sources.
* @param uri Uri of the source.
* @param deep Deep of the hirachy, which should traversed.
*/
private void collectSources(Hashtable sources, String uri,
int deep) throws ProcessingException {
Source source = null;
try {
source = this.resolver.resolveURI(uri+this.queryString);
} catch (Exception e) {
if (sources.isEmpty()) {
throw new ProcessingException("Could not retrieve source with
the uri '"+
uri+"'", e);
}
getLogger().debug("Could not retrieve source with the uri '"+uri+
"'", e);
return;
}
sources.put(uri, source);
if (source instanceof TraversableSource) {
TraversableSource traversablesource = (TraversableSource) source;
try {
if (traversablesource.isSourceCollection() && (deep>0)) {
for (int i = 0; i<traversablesource.getChildSourceCount();
i++)
collectSources(sources,
traversablesource.getChildSource(i),
deep-1);
}
} catch (SourceException se) {
getLogger().warn("Could not traverse source", se);
}
}
}
/**
* Generate XML data.
*/
public void generate()
throws IOException, SAXException, ProcessingException {
try {
this.contentHandler.startDocument();
this.contentHandler.startPrefixMapping(SOURCE_PREFIX, SOURCE_NS);
if (((Source) this.cachedsources.get(this.source))==null) {
throw new ProcessingException("Could not retrieve source with
the uri '"+
this.source+"'");
}
pushSourceDescription(this.source, this.deep);
this.contentHandler.endPrefixMapping(SOURCE_PREFIX);
this.contentHandler.endDocument();
} catch (SourceException se) {
throw new ProcessingException("Could not get source", se);
}
}
/**
* Push a XML description of specified source.
*
* @param uri Uniform resource identifier of the source.
* @param deep Deep of the hirachy, which should traversed.
*/
private void pushSourceDescription(String uri,
int deep)
throws SAXException,
SourceException,
ProcessingException,
IOException {
Source source = (Source) this.cachedsources.get(uri);
if (source==null) {
return;
}
try {
AttributesImpl attributes = new AttributesImpl();
attributes.addAttribute(SOURCE_NS, URI_ATTR_NAME, URI_ATTR_NAME,
"CDATA", source.getURI());
String name = source.getURI();
if (name.endsWith("://")) {
attributes.addAttribute(SOURCE_NS, NAME_ATTR_NAME,
NAME_ATTR_NAME, "CDATA", "");
} else if (name.endsWith("/")) {
name = name.substring(1, name.length()-1);
attributes.addAttribute(SOURCE_NS, NAME_ATTR_NAME,
NAME_ATTR_NAME, "CDATA",
name.substring(name.lastIndexOf("/")+
1, name.length()));
} else {
attributes.addAttribute(SOURCE_NS, NAME_ATTR_NAME,
NAME_ATTR_NAME, "CDATA",
name.substring(name.lastIndexOf("/")+
1, name.length()));
}
if ((source.getMimeType()!=null) &&
(source.getMimeType().length()>0)) {
attributes.addAttribute(SOURCE_NS, MIMETYPE_ATTR_NAME,
MIMETYPE_ATTR_NAME, "CDATA",
source.getMimeType());
}
if (source.getContentLength()>=0) {
attributes.addAttribute(SOURCE_NS, CONTENTLENGTH_ATTR_NAME,
CONTENTLENGTH_ATTR_NAME, "CDATA",
String.valueOf(source.getContentLength()));
}
if (source.getLastModified()>0) {
attributes.addAttribute(SOURCE_NS, LASTMODIFIED_ATTR_NAME,
LASTMODIFIED_ATTR_NAME, "CDATA",
String.valueOf(source.getLastModified()));
}
if (this.version && (source instanceof VersionableSource)) {
VersionableSource versionablesource = (VersionableSource)
source;
if (versionablesource.isVersioned()) {
if ((versionablesource.getSourceRevision()!=null) &&
(versionablesource.getSourceRevision().length()>0)) {
attributes.addAttribute(SOURCE_NS,
REVISION_ATTR_NAME,
REVISION_ATTR_NAME, "CDATA",
versionablesource.getSourceRevision());
}
if ((versionablesource.getSourceRevisionBranch()!=null) &&
(versionablesource.getSourceRevisionBranch().length()>
0)) {
attributes.addAttribute(SOURCE_NS,
REVISIONBRANCH_ATTR_NAME,
REVISIONBRANCH_ATTR_NAME,
"CDATA",
versionablesource.getSourceRevisionBranch());
}
}
}
boolean isCollection = false;
TraversableSource traversablesource = null;
if (source instanceof TraversableSource) {
traversablesource = (TraversableSource) source;
isCollection = traversablesource.isSourceCollection();
attributes.addAttribute(SOURCE_NS, COLLECTION_ATTR_NAME,
COLLECTION_ATTR_NAME, "CDATA",
String.valueOf(isCollection));
String parent = traversablesource.getParentSource();
if ((parent!=null) && (parent.length()>0)) {
attributes.addAttribute(SOURCE_NS, PARENT_ATTR_NAME,
PARENT_ATTR_NAME, "CDATA",
parent);
}
}
this.contentHandler.startElement(SOURCE_NS, SOURCE_NODE_NAME,
SOURCE_NODE_QNAME, attributes);
if (this.properties && (source instanceof InspectableSource)) {
pushLiveSourceProperties((InspectableSource) source);
}
if (this.properties) {
pushComputedSourceProperties(source);
}
if (this.permissions) {
try {
if (source instanceof RestrictableSource) {
pushSourcePermissions((RestrictableSource) source);
}
} catch (SourceException se) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Could not retrieve source
permissions",
se);
}
}
}
if (this.locks && (source instanceof LockableSource)) {
pushSourceLocks((LockableSource) source);
}
if ((isCollection) && (deep>0)) {
this.contentHandler.startElement(SOURCE_NS,
CHILDREN_NODE_NAME,
CHILDREN_NODE_QNAME,
new AttributesImpl());
for (int i = 0; i<traversablesource.getChildSourceCount();
i++) {
try {
pushSourceDescription(traversablesource.getChildSource(i),
deep-1);
} catch (SourceException se) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Could not retrieve source",
se);
}
}
}
this.contentHandler.endElement(SOURCE_NS, SOURCE_NODE_NAME,
SOURCE_NODE_QNAME);
}
this.contentHandler.endElement(SOURCE_NS, SOURCE_NODE_NAME,
SOURCE_NODE_QNAME);
} catch (SAXException saxe) {
throw saxe;
}
}
/**
* Push a XML description about all properties, which
* the source owns.
*
* @param source Source.
*/
private void pushLiveSourceProperties(InspectableSource source)
throws SAXException, SourceException {
SourceProperty[] properties = source.getSourceProperties();
SourceProperty property;
AttributesImpl attributes = new AttributesImpl();
attributes.addAttribute(SOURCE_NS, PROPERTY_TYPE_ATTR_NAME,
PROPERTY_TYPE_ATTR_NAME, "CDATA", "live");
this.contentHandler.startElement(SOURCE_NS, PROPERTIES_NODE_NAME,
PROPERTIES_NODE_QNAME, attributes);
IncludeXMLConsumer consumer = new
IncludeXMLConsumer(this.contentHandler);
for (int i = 0; i<properties.length; i++) {
property = properties[i];
this.contentHandler.startPrefixMapping("",
property.getNamespace());
property.toSAX(consumer);
this.contentHandler.endPrefixMapping("");
}
this.contentHandler.endElement(SOURCE_NS, PROPERTIES_NODE_NAME,
PROPERTIES_NODE_QNAME);
}
/**
* Push a XML description about all properties, which
* were computed by source inspectors.
*
* @param source Source
*/
private void pushComputedSourceProperties(Source source)
throws SAXException, SourceException {
AttributesImpl attributes = new AttributesImpl();
attributes.addAttribute(SOURCE_NS, PROPERTY_TYPE_ATTR_NAME,
PROPERTY_TYPE_ATTR_NAME, "CDATA", "computed");
this.contentHandler.startElement(SOURCE_NS, PROPERTIES_NODE_NAME,
PROPERTIES_NODE_QNAME, attributes);
SourceInspector inspector = null;
try {
inspector = (SourceInspector)
this.manager.lookup(SourceInspector.ROLE);
SourceProperty[] properties =
inspector.getSourceProperties(source);
IncludeXMLConsumer consumer = new
IncludeXMLConsumer(this.contentHandler);
for (int i = 0; i<properties.length; i++) {
SourceProperty property = properties[i];
this.contentHandler.startPrefixMapping("",
properties[i].getNamespace());
properties[i].toSAX(consumer);
this.contentHandler.endPrefixMapping("");
}
} catch (ComponentException ce) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Could not retrieve source inspector", ce);
}
} finally {
if (inspector!=null) {
this.manager.release(inspector);
}
}
this.contentHandler.endElement(SOURCE_NS, PROPERTIES_NODE_NAME,
PROPERTIES_NODE_QNAME);
}
/**
* Push a XML description of all permissions of a source.
*
* @param source Source
*/
private void pushSourcePermissions(RestrictableSource source)
throws SAXException, SourceException {
SourcePermission[] permissions = source.getSourcePermissions();
if ((permissions!=null) && (permissions.length>0)) {
this.contentHandler.startElement(SOURCE_NS,
PERMISSIONS_NODE_NAME,
PERMISSIONS_NODE_QNAME,
new AttributesImpl());
for (int i = 0; i<permissions.length; i++) {
AttributesImpl attributes = new AttributesImpl();
if (permissions[i] instanceof PrincipalSourcePermission) {
attributes.addAttribute("", PRINCIPAL_ATTR_NAME,
PRINCIPAL_ATTR_NAME, "CDATA",
((PrincipalSourcePermission)
permissions[i]).getPrincipal());
} else if (permissions[i] instanceof GroupSourcePermission) {
attributes.addAttribute("", GROUP_ATTR_NAME,
GROUP_ATTR_NAME, "CDATA",
((GroupSourcePermission)
permissions[i]).getGroup());
}
attributes.addAttribute("", PRIVILEGE_ATTR_NAME,
PRIVILEGE_ATTR_NAME, "CDATA",
permissions[i].getPrivilege());
attributes.addAttribute("", INHERITABLE_ATTR_NAME,
INHERITABLE_ATTR_NAME, "CDATA",
String.valueOf(permissions[i].isInheritable()));
attributes.addAttribute("", NEGATIVE_ATTR_NAME,
NEGATIVE_ATTR_NAME, "CDATA",
String.valueOf(permissions[i].isNegative()));
this.contentHandler.startElement(SOURCE_NS,
PERMISSION_NODE_NAME,
PERMISSION_NODE_QNAME,
attributes);
this.contentHandler.endElement(SOURCE_NS,
PERMISSION_NODE_NAME,
PERMISSION_NODE_QNAME);
}
this.contentHandler.endElement(SOURCE_NS, PERMISSIONS_NODE_NAME,
PERMISSIONS_NODE_QNAME);
}
}
/**
* Push a XML description about all locks of a source.
*
* @param source Source
*/
public void pushSourceLocks(LockableSource source)
throws SAXException, SourceException {
Enumeration locks = source.getSourceLocks();
SourceLock lock;
if (locks.hasMoreElements()) {
this.contentHandler.startElement(SOURCE_NS, LOCKS_NODE_NAME,
LOCKS_NODE_QNAME,
new AttributesImpl());
while (locks.hasMoreElements()) {
lock = (SourceLock) locks.nextElement();
AttributesImpl attributes = new AttributesImpl();
attributes = new AttributesImpl();
attributes.addAttribute("", PRINCIPAL_ATTR_NAME,
PRINCIPAL_ATTR_NAME, "CDATA",
lock.getSubject());
attributes.addAttribute("", TYPE_ATTR_NAME, TYPE_ATTR_NAME,
"CDATA", lock.getType());
attributes.addAttribute("", EXPIRATION_ATTR_NAME,
EXPIRATION_ATTR_NAME, "CDATA",
lock.getExpiration().toString());
attributes.addAttribute("", INHERITABLE_ATTR_NAME,
INHERITABLE_ATTR_NAME, "CDATA",
String.valueOf(lock.isInheritable()));
attributes.addAttribute("", EXCLUSIVE_ATTR_NAME,
EXCLUSIVE_ATTR_NAME, "CDATA",
String.valueOf(lock.isExclusive()));
this.contentHandler.startElement(SOURCE_NS, LOCK_NODE_NAME,
LOCK_NODE_QNAME, attributes);
this.contentHandler.endElement(SOURCE_NS, LOCK_NODE_NAME,
LOCK_NODE_QNAME);
}
this.contentHandler.endElement(SOURCE_NS, LOCKS_NODE_NAME,
LOCKS_NODE_QNAME);
}
}
/**
* Recycle this component.
* All instance variables are set to <code>null</code>.
*/
public void recycle() {
Object uri;
for (Enumeration e = cachedsources.keys(); e.hasMoreElements(); ) {
uri = e.nextElement();
this.resolver.release((Source) cachedsources.get(uri));
cachedsources.remove(uri);
}
}
/**
* Release all resources.
*/
public void dispose() {
recycle();
super.dispose();
}
}
1.1
xml-cocoon2/src/blocks/slide/samples/description2html4content.xsl
Index: description2html4content.xsl
===================================================================
<?xml version="1.0"?>
<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:xi="http://www.w3.org/2001/XInclude">
<xsl:output indent="yes"/>
<xsl:param name="cocoon-source-principal">guest</xsl:param>
<xsl:template match="/">
<html>
<head>
<title>Apache Cocoon @version@</title>
<link rel="SHORTCUT ICON" href="favicon.ico"/>
</head>
<body bgcolor="#ffffff" link="#0086b2" vlink="#00698c" alink="#743e75">
<table border="0" cellspacing="2" cellpadding="2" align="center"
width="100%">
<tr>
<td width="*"><font face="arial,helvetica,sanserif" color="#000000">The
Apache Software Foundation is proud to present...</font></td>
<td width="40%" align="center"><img border="0"
src="/cocoon/samples/images/cocoon.gif"/></td>
<td width="30%" align="center"><font face="arial,helvetica,sanserif"
color="#000000"><b>version @version@</b></font></td>
</tr>
<tr>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td width="90%" align="left" bgcolor="#0086b2"><font size="+1"
face="arial,helvetica,sanserif"
color="#ffffff"><xsl:value-of
select="source:source/@source:uri"/></font></td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/users/">
<i>users</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/content/{substring-after(source:source/@source:uri,'://')}">
<i>content</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/properties/{substring-after(source:source/@source:uri,'://')}">
<i>properties</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/permissions/{substring-after(source:source/@source:uri,'://')}">
<i>permissions</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/locks/{substring-after(source:source/@source:uri,'://')}">
<i>locks</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/logout.html">
<i>logout</i></a>
</td>
</tr>
</table>
</tr>
</table>
<xsl:apply-templates select="source:source"/>
<p align="center">
<font size="-1">
Copyright © @year@ <a href="http://www.apache.org/">The Apache
Software Foundation</a>.<br/>
All rights reserved.
</font>
</p>
</body>
</html>
</xsl:template>
<xsl:template match="source:source">
<table width="100%">
<tr>
<td width="200" valign="top">
<table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0"
width="97%">
<tbody>
<tr>
<td>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td bgcolor="#0086b2" width="100%" align="left">
<font size="+1" face="arial,helvetica,sanserif"
color="#ffffff">Navigation</font>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<table bgcolor="#ffffff" border="0" cellspacing="0"
cellpadding="2" width="100%" align="center">
<xsl:if test="@source:parent">
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<a
href="/cocoon/samples/slide/content/{substring-after(@source:parent,'://')}">Back</a>
</td>
</tr>
</xsl:if>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<br/>
</td>
</tr>
<xsl:for-each select="source:children/source:source">
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<font size="+0" face="arial,helvetica,sanserif"
color="#000000">
<a
href="/cocoon/samples/slide/content/{substring-after(@source:uri,'://')}"
><xsl:value-of select="@source:name"/></a>
</font>
</td>
</tr>
</xsl:for-each>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<br/>
</td>
<td valign="top">
<table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0"
width="97%">
<tbody>
<tr>
<td>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td bgcolor="#0086b2" width="100%" align="left">
<font size="+1" face="arial,helvetica,sanserif"
color="#ffffff">Content</font>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<xsl:choose>
<xsl:when test="@source:collection='true'">
<table width="100%" cellspacing="0" cellpadding="5"
align="center">
<font size="+0" face="arial,helvetica,sanserif"
color="#000000">
<tr>
<td align="left"><b>Filename</b></td>
<td align="left"><b>Type</b></td>
<td align="left"><b>Size</b></td>
<td align="left"><b>Last Modified</b></td>
<td align="right"></td>
</tr>
<xsl:for-each select="source:children/source:source">
<tr>
<td align="left">  
<a
href="/cocoon/samples/slide/content/{substring-after(@source:uri,'://')}"
><xsl:value-of select="@source:name"/></a>
</td>
<td align="left"><xsl:value-of
select="@source:mime-type"/></td>
<td align="left"><xsl:value-of
select="@source:contentlength"/></td>
<td align="left"><xsl:value-of
select="source:properties/dav:getlastmodified"/></td>
<td align="right">
<form action="" method="post">
<input type="hidden" name="method"
value="doDeleteSource"/>
<input type="hidden" name="cocoon-source-uri"
value="[EMAIL PROTECTED]:uri}"/>
<input type="submit" name="cocoon-action-deletesource"
value="Delete"/>
</form>
</td>
</tr>
</xsl:for-each>
<tr>
<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="method" value="doUploadSource"/>
<input type="hidden" name="cocoon-source-uri" value="[EMAIL
PROTECTED]:uri}"/>
<td align="left">
<input type="text" name="cocoon-source-name" size="15"
maxlength="40"/>(optional)
</td>
<td align="left" colspan="3">
File:
<input type="file" name="cocoon-upload-file" size="15"
maxlength="40"/>
</td>
<td align="right">
<input type="submit" name="cocoon-action-upload"
value="Upload File" />
</td>
</form>
</tr>
<tr>
<form action="" method="post">
<input type="hidden" name="method"
value="doCreateCollection"/>
<input type="hidden" name="cocoon-source-uri" value="[EMAIL
PROTECTED]:uri}"/>
<td align="left" colspan="4">
<input type="text" name="cocoon-source-name" size="15"
maxlength="40"/>
</td>
<td align="right">
<input type="submit" name="doCreateCollection"
value="Create collection" />
</td>
</form>
</tr>
</font>
</table>
</xsl:when>
<xsl:when test="@source:mime-type='image/gif'">
<img
src="/cocoon/samples/slide/view/{substring-after(@source:uri,'://')}"/>
</xsl:when>
<xsl:when test="@source:mime-type='image/jpeg'">
<img
src="/cocoon/samples/slide/view/{substring-after(@source:uri,'://')}"/>
</xsl:when>
<xsl:when test="@source:mime-type='text/plain'">
<pre>
<xi:include href="[EMAIL
PROTECTED]:uri}?cocoon-source-principal={$cocoon-source-principal}"
parse="text"/>
</pre>
</xsl:when>
<xsl:when test="@source:mime-type='text/xml'">
<pre>
<xi:include href="[EMAIL
PROTECTED]:uri}?cocoon-source-principal={$cocoon-source-principal}"
parse="text"/>
</pre>
</xsl:when>
<xsl:otherwise>
<h3>Could not display content.</h3>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<br/>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
1.1
xml-cocoon2/src/blocks/slide/samples/description2html4locks.xsl
Index: description2html4locks.xsl
===================================================================
<?xml version="1.0"?>
<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:">
<xsl:output indent="yes"/>
<xsl:template match="/">
<html>
<head>
<title>Apache Cocoon @version@</title>
<link rel="SHORTCUT ICON" href="favicon.ico"/>
</head>
<body bgcolor="#ffffff" link="#0086b2" vlink="#00698c" alink="#743e75">
<table border="0" cellspacing="2" cellpadding="2" align="center"
width="100%">
<tr>
<td width="*"><font face="arial,helvetica,sanserif" color="#000000">The
Apache Software Foundation is proud to present...</font></td>
<td width="40%" align="center"><img border="0"
src="/cocoon/samples/images/cocoon.gif"/></td>
<td width="30%" align="center"><font face="arial,helvetica,sanserif"
color="#000000"><b>version @version@</b></font></td>
</tr>
<tr>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td width="90%" align="left" bgcolor="#0086b2"><font size="+1"
face="arial,helvetica,sanserif"
color="#ffffff"><xsl:value-of
select="source:source/@source:uri"/></font></td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/users/">
<i>users</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/content/{substring-after(source:source/@source:uri,'://')}">
<i>content</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/properties/{substring-after(source:source/@source:uri,'://')}">
<i>properties</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/permissions/{substring-after(source:source/@source:uri,'://')}">
<i>permissions</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/locks/{substring-after(source:source/@source:uri,'://')}">
<i>locks</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/logout.html">
<i>logout</i></a>
</td>
</tr>
</table>
</tr>
</table>
<xsl:apply-templates select="source:source"/>
<p align="center">
<font size="-1">
Copyright © @year@ <a href="http://www.apache.org/">The Apache
Software Foundation</a>.<br/>
All rights reserved.
</font>
</p>
</body>
</html>
</xsl:template>
<xsl:template match="source:source">
<table width="100%">
<tr>
<td width="200" valign="top">
<table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0"
width="97%">
<tbody>
<tr>
<td>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td bgcolor="#0086b2" width="100%" align="left">
<font size="+1" face="arial,helvetica,sanserif"
color="#ffffff">Navigation</font>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<table bgcolor="#ffffff" border="0" cellspacing="0"
cellpadding="2" width="100%" align="center">
<xsl:if test="@source:parent">
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<a
href="/cocoon/samples/slide/locks/{substring-after(@source:parent,'://')}">Back</a>
</td>
</tr>
</xsl:if>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<br/>
</td>
</tr>
<xsl:for-each select="source:children/source:source">
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<font size="+0" face="arial,helvetica,sanserif"
color="#000000">
<a
href="/cocoon/samples/slide/locks/{substring-after(@source:uri,'://')}"
><xsl:value-of select="@source:name"/></a>
</font>
</td>
</tr>
</xsl:for-each>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<br/>
</td>
<td valign="top">
<table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0"
width="97%">
<tbody>
<tr>
<td>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td bgcolor="#0086b2" width="100%" align="left">
<font size="+1" face="arial,helvetica,sanserif"
color="#ffffff">Locks</font>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<table bgcolor="#ffffff" border="0" cellspacing="0"
cellpadding="2" width="100%" align="center">
<font size="+0" face="arial,helvetica,sanserif" color="#000000">
<tr>
<td align="left"><b>Subject</b></td>
<td align="left"><b>Type</b></td>
<td align="left"><b>Expiration</b></td>
<td align="left"><b>Inheritable</b></td>
<td align="left"><b>Exclusive</b></td>
<td align="right"></td>
</tr>
<xsl:for-each select="source:locks/source:lock">
<tr bgcolor="#eeeeee">
<td align="left"><xsl:value-of select="@subject"/></td>
<td align="left"><xsl:value-of select="@type"/></td>
<td align="left"><xsl:value-of select="@expiration"/></td>
<td align="left"><xsl:value-of select="@inheritable"/></td>
<td align="left"><xsl:value-of select="@exclusive"/></td>
<td align="right">
<form action="" method="post">
<input type="hidden" name="method" value="doDeleteLock"/>
<input type="hidden" name="cocoon-source-uri"
value="{../../@source:uri}"/>
<input type="hidden" name="cocoon-lock-subject"
value="[EMAIL PROTECTED]"/>
<input type="submit" name="cocoon-action-deletelock"
value="Delete"/>
</form>
</td>
</tr>
</xsl:for-each>
<tr>
<form action="" method="post">
<input type="hidden" name="method" value="doAddLock"/>
<input type="hidden" name="cocoon-source-uri" value="[EMAIL
PROTECTED]:uri}"/>
<td align="left">
<input name="cocoon-lock-subject" type="text" size="20"
maxlength="40"/>
</td>
<td align="left">
<input name="cocoon-lock-type" type="text" size="15"
maxlength="40"/>
</td>
<td align="left">
<input name="cocoon-lock-expiration" type="text" size="15"
maxlength="40"/>
</td>
<td align="left">
<select name="cocoon-lock-inheritable">
<option>true</option>
<option>false</option>
</select>
</td>
<td align="left">
<select name="cocoon-lock-exclusive">
<option>true</option>
<option>false</option>
</select>
</td>
<td align="right">
<input type="submit" name="cocoon-action-addlock"
value="Add/Modify"/>
</td>
</form>
</tr>
</font>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<br/>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
1.1
xml-cocoon2/src/blocks/slide/samples/description2html4permissions.xsl
Index: description2html4permissions.xsl
===================================================================
<?xml version="1.0"?>
<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:pl="http://xml.apache.org/cocoon/PrincipalListGenerator">
<xsl:output indent="yes"/>
<xsl:template match="/">
<html>
<head>
<title>Apache Cocoon @version@</title>
<link rel="SHORTCUT ICON" href="favicon.ico"/>
</head>
<body bgcolor="#ffffff" link="#0086b2" vlink="#00698c" alink="#743e75">
<table border="0" cellspacing="2" cellpadding="2" align="center"
width="100%">
<tr>
<td width="*"><font face="arial,helvetica,sanserif" color="#000000">The
Apache Software Foundation is proud to present...</font></td>
<td width="40%" align="center"><img border="0"
src="/cocoon/samples/images/cocoon.gif"/></td>
<td width="30%" align="center"><font face="arial,helvetica,sanserif"
color="#000000"><b>version @version@</b></font></td>
</tr>
<tr>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td width="90%" align="left" bgcolor="#0086b2"><font size="+1"
face="arial,helvetica,sanserif"
color="#ffffff"><xsl:value-of
select="document/source:source/@source:uri"/></font></td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/users/">
<i>users</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/content/{substring-after(document/source:source/@source:uri,'://')}">
<i>content</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/properties/{substring-after(document/source:source/@source:uri,'://')}">
<i>properties</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/permissions/{substring-after(document/source:source/@source:uri,'://')}">
<i>permissions</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/locks/{substring-after(document/source:source/@source:uri,'://')}">
<i>locks</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/logout.html">
<i>logout</i></a>
</td>
</tr>
</table>
</tr>
</table>
<xsl:apply-templates select="document/source:source"/>
<p align="center">
<font size="-1">
Copyright © @year@ <a href="http://www.apache.org/">The Apache
Software Foundation</a>.<br/>
All rights reserved.
</font>
</p>
</body>
</html>
</xsl:template>
<xsl:template match="source:source">
<table width="100%">
<tr>
<td width="200" valign="top">
<table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0"
width="97%">
<tbody>
<tr>
<td>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td bgcolor="#0086b2" width="100%" align="left">
<font size="+1" face="arial,helvetica,sanserif"
color="#ffffff">Navigation</font>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<table bgcolor="#ffffff" border="0" cellspacing="0"
cellpadding="2" width="100%" align="center">
<xsl:if test="@source:parent">
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<a
href="/cocoon/samples/slide/permissions/{substring-after(@source:parent,'://')}">Back</a>
</td>
</tr>
</xsl:if>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<br/>
</td>
</tr>
<xsl:for-each select="source:children/source:source">
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<font size="+0" face="arial,helvetica,sanserif"
color="#000000">
<a
href="/cocoon/samples/slide/permissions/{substring-after(@source:uri,'://')}"
><xsl:value-of select="@source:name"/></a>
</font>
</td>
</tr>
</xsl:for-each>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<br/>
</td>
<td valign="top">
<table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0"
width="97%">
<tbody>
<tr>
<td>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td bgcolor="#0086b2" width="100%" align="left">
<font size="+1" face="arial,helvetica,sanserif"
color="#ffffff">User permissions</font>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<table bgcolor="#ffffff" border="0" cellspacing="0"
cellpadding="2" width="100%" align="center">
<font size="+0" face="arial,helvetica,sanserif" color="#000000">
<tr>
<td align="left"><b>Principal</b></td>
<td align="left"><b>Privilege</b></td>
<td align="left"><b>Inheritable</b></td>
<td align="left"><b>Deny</b></td>
<td align="right"></td>
</tr>
<xsl:for-each select="source:permissions/source:[EMAIL
PROTECTED]">
<tr>
<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="doRemovePrincipalPermission"/>
<input type="hidden" name="cocoon-source-uri"
value="{../../@source:uri}"/>
<input type="hidden"
name="cocoon-source-permission-principal" value="[EMAIL PROTECTED]"/>
<input type="hidden"
name="cocoon-source-permission-privilege" value="[EMAIL PROTECTED]"/>
<input type="hidden"
name="cocoon-source-permission-inheritable" value="[EMAIL PROTECTED]"/>
<input type="hidden"
name="cocoon-source-permission-negative" value="[EMAIL PROTECTED]"/>
<input type="submit" name="doRemovePrincipalPermission"
value="Delete"/>
</form>
</td>
</tr>
</xsl:for-each>
<tr>
<form action="" method="post">
<input type="hidden" name="method"
value="doAddPrincipalPermission"/>
<input type="hidden" name="cocoon-source-uri" value="[EMAIL
PROTECTED]:uri}"/>
<td align="left">
<select name="cocoon-source-permission-principal">
<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-source-permission-privilege">
<option>all</option>
<option>read</option>
<option>write</option>
<option>read-acl</option>
<option>write-acl</option>
<option>read-source</option>
<option>create-source</option>
<option>remove-source</option>
<option>lock-source</option>
<option>read-locks</option>
<option>read-property</option>
<option>create-property</option>
<option>modify-property</option>
<option>remove-property</option>
<option>read-content</option>
<option>create-content</option>
<option>modify-content</option>
<option>remove-content</option>
<option>grant-permission</option>
<option>revoke-permission</option>
</select>
</td>
<td align="left">
<select name="cocoon-source-permission-inheritable">
<option>true</option>
<option>false</option>
</select>
</td>
<td align="left">
<select name="cocoon-source-permission-negative">
<option>true</option>
<option>false</option>
</select>
</td>
<td align="right">
<input type="submit" name="doAddPrincipalPermission"
value="Add/Modify"/>
</td>
</form>
</tr>
</font>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<br/>
<table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0"
width="97%">
<tbody>
<tr>
<td>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td bgcolor="#0086b2" width="100%" align="left">
<font size="+1" face="arial,helvetica,sanserif"
color="#ffffff">Group permissions</font>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<table bgcolor="#ffffff" border="0" cellspacing="0"
cellpadding="2" width="100%" align="center">
<tr>
<td align="left"><b>Group</b></td>
<td align="left"><b>Privilege</b></td>
<td align="left"><b>Inheritable</b></td>
<td align="left"><b>Deny</b></td>
<td align="right"></td>
</tr>
<xsl:for-each select="source:permissions/source:[EMAIL
PROTECTED]">
<tr>
<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="method"
value="doRemovePrincipalGroupPermission"/>
<input type="hidden" name="cocoon-source-uri"
value="{../../@source:uri}"/>
<input type="hidden"
name="cocoon-source-permission-principal-group" value="[EMAIL PROTECTED]"/>
<input type="hidden"
name="cocoon-source-permission-privilege" value="[EMAIL PROTECTED]"/>
<input type="hidden"
name="cocoon-source-permission-inheritable" value="[EMAIL PROTECTED]"/>
<input type="hidden"
name="cocoon-source-permission-negative" value="[EMAIL PROTECTED]"/>
<input type="submit" name="doRemovePrincipalGroupPermission"
value="Delete"/>
</form>
</td>
</tr>
</xsl:for-each>
<tr>
<form action="" method="post">
<input type="hidden" name="method"
value="doAddPrincipalGroupPermission"/>
<input type="hidden" name="cocoon-source-uri" value="[EMAIL
PROTECTED]:uri}"/>
<td align="left">
<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="cocoon-source-permission-privilege">
<option>all</option>
<option>read</option>
<option>write</option>
<option>read-acl</option>
<option>write-acl</option>
<option>read-source</option>
<option>create-source</option>
<option>remove-source</option>
<option>lock-source</option>
<option>read-locks</option>
<option>read-property</option>
<option>create-property</option>
<option>modify-property</option>
<option>remove-property</option>
<option>read-content</option>
<option>create-content</option>
<option>modify-content</option>
<option>remove-content</option>
<option>grant-permission</option>
<option>revoke-permission</option>
</select>
</td>
<td align="left">
<select name="cocoon-source-permission-inheritable">
<option>true</option>
<option>false</option>
</select>
</td>
<td align="left">
<select name="cocoon-source-permission-negative">
<option>true</option>
<option>false</option>
</select>
</td>
<td align="right">
<input type="submit" name="doAddPrincipalPermission"
value="Add/Modify"/>
</td>
</form>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
1.1
xml-cocoon2/src/blocks/slide/samples/description2html4properties.xsl
Index: description2html4properties.xsl
===================================================================
<?xml version="1.0"?>
<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:">
<xsl:output indent="yes"/>
<xsl:template match="/">
<html>
<head>
<title>Apache Cocoon @version@</title>
<link rel="SHORTCUT ICON" href="favicon.ico"/>
</head>
<body bgcolor="#ffffff" link="#0086b2" vlink="#00698c" alink="#743e75">
<table border="0" cellspacing="2" cellpadding="2" align="center"
width="100%">
<tr>
<td width="*"><font face="arial,helvetica,sanserif" color="#000000">The
Apache Software Foundation is proud to present...</font></td>
<td width="40%" align="center"><img border="0"
src="/cocoon/samples/images/cocoon.gif"/></td>
<td width="30%" align="center"><font face="arial,helvetica,sanserif"
color="#000000"><b>version @version@</b></font></td>
</tr>
<tr>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td width="90%" align="left" bgcolor="#0086b2"><font size="+1"
face="arial,helvetica,sanserif"
color="#ffffff"><xsl:value-of
select="source:source/@source:uri"/></font></td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/users/">
<i>users</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/content/{substring-after(source:source/@source:uri,'://')}">
<i>content</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/properties/{substring-after(source:source/@source:uri,'://')}">
<i>properties</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/permissions/{substring-after(source:source/@source:uri,'://')}">
<i>permissions</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/locks/{substring-after(source:source/@source:uri,'://')}">
<i>locks</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/logout.html">
<i>logout</i></a>
</td>
</tr>
</table>
</tr>
</table>
<xsl:apply-templates select="source:source"/>
<p align="center">
<font size="-1">
Copyright © @year@ <a href="http://www.apache.org/">The Apache
Software Foundation</a>.<br/>
All rights reserved.
</font>
</p>
</body>
</html>
</xsl:template>
<xsl:template match="source:source">
<table width="100%">
<tr>
<td width="200" valign="top">
<table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0"
width="97%">
<tbody>
<tr>
<td>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td bgcolor="#0086b2" width="100%" align="left">
<font size="+1" face="arial,helvetica,sanserif"
color="#ffffff">Navigation</font>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<table bgcolor="#ffffff" border="0" cellspacing="0"
cellpadding="2" width="100%" align="center">
<xsl:if test="@source:parent">
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<a
href="/cocoon/samples/slide/properties/{substring-after(@source:parent,'://')}">Back</a>
</td>
</tr>
</xsl:if>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<br/>
</td>
</tr>
<xsl:for-each select="source:children/source:source">
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<font size="+0" face="arial,helvetica,sanserif"
color="#000000">
<a
href="/cocoon/samples/slide/properties/{substring-after(@source:uri,'://')}"
><xsl:value-of select="@source:name"/></a>
</font>
</td>
</tr>
</xsl:for-each>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<br/>
</td>
<td valign="top">
<table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0"
width="97%">
<tbody>
<tr>
<td>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td bgcolor="#0086b2" width="100%" align="left">
<font size="+1" face="arial,helvetica,sanserif"
color="#ffffff">Properties</font>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<table bgcolor="#ffffff" border="0" cellspacing="0"
cellpadding="2" width="100%" align="center">
<font size="+0" face="arial,helvetica,sanserif" color="#000000">
<tr>
<td align="left"><b>Namespace</b></td>
<td align="left"><b>Name</b></td>
<td align="left"><b>Value</b></td>
<td align="right"></td>
</tr>
<xsl:for-each
select="source:properties/*[local-name()!='children' and
local-name()!='permissions' and local-name()!='locks' and
local-name()!='parent']">
<tr>
<td align="left"><xsl:value-of select="namespace-uri(.)"/></td>
<td align="left"><xsl:value-of select="local-name(.)"/></td>
<td align="left"><xsl:value-of select="."/></td>
<td align="right">
<xsl:if test="namespace-uri()!='DAV:' and
../@source:type='live'">
<form action="" method="post">
<input type="hidden" name="method"
value="doDeleteProperty"/>
<input type="hidden" name="cocoon-source-uri"
value="{../../@source:uri}"/>
<input type="hidden"
name="cocoon-source-property-namespace" value="{namespace-uri()}"/>
<input type="hidden" name="cocoon-source-property-name"
value="{local-name()}"/>
<input type="submit" name="cocoon-action-deleteproperty"
value="Delete"/>
</form>
</xsl:if>
</td>
</tr>
</xsl:for-each>
<tr>
<form action="" method="post">
<input type="hidden" name="method" value="doAddProperty"/>
<input type="hidden" name="cocoon-source-uri" value="[EMAIL
PROTECTED]:uri}"/>
<td align="left">
<input name="cocoon-source-property-namespace" type="text"
size="15" maxlength="40"/>
</td>
<td align="left">
<input name="cocoon-source-property-name" type="text"
size="15" maxlength="40"/>
</td>
<td align="left">
<input name="cocoon-source-property-value" type="text"
size="15" maxlength="40"/>
</td>
<td align="right">
<input type="submit" name="cocoon-action-addproperty"
value="Add/Modify"/>
</td>
</form>
</tr>
</font>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<br/>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
1.1 xml-cocoon2/src/blocks/slide/samples/login-failed.html
Index: login-failed.html
===================================================================
<?xml version="1.0"?>
<html>
<head>
<title>Apache Cocoon 2.1-dev</title>
<link rel="SHORTCUT ICON" href="favicon.ico"/>
</head>
<body bgcolor="#ffffff" link="#0086b2" vlink="#00698c" alink="#743e75">
<table border="0" cellspacing="2" cellpadding="2" align="center"
width="100%">
<tr>
<td width="*"><font face="arial,helvetica,sanserif" color="#000000">The
Apache Software Foundation is proud to present...</font></td>
<td width="40%" align="center"><img border="0"
src="/cocoon/samples/images/cocoon.gif"/></td>
<td width="30%" align="center"><font face="arial,helvetica,sanserif"
color="#000000"><b>version 2.1-dev</b></font></td>
</tr>
<tr>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td width="95%" align="left" bgcolor="#0086b2">
<br/>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a href="..">
<i>back</i></a>
</td>
</tr>
</table>
</tr>
</table>
<table width="200" align="center">
<tr>
<td valign="top">
<table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0"
width="97%">
<tbody>
<tr>
<td>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td bgcolor="#0086b2" width="100%" align="left">
<font size="+1" face="arial,helvetica,sanserif"
color="#ffffff">Login</font>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<table bgcolor="#ffffff" border="0" cellspacing="0"
cellpadding="2" width="100%" align="center">
<form action="login" method="post">
<input type="hidden" name="resource" value="content/"/>
<tr>
<td>Username</td>
<td><input name="userid" type="text" size="15"
maxlength="40"/></td>
</tr>
<tr>
<td>Password</td>
<td><input name="password" type="password" size="15"
maxlength="40"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="cocoon-login"
value="Login"/></td>
</tr>
<tr>
<td></td>
<td>Login failed!</td>
</tr>
<tr>
<td></td>
<td>Try root,root or john,john</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<br/>
</td>
</tr>
</table>
<p align="center">
<font size="-1">
Copyright © 1999-2002 <a href="http://www.apache.org/">The Apache
Software Foundation</a>.<br/>
All rights reserved.
</font>
</p>
</body>
</html>
1.1 xml-cocoon2/src/blocks/slide/samples/login.html
Index: login.html
===================================================================
<?xml version="1.0"?>
<html>
<head>
<title>Apache Cocoon 2.1-dev</title>
<link rel="SHORTCUT ICON" href="favicon.ico"/>
</head>
<body bgcolor="#ffffff" link="#0086b2" vlink="#00698c" alink="#743e75">
<table border="0" cellspacing="2" cellpadding="2" align="center"
width="100%">
<tr>
<td width="*"><font face="arial,helvetica,sanserif" color="#000000">The
Apache Software Foundation is proud to present...</font></td>
<td width="40%" align="center"><img border="0"
src="/cocoon/samples/images/cocoon.gif"/></td>
<td width="30%" align="center"><font face="arial,helvetica,sanserif"
color="#000000"><b>version 2.1-dev</b></font></td>
</tr>
<tr>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td width="95%" align="left" bgcolor="#0086b2">
<br/>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a href="..">
<i>back</i></a>
</td>
</tr>
</table>
</tr>
</table>
<table width="200" align="center">
<tr>
<td valign="top">
<table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0"
width="97%">
<tbody>
<tr>
<td>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td bgcolor="#0086b2" width="100%" align="left">
<font size="+1" face="arial,helvetica,sanserif"
color="#ffffff">Login</font>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<table bgcolor="#ffffff" border="0" cellspacing="0"
cellpadding="2" width="100%" align="center">
<form action="login" method="post">
<input type="hidden" name="resource" value="content/"/>
<tr>
<td>Username</td>
<td><input name="userid" type="text" size="15"
maxlength="40"/></td>
</tr>
<tr>
<td>Password</td>
<td><input name="password" type="password" size="15"
maxlength="40"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="cocoon-login"
value="Login"/></td>
</tr>
<tr>
<td></td>
<td>Try root,root or john,john</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<br/>
</td>
</tr>
</table>
<p align="center">
<font size="-1">
Copyright © 1999-2002 <a href="http://www.apache.org/">The Apache
Software Foundation</a>.<br/>
All rights reserved.
</font>
</p>
</body>
</html>
1.1 xml-cocoon2/src/blocks/slide/samples/logout.html
Index: logout.html
===================================================================
<?xml version="1.0"?>
<html>
<head>
<title>Apache Cocoon @version@</title>
<link rel="SHORTCUT ICON" href="favicon.ico"/>
</head>
<body bgcolor="#ffffff" link="#0086b2" vlink="#00698c" alink="#743e75">
<table border="0" cellspacing="2" cellpadding="2" align="center"
width="100%">
<tr>
<td width="*"><font face="arial,helvetica,sanserif" color="#000000">The
Apache Software Foundation is proud to present...</font></td>
<td width="40%" align="center"><img border="0"
src="/cocoon/samples/images/cocoon.gif"/></td>
<td width="30%" align="center"><font face="arial,helvetica,sanserif"
color="#000000"><b>version @version@</b></font></td>
</tr>
<tr>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td width="95%" align="left" bgcolor="#0086b2">
<br/>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/login.html">
<i>login</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a href="..">
<i>back</i></a>
</td>
</tr>
</table>
</tr>
</table>
<table width="200" align="center">
<tr>
<td valign="top">
<table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0"
width="97%">
<tbody>
<tr>
<td>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td bgcolor="#0086b2" width="100%" align="left">
<font size="+1" face="arial,helvetica,sanserif"
color="#ffffff">Logout</font>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<table bgcolor="#ffffff" border="0" cellspacing="0"
cellpadding="2" width="100%" align="center">
<tr>
<td>Good bye.</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<br/>
</td>
</tr>
</table>
<p align="center">
<font size="-1">
Copyright © @year@ <a href="http://www.apache.org/">The Apache
Software Foundation</a>.<br/>
All rights reserved.
</font>
</p>
</body>
</html>
1.1 xml-cocoon2/src/blocks/slide/samples/principal2auth.xsl
Index: principal2auth.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:pl="http://xml.apache.org/cocoon/PrincipalListGenerator">
<xsl:param name="name"/>
<xsl:param name="password"/>
<xsl:template match="pl:list">
<authentication>
<xsl:apply-templates select="pl:principal"/>
</authentication>
</xsl:template>
<xsl:template match="pl:principal">
<xsl:if test="normalize-space(@name) = $name and normalize-space(@password)
= $password">
<ID><xsl:value-of select="@name"/></ID>
<role><xsl:value-of select="@role"/></role>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
1.1
xml-cocoon2/src/blocks/slide/samples/principal2html4users.xsl
Index: principal2html4users.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:pl="http://xml.apache.org/cocoon/PrincipalListGenerator">
<xsl:output indent="yes"/>
<xsl:template match="/">
<html>
<head>
<title>Apache Cocoon @version@</title>
<link rel="SHORTCUT ICON" href="favicon.ico"/>
</head>
<body bgcolor="#ffffff" link="#0086b2" vlink="#00698c" alink="#743e75">
<table border="0" cellspacing="2" cellpadding="2" align="center"
width="100%">
<tr>
<td width="*"><font face="arial,helvetica,sanserif" color="#000000">The
Apache Software Foundation is proud to present...</font></td>
<td width="40%" align="center"><img border="0"
src="/cocoon/samples/images/cocoon.gif"/></td>
<td width="30%" align="center"><font face="arial,helvetica,sanserif"
color="#000000"><b>version @version@</b></font></td>
</tr>
<tr>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td width="90%" align="left" bgcolor="#0086b2"><font size="+1"
face="arial,helvetica,sanserif"
color="#ffffff">User management</font></td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/users/">
<i>users</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/content/">
<i>content</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/properties/">
<i>properties</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/permissions/">
<i>permissions</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/locks/">
<i>locks</i></a>
</td>
<td nowrap="nowrap" bgcolor="#ffffff"><a
href="/cocoon/samples/slide/logout.html">
<i>logout</i></a>
</td>
</tr>
</table>
</tr>
</table>
<xsl:apply-templates select="pl:list"/>
<p align="center">
<font size="-1">
Copyright © @year@ <a href="http://www.apache.org/">The Apache
Software Foundation</a>.<br/>
All rights reserved.
</font>
</p>
</body>
</html>
</xsl:template>
<xsl:template match="pl:list">
<table width="100%">
<tr>
<td width="60%" valign="top">
<table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0"
width="97%">
<tbody>
<tr>
<td>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td bgcolor="#0086b2" width="100%" align="left">
<font size="+1" face="arial,helvetica,sanserif"
color="#ffffff">Users</font>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<table bgcolor="#ffffff" border="0" cellspacing="0"
cellpadding="2" width="100%" align="center">
<font size="+0" face="arial,helvetica,sanserif" color="#000000">
<tr>
<td align="left"><b>User</b></td>
<td align="left"></td>
<td align="left"><b>Role</b></td>
<td align="left"><b>Groups</b></td>
<td align="left"></td>
<td align="right"></td>
</tr>
<xsl:for-each select="pl:principal">
<tr>
<form action="" method="post">
<input type="hidden" name="cocoon-principal-name"
value="[EMAIL PROTECTED]"/>
<input type="hidden" name="method" value="doRemovePrincipal"/>
<td align="left">
<xsl:value-of select="@name"/>
</td>
<td align="left">
<input type="submit" name="cocoon-action-deleteprincipal"
value="Delete user"/>
</td>
</form>
<td align="left"><xsl:value-of select="@role"/></td>
<form action="" method="post">
<input type="hidden" name="cocoon-principal-name"
value="[EMAIL PROTECTED]"/>
<input type="hidden" name="method"
value="doRemovePrincipalGroupMember"/>
<td align="left">
<xsl:variable name="name" select="@name"/>
<select name="cocoon-principal-group-name"
size="{count(../pl:group/pl:[EMAIL PROTECTED])}">
<xsl:for-each select="../pl:group/pl:[EMAIL PROTECTED]">
<option><xsl:value-of select="../@name"/></option>
</xsl:for-each>
</select>
</td>
<td align="left">
<input type="submit" name="cocoon-action-removemember"
value="Remove group"/>
</td>
</form>
</tr>
<tr>
<td align="left"></td>
<td align="left"></td>
<td align="left"></td>
<form action="" method="post">
<input type="hidden" name="cocoon-principal-name"
value="[EMAIL PROTECTED]"/>
<input type="hidden" name="method"
value="doAddPrincipalGroupMember"/>
<td align="left">
<xsl:variable name="name" select="@name"/>
<select name="cocoon-principal-group-name" size="1">
<xsl:for-each select="../pl:group">
<option><xsl:value-of select="@name"/></option>
</xsl:for-each>
</select>
</td>
<td align="left">
<input type="submit" name="cocoon-action-addmember"
value="Add group"/>
</td>
</form>
</tr>
</xsl:for-each>
<tr>
<form action="" method="post">
<input type="hidden" name="method" value="doAddPrincipal"/>
<td align="left">
<input name="cocoon-principal-name" type="text" size="10"
maxlength="40"/>
</td>
<td align="left"></td>
<td align="left">
<input name="cocoon-principal-role" type="text" size="10"
maxlength="40"/>
</td>
<td align="left">Password:</td>
<td align="left">
<input name="cocoon-principal-password" type="text"
size="10" maxlength="40"/>
</td>
<td align="right">
<input type="submit" name="cocoon-action-addprincipal"
value="Add user"/>
</td>
</form>
</tr>
</font>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<br/>
</td>
<td valign="top">
<table border="0" bgcolor="#000000" cellpadding="0" cellspacing="0"
width="97%">
<tbody>
<tr>
<td>
<table bgcolor="#000000" border="0" cellspacing="2" cellpadding="2"
align="center" width="100%">
<tr>
<td bgcolor="#0086b2" width="100%" align="left">
<font size="+1" face="arial,helvetica,sanserif"
color="#ffffff">Groups</font>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#ffffff" align="left">
<table bgcolor="#ffffff" border="0" cellspacing="0"
cellpadding="2" width="100%" align="center">
<font size="+0" face="arial,helvetica,sanserif" color="#000000">
<tr>
<td align="left"><b>Group</b></td>
<td align="right"></td>
</tr>
<xsl:for-each select="pl:group">
<tr>
<form action="" method="post">
<input type="hidden" name="cocoon-principal-group-name"
value="[EMAIL PROTECTED]"/>
<input type="hidden" name="method"
value="doRemovePrincipalGroup"/>
<td align="left">
<xsl:value-of select="@name"/>
</td>
<td align="right">
<input type="submit" name="cocoon-action-deletegroup"
value="Delete group"/>
</td>
</form>
</tr>
</xsl:for-each>
<tr>
<form action="" method="post">
<input type="hidden" name="method"
value="doAddPrincipalGroup"/>
<td align="left">
<input name="cocoon-principal-group-name" type="text"
size="15" maxlength="40"/>
</td>
<td align="right">
<input type="submit" name="cocoon-action-addgroup"
value="Add group"/>
</td>
</form>
</tr>
</font>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<br/>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
1.1 xml-cocoon2/src/blocks/slide/samples/redirect4login.xsl
Index: redirect4login.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- <xsl:param name="destination">content/</xsl:param>-->
<xsl:param name="destination">bla</xsl:param>
<xsl:template match="[EMAIL PROTECTED]">
<input type="hidden" name="resource" value="{$destination}"/>
</xsl:template>
<xsl:template match="@*|*|text()|processing-instruction()" priority="-1">
<xsl:copy>
<xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
1.1 xml-cocoon2/src/blocks/slide/samples/sitemap.xmap
Index: sitemap.xmap
===================================================================
<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<!-- =========================== Components
=================================== -->
<map:components>
<map:generators default="file">
<map:generator name="sourcedescription"
src="org.apache.cocoon.generation.SourceDescriptionGenerator"
logger="sitemap.generator.sourcedescription"
label="content"/>
<map:generator name="principallist"
src="org.apache.cocoon.generation.PrincipalListGenerator"
logger="sitemap.generator.principallist"
label="content"/>
</map:generators>
<map:transformers default="xslt">
<map:transformer name="session" logger="sitemap.transformer.session"
src="org.apache.cocoon.webapps.session.transformation.SessionTransformer"/>
<map:transformer logger="sitemap.transformer.write-source"
name="write-source"
src="org.apache.cocoon.transformation.SourceWritingTransformer"/>
<map:transformer logger="sitemap.transformer.xinclude" name="xinclude"
src="org.apache.cocoon.transformation.XIncludeTransformer"/>
<map:transformer name="log"
src="org.apache.cocoon.transformation.LogTransformer"/>
</map:transformers>
<map:readers default="resource"/>
<map:serializers default="html">
<map:serializer logger="sitemap.serializer.xml" mime-type="text/xml"
name="xml"
src="org.apache.cocoon.serialization.XMLSerializer"/>
<map:serializer logger="sitemap.serializer.html" mime-type="text/html"
name="html"
pool-grow="4" pool-max="32" pool-min="4"
src="org.apache.cocoon.serialization.HTMLSerializer">
<buffer-size>1024</buffer-size>
</map:serializer>
</map:serializers>
<map:matchers default="wildcard"/>
<map:selectors default="browser"/>
<map:actions>
<map:action logger="sitemap.action.slide" name="source-actions"
src="org.apache.cocoon.acting.SourceMultiAction"/>
<map:action logger="sitemap.action.slide" name="principal-actions"
src="org.apache.cocoon.acting.PrincipalMultiAction"/>
<map:action name="auth-protect" logger="sitemap.action.auth-protect"
src="org.apache.cocoon.webapps.authentication.acting.AuthAction"/>
<map:action name="auth-login" logger="sitemap.action.auth-login"
src="org.apache.cocoon.webapps.authentication.acting.LoginAction"/>
<map:action name="auth-logout" logger="sitemap.action.auth-logout"
src="org.apache.cocoon.webapps.authentication.acting.LogoutAction"/>
<map:action name="auth-loggedIn" logger="sitemap.action.auth-loggedIn"
src="org.apache.cocoon.webapps.authentication.acting.LoggedInAction"/>
</map:actions>
</map:components>
<!-- =========================== Views =================================== -->
<map:views>
<map:view name="content" from-label="content">
<map:transform
src="context://samples/common/style/xsl/html/simple-xml2html.xsl"/>
<map:serialize type="html">
<encoding>ASCII</encoding>
</map:serialize>
</map:view>
<map:view name="xml" from-label="content">
<map:serialize type="xml">
<encoding>ASCII</encoding>
</map:serialize>
</map:view>
</map:views>
<!-- =========================== Resources
=================================== -->
<map:resources>
<map:resource name="description">
<map:generate type="sourcedescription"
src="slide://{1}?cocoon-source-principal={../../ID}">
<map:parameter name="repository" value="slide"/>
<map:parameter name="namespace" value="myrepository"/>
<map:parameter name="properties" value="true"/>
<map:parameter name="permissions" value="true"/>
<map:parameter name="locks" value="true"/>
<map:parameter name="depth" value="1"/>
</map:generate>
</map:resource>
</map:resources>
<!-- =========================== Pipelines =================================
-->
<map:pipelines>
<map:component-configurations>
<authentication-manager>
<handlers>
<handler name="slidehandler"
xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<redirect-to uri="cocoon://samples/slide/login.html"/>
<authentication uri="cocoon:raw:/authenticate"/>
</handler>
</handlers>
</authentication-manager>
</map:component-configurations>
<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="authenticate">
<map:generate src="cocoon:/principallist"/>
<map:transform type="xslt" src="principal2auth.xsl"> <!-- stylesheets
seems to have a problem with XSLTC -->
<map:parameter name="use-request-parameters" value="true"/>
</map:transform>
<map:serialize type="xml"/>
</map:match>
<!-- ============= Source description ============= -->
<map:match pattern="description/*/**">
<map:generate type="sourcedescription"
src="slide://{2}?cocoon-source-principal={1}">
<map:parameter name="repository" value="slide"/>
<map:parameter name="namespace" value="myrepository"/>
<map:parameter name="properties" value="true"/>
<map:parameter name="permissions" value="true"/>
<map:parameter name="locks" value="true"/>
<map:parameter name="depth" value="1"/>
</map:generate>
<map:serialize type="xml"/>
</map:match>
<!-- <map:handle-errors>
<map:transform
src="context://samples/common/style/xsl/html/error2html.xsl"/>
<map:serialize status-code="500"/>
</map:handle-errors>-->
</map:pipeline>
<map:pipeline>
<map:match pattern="">
<map:redirect-to uri="content/"/>
</map:match>
<map:match pattern="login.html">
<map:generate src="login.html"/>
<map:transform src="redirect4login.xsl">
<map:parameter name="destination" value="{request-param:resource}"/>
</map:transform>
<map:serialize/>
</map:match>
<map:match pattern="login">
<map:act type="auth-login">
<map:parameter name="handler" value="slidehandler"/>
<map:parameter name="parameter_name" value="{request-param:userid}"/>
<map:parameter name="parameter_password"
value="{request-param:password}"/>
<map:redirect-to uri="{request-param:resource}"/>
</map:act>
<map:generate src="login-failed.html"/>
<map:transform src="redirect4login.xsl">
<map:parameter name="destination" value="{request-param:resource}"/>
</map:transform>
<map:serialize/>
</map:match>
<map:match pattern="logout.html">
<map:act type="auth-logout">
<map:parameter name="handler" value="slidehandler"/>
<map:read src="logout.html"/>
</map:act>
<map:redirect-to uri="login.html"/>
</map:match>
<map:match pattern="**">
<map:act type="auth-protect">
<map:parameter name="handler" value="slidehandler"/>
<!-- ============= Source content ================== -->
<map:match pattern="content/**">
<map:act type="source-actions">
<map:parameter name="method" value="{request-param:method}"/>
<map:parameter name="cocoon-source-principal" value="{../ID}"/>
</map:act>
<map:generate src="cocoon:/description/{../ID}/{1}"/>
<map:transform src="description2html4content.xsl">
<map:parameter name="cocoon-source-principal" value="{../ID}"/>
</map:transform>
<map:transform type="xinclude"/>
<map:serialize type="html"/>
</map:match>
<!-- ============= Source properties =============== -->
<map:match pattern="properties/**">
<map:act type="source-actions">
<map:parameter name="method" value="{request-param:method}"/>
<map:parameter name="cocoon-source-principal" value="{../ID}"/>
</map:act>
<map:generate src="cocoon:/description/{../ID}/{1}"/>
<map:transform src="description2html4properties.xsl"/>
<map:serialize type="html"/>
</map:match>
<!-- ============= Source permissions ============== -->
<map:match pattern="permissions/**">
<map:act type="source-actions">
<map:parameter name="method" value="{request-param:method}"/>
<map:parameter name="cocoon-source-principal" value="{../ID}"/>
</map:act>
<map:aggregate element="document">
<map:part src="cocoon:/description/{../ID}/{1}"/>
<map:part src="cocoon:/principallist"/>
</map:aggregate>
<map:transform src="description2html4permissions.xsl"/>
<map:serialize type="html"/>
</map:match>
<!-- ============= Source locks ==================== -->
<map:match pattern="locks/**">
<map:act type="source-actions">
<map:parameter name="method" value="{request-param:method}"/>
<map:parameter name="cocoon-source-principal" value="{../ID}"/>
</map:act>
<map:generate src="cocoon:/description/{../ID}/{1}"/>
<map:transform src="description2html4locks.xsl"/>
<map:serialize type="html"/>
</map:match>
<!-- ============= Source direct ================== -->
<map:match pattern="view/**">
<map:read src="slide://{1}?cocoon-source-principal={../ID}"/>
</map:match>
<!-- ============= Repository users =============== -->
<map:match pattern="users/**">
<map:act type="principal-actions">
<map:parameter name="method" value="{request-param:method}"/>
<map:parameter name="cocoon-caller-principal-name" value="{../ID}"/>
</map:act>
<map:generate type="principallist">
<map:parameter name="principalprovider" value="slide"/>
<map:parameter name="principalcaller" value="{../ID}"/>
</map:generate>
<map:transform src="principal2html4users.xsl"/>
<map:serialize type="html"/>
</map:match>
</map:act>
</map:match>
<map:handle-errors>
<map:transform
src="context://samples/common/style/xsl/html/error2html.xsl"/>
<map:serialize status-code="500"/>
</map:handle-errors>
</map:pipeline>
</map:pipelines>
</map:sitemap>
1.1 xml-cocoon2/src/blocks/slide/samples/slide.xconf
Index: slide.xconf
===================================================================
<?xml version="1.0"?>
<slide logger="org.apache.slide.util.logger.SimpleLogger" logger-level="6"
default="myrepository">
<!--
logger
~~~~~~
org.apache.slide.util.logger.SimpleLogger
default logger with 1 log level
log4j.Log4jLogger
logger with fine granularity
see http://jakarta.apache.org/log4j/
logger-level
~~~~~~~~~~~~
0 EMERGENCY
1 CRITICAL
2 ERROR
4 WARNING
6 INFO
7 DEBUG
-->
<namespace name="myrepository">
<definition>
<!-- ### Memory Configuration ###
The following memory configuration uses the
MemoryDescriptorsStore for
node, security, locks and revisions. For content the
FileContentStore
is used. Content is reset before start.
-->
<store name="memory">
<nodestore
classname="slidestore.reference.MemoryDescriptorsStore"/>
<securitystore>
<reference store="nodestore"/>
</securitystore>
<lockstore>
<reference store="nodestore"/>
</lockstore>
<revisiondescriptorsstore>
<reference store="nodestore"/>
</revisiondescriptorsstore>
<revisiondescriptorstore>
<reference store="nodestore"/>
</revisiondescriptorstore>
<contentstore
classname="slidestore.reference.FileContentStore">
<parameter name="rootpath">contentstore</parameter>
<parameter name="version">false</parameter>
<parameter name="resetBeforeStarting">true</parameter>
</contentstore>
</store>
<!-- ### JDBC Configuration ###
The following jdbc sample configuration uses the hsql Database
Engine
a relational database engine written in Java, for more info:
http://hsqldb.sourceforge.net/
-->
<!--
<store name="jdbc">
<nodestore
classname="slidestore.reference.JDBCDescriptorsStore">
<parameter name="driver">org.hsqldb.jdbcDriver</parameter>
<parameter
name="url">jdbc:hsqldb:slidestructure</parameter>
<parameter name="user">sa</parameter>
<parameter name="password"></parameter>
</nodestore>
<securitystore>
<reference store="nodestore" />
</securitystore>
<lockstore>
<reference store="nodestore" />
</lockstore>
<revisiondescriptorsstore>
<reference store="nodestore" />
</revisiondescriptorsstore>
<revisiondescriptorstore>
<reference store="nodestore" />
</revisiondescriptorstore>
<contentstore
classname="slidestore.reference.JDBCContentStore">
<parameter name="driver">org.hsqldb.jdbcDriver</parameter>
<parameter name="url">jdbc:hsqldb:slidecontent</parameter>
<parameter name="user">sa</parameter>
<parameter name="password"></parameter>
</contentstore>
</store>
-->
<!-- ### MySQL Configuration ###
The following jdbc sample configuration uses the MySQL Database.
-->
<!--
<store name="mysql">
<nodestore classname="slidestore.mysql.MySQLDescriptorsStore">
<parameter
name="driver">org.gjt.mm.mysql.Driver</parameter>
<parameter
name="url">jdbc:mysql://localhost/myDB</parameter>
<parameter name="user">cocoon</parameter>
<parameter name="password">cocoon</parameter>
</nodestore>
<securitystore>
<reference store="nodestore" />
</securitystore>
<lockstore>
<reference store="nodestore" />
</lockstore>
<revisiondescriptorsstore>
<reference store="nodestore" />
</revisiondescriptorsstore>
<revisiondescriptorstore>
<reference store="nodestore" />
</revisiondescriptorstore>
<contentstore classname="slidestore.mysql.MySQLContentStore">
<parameter
name="driver">org.gjt.mm.mysql.Driver</parameter>
<parameter
name="url">jdbc:mysql://localhost/myDB</parameter>
<parameter name="user">cocoon</parameter>
<parameter name="password">cocoon</parameter>
</contentstore>
</store>
-->
<!-- ### Mixed JDBC - Filesystem ###
stores: slidestore.reference.JDBCDescriptorsStore
slidestore.reference.FileContentStore
!!! set resetBeforeStarting parameter for FileContentStore to
false !!!
-->
<!-- ### Cloudscape configuration (embedded database) ###
stores: slidestore.cloudscape.CloudscapeDescriptorsStore
slidestore.cloudscape.CloudscapeContentStore
driver: COM.cloudscape.core.JDBCDriver
url: jdbc:cloudscape:slidestructure;create=true
jdbc:cloudscape:slidecontent;create=true
-->
<!-- ### Oracle configuration (thin driver) ###
stores: slidestore.reference.JDBCDescriptorsStore
slidestore.oracle.OracleContentStore
driver: oracle.jdbc.OracleDriver
url: jdbc:oracle:thin:@localhost:1521:slide
-->
<!-- ### XML Configuration ###
The following XML configuration uses the XMLDescriptorsStore for
node, security, locks and revisions. For content the
FileContentStore
is used.
-->
<!--
<store name="xml">
<nodestore
classname="slidestore.file.XMLFileDescriptorsStore">
<parameter name="rootpath">slide</parameter>
</nodestore>
<securitystore>
<reference store="nodestore" />
</securitystore>
<lockstore>
<reference store="nodestore" />
</lockstore>
<revisiondescriptorsstore>
<reference store="nodestore" />
</revisiondescriptorsstore>
<revisiondescriptorstore>
<reference store="nodestore" />
</revisiondescriptorstore>
<contentstore
classname="slidestore.reference.FileContentStore">
<parameter name="rootpath">slide</parameter>
<parameter name="version">false</parameter>
<parameter name="resetBeforeStarting">false</parameter>
</contentstore>
</store>
-->
<scope match="/" store="memory"/>
</definition>
<configuration>
<!-- Actions mapping -->
<default-action>/actions</default-action>
<read-object>/actions/read</read-object>
<create-object>/actions/write</create-object>
<remove-object>/actions/write</remove-object>
<grant-permission>/actions/manage</grant-permission>
<revoke-permission>/actions/manage</revoke-permission>
<read-permissions>/actions/manage</read-permissions>
<lock-object>/actions/write</lock-object>
<kill-lock>/actions/manage</kill-lock>
<read-locks>/actions/read</read-locks>
<read-revision-metadata>/actions/read</read-revision-metadata>
<create-revision-metadata>/actions/write</create-revision-metadata>
<modify-revision-metadata>/actions/write</modify-revision-metadata>
<remove-revision-metadata>/actions/write</remove-revision-metadata>
<read-revision-content>/actions/read</read-revision-content>
<create-revision-content>/actions/write</create-revision-content>
<modify-revision-content>/actions/write</modify-revision-content>
<remove-revision-content>/actions/write</remove-revision-content>
<!-- Paths configuration -->
<userspath>/users</userspath>
<guestpath>guest</guestpath>
<filespath>/files</filespath>
<parameter name="dav">true</parameter>
<parameter name="standalone">true</parameter>
<!-- Roles definition -->
<role name="root">slideroles.basic.RootRole</role>
<role name="user">slideroles.basic.UserRole</role>
<role name="guest">slideroles.basic.GuestRole</role>
<!-- Users management -->
<auto-create-users>true</auto-create-users>
<!-- Default properties mapping -->
<default-property
namespace="http://jakarta.apache.org/slide/" name="password"
value="" role="user"/>
</configuration>
<data>
<objectnode classname="org.apache.slide.structure.SubjectNode"
uri="/">
<!-- Subject can be:
self "~"
all "nobody"
user "/users/john"
group "+/users/groupA"
role "root"
-->
<!-- Uncomment the following line to give all permissions to
principals have the root role
-->
<!-- <permission action="/actions" subject="root"/> -->
<permission action="/actions" subject="/users/root"/>
<permission action="/actions/read" subject="/users"
inheritable="false"/>
<permission action="/actions/read" subject="nobody"
inheritable="false"/>
<!-- /users -->
<objectnode classname="org.apache.slide.structure.SubjectNode"
uri="/users">
<permission action="/actions" subject="~"/>
<permission action="/actions" subject="/users/guest"
inheritable="true" negative="true"/>
<permission action="/actions/read" subject="/users"
inheritable="false"/>
<!-- Permission group example -->
<objectnode
classname="org.apache.slide.structure.GroupNode"
uri="/users/groupA">
<objectnode
classname="org.apache.slide.structure.LinkNode"
uri="/users/groupA/john" linkedUri="/users/john"/>
<objectnode
classname="org.apache.slide.structure.LinkNode"
uri="/users/groupA/root" linkedUri="/users/root"/>
</objectnode>
<!-- /users/root represents the administrator -->
<objectnode classname="slideroles.basic.RootRoleImpl"
uri="/users/root">
<revision>
<property name="password"
namespace="http://jakarta.apache.org/slide/">root</property>
</revision>
</objectnode>
<!-- /users/john represents an authenticated user -->
<objectnode classname="slideroles.basic.UserRoleImpl"
uri="/users/john">
<revision>
<property name="password"
namespace="http://jakarta.apache.org/slide/">john</property>
</revision>
</objectnode>
<!-- /users/guest represents an authenticated or
unauthenticated guest user -->
<objectnode classname="slideroles.basic.GuestRoleImpl"
uri="/users/guest">
<revision>
<property name="password"
namespace="http://jakarta.apache.org/slide/"/>
</revision>
</objectnode>
</objectnode>
<objectnode classname="org.apache.slide.structure.ActionNode"
uri="/actions">
<objectnode
classname="org.apache.slide.structure.ActionNode"
uri="/actions/read"/>
<objectnode
classname="org.apache.slide.structure.ActionNode"
uri="/actions/write"/>
<objectnode
classname="org.apache.slide.structure.ActionNode"
uri="/actions/manage"/>
</objectnode>
<objectnode classname="org.apache.slide.structure.SubjectNode"
uri="/files">
<!-- ### Give read/write/manage permission to guest ###
Uncomment the following line to give permission to do all
actions on /files to guest (unauthenticated users) -->
<permission action="/actions" subject="/users/guest"/>
<permission action="/actions/manage"
subject="/users/john"/>
<permission action="/actions/write"
subject="+/users/groupA"/>
<permission action="/actions/read" subject="nobody"/>
</objectnode>
<!-- DeltaV: default history and workspace paths -->
<objectnode classname="org.apache.slide.structure.SubjectNode"
uri="/history"/>
<objectnode classname="org.apache.slide.structure.SubjectNode"
uri="/workspace"/>
<objectnode classname="org.apache.slide.structure.SubjectNode"
uri="/workingresource"/>
</objectnode>
</data>
</namespace>
<!--
DeltaV global parameters
========================
* historypath (mandatory=no, default="/history"):
Specifies a Slide path which determines the location where this DeltaV
server stores history data.
* workspacepath (mandatory=no, default="/workspace"):
Specifies a Slide path which determines the location where this DeltaV
server allows workspaces to reside.
* workingresourcepath (mandatory=no, default="/workingresource"):
Specifies a Slide path which determines the location where this DeltaV
server stores working resources.
* auto-version (mandatory=no, default="checkout-checkin"):
Controls the DeltaV auto-version behaviour.
* auto-version-control (mandatory=no, default="false"):
Indicates if a resource just created by a PUT should be set under
version-control.
* versioncontrol-exclude (mandatory=no, default=""):
Specifies a Slide path which determines resources which are excluded from
version-control.
The default value "" makes no path being excluded.
* checkout-fork (mandatory=no, default="forbidden"):
Controls the DeltaV check-out behaviour when a version is already
checked-out or has a successor.
* checkin-fork (mandatory=no, default="forbidden"):
Controls the DeltaV check-out behaviour when a version has already a
successor.
* standardLivePropertiesClass (mandatory=no,
default="org.apache.slide.webdav.util.resourcekind.AbstractResourceKind"):
Determines the "agent" knowing about what the standard live properties
are.
It should be a loadable class containing the following static methods:
- boolean isLiveProperty(String propName)
- boolean isProtectedProperty(String propName)
- boolean isComputedProperty(String propName)
- Set getAllLiveProperties()
- Set getAllProtectedProperties()
- Set getAllComputedProperties()
* uriRedirectorClass (mandatory=no,
default="org.apache.slide.webdav.util.DeltavUriRedirector"):
Determines the URI redirector class. The DeltaV URI redirector is in
charge of the following redirections:
- version URI to history URI, e.g. /history/2/1.4 to /history/2
- latest revision number for history resource to 0.0
- latest revision number for version resource to last URI token,
e.g. /history/2/1.4 to 1.4
It should be a loadable class containing the following static methods:
- String redirectUri(String uri)
- NodeRevisionNumber redirectLatestRevisionNumber(String uri)
-->
<parameter name="historypath">/history</parameter>
<parameter name="workspacepath">/workspace</parameter>
<parameter name="workingresourcepath">/workingresource</parameter>
<parameter name="auto-version">checkout-checkin</parameter>
<parameter name="auto-version-control">false</parameter>
<parameter name="versioncontrol-exclude"></parameter>
<parameter name="checkout-fork">forbidden</parameter>
<parameter name="checkin-fork">forbidden</parameter>
</slide>
1.1
xml-cocoon2/src/mocks/javax/transaction/HeuristicMixedException.java
Index: HeuristicMixedException.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package javax.transaction;
/**
* Mock class providing the declarations required to compile the Cocoon code
when
* the actual library is not present.
*
* @version CVS $Id: HeuristicMixedException.java,v 1.1 2003/01/31 18:08:45
stephan Exp $
*/
public class HeuristicMixedException extends Exception {
public HeuristicMixedException() {
throw new NoSuchMethodError("This is a mock object");
}
public HeuristicMixedException(String msg) {
throw new NoSuchMethodError("This is a mock object");
}
}
1.1
xml-cocoon2/src/mocks/javax/transaction/HeuristicRollbackException.java
Index: HeuristicRollbackException.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package javax.transaction;
/**
* Mock class providing the declarations required to compile the Cocoon code
when
* the actual library is not present.
*
* @version CVS $Id: HeuristicRollbackException.java,v 1.1 2003/01/31
18:08:45 stephan Exp $
*/
public class HeuristicRollbackException extends Exception {
public HeuristicRollbackException() {
throw new NoSuchMethodError("This is a mock object");
}
public HeuristicRollbackException(String msg) {
throw new NoSuchMethodError("This is a mock object");
}
}
1.1
xml-cocoon2/src/mocks/javax/transaction/NotSupportedException.java
Index: NotSupportedException.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package javax.transaction;
/**
* Mock class providing the declarations required to compile the Cocoon code
when
* the actual library is not present.
*
* @version CVS $Id: NotSupportedException.java,v 1.1 2003/01/31 18:08:45
stephan Exp $
*/
public class NotSupportedException extends Exception {
public NotSupportedException() {
throw new NoSuchMethodError("This is a mock object");
}
public NotSupportedException(String msg) {
throw new NoSuchMethodError("This is a mock object");
}
}
1.1
xml-cocoon2/src/mocks/javax/transaction/RollbackException.java
Index: RollbackException.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package javax.transaction;
/**
* Mock class providing the declarations required to compile the Cocoon code
when
* the actual library is not present.
*
* @version CVS $Id: RollbackException.java,v 1.1 2003/01/31 18:08:45 stephan
Exp $
*/
public class RollbackException extends Exception {
public RollbackException() {
throw new NoSuchMethodError("This is a mock object");
}
public RollbackException(String s) {
throw new NoSuchMethodError("This is a mock object");
}
}
1.1
xml-cocoon2/src/mocks/javax/transaction/SystemException.java
Index: SystemException.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package javax.transaction;
/**
* Mock class providing the declarations required to compile the Cocoon code
when
* the actual library is not present.
*
* @version CVS $Id: SystemException.java,v 1.1 2003/01/31 18:08:45 stephan
Exp $
*/
public class SystemException extends Exception {
public SystemException() {
throw new NoSuchMethodError("This is a mock object");
}
public SystemException(String s) {
throw new NoSuchMethodError("This is a mock object");
}
public SystemException(int i) {
throw new NoSuchMethodError("This is a mock object");
}
}
1.1
xml-cocoon2/src/mocks/javax/transaction/UserTransaction.java
Index: UserTransaction.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package javax.transaction;
/**
* Mock class providing the declarations required to compile the Cocoon code
when
* the actual library is not present.
*
* @version CVS $Id: UserTransaction.java,v 1.1 2003/01/31 18:08:45 stephan
Exp $
*/
public interface UserTransaction {
public abstract void begin() throws NotSupportedException,
SystemException;
public abstract void commit()
throws
RollbackException,
HeuristicMixedException,
HeuristicRollbackException,
SecurityException,
IllegalStateException,
SystemException;
public abstract void rollback()
throws IllegalStateException, SecurityException, SystemException;
public abstract void setRollbackOnly()
throws IllegalStateException, SystemException;
public abstract int getStatus() throws SystemException;
public abstract void setTransactionTimeout(int seconds) throws
SystemException;
}
1.4 +6 -12
xml-cocoon2/src/scratchpad/webapp/samples/scratchpad-samples.xml
Index: scratchpad-samples.xml
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/webapp/samples/scratchpad-samples.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- scratchpad-samples.xml 7 Jan 2003 23:32:59 -0000 1.3
+++ scratchpad-samples.xml 31 Jan 2003 18:08:48 -0000 1.4
@@ -10,11 +10,11 @@
</sample>
</group>
- <group name="Charts">
+<!-- <group name="Charts">
<sample name="Wings Transformer" href="charts/">
Show the usage of the Krysalis Wings Chart Generator.
</sample>
- </group>
+ </group>-->
<group name="Slash Edit">
<sample name="Source Writing Transformer" href="editor/">
@@ -29,11 +29,11 @@
</sample>
</group>
- <group name="Precept">
+<!-- <group name="Precept">
<sample name="Precept" href="precept/">
Introduction into the Precept Form components.
</sample>
- </group>
+ </group>-->
<group name="SOAP Server">
<sample name="SOAP Server" href="soap-server/">
@@ -47,18 +47,12 @@
</sample>
</group>
- <group name="Slide Integration">
- <sample name="Slide" href="slide/">
- Shows an example of how it could be possible to integrate a
- Content Management System, like Jakarta Slide, into Cocoon.
- </sample>
- </group>
-
<group name="AsciiArt">
<sample name="AsciiArt Generator" href="asciiart/welcome">
Show the usage of the AsciiArt Generator.
</sample>
</group>
+
<group name="Mail">
<sample name="Mail" href="mail/index.html">
Show the usage of the Mail Action.
1.28 +2 -2 xml-cocoon2/src/webapp/samples/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/webapp/samples/sitemap.xmap,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- sitemap.xmap 31 Jan 2003 16:40:25 -0000 1.27
+++ sitemap.xmap 31 Jan 2003 18:08:48 -0000 1.28
@@ -57,9 +57,9 @@
<map:serializers default="html"/>
<map:matchers default="wildcard">
<map:matcher logger="sitemap.matcher.header" name="filename"
src="org.apache.cocoon.matching.modular.CachingRegexpMatcher">
- <input-module name="request-param">
+<!-- <input-module name="request-param">
<parameter>filename</parameter>
- </input-module>
+ </input-module>-->
</map:matcher>
</map:matchers>
<map:selectors default="browser"/>
1.18 +4 -0 xml-cocoon2/tools/src/blocks-build.xsl
Index: blocks-build.xsl
===================================================================
RCS file: /home/cvs/xml-cocoon2/tools/src/blocks-build.xsl,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- blocks-build.xsl 14 Jan 2003 09:26:49 -0000 1.17
+++ blocks-build.xsl 31 Jan 2003 18:08:48 -0000 1.18
@@ -197,6 +197,10 @@
<xsl:attribute
name="path">${build.currentblock.mocks.dir}</xsl:attribute>
</pathelement>
+ <pathelement>
+ <xsl:attribute name="path">${build.mocks}</xsl:attribute>
+ </pathelement>
+
</path>
<copy filtering="on">
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]