001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.vfs2.provider.webdav; 018 019import org.apache.commons.vfs2.FileSystem; 020import org.apache.commons.vfs2.FileSystemOptions; 021import org.apache.commons.vfs2.provider.http.HttpFileSystemConfigBuilder; 022 023/** 024 * Configuration options for WebDav. 025 * 026 * @since 2.0 027 */ 028public final class WebdavFileSystemConfigBuilder extends HttpFileSystemConfigBuilder { 029 030 private static final WebdavFileSystemConfigBuilder BUILDER = new WebdavFileSystemConfigBuilder(); 031 032 private static final boolean DEFAULT_FOLLOW_REDIRECT = false; 033 034 /** 035 * Gets the singleton builder. 036 * 037 * @return the singleton builder. 038 */ 039 public static HttpFileSystemConfigBuilder getInstance() { 040 return BUILDER; 041 } 042 043 private WebdavFileSystemConfigBuilder() { 044 super("webdav."); 045 } 046 047 /** 048 * @return The WebDAV FileSystem Class object. 049 */ 050 @Override 051 protected Class<? extends FileSystem> getConfigClass() { 052 return WebdavFileSystem.class; 053 } 054 055 /** 056 * Gets the user name to be associated with changes to the file. 057 * 058 * @param opts The FileSystem options 059 * @return The creatorName. 060 */ 061 public String getCreatorName(final FileSystemOptions opts) { 062 return getString(opts, "creatorName"); 063 } 064 065 /** 066 * Gets whether to follow redirects for the connection. 067 * 068 * @param opts The FileSystem options. 069 * @return {@code true} to follow redirects, {@code false} not to. 070 * @see #setFollowRedirect 071 * @since 2.1 072 */ 073 @Override 074 public boolean getFollowRedirect(final FileSystemOptions opts) { 075 return getBoolean(opts, KEY_FOLLOW_REDIRECT, DEFAULT_FOLLOW_REDIRECT); 076 } 077 078 /** 079 * The cookies to add to the request. 080 * 081 * @param opts The FileSystem options. 082 * @return true if versioning is enabled. 083 */ 084 public boolean isVersioning(final FileSystemOptions opts) { 085 return getBoolean(opts, "versioning", false); 086 } 087 088 /** 089 * The user name to be associated with changes to the file. 090 * 091 * @param opts The FileSystem options 092 * @param creatorName The creator name to be associated with the file. 093 */ 094 public void setCreatorName(final FileSystemOptions opts, final String creatorName) { 095 setParam(opts, "creatorName", creatorName); 096 } 097 098 /** 099 * 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}