Hi, I am writing a wrapper on top of WebDav Client 2.1 M1 (with latest CVS code for DOMUtils.java). I am having a problem executing proppatchMethod() for the property "group-member-set". I am trying to assign user "john" to role "root". If I try the same through DAVExplorer 0.9, it is working fine. The group-member-set property value that my algorithm generates before it calls proppatchMethod is:
The group-member-set property value that I am trying to set using webdavResource.proppatchMethod ============================================================================ <![CDATA[<D:href xmlns:D='DAV:'>/Slide/users/root</D:href><D:href xmlns:D='DAV:'>/Slide/users/john</D:href><D:href xmlns:D='DAV:'>/Slide/users/guest</D:href>]]> ============================================================================ I get the following error: ============================================================================ <![CDATA[<D:href xmlns:D='DAV:'>/Slide/users/root</D:href><D:href xmlns:D='DAV:'>/Slide/users/john</D:href><D:href xmlns:D='DAV:'>/Slide/users/guest</D:href>]]> Prop patch failed::Bad Request (400) ============================================================================ If I take this same string and add the property through DAVExplorer it works fine. So I am sure that the string that I am generating for the property is right. I guess there is a bug with the Slide2.1 M1 Webdav Client while handling XML data. Has anyone worked on this, any clues what could be wrong, or can anyone validate that this is a bug with Webdav Client ..... any help is appreciated ... thanks and regards, Krishna PS: Source code for the method that assigns user to role public boolean assignUserToRole(String sUserName, String sRoleName) throws IOException { // URI pointing to the given role String sURI = BASE_URL + "roles/" + sRoleName; String sNewUserURI = "/Slide/users/" + sUserName; boolean bSuccess = false; boolean bUserAlreadyBelongsToRole = false; try { // Connect to Slide resource if(connect(sURI)) { write("Connected to slide successfully"); // Try to set the group-member-set property as follows /* * proppatch /roles/role1 * group-member-set = <![CDATA[<D:href xmlns:D='DAV:'>/users/user1</D:href><D:href xmlns:D='DAV:'>/users/user2</D:href>]]> * namespace = "DAV:" */ String sPropertyName = "group-member-set"; Enumeration enumProperties = webDavResource.propfindMethod("group-member-set"); String sListOfUsersInRole = (String)enumProperties.nextElement(); // Split the output into the multiple user URI's String[] saUsersInRole = sListOfUsersInRole.split("\n"); String sUserInRoleURI; // Build the new group-member-set property including existing users and additionally the new user // Ex: <![CDATA[<D:href xmlns:D='DAV:'>/users/user1</D:href><D:href xmlns:D='DAV:'>/users/user2</D:href>]]> StringBuffer sbNewMemberSetProperty = new StringBuffer(); // Add the CDATA elemet header sbNewMemberSetProperty.append("<![CDATA["); // Loop through each exisitng user URI belonging to the role for(int j = 0; j < saUsersInRole.length; j++) { sUserInRoleURI = saUsersInRole[j]; sUserInRoleURI = sUserInRoleURI.trim(); // Check if the user alrady belongs to the role, if yes do not execute propPatch if(sNewUserURI.equals(sUserInRoleURI)) bUserAlreadyBelongsToRole = true; write(sUserInRoleURI); if(sUserInRoleURI.length() > 0) { // Add the <href> element with user URI for each existing user sbNewMemberSetProperty.append("<D:href xmlns:D='DAV:'>"); sbNewMemberSetProperty.append(sUserInRoleURI); sbNewMemberSetProperty.append("</D:href>"); } } // end for() loop // Add the <href> element with new user URI (this is where new user gets assigned to the role) if(bUserAlreadyBelongsToRole == false) { sbNewMemberSetProperty.append("<D:href xmlns:D='DAV:'>"); sbNewMemberSetProperty.append(sNewUserURI); sbNewMemberSetProperty.append("</D:href>"); } // Append the CDATA closing brackets sbNewMemberSetProperty.append("]]>"); write(sbNewMemberSetProperty.toString()); // Now that the xml property string is build, it has to be set as new property for the given webresource Hashtable htProperties = new Hashtable(); htProperties.put("group-member-set", sbNewMemberSetProperty.toString()); // String sProperty = "<D:href xmlns:D='DAV:'>/users/kkankipa</D:href>"; // htProperties.put("group-member-set", sProperty); // Set the new property value for the resource property if the user is not already // member of the role if(bUserAlreadyBelongsToRole == false) { if(webDavResource.proppatchMethod(htProperties, true)) { write("Prop patch worked"); bSuccess = true; } else { String sStatus = webDavResource.getStatusMessage(); write("Prop patch failed::" + sStatus); bSuccess = false; } } } else { throw new IOException("Connection to Slide failed"); } } catch(IOException ex) { write(ex.getMessage()); throw ex; } finally { disconnect(); } return bSuccess; } end PS: -----Original Message----- From: James Mason [mailto:[EMAIL PROTECTED] Sent: Friday, July 30, 2004 2:55 PM To: [EMAIL PROTECTED] Subject: RE: Problem with propFind for property group-member-set Good :). >>> Krishna Kankipati <[EMAIL PROTECTED]> 7/30/2004 1:51:33 PM >>> James, It works ..... Krishna -----Original Message----- From: James Mason [mailto:[EMAIL PROTECTED] Sent: Friday, July 30, 2004 2:19 PM To: [EMAIL PROTECTED] Subject: RE: Problem with propFind for property group-member-set Let me know how it goes. -James >>> Krishna Kankipati <[EMAIL PROTECTED]> 7/30/2004 1:15:56 PM >>> James, Please ignore my e-mail, I looked at the CVS web site and it was pretty clear how to download the latest and greatest source code, I will try with the latest code and get back to you .... thanks a bunch! Krishna -----Original Message----- From: James Mason [mailto:[EMAIL PROTECTED] Sent: Friday, July 30, 2004 2:02 PM To: [EMAIL PROTECTED] Subject: Re: Problem with propFind for property group-member-set You'll need to get it from CVS or wait until August 10 for the next beta release. The actual change was made to the DOMUtils class in org.apache.util. -James >>> Krishna Kankipati <[EMAIL PROTECTED]> 7/30/2004 12:59:31 PM >>> Hi James, I am writing a wrapper on top of webdav client for our application. I am using Slide2.1M1. I found that the propfindMethod call on property "group-member-set" is always returning blank string. In the archived discussion you had with Oliver (http://www.mail-archive.com/[EMAIL PROTECTED]/msg06713.html), you were saying that you fixed this and that you had a patch that solves this problem, where can I find the patch? Code ============================================================================ ============ String sPropertyName = "group-member-set"; Enumeration enumProperties = webDavResource.propfindMethod("group-member-set"); String str = (String)enumProperties.nextElement(); str = str.trim(); write("Property = index of root = " + str + str.length()); ============================================================================ ============ kind regards, Krishna Krishna Kankipati Software Engineer SSA Global * 1626 Cole Blvd. Golden, CO 80401, USA * 303-274-3027 Fax: 303-274-3137 * [EMAIL PROTECTED]