KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > webdav > method > MkworkspaceMethod


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/MkworkspaceMethod.java,v 1.13 2004/08/05 14:43:29 dflorey Exp $
3  * $Revision: 1.13 $
4  * $Date: 2004/08/05 14:43:29 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.slide.webdav.method;
25
26 import java.io.IOException JavaDoc;
27
28 import org.apache.slide.common.NamespaceAccessToken;
29 import org.apache.slide.common.ServiceAccessException;
30 import org.apache.slide.webdav.WebdavException;
31 import org.apache.slide.webdav.WebdavServletConfig;
32 import org.apache.slide.webdav.util.DeltavConstants;
33 import org.apache.slide.webdav.util.PreconditionViolationException;
34 import org.apache.slide.webdav.util.VersioningHelper;
35 import org.apache.slide.webdav.util.WebdavStatus;
36
37
38 /**
39  * MKWORKSPACE method.
40  *
41  */

42 public class MkworkspaceMethod extends AbstractWebdavMethod
43 implements DeltavConstants, WriteMethod {
44     
45     /**
46      * Resource to be created.
47      */

48     private String JavaDoc resourcePath;
49     
50     
51     // ----------------------------------------------------------- Constructors
52

53     
54     /**
55      * Constructor.
56      *
57      * @param token the token for accessing the namespace
58      * @param config configuration of the WebDAV servlet
59      */

60     public MkworkspaceMethod(NamespaceAccessToken token,
61                              WebdavServletConfig config) {
62         super(token, config);
63     }
64     
65     /**
66      * Parse WebDAV XML query.
67      *
68      * @exception WebdavException
69      */

70     protected void parseRequest() throws WebdavException {
71         resourcePath = requestUri;
72         if (resourcePath == null) {
73             resourcePath = "/";
74         }
75     }
76
77     /**
78      * Execute the request.
79      *
80      * @exception WebdavException
81      */

82     protected void executeRequest() throws WebdavException, IOException JavaDoc {
83         
84         // Prevent dirty reads
85
slideToken.setForceStoreEnlistment(true);
86         
87         // check lock-null resources
88
try {
89             if (isLockNull(resourcePath)) {
90                 int statusCode = WebdavStatus.SC_NOT_FOUND;
91                 sendError( statusCode, "lock-null resource", new Object JavaDoc[]{resourcePath} );
92                 throw new WebdavException( statusCode );
93             }
94         }
95         catch (ServiceAccessException e) {
96             int statusCode = getErrorCode((Exception JavaDoc)e);
97             sendError( statusCode, e );
98             throw new WebdavException( statusCode );
99         }
100
101         try {
102             VersioningHelper vh = VersioningHelper.getVersioningHelper(
103                 slideToken, token, req, resp, getConfig() );
104             vh.mkworkspace( resourcePath );
105         }
106         catch (PreconditionViolationException e) {
107             sendPreconditionViolation(e);
108             throw e;
109         }
110         catch (Exception JavaDoc e) {
111             int statusCode = getErrorCode( e );
112             sendError( statusCode, e );
113             throw new WebdavException( statusCode );
114         }
115         finally {
116             resp.setHeader(H_CACHE_CONTROL, NO_CACHE);
117         }
118     }
119     
120 }
121
122
Popular Tags