You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by ju...@apache.org on 2002/03/08 12:57:29 UTC
cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/util PropertyRetrieverImpl.java
juergen 02/03/08 03:57:29
Modified: src/webdav/server/org/apache/slide/webdav/util
PropertyRetrieverImpl.java
Log:
Added parameter 'serverURL'.
Use PropertyHelper to retrieve computed (DeltaV) properties.
(ralf)
Revision Changes Path
1.3 +308 -144 jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyRetrieverImpl.java
Index: PropertyRetrieverImpl.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyRetrieverImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PropertyRetrieverImpl.java 26 Feb 2002 08:04:34 -0000 1.2
+++ PropertyRetrieverImpl.java 8 Mar 2002 11:57:29 -0000 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyRetrieverImpl.java,v 1.2 2002/02/26 08:04:34 juergen Exp $
- * $Revision: 1.2 $
- * $Date: 2002/02/26 08:04:34 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyRetrieverImpl.java,v 1.3 2002/03/08 11:57:29 juergen Exp $
+ * $Revision: 1.3 $
+ * $Date: 2002/03/08 11:57:29 $
*
* ====================================================================
*
@@ -105,6 +105,9 @@
import org.apache.slide.macro.ConflictException;
import org.apache.slide.macro.ForbiddenException;
+import org.apache.slide.webdav.util.resourcekind.ResourceKind;
+import org.apache.slide.webdav.util.resourcekind.AbstractResourceKind;
+
import java.io.StringReader;
import java.io.IOException;
@@ -113,6 +116,7 @@
import java.util.HashMap;
import java.util.Enumeration;
import java.util.Date;
+import java.util.Set;
import org.jdom.Document;
import org.jdom.Element;
@@ -128,49 +132,15 @@
* providing property information (<code>PropFindMethod</code>,
* <code>ReportMethod</code>) should use this class.
*
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*
* @author <a href="mailto:ralf.stuckert@softwareag.com">Ralf Stuckert</a>
*/
-public class PropertyRetrieverImpl implements PropertyRetriever{
-
- protected static final String SUPPORTED_LOCK = "<lockentry>"
- + "<lockscope><exclusive/></lockscope>"
- + "<locktype><write/></locktype>"
- + "</lockentry>"
- + "<lockentry>"
- + "<lockscope><shared/></lockscope>"
- + "<locktype><write/></locktype>"
- + "</lockentry>";
+public class PropertyRetrieverImpl implements PropertyRetriever, WebdavConstants, DeltavConstants, AclConstants {
protected static final String SUPPORTED_PRIVILEGE_SET =
"supported-privilege-set";
- protected static final String SUPPORTED_PRIVILEGES =
- "<supported-privilege>"
- + "<privilege><all/></privilege>"
- + "<description>Any operation</description>"
- + "<supported-privilege>"
- + "<privilege><read/></privilege>"
- + "<description>Read any object</description>"
- + "</supported-privilege>"
- + "<supported-privilege>"
- + "<privilege><write/></privilege>"
- + "<description>Write any object</description>"
- + "</supported-privilege>"
- + "<supported-privilege>"
- + "<privilege><read-acl/></privilege>"
- + "<description>Read the ACL</description>"
- + "</supported-privilege>"
- + "<supported-privilege>"
- + "<privilege><write-acl/></privilege>"
- + "<description>Write the ACL</description>"
- + "</supported-privilege>"
- + "</supported-privilege>";
-
- protected static final String SLIDE_ACL_SEMANTICS =
- "<ace-combination><all-grant-before-any-deny/></ace-combination>"
- + "<required-principal><all/></required-principal>";
protected static final String OWNER =
"owner";
@@ -244,6 +214,11 @@
*/
protected int namespaceNumber = 0;
+ /**
+ * The PropertyHelper used to access the (computed) properties.
+ */
+ protected PropertyHelper propertyHelper = null;
+
/**
* Returns the SAXBuilder used to create JDOM Documents in method
@@ -277,7 +252,18 @@
namespacesMap = new HashMap();
namespacesMap.put(WebdavMethod.SLIDE_NAMESPACE, WebdavMethod.SLIDE_NAMESPACE_ABBREV);
+ namespacesMap.put(DEFAULT_NAMESPACE, null);
+ propertyHelper = new PropertyHelper(slideToken, token);
+ }
+
+ /**
+ * Returns the PropertyHelper used to access the (computed) properties.
+ *
+ * @return the PropertyHelper used to access the (computed) properties.
+ */
+ protected PropertyHelper getPropertyHelper() {
+ return propertyHelper;
}
/**
@@ -305,7 +291,10 @@
*
* @param requestedProperties the requested properties.
* @param uri the URI of the resource.
- * @param contextPath the context path of the <code>uri</code>.
+ * @param contextPath the context path of the uri. The concatenation of
+ * <code>serverURL</code>/<code>contextPath</code>
+ * /<code>uri</code> gives the absolute URL of the resource.
+ * @param serverURL the URL of the server (e.g. <code>http://www.abc.com</code>).
* @param allpropSupportsDeltaV indicates if the <code>DeltaV</code> specific
* properties should be included in case
* all properties are requested.
@@ -321,10 +310,10 @@
* @throws LockTokenNotFoundException
* @throws JDOMException if creating the JDOM Element fails.
*/
- public Element getPropertiesOfObject(RequestedProperties requestedProperties, String uri, String contextPath, boolean allpropSupportsDeltaV) throws ObjectLockedException, ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, RevisionDescriptorNotFoundException, LockTokenNotFoundException, JDOMException {
+ public Element getPropertiesOfObject(RequestedProperties requestedProperties, String uri, String contextPath, String serverURL, boolean allpropSupportsDeltaV) throws ObjectLockedException, ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, RevisionDescriptorNotFoundException, LockTokenNotFoundException, JDOMException {
XMLPrinter xmlPrinter = new XMLPrinter();
- writePropertiesOfObject(requestedProperties, uri, contextPath, allpropSupportsDeltaV, xmlPrinter);
+ writePropertiesOfObject(requestedProperties, uri, contextPath, serverURL, allpropSupportsDeltaV, xmlPrinter);
return (Element) getJDOMDocumentFromXMLPrinter(xmlPrinter).getRootElement().clone();
}
@@ -336,7 +325,10 @@
*
* @param requestedProperties the requested properties.
* @param uri the URI of the resource.
- * @param contextPath the context path of the <code>uri</code>.
+ * @param contextPath the context path of the uri. The concatenation of
+ * <code>serverURL</code>/<code>contextPath</code>
+ * /<code>uri</code> gives the absolute URL of the resource.
+ * @param serverURL the URL of the server (e.g. <code>http://www.abc.com</code>).
* @param allpropSupportsDeltaV indicates if the <code>DeltaV</code> specific
* properties should be included in case
* all properties are requested.
@@ -350,10 +342,10 @@
* @throws LockTokenNotFoundException
* @throws JDOMException if creating the JDOM Element fails.
*/
- public Element getPropertiesOfObject(RequestedProperties requestedProperties, String uri, NodeRevisionNumber revisionNumber, String contextPath, boolean allpropSupportsDeltaV) throws ObjectLockedException, ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, RevisionDescriptorNotFoundException, LockTokenNotFoundException, JDOMException {
+ public Element getPropertiesOfObject(RequestedProperties requestedProperties, String uri, NodeRevisionNumber revisionNumber, String contextPath, String serverURL, boolean allpropSupportsDeltaV) throws ObjectLockedException, ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, RevisionDescriptorNotFoundException, LockTokenNotFoundException, JDOMException {
XMLPrinter xmlPrinter = new XMLPrinter();
- writePropertiesOfObject(requestedProperties, uri, revisionNumber, contextPath, allpropSupportsDeltaV, xmlPrinter);
+ writePropertiesOfObject(requestedProperties, uri, revisionNumber, contextPath, serverURL, allpropSupportsDeltaV, xmlPrinter);
return (Element) getJDOMDocumentFromXMLPrinter(xmlPrinter).getRootElement().clone();
}
@@ -366,7 +358,10 @@
*
* @param requestedProperties the requested properties.
* @param uri the URI of the resource.
- * @param contextPath the context path of the <code>uri</code>.
+ * @param contextPath the context path of the uri. The concatenation of
+ * <code>serverURL</code>/<code>contextPath</code>
+ * /<code>uri</code> gives the absolute URL of the resource.
+ * @param serverURL the URL of the server (e.g. <code>http://www.abc.com</code>).
* @param allpropSupportsDeltaV indicates if the <code>DeltaV</code> specific
* properties should be included in case
* all properties are requested.
@@ -380,7 +375,7 @@
* @throws RevisionDescriptorNotFoundException
* @throws LockTokenNotFoundException
*/
- public void writePropertiesOfObject(RequestedProperties requestedProperties, String uri, String contextPath, boolean allpropSupportsDeltaV, XMLPrinter generatedXML) throws ObjectLockedException, ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, RevisionDescriptorNotFoundException, LockTokenNotFoundException {
+ public void writePropertiesOfObject(RequestedProperties requestedProperties, String uri, String contextPath, String serverURL, boolean allpropSupportsDeltaV, XMLPrinter generatedXML) throws ObjectLockedException, ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, RevisionDescriptorNotFoundException, LockTokenNotFoundException {
NodeRevisionDescriptors revisionDescriptors = null;
NodeRevisionDescriptor revisionDescriptor = null;
@@ -422,7 +417,7 @@
// throw new WebdavException(getErrorCode(e)); // abort the TA
// }
- writePropertiesOfObject(requestedProperties, uri, revisionDescriptor.getRevisionNumber(), contextPath, allpropSupportsDeltaV, generatedXML);
+ writePropertiesOfObject(requestedProperties, uri, revisionDescriptor.getRevisionNumber(), contextPath, serverURL, allpropSupportsDeltaV, generatedXML);
}
@@ -430,11 +425,14 @@
/**
* Writes the requested properties of the resource identified by the given
* <code>uri</code> and <code>revisionNumber</code> as an XML text (starting
- * with the <code><propstat></code>) into the given <code>XMLPrinter</code>.
+ * with the generatedXML.writeElement(null, DEFAULT_NAMESPACE</code>) into the given <code>XMLPrinter</code>.
*
* @param requestedProperties the requested properties.
* @param uri the URI of the resource.
- * @param contextPath the context path of the <code>uri</code>.
+ * @param contextPath the context path of the uri. The concatenation of
+ * <code>serverURL</code>/<code>contextPath</code>
+ * /<code>uri</code> gives the absolute URL of the resource.
+ * @param serverURL the URL of the server (e.g. <code>http://www.abc.com</code>).
* @param allpropSupportsDeltaV indicates if the <code>DeltaV</code> specific
* properties should be included in case
* all properties are requested.
@@ -448,7 +446,7 @@
* @throws RevisionDescriptorNotFoundException
* @throws LockTokenNotFoundException
*/
- public void writePropertiesOfObject(RequestedProperties requestedProperties, String uri, NodeRevisionNumber revisionNumber, String contextPath, boolean allpropSupportsDeltaV, XMLPrinter generatedXML) throws ObjectLockedException, ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, RevisionDescriptorNotFoundException, LockTokenNotFoundException {
+ public void writePropertiesOfObject(RequestedProperties requestedProperties, String uri, NodeRevisionNumber revisionNumber, String contextPath, String serverURL, boolean allpropSupportsDeltaV, XMLPrinter generatedXML) throws ObjectLockedException, ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, RevisionDescriptorNotFoundException, LockTokenNotFoundException {
String status = new String("HTTP/1.1 " + WebdavStatus.SC_OK + " "
+ WebdavStatus.getStatusText
@@ -492,9 +490,9 @@
if (requestedProperties.isAllProp()) {
// Show properties / values for current object.
- generatedXML.writeElement(null, "propstat",
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "propstat",
XMLPrinter.OPENING);
- generatedXML.writeElement(null, "prop", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "prop", XMLPrinter.OPENING);
status = new String("HTTP/1.1 " + WebdavStatus.SC_OK
+ " " + WebdavStatus.getStatusText
@@ -506,10 +504,10 @@
}
// Supported locks
- generatedXML.writeElement(null, "supportedlock",
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "supportedlock",
XMLPrinter.OPENING);
- generatedXML.writeText(SUPPORTED_LOCK);
- generatedXML.writeElement(null, "supportedlock",
+ writeSupportedLock(generatedXML);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "supportedlock",
XMLPrinter.CLOSING);
// WebDAV ACL
@@ -532,11 +530,11 @@
else {
ownerHref=config.getUsersPath() + "/" + config.getGuestPath();
}
- generatedXML.writeElement(null, OWNER, XMLPrinter.OPENING);
- generatedXML.writeElement(null, "href", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, OWNER, XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "href", XMLPrinter.OPENING);
generatedXML.writeText(WebdavUtils.encodeURL(ownerHref));
- generatedXML.writeElement(null, "href", XMLPrinter.CLOSING);
- generatedXML.writeElement(null, OWNER, XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "href", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, OWNER, XMLPrinter.CLOSING);
}
@@ -561,20 +559,27 @@
}
}
- generatedXML.writeElement(null, "prop", XMLPrinter.CLOSING);
- generatedXML.writeProperty(null, "status", status);
- generatedXML.writeElement(null, "propstat",
+ // DeltaV computed properties
+ if (allpropSupportsDeltaV) {
+ writeAllComputedDeltaVProperties(revisionDescriptors, revisionDescriptor, contextPath, serverURL, propertyHelper, generatedXML);
+ }
+
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "prop", XMLPrinter.CLOSING);
+ generatedXML.writeProperty(null, DEFAULT_NAMESPACE, "status", status);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "propstat",
XMLPrinter.CLOSING);
}
else {
// Show requested properties value.
+ ResourceKind resourceKind = AbstractResourceKind.determineResourceKind(revisionDescriptor);
+
Iterator propertyIterator = requestedProperties.getRequestedProperties();
- generatedXML.writeElement(null, "propstat",
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "propstat",
XMLPrinter.OPENING);
- generatedXML.writeElement(null, "prop", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "prop", XMLPrinter.OPENING);
status = new String("HTTP/1.1 " + WebdavStatus.SC_OK
+ " " + WebdavStatus.getStatusText
@@ -597,10 +602,10 @@
(property.getNamespace().equals
(NodeProperty.DEFAULT_NAMESPACE))) {
// Supported locks
- generatedXML.writeElement(null, "supportedlock",
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "supportedlock",
XMLPrinter.OPENING);
- generatedXML.writeText(SUPPORTED_LOCK);
- generatedXML.writeElement(null, "supportedlock",
+ writeSupportedLock(generatedXML);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "supportedlock",
XMLPrinter.CLOSING);
} else if ((property.getName().equals(OWNER)) &&
(property.getNamespace().equals
@@ -615,11 +620,11 @@
else {
ownerHref=config.getUsersPath() + "/" + config.getGuestPath();
}
- generatedXML.writeElement(null, OWNER, XMLPrinter.OPENING);
- generatedXML.writeElement(null, "href", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, OWNER, XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "href", XMLPrinter.OPENING);
generatedXML.writeText(WebdavUtils.encodeURL(ownerHref));
- generatedXML.writeElement(null, "href", XMLPrinter.CLOSING);
- generatedXML.writeElement(null, OWNER, XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "href", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, OWNER, XMLPrinter.CLOSING);
} else if ((property.getName().equals(SUPPORTED_PRIVILEGE_SET)) &&
(property.getNamespace().equals
(NodeProperty.DEFAULT_NAMESPACE))) {
@@ -646,7 +651,14 @@
(NodeProperty.DEFAULT_NAMESPACE))) {
if( org.apache.slide.util.Configuration.useIntegratedSecurity() )
showPrincipalCollectionSet(contextPath, generatedXML);
- } else {
+ }
+
+ // now the computed (DeltaV) properties
+ else if (resourceKind.isSupportedLiveProperty(property.getName())) {
+ writeLiveProperty(property.getName(), revisionDescriptors, revisionDescriptor, contextPath, serverURL, propertyHelper, generatedXML);
+ }
+
+ else {
// Search in the custom properties
@@ -662,9 +674,9 @@
}
- generatedXML.writeElement(null, "prop", XMLPrinter.CLOSING);
- generatedXML.writeProperty(null, "status", status);
- generatedXML.writeElement(null, "propstat",
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "prop", XMLPrinter.CLOSING);
+ generatedXML.writeProperty(null, DEFAULT_NAMESPACE, "status", status);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "propstat",
XMLPrinter.CLOSING);
Enumeration propertiesNotFoundList =
@@ -676,9 +688,9 @@
+ " " + WebdavStatus.getStatusText
(WebdavStatus.SC_NOT_FOUND));
- generatedXML.writeElement(null, "propstat",
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "propstat",
XMLPrinter.OPENING);
- generatedXML.writeElement(null, "prop",
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "prop",
XMLPrinter.OPENING);
while (propertiesNotFoundList.hasMoreElements()) {
@@ -690,10 +702,10 @@
(namespaceAbbrev, null, propertyNotFound.getName(), XMLPrinter.NO_CONTENT);
}
- generatedXML.writeElement(null, "prop",
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "prop",
XMLPrinter.CLOSING);
- generatedXML.writeProperty(null, "status", status);
- generatedXML.writeElement(null, "propstat",
+ generatedXML.writeProperty(null, DEFAULT_NAMESPACE, "status", status);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "propstat",
XMLPrinter.CLOSING);
}
@@ -728,14 +740,13 @@
String namespace,
String propertyName,
Object propertyValue) {
- String namespaceAbbrev = (String) namespacesMap.get(namespace);
if ((propertyValue == null) ||
(propertyValue.toString().equals(""))) {
generatedXML.writeElement
- (namespaceAbbrev, null, propertyName, XMLPrinter.NO_CONTENT);
+ (null, namespace, propertyName, XMLPrinter.NO_CONTENT);
} else {
generatedXML.writeElement
- (namespaceAbbrev, null, propertyName, XMLPrinter.OPENING);
+ (null, namespace, propertyName, XMLPrinter.OPENING);
String currentPropertyString = propertyValue.toString();
if (propertyName.equals("displayname") &&
!currentPropertyString.startsWith("<![CDATA[") &&
@@ -746,7 +757,7 @@
generatedXML.writeText(currentPropertyString);
}
generatedXML.writeElement
- (namespaceAbbrev, null, propertyName, XMLPrinter.CLOSING);
+ (null, namespace, propertyName, XMLPrinter.CLOSING);
}
}
@@ -807,32 +818,32 @@
XMLPrinter generatedXML)
{
- generatedXML.writeElement(null, "lockdiscovery", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "lockdiscovery", XMLPrinter.OPENING);
- generatedXML.writeElement(null, "activelock", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "activelock", XMLPrinter.OPENING);
- generatedXML.writeElement(null, "locktype", XMLPrinter.OPENING);
- generatedXML.writeElement(null, "write", XMLPrinter.NO_CONTENT);
- generatedXML.writeElement(null, "locktype", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "locktype", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "write", XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "locktype", XMLPrinter.CLOSING);
- generatedXML.writeElement(null, "lockscope", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "lockscope", XMLPrinter.OPENING);
if (token.isExclusive()) {
- generatedXML.writeElement(null, "exclusive",
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "exclusive",
XMLPrinter.NO_CONTENT);
} else {
- generatedXML.writeElement(null, "shared", XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "shared", XMLPrinter.NO_CONTENT);
}
- generatedXML.writeElement(null, "lockscope", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "lockscope", XMLPrinter.CLOSING);
- generatedXML.writeElement(null, "depth", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "depth", XMLPrinter.OPENING);
if (token.isInheritable()) {
- generatedXML.writeText("Infinity");
+ generatedXML.writeText("infinity");
} else {
generatedXML.writeText("0");
}
- generatedXML.writeElement(null, "depth", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "depth", XMLPrinter.CLOSING);
- generatedXML.writeElement(null, "owner", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "owner", XMLPrinter.OPENING);
/* We need to write this as data (i.e. a CDATA section) because
* we don't know what the subjectUri (i.e. username) might
* contain. The webdav RFC leaves us completely free to
@@ -840,17 +851,17 @@
*/
generatedXML.writeText(getFullPath(contextPath, token.getSubjectUri()));
// generatedXML.writeData(token.getSubjectUri());
- generatedXML.writeElement(null, "owner", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "owner", XMLPrinter.CLOSING);
- generatedXML.writeElement(null, "timeout", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "timeout", XMLPrinter.OPENING);
generatedXML.writeText("Second-"
+ (new Long((token.getExpirationDate().getTime()
- (new Date()).getTime())/1000))
.toString());
- generatedXML.writeElement(null, "timeout", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "timeout", XMLPrinter.CLOSING);
- generatedXML.writeElement(null, "locktoken", XMLPrinter.OPENING);
- generatedXML.writeElement(null, "href", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "locktoken", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "href", XMLPrinter.OPENING);
// Put here the token Id
boolean isOwner = false;
try {
@@ -864,12 +875,12 @@
} else {
generatedXML.writeText("opaquelocktoken:faketoken");
}
- generatedXML.writeElement(null, "href", XMLPrinter.CLOSING);
- generatedXML.writeElement(null, "locktoken", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "href", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "locktoken", XMLPrinter.CLOSING);
- generatedXML.writeElement(null, "activelock", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "activelock", XMLPrinter.CLOSING);
- generatedXML.writeElement(null, "lockdiscovery", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "lockdiscovery", XMLPrinter.CLOSING);
}
@@ -879,15 +890,14 @@
*/
protected void showSupportedPrivilegeSet(XMLPrinter generatedXML) {
- generatedXML.writeElement(null, SUPPORTED_PRIVILEGE_SET,
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, SUPPORTED_PRIVILEGE_SET,
XMLPrinter.OPENING);
// FIXME : Make the genaration dynamic (although it needs only to be
// generated once). I suggest waiting for the DAV ACL spec final
// version before implementing that.
- generatedXML.writeText(SUPPORTED_PRIVILEGES);
-
- generatedXML.writeElement(null, SUPPORTED_PRIVILEGE_SET,
+ writeSupportedPrivileges(generatedXML);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, SUPPORTED_PRIVILEGE_SET,
XMLPrinter.CLOSING);
}
@@ -977,7 +987,7 @@
boolean canAll = canRead && canWrite && canReadAcl && canWriteAcl
&& killLock;
- generatedXML.writeElement(null, CURRENT_USER_PRIVILEGE_SET,
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, CURRENT_USER_PRIVILEGE_SET,
XMLPrinter.OPENING);
if (canRead) {
@@ -996,7 +1006,7 @@
writePrivilege(generatedXML, "all", null);
}
- generatedXML.writeElement(null, CURRENT_USER_PRIVILEGE_SET,
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, CURRENT_USER_PRIVILEGE_SET,
XMLPrinter.CLOSING);
} catch (SlideException e) {
@@ -1011,9 +1021,9 @@
*/
protected void writePrivilege(XMLPrinter generatedXML, String privilege,
String namespace) {
- generatedXML.writeElement(null, "privilege", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "privilege", XMLPrinter.OPENING);
generatedXML.writeElement(namespace, privilege, XMLPrinter.NO_CONTENT);
- generatedXML.writeElement(null, "privilege", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "privilege", XMLPrinter.CLOSING);
}
@@ -1022,7 +1032,7 @@
*/
protected void showAcl(ObjectNode object, String contextPath, XMLPrinter generatedXML) throws AccessDeniedException, ServiceAccessException {
- generatedXML.writeElement(null, ACL, XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, ACL, XMLPrinter.OPENING);
NamespaceConfig config = token.getNamespaceConfig();
@@ -1185,14 +1195,14 @@
// start generating XML
- generatedXML.writeElement(null, ACE, XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, ACE, XMLPrinter.OPENING);
writePrincipal(contextPath, generatedXML, principal);
if (permission.isNegative()) {
- generatedXML.writeElement(null, DENY, XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, DENY, XMLPrinter.OPENING);
} else {
- generatedXML.writeElement(null, GRANT, XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, GRANT, XMLPrinter.OPENING);
}
if (isAll) {
@@ -1268,28 +1278,28 @@
}
if (permission.isNegative()) {
- generatedXML.writeElement(null, DENY,
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, DENY,
XMLPrinter.CLOSING);
} else {
- generatedXML.writeElement(null, GRANT,
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, GRANT,
XMLPrinter.CLOSING);
}
if (inheritedPermissions) {
- generatedXML.writeElement(null, "protected",
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "protected",
XMLPrinter.NO_CONTENT);
- generatedXML.writeElement(null, INHERITED,
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, INHERITED,
XMLPrinter.OPENING);
- generatedXML.writeElement(null, "href",
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "href",
XMLPrinter.OPENING);
generatedXML.writeText(getFullPath(contextPath, current.getUri()));
- generatedXML.writeElement(null, "href",
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "href",
XMLPrinter.CLOSING);
- generatedXML.writeElement(null, INHERITED,
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, INHERITED,
XMLPrinter.CLOSING);
}
- generatedXML.writeElement(null, ACE, XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, ACE, XMLPrinter.CLOSING);
}
} catch (SlideException e) {
@@ -1305,7 +1315,7 @@
}
- generatedXML.writeElement(null, ACL, XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, ACL, XMLPrinter.CLOSING);
}
@@ -1314,20 +1324,20 @@
* Write principal.
*/
protected void writePrincipal(String contextPath, XMLPrinter generatedXML, String principal) {
- generatedXML.writeElement(null, PRINCIPAL, XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, PRINCIPAL, XMLPrinter.OPENING);
// FIXME: Apparently, there are or will be some other cases, but it
// isn't very clear in the spec
if (principal.equals("~")) {
- generatedXML.writeElement(null, "self", XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "self", XMLPrinter.NO_CONTENT);
} else if (principal.equals("nobody")) {
- generatedXML.writeElement(null, "all",
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "all",
XMLPrinter.NO_CONTENT);
} else {
- generatedXML.writeElement(null, "href", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "href", XMLPrinter.OPENING);
generatedXML.writeText(getFullPath(contextPath, principal));
- generatedXML.writeElement(null, "href", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "href", XMLPrinter.CLOSING);
}
- generatedXML.writeElement(null, PRINCIPAL, XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, PRINCIPAL, XMLPrinter.CLOSING);
}
@@ -1336,14 +1346,14 @@
*/
protected void writePrivilege(XMLPrinter generatedXML, String name,
boolean standard) {
- generatedXML.writeElement(null, PRIVILEGE, XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, PRIVILEGE, XMLPrinter.OPENING);
if (standard) {
- generatedXML.writeElement(null, name, XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, name, XMLPrinter.NO_CONTENT);
} else {
generatedXML.writeElement(WebdavMethod.SLIDE_NAMESPACE_ABBREV, name,
XMLPrinter.NO_CONTENT);
}
- generatedXML.writeElement(null, PRIVILEGE, XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, PRIVILEGE, XMLPrinter.CLOSING);
}
@@ -1351,9 +1361,9 @@
* WebDAV ACL DAV:acl-semantics property.
*/
protected void showAclSemantics(XMLPrinter generatedXML) {
- generatedXML.writeElement(null, ACL_SEMANTICS, XMLPrinter.OPENING);
- generatedXML.writeText(SLIDE_ACL_SEMANTICS);
- generatedXML.writeElement(null, ACL_SEMANTICS, XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, ACL_SEMANTICS, XMLPrinter.OPENING);
+ writeSlideAclSemantics(generatedXML);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, ACL_SEMANTICS, XMLPrinter.CLOSING);
}
@@ -1362,12 +1372,13 @@
*/
protected void showPrincipalCollectionSet(String contextPath, XMLPrinter generatedXML) {
NamespaceConfig config = token.getNamespaceConfig();
- generatedXML.writeElement(null, PRINCIPAL_COLLECTION_SET,
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, PRINCIPAL_COLLECTION_SET,
XMLPrinter.OPENING);
- generatedXML.writeElement(null, "href", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "href", XMLPrinter.OPENING);
+
generatedXML.writeText(getFullPath(contextPath, config.getUsersPath()));
- generatedXML.writeElement(null, "href", XMLPrinter.CLOSING);
- generatedXML.writeElement(null, PRINCIPAL_COLLECTION_SET,
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "href", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, PRINCIPAL_COLLECTION_SET,
XMLPrinter.CLOSING);
}
@@ -1436,6 +1447,159 @@
}
}
+ /**
+ * Writes the <code><lockentry></code> to the given
+ * xmlPrinter.
+ *
+ * @param generatedXML the XMLPrinter to write to.
+ */
+ protected void writeSupportedLock(XMLPrinter generatedXML) {
+
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, E_LOCKENTRY, XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, E_LOCKSCOPE, XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, E_EXCLUSIVE, XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, E_LOCKSCOPE, XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, E_LOCKTYPE, XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, E_WRITE, XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, E_LOCKTYPE, XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, E_LOCKENTRY, XMLPrinter.CLOSING);
+
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, E_LOCKENTRY, XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, E_LOCKSCOPE, XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, E_SHARED, XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, E_LOCKSCOPE, XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, E_LOCKTYPE, XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, E_WRITE, XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, E_LOCKTYPE, XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, E_LOCKENTRY, XMLPrinter.CLOSING);
+
+ }
+
+ /**
+ * Writes the <code><supported-privilege></code> to the given
+ * xmlPrinter.
+ *
+ * @param generatedXML the XMLPrinter to write to.
+ */
+ protected void writeSupportedPrivileges(XMLPrinter generatedXML) {
+
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "supported-privilege", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "privilege", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "all", XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "privilege", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "description", XMLPrinter.OPENING);
+ generatedXML.writeText("Any operation");
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "description", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "privilege", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "read", XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "privilege", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "description", XMLPrinter.OPENING);
+ generatedXML.writeText("Read any object");
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "description", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "supported-privilege", XMLPrinter.CLOSING);
+
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "supported-privilege", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "privilege", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "write", XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "privilege", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "description", XMLPrinter.OPENING);
+ generatedXML.writeText("Write any object");
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "description", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "privilege", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "read-acl", XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "privilege", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "description", XMLPrinter.OPENING);
+ generatedXML.writeText("Read the ACL");
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "description", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "supported-privilege", XMLPrinter.CLOSING);
+
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "supported-privilege", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "privilege", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "write-acl", XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "privilege", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "description", XMLPrinter.OPENING);
+ generatedXML.writeText("Write the ACL");
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "description", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "supported-privilege", XMLPrinter.CLOSING);
+ }
+
+ /**
+ * Writes the <code><supported-privilege></code> to the given
+ * xmlPrinter.
+ *
+ * @param generatedXML the XMLPrinter to write to.
+ */
+ protected void writeSlideAclSemantics(XMLPrinter generatedXML) {
+
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "ace-combination", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "all-grant-before-any-deny", XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "ace-combination", XMLPrinter.CLOSING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "required-principal", XMLPrinter.OPENING);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "all", XMLPrinter.NO_CONTENT);
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, "required-principal", XMLPrinter.CLOSING);
+ }
+
+ /**
+ * Writes the specified (live) property to the given XMLPrinter.
+ *
+ * @param propertyName
+ * @param revisionDescriptors
+ * @param revisionDescriptor
+ * @param contextPath the context path of the uri. The concatenation of
+ * <code>serverURL</code>/<code>contextPath</code>
+ * /<code>uri</code> gives the absolute URL of the resource.
+ * @param serverURL the URL of the server (e.g. <code>http://www.abc.com</code>).
+ * @param propertyHelper
+ * @param generatedXML
+ *
+ * @throws ObjectLockedException
+ * @throws ServiceAccessException
+ * @throws LinkedObjectNotFoundException
+ * @throws AccessDeniedException
+ * @throws ObjectNotFoundException
+ * @throws RevisionDescriptorNotFoundException
+ * @throws LockTokenNotFoundException
+ */
+ protected void writeLiveProperty(String propertyName, NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, String serverURL, PropertyHelper propertyHelper, XMLPrinter generatedXML) throws ObjectLockedException, ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, RevisionDescriptorNotFoundException, LockTokenNotFoundException {
+
+ NodeProperty property = propertyHelper.getProperty(propertyName, revisionDescriptors, revisionDescriptor);
+ if (property != null) {
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, propertyName, XMLPrinter.OPENING);
+ generatedXML.writeText(property.getValue().toString());
+ generatedXML.writeElement(null, DEFAULT_NAMESPACE, propertyName, XMLPrinter.CLOSING);
+ }
+ }
+
+ /**
+ * Writes all computed DeltaV properties to the given XMLPrinter.
+ *
+ * @param revisionDescriptors
+ * @param revisionDescriptor
+ * @param contextPath the context path of the uri. The concatenation of
+ * <code>serverURL</code>/<code>contextPath</code>
+ * /<code>uri</code> gives the absolute URL of the resource.
+ * @param serverURL the URL of the server (e.g. <code>http://www.abc.com</code>).
+ * @param propertyHelper
+ * @param generatedXML
+ *
+ * @throws ObjectLockedException
+ * @throws ServiceAccessException
+ * @throws LinkedObjectNotFoundException
+ * @throws AccessDeniedException
+ * @throws ObjectNotFoundException
+ * @throws RevisionDescriptorNotFoundException
+ * @throws LockTokenNotFoundException
+ */
+ protected void writeAllComputedDeltaVProperties(NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath, String serverURL, PropertyHelper propertyHelper, XMLPrinter generatedXML) throws ObjectLockedException, ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException, RevisionDescriptorNotFoundException, LockTokenNotFoundException {
+
+ ResourceKind resourceKind = AbstractResourceKind.determineResourceKind(revisionDescriptor);
+ Set computedLivePropertyNames = resourceKind.getSupportedLiveProperties(Q_COMPUTED_ONLY, new String[] {F_ACCESS_CONTROL, F_LOCKING, F_UPDATE});
+ Iterator iterator = computedLivePropertyNames.iterator();
+ while (iterator.hasNext()) {
+ writeLiveProperty((String)iterator.next(), revisionDescriptors, revisionDescriptor, contextPath, serverURL, propertyHelper, generatedXML);
+ }
+}
}
+
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>