mirror of https://github.com/tasks/tasks
Remove CreateRequest
parent
1aa54a40a7
commit
96907fea3d
@ -1,37 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2012 Todoroo Inc
|
||||
*
|
||||
* See the file "LICENSE" for the full license governing this code.
|
||||
*/
|
||||
package com.todoroo.astrid.gtasks.api;
|
||||
|
||||
import com.google.api.services.tasks.model.Task;
|
||||
|
||||
import java.io.IOException;
|
||||
/**
|
||||
* Encapsulates a request to the api to create a task on the remote server
|
||||
* @author Sam Bosley
|
||||
*
|
||||
*/
|
||||
public class CreateRequest extends PushRequest {
|
||||
|
||||
private String parent;
|
||||
private String priorSiblingId;
|
||||
|
||||
public CreateRequest(GtasksInvoker service, String listId, Task toUpdate, String parent, String priorSiblingId) {
|
||||
super(service, listId, toUpdate);
|
||||
this.parent = parent;
|
||||
this.priorSiblingId = priorSiblingId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task executePush() throws IOException {
|
||||
return service.createGtask(listId, toPush, parent, priorSiblingId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void recover() {
|
||||
parent = null;
|
||||
priorSiblingId = null;
|
||||
}
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2012 Todoroo Inc
|
||||
*
|
||||
* See the file "LICENSE" for the full license governing this code.
|
||||
*/
|
||||
package com.todoroo.astrid.gtasks.api;
|
||||
|
||||
import com.google.api.services.tasks.model.Task;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Abstract class that encapsulates some push request to the server
|
||||
* @author Sam Bosley
|
||||
*
|
||||
*/
|
||||
public abstract class PushRequest {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(PushRequest.class);
|
||||
|
||||
protected String listId;
|
||||
protected Task toPush;
|
||||
protected GtasksInvoker service;
|
||||
|
||||
public PushRequest(GtasksInvoker service, String listId, Task toPush) {
|
||||
this.service = service;
|
||||
this.listId = listId;
|
||||
this.toPush = toPush;
|
||||
}
|
||||
|
||||
public Task push() throws IOException {
|
||||
try {
|
||||
return executePush();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
recover();
|
||||
return executePush();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract Task executePush() throws IOException;
|
||||
|
||||
protected abstract void recover();
|
||||
}
|
||||
Loading…
Reference in New Issue