jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Jackrabbit Wiki] Update of "WebDAV" by MartinJung
Date Mon, 01 Sep 2008 13:59:04 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jackrabbit Wiki" for change notification.

The following page has been changed by MartinJung:
http://wiki.apache.org/jackrabbit/WebDAV

------------------------------------------------------------------------------
     * [http://jackrabbit.apache.org/api/1.4/org/apache/jackrabbit/webdav/util/package-summary.html
org.apache.jackrabbit.webdav.util]
     * [http://jackrabbit.apache.org/api/1.4/org/apache/jackrabbit/webdav/xml/package-summary.html
org.apache.jackrabbit.webdav.xml]
  
+ === Using the WebDAV Client API ===
  
+   * Init the Client
+   {{{
+         hostConfig = new HostConfiguration();
+ 	hostConfig.setHost("www.somehost.com");	
+ 	HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
+ 	HttpConnectionManagerParams params = new HttpConnectionManagerParams();
+ 	int maxHostConnections = 20;
+ 	params.setMaxConnectionsPerHost(hostConfig, maxHostConnections);
+ 	connectionManager.setParams(params);	
+ 	client = new HttpClient(connectionManager);
+ 	Credentials creds = new UsernamePasswordCredentials("userId", "pw");
+         client.getState().setCredentials(AuthScope.ANY, creds);
+ 	client.setHostConfiguration(hostConfig);
+   }}} 
+   * Copy a File
+   {{{
+         //source, dest, overwrite
+         DavMethod copy=new CopyMethod("http://www.somehost.com/duff/test3.txt", "http://www.somehost.com/duff/test4.txt",
true);
+ 	client.executeMethod(copy);
+ 	
+ 	System.out.println(copy.getStatusCode() + " "+ copy.getStatusText());
+   }}}
+   * Reading all properties of a resourece
+   {{{
+     DavMethod pFind = new PropFindMethod("http://www.somehost.com/duff/test3.txt", DavConstants.PROPFIND_ALL_PROP,
DavConstants.DEPTH_INFINITY);
+     client.executeMethod(pFind);
  
- 
+     MultiStatus multiStatus = pFind.getResponseBodyAsMultiStatus();	 
+ 	 
+     //Not quite nice, but for a example ok
+     DavPropertySet props = multiStatus.getResponses()[0].getProperties(200);
+ 	  
+     Collection<DefaultDavProperty> propertyColl=props.getContent(); 
+     propertyColl.iterator();
+     for(Iterator<DefaultDavProperty> iterator = propertyColl.iterator(); iterator.hasNext();){
+ 	DefaultDavProperty tmpProp=iterator.next();
+ 	System.out.println(tmpProp.getName() +"  "+ tmpProp.getValue());
+     }
+     
+   }}}
+   * Setting a property of a resource
+   {{{
+         DavPropertySet newProps=new DavPropertySet();	
+ 	DavPropertyNameSet removeProperties=new DavPropertyNameSet();
+ 	
+         DavProperty testProp=new DefaultDavProperty("TheAnswer","42",DavConstants.NAMESPACE);
+ 	newProps.add(testProp);
+ 	PropPatchMethod proPatch=new PropPatchMethod("http://www.somehost.com/duff/test4.txt",newProps,removeProperties);
+ 	
+ 	client.executeMethod(proPatch);
+ 	System.out.println(proPatch.getStatusCode() + " "+ proPatch.getStatusText());
+   }}}
  ----
  === General SSL access examples ===
  

Mime
View raw message