@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 println url try { client = new HttpClient() client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials('username', 'password')) method = new PropFindMethod(url, DavConstants.PROPFIND_ALL_PROP, DavConstants.DEPTH_1) client.executeMethod(method) multistatus = method.getResponseBodyAsMultiStatus() responses = multistatus.getResponses() for( response in responses ){ // display nameを表示 println response.getProperties(HttpStatus.SC_OK).get(DavConstants.PROPERTY_DISPLAYNAME).value // hrefを表示 println response.getHref() } println(method.getStatusCode() + ":" + method.getStatusText()) } catch(HttpException ex){ println ex }
動作環境
groovy 1.8.2, JDK6 Update27, Jackrabbit 2.2.9
0 件のコメント:
コメントを投稿