|
@@ -28,7 +28,7 @@ public class AliyunSiteManager {
|
|
|
|
|
|
private static final Map<String, AliYunAccount> ACCOUNT_HOLDERS = new ConcurrentHashMap<>();
|
|
private static final Map<String, AliYunAccount> ACCOUNT_HOLDERS = new ConcurrentHashMap<>();
|
|
|
|
|
|
- public static void init() {
|
|
|
|
|
|
+ public static void initSite() {
|
|
String resoucePath = PathUtil.getResoucePath("aliyun.xml");
|
|
String resoucePath = PathUtil.getResoucePath("aliyun.xml");
|
|
File file = new File(resoucePath);
|
|
File file = new File(resoucePath);
|
|
|
|
|
|
@@ -43,14 +43,23 @@ public class AliyunSiteManager {
|
|
List<AliyunSite> obj = (List<AliyunSite>) xStream.fromXML(file);
|
|
List<AliyunSite> obj = (List<AliyunSite>) xStream.fromXML(file);
|
|
list = obj;
|
|
list = obj;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- throw new StatusException("520001", "aliyun.xml is wrong", e);
|
|
|
|
|
|
+ throw new StatusException("20001", "aliyun.xml is wrong", e);
|
|
}
|
|
}
|
|
|
|
|
|
for (AliyunSite aliyunSite : list) {
|
|
for (AliyunSite aliyunSite : list) {
|
|
|
|
|
|
SITE_HOLDERS.put(aliyunSite.getId(), aliyunSite);
|
|
SITE_HOLDERS.put(aliyunSite.getId(), aliyunSite);
|
|
|
|
+ }
|
|
|
|
|
|
- String aliyunId = aliyunSite.getAliyunId();
|
|
|
|
|
|
+ }
|
|
|
|
+ public static void initClient() {
|
|
|
|
+ String aliyunNum = PropertyHolder.getString("$aliyun.site.num");
|
|
|
|
+ if (StringUtils.isBlank(aliyunNum)) {
|
|
|
|
+ throw new StatusException("20021", "aliyunNum is not configured.");
|
|
|
|
+ }
|
|
|
|
+ int num=Integer.parseInt(aliyunNum);
|
|
|
|
+ for(int i=1;i<=num;i++) {
|
|
|
|
+ String aliyunId=i+"";
|
|
String bucket = PropertyHolder.getString("$aliyun.site." + aliyunId + ".bucket");
|
|
String bucket = PropertyHolder.getString("$aliyun.site." + aliyunId + ".bucket");
|
|
String ossEndpoint = PropertyHolder.getString("$aliyun.site." + aliyunId + ".ossEndpoint");
|
|
String ossEndpoint = PropertyHolder.getString("$aliyun.site." + aliyunId + ".ossEndpoint");
|
|
|
|
|
|
@@ -60,19 +69,19 @@ public class AliyunSiteManager {
|
|
String domainBackup = PropertyHolder.getString("$aliyun.site." + aliyunId + ".domain.backup");
|
|
String domainBackup = PropertyHolder.getString("$aliyun.site." + aliyunId + ".domain.backup");
|
|
|
|
|
|
if (StringUtils.isBlank(bucket)) {
|
|
if (StringUtils.isBlank(bucket)) {
|
|
- throw new StatusException("520001", "bucket is not configured. aliyunId=" + aliyunId);
|
|
|
|
|
|
+ throw new StatusException("20001", "bucket is not configured. aliyunId=" + aliyunId);
|
|
}
|
|
}
|
|
if (StringUtils.isBlank(ossEndpoint)) {
|
|
if (StringUtils.isBlank(ossEndpoint)) {
|
|
- throw new StatusException("520002", "ossEndpoint is not configured. aliyunId=" + aliyunId);
|
|
|
|
|
|
+ throw new StatusException("20002", "ossEndpoint is not configured. aliyunId=" + aliyunId);
|
|
}
|
|
}
|
|
if (StringUtils.isBlank(accessKeyId)) {
|
|
if (StringUtils.isBlank(accessKeyId)) {
|
|
- throw new StatusException("520003", "accessKeyId is not configured. aliyunId=" + aliyunId);
|
|
|
|
|
|
+ throw new StatusException("20003", "accessKeyId is not configured. aliyunId=" + aliyunId);
|
|
}
|
|
}
|
|
if (StringUtils.isBlank(accessKeySecret)) {
|
|
if (StringUtils.isBlank(accessKeySecret)) {
|
|
- throw new StatusException("520004", "accessKeySecret is not configured. aliyunId=" + aliyunId);
|
|
|
|
|
|
+ throw new StatusException("20004", "accessKeySecret is not configured. aliyunId=" + aliyunId);
|
|
}
|
|
}
|
|
if (StringUtils.isBlank(domain)) {
|
|
if (StringUtils.isBlank(domain)) {
|
|
- throw new StatusException("520005", "domain is not configured. aliyunId=" + aliyunId);
|
|
|
|
|
|
+ throw new StatusException("20005", "domain is not configured. aliyunId=" + aliyunId);
|
|
}
|
|
}
|
|
if (null == ACCOUNT_HOLDERS.get(aliyunId)) {
|
|
if (null == ACCOUNT_HOLDERS.get(aliyunId)) {
|
|
AliYunAccount ac = new AliYunAccount(bucket, ossEndpoint, accessKeyId, accessKeySecret, domain,
|
|
AliYunAccount ac = new AliYunAccount(bucket, ossEndpoint, accessKeyId, accessKeySecret, domain,
|
|
@@ -83,11 +92,8 @@ public class AliyunSiteManager {
|
|
OSS ossClient = new OSSClientBuilder().build(ossEndpoint, accessKeyId, accessKeySecret);
|
|
OSS ossClient = new OSSClientBuilder().build(ossEndpoint, accessKeyId, accessKeySecret);
|
|
CLIENT_HOLDERS.put(aliyunId, ossClient);
|
|
CLIENT_HOLDERS.put(aliyunId, ossClient);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 方法注释
|
|
* 方法注释
|
|
*
|
|
*
|
|
@@ -99,7 +105,7 @@ public class AliyunSiteManager {
|
|
AliyunSite aliyunSite = SITE_HOLDERS.get(siteId);
|
|
AliyunSite aliyunSite = SITE_HOLDERS.get(siteId);
|
|
|
|
|
|
if (null == aliyunSite) {
|
|
if (null == aliyunSite) {
|
|
- throw new StatusException("520006", "aliyunSite is null");
|
|
|
|
|
|
+ throw new StatusException("20006", "aliyunSite is null");
|
|
}
|
|
}
|
|
return aliyunSite;
|
|
return aliyunSite;
|
|
}
|
|
}
|
|
@@ -108,7 +114,7 @@ public class AliyunSiteManager {
|
|
AliYunAccount ac = ACCOUNT_HOLDERS.get(aliyunId);
|
|
AliYunAccount ac = ACCOUNT_HOLDERS.get(aliyunId);
|
|
|
|
|
|
if (null == ac) {
|
|
if (null == ac) {
|
|
- throw new StatusException("520007", "AliYunAccount is null");
|
|
|
|
|
|
+ throw new StatusException("20007", "AliYunAccount is null");
|
|
}
|
|
}
|
|
return ac;
|
|
return ac;
|
|
}
|
|
}
|
|
@@ -117,7 +123,7 @@ public class AliyunSiteManager {
|
|
OSS oss = CLIENT_HOLDERS.get(aliyunId);
|
|
OSS oss = CLIENT_HOLDERS.get(aliyunId);
|
|
|
|
|
|
if (null == oss) {
|
|
if (null == oss) {
|
|
- throw new StatusException("520008", "aliYunClient is null");
|
|
|
|
|
|
+ throw new StatusException("20008", "aliYunClient is null");
|
|
}
|
|
}
|
|
return oss;
|
|
return oss;
|
|
}
|
|
}
|