FileDocCategorySizeDatePackage
ModifyExample.javaAPI DocExample2361Wed May 18 09:39:02 BST 2005com.discursive.jccook.slide

ModifyExample

public class ModifyExample extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

		HttpClient client = new HttpClient();

		String url = "http://www.discursive.com/jccook/dav/test.html";
		Credentials credentials =
			new UsernamePasswordCredentials("davuser", "davpass");

		// List resources in top directory
		WebdavResource resource = new WebdavResource(url, credentials);

		// Lock the Resource for 100 seconds
		boolean locked = resource.lockMethod( "tobrien", 100 );

		if( locked ) {
			try {
				// Read content as a String
				String resourceData = resource.getMethodDataAsString();
				printResource(resource, resourceData);
		
				// Modify a resource
				System.out.println( "*** Modifying Resource");
				resourceData = resourceData.replaceAll( "test", "modified test" );
				resource.putMethod( resourceData );
			} finally {
				// Unlock the resource
				resource.unlockMethod( "tobrien" );
			}
		}
		
		// Close the resource	
		resource.close();		
	
private static voidprintResource(org.apache.webdav.lib.WebdavResource resource, java.lang.String resourceData)

		System.out.println( "*** Contents of " + resource.getName() );
		System.out.println( resourceData );