View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.vfs2.provider.webdav;
18  
19  import org.apache.commons.vfs2.FileSystem;
20  import org.apache.commons.vfs2.FileSystemOptions;
21  import org.apache.commons.vfs2.provider.http.HttpFileSystemConfigBuilder;
22  
23  /**
24   * Configuration options for WebDav.
25   *
26   * @since 2.0
27   */
28  public final class WebdavFileSystemConfigBuilder extends HttpFileSystemConfigBuilder {
29  
30      private static final WebdavFileSystemConfigBuilderFileSystemConfigBuilder.html#WebdavFileSystemConfigBuilder">WebdavFileSystemConfigBuilder BUILDER = new WebdavFileSystemConfigBuilder();
31  
32      private static final boolean DEFAULT_FOLLOW_REDIRECT = false;
33  
34      private WebdavFileSystemConfigBuilder() {
35          super("webdav.");
36      }
37  
38      /**
39       * Gets the singleton builder.
40       *
41       * @return the singleton builder.
42       */
43      public static HttpFileSystemConfigBuilder getInstance() {
44          return BUILDER;
45      }
46  
47      /**
48       * The user name to be associated with changes to the file.
49       *
50       * @param opts The FileSystem options
51       * @param creatorName The creator name to be associated with the file.
52       */
53      public void setCreatorName(final FileSystemOptions opts, final String creatorName) {
54          setParam(opts, "creatorName", creatorName);
55      }
56  
57      /**
58       * Return the user name to be associated with changes to the file.
59       *
60       * @param opts The FileSystem options
61       * @return The creatorName.
62       */
63      public String getCreatorName(final FileSystemOptions opts) {
64          return getString(opts, "creatorName");
65      }
66  
67      /**
68       * Gets whether to follow redirects for the connection.
69       *
70       * @param opts The FileSystem options.
71       * @return {@code true} to follow redirects, {@code false} not to.
72       * @see #setFollowRedirect
73       * @since 2.1
74       */
75      @Override
76      public boolean getFollowRedirect(final FileSystemOptions opts) {
77          return getBoolean(opts, KEY_FOLLOW_REDIRECT, DEFAULT_FOLLOW_REDIRECT);
78      }
79  
80      /**
81       * Whether to use versioning.
82       *
83       * @param opts The FileSystem options.
84       * @param versioning true if versioning should be enabled.
85       */
86      public void setVersioning(final FileSystemOptions opts, final boolean versioning) {
87          setParam(opts, "versioning", Boolean.valueOf(versioning));
88      }
89  
90      /**
91       * The cookies to add to the request.
92       *
93       * @param opts The FileSystem options.
94       * @return true if versioning is enabled.
95       */
96      public boolean isVersioning(final FileSystemOptions opts) {
97          return getBoolean(opts, "versioning", false);
98      }
99  
100     /**
101      * @return The Webdav FileSystem Class object.
102      */
103     @Override
104     protected Class<? extends FileSystem> getConfigClass() {
105         return WebdavFileSystem.class;
106     }
107 }