Hi Alan,
this is a snippet :

// Retrieve the current property value
Vector props = new Vector();
props.add(new PropertyName("DAV:", "group-member-set"));
Enumeration enu = resource.propfindMethod(DepthSupport.DEPTH_0, props);
if (!enu.hasMoreElements()) return false;
ResponseEntity ent = (ResponseEntity) enu.nextElement();
enu = ent.getProperties();
if (!enu.hasMoreElements()) return false;
Property property = (Property) enu.nextElement();


// Cast it to JDOM, it's a waste i know, if you want you can do it in DOM directly, with something like
//org.w3c.dom.Element propele = property.getElement();
//org.w3c.dom.Element nele = propele.getOwnerDocument().createElementNS("DAV:", "href:");
//nele.setNodeValue("/users/username");
//propele.appendChild(nele);
DOMBuilder builder = new DOMBuilder(true);
Element ele = builder.build(property.getElement());


// Now add the new user
Element nele = new Element("href", "DAV:");
nele.addContent("/users/" + siteText.getText() + "-" + userText.getText());
ele.addContent(nele);


        // Convert the JDOM tree to a string and patch the property
        XMLOutputter xout = new XMLOutputter("");
        xout.setTextNormalize(true);
        String newattvalue = xout.outputString(ele.getContent());
        resource.proppatchMethod(new PropertyName(ele.getNamespaceURI(), ele
                .getName()), newattvalue, true);

This code is the result of a cut and paste from my own code, where i have it splitted in different methods (that's why there are conversions from DOM to JDOM and so on). It can be optimized not moving from DOM to JDOM and so on, and maybe in other different ways. Anyhow, it works perfectly for me, and adding a user to a role/group rarely is a bottleneck in performances. I REPEAT, i made a cut and paste from various methods in my code to this mail, so i could have done some errors ...

Regarding the permissions to use it, obviously the user with which you log on must have the right permission to issue a proppatch. Currently i'm using root just to make sure it works.

Let us know.

Ciao,
Simone Gianni

At 04.25 22/05/2004, you wrote:
Hi,

I am trying to add a new user to roles/user group-member-set. According to
the documentation



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to