This commit is contained in:
parent
f1920c54f0
commit
e51fb4fc96
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
|||
</parent>
|
||||
<groupId>com.github.zxbu</groupId>
|
||||
<artifactId>webdav-teambition</artifactId>
|
||||
<version>0.0.2-SNAPSHOT</version>
|
||||
<version>1.0.0</version>
|
||||
<name>webdav-teambition</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.github.zxbu.webdavteambition.client;
|
|||
|
||||
import com.github.zxbu.webdavteambition.config.TeambitionProperties;
|
||||
import com.github.zxbu.webdavteambition.util.JsonUtil;
|
||||
import net.sf.webdav.exceptions.WebdavException;
|
||||
import okhttp3.*;
|
||||
import okio.BufferedSink;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -69,7 +70,7 @@ public class TeambitionClient {
|
|||
response = okHttpClient.newCall(request).execute();
|
||||
return response.body().byteStream();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new WebdavException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,10 +82,10 @@ public class TeambitionClient {
|
|||
LOGGER.info("post {}, code {}", url, response.code());
|
||||
if (!response.isSuccessful()) {
|
||||
LOGGER.error("请求失败,url={}, code={}, body={}", url, response.code(), response.body().string());
|
||||
throw new RuntimeException("请求失败:" + url);
|
||||
throw new WebdavException("请求失败:" + url);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new WebdavException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,11 +97,11 @@ public class TeambitionClient {
|
|||
LOGGER.info("post {}, code {}", url, response.code());
|
||||
if (!response.isSuccessful()) {
|
||||
LOGGER.error("请求失败,url={}, code={}, body={}", url, response.code(), response.body().string());
|
||||
throw new RuntimeException("请求失败:" + url);
|
||||
throw new WebdavException("请求失败:" + url);
|
||||
}
|
||||
return toString(response.body());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new WebdavException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,11 +113,11 @@ public class TeambitionClient {
|
|||
LOGGER.info("put {}, code {}", url, response.code());
|
||||
if (!response.isSuccessful()) {
|
||||
LOGGER.error("请求失败,url={}, code={}, body={}", url, response.code(), response.body().string());
|
||||
throw new RuntimeException("请求失败:" + url);
|
||||
throw new WebdavException("请求失败:" + url);
|
||||
}
|
||||
return toString(response.body());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new WebdavException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,13 +130,13 @@ public class TeambitionClient {
|
|||
try (Response response = okHttpClient.newCall(request).execute()){
|
||||
LOGGER.info("get {}, code {}", urlBuilder.build(), response.code());
|
||||
if (!response.isSuccessful()) {
|
||||
throw new RuntimeException("请求失败:" + urlBuilder.build().toString());
|
||||
throw new WebdavException("请求失败:" + urlBuilder.build().toString());
|
||||
}
|
||||
return toString(response.body());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new WebdavException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.github.zxbu.webdavteambition.model.result.ListResult;
|
|||
import com.github.zxbu.webdavteambition.model.result.TFile;
|
||||
import com.github.zxbu.webdavteambition.model.result.UploadPreResult;
|
||||
import com.github.zxbu.webdavteambition.util.JsonUtil;
|
||||
import net.sf.webdav.exceptions.WebdavException;
|
||||
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -83,7 +84,7 @@ public class TeambitionClientService {
|
|||
});
|
||||
return stringMap;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new WebdavException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,7 +130,7 @@ public class TeambitionClientService {
|
|||
LOGGER.info("文件正在上传。文件名:{},当前进度:{}/{}", path, (i+1), uploadUrl.size());
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new WebdavException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.github.zxbu.webdavteambition.model.result.TFile;
|
|||
import net.sf.webdav.ITransaction;
|
||||
import net.sf.webdav.IWebdavStore;
|
||||
import net.sf.webdav.StoredObject;
|
||||
import net.sf.webdav.exceptions.WebdavException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
@ -140,7 +141,7 @@ public class TeambitionFileSystemStore implements IWebdavStore {
|
|||
teambitionClientService.move(sourcePath, destinationPathInfo.getParentPath());
|
||||
} else {
|
||||
if (!destinationPathInfo.getParentPath().equals(sourcePathInfo.getParentPath())) {
|
||||
throw new RuntimeException("不支持目录和名字同时修改");
|
||||
throw new WebdavException("不支持目录和名字同时修改");
|
||||
}
|
||||
// 名字不同,说明是修改名字。不考虑目录和名字同时修改的情况
|
||||
teambitionClientService.rename(sourcePath, destinationPathInfo.getName());
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package com.github.zxbu.webdavteambition.util;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import net.sf.webdav.exceptions.WebdavException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -20,7 +19,7 @@ public class JsonUtil {
|
|||
try {
|
||||
return objectMapper.writeValueAsString(o);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new WebdavException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +27,7 @@ public class JsonUtil {
|
|||
try {
|
||||
return objectMapper.readValue(json, valueTypeRef);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new WebdavException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +36,7 @@ public class JsonUtil {
|
|||
try {
|
||||
return objectMapper.readValue(json, valueType);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new WebdavException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +64,7 @@ public class JsonUtil {
|
|||
}
|
||||
return objectMapper.treeToValue(jsonNode, Object.class);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new WebdavException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +114,7 @@ public class JsonUtil {
|
|||
try {
|
||||
return objectMapper.readTree(responseBody);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new WebdavException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue