Index: contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/ResourceType.java =================================================================== --- contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/ResourceType.java (revision 231170) +++ contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/ResourceType.java (working copy) @@ -15,12 +15,17 @@ */ package org.apache.jackrabbit.webdav.property; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + import org.jdom.Element; /** * The ResourceType class represents the webdav resource - * type property. Valid resource types are '{@link #COLLECTION collection}', - * {@link #DEFAULT_RESOURCE}. + * type property. The property may contain multiple resource type + * values. Valid resource types are '{@link #COLLECTION collection}', + * {@link #DEFAULT_RESOURCE}. Subclasses may add more. */ public class ResourceType extends AbstractDavProperty { @@ -34,54 +39,91 @@ */ public static final int COLLECTION = DEFAULT_RESOURCE + 1; - private int resourceType = DEFAULT_RESOURCE; + private int[] resourceTypes = { DEFAULT_RESOURCE }; /** - * Create a resource type property + * Create a single-valued resource type property */ public ResourceType(int resourceType) { + this(new int[] { resourceType }); + } + + /** + * Create a multi-valued resource type property + */ + public ResourceType(int[] resourceTypes) { super(DavPropertyName.RESOURCETYPE, false); - if (!isValidResourceType(resourceType)) { - throw new IllegalArgumentException("Invalid resource type '"+ resourceType +"'."); + for (int i=0; iSet of Elements. * - * @return Xml representation of this resource type. + * @return a Set of Elements + * representing this property. * @see DavProperty#getValue() */ public Object getValue() { - return (resourceType == COLLECTION) ? new Element(XML_COLLECTION, NAMESPACE) : null; + Set elements = new HashSet(); + for (int i=0; inull if the resource type has no Xml + * representation (e.g. {@link #COLLECTION}). * - * @return resourceType + * {@link #getValue()} uses this method to build the full set of + * Xml elements for the property's resource types. Subclasses + * should override this method to add support for resource types + * they define. */ - public int getResourceType() { - return resourceType; + protected Element resourceTypeToXml(int resourceType) { + if (resourceType == COLLECTION) { + return new Element(XML_COLLECTION, NAMESPACE); + } + return null; } /** - * Validates the specified resourceType. + * Returns the resource types specified with the constructor. * + * @return resourceTypes + */ + public int[] getResourceTypes() { + return resourceTypes; + } + + /** + * Validates the specified resourceType. Subclasses should + * override this method to add support for resource types they + * define. + * * @param resourceType * @return true if the specified resourceType is valid. */ Index: contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/ResourceType.java =================================================================== --- contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/ResourceType.java (revision 231170) +++ contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/ResourceType.java (working copy) @@ -46,8 +46,8 @@ * Array containing all possible resourcetype elements */ private static final String[] ELEMENT_NAMES = { + null, // let the superclass handle the resource types it defined null, - XML_COLLECTION, XML_VERSION_HISTORY, XML_ACTIVITY, XML_BASELINE @@ -55,7 +55,7 @@ /** - * Create a resource type property + * Create a single-valued resource type property * * @param resourceType */ @@ -64,13 +64,26 @@ } /** + * Create a multi-valued resource type property + * + * @param resourceTypes + */ + public ResourceType(int[] resourceTypes) { + super(resourceTypes); + } + + /** * Return the resource type as Xml element. * * @return Xml element representing the internal type or null * if the resource has no element name assigned (default resource type). */ - public Object getValue() { - String name = ELEMENT_NAMES[getResourceType()]; + public Element resourceTypeToXml(int resourceType) { + Element element = super.resourceTypeToXml(resourceType); + if (element != null) { + return element; + } + String name = ELEMENT_NAMES[resourceType]; return (name != null) ? new Element(name, DeltaVConstants.NAMESPACE) : null; } @@ -86,4 +99,4 @@ } return true; } -} \ No newline at end of file +}