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.operations; 019 020import org.syncany.config.Config; 021 022/** 023 * Operations represent and implement Syncany's business logic. They typically 024 * correspond to a command or an action initiated by either a user, or by a 025 * periodic action. 026 * 027 * <p>Each operation might be configured using an operation-specific implementation of 028 * the {@link OperationOptions} interface and is run using the {@link #execute()} method. 029 * While the input options are optional, it must return a corresponding {@link OperationResult} 030 * object. 031 * 032 * @see OperationOptions 033 * @see OperationResult 034 * @author Philipp C. Heckel (philipp.heckel@gmail.com) 035 */ 036public abstract class Operation { 037 protected Config config; 038 039 public Operation(Config config) { 040 this.config = config; 041 } 042 043 /** 044 * Executes the operation synchronously and returns a result when 045 * the operation exits. Using covariance is recommend, that is OperationFoo should 046 * override execute so as to return a OperationFooResult rather than OperationResult. 047 * 048 * @return Returns an operation-specific operation result 049 * @throws Exception If the operation fails 050 */ 051 public abstract OperationResult execute() throws Exception; 052}