@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" oldpath = "/" + java.net.URLEncoder.encode("テスト", "UTF-8") newpath = "" oldurl = baseUrl + oldpath newurl = baseUrl + newpath filename = "サンプルファイル.txt" try { client = new HttpClient() client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials('username', 'password')) method = new MoveMethod( oldurl + "/" + java.net.URLEncoder.encode(filename, "UTF-8"), newurl + "/" + java.net.URLEncoder.encode(filename, "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 件のコメント:
コメントを投稿