You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-user@jakarta.apache.org by Krishna Kankipati <kk...@baan.com> on 2004/08/03 18:53:18 UTC

RE: Problem with "proppatchMethod" for property "group-member-set "

James,
	Your trick # 1 worked. I had to use the same method that the
commandline client was using. Here is the method I used to make it work. I
could keep the CDATA element.

Code that worked:
============================================================================
====
PropertyName pName = new PropertyName("DAV:", "group-member-set");
					
	
if(webDavResource.proppatchMethod(sRolePathURI, pName,
sbNewMemberSetProperty.toString(), true))
					{
						write("Prop patch worked");
						bSuccess = true;
					}
============================================================================
====

I appreciate your timely help .....

thanks,

Krishna



-----Original Message-----
From: James Mason [mailto:masonjm@ah.org]
Sent: Monday, August 02, 2004 10:13 PM
To: kkankipa@baan.com
Subject: RE: Problem with "proppatchMethod" for property
"group-member-set"


Two things to try:

1) Look at the code the command line client uses to send proppatches to
the server. The client library supports multiple methods for most
operations, and whichever one the command line client uses seems to get
the most testing ::shrug::.

2) Try dropping the enclosing <!CDATA[ ]]>. I could be wrong, but I
don't think it's necessary, and it may be interfering.

Post back to list after you've looked at those two options. Maybe with
more data to go on someone who knows the client library well will be
able to give you a better answer.

-James

>>> Krishna Kankipati <kk...@baan.com> 08/02/04 3:54 PM >>>
James,
	I did not get any responses from anyone, i am assuming no one
has
tried this yet. What is your opinion, I did some debugging and found
that
Webdav Client is doing its job of sending data to servlet. I think Slide
Server is not handling the XML data for group-member-set property
properly.
Can you please let me know what you think about this issue .....

thanks,

Krishna


-----Original Message-----
From: Krishna Kankipati [mailto:kkankipa@baan.com]
Sent: Monday, August 02, 2004 11:46 AM
To: slide-user@jakarta.apache.org; 'MasonJM@ah.org'
Subject: Problem with "proppatchMethod" for property "group-member-set"


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] 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:MasonJM@ah.org]
Sent: Friday, July 30, 2004 2:55 PM
To: kkankipa@baan.com
Subject: RE: Problem with propFind for property group-member-set


Good :).

>>> Krishna Kankipati <kk...@baan.com> 7/30/2004 1:51:33 PM >>>
James,
	It works .....

Krishna

-----Original Message-----
From: James Mason [mailto:MasonJM@ah.org] 
Sent: Friday, July 30, 2004 2:19 PM
To: kkankipa@baan.com 
Subject: RE: Problem with propFind for property group-member-set


Let me know how it goes.

-James

>>> Krishna Kankipati <kk...@baan.com> 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:MasonJM@ah.org] 
Sent: Friday, July 30, 2004 2:02 PM
To: kkankipa@baan.com 
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 <kk...@baan.com> 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/slide-user@jakarta.apache.org/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
*  kkankipa@baan.com