pnever 02/04/05 08:12:14
Modified: src/webdav/server/org/apache/slide/webdav/util
VersioningHelper.java
Log:
New method mkworkspace()
Revision Changes Path
1.22 +66 -3
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java
Index: VersioningHelper.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- VersioningHelper.java 5 Apr 2002 13:26:23 -0000 1.21
+++ VersioningHelper.java 5 Apr 2002 16:12:14 -0000 1.22
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
1.21 2002/04/05 13:26:23 juergen Exp $
- * $Revision: 1.21 $
- * $Date: 2002/04/05 13:26:23 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/VersioningHelper.java,v
1.22 2002/04/05 16:12:14 pnever Exp $
+ * $Revision: 1.22 $
+ * $Date: 2002/04/05 16:12:14 $
*
* ====================================================================
*
@@ -185,6 +185,9 @@
/**
* Set the specified resource under version control
+ *
+ * @param resourcePath the URI of the resource to version-control
+ * @throws SlideException
*/
public void versionControl( String resourcePath ) throws SlideException {
UriHandler rUh = UriHandler.getUriHandler( nsaToken, resourcePath );
@@ -286,6 +289,66 @@
content.store( sToken, resourcePath, rNrd, null ); //revisionContent=null
content.store( sToken, vhrUri, vhrNrd, null ); //revisionContent=null
content.store( sToken, vhrUri, vrNrd, null ); //revisionContent=null
+ }
+
+ /**
+ * Create the specified workspace.
+ *
+ * @param resourcePath the URI of the workspace to create
+ * @throws SlideException
+ */
+ public void mkworkspace( String resourcePath ) throws SlideException {
+ Iterator i;
+
+ UriHandler rUh = UriHandler.getUriHandler( nsaToken, resourcePath );
+ NodeRevisionDescriptor rNrd = null;
+ try {
+ NodeRevisionDescriptors rNrds = retrieveRevisionDescriptors(
resourcePath );
+ rNrd = retrieveLatestRevisionDescriptor( resourcePath, rNrds );
+ }
+ catch( ObjectNotFoundException e ) {}; // can be ignored here!
+
+ ResourceKind rRk = AbstractResourceKind.determineResourceKind( rNrd );
+
+ if( !(rRk instanceof DeltavCompliantUnmappedUrl) ) {
+ throw new PreconditionViolationException(
+ new ViolatedPrecondition(
+ C_RESOURCE_MUST_BE_NULL, WebdavStatus.SC_CONFLICT),
resourcePath);
+ }
+ if( !rUh.isWorkspaceUri() ) {
+ throw new PreconditionViolationException(
+ new ViolatedPrecondition(
+ C_WORKSPACE_LOCATION_OK, WebdavStatus.SC_CONFLICT),
resourcePath);
+ }
+ if( !rRk.isSupportedMethod(req.getMethod()) ) {
+ resp.setStatus( WebdavStatus.SC_BAD_REQUEST );
+ throw new WebdavException( WebdavStatus.SC_BAD_REQUEST );
+ }
+
+ // Set initial ws properties
+ String wsUri = String.valueOf(rUh);
+ NodeRevisionDescriptor wsNrd =
+ new NodeRevisionDescriptor(0);
+ i = pHelp.createInitialProperties(WorkspaceImpl.getInstance()).iterator();
+ while( i.hasNext() )
+ wsNrd.setProperty( (NodeProperty)i.next() );
+
+ // Set specific properties
+ wsNrd.setProperty(
+ new NodeProperty(P_WORKSPACE, pHelp.createHrefValue(wsUri)) );
+ wsNrd.setETag( wsUri.hashCode()+"_" ); // P_GETETAG
+ wsNrd.setLastModified( new Date() ); //P_GETLASTMODIFIED
+ wsNrd.setContentLength( 0 ); // P_GETCONTENTLENGTH
+ wsNrd.setName( rUh.getWorkspaceName() ); // P_DISPLAYNAME
+ wsNrd.setCreationDate( new Date() ); // P_CREATIONDATE
+
+ // Create the ws resource
+ SubjectNode wsNode = new SubjectNode();
+ structure.create( sToken, wsNode, wsUri );
+ content.create( sToken, wsUri, wsNrd, null ); // revisionContent = null
+
+ // Set status created
+ resp.setStatus( WebdavStatus.SC_CREATED );
}
/**
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>