You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2007/11/07 11:23:16 UTC
svn commit: r592686 [1/2] - in /incubator/sling/trunk/jcr/resource: ./
src/main/java/org/apache/sling/content/ src/main/java/org/apache/sling/jcr/
src/main/java/org/apache/sling/jcr/resource/
src/main/java/org/apache/sling/jcr/resource/internal/ src/ma...
Author: fmeschbe
Date: Wed Nov 7 02:23:10 2007
New Revision: 592686
URL: http://svn.apache.org/viewvc?rev=592686&view=rev
Log:
SLING-83 Package reorgnaization and SLING-98 API adoption (work in progress)
Added:
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/DefaultMappedObject.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceConstants.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceManagerFactory.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/SyntheticResource.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrContentHelper.java
- copied, changed from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/JcrContentHelper.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/JsonReader.java
- copied, changed from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/JsonReader.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Loader.java
- copied, changed from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/Loader.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Node.java
- copied, changed from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/Node.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/NodeReader.java
- copied, changed from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/NodeReader.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Property.java
- copied, changed from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/Property.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/XmlReader.java
- copied, changed from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/XmlReader.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/nodetype/
- copied from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/nodetype/
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/nodetype/BaseNodeManagementException.java
- copied, changed from r592674, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/nodetype/BaseNodeManagementException.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/nodetype/NodeTypeCreationException.java
- copied, changed from r592674, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/nodetype/NodeTypeCreationException.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/BundleMapper.java
- copied, changed from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/BundleMapper.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ClassDescriptorReader.java
- copied, changed from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/ClassDescriptorReader.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ContentManagerImpl.java
- copied, changed from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/ContentManagerImpl.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/MapperAtomicTypeConverterProvider.java
- copied, changed from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/MapperAtomicTypeConverterProvider.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ObservingObjectCache.java
- copied, changed from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/ObservingObjectCache.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/PersistenceManagerProviderImpl.java
- copied, changed from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/PersistenceManagerProviderImpl.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ValueTypeConverterImpl.java
- copied, changed from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/ValueTypeConverterImpl.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/classloader/
- copied from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/classloader/
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/classloader/BundleLoader.java
- copied, changed from r592674, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/classloader/BundleLoader.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/classloader/ClassLoaderLoader.java
- copied, changed from r592674, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/classloader/ClassLoaderLoader.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/classloader/Loader.java
- copied, changed from r592674, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/classloader/Loader.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/classloader/LoaderDelegate.java
- copied, changed from r592674, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/classloader/LoaderDelegate.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/classloader/MapperClassLoader.java
- copied, changed from r592674, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/classloader/MapperClassLoader.java
incubator/sling/trunk/jcr/resource/src/test/java/org/apache/sling/jcr/
incubator/sling/trunk/jcr/resource/src/test/java/org/apache/sling/jcr/resource/
incubator/sling/trunk/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/
incubator/sling/trunk/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/loader/
- copied from r592370, incubator/sling/trunk/jcr/resource/src/test/java/org/apache/sling/content/jcr/internal/loader/
incubator/sling/trunk/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/loader/JsonReaderTest.java
- copied, changed from r592674, incubator/sling/trunk/jcr/resource/src/test/java/org/apache/sling/content/jcr/internal/loader/JsonReaderTest.java
Removed:
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/
incubator/sling/trunk/jcr/resource/src/main/resources/SLING-INF/
incubator/sling/trunk/jcr/resource/src/test/java/org/apache/sling/content/
Modified:
incubator/sling/trunk/jcr/resource/pom.xml
Modified: incubator/sling/trunk/jcr/resource/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/pom.xml?rev=592686&r1=592685&r2=592686&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/pom.xml (original)
+++ incubator/sling/trunk/jcr/resource/pom.xml Wed Nov 7 02:23:10 2007
@@ -28,38 +28,33 @@
<relativePath>../../parent/pom.xml</relativePath>
</parent>
- <artifactId>sling-content-jcr</artifactId>
+ <artifactId>jcr.resource</artifactId>
<version>2.0.0-incubator-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>
- Sling - Content Loading and Mapping Management
+ Sling - Resource Loading and Mapping Management
</name>
<description>
This bundle provides two kinds of Repository Content related
- functionality: Initial content
- installation and JCR Mapping.
+ functionality: Initial content installation and JCR Mapping.
</description>
<scm>
<connection>
- scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/content
+ scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/jcr/resource
</connection>
<developerConnection>
- scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/content
+ scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/jcr/resource
</developerConnection>
<url>
- http://svn.apache.org/viewvc/incubator/sling/trunk/content
+ http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource
</url>
</scm>
<build>
<plugins>
<plugin>
- <groupId>org.apache.sling</groupId>
- <artifactId>maven-sling-plugin</artifactId>
- </plugin>
- <plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
@@ -74,8 +69,7 @@
<configuration>
<instructions>
<Export-Package>
- org.apache.sling.content,
- org.apache.sling.content.jcr,
+ org.apache.sling.jcr.resource,
org.apache.jackrabbit.ocm.exception;
org.apache.jackrabbit.ocm.mapper;
org.apache.jackrabbit.ocm.manager;
@@ -86,7 +80,7 @@
org.apache.jackrabbit.ocm.version;version=1.4
</Export-Package>
<Private-Package>
- org.apache.sling.content.jcr.internal.*,
+ org.apache.sling.jcr.resource.internal.*,
org.apache.jackrabbit.ocm.lock,
org.apache.jackrabbit.ocm.manager.atomictypeconverter.impl,
org.apache.jackrabbit.ocm.manager.beanconverter,
@@ -108,12 +102,10 @@
org.apache.jackrabbit.ocm.mapper.impl.digester;resolution:=optional,*
</Import-Package>
- <!-- CND for the sling:content node type for BaseContent -->
- <Sling-Nodetypes>
- SLING-INF/nodetypes/BaseContent.cnd
- </Sling-Nodetypes>
<Sling-Namespaces>
- sling=http://jackrabbit.apache.org/sling/1.0
+ sling=http://sling.apache.org/sling/1.0
+ TODO!!!
+ ocm=http://jackrabbit.apache.org/ocm/1.0
</Sling-Namespaces>
</instructions>
</configuration>
@@ -130,23 +122,27 @@
<artifactId>osgi_R4_compendium</artifactId>
</dependency>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.sling</groupId>
- <artifactId>sling-component-api</artifactId>
+ <artifactId>api</artifactId>
<version>2.0.0-incubator-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
- <artifactId>sling-mime</artifactId>
+ <artifactId>commons.mime</artifactId>
<version>2.0.0-incubator-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
- <artifactId>sling-json</artifactId>
+ <artifactId>commons.json</artifactId>
<version>2.0.0-incubator-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
- <artifactId>sling-jackrabbit-api</artifactId>
+ <artifactId>jcr.api</artifactId>
<version>2.0.0-incubator-SNAPSHOT</version>
</dependency>
<dependency>
Added: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/DefaultMappedObject.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/DefaultMappedObject.java?rev=592686&view=auto
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/DefaultMappedObject.java (added)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/DefaultMappedObject.java Wed Nov 7 02:23:10 2007
@@ -0,0 +1,370 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.sling.jcr.resource;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManagedHashMap;
+
+/**
+ * The <code>DefaultMappedObject</code> class is a default <code>Content</code>
+ * implementation as follows:
+ * <ul>
+ * <li>This object may be loaded from any existing node.
+ * <li>If inserting a new instance of this class into the repository a node of
+ * type <code>nt:unstructured</code> without any mixin types is created
+ * <li>All non-protected properties are simple read and may be accessed in the
+ * Java standard <code>Map</code> style using the {@link #get(Object)} and
+ * {@link #put(Object, Object)} methods.
+ * <li>Storing the object back to the repository just writes the map contents
+ * into the properties. Care must be taken to obey the node type restrictions if
+ * setting properties, otherwise storing back may fail.
+ * <li>The component ID is retrieved as the <code>sling:componentId</code>
+ * property.
+ * <li>Single-value properties are loaded and stored as scalar instances
+ * according to the mapping below. Multi-value properties are represented by
+ * this object as <code>java.util.List</code> instances.
+ * </ul>
+ * <p>
+ * <b>Reserved Properties</b>
+ * <p>
+ * The following is a list of reserved properties and their meanings. These
+ * properties should not be modified through the getters and setters.
+ * <dl>
+ * <dt><code>path</code>
+ * <dd>The path of the node underlying this instance.
+ * <dt><code>primaryType</code>
+ * <dd>The primary node type of the node underlying this instance. This
+ * property is read-only. Any modifications will not be stored in the node (of
+ * course). For newly created objects, this property is not used to indicate the
+ * desired node type.
+ * <dt><code>mixinTypes</code>
+ * <dd>The list of mixin node types of the node underlying this instance. This
+ * property is read-only. Any modifications will not be stored in the node. For
+ * newly created objects, this property is not used to indicate the desired
+ * mixin node types.
+ * <dt><code>properties</code>
+ * <dd>The map representing the properties of this content object itself.
+ * <dt><code>sling:componentId</code>
+ * <dd>This is not actually a read-only property. But it is used to implement
+ * the {@link #getComponentId()} method. This property may thus be modified, but
+ * care must be taken as the content may not be rendered correctly anymore.
+ * </dl>
+ * <p>
+ * <b>Mapping JCR Property types</b> <table border="1" cellspacing="0"
+ * cellpadding="3">
+ * <tr>
+ * <th colspan="2">Property type to Java types</th>
+ * </tr>
+ * <tr>
+ * <th>JCR Type</th>
+ * <th>Java Type</th>
+ * </tr>
+ * <tr>
+ * <td>STRING</td>
+ * <td>String</td>
+ * </tr>
+ * <tr>
+ * <td>DATE</td>
+ * <td>String</td>
+ * </tr>
+ * <tr>
+ * <td>BINARY</td>
+ * <td>java.io.InputStream</td>
+ * </tr>
+ * <tr>
+ * <td>DOUBLE</td>
+ * <td>java.lang.Double</td>
+ * </tr>
+ * <tr>
+ * <td>LONG</td>
+ * <td>java.lang.Long</td>
+ * </tr>
+ * <tr>
+ * <td>BOOLEAN</td>
+ * <td>java.lang.Boolean</td>
+ * </tr>
+ * <tr>
+ * <td>NAME</td>
+ * <td>String</td>
+ * </tr>
+ * <tr>
+ * <td>PATH</td>
+ * <td>String</td>
+ * </tr>
+ * <tr>
+ * <td>REFERENCE</td>
+ * <td>String</td>
+ * </tr>
+ * <tr>
+ * <th colspan="2">Java type to Property type</th>
+ * </tr>
+ * <tr>
+ * <th>Java Type</th>
+ * <th>JCR Type</th>
+ * </tr>
+ * <tr>
+ * <td>String</td>
+ * <td>STRING</td>
+ * </tr>
+ * <tr>
+ * <td>java.util.Date</td>
+ * <td>DATE</td>
+ * </tr>
+ * <tr>
+ * <td>java.util.Calendar</td>
+ * <td>DATE</td>
+ * </tr>
+ * <tr>
+ * <td>java.util.GregorianCalendar</td>
+ * <td>DATE</td>
+ * </tr>
+ * <tr>
+ * <td>java.io.InputStream</td>
+ * <td>BINARY</td>
+ * </tr>
+ * <tr>
+ * <td>java.lang.Double</td>
+ * <td>DOUBLE</td>
+ * </tr>
+ * <tr>
+ * <td>java.lang.Long</td>
+ * <td>LONG</td>
+ * </tr>
+ * <tr>
+ * <td>java.lang.Integer</td>
+ * <td>LONG</td>
+ * </tr>
+ * <tr>
+ * <td>java.lang.Boolean</td>
+ * <td>BOOLEAN</td>
+ * </tr>
+ * </table>
+ *
+ * @ocm.mapped discriminator="false" extend=""
+ */
+public class DefaultMappedObject extends HashMap<String, Object> {
+
+ /*
+ * Implementation Note: As this class extends the HashMap class it
+ * implements the Map interface and therefore the Commons Beanutils library
+ * used by the Graffito JCR Mapper will directly access the map getter and
+ * setter methods to get and set properties instead of checking for specific
+ * getter and setter methods. For this reason the get() and put() methods
+ * have been overwritten here and check for the specially mapped property
+ * "properties" to call the respective specific getter and setter methods.
+ * As a consequence of this situation, no client properties of the name
+ * "properties" may currently be used. Also the "properties" property is not
+ * actually stored in the hash map and will not be iterated over. But the
+ * check for existence (containsKey) will also consider the "properties"
+ * property.
+ */
+
+ /**
+ * The name of the <i>path</i> object property.
+ * <p>
+ * See the implementation notes above regarding this property.
+ */
+ private static final String FIELD_PATH = "path";
+
+ /**
+ * The name of the <i>properties</i> object property.
+ * <p>
+ * See the implementation notes above regarding this property.
+ */
+ private static final String FIELD_PROPERTIES = "properties";
+
+ /**
+ * The name of the <i>primaryType</i> object property.
+ * <p>
+ * See the implementation notes above regarding this property.
+ */
+ private static final String FIELD_PRIMARY_TYPE = "primaryType";
+
+ /**
+ * The name of the <i>mixinTypes</i> object property.
+ * <p>
+ * See the implementation notes above regarding this property.
+ */
+ private static final String FIELD_MIXIN_TYPES = "mixinTypes";
+
+ /**
+ * Returns the value of the indexed property.
+ * <p>
+ * For the special property <code>properties</code> the
+ * {@link #getProperties()} method is called to return a copy of this map
+ * instead of looking in the map itself.
+ *
+ * @param key The index of the property to return.
+ * @return the indicated property or <code>null</code> if the map does not
+ * contain it.
+ */
+ public Object get(String key) {
+ // handle properties as if they were map elements
+ // due to an inconsistency in the BeanUtils 1.5 through 1.7.0
+ // versions. Version 1.7.1 will fix this again, though ...
+ if (FIELD_PROPERTIES.equals(key)) {
+ return this.getProperties();
+ }
+
+ return super.get(key);
+ }
+
+ /**
+ * Sets the value of the indexed property.
+ * <p>
+ * For the special property <code>properties</code> the
+ * {@link #setProperties(ManagedHashMap)} method is called to insert all
+ * elements of the <code>value</code> which must be a <code>Map</code>
+ * into this map.
+ *
+ * @param key The index of the property to set
+ * @param value The value of the property to set.
+ * @return The former value of the property or <code>null</code> if the
+ * property is new.
+ * @throws ClassCastException If the type of the <code>value</code> is
+ * <code>ManagedHashMap</code> for the <code>properties</code>
+ * property.
+ */
+ public Object put(String key, Object value) {
+ // handle properties as if they were map elements
+ // due to an inconsistency in the BeanUtils 1.5 through 1.7.0
+ // versions. Version 1.7.1 will fix this again, though ...
+ if (FIELD_PROPERTIES.equals(key)) {
+ Object old = this.getProperties();
+ this.setProperties((ManagedHashMap) value);
+ return old;
+ }
+
+ return super.put(key, value);
+ }
+
+ /**
+ * Returns <code>true</code> if this map contains the named property.
+ */
+ public boolean containsKey(String key) {
+ return FIELD_PROPERTIES.equals(key) || super.containsKey(key);
+ }
+
+ // ---------- Content Mapping support --------------------------------------
+
+ /**
+ * Sets the path of this <code>Content</code> object.
+ *
+ * @ocm.field path="true"
+ */
+ public void setPath(String path) {
+ if (path != null) {
+ this.put(FIELD_PATH, path);
+ }
+ }
+
+ /**
+ * Returns the path of this <code>Content</code> object.
+ */
+ public String getPath() {
+ return (String) this.get(FIELD_PATH);
+ }
+
+ /**
+ * Sets the properties of this content object as read from the properties of
+ * the repository node.
+ * <p>
+ * This method copies the properties of the <code>contents</code> map into
+ * this map instance.
+ *
+ * @ocm.collection jcrName="*"
+ * collectionConverter="org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ResidualPropertiesCollectionConverterImpl"
+ */
+ public void setProperties(ManagedHashMap contents) {
+ if (contents != null) {
+ this.putAll(contents);
+ }
+ }
+
+ /**
+ * Returns the properties of this content to be written to the properties of
+ * the repository node.
+ * <p>
+ * The contents of the returned map replace all non-protected properties of
+ * the repository. That is, existing properties not contained in the map
+ * will be removed.
+ * <p>
+ * This method returns a new instance of a <code>ManagedHashMap</code>
+ * containing a copy of the current properties on each call.
+ */
+ public ManagedHashMap getProperties() {
+ // a copy of this map with the special properties removed
+ ManagedHashMap properties = new ManagedHashMap(this);
+ properties.remove(FIELD_PATH);
+ properties.remove(FIELD_PRIMARY_TYPE);
+ properties.remove(FIELD_MIXIN_TYPES);
+ return properties;
+ }
+
+ /**
+ * Sets the primary node type of the underlying node.
+ * <p>
+ * This method should only be called by the Graffito Mapper to set the type
+ * read from the node.
+ *
+ * @ocm.field jcrName="jcr:primaryType" autoUpdate="false"
+ * autoInsert="false"
+ */
+ public void setPrimaryType(String type) {
+ this.put(FIELD_PRIMARY_TYPE, type);
+ }
+
+ /**
+ * Returns the primary node type of the underlying node or <code>null</code>
+ * for new objects.
+ */
+ public String getPrimaryType() {
+ return (String) this.get(FIELD_PRIMARY_TYPE);
+ }
+
+ /**
+ * Sets the mixin node types of the underlying node.
+ * <p>
+ * This method should only be called by the Graffito Mapper to set the types
+ * read from the node.
+ *
+ * @ocm.collection jcrName="jcr:mixinTypes"
+ * elementClassName="java.lang.String"
+ * collectionConverter="org.apache.jackrabbit.ocm.manager.collectionconverter.impl.MultiValueCollectionConverterImpl"
+ * autoUpdate="false" autoInsert="false"
+ */
+ public void setMixinTypes(ArrayList mixinTypes) {
+ if (mixinTypes != null) {
+ this.put(FIELD_MIXIN_TYPES, new ArrayList(mixinTypes));
+ }
+ }
+
+ /**
+ * Returns a list of the mixin node typse of the underlying node or
+ * <code>null</code> for new objects or if the node has no mixin node
+ * types.
+ */
+ public ArrayList getMixinTypes() {
+ List types = (List) this.get(FIELD_MIXIN_TYPES);
+ return (types != null) ? new ArrayList(types) : null;
+ }
+}
Added: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceConstants.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceConstants.java?rev=592686&view=auto
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceConstants.java (added)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceConstants.java Wed Nov 7 02:23:10 2007
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.sling.jcr.resource;
+
+/**
+ * The <code>JcrResourceConstants</code> interface provides constant values
+ * for event topics and event properties for events sent from this bundle.
+ */
+public interface JcrResourceConstants {
+
+ /**
+ * The namespace URI used by the JCR Mapping implementation for internal
+ * properties, such as the discriminator property set on certain nodes to
+ * indicate the fully qualified name of the class to which the node is
+ * mapped (value is "http://jackrabbit.apache.org/ocm").
+ */
+ static final String JCR_OCM_NS_URI = "http://jackrabbit.apache.org/ocm";
+
+ /**
+ * The namespace prefix used for the
+ * {@link #JCR_OCM_NS_URI mapping namespace URI} (value is "ocm").
+ */
+ static final String JCR_OCM_NS_PREFIX = "ocm";
+
+ static final String SLING_NS_URI = "http://jackrabbit.apache.org/sling/1.0";
+
+ static final String SLING_NS_PREFIX = "sling";
+
+ /**
+ * The topic root for events published by this bundle (value is
+ * "org/apache/sling/content/jcr/ContentEvent"). Event consumers should
+ * register to "org/apache/sling/content/jcr/ContentEvent/*" to receive all
+ * events from this bundle.
+ */
+ static final String CONTENT_EVENT = "org/apache/sling/content/jcr/ContentEvent";
+
+ /**
+ * The name of the event sent after new Object Mappings have been registered
+ * (value is "org/apache/sling/content/jcr/ContentEvent/MAPPED"). This name
+ * is appended to the {@link #CONTENT_EVENT root topic} to create the event
+ * topic.
+ * <p>
+ * Events of this topics have two additional properties:
+ * {@link #MAPPING_CLASS} and {@link #MAPPING_NODE_TYPE}.
+ */
+ static final String EVENT_MAPPING_ADDED = CONTENT_EVENT + "/MAPPED";
+
+ /**
+ * The name of the event sent after Object Mappings have been unregistered
+ * (value is "org/apache/sling/content/jcr/ContentEvent/UNMAPPED"). This
+ * name is appended to the {@link #CONTENT_EVENT root topic} to create the
+ * event topic.
+ * <p>
+ * Events of this topics have two additional properties:
+ * {@link #MAPPING_CLASS} and {@link #MAPPING_NODE_TYPE}.
+ */
+ static final String EVENT_MAPPING_REMOVED = CONTENT_EVENT + "/UNMAPPED";
+
+ /**
+ * The name of the event property providing a <code>String[]</code> of
+ * class names mapped at the time the event is sent (value is
+ * "MAPPED_CLASS"). This is the complete list of all classes which are
+ * supported by the content manager for mapping.
+ */
+ static final String MAPPING_CLASS = "MAPPED_CLASS";
+
+ /**
+ * The name of the event property providing a <code>String[]</code> of
+ * node types mapped at the time the event is sent (value is
+ * "MAPPED_NODE_TYPE"). This is the complete list of all node types which
+ * are supported by the content manager for mapping.
+ */
+ static final String MAPPING_NODE_TYPE = "MAPPED_NODE_TYPE";
+}
Added: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceManagerFactory.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceManagerFactory.java?rev=592686&view=auto
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceManagerFactory.java (added)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceManagerFactory.java Wed Nov 7 02:23:10 2007
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.sling.jcr.resource;
+
+import javax.jcr.Session;
+
+import org.apache.sling.api.SlingException;
+import org.apache.sling.api.resource.ResourceManager;
+
+/**
+ * The <code>ContentManagerFactory</code> TODO
+ */
+public interface JcrResourceManagerFactory {
+
+ /**
+ * Returns a ContentManager for the given session. Calling this method
+ * repeatedly for the same session returns the same ContentManager instance.
+ */
+ ResourceManager getResourceManager(Session session) throws SlingException;
+
+}
Added: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/SyntheticResource.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/SyntheticResource.java?rev=592686&view=auto
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/SyntheticResource.java (added)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/SyntheticResource.java Wed Nov 7 02:23:10 2007
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.sling.jcr.resource;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceMetadata;
+
+/**
+ * The <code>SyntheticResource</code> class is a simple implementation of the
+ * <code>Resource</code> interface which may be used to provide a resource
+ * object which is related to a repository item.
+ */
+public class SyntheticResource implements Resource {
+
+ /** The path of the synthetic resource */
+ private String path;
+
+ /** The type this synthetic resource assumes */
+ private String resourceType;
+
+ /** The metadat of this resource just containig the resource path */
+ private ResourceMetadata resourceMetadata;
+
+ /**
+ * Creates a synthetic content with the given path and component Id.
+ *
+ * @param path The path of the synthetic content
+ * @param resourceType The ID of the component rendering the synthetic
+ * content
+ */
+ public SyntheticResource(String path, String resourceType) {
+ this.path = path;
+ this.resourceType = resourceType;
+ this.resourceMetadata = new ResourceMetadata();
+ this.resourceMetadata.put(ResourceMetadata.RESOLUTION_PATH, path);
+ }
+
+ public String getURI() {
+ return path;
+ }
+
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public ResourceMetadata getResourceMetadata() {
+ return resourceMetadata;
+ }
+
+ public Object getRawData() {
+ return null;
+ }
+
+ public Object getObject() {
+ return null;
+ }
+
+}
Copied: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrContentHelper.java (from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/JcrContentHelper.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrContentHelper.java?p2=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrContentHelper.java&p1=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/JcrContentHelper.java&r1=592370&r2=592686&rev=592686&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/JcrContentHelper.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrContentHelper.java Wed Nov 7 02:23:10 2007
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.sling.content.jcr.internal;
+package org.apache.sling.jcr.resource.internal;
import java.util.Dictionary;
import java.util.Hashtable;
@@ -24,12 +24,13 @@
import javax.jcr.Session;
-import org.apache.sling.content.jcr.JcrContentManager;
-import org.apache.sling.content.jcr.JcrContentManagerFactory;
-import org.apache.sling.content.jcr.internal.loader.Loader;
-import org.apache.sling.content.jcr.internal.mapping.PersistenceManagerProviderImpl;
-import org.apache.sling.jcr.SlingRepository;
-import org.apache.sling.mime.MimeTypeService;
+import org.apache.sling.api.SlingException;
+import org.apache.sling.api.resource.ResourceManager;
+import org.apache.sling.commons.mime.MimeTypeService;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.jcr.resource.JcrResourceManagerFactory;
+import org.apache.sling.jcr.resource.internal.loader.Loader;
+import org.apache.sling.jcr.resource.internal.mapping.PersistenceManagerProviderImpl;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.ServiceReference;
@@ -44,14 +45,14 @@
* The <code>JcrContentHelper</code> TODO
*
* @scr.component immediate="true" label="%content.name"
- * description="%content.description"
+ * description="%content.description" metatype="false"
* @scr.property name="service.description"
* value="Sling ContentManagerFactory Implementation"
* @scr.property name="service.vendor" value="The Apache Software Foundation"
- * @scr.service interface="org.apache.sling.content.jcr.JcrContentManagerFactory"
+ * @scr.service interface="org.apache.sling.jcr.resource.JcrResourceManagerFactory"
* @author fmeschbe
*/
-public class JcrContentHelper implements JcrContentManagerFactory,
+public class JcrContentHelper implements JcrResourceManagerFactory,
SynchronousBundleListener {
private ComponentContext componentContext;
@@ -80,8 +81,8 @@
/**
* @throws IllegalStateException If this provider is not operational
*/
- public JcrContentManager getContentManager(Session session) {
- return this.pmProvider.getContentManager(session);
+ public ResourceManager getResourceManager(Session session) throws SlingException{
+ return this.pmProvider.getResourceManager(session);
}
// ---------- BundleListener -----------------------------------------------
Copied: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/JsonReader.java (from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/JsonReader.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/JsonReader.java?p2=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/JsonReader.java&p1=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/JsonReader.java&r1=592370&r2=592686&rev=592686&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/JsonReader.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/JsonReader.java Wed Nov 7 02:23:10 2007
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.sling.content.jcr.internal.loader;
+package org.apache.sling.jcr.resource.internal.loader;
import java.io.IOException;
import java.io.InputStream;
@@ -25,9 +25,9 @@
import javax.jcr.PropertyType;
import org.apache.commons.io.IOUtils;
-import org.apache.sling.json.JSONArray;
-import org.apache.sling.json.JSONException;
-import org.apache.sling.json.JSONObject;
+import org.apache.sling.commons.json.JSONArray;
+import org.apache.sling.commons.json.JSONException;
+import org.apache.sling.commons.json.JSONObject;
/**
Copied: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Loader.java (from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/Loader.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Loader.java?p2=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Loader.java&p1=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/Loader.java&r1=592370&r2=592686&rev=592686&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/Loader.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Loader.java Wed Nov 7 02:23:10 2007
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.sling.content.jcr.internal.loader;
+package org.apache.sling.jcr.resource.internal.loader;
import java.io.IOException;
import java.io.InputStream;
@@ -41,7 +41,7 @@
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import org.apache.sling.content.jcr.internal.JcrContentHelper;
+import org.apache.sling.jcr.resource.internal.JcrContentHelper;
import org.osgi.framework.Bundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -256,7 +256,7 @@
}
ins = nodeXML.openStream();
- org.apache.sling.content.jcr.internal.loader.Node clNode = nodeReader.parse(ins);
+ org.apache.sling.jcr.resource.internal.loader.Node clNode = nodeReader.parse(ins);
// nothing has been parsed
if (clNode == null) {
@@ -283,7 +283,7 @@
}
}
- private Node createNode(Node parentNode, org.apache.sling.content.jcr.internal.loader.Node clNode) throws RepositoryException {
+ private Node createNode(Node parentNode, org.apache.sling.jcr.resource.internal.loader.Node clNode) throws RepositoryException {
Node node;
if (parentNode.hasNode(clNode.getName())) {
node = parentNode.getNode(clNode.getName());
@@ -321,7 +321,7 @@
}
if (clNode.getChildren() != null) {
- for (org.apache.sling.content.jcr.internal.loader.Node child : clNode.getChildren()) {
+ for (org.apache.sling.jcr.resource.internal.loader.Node child : clNode.getChildren()) {
this.createNode(node, child);
}
}
Copied: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Node.java (from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/Node.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Node.java?p2=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Node.java&p1=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/Node.java&r1=592370&r2=592686&rev=592686&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/Node.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Node.java Wed Nov 7 02:23:10 2007
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.sling.content.jcr.internal.loader;
+package org.apache.sling.jcr.resource.internal.loader;
import java.util.ArrayList;
import java.util.HashSet;
Copied: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/NodeReader.java (from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/NodeReader.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/NodeReader.java?p2=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/NodeReader.java&p1=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/NodeReader.java&r1=592370&r2=592686&rev=592686&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/NodeReader.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/NodeReader.java Wed Nov 7 02:23:10 2007
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.sling.content.jcr.internal.loader;
+package org.apache.sling.jcr.resource.internal.loader;
import java.io.IOException;
import java.io.InputStream;
Copied: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Property.java (from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/Property.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Property.java?p2=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Property.java&p1=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/Property.java&r1=592370&r2=592686&rev=592686&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/Property.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/Property.java Wed Nov 7 02:23:10 2007
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.sling.content.jcr.internal.loader;
+package org.apache.sling.jcr.resource.internal.loader;
import java.util.ArrayList;
import java.util.List;
Copied: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/XmlReader.java (from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/XmlReader.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/XmlReader.java?p2=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/XmlReader.java&p1=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/XmlReader.java&r1=592370&r2=592686&rev=592686&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/XmlReader.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/XmlReader.java Wed Nov 7 02:23:10 2007
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.sling.content.jcr.internal.loader;
+package org.apache.sling.jcr.resource.internal.loader;
import java.io.IOException;
import java.io.InputStream;
Copied: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/nodetype/BaseNodeManagementException.java (from r592674, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/nodetype/BaseNodeManagementException.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/nodetype/BaseNodeManagementException.java?p2=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/nodetype/BaseNodeManagementException.java&p1=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/nodetype/BaseNodeManagementException.java&r1=592674&r2=592686&rev=592686&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/nodetype/BaseNodeManagementException.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/nodetype/BaseNodeManagementException.java Wed Nov 7 02:23:10 2007
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.sling.content.jcr.internal.loader.nodetype;
+package org.apache.sling.jcr.resource.internal.loader.nodetype;
/**
* Base exception for all JCR Node Type Management exceptions.
Copied: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/nodetype/NodeTypeCreationException.java (from r592674, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/nodetype/NodeTypeCreationException.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/nodetype/NodeTypeCreationException.java?p2=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/nodetype/NodeTypeCreationException.java&p1=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/nodetype/NodeTypeCreationException.java&r1=592674&r2=592686&rev=592686&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/loader/nodetype/NodeTypeCreationException.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/loader/nodetype/NodeTypeCreationException.java Wed Nov 7 02:23:10 2007
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.sling.content.jcr.internal.loader.nodetype;
+package org.apache.sling.jcr.resource.internal.loader.nodetype;
/**
* Exception that is thrown when a JCR node type could not be created.
Copied: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/BundleMapper.java (from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/BundleMapper.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/BundleMapper.java?p2=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/BundleMapper.java&p1=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/BundleMapper.java&r1=592370&r2=592686&rev=592686&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/BundleMapper.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/BundleMapper.java Wed Nov 7 02:23:10 2007
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.sling.content.jcr.internal.mapping;
+package org.apache.sling.jcr.resource.internal.mapping;
import java.util.Map;
Copied: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ClassDescriptorReader.java (from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/ClassDescriptorReader.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ClassDescriptorReader.java?p2=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ClassDescriptorReader.java&p1=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/ClassDescriptorReader.java&r1=592370&r2=592686&rev=592686&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/ClassDescriptorReader.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ClassDescriptorReader.java Wed Nov 7 02:23:10 2007
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.sling.content.jcr.internal.mapping;
+package org.apache.sling.jcr.resource.internal.mapping;
import java.io.IOException;
import java.io.InputStream;
Copied: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ContentManagerImpl.java (from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/ContentManagerImpl.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ContentManagerImpl.java?p2=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ContentManagerImpl.java&p1=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/ContentManagerImpl.java&r1=592370&r2=592686&rev=592686&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/ContentManagerImpl.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ContentManagerImpl.java Wed Nov 7 02:23:10 2007
@@ -16,18 +16,25 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.sling.content.jcr.internal.mapping;
+package org.apache.sling.jcr.resource.internal.mapping;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.NoSuchElementException;
+import javax.jcr.Item;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import javax.jcr.query.Query;
+import javax.jcr.Value;
import javax.jcr.query.QueryResult;
-
+import javax.jcr.query.RowIterator;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
import org.apache.jackrabbit.ocm.exception.JcrMappingException;
import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverterProvider;
@@ -40,23 +47,32 @@
import org.apache.jackrabbit.ocm.query.QueryManager;
import org.apache.jackrabbit.ocm.query.impl.QueryManagerImpl;
import org.apache.jackrabbit.ocm.reflection.ReflectionUtils;
-import org.apache.sling.component.Content;
-import org.apache.sling.content.jcr.DefaultContent;
-import org.apache.sling.content.jcr.InvalidQueryException;
-import org.apache.sling.content.jcr.JcrContentManager;
+import org.apache.sling.api.SlingException;
+import org.apache.sling.api.resource.NonExistingResource;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceManager;
+import org.apache.sling.api.resource.ResourceMetadata;
+import org.apache.sling.jcr.resource.DefaultMappedObject;
+import org.apache.sling.jcr.resource.internal.util.JcrHelper;
+import org.apache.sling.jcr.resource.internal.util.JcrNodeResource;
+import org.apache.sling.jcr.resource.internal.util.ResourcePathIterator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The <code>ContentManagerImpl</code> TODO
*/
-public class ContentManagerImpl extends ObjectContentManagerImpl implements
- JcrContentManager {
+public class ContentManagerImpl implements ResourceManager {
+
+ /** default log */
+ private final Logger log = LoggerFactory.getLogger(getClass());
/**
* The class used to load repository content into if a mapping cannot be
* found for a given existing node. See {@link #load(String)}.
*/
- public static final Class DEFAULT_CONTENT_CLASS = DefaultContent.class;
+ public static final Class DEFAULT_CONTENT_CLASS = DefaultMappedObject.class;
protected static final String ACTION_READ = "read";
protected static final String ACTION_CREATE = "add_node,set_property";
@@ -66,7 +82,7 @@
private PersistenceManagerProviderImpl pmProvider;
- private boolean autoSave;
+ private ObjectContentManagerImpl ocm;
/**
*
@@ -77,7 +93,7 @@
public ContentManagerImpl(PersistenceManagerProviderImpl pmProvider,
Mapper mapper, AtomicTypeConverterProvider typeConverterProvider,
Session session) throws RepositoryException {
- super(mapper, null, null, null, session);
+ ocm = new ObjectContentManagerImpl(mapper, null, null, null, session);
ObjectCache objectCache = new ObservingObjectCache(session); // new RequestObjectCacheImpl();
QueryManager queryManager = new QueryManagerImpl(mapper,
@@ -86,37 +102,23 @@
ObjectConverter objectConverter = new ObjectConverterImpl(mapper,
typeConverterProvider, new ProxyManagerImpl(), objectCache);
- this.setObjectConverter(objectConverter);
- this.setQueryManager(queryManager);
- this.setRequestObjectCache(objectCache);
+ ocm.setObjectConverter(objectConverter);
+ ocm.setQueryManager(queryManager);
+ ocm.setRequestObjectCache(objectCache);
this.pmProvider = pmProvider;
}
- public void logout() {
- // does nothing according to the ContentManager API spec
+ protected Session getSession() {
+ return ocm.getSession();
}
// ---------- Persistence Support ------------------------------------------
/**
- * @see org.apache.sling.core.content.ContentManager#setAutoSave(boolean)
- */
- public void setAutoSave(boolean autoSave) {
- this.autoSave = autoSave;
- }
-
- /**
- * @see org.apache.sling.core.content.ContentManager#isAutoSave()
- */
- public boolean isAutoSave() {
- return this.autoSave;
- }
-
- /**
* @return
*/
- public boolean hasPendingChanges() {
+ public boolean hasChanges() {
try {
return this.getSession().hasPendingChanges();
} catch (RepositoryException re) {
@@ -127,55 +129,62 @@
/**
* @see org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl#refresh(boolean)
*/
- public void refresh(boolean keepChanges) {
+ public void rollback() {
try {
- this.getSession().refresh(keepChanges);
+ getSession().refresh(false);
} catch (RepositoryException re) {
throw new ObjectContentManagerException("Cannot rollback changes", re);
}
}
- /**
- * @see org.apache.sling.core.content.ContentManager#copy(org.apache.sling.core.component.Content, java.lang.String, boolean)
- */
- public void copy(Content content, String destination, boolean deep) {
+ public void save() throws SlingException {
+ try {
+ getSession().save();
+ } catch (RepositoryException re) {
+ throw new SlingException("Cannot save changes", re);
+ }
+ }
+
+ public void copy(Resource resource, String destination, boolean deep)
+ throws SlingException {
this.checkPermission(destination, ACTION_CREATE);
if (deep) {
// recursively copy directly in the repository
try {
- this.getSession().getWorkspace().copy(content.getPath(), destination);
+ getSession().getWorkspace().copy(resource.getURI(), destination);
} catch (RepositoryException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ e.printStackTrace(); // To change body of catch statement use
+ // File | Settings | File Templates.
}
} else {
- Content copied = this.load(content.getPath(), content.getClass());
- this.setPath(copied, destination);
- this.insert(copied);
+ Object copied = load(resource.getURI(),
+ resource.getObject().getClass());
+ setPath(copied, destination);
+ ocm.insert(copied);
}
- this.conditionalSave();
}
/**
* @see org.apache.sling.content.ContentManager#create(org.apache.sling.component.Content)
*/
- public void create(Content content) {
- String path = content.getPath();
+ public void create(Resource resource) {
+ if (resource.getObject() != null) {
+ String path = resource.getURI();
- this.checkPermission(path, ACTION_CREATE);
+ this.checkPermission(path, ACTION_CREATE);
- // TODO handle exceptions correctly
- this.insert(content);
- this.conditionalSave();
+ // TODO handle exceptions correctly
+ ocm.insert(resource.getObject());
+ }
}
/**
* @see org.apache.sling.core.content.ContentManager#delete(org.apache.sling.core.component.Content)
*/
- public void delete(Content content) {
- this.checkPermission(content.getPath(), ACTION_REMOVE);
- this.remove(content);
- this.conditionalSave();
+ public void delete(Resource resource) throws SlingException {
+ this.checkPermission(resource.getURI(), ACTION_REMOVE);
+ ocm.remove(resource.getURI());
}
/**
@@ -183,8 +192,7 @@
*/
public void delete(String path) {
this.checkPermission(path, ACTION_REMOVE);
- this.remove(path);
- this.conditionalSave();
+ ocm.remove(path);
}
/**
@@ -201,22 +209,19 @@
* @throws AccessControlException If the item really exists but this content
* manager's session has no read access to it.
*/
- public Content load(String path) {
+ public Object load(String path) {
if (this.itemExists(path)) {
// load and return (only if content)
try {
- Object loaded = this.getObject(path);
- if (loaded instanceof Content) {
- return (Content) loaded;
+ Object loaded = ocm.getObject(path);
+ if (loaded != null) {
+ return loaded;
}
} catch (JcrMappingException jme) {
// fall back to default content
try {
- Object loaded = this.getObject(DEFAULT_CONTENT_CLASS, path);
- if (loaded instanceof Content) {
- return (Content) loaded;
- }
+ return ocm.getObject(DEFAULT_CONTENT_CLASS, path);
} catch (Throwable t) {
// don't care for this exception, use initial one
throw jme;
@@ -231,13 +236,10 @@
/**
* @see org.apache.sling.core.content.ContentManager#load(java.lang.String, java.lang.Class)
*/
- public Content load(String path, Class type) {
+ public Object load(String path, Class<?> type) {
if (this.itemExists(path)) {
// load and return (only if content)
- Object loaded = this.getObject(type, path);
- if (loaded instanceof Content) {
- return (Content) loaded;
- }
+ return ocm.getObject(type, path);
}
// item does not exist or is no content
@@ -247,14 +249,15 @@
/**
* @see org.apache.sling.core.content.ContentManager#move(org.apache.sling.core.component.Content, java.lang.String)
*/
- public void move(Content content, String destination) {
- this.move(content.getPath(), destination);
+ public void move(Resource resource, String destination)
+ throws SlingException {
+ this.move(resource.getURI(), destination);
}
/**
* @see org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl#move(java.lang.String, java.lang.String)
*/
- public void move(String source, String destination) {
+ public void move(String source, String destination) throws SlingException {
this.checkPermission(source, ACTION_REMOVE);
this.checkPermission(destination, ACTION_CREATE);
@@ -266,23 +269,22 @@
// } catch (ConstraintViolationException cve) {
// } catch (LockException le) {
} catch (RepositoryException re) {
- throw new ObjectContentManagerException("Cannot move " + source + " to "
+ throw new SlingException("Cannot move " + source + " to "
+ destination, re);
}
-
- this.conditionalSave();
}
/**
* @see org.apache.sling.core.content.ContentManager#orderBefore(org.apache.sling.core.component.Content, java.lang.String)
*/
- public void orderBefore(Content content, String afterName) {
+ public void orderBefore(Resource resource, String afterName)
+ throws SlingException {
Node parent;
try {
- parent = this.getSession().getItem(content.getPath()).getParent();
+ parent = ((Item) resource.getRawData()).getParent();
} catch (RepositoryException re) {
- throw new ObjectContentManagerException("Cannot get parent of "
- + content.getPath() + " to order content");
+ throw new SlingException("Cannot get parent of "
+ + resource.getURI() + " to order content");
}
// check whether the parent node supports child node ordering
@@ -291,60 +293,72 @@
return;
}
} catch (RepositoryException re) {
- throw new ObjectContentManagerException("Cannot check whether "
- + content.getPath() + " can be ordered", re);
+ throw new SlingException("Cannot check whether "
+ + resource.getURI() + " can be ordered", re);
}
- int ls = content.getPath().lastIndexOf('/');
- String name = content.getPath().substring(ls + 1);
+ int ls = resource.getURI().lastIndexOf('/');
+ String name = resource.getURI().substring(ls + 1);
try {
parent.orderBefore(name, afterName);
} catch (RepositoryException re) {
- throw new ObjectContentManagerException("Cannot order " + content.getPath(),
- re);
+ throw new SlingException("Cannot order " + resource.getURI(), re);
}
-
- this.conditionalSave();
}
/**
* @see org.apache.sling.core.content.ContentManager#store(org.apache.sling.core.component.Content)
*/
- public void store(Content content) {
- this.update(content);
- this.conditionalSave();
+ public void store(Resource resource) throws SlingException {
+ if (resource.getObject() != null) {
+ ocm.update(resource.getObject());
+ }
}
//---------- JcrContentManager interface ----------------------------------
- public Iterator getObjects(String queryExpression, String language) {
+ public Resource resolve(ServletRequest request) throws SlingException {
+ Resource result = null;
+ String path = null;
+ String pathInfo = ((HttpServletRequest) request).getPathInfo();
try {
- Session session = this.getSession();
- javax.jcr.query.QueryManager queryManager = session.getWorkspace().getQueryManager();
- Query query = queryManager.createQuery(queryExpression, language);
- final QueryResult queryResult = query.execute();
-
- return new Iterator() {
- private final NodeIterator results;
- private Object nextResult;
-
- {
- this.results = queryResult.getNodes();
- this.seek();
- }
+ final ResourcePathIterator it = new ResourcePathIterator(pathInfo);
+ while (it.hasNext() && result == null) {
+ result = getResourceInternal(it.next(), null);
+ }
+ } catch (RepositoryException re) {
+ throw new SlingException("RepositoryException for path=" + path, re);
+ }
+
+ if (result == null) {
+ result = new NonExistingResource(pathInfo);
+ }
+
+ return result;
+ }
+
+ public Iterator<Resource> findResources(String query, String language)
+ throws SlingException {
+ try {
+ QueryResult res = JcrHelper.query(getSession(), query, language);
+ final NodeIterator nodes = res.getNodes();
+
+ return new Iterator<Resource>() {
+
+ private Resource nextResult = seek();
public boolean hasNext() {
- return this.nextResult != null;
+ return nextResult != null;
}
- public Object next() {
- if (this.nextResult == null) {
+ public Resource next() {
+ if (nextResult == null) {
throw new NoSuchElementException();
}
- Object result = this.nextResult;
- this.seek();
+ Resource result = nextResult;
+ nextResult = seek();
return result;
}
@@ -352,15 +366,11 @@
throw new UnsupportedOperationException();
}
- private void seek() {
- while (this.results.hasNext()) {
+ private Resource seek() {
+ while (nodes.hasNext()) {
try {
- Node node = this.results.nextNode();
- Object value = ContentManagerImpl.this.getObject(node.getPath());
- if (value != null) {
- this.nextResult = value;
- return;
- }
+ return new JcrNodeResource(ContentManagerImpl.this,
+ nodes.nextNode());
} catch (RepositoryException re) {
// TODO: log this situation and continue mapping
} catch (ObjectContentManagerException ocme) {
@@ -371,23 +381,40 @@
}
// no more results
- this.nextResult = null;
+ return null;
}
};
} catch (javax.jcr.query.InvalidQueryException iqe) {
- throw new InvalidQueryException(iqe);
+ throw new SlingException(iqe);
} catch (RepositoryException re) {
- throw new ObjectContentManagerException(re.getMessage(), re);
+ throw new SlingException(re.getMessage(), re);
}
}
//---------- implementation helper ----------------------------------------
- protected void conditionalSave() {
- if (this.isAutoSave()) {
- this.save();
+ /** Creates a JcrNodeResource with the given path if existing */
+ protected Resource getResourceInternal(String path, Class<?> type)
+ throws RepositoryException {
+ Session session = getSession();
+ if (session.itemExists(path)) {
+ Resource result;
+
+ if (type != null) {
+ Object mapped = load(path, type);
+ result = new JcrNodeResource(session, path, mapped);
+ } else {
+ result = new JcrNodeResource(this, session, path);
+ }
+ result.getResourceMetadata().put(ResourceMetadata.RESOLUTION_PATH,
+ path);
+ log.info("Found Resource at path '{}'", path);
+ return result;
}
+
+ log.info("Path '{}' does not resolve to an Item", path);
+ return null;
}
/**
@@ -424,8 +451,138 @@
}
}
- protected void setPath(Content content, String path) {
+ protected void setPath(Object content, String path) {
+ // TODO: Investigate more here !!
ReflectionUtils.setNestedProperty(content, "path", path);
+ }
+
+ public Resource getResource(String path, Class<?> type)
+ throws SlingException {
+ path = JcrHelper.resolveRelativeSegments(path);
+ if (path != null) {
+ try {
+ return getResourceInternal(path, type);
+ } catch (RepositoryException re) {
+ throw new SlingException("Cannot get resource " + path, re);
+ }
+ }
+
+ // relative path segments cannot be resolved
+ return null;
+ }
+
+ public Resource getResource(String path) throws SlingException {
+ return getResource(path, null);
+ }
+
+ public Resource getResource(Resource base, String path)
+ throws SlingException {
+ // special case of absolute paths
+ if (path.startsWith("/")) {
+ return getResource(path);
+ }
+
+ // resolve relative path segments now
+ path = JcrHelper.resolveRelativeSegments(path);
+ if (path != null) {
+ if (path.length() == 0) {
+ // return the base resource
+ return base;
+ } else if (base.getRawData() instanceof Node) {
+ try {
+ Node baseNode = (Node) base.getRawData();
+ if (baseNode.hasNode(path)) {
+ return new JcrNodeResource(this, baseNode.getNode(path));
+ }
+
+ log.error("getResource: There is no node at {} below {}",
+ path, base.getURI());
+ return null;
+ } catch (RepositoryException re) {
+ log.error(
+ "getResource: Problem accessing relative resource at "
+ + path, re);
+ return null;
+ }
+ }
+ }
+
+ // try (again) with absolute resource path
+ path = base.getURI() + "/" + path;
+ return getResource(path);
+ }
+
+ public Iterator<Resource> listChildren(final Resource parent)
+ throws SlingException {
+ if (parent.getRawData() instanceof Node) {
+
+ try {
+ final NodeIterator children = ((Node) parent.getRawData()).getNodes();
+ return new Iterator<Resource>() {
+
+ public boolean hasNext() {
+ return children.hasNext();
+ }
+
+ public Resource next() {
+ try {
+ return new JcrNodeResource(ContentManagerImpl.this,
+ children.nextNode());
+ } catch (RepositoryException re) {
+ log.warn(
+ "Problem while trying to create a resource", re);
+ return new NonExistingResource(parent.getURI()
+ + "/?");
+ }
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException("remove");
+ }
+
+ };
+ } catch (RepositoryException re) {
+ throw new SlingException("Cannot get children of Resource "
+ + parent, re);
+ }
+ }
+
+ // return an empty iterator if parent has no node
+ List<Resource> empty = Collections.emptyList();
+ return empty.iterator();
+ }
+
+ public Iterator<Map<String, Object>> queryResources(String query,
+ String language) throws SlingException {
+ try {
+ QueryResult result = JcrHelper.query(getSession(), query, language);
+ final String[] colNames = result.getColumnNames();
+ final RowIterator rows = result.getRows();
+ return new Iterator<Map<String, Object>>() {
+ public boolean hasNext() {
+ return rows.hasNext();
+ };
+
+ public Map<String, Object> next() {
+ Map<String, Object> row = new HashMap<String, Object>();
+ try {
+ Value[] values = rows.nextRow().getValues();
+ for (int i = 0; i < values.length; i++) {
+ row.put(colNames[i], JcrHelper.toJavaObject(values[i]));
+ }
+ } catch (RepositoryException re) {
+ // TODO:log
+ }
+ return row;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException("remove");
+ }
+ };
+ } catch (RepositoryException re) {
+ throw new SlingException(re);
+ }
}
}
Copied: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/MapperAtomicTypeConverterProvider.java (from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/MapperAtomicTypeConverterProvider.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/MapperAtomicTypeConverterProvider.java?p2=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/MapperAtomicTypeConverterProvider.java&p1=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/MapperAtomicTypeConverterProvider.java&r1=592370&r2=592686&rev=592686&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/MapperAtomicTypeConverterProvider.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/MapperAtomicTypeConverterProvider.java Wed Nov 7 02:23:10 2007
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.sling.content.jcr.internal.mapping;
+package org.apache.sling.jcr.resource.internal.mapping;
import java.util.Map;
Copied: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ObservingObjectCache.java (from r592370, incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/ObservingObjectCache.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ObservingObjectCache.java?p2=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ObservingObjectCache.java&p1=incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/ObservingObjectCache.java&r1=592370&r2=592686&rev=592686&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/content/jcr/internal/mapping/ObservingObjectCache.java (original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/mapping/ObservingObjectCache.java Wed Nov 7 02:23:10 2007
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.sling.content.jcr.internal.mapping;
+package org.apache.sling.jcr.resource.internal.mapping;
import javax.jcr.RepositoryException;
import javax.jcr.Session;