juergen 02/03/11 23:20:55
Modified: src/webdav/server/org/apache/slide/webdav/util
PropertyHelper.java
Log:
Added parameters "contextPath" and "serverURL" to support absolute URLs in <href>
properties.
(ralf)
Revision Changes Path
1.6 +142 -23
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java
Index: PropertyHelper.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PropertyHelper.java 8 Mar 2002 11:55:51 -0000 1.5
+++ PropertyHelper.java 12 Mar 2002 07:20:55 -0000 1.6
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java,v
1.5 2002/03/08 11:55:51 juergen Exp $
- * $Revision: 1.5 $
- * $Date: 2002/03/08 11:55:51 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/PropertyHelper.java,v
1.6 2002/03/12 07:20:55 juergen Exp $
+ * $Revision: 1.6 $
+ * $Date: 2002/03/12 07:20:55 $
*
* ====================================================================
*
@@ -386,6 +386,30 @@
* @throws ObjectNotFoundException
*/
public NodeProperty getProperty(String propertyName, String resourcePath)
throws ObjectLockedException, RevisionDescriptorNotFoundException,
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException,
ObjectNotFoundException {
+ return getProperty(propertyName, resourcePath, null, null);
+ }
+
+ /**
+ * Returns the property of the resource described by
+ * the resourcePath.
+ *
+ * @param propertyName the name of the property.
+ * @param resourcePath the path that identifies the resource.
+ * @param contextPath the context path of the uri. The concatenation
of
+ * <code>serverURL</code>/<code>contextPath</code>
+ * /<code>resourcePath</code> gives the absolute
URL of the resource.
+ * @param serverURL the URL of the server (e.g.
<code>http://www.abc.com</code>).
+ *
+ * @return the property.
+ *
+ * @throws ObjectLockedException
+ * @throws RevisionDescriptorNotFoundException
+ * @throws ServiceAccessException
+ * @throws LinkedObjectNotFoundException
+ * @throws AccessDeniedException
+ * @throws ObjectNotFoundException
+ */
+ public NodeProperty getProperty(String propertyName, String resourcePath,
String contextPath, String serverURL) throws ObjectLockedException,
RevisionDescriptorNotFoundException, ServiceAccessException,
LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException {
UriHandler uriHandler = UriHandler.getUriHandler(nsaToken, resourcePath);
String uri = null;
@@ -410,7 +434,7 @@
revisionDescriptors = contentHelper.retrieve(sToken, uri);
revisionDescriptor = contentHelper.retrieve(sToken,
revisionDescriptors);
}
- return getProperty(propertyName, revisionDescriptors, revisionDescriptor);
+ return getProperty(propertyName, revisionDescriptors, revisionDescriptor,
contextPath, serverURL);
}
/**
@@ -431,12 +455,38 @@
* @throws ObjectNotFoundException
*/
public NodeProperty getProperty(String propertyName, NodeRevisionDescriptors
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor) throws
ObjectLockedException, RevisionDescriptorNotFoundException, ServiceAccessException,
LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException {
+ return getProperty(propertyName, revisionDescriptors, revisionDescriptor,
null, null);
+ }
+
+ /**
+ * Returns the property of the resource described by
+ * the resourcePath.
+ *
+ * @param propertyName the name of the property.
+ * @param revisionDescriptors the NodeRevisionDescriptors of the resource.
+ * @param revisionDescriptor the NodeRevisionDescriptor of the resource.
+ * @param contextPath the context path of the
NodeRevisionDescriptors' uri.
+ * The concatenation of <code>serverURL</code>/
+ *
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
+ * gives the absolute URL of the resource.
+ * @param serverURL the URL of the server (e.g.
<code>http://www.abc.com</code>).
+ *
+ * @return the property.
+ *
+ * @throws ObjectLockedException
+ * @throws RevisionDescriptorNotFoundException
+ * @throws ServiceAccessException
+ * @throws LinkedObjectNotFoundException
+ * @throws AccessDeniedException
+ * @throws ObjectNotFoundException
+ */
+ public NodeProperty getProperty(String propertyName, NodeRevisionDescriptors
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath,
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException,
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException,
ObjectNotFoundException {
NodeProperty property = null;
ResourceKind resourceKind =
AbstractResourceKind.determineResourceKind(revisionDescriptor);
if (resourceKind.isSupportedLiveProperty(propertyName)) {
if (AbstractResourceKind.isComputedProperty(propertyName)) {
- property = computeProperty(propertyName, revisionDescriptors,
revisionDescriptor);
+ property = computeProperty(propertyName, revisionDescriptors,
revisionDescriptor, contextPath, serverURL);
}
}
@@ -449,6 +499,11 @@
* @param propertyName the name of the property.
* @param revisionDescriptors the NodeRevisionDescriptors of the resource.
* @param revisionDescriptor the NodeRevisionDescriptor of the resource.
+ * @param contextPath the context path of the
NodeRevisionDescriptors' uri.
+ * The concatenation of <code>serverURL</code>/
+ *
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
+ * gives the absolute URL of the resource.
+ * @param serverURL the URL of the server (e.g.
<code>http://www.abc.com</code>).
*
* @return the property.
*
@@ -459,26 +514,26 @@
* @throws AccessDeniedException
* @throws ObjectNotFoundException
*/
- public NodeProperty computeProperty(String propertyName,
NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor
revisionDescriptor) throws ObjectLockedException, RevisionDescriptorNotFoundException,
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException,
ObjectNotFoundException {
+ public NodeProperty computeProperty(String propertyName,
NodeRevisionDescriptors revisionDescriptors, NodeRevisionDescriptor
revisionDescriptor, String contextPath, String serverURL) throws
ObjectLockedException, RevisionDescriptorNotFoundException, ServiceAccessException,
LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException {
NodeProperty property = null;
if (P_SUCCESSOR_SET.equals(propertyName)) {
- property = new NodeProperty(propertyName,
computeSuccessorSet(revisionDescriptors, revisionDescriptor));
+ property = new NodeProperty(propertyName,
computeSuccessorSet(revisionDescriptors, revisionDescriptor, contextPath, serverURL));
}
else if (P_VERSION_HISTORY.equals(propertyName)) {
- property = new NodeProperty(propertyName,
computeVersionHistory(revisionDescriptors, revisionDescriptor));
+ property = new NodeProperty(propertyName,
computeVersionHistory(revisionDescriptors, revisionDescriptor, contextPath,
serverURL));
}
else if (P_ROOT_VERSION.equals(propertyName)) {
- property = new NodeProperty(propertyName,
computeRootVersion(revisionDescriptors, revisionDescriptor));
+ property = new NodeProperty(propertyName,
computeRootVersion(revisionDescriptors, revisionDescriptor, contextPath, serverURL));
}
else if (P_SUPPORTED_METHOD_SET.equals(propertyName)) {
- property = new NodeProperty(propertyName,
computeSupportedMethodSet(revisionDescriptors, revisionDescriptor));
+ property = new NodeProperty(propertyName,
computeSupportedMethodSet(revisionDescriptors, revisionDescriptor, contextPath,
serverURL));
}
else if (P_SUPPORTED_LIVE_PROPERTY_SET.equals(propertyName)) {
- property = new NodeProperty(propertyName,
computeSupportedLivePropertySet(revisionDescriptors, revisionDescriptor));
+ property = new NodeProperty(propertyName,
computeSupportedLivePropertySet(revisionDescriptors, revisionDescriptor, contextPath,
serverURL));
}
else if (P_SUPPORTED_REPORT_SET.equals(propertyName)) {
- property = new NodeProperty(propertyName,
computeSupportedReportSet(revisionDescriptors, revisionDescriptor));
+ property = new NodeProperty(propertyName,
computeSupportedReportSet(revisionDescriptors, revisionDescriptor, contextPath,
serverURL));
}
return property;
@@ -490,6 +545,11 @@
*
* @param revisionDescriptors the NodeRevisionDescriptors of the resource.
* @param revisionDescriptor the NodeRevisionDescriptor of the resource.
+ * @param contextPath the context path of the
NodeRevisionDescriptors' uri.
+ * The concatenation of <code>serverURL</code>/
+ *
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
+ * gives the absolute URL of the resource.
+ * @param serverURL the URL of the server (e.g.
<code>http://www.abc.com</code>).
*
* @return the successor list.
*
@@ -500,7 +560,7 @@
* @throws AccessDeniedException
* @throws ObjectNotFoundException
*/
- public XMLValue computeSuccessorSet(NodeRevisionDescriptors
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor) throws
ObjectLockedException, RevisionDescriptorNotFoundException, ServiceAccessException,
LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException {
+ public XMLValue computeSuccessorSet(NodeRevisionDescriptors
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath,
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException,
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException,
ObjectNotFoundException {
XMLValue xmlValue = new XMLValue();
Element hrefElement = new Element(E_HREF, defNamespace);
@@ -517,7 +577,7 @@
buffer.append("/");
}
buffer.append(successorRevisionNumber.toString());
- hrefElement.setText(buffer.toString());
+ hrefElement.setText(getAbsoluteURL(serverURL, contextPath,
buffer.toString()));
xmlValue.add(hrefElement);
}
}
@@ -531,6 +591,11 @@
*
* @param revisionDescriptors the NodeRevisionDescriptors of the resource.
* @param revisionDescriptor the NodeRevisionDescriptor of the resource.
+ * @param contextPath the context path of the
NodeRevisionDescriptors' uri.
+ * The concatenation of <code>serverURL</code>/
+ *
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
+ * gives the absolute URL of the resource.
+ * @param serverURL the URL of the server (e.g.
<code>http://www.abc.com</code>).
*
* @return the version history <code><href></code>.
*
@@ -541,27 +606,27 @@
* @throws AccessDeniedException
* @throws ObjectNotFoundException
*/
- public XMLValue computeVersionHistory(NodeRevisionDescriptors
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor) throws
ObjectLockedException, RevisionDescriptorNotFoundException, ServiceAccessException,
LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException {
+ public XMLValue computeVersionHistory(NodeRevisionDescriptors
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath,
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException,
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException,
ObjectNotFoundException {
XMLValue xmlValue = new XMLValue();
ResourceKind resourceKind =
AbstractResourceKind.determineResourceKind(revisionDescriptor);
if (resourceKind instanceof Version) {
Element element = new Element(E_HREF, defNamespace);
- element.setText(revisionDescriptors.getUri());
+ element.setText(getAbsoluteURL(serverURL, contextPath,
revisionDescriptors.getUri()));
xmlValue.add(element);
}
else if (resourceKind instanceof CheckedInVersionControlled) {
Element element = new Element(E_HREF, defNamespace);
String checkedInUri =
revisionDescriptor.getProperty(P_CHECKED_IN).getValue().toString();
UriHandler uriHandler = UriHandler.getUriHandler(nsaToken,
checkedInUri);
- element.setText(uriHandler.getAssociatedHistoryUri());
+ element.setText(getAbsoluteURL(serverURL, contextPath,
uriHandler.getAssociatedHistoryUri()));
xmlValue.add(element);
}
else if (resourceKind instanceof CheckedOutVersionControlled) {
Element element = new Element(E_HREF, defNamespace);
String checkedInUri =
revisionDescriptor.getProperty(P_CHECKED_OUT).getValue().toString();
UriHandler uriHandler = UriHandler.getUriHandler(nsaToken,
checkedInUri);
- element.setText(uriHandler.getAssociatedHistoryUri());
+ element.setText(getAbsoluteURL(serverURL, contextPath,
uriHandler.getAssociatedHistoryUri()));
xmlValue.add(element);
}
@@ -575,6 +640,11 @@
*
* @param revisionDescriptors the NodeRevisionDescriptors of the resource.
* @param revisionDescriptor the NodeRevisionDescriptor of the resource.
+ * @param contextPath the context path of the
NodeRevisionDescriptors' uri.
+ * The concatenation of <code>serverURL</code>/
+ *
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
+ * gives the absolute URL of the resource.
+ * @param serverURL the URL of the server (e.g.
<code>http://www.abc.com</code>).
*
* @return the root version URI.
*
@@ -585,7 +655,7 @@
* @throws AccessDeniedException
* @throws ObjectNotFoundException
*/
- public XMLValue computeRootVersion(NodeRevisionDescriptors revisionDescriptors,
NodeRevisionDescriptor revisionDescriptor) throws ObjectLockedException,
RevisionDescriptorNotFoundException, ServiceAccessException,
LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException {
+ public XMLValue computeRootVersion(NodeRevisionDescriptors revisionDescriptors,
NodeRevisionDescriptor revisionDescriptor, String contextPath, String serverURL)
throws ObjectLockedException, RevisionDescriptorNotFoundException,
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException,
ObjectNotFoundException {
XMLValue xmlValue = new XMLValue();
@@ -597,7 +667,7 @@
buffer.append("/");
}
buffer.append(revisionDescriptors.getInitialRevision().toString());
- element.setText(buffer.toString());
+ element.setText(getAbsoluteURL(serverURL, contextPath,
buffer.toString()));
xmlValue.add(element);
}
@@ -617,6 +687,11 @@
*
* @param revisionDescriptors the NodeRevisionDescriptors of the resource.
* @param revisionDescriptor the NodeRevisionDescriptor of the resource.
+ * @param contextPath the context path of the
NodeRevisionDescriptors' uri.
+ * The concatenation of <code>serverURL</code>/
+ *
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
+ * gives the absolute URL of the resource.
+ * @param serverURL the URL of the server (e.g.
<code>http://www.abc.com</code>).
*
* @return the supported methods.
*
@@ -627,7 +702,7 @@
* @throws AccessDeniedException
* @throws ObjectNotFoundException
*/
- public XMLValue computeSupportedMethodSet(NodeRevisionDescriptors
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor) throws
ObjectLockedException, RevisionDescriptorNotFoundException, ServiceAccessException,
LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException {
+ public XMLValue computeSupportedMethodSet(NodeRevisionDescriptors
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath,
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException,
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException,
ObjectNotFoundException {
XMLValue xmlValue = new XMLValue();
@@ -658,6 +733,11 @@
*
* @param revisionDescriptors the NodeRevisionDescriptors of the resource.
* @param revisionDescriptor the NodeRevisionDescriptor of the resource.
+ * @param contextPath the context path of the
NodeRevisionDescriptors' uri.
+ * The concatenation of <code>serverURL</code>/
+ *
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
+ * gives the absolute URL of the resource.
+ * @param serverURL the URL of the server (e.g.
<code>http://www.abc.com</code>).
*
* @return the supported live properties.
*
@@ -668,7 +748,7 @@
* @throws AccessDeniedException
* @throws ObjectNotFoundException
*/
- public XMLValue computeSupportedLivePropertySet(NodeRevisionDescriptors
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor) throws
ObjectLockedException, RevisionDescriptorNotFoundException, ServiceAccessException,
LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException {
+ public XMLValue computeSupportedLivePropertySet(NodeRevisionDescriptors
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath,
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException,
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException,
ObjectNotFoundException {
XMLValue xmlValue = new XMLValue();
@@ -705,6 +785,11 @@
*
* @param revisionDescriptors the NodeRevisionDescriptors of the resource.
* @param revisionDescriptor the NodeRevisionDescriptor of the resource.
+ * @param contextPath the context path of the
NodeRevisionDescriptors' uri.
+ * The concatenation of <code>serverURL</code>/
+ *
<code>contextPath</code>/<code>revisionDescriptor.getUri()</code>
+ * gives the absolute URL of the resource.
+ * @param serverURL the URL of the server (e.g.
<code>http://www.abc.com</code>).
*
* @return the supported reports.
*
@@ -715,7 +800,7 @@
* @throws AccessDeniedException
* @throws ObjectNotFoundException
*/
- public XMLValue computeSupportedReportSet(NodeRevisionDescriptors
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor) throws
ObjectLockedException, RevisionDescriptorNotFoundException, ServiceAccessException,
LinkedObjectNotFoundException, AccessDeniedException, ObjectNotFoundException {
+ public XMLValue computeSupportedReportSet(NodeRevisionDescriptors
revisionDescriptors, NodeRevisionDescriptor revisionDescriptor, String contextPath,
String serverURL) throws ObjectLockedException, RevisionDescriptorNotFoundException,
ServiceAccessException, LinkedObjectNotFoundException, AccessDeniedException,
ObjectNotFoundException {
XMLValue xmlValue = new XMLValue();
@@ -738,5 +823,39 @@
return xmlValue;
}
+ /**
+ * Returns the concatenation of <code>serverURL</code>, <code>contextPath</code>
+ * and <code>uri</code> and inserts all needed slashes.
+ *
+ * @param serverURL the URL of the server
+ * @param contextPath the context path.
+ * @param uri the (slide-) URI of the resource.
+ *
+ * @return the concatenated URL.
+ */
+ protected static String getAbsoluteURL(String serverURL, String contextPath,
String uri) {
+
+ StringBuffer buffer = new StringBuffer();
+ String lastAppended = null;
+ if (serverURL != null) {
+ buffer.append(serverURL);
+ lastAppended = serverURL;
+ }
+ if (contextPath != null) {
+ if ( (lastAppended != null) && !lastAppended.endsWith("/") &&
!contextPath.startsWith("/") ) {
+ buffer.append("/");
+ }
+ buffer.append(contextPath);
+ lastAppended = contextPath;
+ }
+ if (uri != null) {
+ if ( (lastAppended != null) && !lastAppended.endsWith("/") &&
!uri.startsWith("/") ) {
+ buffer.append("/");
+ }
+ buffer.append(uri);
+ }
+
+ return buffer.toString();
+ }
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>