You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2005/08/26 22:04:35 UTC
svn commit: r240329 - in /cocoon/blocks/jcr/trunk: WEB-INF/xconf/ conf/
java/org/apache/cocoon/jcr/ java/org/apache/cocoon/jcr/source/ samples/
test/org/apache/cocoon/jcr/source/
Author: vgritsenko
Date: Fri Aug 26 13:04:15 2005
New Revision: 240329
URL: http://svn.apache.org/viewcvs?rev=240329&view=rev
Log:
license, svn props, (c) year
Modified:
cocoon/blocks/jcr/trunk/WEB-INF/xconf/jcr.xconf
cocoon/blocks/jcr/trunk/conf/jcr-component.xconf
cocoon/blocks/jcr/trunk/conf/jcr-source.xconf
cocoon/blocks/jcr/trunk/conf/jcr.xroles
cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/AbstractRepository.java
cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/JNDIRepository.java
cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/JackrabbitRepository.java
cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/jcr.roles
cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/source/JCRNodeSource.java
cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/source/JCRNodeSourceValidity.java
cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/source/JCRSourceFactory.java
cocoon/blocks/jcr/trunk/samples/repository.xml (props changed)
cocoon/blocks/jcr/trunk/samples/sitemap.xmap (contents, props changed)
cocoon/blocks/jcr/trunk/test/org/apache/cocoon/jcr/source/JCRSourceTestCase.java
cocoon/blocks/jcr/trunk/test/org/apache/cocoon/jcr/source/JCRSourceTestCase.xtest (contents, props changed)
Modified: cocoon/blocks/jcr/trunk/WEB-INF/xconf/jcr.xconf
URL: http://svn.apache.org/viewcvs/cocoon/blocks/jcr/trunk/WEB-INF/xconf/jcr.xconf?rev=240329&r1=240328&r2=240329&view=diff
==============================================================================
--- cocoon/blocks/jcr/trunk/WEB-INF/xconf/jcr.xconf (original)
+++ cocoon/blocks/jcr/trunk/WEB-INF/xconf/jcr.xconf Fri Aug 26 13:04:15 2005
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!--
- Copyright 1999-2005 The Apache Software Foundation
+ Copyright 2005 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,7 +14,10 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<!-- $Id$ -->
+
+<!--
+ - $Id$
+ -->
<components>
<include src="resource://org/apache/cocoon/jcr/jcr.roles"/>
</components>
Modified: cocoon/blocks/jcr/trunk/conf/jcr-component.xconf
URL: http://svn.apache.org/viewcvs/cocoon/blocks/jcr/trunk/conf/jcr-component.xconf?rev=240329&r1=240328&r2=240329&view=diff
==============================================================================
--- cocoon/blocks/jcr/trunk/conf/jcr-component.xconf (original)
+++ cocoon/blocks/jcr/trunk/conf/jcr-component.xconf Fri Aug 26 13:04:15 2005
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!--
- Copyright 1999-2004 The Apache Software Foundation
+ Copyright 2005 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Modified: cocoon/blocks/jcr/trunk/conf/jcr-source.xconf
URL: http://svn.apache.org/viewcvs/cocoon/blocks/jcr/trunk/conf/jcr-source.xconf?rev=240329&r1=240328&r2=240329&view=diff
==============================================================================
--- cocoon/blocks/jcr/trunk/conf/jcr-source.xconf (original)
+++ cocoon/blocks/jcr/trunk/conf/jcr-source.xconf Fri Aug 26 13:04:15 2005
@@ -1,12 +1,27 @@
<?xml version="1.0"?>
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<!--
- $Id$
-->
- <xconf xpath="/cocoon/source-factories"
- unless="/cocoon/source-factories/component-instance[@name = 'jcr']">
+<xconf xpath="/cocoon/source-factories"
+ unless="/cocoon/source-factories/component-instance[@name = 'jcr']">
- <component-instance class="org.apache.cocoon.jcr.source.JCRSourceFactory" name="jcr">
+ <component-instance name="jcr" class="org.apache.cocoon.jcr.source.JCRSourceFactory">
<folder-node type="rep:root" new-file="nt:file" new-folder="nt:folder"/>
<folder-node type="nt:unstructured" new-file="nt:file" new-folder="nt:unstructured"/>
<!--
Modified: cocoon/blocks/jcr/trunk/conf/jcr.xroles
URL: http://svn.apache.org/viewcvs/cocoon/blocks/jcr/trunk/conf/jcr.xroles?rev=240329&r1=240328&r2=240329&view=diff
==============================================================================
--- cocoon/blocks/jcr/trunk/conf/jcr.xroles (original)
+++ cocoon/blocks/jcr/trunk/conf/jcr.xroles Fri Aug 26 13:04:15 2005
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!--
- Copyright 1999-2005 The Apache Software Foundation
+ Copyright 2005 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -19,8 +19,8 @@
- $Id$
-->
<xroles xpath="/role-list" unless="/role-list[@cocoon-version != '2.1']|role[@shorthand='jcr-repository']">
-
+
<!-- JCR repository, no default class -->
- <role name="javax.jcr.Repository"
+ <role name="javax.jcr.Repository"
shorthand="jcr-repository"/>
</xroles>
Modified: cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/AbstractRepository.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/AbstractRepository.java?rev=240329&r1=240328&r2=240329&view=diff
==============================================================================
--- cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/AbstractRepository.java (original)
+++ cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/AbstractRepository.java Fri Aug 26 13:04:15 2005
@@ -1,12 +1,12 @@
/*
- * Copyright 1999-2005 The Apache Software Foundation.
- *
+ * Copyright 2005 The Apache Software Foundation.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -59,17 +59,17 @@
* should be used.
* <p>
* The configuration of this class, inherited by its subclasses, is as follows:
- *
+ *
* <pre>
- *
+ *
* <jcr-repository>
* <jaas src="context://samples/jaas.config"/>
* <credentials login="<i>expression</i>" password="<i>expression</i>"/>
* ... other specific configuration...
* </jcr-repository>
- *
+ *
* </pre>
- *
+ *
* Login and password can be specified using the sitemap expression language,
* thus allowing the use of input modules to compute their values, e.g.
* <code>password="{session-attr:jcr-password}"</code>
@@ -77,7 +77,7 @@
* <code><credentials></code> is optional. If not specified, the
* application must explicitely supply credentials when calling
* <code>Repository.login()</code>.
- *
+ *
* @version $Id$
*/
public class AbstractRepository extends AbstractLogEnabled implements Repository, ThreadSafe, Contextualizable, Serviceable, Configurable, Disposable {
@@ -94,7 +94,7 @@
protected VariableResolver loginResolver = null;
protected VariableResolver passwordResolver = null;
-
+
/**
* The request attribute in which the JCR session is stored
*/
@@ -224,17 +224,17 @@
}
// =============================================================================================
-
+
private Session getCachedSession(String workspace) {
String attributeName = workspace == null ?
JCR_SESSION_REQUEST_ATTRIBUTE : JCR_SESSION_REQUEST_ATTRIBUTE + "/" + workspace;
Map objectModel = ContextHelper.getObjectModel(context);
Request request = ObjectModelHelper.getRequest(objectModel);
Session session = (Session) request.getAttribute(attributeName);
-
+
return (session != null && session.isLive()) ? session : null;
}
-
+
private void cacheSession(Session session, String workspace) {
String attributeName = workspace == null ?
JCR_SESSION_REQUEST_ATTRIBUTE : JCR_SESSION_REQUEST_ATTRIBUTE + "/" + workspace;
Modified: cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/JNDIRepository.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/JNDIRepository.java?rev=240329&r1=240328&r2=240329&view=diff
==============================================================================
--- cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/JNDIRepository.java (original)
+++ cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/JNDIRepository.java Fri Aug 26 13:04:15 2005
@@ -1,12 +1,12 @@
/*
- * Copyright 1999-2005 The Apache Software Foundation.
- *
+ * Copyright 2005 The Apache Software Foundation.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,13 +22,16 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+/**
+ * @version $Id$
+ */
public class JNDIRepository extends AbstractRepository {
public void configure(Configuration config) throws ConfigurationException {
super.configure(config);
Configuration rsrcConfig = config.getChild("jndi-resource");
String name = rsrcConfig.getAttribute("name");
-
+
try {
InitialContext ctx = new InitialContext();
this.delegate = (Repository)ctx.lookup(name);
Modified: cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/JackrabbitRepository.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/JackrabbitRepository.java?rev=240329&r1=240328&r2=240329&view=diff
==============================================================================
--- cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/JackrabbitRepository.java (original)
+++ cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/JackrabbitRepository.java Fri Aug 26 13:04:15 2005
@@ -1,12 +1,12 @@
/*
- * Copyright 1999-2005 The Apache Software Foundation.
- *
+ * Copyright 2005 The Apache Software Foundation.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,21 +30,21 @@
* href="http://incubator.apache.org/jackrabbit">Jackrabbit</a>
* <p>
* The configuration is as follows:
- *
+ *
* <pre>
- *
+ *
* <jcr-repository>
* <credentials login="<i>expression</i>" password="<i>expression</i>"/>
* <home src="file://path/to/repository"/>
* <configuration src="resource://your/application/jcr/repository.xml"/>
* </jcr-repository>
- *
+ *
* </pre>
- *
+ *
* The <code>home</code> URI points to the base location of the repository,
* and <code>configuration</code> points to the Jackrabbit repository
* configuration file.
- *
+ *
* @see AbstractRepository
* @version $Id$
*/
Modified: cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/jcr.roles
URL: http://svn.apache.org/viewcvs/cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/jcr.roles?rev=240329&r1=240328&r2=240329&view=diff
==============================================================================
--- cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/jcr.roles (original)
+++ cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/jcr.roles Fri Aug 26 13:04:15 2005
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!--
- Copyright 1999-2005 The Apache Software Foundation
+ Copyright 2005 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,9 +14,11 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<!-- $Id$ -->
+
+<!--
+ - $Id$
+ -->
<role-list>
<role name="javax.jcr.Repository"
- shorthand="jcr-repository"
- />
+ shorthand="jcr-repository"/>
</role-list>
Modified: cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/source/JCRNodeSource.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/source/JCRNodeSource.java?rev=240329&r1=240328&r2=240329&view=diff
==============================================================================
--- cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/source/JCRNodeSource.java (original)
+++ cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/source/JCRNodeSource.java Fri Aug 26 13:04:15 2005
@@ -1,12 +1,12 @@
/*
- * Copyright 1999-2005 The Apache Software Foundation.
- *
+ * Copyright 2005 The Apache Software Foundation.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -43,7 +43,7 @@
/**
* A Source for a JCR node.
- *
+ *
* @version $Id$
*/
public class JCRNodeSource implements Source, TraversableSource, ModifiableTraversableSource {
@@ -121,16 +121,16 @@
/**
* Returns the JCR <code>Node</code> this source points to, or
* <code>null</code> if it denotes a non-existing path.
- *
+ *
* @return the JCR node.
*/
public Node getNode() {
return this.node;
}
-
+
/**
* Returns the path within the repository this source points to.
- *
+ *
* @return the path
*/
public String getPath() {
@@ -139,7 +139,7 @@
/**
* Returns the JCR <code>Session</code> used by this source.
- *
+ *
* @return the JCR session.
*/
public Session getSession() {
@@ -149,7 +149,7 @@
/**
* Returns the JCR <code>Node</code> used to store the content of this
* source.
- *
+ *
* @return the JCR content node, or <code>null</code> if no such node
* exist, either because the source is a collection or doesn't
* currently contain data.
@@ -176,7 +176,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.excalibur.source.Source#exists()
*/
public boolean exists() {
@@ -185,7 +185,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.excalibur.source.Source#getInputStream()
*/
public InputStream getInputStream() throws IOException, SourceNotFoundException {
@@ -207,7 +207,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.excalibur.source.Source#getURI()
*/
public String getURI() {
@@ -219,7 +219,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.excalibur.source.Source#getScheme()
*/
public String getScheme() {
@@ -228,7 +228,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.excalibur.source.Source#getValidity()
*/
public SourceValidity getValidity() {
@@ -245,7 +245,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.excalibur.source.Source#refresh()
*/
public void refresh() {
@@ -254,7 +254,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.excalibur.source.Source#getMimeType()
*/
public String getMimeType() {
@@ -276,7 +276,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.excalibur.source.Source#getContentLength()
*/
public long getContentLength() {
@@ -293,7 +293,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.excalibur.source.Source#getLastModified()
*/
public long getLastModified() {
Modified: cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/source/JCRNodeSourceValidity.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/source/JCRNodeSourceValidity.java?rev=240329&r1=240328&r2=240329&view=diff
==============================================================================
--- cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/source/JCRNodeSourceValidity.java (original)
+++ cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/source/JCRNodeSourceValidity.java Fri Aug 26 13:04:15 2005
@@ -1,12 +1,12 @@
/*
- * Copyright 1999-2005 The Apache Software Foundation.
- *
+ * Copyright 2005 The Apache Software Foundation.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,7 +22,7 @@
/**
* Validity of a {@link JCRNodeSource}. It's a wrapper around a JCR
* <code>Value</code>.
- *
+ *
* @version $Id$
*/
public class JCRNodeSourceValidity implements SourceValidity {
Modified: cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/source/JCRSourceFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/source/JCRSourceFactory.java?rev=240329&r1=240328&r2=240329&view=diff
==============================================================================
--- cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/source/JCRSourceFactory.java (original)
+++ cocoon/blocks/jcr/trunk/java/org/apache/cocoon/jcr/source/JCRSourceFactory.java Fri Aug 26 13:04:15 2005
@@ -1,12 +1,12 @@
/*
- * Copyright 1999-2005 The Apache Software Foundation.
- *
+ * Copyright 2005 The Apache Software Foundation.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -50,9 +50,9 @@
* "files" and "folders" and the properties used to store source-related data.
* <p>
* A typical configuration for a naked Jackrabbit repository is as follows:
- *
+ *
* <pre>
- *
+ *
* <source-factories>
* <component-instance class="org.apache.cocoon.jcr.source.JCRSourceFactory" name="jcr">
* <folder-node type="rep:root" new-file="nt:file" new-folder="nt:folder"/>
@@ -66,9 +66,9 @@
* validity-prop="jcr:lastModified"/>
* </component-instance>
* </source-factories>
- *
+ *
* </pre>
- *
+ *
* A <code><folder-node></code> defines a node type that is mapped to a
* non-terminal source (i.e. that can have children). The <code>new-file</code>
* and <code>new-folder</code> attributes respectively define what node types
@@ -105,7 +105,7 @@
* The format of URIs for this source is a path in the repository, and it is
* therefore currently limited to repository traversal. Further work will add
* the ability to specify query strings.
- *
+ *
* @version $Id$
*/
public class JCRSourceFactory implements ThreadSafe, SourceFactory, Configurable, Serviceable {
@@ -205,7 +205,7 @@
}
}
-
+
protected void lazyInit() {
if (this.repo == null) {
try {
@@ -218,7 +218,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.excalibur.source.SourceFactory#getSource(java.lang.String,
* java.util.Map)
*/
@@ -259,7 +259,7 @@
/*
* (non-Javadoc)
- *
+ *
* @see org.apache.excalibur.source.SourceFactory#release(org.apache.excalibur.source.Source)
*/
public void release(Source source) {
@@ -272,7 +272,7 @@
/**
* Get the type info for a node.
- *
+ *
* @param node the node
* @return the type info
* @throws RepositoryException if node type couldn't be accessed or if no type info is found
@@ -306,7 +306,7 @@
/**
* Get the content node for a given node
- *
+ *
* @param node the node for which we want the content node
* @return the content node
* @throws RepositoryException if some error occurs, or if the given node isn't a file node or a content node
@@ -332,10 +332,10 @@
throw new RepositoryException("Can't get content node for folder node at " + node.getPath());
}
}
-
+
/**
* Creates a new source given its parent and its node
- *
+ *
* @param parent the parent
* @param node the node
* @return a new source
@@ -344,10 +344,10 @@
public JCRNodeSource createSource(JCRNodeSource parent, Node node) throws SourceException {
return new JCRNodeSource(parent, node);
}
-
+
/**
* Creates a new source given a session and a path
- *
+ *
* @param session the session
* @param path the absolute path
* @return a new source
@@ -359,7 +359,7 @@
/**
* Create a child file node in a folder node.
- *
+ *
* @param folderNode the folder node
* @param name the child's name
* @return the newly created child node
@@ -377,7 +377,7 @@
/**
* Create the content node for a file node.
- *
+ *
* @param fileNode the file node
* @return the content node for this file node
* @throws RepositoryException if some error occurs
@@ -397,7 +397,7 @@
/**
* Get the content property for a given node
- *
+ *
* @param node a file or content node
* @return the content property
* @throws RepositoryException if some error occurs
@@ -410,7 +410,7 @@
/**
* Get the mime-type property for a given node
- *
+ *
* @param node a file or content node
* @return the mime-type property, or <code>null</code> if no such property exists
* @throws RepositoryException if some error occurs
@@ -429,7 +429,7 @@
/**
* Get the lastmodified property for a given node
- *
+ *
* @param node a file or content node
* @return the lastmodified property, or <code>null</code> if no such property exists
* @throws RepositoryException if some error occurs
@@ -448,7 +448,7 @@
/**
* Get the validity property for a given node
- *
+ *
* @param node a file or content node
* @return the validity property, or <code>null</code> if no such property exists
* @throws RepositoryException if some error occurs
@@ -467,7 +467,7 @@
/**
* Does a node represent a collection (i.e. folder-node)?
- *
+ *
* @param node the node
* @return <code>true</code> if it's a collection
* @throws RepositoryException if some error occurs
@@ -478,7 +478,7 @@
/**
* Get the node type to create a new subfolder of a given folder node.
- *
+ *
* @param folderNode
* @return the child folder node type
* @throws RepositoryException if some error occurs
Propchange: cocoon/blocks/jcr/trunk/samples/repository.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/blocks/jcr/trunk/samples/repository.xml
------------------------------------------------------------------------------
svn:keywords = Id
Modified: cocoon/blocks/jcr/trunk/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/blocks/jcr/trunk/samples/sitemap.xmap?rev=240329&r1=240328&r2=240329&view=diff
==============================================================================
--- cocoon/blocks/jcr/trunk/samples/sitemap.xmap (original)
+++ cocoon/blocks/jcr/trunk/samples/sitemap.xmap Fri Aug 26 13:04:15 2005
@@ -1,10 +1,29 @@
<?xml version="1.0"?>
+<!--
+ Copyright 2005 The Apache Software Foundation
-<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ - $Id$
+ -->
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
<map:generators default="file">
- <map:generator logger="sitemap.generator.traversable" name="traversable" src="org.apache.cocoon.generation.TraversableGenerator"/>
+ <map:generator name="traversable"
+ logger="sitemap.generator.traversable"
+ src="org.apache.cocoon.generation.TraversableGenerator"/>
</map:generators>
</map:components>
@@ -12,9 +31,6 @@
<map:pipeline>
<map:match pattern="**">
<map:generate type="traversable" src="jcr://"/>
- <!--
- <map:generate src="jcr://blog/entries/entry-1120863970581"/>
- -->
<map:serialize type="xml"/>
</map:match>
</map:pipeline>
Propchange: cocoon/blocks/jcr/trunk/samples/sitemap.xmap
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/blocks/jcr/trunk/samples/sitemap.xmap
------------------------------------------------------------------------------
svn:keywords = Id
Modified: cocoon/blocks/jcr/trunk/test/org/apache/cocoon/jcr/source/JCRSourceTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/jcr/trunk/test/org/apache/cocoon/jcr/source/JCRSourceTestCase.java?rev=240329&r1=240328&r2=240329&view=diff
==============================================================================
--- cocoon/blocks/jcr/trunk/test/org/apache/cocoon/jcr/source/JCRSourceTestCase.java (original)
+++ cocoon/blocks/jcr/trunk/test/org/apache/cocoon/jcr/source/JCRSourceTestCase.java Fri Aug 26 13:04:15 2005
@@ -1,31 +1,49 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.cocoon.jcr.source;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.util.Collection;
-import java.util.Collections;
-
import org.apache.avalon.framework.CascadingRuntimeException;
import org.apache.avalon.framework.context.DefaultContext;
import org.apache.avalon.framework.service.ServiceSelector;
+
import org.apache.cocoon.core.container.ContainerTestCase;
+
import org.apache.excalibur.source.ModifiableSource;
import org.apache.excalibur.source.ModifiableTraversableSource;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceFactory;
import org.apache.excalibur.source.SourceResolver;
-import org.apache.excalibur.source.SourceUtil;
import org.apache.excalibur.source.TraversableSource;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * @version $Id$
+ */
public class JCRSourceTestCase extends ContainerTestCase {
-
+
private SourceResolver resolver;
-
+
private File tempDir;
-
+
protected void addContext(DefaultContext context) {
super.addContext(context);
// Create a temp file
@@ -38,11 +56,11 @@
tempDir.delete();
tempDir.mkdir();
tempDir.deleteOnExit();
-
- // Setup context root as the temp dir so that relative URI used in the
+
+ // Setup context root as the temp dir so that relative URI used in the
// repository configuration go there
context.put("context-root", tempDir);
-
+
// Make VariableResolver used in repository configuration happy
context.put("object-model", Collections.EMPTY_MAP);
}
@@ -51,14 +69,14 @@
super.setUp();
resolver = (SourceResolver)getManager().lookup(SourceResolver.ROLE);
}
-
+
private void write(ModifiableSource src, String text) throws Exception {
byte[] data = text.getBytes("ISO-8859-1");
OutputStream os = src.getOutputStream();
os.write(data);
os.close();
}
-
+
private String read(Source src) throws Exception {
byte[] data = new byte[(int)src.getContentLength()];
InputStream is = src.getInputStream();
@@ -66,7 +84,7 @@
is.close();
return new String(data, "ISO-8859-1");
}
-
+
protected void deleteFile(File file) {
File[] children = file.listFiles();
if (children != null) {
@@ -76,61 +94,61 @@
}
file.delete();
}
-
+
protected void tearDown() throws Exception {
super.tearDown();
deleteFile(tempDir);
}
-
+
public void testJCRSourceInitialization() throws Exception {
ServiceSelector selector = (ServiceSelector)getManager().lookup(SourceFactory.ROLE + "Selector");
Object jcrSourceFactory = selector.select("jcr");
assertEquals("Wrong class name for jcr protocol", jcrSourceFactory.getClass(), JCRSourceFactory.class);
}
-
+
public void testGetRootNode() throws Exception {
-
+
JCRNodeSource source = (JCRNodeSource)resolver.resolveURI("jcr://");
assertTrue("Root node should exist", source.exists());
System.err.println("Root node type = " + source.getNode().getPrimaryNodeType().getName());
assertTrue("Root node should be a collection", source.isCollection());
}
-
+
public void testCreateFirstLevelFile() throws Exception {
-
+
String someText = "Some text";
JCRNodeSource root = (JCRNodeSource)resolver.resolveURI("jcr://");
-
+
JCRNodeSource firstChild = (JCRNodeSource)root.getChild("child1");
-
+
assertFalse(firstChild.exists());
assertEquals(firstChild.getURI(), "jcr://child1");
-
+
write(firstChild, someText);
-
+
assertTrue(firstChild.exists());
-
+
// Check content
Source child1 = resolver.resolveURI("jcr://child1");
assertTrue(child1.exists());
-
+
int len = (int)child1.getContentLength();
assertEquals(someText.length(), len);
assertEquals(someText, read(child1));
-
+
}
-
+
public void testCreateDeepFile() throws Exception {
String anotherText = "another text";
-
+
JCRNodeSource source = (JCRNodeSource)resolver.resolveURI("jcr://some/deep/path/to/file");
assertFalse(source.exists());
-
+
write(source, anotherText);
-
+
// Lookup again, using the parent, doing some traversal
TraversableSource dir = (TraversableSource)resolver.resolveURI("jcr://some/deep");
assertTrue(dir.isCollection());
@@ -138,86 +156,86 @@
assertTrue(dir.isCollection());
dir = (TraversableSource)dir.getChild("to");
assertTrue(dir.isCollection());
-
+
source = (JCRNodeSource)dir.getChild("file");
assertTrue(source.exists());
-
+
assertEquals(anotherText, read(source));
}
-
+
public void testDeleteFile() throws Exception {
String text = "Yeah! Some content!";
ModifiableSource source = (ModifiableSource)resolver.resolveURI("jcr://yet/another/deep/file");
-
+
assertFalse(source.exists());
write(source, text);
-
+
// Lookup a fresh source
source = (ModifiableSource)resolver.resolveURI("jcr://yet/another/deep/file");
assertTrue(source.exists());
source.delete();
assertFalse(source.exists());
-
+
// Lookup again to check it was really deleted
source = (ModifiableSource)resolver.resolveURI("jcr://yet/another/deep/file");
assertFalse(source.exists());
}
-
+
public void testDeleteDir() throws Exception {
String text = "Wow, a lot of data going there";
ModifiableTraversableSource source = (ModifiableTraversableSource)resolver.resolveURI("jcr://and/again/a/deep/node");
-
+
assertFalse(source.exists());
write(source, text);
-
+
// Lookup 'a' node
source = (ModifiableTraversableSource)resolver.resolveURI("jcr://and/again/a/");
assertTrue(source.isCollection());
source.delete();
assertFalse(source.exists());
-
+
// Double check with a fresh source
source = (ModifiableTraversableSource)resolver.resolveURI("jcr://and/again/a/");
assertFalse(source.exists());
-
+
// Check on children
source = (ModifiableTraversableSource)resolver.resolveURI("jcr://and/again/a/deep/node");
assertFalse(source.exists());
}
-
+
public void testTraverseDir() throws Exception {
String text = "Look Ma, more data!";
-
+
ModifiableTraversableSource dir = (ModifiableTraversableSource)resolver.resolveURI("jcr://path/to/dir");
dir.makeCollection();
-
+
for (int i = 0; i < 10; i++) {
ModifiableTraversableSource src = (ModifiableTraversableSource)dir.getChild("file" + i);
write(src, text + i);
}
-
+
// Lookup dir again, and inspect children
dir = (ModifiableTraversableSource)resolver.resolveURI("jcr://path/to/dir");
Collection children = dir.getChildren();
-
+
assertEquals(10, children.size());
-
+
for (int i = 0; i < 10; i++) {
Source src = dir.getChild("file" + i);
assertTrue(src.exists());
assertEquals(text + i, read(src));
}
}
-
+
public void testCrawlUp() throws Exception {
String text = "Look Pa, some more!";
-
+
ModifiableTraversableSource src = (ModifiableTraversableSource)resolver.resolveURI("jcr://path/to/very/deep/content");
write(src, text);
-
+
// Do a fresh lookup
src = (ModifiableTraversableSource)resolver.resolveURI("jcr://path/to/very/deep/content");
-
+
ModifiableTraversableSource parent = (ModifiableTraversableSource)src.getParent();
assertTrue(parent.exists());
assertEquals("jcr://path/to/very/deep", parent.getURI());
@@ -233,11 +251,11 @@
parent = (ModifiableTraversableSource)parent.getParent();
assertTrue(parent.exists());
assertEquals("jcr://path", parent.getURI());
-
+
parent = (ModifiableTraversableSource)parent.getParent();
- assertTrue(parent.exists());
+ assertTrue(parent.exists());
assertEquals("jcr://", parent.getURI());
-
+
// Root node has no parent
parent = (ModifiableTraversableSource)parent.getParent();
assertNull(parent);
Modified: cocoon/blocks/jcr/trunk/test/org/apache/cocoon/jcr/source/JCRSourceTestCase.xtest
URL: http://svn.apache.org/viewcvs/cocoon/blocks/jcr/trunk/test/org/apache/cocoon/jcr/source/JCRSourceTestCase.xtest?rev=240329&r1=240328&r2=240329&view=diff
==============================================================================
--- cocoon/blocks/jcr/trunk/test/org/apache/cocoon/jcr/source/JCRSourceTestCase.xtest (original)
+++ cocoon/blocks/jcr/trunk/test/org/apache/cocoon/jcr/source/JCRSourceTestCase.xtest Fri Aug 26 13:04:15 2005
@@ -1,12 +1,28 @@
-<testcase>
+<?xml version="1.0"?>
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<testcase>
<context/>
-
+
<roles>
<role name="javax.jcr.Repository"
shorthand="jcr-repository"
default-class="org.apache.cocoon.jcr.JackrabbitRepository"/>
-
+
<role name="org.apache.excalibur.source.SourceFactorySelector"
shorthand="source-factories"
default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector"/>
@@ -23,7 +39,7 @@
<configuration src="resource://org/apache/cocoon/jcr/repository.xml"/>
<credentials login="super" password=""/>
</jcr-repository>
-
+
<source-factories>
<component-instance class="org.apache.cocoon.jcr.source.JCRSourceFactory" name="jcr">
<folder-node type="rep:root" new-file="nt:file" new-folder="nt:folder"/>
@@ -35,11 +51,11 @@
mimetype-prop="jcr:mimeType"
lastmodified-prop="jcr:lastModified"
validity-prop="jcr:lastModified"/>
-
+
</component-instance>
<component-instance class="org.apache.excalibur.source.impl.ResourceSourceFactory" name="resource"/>
<component-instance class="org.apache.excalibur.source.impl.URLSourceFactory" name="*"/>
</source-factories>
</components>
-</testcase>
\ No newline at end of file
+</testcase>
Propchange: cocoon/blocks/jcr/trunk/test/org/apache/cocoon/jcr/source/JCRSourceTestCase.xtest
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/blocks/jcr/trunk/test/org/apache/cocoon/jcr/source/JCRSourceTestCase.xtest
------------------------------------------------------------------------------
svn:keywords = Id