Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /* ************************************************************************
 #
 #  DivConq
 #
 #  http://divconq.com/
 #
 #  Copyright:
 #    Copyright 2014 eTimeline, LLC. All rights reserved.
 #
#  License:
#    See the license.txt file in the project's top-level directory for details.
#  Authors:
#    * Andy White
************************************************************************ */
package divconq.api.tasks;
public class TaskFactory {
	static public Task createUploadTask(ApiSession sessString servicenamePath localCommonPath remoteStruct storeParamsboolean allowResume) {
		UploadFile work = new UploadFile();
		work.session = sess;
		return new Task()
			.withTitle("Upload file " + local)
			.withWork(work)
					new FieldStruct("LocalPath"local),
					new FieldStruct("RemotePath"remote),
					new FieldStruct("ServiceName"servicename),
					new FieldStruct("TransferParams"storeParams),
					new FieldStruct("ForceOverwrite", !allowResume)
			))
	}
	static public Task createDownloadTask(ApiSession sessString servicenamePath localCommonPath remoteStruct storeParamsboolean allowResume) {
		DownloadFile work = new DownloadFile();
		work.session = sess;
		RecordStruct params = new RecordStruct(
				new FieldStruct("LocalPath"local),
				new FieldStruct("RemotePath"remote),
				new FieldStruct("ServiceName"servicename),
				new FieldStruct("TransferParams"storeParams)
		);
		if (allowResume && Files.exists(local)) {
			try {
				params.setField("Offset", Files.size(local));
			catch (IOException x) {
				Logger.error("Unable to get file size for: " + local);
				return null;
			}
		}		
		return new Task()
			.withTitle("Download file " + local)
			.withWork(work)
			.withParams(params)
	}
New to GrepCode? Check out our FAQ X