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 WebdavFileSystemConfigBuilder BUILDER = new WebdavFileSystemConfigBuilder();
31  
32      private static final boolean DEFAULT_FOLLOW_REDIRECT = false;
33  
34      private WebdavFileSystemConfigBuilder()
35      {
36          super("webdav.");
37      }
38  
39      /**
40       * Gets the singleton builder.
41       *
42       * @return the singleton builder.
43       */
44      public static HttpFileSystemConfigBuilder getInstance()
45      {
46          return BUILDER;
47      }
48  
49      /**
50       * The user name to be associated with changes to the file.
51       * @param opts The FileSystem options
52       * @param creatorName The creator name to be associated with the file.
53       */
54      public void setCreatorName(final FileSystemOptions opts, final String creatorName)
55      {
56          setParam(opts, "creatorName", creatorName);
57      }
58  
59      /**
60       * Return the user name to be associated with changes to the file.
61       * @param opts The FileSystem options
62       * @return The creatorName.
63       */
64      public String getCreatorName(final FileSystemOptions opts)
65      {
66          return getString(opts, "creatorName");
67      }
68  
69      /**
70       * Gets whether to follow redirects for the connection.
71       *
72       * @param opts
73       *            The FileSystem options.
74       * @return {@code true} to follow redirects, {@code false} not to.
75       * @see #setFollowRedirect
76       * @since 2.1
77       */
78      @Override
79      public boolean getFollowRedirect(final FileSystemOptions opts)
80      {
81          return getBoolean(opts, KEY_FOLLOW_REDIRECT, DEFAULT_FOLLOW_REDIRECT);
82      }
83  
84      /**
85       * Whether to use versioning.
86       * @param opts The FileSystem options.
87       * @param versioning true if versioning should be enabled.
88       */
89      public void setVersioning(final FileSystemOptions opts, final boolean versioning)
90      {
91          setParam(opts, "versioning", Boolean.valueOf(versioning));
92      }
93  
94      /**
95       * The cookies to add to the request.
96       * @param opts The FileSystem options.
97       * @return true if versioning is enabled.
98       */
99      public boolean isVersioning(final FileSystemOptions opts)
100     {
101         return getBoolean(opts, "versioning", false);
102     }
103 
104     /**
105      * @return The Webdav FileSystem Class object.
106      */
107     @Override
108     protected Class<? extends FileSystem> getConfigClass()
109     {
110         return WebdavFileSystem.class;
111     }
112 }