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 oz...@apache.org on 2004/05/05 14:30:27 UTC
cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/util UriHandler.java
ozeigermann 2004/05/05 05:30:27
Modified: src/webdav/server/org/apache/slide/webdav/util
UriHandler.java
Log:
Creation of unique URIs for history and workingresource uses
sequence mechanism if available.
Revision Changes Path
1.31 +90 -76 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.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- UriHandler.java 5 May 2004 12:07:30 -0000 1.30
+++ UriHandler.java 5 May 2004 12:30:27 -0000 1.31
@@ -31,6 +31,7 @@
import org.apache.slide.common.ServiceAccessException;
import org.apache.slide.structure.ObjectNotFoundException;
import org.apache.slide.structure.LinkedObjectNotFoundException;
+import org.apache.slide.structure.Structure;
import org.apache.slide.content.Content;
import org.apache.slide.content.NodeProperty;
import org.apache.slide.content.NodeProperty.NamespaceCache;
@@ -105,46 +106,53 @@
Content content = nsaToken.getContentHelper();
String hpath = hpathHandler.toString();
- NodeRevisionDescriptors hpathNrds =
- content.retrieve( sToken, hpath );
-
- NodeRevisionDescriptor hpathNrd =
- content.retrieve( sToken, hpathNrds );
-
- NodeProperty nextHnProp = hpathNrd.getProperty(I_NEXT_HISTORY_NAME,
- NamespaceCache.SLIDE_URI);
- if (nextHnProp == null) {
- // convert to slide namespace if this property is still
- // in DAV: namespace
- nextHnProp = hpathNrd.getProperty( I_NEXT_HISTORY_NAME );
- if (nextHnProp != null) {
- hpathNrd.removeProperty(nextHnProp);
- nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME,
- nextHnProp.getValue(),
- NamespaceCache.SLIDE_URI);
+ Structure structure = nsaToken.getStructureHelper();
+ String uniqueUri = structure.generateUniqueUri(sToken, hpath);
+
+ if (uniqueUri != null) {
+ result = new UriHandler(uniqueUri);
+ } else {
+ NodeRevisionDescriptors hpathNrds =
+ content.retrieve( sToken, hpath );
+
+ NodeRevisionDescriptor hpathNrd =
+ content.retrieve( sToken, hpathNrds );
+
+ NodeProperty nextHnProp = hpathNrd.getProperty(I_NEXT_HISTORY_NAME,
+ NamespaceCache.SLIDE_URI);
+ if (nextHnProp == null) {
+ // convert to slide namespace if this property is still
+ // in DAV: namespace
+ nextHnProp = hpathNrd.getProperty( I_NEXT_HISTORY_NAME );
+ if (nextHnProp != null) {
+ hpathNrd.removeProperty(nextHnProp);
+ nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME,
+ nextHnProp.getValue(),
+ NamespaceCache.SLIDE_URI);
+ nextHnProp.setKind( NodeProperty.Kind.PROTECTED );
+ hpathNrd.setProperty( nextHnProp );
+ }
+ }
+ if( nextHnProp == null || nextHnProp.getValue() == null ) {
+ nextHnProp =
+ new NodeProperty(I_NEXT_HISTORY_NAME,
+ I_INITIAL_HISTORY_NAME,
+ NamespaceCache.SLIDE_URI);
nextHnProp.setKind( NodeProperty.Kind.PROTECTED );
hpathNrd.setProperty( nextHnProp );
}
- }
- if( nextHnProp == null || nextHnProp.getValue() == null ) {
- nextHnProp =
- new NodeProperty(I_NEXT_HISTORY_NAME,
- I_INITIAL_HISTORY_NAME,
- NamespaceCache.SLIDE_URI);
- nextHnProp.setKind( NodeProperty.Kind.PROTECTED );
+
+ String nextHnStr = (String)nextHnProp.getValue();
+ result = new UriHandler( hpath+"/"+nextHnStr );
+
+ long nextHnLong = Long.parseLong( nextHnStr );
+ nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME,
+ String.valueOf(nextHnLong + 1),
+ NamespaceCache.SLIDE_URI );
hpathNrd.setProperty( nextHnProp );
+
+ content.store( sToken, hpath, hpathNrd, null ); //revisionContent = null
}
-
- String nextHnStr = (String)nextHnProp.getValue();
- result = new UriHandler( hpath+"/"+nextHnStr );
-
- long nextHnLong = Long.parseLong( nextHnStr );
- nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME,
- String.valueOf(nextHnLong + 1),
- NamespaceCache.SLIDE_URI );
- hpathNrd.setProperty( nextHnProp );
-
- content.store( sToken, hpath, hpathNrd, null ); //revisionContent = null
return result;
}
@@ -168,48 +176,54 @@
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,
- NamespaceCache.SLIDE_URI);
- if (nextWrnProp == null) {
- // convert to slide namespace if this property is still
- // in DAV: namespace
- nextWrnProp = wrpathNrd.getProperty( I_NEXT_WORKINGRESOURCE_NAME );
- if (nextWrnProp != null) {
- wrpathNrd.removeProperty(nextWrnProp);
- nextWrnProp = new NodeProperty(I_NEXT_WORKINGRESOURCE_NAME,
- nextWrnProp.getValue(),
- NamespaceCache.SLIDE_URI);
+ Structure structure = nsaToken.getStructureHelper();
+ String uniqueUri = structure.generateUniqueUri(sToken, wrpath);
+
+ if (uniqueUri != null) {
+ result = new UriHandler(uniqueUri);
+ } else {
+ NodeRevisionDescriptors wrpathNrds =
+ content.retrieve( sToken, wrpath );
+
+ NodeRevisionDescriptor wrpathNrd =
+ content.retrieve( sToken, wrpathNrds );
+
+ NodeProperty nextWrnProp = wrpathNrd.getProperty(I_NEXT_WORKINGRESOURCE_NAME,
+ NamespaceCache.SLIDE_URI);
+ if (nextWrnProp == null) {
+ // convert to slide namespace if this property is still
+ // in DAV: namespace
+ nextWrnProp = wrpathNrd.getProperty( I_NEXT_WORKINGRESOURCE_NAME );
+ if (nextWrnProp != null) {
+ wrpathNrd.removeProperty(nextWrnProp);
+ nextWrnProp = new NodeProperty(I_NEXT_WORKINGRESOURCE_NAME,
+ nextWrnProp.getValue(),
+ NamespaceCache.SLIDE_URI);
+ nextWrnProp.setKind( NodeProperty.Kind.PROTECTED );
+ wrpathNrd.setProperty( nextWrnProp );
+ }
+ }
+
+ if( nextWrnProp == null || nextWrnProp.getValue() == null ) {
+ nextWrnProp =
+ new NodeProperty(I_NEXT_WORKINGRESOURCE_NAME,
+ I_INITIAL_WORKINGRESOURCE_NAME,
+ NamespaceCache.SLIDE_URI );
nextWrnProp.setKind( NodeProperty.Kind.PROTECTED );
wrpathNrd.setProperty( nextWrnProp );
}
- }
-
- if( nextWrnProp == null || nextWrnProp.getValue() == null ) {
- nextWrnProp =
- new NodeProperty(I_NEXT_WORKINGRESOURCE_NAME,
- I_INITIAL_WORKINGRESOURCE_NAME,
- NamespaceCache.SLIDE_URI );
- nextWrnProp.setKind( NodeProperty.Kind.PROTECTED );
+
+ String nextWrnStr = (String)nextWrnProp.getValue();
+ result = new UriHandler( wrpath+"/"+nextWrnStr );
+
+ long nextWrnLong = Long.parseLong( nextWrnStr );
+ nextWrnProp = new NodeProperty(I_NEXT_WORKINGRESOURCE_NAME,
+ String.valueOf(nextWrnLong + 1),
+ NamespaceCache.SLIDE_URI );
wrpathNrd.setProperty( nextWrnProp );
- }
-
- String nextWrnStr = (String)nextWrnProp.getValue();
- result = new UriHandler( wrpath+"/"+nextWrnStr );
-
- long nextWrnLong = Long.parseLong( nextWrnStr );
- nextWrnProp = new NodeProperty(I_NEXT_WORKINGRESOURCE_NAME,
- String.valueOf(nextWrnLong + 1),
- NamespaceCache.SLIDE_URI );
- wrpathNrd.setProperty( nextWrnProp );
-
- content.store( sToken, wrpath, wrpathNrd, null ); //revisionContent = null
-
+
+ content.store( sToken, wrpath, wrpathNrd, null ); //revisionContent = null
+ }
return result;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org