pnever 02/04/26 05:46:16
Modified: src/webdav/server/org/apache/slide/webdav/util
UriHandler.java
Log:
Added support for workingresource URIs
Revision Changes Path
1.9 +67 -3
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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- UriHandler.java 25 Apr 2002 21:15:15 -0000 1.8
+++ UriHandler.java 26 Apr 2002 12:46:16 -0000 1.9
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/UriHandler.java,v
1.8 2002/04/25 21:15:15 jericho Exp $
- * $Revision: 1.8 $
- * $Date: 2002/04/25 21:15:15 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/UriHandler.java,v
1.9 2002/04/26 12:46:16 pnever Exp $
+ * $Revision: 1.9 $
+ * $Date: 2002/04/26 12:46:16 $
*
* ====================================================================
*
@@ -93,6 +93,10 @@
// namespace_name -> URI_handler_for_workspace_path
protected static Map wspathHandlers = new HashMap();
+ // Cache for workingresource path handlers:
+ // namespace_name -> URI_handler_for_workingresource_path
+ protected static Map wrpathHandlers = new HashMap();
+
/**
* Factory method.
*/
@@ -149,6 +153,49 @@
}
/**
+ * Generates the next available workingresource URI and returns an URI handler
for it.
+ */
+ public static UriHandler
+ createNextWorkingresourceUri( SlideToken sToken, NamespaceAccessToken nsaToken )
+ throws ObjectNotFoundException, AccessDeniedException, ObjectLockedException,
+ LinkedObjectNotFoundException, ServiceAccessException,
+ RevisionDescriptorNotFoundException, RevisionNotFoundException {
+
+ UriHandler result = null;
+ String nsName = nsaToken.getName();
+ UriHandler wrpathHandler =
+ WorkingresourcePathHandler.getWorkingresourcePathHandler( nsaToken );
+ Content content = nsaToken.getContentHelper();
+ String wrpath = wrpathHandler.toString();
+
+ NodeRevisionDescriptors wrpathNrds =
+ content.retrieve( sToken, wrpath );
+
+ NodeRevisionDescriptor wrpathNrd =
+ content.retrieve( sToken, wrpathNrds );
+
+ NodeProperty nextWrnProp = wrpathNrd.getProperty(
I_NEXT_WORKINGRESOURCE_NAME );
+ if( nextWrnProp == null || nextWrnProp.getValue() == null ) {
+ nextWrnProp =
+ new NodeProperty( I_NEXT_WORKINGRESOURCE_NAME,
I_INITIAL_WORKINGRESOURCE_NAME );
+ wrpathNrd.setProperty( nextWrnProp );
+ }
+
+ String nextHnStr = (String)nextWrnProp.getValue();
+ result = new UriHandler(
+ nsName, wrpath+"/"+nextHnStr );
+
+ long nextHnLong = Long.parseLong( nextHnStr );
+ nextWrnProp = new NodeProperty(
+ I_NEXT_WORKINGRESOURCE_NAME, String.valueOf(nextHnLong + 1) );
+ wrpathNrd.setProperty( nextWrnProp );
+
+ content.store( sToken, wrpath, wrpathNrd, null ); //revisionContent = null
+
+ return result;
+ }
+
+ /**
* Creates a VR URI for the specified version in the specified history and
* returns an URI handler for it.
*/
@@ -300,6 +347,23 @@
if( (hpathTokens.length + 2) == uriTokens.length ) {
for( int i = 0; i < hpathTokens.length; i++ ) {
if( !hpathTokens[i].equals(uriTokens[i]) )
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return true, if this is a valid workingresource URI
+ */
+ public boolean isWorkingresourceUri() {
+ UriHandler wrpathHandler = (UriHandler)wrpathHandlers.get( nsName );
+ String[] wrpathTokens = wrpathHandler.getUriTokens();
+
+ if( (wrpathTokens.length + 1) == uriTokens.length ) {
+ for( int i = 0; i < wrpathTokens.length; i++ ) {
+ if( !wrpathTokens[i].equals(uriTokens[i]) )
return false;
}
return true;
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>