@Grab(group='org.apache.jackrabbit', module='jackrabbit-jcr2dav', version='2.2.9') import org.apache.commons.httpclient.auth.* import org.apache.commons.httpclient.* import org.apache.jackrabbit.webdav.client.methods.* import org.apache.jackrabbit.webdav.* // WebDAV URL baseUrl = "http://localhost:8080/repository/default" path = "/" + java.net.URLEncoder.encode("テスト", "UTF-8") url = baseUrl + path filename = "サンプルファイル.txt" copiedFilename = "サンプルファイル2.txt" try { client = new HttpClient() client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials('username', 'password')) method = new CopyMethod( url + "/" + java.net.URLEncoder.encode(filename, "UTF-8"), url + "/" + java.net.URLEncoder.encode(copiedFilename, "UTF-8"), false /*= overwrite */ ) client.executeMethod(method) println(method.getStatusCode() + ":" + method.getStatusText()) } catch(HttpException ex){ println ex }
動作環境
groovy 1.8.2, JDK6 Update27, Jackrabbit 2.2.9
0 件のコメント:
コメントを投稿