pnever 2004/12/03 06:27:40
Modified: proposals/wvcm/src/org/apache/wvcm/store/webdav/request
AbstractRequest.java
proposals/wvcm/src/javax/wvcm AccessControlElement.java
Resource.java
proposals/wvcm/src/org/apache/wvcm/store/webdav/response
PropertiesFactory.java
proposals/wvcm/src/org/apache/wvcm/model
PropertyDescriptor.java
Log:
Upgraded to JDOM_1.0
Fixed bug with getSupportedPrivilegeList()
Revision Changes Path
1.4 +9 -5
jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/request/AbstractRequest.java
Index: AbstractRequest.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/request/AbstractRequest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AbstractRequest.java 30 Jul 2004 06:52:29 -0000 1.3
+++ AbstractRequest.java 3 Dec 2004 14:27:39 -0000 1.4
@@ -84,6 +84,7 @@
import org.jdom.Namespace;
import org.jdom.Text;
import org.jdom.output.XMLOutputter;
+import org.jdom.output.Format;
/**
* Base class for all handlers for request bodies.
@@ -126,7 +127,10 @@
this.reqBodyAsString = null;
try {
StringWriter out = new StringWriter();
- new XMLOutputter(" ", true, "UTF-8").output(reqBodyDoc, out);
+//JDOMbeta new XMLOutputter(" ", true,
"UTF-8").output(reqBodyDoc, out);
+ Format f = Format.getPrettyFormat();
+ f.setEncoding("UTF-8");
+ new XMLOutputter(f).output(reqBodyDoc, out);
this.reqBodyAsString = out.toString();
}
catch (IOException e) {
1.5 +34 -30
jakarta-slide/proposals/wvcm/src/javax/wvcm/AccessControlElement.java
Index: AccessControlElement.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/javax/wvcm/AccessControlElement.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AccessControlElement.java 30 Jul 2004 06:52:22 -0000 1.4
+++ AccessControlElement.java 3 Dec 2004 14:27:40 -0000 1.5
@@ -23,25 +23,25 @@
*/
public class AccessControlElement {
-
+
// the principal
private Principal principal;
-
+
// the list of Privilege objects
private List privileges;
-
+
// if true, the all privileges of the ACE are granted; otherwise, all
are denied
private boolean grant;
-
+
// the resource from which this ACE was inherited
private Resource inheritedFrom;
-
+
public AccessControlElement(Principal principal, List privileges,
boolean grant) {
this.principal = principal;
this.privileges = privileges;
this.grant = grant;
}
-
+
/**
* Set the principal of this ACE
*
@@ -50,7 +50,7 @@
public void setPrincipal(Principal principal) {
this.principal = principal;
}
-
+
/**
* Get the principal of this ACE
*
@@ -59,7 +59,7 @@
public Principal getPrincipal() {
return principal;
}
-
+
/**
* Set the List of Privilege objects to be granted or denied by this ACE
*
@@ -68,7 +68,7 @@
public void setPrivileges(List privileges) {
this.privileges = privileges;
}
-
+
/**
* Set the List of Privilege objects which are granted or denied by this
ACE
*
@@ -78,7 +78,7 @@
public List getPrivileges() {
return privileges;
}
-
+
/**
* Set whether the privileges of this ACE are granted (grant=true) or
denied
* (grant=false)
@@ -89,7 +89,7 @@
public void setGrant(boolean grant) {
this.grant = grant;
}
-
+
/**
* Returns true, if the privileges of this ACE are all granted, and false
* if the privileges of this ACE are all denied.
@@ -101,7 +101,7 @@
public boolean isGrant() {
return grant;
}
-
+
/**
* Set the resource this ACE is inherited from.
*
@@ -110,7 +110,7 @@
public void setInheritedFrom(Resource inheritedFrom) {
this.inheritedFrom = inheritedFrom;
}
-
+
/**
* Get the resource from which this ACE is inherited from.
*
@@ -119,7 +119,7 @@
public Resource getInheritedFrom() {
return inheritedFrom;
}
-
+
public String toString() {
StringBuffer b = new StringBuffer("ACE: principal=");
try {
@@ -143,27 +143,27 @@
// catch (WvcmException e) {}
return b.toString();
}
-
-
+
+
public boolean equals(Object that) {
if (!(that instanceof AccessControlElement)) return false;
AccessControlElement other = (AccessControlElement) that;
boolean result =
(this.isGrant() == other.isGrant()) &&
(this.getPrincipal().equals(other.getPrincipal())) &&
-// (this.getInheritedFrom().equals(other.getInheritedFrom())) &&
+ //
(this.getInheritedFrom().equals(other.getInheritedFrom())) &&
(this.getPrivileges().equals(other.getPrivileges())) ;
return result;
}
-
-
-
+
+
+
public int hashCode() {
return getPrincipal().hashCode();
}
-
-
-
+
+
+
/**
* NOT YET STANDARD
* <p>
@@ -179,9 +179,9 @@
* </p>
*/
public static interface Privilege extends Resource {
-
+
public Privilege ALL = new GenericPrivilegeImpl(Location.ALL);
-
+
/**
* Create a Privilege on the server.
*
@@ -194,8 +194,8 @@
* <br>(initialize-resource): A new Privilege resource exists at the
location of this Resource.
*/
public void doCreateResource() throws WvcmException;
-
-
+
+
/**
* NOT YET STANDARD
* Implementation of a generic Privilege.
@@ -204,7 +204,7 @@
* @version $Revision$
*/
public class GenericPrivilegeImpl extends GenericResourceImpl
implements Privilege {
-
+
/**
* Constructor
*
@@ -213,7 +213,7 @@
public GenericPrivilegeImpl(Location location) {
super(location);
}
-
+
/**
* Create a Privilege on the server.
*
@@ -227,6 +227,10 @@
*/
public void doCreateResource() throws WvcmException {
throw new UnsupportedOperationException("Not supported for
generic resources");
+ }
+
+ public String toString() {
+ return location().lastSegment();
}
}
}
1.11 +6 -2 jakarta-slide/proposals/wvcm/src/javax/wvcm/Resource.java
Index: Resource.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/javax/wvcm/Resource.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Resource.java 30 Jul 2004 06:52:22 -0000 1.10
+++ Resource.java 3 Dec 2004 14:27:40 -0000 1.11
@@ -654,7 +654,7 @@
* @throws WvcmException
*/
public List getLockTokens() throws WvcmException;
-
+
/**
* NOT YET STANDARD
* Implementation of a generic Resource.
@@ -1327,6 +1327,10 @@
*/
public void doUnlock(LockToken lockToken) throws WvcmException {
throw new UnsupportedOperationException("Not supported for
generic resources");
+ }
+
+ public String toString() {
+ return location().string();
}
}
}
1.5 +36 -36
jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/response/PropertiesFactory.java
Index: PropertiesFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/response/PropertiesFactory.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PropertiesFactory.java 30 Jul 2004 06:52:31 -0000 1.4
+++ PropertiesFactory.java 3 Dec 2004 14:27:40 -0000 1.5
@@ -62,49 +62,24 @@
*/
package org.apache.wvcm.store.webdav.response;
+import java.util.*;
+import javax.wvcm.*;
+import org.apache.wvcm.*;
+import org.jdom.*;
+
import java.io.IOException;
import java.io.StringBufferInputStream;
import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.StringTokenizer;
-import javax.wvcm.ControllableFolder;
-import javax.wvcm.Location;
-import javax.wvcm.PropertyNameList;
import javax.wvcm.PropertyNameList.AttributeName;
import javax.wvcm.PropertyNameList.NestedPropertyName;
import javax.wvcm.PropertyNameList.PropertyName;
-import javax.wvcm.Provider;
-import javax.wvcm.Resource;
-import javax.wvcm.WvcmException;
import javax.wvcm.WvcmException.ReasonCode;
-import org.apache.wvcm.ControllableFolderImpl;
-import org.apache.wvcm.FolderImpl;
-import org.apache.wvcm.LocationImpl;
-import org.apache.wvcm.PrivilegeImpl;
-import org.apache.wvcm.ProviderImpl;
-import org.apache.wvcm.ResourceImpl;
import org.apache.wvcm.model.PropertyDescriptor;
import org.apache.wvcm.store.webdav.DateRepresentations;
import org.apache.wvcm.store.webdav.WebdavProperties;
import org.apache.wvcm.util.PropertyNameLists;
import org.apache.wvcm.util.XPathWrapper;
-import org.jdom.CDATA;
-import org.jdom.Comment;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.EntityRef;
-import org.jdom.JDOMException;
-import org.jdom.Namespace;
-import org.jdom.ProcessingInstruction;
-import org.jdom.Text;
-import org.jdom.input.SAXBuilder;
+import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
/**
@@ -226,9 +201,12 @@
}
}
else if( propdescriptor.basetype() ==
ResourceImpl.XmlPropertyValue.class ) {
+ Format f = Format.getPrettyFormat();
+ f.setEncoding("UTF-8");
propvalue = new ResourceImpl.XmlPropertyValue(
requestResource,
- new XMLOutputter("", false,
"UTF-8").outputString(propertyElm)
+ //JDOMbeta new XMLOutputter("",
false, "UTF-8").outputString(propertyElm)
+ new XMLOutputter(f).outputString(propertyElm)
);
}
else if( propdescriptor.basetype() ==
FolderImpl.BindingImpl.class ) {
@@ -297,6 +275,10 @@
propvalue = propertyElm.getTextTrim();
propvalue = new Float( (String)propvalue );
}
+
+ if (propname.getString().endsWith("privilege-list")) {
+ propvalue = createSupportedPrivilegeList(propertyElm);
+ }
}
else {
Iterator k = propertyElm.getContent().iterator();
@@ -380,6 +362,24 @@
catch (IOException e) {
e.printStackTrace();
throw new WvcmException("", requestResource.location().string(),
ReasonCode.READ_FAILED, new Exception[]{e});
+ }
+ return privileges;
+ }
+
+ private List createSupportedPrivilegeList(Element propertyElm) throws
WvcmException {
+ List privileges = new ArrayList();
+ XPathWrapper xp = new XPathWrapper("//d:privilege", dnsp);
+ Iterator i = xp.selectNodes(propertyElm).iterator();
+ while (i.hasNext()) {
+ Element pElm = (Element)((Element)i.next()).getChildren().get(0);
+ Location privilegesLocation =
((ProviderImpl)provider).serverPrivilegesLocation();
+ if ("all".equals(pElm.getName())) {
+ privileges.add(AccessControlElement.Privilege.ALL);
+ }
+ else {
+ LocationImpl l =
(LocationImpl)privilegesLocation.child(pElm.getName());
+ privileges.add( l.resource(PrivilegeImpl.class) );
+ }
}
return privileges;
}
1.15 +6 -5
jakarta-slide/proposals/wvcm/src/org/apache/wvcm/model/PropertyDescriptor.java
Index: PropertyDescriptor.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/org/apache/wvcm/model/PropertyDescriptor.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- PropertyDescriptor.java 30 Jul 2004 06:52:26 -0000 1.14
+++ PropertyDescriptor.java 3 Dec 2004 14:27:40 -0000 1.15
@@ -198,7 +198,8 @@
propertyDescriptors.put( PropertyName.OWNER, new
PropertyDescriptor(PrincipalImpl.class, null) );
propertyDescriptors.put( PropertyName.PRINCIPAL_FOLDER_LIST, new
PropertyDescriptor(FolderImpl.class, ArrayList.class) );
propertyDescriptors.put( PropertyName.PRIVILEGE_FOLDER_LIST, new
PropertyDescriptor(FolderImpl.class, ArrayList.class) );
- propertyDescriptors.put( PropertyName.SUPPORTED_PRIVILEGE_LIST, new
PropertyDescriptor(PrivilegeImpl.class, ArrayList.class) );
+// propertyDescriptors.put( PropertyName.SUPPORTED_PRIVILEGE_LIST,
new PropertyDescriptor(ResourceImpl.XmlPropertyValue.class, ArrayList.class));
+ propertyDescriptors.put( PropertyName.SUPPORTED_PRIVILEGE_LIST, new
PropertyDescriptor(PrivilegeImpl.class, ArrayList.class){public boolean
isHref(){return false;}});
propertyDescriptors.put( PropertyName.MODIFICATION_DATE, new
PropertyDescriptor(Date.class, null) );
propertyDescriptors.put( PropertyName.CREATION_USER, new
PropertyDescriptor(PrincipalImpl.class, null) );
propertyDescriptors.put( PropertyName.MODIFICATION_USER, new
PropertyDescriptor(PrincipalImpl.class, null) );
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]