优化大量代码

pull/330/head
laoyuyu 7 years ago
parent c6d548ec48
commit 554b5bf63e
  1. 2
      Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java
  2. 9
      Aria/src/main/java/com/arialyy/aria/core/FtpUrlEntity.java
  3. 2
      Aria/src/main/java/com/arialyy/aria/core/command/normal/CancelCmd.java
  4. 4
      Aria/src/main/java/com/arialyy/aria/core/command/normal/ResumeAllCmd.java
  5. 4
      Aria/src/main/java/com/arialyy/aria/core/command/normal/StartCmd.java
  6. 14
      Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java
  7. 16
      Aria/src/main/java/com/arialyy/aria/core/common/AbsFtpInfoThread.java
  8. 8
      Aria/src/main/java/com/arialyy/aria/core/common/AbsFtpThreadTask.java
  9. 10
      Aria/src/main/java/com/arialyy/aria/core/delegate/FtpDelegate.java
  10. 24
      Aria/src/main/java/com/arialyy/aria/core/delegate/HttpHeaderDelegate.java
  11. 2
      Aria/src/main/java/com/arialyy/aria/core/download/BaseDListener.java
  12. 2
      Aria/src/main/java/com/arialyy/aria/core/download/BaseGroupTarget.java
  13. 8
      Aria/src/main/java/com/arialyy/aria/core/download/BaseNormalTarget.java
  14. 3
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupEntity.java
  15. 2
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java
  16. 2
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTask.java
  17. 1
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java
  18. 2
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java
  19. 54
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadTaskEntity.java
  20. 10
      Aria/src/main/java/com/arialyy/aria/core/download/FtpDirDownloadTarget.java
  21. 6
      Aria/src/main/java/com/arialyy/aria/core/download/FtpDownloadTarget.java
  22. 10
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/AbsGroupUtil.java
  23. 8
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/ConnectionHelp.java
  24. 8
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/Downloader.java
  25. 20
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpDirInfoThread.java
  26. 4
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpFileInfoThread.java
  27. 2
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpThreadTask.java
  28. 27
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java
  29. 2
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpThreadTask.java
  30. 6
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/SimpleDownloadUtil.java
  31. 4
      Aria/src/main/java/com/arialyy/aria/core/download/wrapper/DGTEWrapper.java
  32. 2
      Aria/src/main/java/com/arialyy/aria/core/download/wrapper/DTEWrapper.java
  33. 2
      Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java
  34. 135
      Aria/src/main/java/com/arialyy/aria/core/inf/AbsTaskEntity.java
  35. 4
      Aria/src/main/java/com/arialyy/aria/core/inf/IEntity.java
  36. 12
      Aria/src/main/java/com/arialyy/aria/core/manager/DGTEFactory.java
  37. 10
      Aria/src/main/java/com/arialyy/aria/core/manager/DTEFactory.java
  38. 10
      Aria/src/main/java/com/arialyy/aria/core/manager/UTEFactory.java
  39. 2
      Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java
  40. 2
      Aria/src/main/java/com/arialyy/aria/core/queue/UploadTaskQueue.java
  41. 2
      Aria/src/main/java/com/arialyy/aria/core/upload/BaseNormalTarget.java
  42. 2
      Aria/src/main/java/com/arialyy/aria/core/upload/BaseUListener.java
  43. 12
      Aria/src/main/java/com/arialyy/aria/core/upload/FtpUploadTarget.java
  44. 23
      Aria/src/main/java/com/arialyy/aria/core/upload/UploadReceiver.java
  45. 10
      Aria/src/main/java/com/arialyy/aria/core/upload/UploadTarget.java
  46. 5
      Aria/src/main/java/com/arialyy/aria/core/upload/uploader/FtpFileInfoThread.java
  47. 4
      Aria/src/main/java/com/arialyy/aria/core/upload/uploader/FtpThreadTask.java
  48. 20
      Aria/src/main/java/com/arialyy/aria/core/upload/uploader/HttpThreadTask.java
  49. 2
      Aria/src/main/java/com/arialyy/aria/core/upload/uploader/SimpleUploadUtil.java
  50. 4
      Aria/src/main/java/com/arialyy/aria/core/upload/uploader/Uploader.java
  51. 2
      Aria/src/main/java/com/arialyy/aria/core/upload/wrapper/UTEWrapper.java
  52. 5
      Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java
  53. 43
      Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java
  54. 4
      Aria/src/main/java/com/arialyy/aria/util/ALog.java
  55. 1
      Aria/src/main/java/com/arialyy/aria/util/AriaCrashHandler.java
  56. 11
      Aria/src/main/java/com/arialyy/aria/util/ErrorHelp.java
  57. 4
      app/build.gradle
  58. 4
      app/src/main/AndroidManifest.xml
  59. 2
      app/src/main/java/com/arialyy/simple/download/group/DownloadGroupActivity.java
  60. 2
      app/src/main/java/com/arialyy/simple/test/AnyRunActivity.java
  61. 20
      app/src/main/java/com/arialyy/simple/test/AnyRunnModule.java
  62. 1
      app/src/main/java/com/arialyy/simple/test/TestActivity.java
  63. 32
      aria/src/main/java/com/arialyy/aria/core/Configuration.java
  64. 62
      aria/src/main/java/com/arialyy/aria/core/upload/UploadTaskEntity.java

