01: /*
02: * Copyright 2005 Hippo Webworks.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package nl.hippo.slide.webdav;
17:
18: import nl.hippo.slide.webdav.method.FacetsMethod;
19: import nl.hippo.slide.webdav.method.ReplaceMethod;
20: import nl.hippo.slide.webdav.method.SearchNoACLMethod;
21:
22: import org.apache.slide.common.NamespaceAccessToken;
23: import org.apache.slide.webdav.WebdavMethod;
24: import org.apache.slide.webdav.WebdavServlet;
25: import org.apache.slide.webdav.WebdavServletConfig;
26: import org.apache.slide.webdav.method.DefaultMethodFactory;
27:
28: /**
29: * @author mpfingsthorn
30: *
31: */
32: public class WebdavMethodFactory extends DefaultMethodFactory {
33:
34: /**
35: * Configuration of the WebDAV servlet.
36: */
37: private WebdavServletConfig config;
38:
39: /**
40: * The token for accessing the namespace.
41: */
42: private NamespaceAccessToken token;
43:
44: public WebdavMethod createMethod(String name) {
45:
46: if (name.equals("REPLACE")) {
47: return new ReplaceMethod(token, config);
48: }
49:
50: if (name.equals("FACETS")) {
51: return new FacetsMethod(token, config);
52: }
53:
54: if (name.equals("SEARCH-NOACL")) {
55: return new SearchNoACLMethod(token, config);
56: }
57: return super .createMethod(name);
58: }
59:
60: protected void setConfig(WebdavServletConfig config) {
61: super .setConfig(config);
62:
63: this .config = config;
64: token = (NamespaceAccessToken) config.getServletContext()
65: .getAttribute(WebdavServlet.ATTRIBUTE_NAME);
66: }
67: }
|