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.files; 019 020import org.syncany.plugins.transfer.StorageException; 021 022/** 023 * The master file represents the file that stores the salt for the master 024 * key. The file is only mandatory if the repository is encrypted. 025 * 026 * <p><b>Name pattern:</b> The file must always be called <b>master</b> 027 * Initializing an instance with a different name will throw an 028 * exception. 029 * 030 * @author Philipp C. Heckel (philipp.heckel@gmail.com) 031 */ 032public class MasterRemoteFile extends RemoteFile { 033 private static final String NAME_FORMAT = "master"; 034 035 /** 036 * Initializes a new master file with the name <b>master</b>. 037 * @throws StorageException Never throws an exception. 038 */ 039 public MasterRemoteFile() throws StorageException { 040 super(NAME_FORMAT); 041 } 042 043 /** 044 * Initializes a new master file, given a name. This constructor might 045 * be called by the {@link RemoteFile#createRemoteFile(String, Class) createRemoteFile()} 046 * method of the {@link RemoteFile}. 047 * 048 * @param name Master file name; <b>must</b> always be <b>master</b> 049 * @throws StorageException If the name is not <b>master</b> 050 */ 051 public MasterRemoteFile(String name) throws StorageException { 052 super(name); 053 } 054 055 @Override 056 protected String validateName(String name) throws StorageException { 057 if (!NAME_FORMAT.equals(name)) { 058 throw new StorageException(name + ": remote filename pattern does not match: " + NAME_FORMAT + " expected."); 059 } 060 061 return name; 062 } 063}