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.webdav4;
18  
19  import org.apache.commons.vfs2.FileSystem;
20  import org.apache.commons.vfs2.FileSystemOptions;
21  import org.apache.commons.vfs2.provider.http4.Http4FileSystemConfigBuilder;
22  
23  /**
24   * Configuration options for WebDav based on HTTP4.
25   *
26   * @since 2.5.0
27   */
28  public final class Webdav4FileSystemConfigBuilder extends Http4FileSystemConfigBuilder {
29  
30      private static final Webdav4FileSystemConfigBuilder4FileSystemConfigBuilder.html#Webdav4FileSystemConfigBuilder">Webdav4FileSystemConfigBuilder BUILDER = new Webdav4FileSystemConfigBuilder();
31  
32      private static final boolean DEFAULT_FOLLOW_REDIRECT = false;
33  
34      private Webdav4FileSystemConfigBuilder() {
35          super("webdav4.");
36      }
37  
38      /**
39       * Gets the singleton builder.
40       *
41       * @return the singleton builder.
42       */
43      public static Webdav4FileSystemConfigBuilder 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       */
74      @Override
75      public boolean getFollowRedirect(final FileSystemOptions opts) {
76          return getBoolean(opts, KEY_FOLLOW_REDIRECT, DEFAULT_FOLLOW_REDIRECT);
77      }
78  
79      /**
80       * Whether to use versioning.
81       *
82       * @param opts The FileSystem options.
83       * @param versioning true if versioning should be enabled.
84       */
85      public void setVersioning(final FileSystemOptions opts, final boolean versioning) {
86          setParam(opts, "versioning", Boolean.valueOf(versioning));
87      }
88  
89      /**
90       * The cookies to add to the request.
91       *
92       * @param opts The FileSystem options.
93       * @return true if versioning is enabled.
94       */
95      public boolean isVersioning(final FileSystemOptions opts) {
96          return getBoolean(opts, "versioning", false);
97      }
98  
99      /**
100      * @return The Webdav FileSystem Class object.
101      */
102     @Override
103     protected Class<? extends FileSystem> getConfigClass() {
104         return Webdav4FileSystem.class;
105     }
106 }