1919
2020package org .dmfs .dav .rfc3253 ;
2121
22+ import java .io .IOException ;
2223import java .util .Set ;
2324
2425import org .dmfs .dav .rfc4918 .WebDav ;
2526import org .dmfs .dav .utils .MergeSetObjectBuilder ;
2627import org .dmfs .httpclientinterfaces .HttpMethod ;
2728import org .dmfs .xmlobjects .ElementDescriptor ;
2829import org .dmfs .xmlobjects .QualifiedName ;
30+ import org .dmfs .xmlobjects .builder .AbstractObjectBuilder ;
2931import org .dmfs .xmlobjects .builder .QualifiedNameObjectBuilder ;
3032import org .dmfs .xmlobjects .builder .SetObjectBuilder ;
33+ import org .dmfs .xmlobjects .builder .StringObjectBuilder ;
34+ import org .dmfs .xmlobjects .pull .ParserContext ;
35+ import org .dmfs .xmlobjects .pull .XmlObjectPullParserException ;
36+ import org .dmfs .xmlobjects .serializer .SerializerContext ;
37+ import org .dmfs .xmlobjects .serializer .SerializerException ;
38+ import org .dmfs .xmlobjects .serializer .XmlObjectSerializer ;
3139
3240
3341/**
@@ -46,13 +54,46 @@ public final class WebDavVersioning
4654 */
4755 public final static String NAMESPACE = WebDav .NAMESPACE ;
4856
57+ /**
58+ * {@link QualifiedName} of a name attribute.
59+ */
60+ private final static QualifiedName ATTRIBUTE_NAME = QualifiedName .get ("name" );
61+
4962 /**
5063 * REPORT HTTP method.
5164 *
5265 * @see <a href="http://tools.ietf.org/html/rfc3253#section-3.6">RFC 3253, section 3.6</a>
5366 */
5467 public final static HttpMethod METHOD_REPORT = HttpMethod .safeMethod ("REPORT" );
5568
69+ /**
70+ * <code>DAV:supported-method</code> as defined in <a href="https://tools.ietf.org/html/rfc3253#section-3.1.3">RFC 3253, section 3.1.3</a>
71+ * <p/>
72+ * Note: this will return <code>null</code> for unknown method names, i.e. if no {@link HttpMethod} has been created for that verb.
73+ */
74+ public final static ElementDescriptor <HttpMethod > SUPPORTED_METHOD = ElementDescriptor .register (QualifiedName .get (NAMESPACE , "supported-method" ),
75+ new AbstractObjectBuilder <HttpMethod >()
76+ {
77+ @ Override
78+ public HttpMethod update (ElementDescriptor <HttpMethod > descriptor , HttpMethod object , QualifiedName attribute , String value , ParserContext context )
79+ throws XmlObjectPullParserException
80+ {
81+ if (attribute == ATTRIBUTE_NAME )
82+ {
83+ return HttpMethod .get (value );
84+ }
85+ return null ;
86+ };
87+
88+
89+ @ Override
90+ public void writeAttributes (ElementDescriptor <HttpMethod > descriptor , HttpMethod object , XmlObjectSerializer .IXmlAttributeWriter attributeWriter ,
91+ SerializerContext context ) throws SerializerException , IOException
92+ {
93+ attributeWriter .writeAttribute (ATTRIBUTE_NAME , object .verb , context );
94+ };
95+ });
96+
5697 /**
5798 * <code>DAV:report</code> as defined in <a href="http://tools.ietf.org/html/rfc3253#section-3.1.5">RFC 3253, section 3.1.5</a>. It accepts any element and
5899 * stores the {@link QualifiedName}.
@@ -77,6 +118,14 @@ public final class WebDavVersioning
77118
78119 /* --------------------------------------------- Property elements --------------------------------------------- */
79120
121+ final static ElementDescriptor <String > PROP_COMMENT = ElementDescriptor .register (QualifiedName .get (NAMESPACE , "comment" ), StringObjectBuilder .INSTANCE );
122+
123+ final static ElementDescriptor <String > PROP_CREATOR_DISPLAYNAME = ElementDescriptor .register (QualifiedName .get (NAMESPACE , "creator-displayname" ),
124+ StringObjectBuilder .INSTANCE );
125+
126+ final static ElementDescriptor <Set <HttpMethod >> PROP_SUPPORTED_METHOD_SET = ElementDescriptor .register (
127+ QualifiedName .get (NAMESPACE , "supported-method-set" ), new SetObjectBuilder <>(SUPPORTED_METHOD , false ));
128+
80129 /*
81130 * TODO: we use a MergeSetObjectBuilder to support broken servers that return all reports in one report element. We should revert this once all known
82131 * servers have been fixed for some time.
@@ -89,6 +138,25 @@ public final class WebDavVersioning
89138 */
90139 public final static class Properties
91140 {
141+
142+ /**
143+ * <code>DAV:comment</code> as defined in <a href="http://tools.ietf.org/html/rfc3253#section-3.1.1">RFC 3253, section 3.1.1</a>
144+ */
145+ public final static ElementDescriptor <String > COMMENT = WebDavVersioning .PROP_COMMENT ;
146+
147+ /**
148+ * <code>DAV:creator-displayname</code> as defined in <a href="http://tools.ietf.org/html/rfc3253#section-3.1.2">RFC 3253, section 3.1.2</a>
149+ */
150+ public final static ElementDescriptor <String > CREATOR_DISPLAYNAME = WebDavVersioning .PROP_CREATOR_DISPLAYNAME ;
151+
152+ /**
153+ * <code>DAV:supported-method-set</code> as defined in <a href="http://tools.ietf.org/html/rfc3253#section-3.1.3">RFC 3253, section 3.1.3</a>
154+ * <p/>
155+ * Note: this will only contain {@link HttpMethod}s registered at the time a response as been parsed. Make sure all classes defining HttpMethods you're
156+ * interested in have been loaded.
157+ */
158+ public final static ElementDescriptor <Set <HttpMethod >> SUPPORTED_METHOD_SET = WebDavVersioning .PROP_SUPPORTED_METHOD_SET ;
159+
92160 /**
93161 * <code>DAV:supported-report-set</code> as defined in <a href="http://tools.ietf.org/html/rfc3253#section-3.1.5">RFC 3253, section 3.1.5</a>
94162 */
0 commit comments