}
private boolean addPermission(WebdavResource webdavResource, QName permission, String path, String principal, boolean negative) throws HttpException, IOException
{
AclProperty acl = webdavResource.aclfindMethod(path);
if (acl==null)
{
out.println("Error: PropFind didn't return an AclProperty!");
return false;
}
Ace[] aces=acl.getAces();
if (aces==null)
aces=new Ace[0];
if (debugLevel>5) {
out.println();
out.println("ACL from server");
showAces(path, aces);
}
Ace ace=null;
for (int i=0; i<aces.length && (ace==null); i++)
{
if ((aces[i].isNegative()==negative) && !aces[i].isProtected()
&& !aces[i].isInherited() && aces[i].getPrincipal().equals(principal))
{
if (debugLevel>5)
out.println("found ace");
ace=aces[i];
}
}
if (ace==null)
{
Ace[] oldAces=aces;
aces=new Ace[oldAces.length+1];
System.arraycopy(oldAces,0,aces,0,oldAces.length);
ace=new Ace(principal, negative, false, false,null);
aces[oldAces.length]=ace;
}
Privilege privilege=new Privilege(permission.getNamespaceURI(), permission.getLocalName(), null);
ace.addPrivilege(privilege);
if (debugLevel>5) {
out.println();
out.println("ACL with updated privileges");
showAces(path, aces);
}
boolean success = webdavResource.aclMethod(path,aces);
if (!success)
out.println(webdavResource.getStatusMessage());
if (debugLevel>5) {
acl = webdavResource.aclfindMethod(path);
if (acl==null)
out.println("Error: PropFind didn't return an AclProperty!");
else
{
aces=acl.getAces();
out.println();
out.println("ACL from server after update");
showAces(path, aces);
}
}