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 repo file represents the repository-defining file. It is used to 024 * describe the chunking and encryption parameters of an an initialized 025 * repository. 026 * 027 * <p><b>Name pattern:</b> The file must always be called <b>syncany</b> 028 * Initializing an instance with a different name will throw an 029 * exception. 030 * 031 * @author Philipp C. Heckel (philipp.heckel@gmail.com) 032 */ 033public class SyncanyRemoteFile extends RemoteFile { 034 private static final String NAME_FORMAT = "syncany"; 035 036 /** 037 * Initializes a new repo file with the name <b>syncany</b>. 038 * @throws StorageException Never throws an exception. 039 */ 040 public SyncanyRemoteFile() throws StorageException { 041 super(NAME_FORMAT); 042 } 043 044 /** 045 * Initializes a new repo file, given a name. This constructor might 046 * be called by the {@link RemoteFile#createRemoteFile(String, Class) createRemoteFile()} 047 * method of the {@link RemoteFile}. 048 * 049 * @param name Repo file name; <b>must</b> always be <b>syncany</b> 050 * @throws StorageException If the name is not <b>syncany</b> 051 */ 052 public SyncanyRemoteFile(String name) throws StorageException { 053 super(name); 054 } 055 056 @Override 057 protected String validateName(String name) throws StorageException { 058 if (!NAME_FORMAT.equals(name)) { 059 throw new StorageException(name + ": remote filename pattern does not match: " + NAME_FORMAT + " expected."); 060 } 061 062 return name; 063 } 064}