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 pn...@apache.org on 2002/04/05 18:12:00 UTC
cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/util UriHandler.java
pnever 02/04/05 08:12:00
Modified: src/webdav/server/org/apache/slide/webdav/util
UriHandler.java
Log:
Added support for workspace paths
Revision Changes Path
1.5 +42 -6 jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/UriHandler.java
Index: UriHandler.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/UriHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- UriHandler.java 28 Mar 2002 06:12:13 -0000 1.4
+++ UriHandler.java 5 Apr 2002 16:12:00 -0000 1.5
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/UriHandler.java,v 1.4 2002/03/28 06:12:13 jericho Exp $
- * $Revision: 1.4 $
- * $Date: 2002/03/28 06:12:13 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/UriHandler.java,v 1.5 2002/04/05 16:12:00 pnever Exp $
+ * $Revision: 1.5 $
+ * $Date: 2002/04/05 16:12:00 $
*
* ====================================================================
*
@@ -89,6 +89,10 @@
// namespace_name -> URI_handler_for_history_path
protected static Map hpathHandlers = new HashMap();
+ // Cache for workspace path handlers:
+ // namespace_name -> URI_handler_for_workspace_path
+ protected static Map wspathHandlers = new HashMap();
+
/**
* Factory method.
*/
@@ -96,8 +100,8 @@
getUriHandler( NamespaceAccessToken nsaToken, String resourcePath ) {
String nsName = nsaToken.getName();
- UriHandler hpathHandler =
- HistoryPathHandler.getHistoryPathHandler( nsaToken );
+ HistoryPathHandler.getHistoryPathHandler( nsaToken );
+ WorkspacePathHandler.getWorkspacePathHandler( nsaToken );
return new UriHandler( nsName, resourcePath );
}
@@ -156,7 +160,6 @@
private String uri;
private String nsName;
private String[] uriTokens = null;
- private UriHandler hpathHandler = null;
/**
@@ -203,6 +206,23 @@
}
/**
+ * Return true, if this is a valid workspace URI
+ */
+ public boolean isWorkspaceUri() {
+ UriHandler wspathHandler = (UriHandler)wspathHandlers.get( nsName );
+ String[] wspathTokens = wspathHandler.getUriTokens();
+
+ if( (wspathTokens.length + 1) == uriTokens.length ) {
+ for( int i = 0; i < wspathTokens.length; i++ ) {
+ if( !wspathTokens[i].equals(uriTokens[i]) )
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
* Return true, if this is a history URI
*/
public boolean isHistoryUri() {
@@ -237,6 +257,21 @@
}
/**
+ * Returns the workspace identifier from the uri
+ * @pre isWorkspaceUri()
+ */
+ public String getWorkspaceName() {
+ UriHandler wspathHandler = (UriHandler)wspathHandlers.get( nsName );
+ String[] wspathTokens = wspathHandler.getUriTokens();
+
+ if( !isWorkspaceUri() )
+ throw new IllegalStateException(
+ "URI "+uri+" is not a workspace URI" );
+
+ return uriTokens[wspathTokens.length];
+ }
+
+ /**
* Returns the history identifier from the uri
* @pre isHistoryUri() || isVersionUri()
*/
@@ -294,4 +329,5 @@
return b.toString();
}
}
+
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>