1 package com.ibm.webdav.protocol.http; 2 3 17 import com.ibm.webdav.*; 18 import com.ibm.webdav.impl.IRCollection; 19 import java.util.*; 20 import java.io.*; 21 import java.net.URL ; 22 import org.w3c.dom.*; 23 24 30 public class CollectionHTTPStub extends ResourceHTTPStub implements IRCollection { 31 32 private Vector members = null; public CollectionHTTPStub() { 34 super(); 35 } 36 45 public CollectionHTTPStub(String url) throws WebDAVException { 46 if (!url.endsWith("/")) { 47 url = url + "/"; 48 } 49 try { 50 this.url = new URL (url); 51 } catch (java.net.MalformedURLException exc) { 52 throw new WebDAVException(WebDAVStatus.SC_BAD_REQUEST, "Malformed URL"); 53 } 54 } 55 65 public CollectionHTTPStub(String protocol, String host, int port, String file) throws WebDAVException { 66 if (!file.endsWith("/")) { 67 file = file + "/"; 68 } 69 try { 70 this.url = new URL (protocol, host, port, file); 71 } catch (java.net.MalformedURLException exc) { 72 throw new WebDAVException(WebDAVStatus.SC_BAD_REQUEST, "Malformed URL"); 73 } 74 } 75 84 public CollectionHTTPStub(String protocol, String host, String file) throws WebDAVException { 85 if (!file.endsWith("/")) { 86 file = file + "/"; 87 } 88 try { 89 this.url = new URL (protocol, host, file); 90 } catch (java.net.MalformedURLException exc) { 91 throw new WebDAVException(WebDAVStatus.SC_BAD_REQUEST, "Malformed URL"); 92 } 93 } 94 107 public CollectionHTTPStub(URL url, TargetSelector targetSelector) throws WebDAVException { 108 super(url, targetSelector); 109 } 110 124 public CollectionHTTPStub(URL context, String spec) throws WebDAVException { 125 if (!spec.endsWith("/")) { 126 spec = spec + "/"; 127 } 128 try { 129 this.url = new URL (context, spec); 130 } catch (java.net.MalformedURLException exc) { 131 throw new WebDAVException(WebDAVStatus.SC_BAD_REQUEST, "Malformed URL"); 132 } 133 } 134 159 public MultiStatus copy(ResourceContext context, String destinationURL, boolean overwrite, Vector propertiesToCopy, String depth) throws WebDAVException { 160 context.getRequestContext().depth(depth); 161 return super.copy(context, destinationURL, overwrite, propertiesToCopy); 162 } 163 175 public MultiStatus createCollection(ResourceContext context, Document contents) throws WebDAVException { 176 this.context = context; 177 178 try { 179 if (contents != null) { 180 connection.setDoOutput(true); 181 context.getRequestContext().contentType("text/xml"); 182 } 183 setupRequest("MKCOL"); 184 if (contents != null) { 185 OutputStream os = connection.getOutputStream(); 186 PrintWriter pw = new PrintWriter(os, false); 187 pw.print(XMLUtility.printNode(contents.getDocumentElement())); 188 pw.flush(); 190 } 191 192 getResults(); 193 194 } catch (WebDAVException exc) { 195 throw exc; 196 } catch (java.io.IOException exc) { 197 throw new WebDAVException(WebDAVStatus.SC_INTERNAL_SERVER_ERROR, "IO Exception"); 198 } 199 return responseToMultiStatus(); 200 } 201 213 public MultiStatus getProperties(ResourceContext context, PropertyName names[], String depth) throws WebDAVException { 214 context.getRequestContext().depth(depth); 215 return super.getProperties(context, names); 216 } 217 229 public MultiStatus getProperties(ResourceContext context, String depth) throws WebDAVException { 230 context.getRequestContext().depth(depth); 231 return super.getProperties(context); 232 } 233 246 public MultiStatus getPropertyNames(ResourceContext context, String depth) throws WebDAVException { 247 context.getRequestContext().depth(depth); 248 return super.getPropertyNames(context); 249 } 250 272 public MultiStatus lock(ResourceContext context, String scope, String type, int timeout, Element owner, String depth) throws WebDAVException { 273 context.getRequestContext().depth(depth); 274 return super.lock(context, scope, type, timeout, owner); 275 } 276 } 277 | Popular Tags |