KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/DefaultMethodFactory.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 org.apache.slide.common.NamespaceAccessToken;
27 import org.apache.slide.util.Configuration;
28 import org.apache.slide.webdav.WebdavMethod;
29 import org.apache.slide.webdav.WebdavMethodFactory;
30 import org.apache.slide.webdav.WebdavServlet;
31 import org.apache.slide.webdav.WebdavServletConfig;
32
33 /**
34  * The default factory for WebDAVMethod implementations.
35  *
36  */

37 public class DefaultMethodFactory
38     extends WebdavMethodFactory {
39     
40     
41     // ----------------------------------------------------- Instance Variables
42

43     
44     /**
45      * Configuration of the WebDAV servlet.
46      */

47     private WebdavServletConfig config;
48     
49     
50     /**
51      * The token for accessing the namespace.
52      */

53     private NamespaceAccessToken token;
54     
55     
56     // ------------------------------------- WebdavMethodFactory Implementation
57

58     
59     // inherit javadocs
60
public WebdavMethod createMethod(String JavaDoc name) {
61         
62         if ((config == null) || (token == null)) {
63             throw new IllegalStateException JavaDoc();
64         }
65         
66         if (name.equals("GET")) {
67             return new GetMethod(token, config);
68         } else if (name.equals("PROPFIND")) {
69             return new PropFindMethod(token, config);
70         } else if (name.equals("HEAD")) {
71             return new HeadMethod(token, config);
72         } else if (name.equals("LOCK")) {
73             return new LockMethod(token, config);
74         } else if (name.equals("UNLOCK")) {
75             return new UnlockMethod(token, config);
76         } else if (name.equals("OPTIONS")) {
77             return new OptionsMethod(token, config);
78         } else if (name.equals("PUT")) {
79             return new PutMethod(token, config);
80         } else if (name.equals("MKCOL")) {
81             return new MkcolMethod(token, config);
82         } else if (name.equals("POST")) {
83             return new PostMethod(token, config);
84         } else if (name.equals("COPY")) {
85             return new CopyMethod(token, config);
86         } else if (name.equals("MOVE")) {
87             return new MoveMethod(token, config);
88         } else if (name.equals("DELETE")) {
89             return new DeleteMethod(token, config);
90         } else if (name.equals("PROPPATCH")) {
91             return new PropPatchMethod(token, config);
92         } else if (name.equals("REPORT")) {
93             return new ReportMethod(token, config);
94         } else if (name.equals("SUBSCRIBE")) {
95             return new SubscribeMethod(token, config);
96         } else if (name.equals("UNSUBSCRIBE")) {
97             return new UnsubscribeMethod(token, config);
98         } else if (name.equals("POLL")) {
99             return new PollMethod(token, config);
100         } else if (name.equals("EVENT")) {
101             return new EventMethod(token, config);
102         } else {
103             if (Configuration.useIntegratedSecurity()) {
104                 if (name.equals("ACL")) {
105                     return new AclMethod(token, config);
106                 }
107             }
108             if (Configuration.useSearch()) {
109                 if (name.equals("SEARCH")) {
110                     return new SearchMethod(token, config);
111                 }
112             }
113             if (Configuration.useVersionControl()) {
114                 if (name.equals("VERSION-CONTROL")) {
115                     return new VersionControlMethod(token, config);
116                 } else if (name.equals("CHECKIN")) {
117                     return new CheckinMethod(token, config);
118                 } else if (name.equals("CHECKOUT")) {
119                     return new CheckoutMethod(token, config);
120                 } else if (name.equals("UNCHECKOUT")) {
121                     return new UncheckoutMethod(token, config);
122                 } else if (name.equals("MKWORKSPACE")) {
123                     return new MkworkspaceMethod(token, config);
124                 } else if (name.equals("LABEL")) {
125                     return new LabelMethod(token, config);
126                 } else if (name.equals("UPDATE")) {
127                     return new UpdateMethod(token, config);
128                 }
129             }
130             if (Configuration.useGlobalBinding()) {
131                 if (name.equals("BIND")) {
132                     return new BindMethod(token, config);
133                 } else if (name.equals("UNBIND")) {
134                     return new UnbindMethod(token, config);
135                 } else if (name.equals("REBIND")) {
136                     return new RebindMethod(token, config);
137                 }
138             }
139         }
140         
141         return null;
142     }
143     
144     /**
145      * Returns the value of a boolean init parameter of the servlet.
146      * Default value: true.
147      */

148     protected boolean getBooleanInitParameter( String JavaDoc name ) {
149         return !"false".equalsIgnoreCase( config.getInitParameter(name) );
150     }
151     
152     
153     // inherit javadocs
154
protected void setConfig(WebdavServletConfig config) {
155         
156         this.config = config;
157         token = (NamespaceAccessToken)config.getServletContext().getAttribute
158             (WebdavServlet.ATTRIBUTE_NAME);
159     }
160     
161 }
162
163
Popular Tags