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