Thanks for that... what is and where is this Projector code you speak of?
-- Ricardo Gladwell
Daniel Florey wrote:
Hi, just a snippet from Projector code (this might help). Full source can be found in CVS head:
public URI createUser(String username, String password, Credentials credentials) throws UserExistsException, IOException { Value userExists = getResource(new URIValue(users+username), credentials); if ( userExists == NullValue.NULL || userExists != null ) { throw new UserExistsException(new ErrorMessage("userExists", new String[] { username })); } else { URI userUri = new URIValue(users+username); MkcolMethod mkcolMethod = new MkcolMethod(domain+userUri.toString()); mkcolMethod.setDoAuthentication(true); HttpState httpState = new HttpState(); httpState.setCredentials(null, host, credentials); int state = mkcolMethod.execute(httpState, new HttpConnection(host, port, protocol)); if ( state == HttpStatus.SC_CREATED ) { changePassword(userUri, null, password, credentials); return userUri; } return null; } }
public URI createRole(String rolename, Credentials credentials) throws RoleExistsException, IOException { Value userExists = getResource(new URIValue(domain+roles+rolename), credentials); if ( userExists == NullValue.NULL || userExists != null ) { throw new RoleExistsException(new ErrorMessage("roleExists", new String[] { rolename })); } else { URI roleUri = new URIValue(roles+rolename); MkcolMethod mkcolMethod = new MkcolMethod(domain+roleUri.toString()); mkcolMethod.setDoAuthentication(true); HttpState httpState = new HttpState(); httpState.setCredentials(null, host, credentials); int state = mkcolMethod.execute(httpState, new HttpConnection(host, port, protocol)); if ( state == HttpStatus.SC_CREATED ) { return roleUri; } return null; } }
public void deleteRole(URI role, Credentials credentials) throws IOException { removeResource(role, credentials); }
public void deleteUser(URI user, Credentials credentials) throws IOException { removeResource(user, credentials); }
public void addRole(URI user, URI role, Credentials credentials) throws IOException { XMLValue roleElement = getPropertyAsXMLValue(role, DAV_NAMESPACE, "group-member-set", credentials); Element newUserElement = new Element("href", "DAV:"); newUserElement.addContent(user.toString()); roleElement.getRootElement().addContent(newUserElement); XMLOutputter xout = new XMLOutputter(Format.getCompactFormat()); String groupMemberSet = xout.outputString(roleElement.getRootElement().getContent()); setProperty(role, DAV_NAMESPACE, "group-member-set", groupMemberSet, credentials); }
public void removeRole(URI user, URI role, Credentials credentials) throws IOException { XMLValue membersElement = getPropertyAsXMLValue(role, DAV_NAMESPACE, "group-member-set", credentials); List members = membersElement.getRootElement().getChildren(); for ( Iterator i = members.iterator(); i.hasNext(); ) { Element memberElement = (Element)i.next(); String uri = memberElement.getTextTrim(); if ( uri.equals(user.toString()) ) { i.remove(); break; } } XMLOutputter xout = new XMLOutputter(Format.getCompactFormat()); String groupMemberSet = xout.outputString(membersElement.getRootElement().getContent()); setProperty(role, DAV_NAMESPACE, "group-member-set", groupMemberSet, credentials); }
public ArrayValue listRoles(URI user, Credentials credentials) throws IOException { XMLValue membership = getPropertyAsXMLValue(user, DAV_NAMESPACE, "group-membership", credentials); List roles = membership.getRootElement().getChildren(); List roleList = new ArrayList(); for ( Iterator i = roles.iterator(); i.hasNext(); ) { Map map = new HashMap(); Element roleElement = (Element)i.next(); String uri = roleElement.getTextTrim(); if ( uri.indexOf(domain) != -1 ) { uri = uri.substring(uri.indexOf(domain)+domain.length()); } map.put("uri", uri); roleList.add(new MapValue(map)); } return new ArrayValue((Value [])roleList.toArray(new Value[roleList.size()])); }
Ricardo Gladwell schrieb:
Hi,
Does anyone have any sample code or classes for updating Slide user details using the WebDav Client API? I would really appreciate the help if anyone does.
Kind regards...
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
