001/* 002 * Syncany, www.syncany.org 003 * Copyright (C) 2011-2016 Philipp C. Heckel <philipp.heckel@gmail.com> 004 * 005 * This program is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU General Public License as published by 007 * the Free Software Foundation, either version 3 of the License, or 008 * (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU General Public License for more details. 014 * 015 * You should have received a copy of the GNU General Public License 016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 017 */ 018package org.syncany.plugins.transfer; 019 020import org.simpleframework.xml.Element; 021 022/** 023 * Represents the return structure of the tests performed by by {@link TransferManager#test(boolean)} 024 * method. 025 * 026 * <p>The result is determined by the following methods: 027 * 028 * <ul> 029 * <li>{@link TransferManager#testTargetExists()}: Tests whether the target exists.</li> 030 * <li>{@link TransferManager#testTargetCanWrite()}: Tests whether the target is writable.</li> 031 * <li>{@link TransferManager#testTargetCanCreate()}: Tests whether the target can be created if it does not 032 * exist already. This is only called if <code>testCreateTarget</code> is set.</li> 033 * <li>{@link TransferManager#testRepoFileExists()}: Tests whether the repo file exists.</li> 034 * </ul> 035 * 036 * @see TransferManager#test(boolean) 037 * @author Philipp Heckel (philipp.heckel@gmail.com) 038 */ 039public class StorageTestResult { 040 @Element(name = "targetExists", required = true) 041 private boolean targetExists; 042 043 @Element(name = "targetCanConnect", required = true) 044 private boolean targetCanConnect; 045 046 @Element(name = "targetCanCreate", required = true) 047 private boolean targetCanCreate; 048 049 @Element(name = "targetCanWrite", required = true) 050 private boolean targetCanWrite; 051 052 @Element(name = "repoFileExists", required = true) 053 private boolean repoFileExists; 054 055 @Element(name = "errorMessage", required = false) 056 private String errorMessage; 057 058 // Note: This should be an "Exception" instead of only an error message, but 059 // due to a SimpleXML bug we use this workaround. See https://sourceforge.net/p/simple/bugs/38/ 060 061 public boolean isTargetExists() { 062 return targetExists; 063 } 064 065 public void setTargetExists(boolean targetExists) { 066 this.targetExists = targetExists; 067 } 068 069 public boolean isTargetCanConnect() { 070 return targetCanConnect; 071 } 072 073 public void setTargetCanConnect(boolean targetCanConnect) { 074 this.targetCanConnect = targetCanConnect; 075 } 076 077 public boolean isTargetCanCreate() { 078 return targetCanCreate; 079 } 080 081 public void setTargetCanCreate(boolean targetCanCreate) { 082 this.targetCanCreate = targetCanCreate; 083 } 084 085 public boolean isTargetCanWrite() { 086 return targetCanWrite; 087 } 088 089 public void setTargetCanWrite(boolean targetCanWrite) { 090 this.targetCanWrite = targetCanWrite; 091 } 092 093 public boolean isRepoFileExists() { 094 return repoFileExists; 095 } 096 097 public void setRepoFileExists(boolean repoFileExists) { 098 this.repoFileExists = repoFileExists; 099 } 100 101 public String getErrorMessage() { 102 return errorMessage; 103 } 104 105 public void setErrorMessage(String errorMessage) { 106 this.errorMessage = errorMessage; 107 } 108 109 @Override 110 public String toString() { 111 return "StorageTestResult [targetExists=" + targetExists + ", targetCanConnect=" + targetCanConnect + ", targetCanCreate=" + targetCanCreate 112 + ", targetCanWrite=" + targetCanWrite + ", repoFileExists=" + repoFileExists + "]"; 113 } 114}