1 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 37 public class DefaultMethodFactory 38 extends WebdavMethodFactory { 39 40 41 43 44 47 private WebdavServletConfig config; 48 49 50 53 private NamespaceAccessToken token; 54 55 56 58 59 public WebdavMethod createMethod(String name) { 61 62 if ((config == null) || (token == null)) { 63 throw new IllegalStateException (); 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 148 protected boolean getBooleanInitParameter( String name ) { 149 return !"false".equalsIgnoreCase( config.getInitParameter(name) ); 150 } 151 152 153 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 |