This repository has been archived by the owner on Jul 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring TransactionTO for better generalization
- Loading branch information
Showing
4 changed files
with
155 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
syncany-lib/src/main/java/org/syncany/plugins/transfer/to/TransactionActionTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Syncany, www.syncany.org | ||
* Copyright (C) 2011-2014 Philipp C. Heckel <philipp.heckel@gmail.com> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.syncany.plugins.transfer.to; | ||
|
||
import java.io.File; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import org.simpleframework.xml.Element; | ||
import org.simpleframework.xml.Namespace; | ||
import org.simpleframework.xml.Root; | ||
import org.syncany.plugins.StorageException; | ||
import org.syncany.plugins.transfer.files.RemoteFile; | ||
import org.syncany.plugins.transfer.files.TempRemoteFile; | ||
|
||
/** | ||
* A TransactionActionTO describes a single action on a file, which is to be bundled | ||
* with other actions to describe a full Transaction. | ||
* @author Pim Otte | ||
*/ | ||
|
||
@Root(name="transactionAction") | ||
@Namespace(reference="http://syncany.org/transaction/action/1") | ||
public class TransactionActionTO { | ||
private static final Logger logger = Logger.getLogger(TransactionActionTO.class.getSimpleName()); | ||
|
||
public static final String TYPE_UPLOAD = "UPLOAD"; | ||
public static final String TYPE_DELETE = "DELETE"; | ||
|
||
@Element(name="type", required=true) | ||
private String type; | ||
|
||
@Element(name="remoteLocation", required=true) | ||
private String remoteLocation; | ||
|
||
@Element(name="remoteTempLocation", required=true) | ||
private String remoteTempLocation; | ||
|
||
@Element(name="localTempLocation", required=false) | ||
private String localTempLocation; | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
public void setRemoteLocation(RemoteFile remoteFile) { | ||
remoteLocation = remoteFile.getName(); | ||
} | ||
|
||
public RemoteFile getRemoteFile() { | ||
try { | ||
return RemoteFile.createRemoteFile(remoteLocation); | ||
} | ||
catch (StorageException e) { | ||
logger.log(Level.INFO, "Invalid remote temporary filename: " + remoteLocation); | ||
return null; | ||
} | ||
} | ||
|
||
public void setRemoteTempLocation(TempRemoteFile tempRemoteFile) { | ||
remoteTempLocation = tempRemoteFile.getName(); | ||
} | ||
|
||
public TempRemoteFile getTempRemoteFile() { | ||
try { | ||
return RemoteFile.createRemoteFile(remoteTempLocation, TempRemoteFile.class); | ||
} | ||
catch (StorageException e) { | ||
logger.log(Level.INFO, "Invalid remote temporary filename: " + remoteTempLocation); | ||
return null; | ||
} | ||
} | ||
|
||
public void setLocalTempLocation(File file) { | ||
localTempLocation = file.getAbsolutePath(); | ||
} | ||
|
||
public File getLocalTempLocation() { | ||
return new File(localTempLocation); | ||
} | ||
|
||
public void execute() { | ||
if (TYPE_UPLOAD.equals(getType())) { | ||
|
||
} | ||
else if (TYPE_DELETE.equals(getType())) { | ||
throw new RuntimeException("NOT IMPLEMENTED YET"); | ||
} | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters