View Javadoc

1   /*
2    * Copyright (c) 2006-2007 Creative Sphere Limited.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v10.html
7    *
8    * Contributors:
9    *
10   *   Creative Sphere - initial API and implementation
11   *
12   */
13  package org.abstracthorizon.danube.webdav.xml.dav.response;
14  
15  import org.abstracthorizon.danube.http.Status;
16  import org.abstracthorizon.danube.webdav.util.NamespacesProvider;
17  import org.abstracthorizon.danube.webdav.xml.XMLRenderer;
18  import org.abstracthorizon.danube.webdav.xml.common.XMLUtils;
19  import org.abstracthorizon.danube.webdav.xml.dav.DAVNamespace;
20  
21  import java.io.PrintWriter;
22  
23  /**
24   * This class models WebDAV's propstat response tag
25   *
26   * @author Daniel Sendula
27   */
28  public class Propstat implements XMLRenderer {
29  
30      /** Tag name */
31      public static final String TAG_NAME = "propstat";
32  
33      /** Response this propstat belongs to */
34      protected Response response;
35  
36      /** Request property */
37      protected ResponseProp prop = new ResponseProp();
38  
39      /** Status */
40      protected Status status;
41  
42      /** Response description */
43      protected ResponseDescription responsedescription;
44  
45      /**
46       * Constructor
47       * @param response response
48       */
49      public Propstat(Response response) {
50          this.response = response;
51      }
52  
53      /**
54       * Returns response prop
55       * @return response prop
56       */
57      public ResponseProp getProp() {
58          return prop;
59      }
60  
61      /**
62       * Returns response description
63       * @return response description
64       */
65      public ResponseDescription getResponsedescription() {
66          return responsedescription;
67      }
68  
69      /**
70       * Sets response description
71       * @param responsedescription response description
72       */
73      public void setResponsedescription(ResponseDescription responsedescription) {
74          this.responsedescription = responsedescription;
75      }
76  
77      /**
78       * Returns status
79       * @return status
80       */
81      public Status getStatus() {
82          return status;
83      }
84  
85      /**
86       * Sets status
87       * @param status status
88       */
89      public void setStatus(Status status) {
90          this.status = status;
91      }
92  
93      /**
94       * Renders the tag
95       * @param writer writer
96       * @param provider namespace provider
97       */
98      public void render(PrintWriter writer, NamespacesProvider provider) {
99          writer.println(XMLUtils.createStartTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME));
100         prop.render(writer, provider);
101         response.renderStatus(writer, provider, status);
102         if (responsedescription != null) {
103             responsedescription.render(writer, provider);
104         }
105         writer.println(XMLUtils.createEndTag(provider, DAVNamespace.DAV_NAMESPACE_URL, TAG_NAME));
106     }
107 }