@ -129,9 +129,9 @@ class ConfigHelper extends DefaultHandler {
private void loadUseAriaCrashHandler(String value) {
if (checkBoolean(value)) {
ALog.w(TAG, "useAriaCrashHandler【" + value + "】错误");
mAppConfig.useAriaCrashHandler = Boolean.parseBoolean(value);
} else {
ALog.w(TAG, "useAriaCrashHandler【" + value + "】错误");
mAppConfig.useAriaCrashHandler = true;
}
}

@ -24,7 +24,10 @@ import java.net.InetAddress;
* ftp url 信息链接实体
*/
public class FtpUrlEntity implements Cloneable {
/**
* ftp://127.0.0.1:21/download/AriaPrj.zip
* remotePath便是download/AriaPrj.zip
*/
public String remotePath;
public String account;
@ -35,12 +38,12 @@ public class FtpUrlEntity implements Cloneable {
public String url;
/**
* ftp协议
* ftp协议ftp
*/
public String protocol;
/**
* 用户
* 登录的用户
*/
public String user;
/**

@ -42,7 +42,7 @@ public class CancelCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
task = createTask();
}
if (task != null) {
mTaskEntity.removeFile = removeFile;
mTaskEntity.setRemoveFile(removeFile);
if (!TextUtils.isEmpty(mTargetName)) {
task.setTargetName(mTargetName);
}

@ -129,8 +129,8 @@ final class ResumeAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
*/
private void resumeEntity(AbsTaskEntity te) {
if (te instanceof DownloadTaskEntity) {
if (te.requestType == AbsTaskEntity.D_FTP || te.requestType == AbsTaskEntity.U_FTP) {
te.urlEntity = CommonUtil.getFtpUrlInfo(te.getEntity().getKey());
if (te.getRequestType() == AbsTaskEntity.D_FTP || te.getRequestType() == AbsTaskEntity.U_FTP) {
te.setUrlEntity(CommonUtil.getFtpUrlInfo(te.getEntity().getKey()));
}
mQueue = DownloadTaskQueue.getInstance();
} else if (te instanceof UploadTaskEntity) {

@ -151,8 +151,8 @@ class StartCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
AbsTask task = getTask(te.getEntity());
if (task != null) continue;
if (te instanceof DownloadTaskEntity) {
if (te.requestType == AbsTaskEntity.D_FTP || te.requestType == AbsTaskEntity.U_FTP) {
te.urlEntity = CommonUtil.getFtpUrlInfo(te.getEntity().getKey());
if (te.getRequestType() == AbsTaskEntity.D_FTP || te.getRequestType() == AbsTaskEntity.U_FTP) {
te.setUrlEntity(CommonUtil.getFtpUrlInfo(te.getEntity().getKey()));
}
mQueue = DownloadTaskQueue.getInstance();
} else if (te instanceof UploadTaskEntity) {

@ -79,7 +79,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
}
public void setNewTask(boolean newTask) {
mTaskEntity.isNewTask = newTask;
mTaskEntity.setNewTask(newTask);
}
@Override public void setMaxSpeed(double maxSpeed) {
@ -107,7 +107,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
if (mListener instanceof IDownloadListener) {
((IDownloadListener) mListener).onPostPre(mEntity.getFileSize());
}
if (!mTaskEntity.isSupportBP) {
if (!mTaskEntity.isSupportBP()) {
mTotalThreadNum = 1;
mStartThreadNum = 1;
mConstance.THREAD_NUM = mTotalThreadNum;
@ -194,10 +194,10 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
}
}
if (mTaskEntity instanceof DownloadTaskEntity) {
CommonUtil.delDownloadTaskConfig(mTaskEntity.removeFile,
CommonUtil.delDownloadTaskConfig(mTaskEntity.isRemoveFile(),
(DownloadEntity) mTaskEntity.getEntity());
} else if (mTaskEntity instanceof UploadTaskEntity) {
CommonUtil.delUploadTaskConfig(mTaskEntity.removeFile,
CommonUtil.delUploadTaskConfig(mTaskEntity.isRemoveFile(),
(UploadEntity) mTaskEntity.getEntity());
}
}
@ -318,7 +318,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
config.START_LOCATION = startL;
config.END_LOCATION = endL;
config.CONFIG_FILE_PATH = mConfigFile.getPath();
config.SUPPORT_BP = mTaskEntity.isSupportBP;
config.SUPPORT_BP = mTaskEntity.isSupportBP();
config.TASK_ENTITY = mTaskEntity;
return selectThreadTask(config);
}
@ -390,7 +390,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
mFixedThreadPool.execute(task);
}
}
mTaskEntity.isNewTask = false;
mTaskEntity.setNewTask(false);
}
/**
@ -412,7 +412,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
config.START_LOCATION = 0;
config.END_LOCATION = config.FILE_SIZE;
config.CONFIG_FILE_PATH = mConfigFile.getPath();
config.SUPPORT_BP = mTaskEntity.isSupportBP;
config.SUPPORT_BP = mTaskEntity.isSupportBP();
config.TASK_ENTITY = mTaskEntity;
AbsThreadTask task = selectThreadTask(config);
if (task == null) return;

@ -82,7 +82,7 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
ALog.i(TAG, s);
boolean isExist = files.length != 0;
if (!isExist && !isUpload) {
failDownload("文件不存在,任务链接【" + mTaskEntity.urlEntity.url + "】,remotePath:" + remotePath,
failDownload("文件不存在,任务链接【" + mTaskEntity.getUrlEntity().url + "】,remotePath:" + remotePath,
false);
int i = remotePath.lastIndexOf(File.separator);
FTPFile[] files1;
@ -111,14 +111,14 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
if (!FTPReply.isPositiveCompletion(reply)) {
if (isUpload) {
//服务器上没有该文件路径,表示该任务为新的上传任务
mTaskEntity.isNewTask = true;
mTaskEntity.setNewTask(true);
} else {
client.disconnect();
failDownload("获取文件信息错误,错误码为:" + reply + ",msg:" + client.getReplyString(), true);
return;
}
}
mTaskEntity.code = reply;
mTaskEntity.setCode(reply);
if (mSize != 0 && !isUpload) {
mEntity.setFileSize(mSize);
}
@ -164,7 +164,7 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
*/
private FTPClient createFtpClient() {
FTPClient client = null;
final FtpUrlEntity urlEntity = mTaskEntity.urlEntity;
final FtpUrlEntity urlEntity = mTaskEntity.getUrlEntity();
try {
Pattern p = Pattern.compile(Regular.REG_IP_V4);
Matcher m = p.matcher(urlEntity.hostName);
@ -173,7 +173,7 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
InetAddress ip = InetAddress.getByName(urlEntity.hostName);
client.setConnectTimeout(10000); // 连接10s超时
client.connect(ip, Integer.parseInt(urlEntity.port));
mTaskEntity.urlEntity.validAddr = ip;
mTaskEntity.getUrlEntity().validAddr = ip;
} else {
InetAddress[] ips = InetAddress.getAllByName(urlEntity.hostName);
client = connect(new FTPClient(), ips, 0, Integer.parseInt(urlEntity.port));
@ -212,10 +212,10 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
// 开启服务器对UTF-8的支持,如果服务器支持就用UTF-8编码
charSet = "UTF-8";
reply = client.sendCommand("OPTS UTF8", "ON");
if (!TextUtils.isEmpty(mTaskEntity.charSet) || (!FTPReply.isPositiveCompletion(reply)
if (!TextUtils.isEmpty(mTaskEntity.getCharSet()) || (!FTPReply.isPositiveCompletion(reply)
&& reply != FTPReply.COMMAND_OK)) {
ALog.i(TAG, "FTP 服务器不支持开启UTF8编码,尝试使用Aria手动设置的编码");
charSet = mTaskEntity.charSet;
charSet = mTaskEntity.getCharSet();
}
client.setControlEncoding(charSet);
client.setDataTimeout(10 * 1000);
@ -234,7 +234,7 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
private FTPClient connect(FTPClient client, InetAddress[] ips, int index, int port) {
try {
client.connect(ips[index], port);
mTaskEntity.urlEntity.validAddr = ips[index];
mTaskEntity.getUrlEntity().validAddr = ips[index];
return client;
} catch (IOException e) {
//e.printStackTrace();

@ -51,7 +51,7 @@ public abstract class AbsFtpThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTI
*/
protected FTPClient createClient() {
FTPClient client = null;
final FtpUrlEntity urlEntity = mTaskEntity.urlEntity;
final FtpUrlEntity urlEntity = mTaskEntity.getUrlEntity();
if (urlEntity.validAddr == null) {
try {
InetAddress[] ips = InetAddress.getAllByName(urlEntity.hostName);
@ -93,9 +93,9 @@ public abstract class AbsFtpThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTI
}
// 开启服务器对UTF-8的支持,如果服务器支持就用UTF-8编码
charSet = "UTF-8";
if (!TextUtils.isEmpty(mTaskEntity.charSet) || !FTPReply.isPositiveCompletion(
if (!TextUtils.isEmpty(mTaskEntity.getCharSet()) || !FTPReply.isPositiveCompletion(
client.sendCommand("OPTS UTF8", "ON"))) {
charSet = mTaskEntity.charSet;
charSet = mTaskEntity.getCharSet();
}
client.setControlEncoding(charSet);
client.setDataTimeout(10 * 1000);
@ -114,7 +114,7 @@ public abstract class AbsFtpThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTI
private FTPClient connect(FTPClient client, InetAddress[] ips, int index, int port) {
try {
client.connect(ips[index], port);
mTaskEntity.urlEntity.validAddr = ips[index];
mTaskEntity.getUrlEntity().validAddr = ips[index];
return client;
} catch (IOException e) {
try {

@ -41,7 +41,7 @@ public class FtpDelegate<TARGET extends ITarget, ENTITY extends AbsEntity, TASK_
@Override public TARGET charSet(String charSet) {
if (TextUtils.isEmpty(charSet)) return mTarget;
mTaskEntity.charSet = charSet;
mTaskEntity.setCharSet(charSet);
return mTarget;
}
@ -57,10 +57,10 @@ public class FtpDelegate<TARGET extends ITarget, ENTITY extends AbsEntity, TASK_
ALog.e(TAG, "密码不能为null");
return mTarget;
}
mTaskEntity.urlEntity.needLogin = true;
mTaskEntity.urlEntity.user = userName;
mTaskEntity.urlEntity.password = password;
mTaskEntity.urlEntity.account = account;
mTaskEntity.getUrlEntity().needLogin = true;
mTaskEntity.getUrlEntity().user = userName;
mTaskEntity.getUrlEntity().password = password;
mTaskEntity.getUrlEntity().account = account;
return mTarget;
}
}

@ -61,10 +61,10 @@ public class HttpHeaderDelegate<TARGET extends ITarget, ENTITY extends AbsEntity
ALog.w(TAG, "设置header失败,header对应的value不能为null");
return mTarget;
}
if (mTaskEntity.headers.get(key) == null) {
mTaskEntity.headers.put(key, value);
} else if (!mTaskEntity.headers.get(key).equals(value)) {
mTaskEntity.headers.put(key, value);
if (mTaskEntity.getHeaders().get(key) == null) {
mTaskEntity.getHeaders().put(key, value);
} else if (!mTaskEntity.getHeaders().get(key).equals(value)) {
mTaskEntity.getHeaders().put(key, value);
}
return mTarget;
}
@ -88,9 +88,9 @@ public class HttpHeaderDelegate<TARGET extends ITarget, ENTITY extends AbsEntity
3只有当上面两个步骤中key value都相同时才能任务两个map数据一致
*/
boolean mapEquals = false;
if (mTaskEntity.headers.size() == headers.size()) {
if (mTaskEntity.getHeaders().size() == headers.size()) {
int i = 0;
Set<String> keys = mTaskEntity.headers.keySet();
Set<String> keys = mTaskEntity.getHeaders().keySet();
for (String key : keys) {
if (headers.containsKey(key)) {
i++;
@ -98,9 +98,9 @@ public class HttpHeaderDelegate<TARGET extends ITarget, ENTITY extends AbsEntity
break;
}
}
if (i == mTaskEntity.headers.size()) {
if (i == mTaskEntity.getHeaders().size()) {
int j = 0;
Collection<String> values = mTaskEntity.headers.values();
Collection<String> values = mTaskEntity.getHeaders().values();
for (String value : values) {
if (headers.containsValue(value)) {
j++;
@ -108,17 +108,17 @@ public class HttpHeaderDelegate<TARGET extends ITarget, ENTITY extends AbsEntity
break;
}
}
if (j == mTaskEntity.headers.size()) {
if (j == mTaskEntity.getHeaders().size()) {
mapEquals = true;
}
}
}
if (!mapEquals) {
mTaskEntity.headers.clear();
mTaskEntity.getHeaders().clear();
Set<String> keys = headers.keySet();
for (String key : keys) {
mTaskEntity.headers.put(key, headers.get(key));
mTaskEntity.getHeaders().put(key, headers.get(key));
}
}
@ -133,7 +133,7 @@ public class HttpHeaderDelegate<TARGET extends ITarget, ENTITY extends AbsEntity
*/
@Override
public TARGET setRequestMode(RequestEnum requestEnum) {
mTaskEntity.requestEnum = requestEnum;
mTaskEntity.setRequestEnum(requestEnum);
return mTarget;
}
}

@ -150,7 +150,7 @@ class BaseDListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
}
private void saveData(int state, long location) {
mTaskEntity.state = state;
mTaskEntity.setState(state);
mEntity.setState(state);
mEntity.setComplete(state == IEntity.STATE_COMPLETE);
if (state == IEntity.STATE_CANCEL) {

@ -126,7 +126,7 @@ abstract class BaseGroupTarget<TARGET extends BaseGroupTarget>
file.renameTo(new File(newPath));
}
de.setDownloadPath(newPath);
dte.key = newPath;
dte.setKey(newPath);
de.save();
dte.save();
}

@ -41,8 +41,8 @@ abstract class BaseNormalTarget<TARGET extends BaseNormalTarget>
this.url = url;
mTargetName = targetName;
mTaskEntity = TEManager.getInstance().getTEntity(DownloadTaskEntity.class, url);
mEntity = mTaskEntity.entity;
mTaskEntity.refreshInfo = refreshInfo;
mEntity = mTaskEntity.getEntity();
mTaskEntity.setRefreshInfo(refreshInfo);
if (mEntity != null) {
mTempFilePath = mEntity.getDownloadPath();
}
@ -141,7 +141,7 @@ abstract class BaseNormalTarget<TARGET extends BaseNormalTarget>
//设置文件保存路径,如果新文件路径和就文件路径不同,则修改路径
if (!filePath.equals(mEntity.getDownloadPath())) {
if (!mTaskEntity.refreshInfo && DbEntity.checkDataExist(DownloadEntity.class,
if (!mTaskEntity.isRefreshInfo() && DbEntity.checkDataExist(DownloadEntity.class,
"downloadPath=?", filePath)) {
ALog.e(TAG, "下载失败,保存路径【" + filePath + "】已经被其它任务占用,请设置其它保存路径");
return false;
@ -150,7 +150,7 @@ abstract class BaseNormalTarget<TARGET extends BaseNormalTarget>
File newFile = new File(filePath);
mEntity.setDownloadPath(filePath);
mEntity.setFileName(newFile.getName());
mTaskEntity.key = filePath;
mTaskEntity.setKey(filePath);
//mTaskEntity.update();
if (oldFile.exists()) {
oldFile.renameTo(newFile);

@ -36,6 +36,9 @@ public class DownloadGroupEntity extends AbsGroupEntity {
*/
private String dirPath;
/**
* 子任务实体列表
*/
public List<DownloadEntity> getSubEntities() {
return subEntities;
}

@ -226,7 +226,7 @@ public class DownloadGroupTarget extends BaseGroupTarget<DownloadGroupTarget> {
}
CommonUtil.renameDownloadConfig(oldFile.getName(), newName);
entity.setDownloadPath(newPath);
taskEntity.key = newPath;
taskEntity.setKey(newPath);
entity.setFileName(newName);
entity.update();
}

@ -41,7 +41,7 @@ public class DownloadGroupTask extends AbsGroupTask<DownloadGroupTaskEntity> {
mOutHandler = outHandler;
mContext = AriaManager.APP;
mListener = new DownloadGroupListener(this, mOutHandler);
switch (taskEntity.requestType) {
switch (taskEntity.getRequestType()) {
case AbsTaskEntity.D_HTTP:
mUtil = new DownloadGroupUtil(mListener, mTaskEntity);
break;

@ -117,6 +117,7 @@ public class DownloadReceiver extends AbsReceiver {
* 加载下载地址如果任务组的中的下载地址改变了则任务从新的一个任务组
*
* @param urls 任务组子任务下载地址列表
* @deprecated {@link #loadGroup(DownloadGroupEntity)}
*/
@Deprecated
public DownloadGroupTarget load(List<String> urls) {

@ -54,7 +54,7 @@ public class DownloadTarget extends BaseNormalTarget<DownloadTarget>
* @param use {@code true} 使用
*/
@Deprecated public DownloadTarget useServerFileName(boolean use) {
mTaskEntity.useServerFileName = use;
mTaskEntity.setUseServerFileName(use);
return this;
}

@ -28,29 +28,29 @@ import com.arialyy.aria.orm.annotation.Primary;
*/
public class DownloadTaskEntity extends AbsNormalTaskEntity<DownloadEntity> {
@Ignore public DownloadEntity entity;
@Ignore private DownloadEntity entity;
/**
* 任务的url
*/
@NoNull public String url = "";
@NoNull private String url;
/**
* 所属的任务组组名如果不属于任务组则为null
*/
@Foreign(parent = DownloadGroupTaskEntity.class, column = "key",
onUpdate = ActionPolicy.CASCADE, onDelete = ActionPolicy.CASCADE)
public String groupName;
private String groupName;
/**
* 是否是chunk模式
*/
public boolean isChunked = false;
private boolean isChunked = false;
/**
* 该任务是否属于任务组
*/
public boolean isGroupTask = false;
private boolean isGroupTask = false;
/**
* Task实体对应的key
@ -58,7 +58,9 @@ public class DownloadTaskEntity extends AbsNormalTaskEntity<DownloadEntity> {
@Primary
@Foreign(parent = DownloadEntity.class, column = "downloadPath",
onUpdate = ActionPolicy.CASCADE, onDelete = ActionPolicy.CASCADE)
public String key;
private String key;
public DownloadTaskEntity() {
}
@ -70,4 +72,44 @@ public class DownloadTaskEntity extends AbsNormalTaskEntity<DownloadEntity> {
@Override public String getKey() {
return key;
}
public String getUrl() {
return url;
}
public String getGroupName() {
return groupName;
}
public boolean isChunked() {
return isChunked;
}
public boolean isGroupTask() {
return isGroupTask;
}
public void setEntity(DownloadEntity entity) {
this.entity = entity;
}
public void setUrl(String url) {
this.url = url;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public void setChunked(boolean chunked) {
isChunked = chunked;
}
public void setGroupTask(boolean groupTask) {
isGroupTask = groupTask;
}
public void setKey(String key) {
this.key = key;
}
}

@ -38,7 +38,7 @@ public class FtpDirDownloadTarget extends BaseGroupTarget<FtpDirDownloadTarget>
private void init(String key) {
mGroupName = key;
mTaskEntity = TEManager.getInstance().getFDTEntity(DownloadGroupTaskEntity.class, key);
mTaskEntity.requestType = AbsTaskEntity.D_FTP_DIR;
mTaskEntity.setRequestType(AbsTaskEntity.D_FTP_DIR);
mEntity = mTaskEntity.getEntity();
if (mEntity != null) {
mDirPathTemp = mEntity.getDirPath();
@ -58,10 +58,10 @@ public class FtpDirDownloadTarget extends BaseGroupTarget<FtpDirDownloadTarget>
if (mTaskEntity.getSubTaskEntities() != null) {
//初始化子项的登录信息
for (DownloadTaskEntity entity : mTaskEntity.getSubTaskEntities()) {
entity.urlEntity.needLogin = mTaskEntity.urlEntity.needLogin;
entity.urlEntity.account = mTaskEntity.urlEntity.account;
entity.urlEntity.user = mTaskEntity.urlEntity.user;
entity.urlEntity.password = mTaskEntity.urlEntity.password;
entity.getUrlEntity().needLogin = mTaskEntity.getUrlEntity().needLogin;
entity.getUrlEntity().account = mTaskEntity.getUrlEntity().account;
entity.getUrlEntity().user = mTaskEntity.getUrlEntity().user;
entity.getUrlEntity().password = mTaskEntity.getUrlEntity().password;
}
}
}

@ -45,9 +45,9 @@ public class FtpDownloadTarget extends BaseNormalTarget<FtpDownloadTarget>
private void init(boolean refreshInfo) {
int lastIndex = url.lastIndexOf("/");
mEntity.setFileName(url.substring(lastIndex + 1, url.length()));
mTaskEntity.urlEntity = CommonUtil.getFtpUrlInfo(url);
mTaskEntity.refreshInfo = refreshInfo;
mTaskEntity.requestType = AbsTaskEntity.D_FTP;
mTaskEntity.setUrlEntity(CommonUtil.getFtpUrlInfo(url));
mTaskEntity.setRefreshInfo(refreshInfo);
mTaskEntity.setRequestType(AbsTaskEntity.D_FTP);
mDelegate = new FtpDelegate<>(this, mTaskEntity);
}

@ -234,7 +234,7 @@ public abstract class AbsGroupUtil implements IUtil {
}
}
clearState();
CommonUtil.delDownloadGroupTaskConfig(mGTEntity.removeFile, mGTEntity.getEntity());
CommonUtil.delDownloadGroupTaskConfig(mGTEntity.isRemoveFile(), mGTEntity.getEntity());
mListener.onCancel();
}
@ -277,13 +277,13 @@ public abstract class AbsGroupUtil implements IUtil {
mCompleteNum++;
mCurrentLocation += te.getEntity().getFileSize();
} else {
mExeMap.put(te.url, te);
mExeMap.put(te.getUrl(), te);
mCurrentLocation += file.exists() ? te.getEntity().getCurrentProgress() : 0;
}
if (isNeedLoadFileSize) {
mTotalLen += te.getEntity().getFileSize();
}
mTasksMap.put(te.url, te);
mTasksMap.put(te.getUrl(), te);
}
updateFileSize();
}
@ -473,7 +473,7 @@ public abstract class AbsGroupUtil implements IUtil {
if (subEntity.getFailNum() < 5 && needRetry && NetUtils.isConnected(AriaManager.APP)) {
reStartTask();
} else {
mFailMap.put(subTaskEntity.url, subTaskEntity);
mFailMap.put(subTaskEntity.getUrl(), subTaskEntity);
mListener.onSubFail(subEntity);
//如果失败的任务数大于实际的下载任务数,任务组停止下载
if (mFailMap.size() >= mExeMap.size()) {
@ -506,7 +506,7 @@ public abstract class AbsGroupUtil implements IUtil {
}
private void saveData(int state, long location) {
subTaskEntity.state = state;
subTaskEntity.setState(state);
subEntity.setState(state);
subEntity.setComplete(state == IEntity.STATE_COMPLETE);
if (state == IEntity.STATE_CANCEL) {

@ -66,12 +66,12 @@ class ConnectionHelp {
*/
static HttpURLConnection setConnectParam(DownloadTaskEntity entity, HttpURLConnection conn)
throws ProtocolException {
conn.setRequestMethod(entity.requestEnum.name);
conn.setRequestMethod(entity.getRequestEnum().name);
Set<String> keys = null;
if (entity.headers != null && entity.headers.size() > 0) {
keys = entity.headers.keySet();
if (entity.getHeaders() != null && entity.getHeaders().size() > 0) {
keys = entity.getHeaders().keySet();
for (String key : keys) {
conn.setRequestProperty(key, entity.headers.get(key));
conn.setRequestProperty(key, entity.getHeaders().get(key));
}
}
if (keys == null || !keys.contains("Charset")) {

@ -45,7 +45,7 @@ class Downloader extends AbsFileer<DownloadEntity, DownloadTaskEntity> {
}
@Override protected int setNewTaskThreadNum() {
return mEntity.getFileSize() <= SUB_LEN || mTaskEntity.requestType == AbsTaskEntity.D_FTP_DIR
return mEntity.getFileSize() <= SUB_LEN || mTaskEntity.getRequestType() == AbsTaskEntity.D_FTP_DIR
? 1
: AriaManager.getInstance(mContext).getDownloadConfig().getThreadNum();
}
@ -53,11 +53,11 @@ class Downloader extends AbsFileer<DownloadEntity, DownloadTaskEntity> {
@Override protected void checkTask() {
mConfigFile = new File(CommonUtil.getFileConfigPath(true, mEntity.getFileName()));
mTempFile = new File(mEntity.getDownloadPath());
if (!mTaskEntity.isSupportBP) {
if (!mTaskEntity.isSupportBP()) {
isNewTask = true;
return;
}
if (mTaskEntity.isNewTask) {
if (mTaskEntity.isNewTask()) {
isNewTask = true;
return;
}
@ -101,7 +101,7 @@ class Downloader extends AbsFileer<DownloadEntity, DownloadTaskEntity> {
}
@Override protected AbsThreadTask selectThreadTask(SubThreadConfig<DownloadTaskEntity> config) {
switch (mTaskEntity.requestType) {
switch (mTaskEntity.getRequestType()) {
case AbsTaskEntity.D_FTP:
case AbsTaskEntity.D_FTP_DIR:
return new FtpThreadTask(mConstance, (IDownloadListener) mListener, config);

@ -40,7 +40,7 @@ class FtpDirInfoThread extends AbsFtpInfoThread<DownloadGroupEntity, DownloadGro
}
@Override protected String setRemotePath() {
return mTaskEntity.urlEntity.remotePath;
return mTaskEntity.getUrlEntity().remotePath;
}
@Override protected void handleFile(String remotePath, FTPFile ftpFile) {
@ -58,7 +58,7 @@ class FtpDirInfoThread extends AbsFtpInfoThread<DownloadGroupEntity, DownloadGro
* FTP文件夹的子任务实体 在这生成
*/
private void addEntity(String remotePath, FTPFile ftpFile) {
final FtpUrlEntity urlEntity = mTaskEntity.urlEntity.clone();
final FtpUrlEntity urlEntity = mTaskEntity.getUrlEntity().clone();
DownloadEntity entity = new DownloadEntity();
entity.setUrl(
urlEntity.protocol + "://" + urlEntity.hostName + ":" + urlEntity.port + "/" + remotePath);
@ -66,22 +66,22 @@ class FtpDirInfoThread extends AbsFtpInfoThread<DownloadGroupEntity, DownloadGro
int lastIndex = remotePath.lastIndexOf("/");
String fileName = lastIndex < 0 ? CommonUtil.keyToHashKey(remotePath)
: remotePath.substring(lastIndex + 1, remotePath.length());
entity.setFileName(new String(fileName.getBytes(), Charset.forName(mTaskEntity.charSet)));
entity.setFileName(new String(fileName.getBytes(), Charset.forName(mTaskEntity.getCharSet())));
entity.setGroupName(mEntity.getGroupName());
entity.setGroupChild(true);
entity.setFileSize(ftpFile.getSize());
entity.insert();
DownloadTaskEntity taskEntity = new DownloadTaskEntity();
taskEntity.key = entity.getDownloadPath();
taskEntity.url = entity.getUrl();
taskEntity.entity = entity;
taskEntity.isGroupTask = true;
taskEntity.groupName = mEntity.getGroupName();
taskEntity.requestType = AbsTaskEntity.D_FTP;
taskEntity.setKey(entity.getDownloadPath());
taskEntity.setUrl(entity.getUrl());
taskEntity.setEntity(entity);
taskEntity.setGroupTask(true);
taskEntity.setGroupName(mEntity.getGroupName());
taskEntity.setRequestType(AbsTaskEntity.D_FTP);
urlEntity.url = entity.getUrl();
urlEntity.remotePath = remotePath;
taskEntity.urlEntity = urlEntity;
taskEntity.setUrlEntity(urlEntity);
taskEntity.insert();
if (mEntity.getUrls() == null) {

@ -32,13 +32,13 @@ class FtpFileInfoThread extends AbsFtpInfoThread<DownloadEntity, DownloadTaskEnt
}
@Override protected String setRemotePath() {
return mTaskEntity.urlEntity.remotePath;
return mTaskEntity.getUrlEntity().remotePath;
}
@Override protected void onPreComplete(int code) {
super.onPreComplete(code);
if (mSize != mTaskEntity.getEntity().getFileSize()) {
mTaskEntity.isNewTask = true;
mTaskEntity.setNewTask(true);
}
mEntity.setFileSize(mSize);
mCallback.onComplete(mEntity.getUrl(), new CompleteInfo(code));

@ -71,7 +71,7 @@ class FtpThreadTask extends AbsFtpThreadTask<DownloadEntity, DownloadTaskEntity>
return;
}
String remotePath =
new String(mTaskEntity.urlEntity.remotePath.getBytes(charSet), SERVER_CHARSET);
new String(mTaskEntity.getUrlEntity().remotePath.getBytes(charSet), SERVER_CHARSET);
ALog.i(TAG, "remotePath【" + remotePath + "】");
is = client.retrieveFileStream(remotePath);
reply = client.getReplyCode();

@ -105,41 +105,46 @@ class HttpFileInfoThread implements Runnable {
String disposition = conn.getHeaderField("Content-Disposition");
if (!TextUtils.isEmpty(disposition)) {
mEntity.setDisposition(CommonUtil.encryptBASE64(disposition));
if (disposition.contains(mTaskEntity.dispositionFileKey)) {
String[] infos = disposition.split("=");
mEntity.setServerFileName(URLDecoder.decode(infos[1], "utf-8"));
if (disposition.contains(";")) {
String[] infos = disposition.split(";");
for (String info : infos) {
if (info.startsWith("filename") && info.contains("=")) {
String[] temp = info.split("=");
mEntity.setServerFileName(URLDecoder.decode(temp[1], "utf-8"));
}
}
}
}
mTaskEntity.code = code;
mTaskEntity.setCode(code);
if (code == HttpURLConnection.HTTP_PARTIAL) {
if (!checkLen(len) && !isChunked) {
return;
}
mEntity.setFileSize(len);
mTaskEntity.isSupportBP = true;
mTaskEntity.setSupportBP(true);
isComplete = true;
} else if (code == HttpURLConnection.HTTP_OK) {
if (!checkLen(len) && !isChunked) {
return;
}
mEntity.setFileSize(len);
mTaskEntity.isSupportBP = false;
mTaskEntity.setSupportBP(false);
isComplete = true;
} else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
failDownload("任务【" + mEntity.getUrl() + "】下载失败,错误码:404", true);
} else if (code == HttpURLConnection.HTTP_MOVED_TEMP
|| code == HttpURLConnection.HTTP_MOVED_PERM
|| code == HttpURLConnection.HTTP_SEE_OTHER) {
mTaskEntity.redirectUrl = conn.getHeaderField("Location");
mTaskEntity.setRedirectUrl(conn.getHeaderField("Location"));
mEntity.setRedirect(true);
mEntity.setRedirectUrl(mTaskEntity.redirectUrl);
handle302Turn(conn, mTaskEntity.redirectUrl);
mEntity.setRedirectUrl(mTaskEntity.getRedirectUrl());
handle302Turn(conn, mTaskEntity.getRedirectUrl());
} else {
failDownload("任务【" + mEntity.getUrl() + "】下载失败,错误码:" + code, true);
}
if (isComplete) {
mTaskEntity.isChunked = isChunked;
mTaskEntity.setChunked(isChunked);
mTaskEntity.update();
if (onFileInfoListener != null) {
CompleteInfo info = new CompleteInfo(code);
@ -183,7 +188,7 @@ class HttpFileInfoThread implements Runnable {
*/
private boolean checkLen(long len) {
if (len != mEntity.getFileSize()) {
mTaskEntity.isNewTask = true;
mTaskEntity.setNewTask(true);
}
if (len < 0) {
failDownload("任务【" + mEntity.getUrl() + "】下载失败,文件长度小于0", true);

@ -81,7 +81,7 @@ final class HttpThreadTask extends AbsThreadTask<DownloadEntity, DownloadTaskEnt
//设置每条线程写入文件的位置
file.seek(mConfig.START_LOCATION);
if (mTaskEntity.isChunked) {
if (mTaskEntity.isChunked()) {
readChunk(is, file);
} else {
readNormal(is, file);

@ -92,8 +92,8 @@ public class SimpleDownloadUtil implements IUtil, Runnable {
@Override public void run() {
mListener.onPre();
if (mTaskEntity.getEntity().getFileSize() <= 1
|| mTaskEntity.refreshInfo
|| mTaskEntity.requestType == AbsTaskEntity.D_FTP) {
|| mTaskEntity.isRefreshInfo()
|| mTaskEntity.getRequestType() == AbsTaskEntity.D_FTP) {
new Thread(createInfoThread()).start();
} else {
mDownloader.start();
@ -104,7 +104,7 @@ public class SimpleDownloadUtil implements IUtil, Runnable {
* 通过链接类型创建不同的获取文件信息的线程
*/
private Runnable createInfoThread() {
switch (mTaskEntity.requestType) {
switch (mTaskEntity.getRequestType()) {
case AbsTaskEntity.D_FTP:
return new FtpFileInfoThread(mTaskEntity, new OnFileInfoCallback() {
@Override public void onComplete(String url, CompleteInfo info) {

@ -53,8 +53,8 @@ public class DGTEWrapper extends AbsWrapper {
if (subWrappers != null && !subWrappers.isEmpty()) {
List<DownloadTaskEntity> temp = new ArrayList<>();
for (DTEWrapper dw : subWrappers) {
if (dw.taskEntity.requestType == AbsTaskEntity.D_FTP) {
dw.taskEntity.urlEntity = CommonUtil.getFtpUrlInfo(dw.taskEntity.url);
if (dw.taskEntity.getRequestType() == AbsTaskEntity.D_FTP) {
dw.taskEntity.setUrlEntity(CommonUtil.getFtpUrlInfo(dw.taskEntity.getUrl()));
}
temp.add(dw.taskEntity);
}

@ -40,7 +40,7 @@ public class DTEWrapper extends AbsWrapper {
@Override public void handleConvert() {
taskEntity = (taskEntitys == null || taskEntitys.isEmpty()) ? null : taskEntitys.get(0);
if (taskEntity != null) {
taskEntity.entity = entity;
taskEntity.setEntity(entity);
}
}
}

@ -50,7 +50,7 @@ public abstract class AbsTarget<TARGET extends AbsTarget, ENTITY extends AbsEnti
*/
public TARGET resetState() {
mTaskEntity.getEntity().setState(IEntity.STATE_WAIT);
mTaskEntity.refreshInfo = true;
mTaskEntity.setRefreshInfo(true);
return (TARGET) this;
}

@ -57,75 +57,72 @@ public abstract class AbsTaskEntity<ENTITY extends AbsEntity> extends DbEntity {
/**
* 账号和密码
*/
@Ignore public FtpUrlEntity urlEntity;
@Ignore private FtpUrlEntity urlEntity;
/**
* 刷新信息 {@code true} 重新刷新下载信息
*/
@Ignore public boolean refreshInfo = false;
@Ignore private boolean refreshInfo = false;
/**
* 是否是新任务{@code true} 新任务
*/
@Ignore public boolean isNewTask = false;
@Ignore private boolean isNewTask = false;
/**
* 任务状态和Entity的state同步
*/
public int state = IEntity.STATE_WAIT;
private int state = IEntity.STATE_WAIT;
/**
* 请求类型
* {@link AbsTaskEntity#D_HTTP}{@link AbsTaskEntity#D_FTP}{@link AbsTaskEntity#D_FTP_DIR}
*/
public int requestType = D_HTTP;
private int requestType = D_HTTP;
/**
* http 请求头
*/
public Map<String, String> headers = new HashMap<>();
private Map<String, String> headers = new HashMap<>();
/**
* 字符编码默认为"utf-8"
*/
public String charSet = "utf-8";
private String charSet = "utf-8";
/**
* 网络请求类型
*/
public RequestEnum requestEnum = RequestEnum.GET;
private RequestEnum requestEnum = RequestEnum.GET;
/**
* 是否使用服务器通过content-disposition传递的文件名内容格式{@code attachment;filename=***}
* 是否使用服务器通过content-disposition传递的文件名内容格式{@code attachment; filename="filename.jpg"}
* {@code true} 使用
*/
public boolean useServerFileName = false;
/**
* 从Disposition获取的文件名说需要的key
*/
public String dispositionFileKey = "attachment;filename";
private boolean useServerFileName = false;
/**
* 重定向链接
*/
public String redirectUrl = "";
private String redirectUrl = "";
/**
* 删除任务时是否删除已下载完成的文件
* 未完成的任务不管true还是false都会删除文件
* {@code true} 删除任务数据库记录并且删除已经下载完成的文件
* {@code false} 如果任务已经完成只删除任务数据库记录
*/
@Ignore public boolean removeFile = false;
@Ignore private boolean removeFile = false;
/**
* 是否支持断点, {@code true} 为支持断点
*/
public boolean isSupportBP = true;
private boolean isSupportBP = true;
/**
* 状态码
*/
public int code;
private int code;
public abstract ENTITY getEntity();
@ -146,4 +143,104 @@ public abstract class AbsTaskEntity<ENTITY extends AbsEntity> extends DbEntity {
}
super.update();
}
public FtpUrlEntity getUrlEntity() {
return urlEntity;
}
public void setUrlEntity(FtpUrlEntity urlEntity) {
this.urlEntity = urlEntity;
}
public boolean isRefreshInfo() {
return refreshInfo;
}
public void setRefreshInfo(boolean refreshInfo) {
this.refreshInfo = refreshInfo;
}
public boolean isNewTask() {
return isNewTask;
}
public void setNewTask(boolean newTask) {
isNewTask = newTask;
}
public void setState(int state) {
this.state = state;
}
public int getRequestType() {
return requestType;
}
public void setRequestType(int requestType) {
this.requestType = requestType;
}
public Map<String, String> getHeaders() {
return headers;
}
public void setHeaders(Map<String, String> headers) {
this.headers = headers;
}
public String getCharSet() {
return charSet;
}
public void setCharSet(String charSet) {
this.charSet = charSet;
}
public RequestEnum getRequestEnum() {
return requestEnum;
}
public void setRequestEnum(RequestEnum requestEnum) {
this.requestEnum = requestEnum;
}
public boolean isUseServerFileName() {
return useServerFileName;
}
public void setUseServerFileName(boolean useServerFileName) {
this.useServerFileName = useServerFileName;
}
public String getRedirectUrl() {
return redirectUrl;
}
public void setRedirectUrl(String redirectUrl) {
this.redirectUrl = redirectUrl;
}
public boolean isRemoveFile() {
return removeFile;
}
public void setRemoveFile(boolean removeFile) {
this.removeFile = removeFile;
}
public boolean isSupportBP() {
return isSupportBP;
}
public void setSupportBP(boolean supportBP) {
isSupportBP = supportBP;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
}

@ -42,7 +42,7 @@ public interface IEntity {
*/
@Ignore int STATE_WAIT = 3;
/**
* 下载中
* 正在执行
*/
@Ignore int STATE_RUNNING = 4;
/**
@ -54,7 +54,7 @@ public interface IEntity {
*/
@Ignore int STATE_POST_PRE = 6;
/**
* 取消下载
* 删除任务
*/
@Ignore int STATE_CANCEL = 7;
}

@ -98,7 +98,7 @@ class DGTEFactory implements IGTEFactory<DownloadGroupEntity, DownloadGroupTaskE
fte.setEntity(dge);
}
fte.setKey(ftpUrl);
fte.urlEntity = CommonUtil.getFtpUrlInfo(ftpUrl);
fte.setUrlEntity(CommonUtil.getFtpUrlInfo(ftpUrl));
if (fte.getEntity().getSubEntities() == null) {
fte.getEntity().setSubEntities(new ArrayList<DownloadEntity>());
@ -116,11 +116,11 @@ class DGTEFactory implements IGTEFactory<DownloadGroupEntity, DownloadGroupTaskE
List<DownloadTaskEntity> list = new ArrayList<>();
for (DownloadEntity entity : dge.getSubEntities()) {
DownloadTaskEntity taskEntity = new DownloadTaskEntity();
taskEntity.entity = entity;
taskEntity.key = entity.getDownloadPath();
taskEntity.groupName = dge.getKey();
taskEntity.isGroupTask = true;
taskEntity.url = entity.getUrl();
taskEntity.setEntity(entity);
taskEntity.setKey(entity.getDownloadPath());
taskEntity.setGroupName(dge.getKey());
taskEntity.setGroupTask(true);
taskEntity.setUrl(entity.getUrl());
list.add(taskEntity);
}
return list;

@ -57,15 +57,15 @@ class DTEFactory implements INormalTEFactory<DownloadEntity, DownloadTaskEntity>
taskEntity = wrapper.get(0).taskEntity;
if (taskEntity == null) {
taskEntity = new DownloadTaskEntity();
} else if (taskEntity.entity == null || TextUtils.isEmpty(taskEntity.entity.getUrl())) {
taskEntity.entity = entity;
} else if (taskEntity.getEntity() == null || TextUtils.isEmpty(taskEntity.getEntity().getUrl())) {
taskEntity.setEntity(entity);
}
} else {
taskEntity = new DownloadTaskEntity();
}
taskEntity.key = entity.getDownloadPath();
taskEntity.url = entity.getUrl();
taskEntity.entity = entity;
taskEntity.setKey(entity.getDownloadPath());
taskEntity.setUrl(entity.getUrl());
taskEntity.setEntity(entity);
return taskEntity;
}

@ -53,15 +53,15 @@ class UTEFactory implements INormalTEFactory<UploadEntity, UploadTaskEntity> {
UploadTaskEntity uTaskEntity = wrapper.get(0).taskEntity;
if (uTaskEntity == null) {
uTaskEntity = new UploadTaskEntity();
uTaskEntity.entity = entity;
} else if (uTaskEntity.entity == null || TextUtils.isEmpty(
uTaskEntity.entity.getFilePath())) {
uTaskEntity.entity = entity;
uTaskEntity.setEntity(entity);
} else if (uTaskEntity.getEntity() == null || TextUtils.isEmpty(
uTaskEntity.getEntity().getFilePath())) {
uTaskEntity.setEntity(entity);
}
return uTaskEntity;
} else {
UploadTaskEntity uTaskEntity = new UploadTaskEntity();
uTaskEntity.entity = entity;
uTaskEntity.setEntity(entity);
return uTaskEntity;
}
}

@ -123,7 +123,7 @@ public class DownloadTaskQueue extends AbsTaskQueue<DownloadTask, DownloadTaskEn
&& mExecutePool.getTask(entity.getEntity().getKey()) == null) {
task = (DownloadTask) TaskFactory.getInstance()
.createTask(target, entity, DownloadSchedulers.getInstance());
entity.key = entity.getEntity().getDownloadPath();
entity.setKey(entity.getEntity().getDownloadPath());
mCachePool.putTask(task);
} else {
ALog.w(TAG, "任务已存在");

@ -69,7 +69,7 @@ public class UploadTaskQueue extends AbsTaskQueue<UploadTask, UploadTaskEntity>
&& mExecutePool.getTask(entity.getEntity().getKey()) == null) {
task = (UploadTask) TaskFactory.getInstance()
.createTask(targetName, entity, UploadSchedulers.getInstance());
entity.key = entity.getEntity().getFilePath();
entity.setKey(entity.getEntity().getFilePath());
mCachePool.putTask(task);
} else {
ALog.w(TAG, "任务已存在");

@ -32,7 +32,7 @@ abstract class BaseNormalTarget<TARGET extends AbsUploadTarget>
void initTarget(String filePath) {
mTaskEntity = TEManager.getInstance().getTEntity(UploadTaskEntity.class, filePath);
mEntity = mTaskEntity.entity;
mEntity = mTaskEntity.getEntity();
File file = new File(filePath);
mEntity.setFileName(file.getName());
mEntity.setFileSize(file.length());

@ -136,7 +136,7 @@ class BaseUListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
}
private void saveData(int state, long location) {
mTaskEntity.state = state;
mTaskEntity.setState(state);
mEntity.setState(state);
mEntity.setComplete(state == IEntity.STATE_COMPLETE);
if (state == IEntity.STATE_CANCEL) {

@ -40,7 +40,7 @@ public class FtpUploadTarget extends BaseNormalTarget<FtpUploadTarget>
private void initTask(String filePath) {
initTarget(filePath);
mTaskEntity.requestType = AbsTaskEntity.U_FTP;
mTaskEntity.setRequestType(AbsTaskEntity.U_FTP);
mDelegate = new FtpDelegate<>(this, mTaskEntity);
}
@ -61,11 +61,11 @@ public class FtpUploadTarget extends BaseNormalTarget<FtpUploadTarget>
if (!b) {
return false;
}
mTaskEntity.urlEntity = CommonUtil.getFtpUrlInfo(mTempUrl);
mTaskEntity.urlEntity.account = mAccount;
mTaskEntity.urlEntity.user = mUser;
mTaskEntity.urlEntity.password = mPw;
mTaskEntity.urlEntity.needLogin = needLogin;
mTaskEntity.setUrlEntity(CommonUtil.getFtpUrlInfo(mTempUrl));
mTaskEntity.getUrlEntity().account = mAccount;
mTaskEntity.getUrlEntity().user = mUser;
mTaskEntity.getUrlEntity().password = mPw;
mTaskEntity.getUrlEntity().needLogin = needLogin;
return true;
}

@ -20,6 +20,7 @@ import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.command.ICmd;
import com.arialyy.aria.core.command.normal.NormalCmdFactory;
import com.arialyy.aria.core.common.ProxyHelper;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.inf.AbsReceiver;
import com.arialyy.aria.core.scheduler.UploadSchedulers;
import com.arialyy.aria.orm.DbEntity;
@ -69,10 +70,32 @@ public class UploadReceiver extends AbsReceiver<UploadEntity> {
return DbEntity.findFirst(UploadEntity.class, "filePath=?", filePath) != null;
}
/**
* 获取所有普通上传任务
* 获取未完成的普通任务列表{@link #getAllNotCompletTask()}
* 获取已经完成的普通任务列表{@link #getAllCompleteTask()}
*/
@Override public List<UploadEntity> getTaskList() {
return DbEntity.findAllData(UploadEntity.class);
}
/**
* 获取所有未完成的普通上传任务
*/
public List<UploadEntity> getAllNotCompletTask() {
return UploadEntity.findDatas(UploadEntity.class,
"isGroupChild=? and isComplete=?", "false", "false");
}
/**
* 获取所有已经完成的普通任务
*/
public List<UploadEntity> getAllCompleteTask() {
return UploadEntity.findDatas(UploadEntity.class,
"isGroupChild=? and isComplete=?", "false", "true");
}
@Override public void stopAllTask() {
AriaManager.getInstance(AriaManager.APP)
.setCmd(NormalCmdFactory.getInstance()

@ -39,8 +39,8 @@ public class UploadTarget extends BaseNormalTarget<UploadTarget>
initTarget(filePath);
//http暂时不支持断点上传
mTaskEntity.isSupportBP = false;
mTaskEntity.requestType = AbsTaskEntity.U_HTTP;
mTaskEntity.setSupportBP(false);
mTaskEntity.setRequestType(AbsTaskEntity.U_HTTP);
mDelegate = new HttpHeaderDelegate<>(this, mTaskEntity);
}
@ -48,7 +48,7 @@ public class UploadTarget extends BaseNormalTarget<UploadTarget>
* 设置userAgent
*/
public UploadTarget setUserAngent(@NonNull String userAgent) {
mTaskEntity.userAgent = userAgent;
mTaskEntity.setUserAgent(userAgent);
return this;
}
@ -58,7 +58,7 @@ public class UploadTarget extends BaseNormalTarget<UploadTarget>
* @param attachment 附件key
*/
public UploadTarget setAttachment(@NonNull String attachment) {
mTaskEntity.attachment = attachment;
mTaskEntity.setAttachment(attachment);
return this;
}
@ -68,7 +68,7 @@ public class UploadTarget extends BaseNormalTarget<UploadTarget>
* @param contentType tipmultipart/form-data
*/
public UploadTarget setContentType(String contentType) {
mTaskEntity.contentType = contentType;
mTaskEntity.setContentType(contentType);
return this;
}

@ -40,8 +40,7 @@ class FtpFileInfoThread extends AbsFtpInfoThread<UploadEntity, UploadTaskEntity>
}
@Override protected String setRemotePath() {
String url = mEntity.getUrl();
return mTaskEntity.urlEntity.remotePath + "/" + mEntity.getFileName();
return mTaskEntity.getUrlEntity().remotePath + "/" + mEntity.getFileName();
}
/**
@ -71,7 +70,7 @@ class FtpFileInfoThread extends AbsFtpInfoThread<UploadEntity, UploadTaskEntity>
File configFile = new File(CommonUtil.getFileConfigPath(false, mEntity.getFileName()));
Properties pro = CommonUtil.loadConfig(configFile);
String key = mEntity.getFileName() + "_record_" + 0;
mTaskEntity.isNewTask = false;
mTaskEntity.setNewTask(false);
long oldRecord = Long.parseLong(pro.getProperty(key, "0"));
if (oldRecord == 0 || oldRecord != ftpFile.getSize()) {
//修改本地保存的停止地址为服务器上对应文件的大小

@ -112,9 +112,9 @@ class FtpThreadTask extends AbsFtpThreadTask<UploadEntity, UploadTaskEntity> {
}
private void initPath() throws UnsupportedEncodingException {
dir = new String(mTaskEntity.urlEntity.remotePath.getBytes(charSet), SERVER_CHARSET);
dir = new String(mTaskEntity.getUrlEntity().remotePath.getBytes(charSet), SERVER_CHARSET);
remotePath = new String(
("/" + mTaskEntity.urlEntity.remotePath + "/" + mEntity.getFileName()).getBytes(charSet),
("/" + mTaskEntity.getUrlEntity().remotePath + "/" + mEntity.getFileName()).getBytes(charSet),
SERVER_CHARSET);
}

@ -66,33 +66,33 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> {
try {
url = new URL(mEntity.getUrl());
mHttpConn = (HttpURLConnection) url.openConnection();
mHttpConn.setRequestMethod(mTaskEntity.requestEnum.name);
mHttpConn.setRequestMethod(mTaskEntity.getRequestEnum().name);
mHttpConn.setUseCaches(false);
mHttpConn.setDoOutput(true);
mHttpConn.setDoInput(true);
mHttpConn.setRequestProperty("Connection", "Keep-Alive");
mHttpConn.setRequestProperty("Content-Type",
mTaskEntity.contentType + "; boundary=" + BOUNDARY);
mHttpConn.setRequestProperty("User-Agent", mTaskEntity.userAgent);
mTaskEntity.getContentType() + "; boundary=" + BOUNDARY);
mHttpConn.setRequestProperty("User-Agent", mTaskEntity.getUserAgent());
mHttpConn.setConnectTimeout(5000);
//mHttpConn.setRequestProperty("Range", "bytes=" + 0 + "-" + "100");
//内部缓冲区---分段上传防止oom
mHttpConn.setChunkedStreamingMode(1024);
//添加Http请求头部
Set<String> keys = mTaskEntity.headers.keySet();
Set<String> keys = mTaskEntity.getHeaders().keySet();
for (String key : keys) {
mHttpConn.setRequestProperty(key, mTaskEntity.headers.get(key));
mHttpConn.setRequestProperty(key, mTaskEntity.getHeaders().get(key));
}
mOutputStream = mHttpConn.getOutputStream();
PrintWriter writer =
new PrintWriter(new OutputStreamWriter(mOutputStream, mTaskEntity.charSet), true);
new PrintWriter(new OutputStreamWriter(mOutputStream, mTaskEntity.getCharSet()), true);
//添加文件上传表单字段
keys = mTaskEntity.formFields.keySet();
keys = mTaskEntity.getFormFields().keySet();
for (String key : keys) {
addFormField(writer, key, mTaskEntity.formFields.get(key));
addFormField(writer, key, mTaskEntity.getFormFields().get(key));
}
uploadFile(writer, mTaskEntity.attachment, uploadFile);
uploadFile(writer, mTaskEntity.getAttachment(), uploadFile);
mTaskEntity.getEntity().setResponseStr(finish(writer));
mListener.onComplete();
} catch (Exception e) {
@ -123,7 +123,7 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> {
.append("\"")
.append(LINE_END);
writer.append("Content-Type: text/plain; charset=")
.append(mTaskEntity.charSet)
.append(mTaskEntity.getCharSet())
.append(LINE_END);
writer.append(LINE_END);
writer.append(value).append(LINE_END);

@ -49,7 +49,7 @@ public class SimpleUploadUtil implements IUtil, Runnable {
@Override public void run() {
mListener.onPre();
switch (mTaskEntity.requestType) {
switch (mTaskEntity.getRequestType()) {
case AbsTaskEntity.U_FTP:
new FtpFileInfoThread(mTaskEntity, new OnFileInfoCallback() {
@Override public void onComplete(String url, CompleteInfo info) {

@ -50,7 +50,7 @@ class Uploader extends AbsFileer<UploadEntity, UploadTaskEntity> {
*/
protected void checkTask() {
mConfigFile = new File(CommonUtil.getFileConfigPath(false, mEntity.getFileName()));
if (!mTaskEntity.isSupportBP) {
if (!mTaskEntity.isSupportBP()) {
isNewTask = true;
return;
}
@ -74,7 +74,7 @@ class Uploader extends AbsFileer<UploadEntity, UploadTaskEntity> {
}
@Override protected AbsThreadTask selectThreadTask(SubThreadConfig<UploadTaskEntity> config) {
switch (mTaskEntity.requestType) {
switch (mTaskEntity.getRequestType()) {
case AbsTaskEntity.U_FTP:
return new FtpThreadTask(mConstance, mListener, config);
case AbsTaskEntity.U_HTTP:

@ -41,7 +41,7 @@ public class UTEWrapper extends AbsWrapper {
//taskEntity.entity = (tEntity == null || tEntity.isEmpty()) ? null : tEntity.get(0);
taskEntity = (taskEntitys == null || taskEntitys.isEmpty()) ? null : taskEntitys.get(0);
if (taskEntity != null) {
taskEntity.entity = entity;
taskEntity.setEntity(entity);
}
}
}

@ -35,6 +35,11 @@ class DBConfig {
static String DB_NAME;
static int VERSION = 31;
/**
* 是否将数据库保存在Sd卡{@code true}
*/
static final boolean SAVE_IN_SDCARD = false;
static {
if (TextUtils.isEmpty(DB_NAME)) {
DB_NAME = "AriaLyyDb";

@ -21,9 +21,18 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.text.TextUtils;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadGroupEntity;
import com.arialyy.aria.core.download.DownloadGroupTaskEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.core.upload.UploadTaskEntity;
import com.arialyy.aria.util.ALog;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
@ -32,11 +41,6 @@ import java.util.Set;
*/
final class SqlHelper extends SQLiteOpenHelper {
private static final String TAG = "SqlHelper";
/**
* 是否将数据库保存在Sd卡{@code true}
*/
private static final boolean SAVE_IN_SDCARD = true;
static volatile SqlHelper INSTANCE = null;
private DelegateCommon mDelegate;
@ -68,7 +72,7 @@ final class SqlHelper extends SQLiteOpenHelper {
}
private SqlHelper(Context context, DelegateCommon delegate) {
super(SAVE_IN_SDCARD ? new DatabaseContext(context) : context, DBConfig.DB_NAME, null,
super(DBConfig.SAVE_IN_SDCARD ? new DatabaseContext(context) : context, DBConfig.DB_NAME, null,
DBConfig.VERSION);
mDelegate = delegate;
}
@ -148,6 +152,7 @@ final class SqlHelper extends SQLiteOpenHelper {
*/
private void handle314AriaUpdate(SQLiteDatabase db) {
Set<String> tables = DBConfig.mapping.keySet();
Map<String, List<DbEntity>> map = new HashMap<>();
for (String tableName : tables) {
Class clazz = DBConfig.mapping.get(tableName);
@ -178,6 +183,8 @@ final class SqlHelper extends SQLiteOpenHelper {
List<DbEntity> list =
DelegateManager.getInstance().getDelegate(DelegateFind.class).findAllData(db, clazz);
map.put(tableName, list);
//修改表名为中介表名
String alertSql = "ALTER TABLE " + tableName + " RENAME TO " + tableName + "_temp";
db.execSQL(alertSql);
@ -189,8 +196,30 @@ final class SqlHelper extends SQLiteOpenHelper {
DelegateUpdate update = DelegateManager.getInstance().getDelegate(DelegateUpdate.class);
try {
for (DbEntity entity : list) {
if (entity instanceof DownloadTaskEntity && ((DownloadTaskEntity) entity).isGroupTask()) {
if (TextUtils.isEmpty(((DownloadTaskEntity) entity).getKey())) {
ALog.w(TAG, "DownloadTaskEntity的key为空,将忽略该条数据");
continue;
}
if (TextUtils.isEmpty(((DownloadTaskEntity) entity).getUrl())) {
List<DbEntity> temp = map.get("DownloadEntity");
boolean isRefresh = false;
for (DbEntity dbEntity : temp) {
if (((DownloadEntity) dbEntity).getDownloadPath()
.equals(((DownloadTaskEntity) entity).getKey())) {
((DownloadTaskEntity) entity).setUrl(((DownloadEntity) dbEntity).getUrl());
isRefresh = true;
break;
}
}
if (isRefresh) {
update.insertData(db, entity);
}
}
} else {
update.insertData(db, entity);
}
}
} catch (Exception e) {
ALog.e(TAG, ALog.getExceptionString(e));
}
@ -201,5 +230,7 @@ final class SqlHelper extends SQLiteOpenHelper {
mDelegate.close(db);
}
map.clear();
}
}

@ -64,7 +64,9 @@ public class ALog {
}
public static int e(String tag, Throwable e) {
return println(Log.ERROR, tag, getExceptionString(e));
String msg = getExceptionString(e);
ErrorHelp.saveError(tag, "", msg);
return println(Log.ERROR, tag, msg);
}
/**

@ -17,6 +17,7 @@
*/
package com.arialyy.aria.util;
import android.util.Log;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@ -16,6 +16,7 @@
package com.arialyy.aria.util;
import android.annotation.SuppressLint;
import android.util.Log;
import com.arialyy.aria.core.AriaManager;
import java.io.File;
import java.io.FileWriter;
@ -37,7 +38,7 @@ public class ErrorHelp {
* @param ex 异常
*/
public static void saveError(String tag, String msg, String ex) {
String message = "msg【" + msg + "】\nException:" + ex;
String message = "\nmsg【" + msg + "】\nException:" + ex;
writeLogToFile(tag, message);
}
@ -47,11 +48,9 @@ public class ErrorHelp {
* @return "/mnt/sdcard/Android/data/{package_name}/files/log/*"
*/
private static String getLogPath() {
String path = android.os.Environment.getExternalStorageDirectory().getPath()
+ "/"
+ CommonUtil.getAppPath(AriaManager.APP)
+ "/log/AriaCrash_"
+ getData("yyyy-MM-dd")
String path = CommonUtil.getAppPath(AriaManager.APP)
+ "log/AriaCrash_"
+ getData("yyyy-MM-dd_HH:mm:ss")
+ ".log";
File log = new File(path);

@ -53,8 +53,8 @@ dependencies {
compile project(':Aria')
compile project(':AriaCompiler')
// compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
// compile 'com.arialyy.aria:aria-core:3.2.13'
// annotationProcessor 'com.arialyy.aria:aria-compiler:3.2.13'
// compile 'com.arialyy.aria:aria-core:3.3.16'
// annotationProcessor 'com.arialyy.aria:aria-compiler:3.3.16'
}
repositories {
mavenCentral()

@ -15,10 +15,10 @@
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
<!--android:name=".test.TestGroupActivity"-->
<!--android:name=".MainActivity"-->
<!--android:name=".test.TestActivity"-->
<!--android:name=".test.AnyRunActivity"-->
<activity
android:name=".MainActivity"
android:name=".test.AnyRunActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

@ -80,7 +80,7 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
switch (view.getId()) {
case R.id.start:
Aria.download(this)
.load(mUrls)
.loadGroup(mUrls)
.setDirPath(
Environment.getExternalStorageDirectory().getPath() + "/Download/group_test_3")
.setGroupAlias("任务组测试")

@ -48,6 +48,6 @@ public class AnyRunActivity extends BaseActivity<ActivityTestBinding> {
@Override protected void onDestroy() {
super.onDestroy();
module.unRegist();
module.unRegister();
}
}

@ -16,9 +16,9 @@ import java.io.File;
*/
public class AnyRunnModule {
String TAG = "TestActivity";
String URL = "http://58.210.9.131/tpk/sipgt//TDLYZTGH.tpk"; //chunked 下载
String TAG = "AnyRunnModule";
private Context mContext;
private String mUrl;
public AnyRunnModule(Context context) {
Aria.download(this).register();
@ -62,17 +62,9 @@ public class AnyRunnModule {
L.d(TAG, "md5Code ==> " + CommonUtil.getFileMD5(new File(task.getDownloadPath())));
}
void start() {
Aria.download(this)
.load(URL)
.addHeader("Accept-Encoding", "gzip, deflate")
.setRequestMode(RequestEnum.GET)
.setFilePath(Environment.getExternalStorageDirectory().getPath() + "/ggsg1.apk")
.resetState()
.start();
}
void start(String url) {
mUrl = url;
Aria.download(this)
.load(url)
.addHeader("Accept-Encoding", "gzip, deflate")
@ -83,14 +75,14 @@ public class AnyRunnModule {
}
void stop() {
Aria.download(this).load(URL).stop();
Aria.download(this).load(mUrl).stop();
}
void cancel() {
Aria.download(this).load(URL).cancel();
Aria.download(this).load(mUrl).cancel();
}
void unRegist() {
void unRegister() {
Aria.download(this).unRegister();
}
}

@ -33,6 +33,7 @@ public class TestActivity extends BaseActivity<ActivityTestBinding> {
super.init(savedInstanceState);
mBar.setVisibility(View.GONE);
Aria.upload(this).register();
}
@Upload.onWait void onWait(UploadTask task) {

@ -130,10 +130,20 @@ class Configuration {
* 保存key
*/
void saveKey(String key, String value) {
boolean isDownload = this instanceof DownloadConfig;
String path = null;
switch (getType()) {
case TYPE_DOWNLOAD:
path = DOWNLOAD_CONFIG_FILE;
break;
case TYPE_UPLOAD:
path = UPLOAD_CONFIG_FILE;
break;
case TYPE_APP:
path = APP_CONFIG_FILE;
break;
}
File file = new File(
AriaManager.APP.getFilesDir().getPath() + (isDownload ? DOWNLOAD_CONFIG_FILE
: UPLOAD_CONFIG_FILE));
AriaManager.APP.getFilesDir().getPath() + path);
if (file.exists()) {
Properties properties = CommonUtil.loadConfig(file);
properties.setProperty(key, value);
@ -146,11 +156,21 @@ class Configuration {
*/
void saveAll() {
List<Field> fields = CommonUtil.getAllFields(getClass());
boolean isDownload = this instanceof DownloadConfig;
try {
String path = null;
switch (getType()) {
case TYPE_DOWNLOAD:
path = DOWNLOAD_CONFIG_FILE;
break;
case TYPE_UPLOAD:
path = UPLOAD_CONFIG_FILE;
break;
case TYPE_APP:
path = APP_CONFIG_FILE;
break;
}
File file = new File(
AriaManager.APP.getFilesDir().getPath() + (isDownload ? DOWNLOAD_CONFIG_FILE
: UPLOAD_CONFIG_FILE));
AriaManager.APP.getFilesDir().getPath() + path);
Properties properties = CommonUtil.loadConfig(file);
for (Field field : fields) {
int m = field.getModifiers();

@ -28,23 +28,23 @@ import java.util.Map;
* 上传任务实体
*/
public class UploadTaskEntity extends AbsNormalTaskEntity<UploadEntity> {
public String attachment; //文件上传需要的key
public String contentType = "multipart/form-data"; //上传的文件类型
public String userAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.6)";
private String attachment; //文件上传需要的key
private String contentType = "multipart/form-data"; //上传的文件类型
private String userAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.6)";
@Ignore public UploadEntity entity;
@Ignore private UploadEntity entity;
public String filePath = "";
private String filePath;
@Primary
@Foreign(parent = UploadEntity.class, column = "filePath",
onUpdate = ActionPolicy.CASCADE, onDelete = ActionPolicy.CASCADE)
public String key;
private String key;
/**
* 文件上传表单
*/
public Map<String, String> formFields = new HashMap<>();
private Map<String, String> formFields = new HashMap<>();
public UploadTaskEntity() {
}
@ -56,4 +56,52 @@ public class UploadTaskEntity extends AbsNormalTaskEntity<UploadEntity> {
@Override public String getKey() {
return key;
}
public void setEntity(UploadEntity entity) {
this.entity = entity;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public void setKey(String key) {
this.key = key;
}
public Map<String, String> getFormFields() {
return formFields;
}
public void setFormFields(Map<String, String> formFields) {
this.formFields = formFields;
}
public String getAttachment() {
return attachment;
}
public void setAttachment(String attachment) {
this.attachment = attachment;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public String getUserAgent() {
return userAgent;
}
public void setUserAgent(String userAgent) {
this.userAgent = userAgent;
}
}

Loading…
Cancel
Save