Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_42566577
o2oa
提交
c3c715a1
o2oa
项目概览
weixin_42566577
/
o2oa
与 Fork 源项目一致
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c3c715a1
编写于
8月 12, 2022
作者:
Z
zhourui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新externalStorageSources
上级
3e964a21
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
406 addition
and
163 deletion
+406
-163
o2server/configSample/externalStorageSources.json
o2server/configSample/externalStorageSources.json
+44
-144
o2server/x_base_core_project/src/main/java/com/x/base/core/project/build/CreateConfigSample.java
...ava/com/x/base/core/project/build/CreateConfigSample.java
+2
-2
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/ExternalStorageSource.java
...com/x/base/core/project/config/ExternalStorageSource.java
+46
-0
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/ExternalStorageSources.java
...om/x/base/core/project/config/ExternalStorageSources.java
+266
-2
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/StorageMappings.java
.../java/com/x/base/core/project/config/StorageMappings.java
+46
-14
o2server/x_console/src/main/java/com/x/server/console/action/RestoreData.java
...rc/main/java/com/x/server/console/action/RestoreData.java
+2
-1
未找到文件。
o2server/configSample/externalStorageSources.json
浏览文件 @
c3c715a1
...
...
@@ -10,17 +10,7 @@
"enable"
:
true
,
"weight"
:
100.0
,
"name"
:
"251"
,
"deepPath"
:
false
,
"###protocol"
:
"协议,可选值ftp、sftp、webdav、file、hdfs、ali"
,
"###username"
:
"登录用户名.###"
,
"###password"
:
"登录密码.###"
,
"###host"
:
"主机地址.###"
,
"###port"
:
"端口.###"
,
"###prefix"
:
"前缀路径.###"
,
"###enable"
:
"是否启用###"
,
"###weight"
:
"设置权重.###"
,
"###name"
:
"存储节点名,对应存储名称,谨慎修改.###"
,
"###deepPath"
:
"是否使用更深的路径.###"
"deepPath"
:
false
}
],
"processPlatform"
:
[
...
...
@@ -34,17 +24,7 @@
"enable"
:
true
,
"weight"
:
100.0
,
"name"
:
"251"
,
"deepPath"
:
false
,
"###protocol"
:
"协议,可选值ftp、sftp、webdav、file、hdfs、ali"
,
"###username"
:
"登录用户名.###"
,
"###password"
:
"登录密码.###"
,
"###host"
:
"主机地址.###"
,
"###port"
:
"端口.###"
,
"###prefix"
:
"前缀路径.###"
,
"###enable"
:
"是否启用###"
,
"###weight"
:
"设置权重.###"
,
"###name"
:
"存储节点名,对应存储名称,谨慎修改.###"
,
"###deepPath"
:
"是否使用更深的路径.###"
"deepPath"
:
false
}
],
"mind"
:
[
...
...
@@ -58,17 +38,7 @@
"enable"
:
true
,
"weight"
:
100.0
,
"name"
:
"251"
,
"deepPath"
:
false
,
"###protocol"
:
"协议,可选值ftp、sftp、webdav、file、hdfs、ali"
,
"###username"
:
"登录用户名.###"
,
"###password"
:
"登录密码.###"
,
"###host"
:
"主机地址.###"
,
"###port"
:
"端口.###"
,
"###prefix"
:
"前缀路径.###"
,
"###enable"
:
"是否启用###"
,
"###weight"
:
"设置权重.###"
,
"###name"
:
"存储节点名,对应存储名称,谨慎修改.###"
,
"###deepPath"
:
"是否使用更深的路径.###"
"deepPath"
:
false
}
],
"meeting"
:
[
...
...
@@ -82,17 +52,7 @@
"enable"
:
true
,
"weight"
:
100.0
,
"name"
:
"251"
,
"deepPath"
:
false
,
"###protocol"
:
"协议,可选值ftp、sftp、webdav、file、hdfs、ali"
,
"###username"
:
"登录用户名.###"
,
"###password"
:
"登录密码.###"
,
"###host"
:
"主机地址.###"
,
"###port"
:
"端口.###"
,
"###prefix"
:
"前缀路径.###"
,
"###enable"
:
"是否启用###"
,
"###weight"
:
"设置权重.###"
,
"###name"
:
"存储节点名,对应存储名称,谨慎修改.###"
,
"###deepPath"
:
"是否使用更深的路径.###"
"deepPath"
:
false
}
],
"calendar"
:
[
...
...
@@ -106,17 +66,7 @@
"enable"
:
true
,
"weight"
:
100.0
,
"name"
:
"251"
,
"deepPath"
:
false
,
"###protocol"
:
"协议,可选值ftp、sftp、webdav、file、hdfs、ali"
,
"###username"
:
"登录用户名.###"
,
"###password"
:
"登录密码.###"
,
"###host"
:
"主机地址.###"
,
"###port"
:
"端口.###"
,
"###prefix"
:
"前缀路径.###"
,
"###enable"
:
"是否启用###"
,
"###weight"
:
"设置权重.###"
,
"###name"
:
"存储节点名,对应存储名称,谨慎修改.###"
,
"###deepPath"
:
"是否使用更深的路径.###"
"deepPath"
:
false
}
],
"okr"
:
[
...
...
@@ -130,17 +80,7 @@
"enable"
:
true
,
"weight"
:
100.0
,
"name"
:
"251"
,
"deepPath"
:
false
,
"###protocol"
:
"协议,可选值ftp、sftp、webdav、file、hdfs、ali"
,
"###username"
:
"登录用户名.###"
,
"###password"
:
"登录密码.###"
,
"###host"
:
"主机地址.###"
,
"###port"
:
"端口.###"
,
"###prefix"
:
"前缀路径.###"
,
"###enable"
:
"是否启用###"
,
"###weight"
:
"设置权重.###"
,
"###name"
:
"存储节点名,对应存储名称,谨慎修改.###"
,
"###deepPath"
:
"是否使用更深的路径.###"
"deepPath"
:
false
}
],
"cms"
:
[
...
...
@@ -154,17 +94,7 @@
"enable"
:
true
,
"weight"
:
100.0
,
"name"
:
"251"
,
"deepPath"
:
false
,
"###protocol"
:
"协议,可选值ftp、sftp、webdav、file、hdfs、ali"
,
"###username"
:
"登录用户名.###"
,
"###password"
:
"登录密码.###"
,
"###host"
:
"主机地址.###"
,
"###port"
:
"端口.###"
,
"###prefix"
:
"前缀路径.###"
,
"###enable"
:
"是否启用###"
,
"###weight"
:
"设置权重.###"
,
"###name"
:
"存储节点名,对应存储名称,谨慎修改.###"
,
"###deepPath"
:
"是否使用更深的路径.###"
"deepPath"
:
false
}
],
"bbs"
:
[
...
...
@@ -178,17 +108,7 @@
"enable"
:
true
,
"weight"
:
100.0
,
"name"
:
"251"
,
"deepPath"
:
false
,
"###protocol"
:
"协议,可选值ftp、sftp、webdav、file、hdfs、ali"
,
"###username"
:
"登录用户名.###"
,
"###password"
:
"登录密码.###"
,
"###host"
:
"主机地址.###"
,
"###port"
:
"端口.###"
,
"###prefix"
:
"前缀路径.###"
,
"###enable"
:
"是否启用###"
,
"###weight"
:
"设置权重.###"
,
"###name"
:
"存储节点名,对应存储名称,谨慎修改.###"
,
"###deepPath"
:
"是否使用更深的路径.###"
"deepPath"
:
false
}
],
"report"
:
[
...
...
@@ -202,17 +122,7 @@
"enable"
:
true
,
"weight"
:
100.0
,
"name"
:
"251"
,
"deepPath"
:
false
,
"###protocol"
:
"协议,可选值ftp、sftp、webdav、file、hdfs、ali"
,
"###username"
:
"登录用户名.###"
,
"###password"
:
"登录密码.###"
,
"###host"
:
"主机地址.###"
,
"###port"
:
"端口.###"
,
"###prefix"
:
"前缀路径.###"
,
"###enable"
:
"是否启用###"
,
"###weight"
:
"设置权重.###"
,
"###name"
:
"存储节点名,对应存储名称,谨慎修改.###"
,
"###deepPath"
:
"是否使用更深的路径.###"
"deepPath"
:
false
}
],
"strategyDeploy"
:
[
...
...
@@ -226,17 +136,7 @@
"enable"
:
true
,
"weight"
:
100.0
,
"name"
:
"251"
,
"deepPath"
:
false
,
"###protocol"
:
"协议,可选值ftp、sftp、webdav、file、hdfs、ali"
,
"###username"
:
"登录用户名.###"
,
"###password"
:
"登录密码.###"
,
"###host"
:
"主机地址.###"
,
"###port"
:
"端口.###"
,
"###prefix"
:
"前缀路径.###"
,
"###enable"
:
"是否启用###"
,
"###weight"
:
"设置权重.###"
,
"###name"
:
"存储节点名,对应存储名称,谨慎修改.###"
,
"###deepPath"
:
"是否使用更深的路径.###"
"deepPath"
:
false
}
],
"teamwork"
:
[
...
...
@@ -250,17 +150,7 @@
"enable"
:
true
,
"weight"
:
100.0
,
"name"
:
"251"
,
"deepPath"
:
false
,
"###protocol"
:
"协议,可选值ftp、sftp、webdav、file、hdfs、ali"
,
"###username"
:
"登录用户名.###"
,
"###password"
:
"登录密码.###"
,
"###host"
:
"主机地址.###"
,
"###port"
:
"端口.###"
,
"###prefix"
:
"前缀路径.###"
,
"###enable"
:
"是否启用###"
,
"###weight"
:
"设置权重.###"
,
"###name"
:
"存储节点名,对应存储名称,谨慎修改.###"
,
"###deepPath"
:
"是否使用更深的路径.###"
"deepPath"
:
false
}
],
"structure"
:
[
...
...
@@ -274,17 +164,21 @@
"enable"
:
true
,
"weight"
:
100.0
,
"name"
:
"251"
,
"deepPath"
:
false
,
"###protocol"
:
"协议,可选值ftp、sftp、webdav、file、hdfs、ali"
,
"###username"
:
"登录用户名.###"
,
"###password"
:
"登录密码.###"
,
"###host"
:
"主机地址.###"
,
"###port"
:
"端口.###"
,
"###prefix"
:
"前缀路径.###"
,
"###enable"
:
"是否启用###"
,
"###weight"
:
"设置权重.###"
,
"###name"
:
"存储节点名,对应存储名称,谨慎修改.###"
,
"###deepPath"
:
"是否使用更深的路径.###"
"deepPath"
:
false
}
],
"im"
:
[
{
"protocol"
:
"webdav"
,
"username"
:
"admin"
,
"password"
:
"admin"
,
"host"
:
"127.0.0.1"
,
"port"
:
8080.0
,
"prefix"
:
""
,
"enable"
:
true
,
"weight"
:
100.0
,
"name"
:
"251"
,
"deepPath"
:
false
}
],
"general"
:
[
...
...
@@ -298,17 +192,23 @@
"enable"
:
true
,
"weight"
:
100.0
,
"name"
:
"251"
,
"deepPath"
:
false
,
"###protocol"
:
"协议,可选值ftp、sftp、webdav、file、hdfs、ali"
,
"###username"
:
"登录用户名.###"
,
"###password"
:
"登录密码.###"
,
"###host"
:
"主机地址.###"
,
"###port"
:
"端口.###"
,
"###prefix"
:
"前缀路径.###"
,
"###enable"
:
"是否启用###"
,
"###weight"
:
"设置权重.###"
,
"###name"
:
"存储节点名,对应存储名称,谨慎修改.###"
,
"###deepPath"
:
"是否使用更深的路径.###"
"deepPath"
:
false
}
]
],
"custom"
:
[
{
"protocol"
:
"webdav"
,
"username"
:
"admin"
,
"password"
:
"admin"
,
"host"
:
"127.0.0.1"
,
"port"
:
8080.0
,
"prefix"
:
""
,
"enable"
:
true
,
"weight"
:
100.0
,
"name"
:
"251"
,
"deepPath"
:
false
}
],
"store"
:
{},
"###extension"
:
"扩展设置.###"
}
\ No newline at end of file
o2server/x_base_core_project/src/main/java/com/x/base/core/project/build/CreateConfigSample.java
浏览文件 @
c3c715a1
...
...
@@ -27,6 +27,7 @@ import com.x.base.core.project.config.ConfigObject;
import
com.x.base.core.project.config.Dingding
;
import
com.x.base.core.project.config.DumpRestoreData
;
import
com.x.base.core.project.config.Exmail
;
import
com.x.base.core.project.config.ExternalStorageSources
;
import
com.x.base.core.project.config.General
;
import
com.x.base.core.project.config.HuaweiPushConfig
;
import
com.x.base.core.project.config.JpushConfig
;
...
...
@@ -44,8 +45,6 @@ import com.x.base.core.project.config.WeLink;
import
com.x.base.core.project.config.WorkTime
;
import
com.x.base.core.project.config.ZhengwuDingding
;
import
com.x.base.core.project.gson.XGsonBuilder
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.tools.DefaultCharset
;
/**
...
...
@@ -69,6 +68,7 @@ public class CreateConfigSample {
classes
.
add
(
Dingding
.
class
);
classes
.
add
(
DumpRestoreData
.
class
);
classes
.
add
(
Exmail
.
class
);
classes
.
add
(
ExternalStorageSources
.
class
);
classes
.
add
(
HuaweiPushConfig
.
class
);
classes
.
add
(
JpushConfig
.
class
);
// classes.add(Meeting.class);
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/ExternalStorageSource.java
浏览文件 @
c3c715a1
...
...
@@ -9,6 +9,7 @@ import com.x.base.core.project.tools.Crypto;
/**
* 第三方附件存储配置
*
* @author sword
*/
public
class
ExternalStorageSource
extends
ConfigObject
{
...
...
@@ -46,6 +47,7 @@ public class ExternalStorageSource extends ConfigObject {
public
static
final
Boolean
DEFAULT_ENABLE
=
true
;
public
static
final
String
DEFAULT_NAME
=
"251"
;
public
static
final
Boolean
DEFAULT_DEEPPATH
=
false
;
public
static
final
String
DEFAULT_STORE
=
""
;
@FieldDescribe
(
"协议,可选值ftp、sftp、webdav、file、hdfs、ali"
)
private
StorageProtocol
protocol
;
...
...
@@ -67,6 +69,12 @@ public class ExternalStorageSource extends ConfigObject {
private
String
name
;
@FieldDescribe
(
"是否使用更深的路径."
)
private
Boolean
deepPath
;
@FieldDescribe
(
"配置名称."
)
private
String
store
;
public
String
getStore
()
{
return
StringUtils
.
isBlank
(
this
.
store
)
?
DEFAULT_STORE
:
this
.
store
;
}
public
StorageProtocol
getProtocol
()
{
return
protocol
;
...
...
@@ -111,4 +119,42 @@ public class ExternalStorageSource extends ConfigObject {
return
BooleanUtils
.
isTrue
(
this
.
deepPath
);
}
public
void
setProtocol
(
StorageProtocol
protocol
)
{
this
.
protocol
=
protocol
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
void
setHost
(
String
host
)
{
this
.
host
=
host
;
}
public
void
setPort
(
Integer
port
)
{
this
.
port
=
port
;
}
public
void
setPrefix
(
String
prefix
)
{
this
.
prefix
=
prefix
;
}
public
void
setWeight
(
Integer
weight
)
{
this
.
weight
=
weight
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
void
setStore
(
String
store
)
{
this
.
store
=
store
;
}
}
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/ExternalStorageSources.java
浏览文件 @
c3c715a1
package
com.x.base.core.project.config
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.CopyOnWriteArrayList
;
import
com.x.base.core.entity.StorageProtocol
;
import
com.x.base.core.entity.StorageType
;
import
com.x.base.core.project.annotation.FieldDescribe
;
public
class
ExternalStorageSources
extends
Con
currentHashMap
<
StorageType
,
CopyOnWriteArrayList
<
ExternalStorageSource
>>
{
public
class
ExternalStorageSources
extends
Con
figObject
{
private
static
final
long
serialVersionUID
=
8229115124625865737L
;
public
static
ExternalStorageSources
defaultInstance
()
{
ExternalStorageSources
externalStorages
=
new
ExternalStorageSources
();
externalStorages
.
getFile
();
externalStorages
.
getMind
();
externalStorages
.
getMeeting
();
externalStorages
.
getProcessPlatform
();
externalStorages
.
getCalendar
();
externalStorages
.
getOkr
();
externalStorages
.
getCms
();
externalStorages
.
getBbs
();
externalStorages
.
getReport
();
externalStorages
.
getStrategyDeploy
();
externalStorages
.
getTeamwork
();
externalStorages
.
getStructure
();
externalStorages
.
getIm
();
externalStorages
.
getGeneral
();
externalStorages
.
getCustom
();
externalStorages
.
getStore
();
return
externalStorages
;
}
public
ExternalStorageSources
()
{
super
();
}
private
CopyOnWriteArrayList
<
ExternalStorageSource
>
file
;
private
CopyOnWriteArrayList
<
ExternalStorageSource
>
processPlatform
;
private
CopyOnWriteArrayList
<
ExternalStorageSource
>
mind
;
private
CopyOnWriteArrayList
<
ExternalStorageSource
>
meeting
;
private
CopyOnWriteArrayList
<
ExternalStorageSource
>
calendar
;
private
CopyOnWriteArrayList
<
ExternalStorageSource
>
okr
;
private
CopyOnWriteArrayList
<
ExternalStorageSource
>
cms
;
private
CopyOnWriteArrayList
<
ExternalStorageSource
>
bbs
;
private
CopyOnWriteArrayList
<
ExternalStorageSource
>
report
;
private
CopyOnWriteArrayList
<
ExternalStorageSource
>
strategyDeploy
;
private
CopyOnWriteArrayList
<
ExternalStorageSource
>
teamwork
;
private
CopyOnWriteArrayList
<
ExternalStorageSource
>
structure
;
private
CopyOnWriteArrayList
<
ExternalStorageSource
>
im
;
private
CopyOnWriteArrayList
<
ExternalStorageSource
>
general
;
private
CopyOnWriteArrayList
<
ExternalStorageSource
>
custom
;
private
ConcurrentHashMap
<
String
,
Store
>
store
;
public
Map
<
String
,
Store
>
getStore
()
{
if
(
null
==
this
.
store
)
{
this
.
store
=
new
ConcurrentHashMap
<>();
}
return
this
.
store
;
}
public
List
<
ExternalStorageSource
>
get
(
StorageType
storageType
)
{
switch
(
storageType
)
{
case
file:
return
this
.
getFile
();
case
processPlatform:
return
this
.
getProcessPlatform
();
case
mind:
return
this
.
getMind
();
case
meeting:
return
this
.
getMeeting
();
case
calendar:
return
this
.
getCalendar
();
case
okr:
return
this
.
getOkr
();
case
cms:
return
this
.
getCms
();
case
bbs:
return
this
.
getBbs
();
case
report:
return
this
.
getReport
();
case
strategyDeploy:
return
this
.
getStrategyDeploy
();
case
teamwork:
return
this
.
getTeamwork
();
case
structure:
return
this
.
getStructure
();
case
im:
return
this
.
getIm
();
case
general:
return
this
.
getGeneral
();
case
custom:
default
:
return
this
.
getCustom
();
}
}
public
List
<
ExternalStorageSource
>
getFile
()
{
if
(
null
==
this
.
file
)
{
this
.
file
=
new
CopyOnWriteArrayList
<>();
this
.
file
.
add
(
new
ExternalStorageSource
());
}
return
this
.
file
;
}
public
List
<
ExternalStorageSource
>
getMind
()
{
if
(
null
==
this
.
mind
)
{
this
.
mind
=
new
CopyOnWriteArrayList
<>();
this
.
mind
.
add
(
new
ExternalStorageSource
());
}
return
this
.
mind
;
}
public
List
<
ExternalStorageSource
>
getMeeting
()
{
if
(
null
==
this
.
meeting
)
{
this
.
meeting
=
new
CopyOnWriteArrayList
<>();
this
.
meeting
.
add
(
new
ExternalStorageSource
());
}
return
this
.
meeting
;
}
public
List
<
ExternalStorageSource
>
getProcessPlatform
()
{
if
(
null
==
this
.
processPlatform
)
{
this
.
processPlatform
=
new
CopyOnWriteArrayList
<>();
this
.
processPlatform
.
add
(
new
ExternalStorageSource
());
}
return
this
.
processPlatform
;
}
public
List
<
ExternalStorageSource
>
getCalendar
()
{
if
(
null
==
this
.
calendar
)
{
this
.
calendar
=
new
CopyOnWriteArrayList
<>();
this
.
calendar
.
add
(
new
ExternalStorageSource
());
}
return
this
.
calendar
;
}
public
List
<
ExternalStorageSource
>
getOkr
()
{
if
(
null
==
this
.
okr
)
{
this
.
okr
=
new
CopyOnWriteArrayList
<>();
this
.
okr
.
add
(
new
ExternalStorageSource
());
}
return
this
.
okr
;
}
public
List
<
ExternalStorageSource
>
getCms
()
{
if
(
null
==
this
.
cms
)
{
this
.
cms
=
new
CopyOnWriteArrayList
<>();
this
.
cms
.
add
(
new
ExternalStorageSource
());
}
return
this
.
cms
;
}
public
List
<
ExternalStorageSource
>
getBbs
()
{
if
(
null
==
this
.
bbs
)
{
this
.
bbs
=
new
CopyOnWriteArrayList
<>();
this
.
bbs
.
add
(
new
ExternalStorageSource
());
}
return
this
.
bbs
;
}
public
List
<
ExternalStorageSource
>
getReport
()
{
if
(
null
==
this
.
report
)
{
this
.
report
=
new
CopyOnWriteArrayList
<>();
this
.
report
.
add
(
new
ExternalStorageSource
());
}
return
this
.
report
;
}
public
List
<
ExternalStorageSource
>
getStrategyDeploy
()
{
if
(
null
==
this
.
strategyDeploy
)
{
this
.
strategyDeploy
=
new
CopyOnWriteArrayList
<>();
this
.
strategyDeploy
.
add
(
new
ExternalStorageSource
());
}
return
this
.
strategyDeploy
;
}
public
List
<
ExternalStorageSource
>
getTeamwork
()
{
if
(
null
==
this
.
teamwork
)
{
this
.
teamwork
=
new
CopyOnWriteArrayList
<>();
this
.
teamwork
.
add
(
new
ExternalStorageSource
());
}
return
this
.
teamwork
;
}
public
List
<
ExternalStorageSource
>
getStructure
()
{
if
(
null
==
this
.
structure
)
{
this
.
structure
=
new
CopyOnWriteArrayList
<>();
this
.
structure
.
add
(
new
ExternalStorageSource
());
}
return
this
.
structure
;
}
public
List
<
ExternalStorageSource
>
getIm
()
{
if
(
null
==
this
.
im
)
{
this
.
im
=
new
CopyOnWriteArrayList
<>();
this
.
im
.
add
(
new
ExternalStorageSource
());
}
return
this
.
im
;
}
public
List
<
ExternalStorageSource
>
getGeneral
()
{
if
(
null
==
this
.
general
)
{
this
.
general
=
new
CopyOnWriteArrayList
<>();
this
.
general
.
add
(
new
ExternalStorageSource
());
}
return
this
.
general
;
}
public
List
<
ExternalStorageSource
>
getCustom
()
{
if
(
null
==
this
.
custom
)
{
this
.
custom
=
new
CopyOnWriteArrayList
<>();
this
.
custom
.
add
(
new
ExternalStorageSource
());
}
return
this
.
custom
;
}
public
static
class
Store
{
private
StorageProtocol
protocol
;
@FieldDescribe
(
"登录用户名."
)
private
String
username
;
@FieldDescribe
(
"登录密码."
)
private
String
password
;
@FieldDescribe
(
"主机地址或阿里云endpoint."
)
private
String
host
;
@FieldDescribe
(
"端口."
)
private
Integer
port
;
@FieldDescribe
(
"存储节点名,对应存储名称,阿里云为bucket(桶)名称."
)
private
String
name
;
public
StorageProtocol
getProtocol
()
{
return
protocol
;
}
public
void
setProtocol
(
StorageProtocol
protocol
)
{
this
.
protocol
=
protocol
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getHost
()
{
return
host
;
}
public
void
setHost
(
String
host
)
{
this
.
host
=
host
;
}
public
Integer
getPort
()
{
return
port
;
}
public
void
setPort
(
Integer
port
)
{
this
.
port
=
port
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
}
}
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/StorageMappings.java
浏览文件 @
c3c715a1
package
com.x.base.core.project.config
;
import
java.security.SecureRandom
;
import
java.util.Random
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.CopyOnWriteArrayList
;
...
...
@@ -17,20 +18,52 @@ public class StorageMappings extends ConcurrentHashMap<StorageType, CopyOnWriteA
private
static
final
long
serialVersionUID
=
2056028069887353406L
;
private
Random
random
=
new
SecureRandom
();
public
StorageMappings
()
{
super
();
}
// public StorageMappings(ExternalStorageSources externalStorageSources) {
// for (Entry<StorageType, CopyOnWriteArrayList<ExternalStorageSource>> entry : externalStorageSources
// .entrySet()) {
// CopyOnWriteArrayList<StorageMapping> list = new CopyOnWriteArrayList<>();
// for (ExternalStorageSource externalStorageSource : entry.getValue()) {
// if (BooleanUtils.isTrue(externalStorageSource.getEnable())) {
// StorageMapping storageMapping = new StorageMapping(externalStorageSource);
// list.add(storageMapping);
// }
// this.put(entry.getKey(), list);
// }
// }
// }
public
StorageMappings
(
ExternalStorageSources
externalStorageSources
)
{
for
(
Entry
<
StorageType
,
CopyOnWriteArrayList
<
ExternalStorageSource
>>
entry
:
externalStorageSources
.
entrySet
())
{
for
(
StorageType
o
:
StorageType
.
values
())
{
CopyOnWriteArrayList
<
StorageMapping
>
list
=
new
CopyOnWriteArrayList
<>();
for
(
ExternalStorageSource
externalStorageSource
:
e
ntry
.
getValue
(
))
{
for
(
ExternalStorageSource
externalStorageSource
:
e
xternalStorageSources
.
get
(
o
))
{
if
(
BooleanUtils
.
isTrue
(
externalStorageSource
.
getEnable
()))
{
fillWithStore
(
externalStorageSources
,
externalStorageSource
);
StorageMapping
storageMapping
=
new
StorageMapping
(
externalStorageSource
);
list
.
add
(
storageMapping
);
}
this
.
put
(
entry
.
getKey
(),
list
);
}
this
.
put
(
o
,
list
);
}
}
private
void
fillWithStore
(
ExternalStorageSources
externalStorageSources
,
ExternalStorageSource
externalStorageSource
)
{
String
key
=
externalStorageSource
.
getStore
();
if
(
StringUtils
.
isNotBlank
(
key
))
{
ExternalStorageSources
.
Store
store
=
externalStorageSources
.
getStore
().
get
(
key
);
if
(
null
!=
store
)
{
externalStorageSource
.
setHost
(
store
.
getHost
());
externalStorageSource
.
setName
(
store
.
getName
());
externalStorageSource
.
setPassword
(
store
.
getPassword
());
externalStorageSource
.
setUsername
(
store
.
getUsername
());
externalStorageSource
.
setPort
(
store
.
getPort
());
externalStorageSource
.
setProtocol
(
store
.
getProtocol
());
}
}
}
...
...
@@ -39,7 +72,7 @@ public class StorageMappings extends ConcurrentHashMap<StorageType, CopyOnWriteA
super
();
/** 填充空值 */
for
(
StorageType
o
:
StorageType
.
values
())
{
this
.
put
(
o
,
new
CopyOnWriteArrayList
<
StorageMapping
>());
this
.
put
(
o
,
new
CopyOnWriteArrayList
<>());
}
StorageServers
storageServers
=
nodeConfigs
.
storageServers
();
for
(
Entry
<
String
,
StorageServer
>
en
:
storageServers
.
entrySet
())
{
...
...
@@ -62,20 +95,20 @@ public class StorageMappings extends ConcurrentHashMap<StorageType, CopyOnWriteA
}
}
private
<
T
extends
StorageObject
>
StorageType
getStorageType
(
Class
<
T
>
clz
)
throws
Exception
{
private
<
T
extends
StorageObject
>
StorageType
getStorageType
(
Class
<
T
>
clz
)
{
Storage
o
=
clz
.
getAnnotation
(
Storage
.
class
);
if
(
null
==
o
)
{
throw
new
Exception
(
throw
new
IllegalState
Exception
(
"can not find "
+
Storage
.
class
.
getName
()
+
" annotation in class: "
+
clz
.
getName
()
+
"."
);
}
StorageType
type
=
o
.
type
();
if
(
null
==
type
)
{
throw
new
Exception
(
"can not find storageType in class: "
+
clz
.
getName
()
+
"."
);
throw
new
IllegalState
Exception
(
"can not find storageType in class: "
+
clz
.
getName
()
+
"."
);
}
return
type
;
}
public
<
T
extends
StorageObject
>
StorageMapping
get
(
Class
<
T
>
clz
,
String
name
)
throws
Exception
{
public
<
T
extends
StorageObject
>
StorageMapping
get
(
Class
<
T
>
clz
,
String
name
)
{
StorageType
type
=
this
.
getStorageType
(
clz
);
return
this
.
get
(
type
,
name
);
}
...
...
@@ -94,18 +127,17 @@ public class StorageMappings extends ConcurrentHashMap<StorageType, CopyOnWriteA
return
storageMapping
;
}
public
<
T
extends
StorageObject
>
StorageMapping
random
(
Class
<
T
>
clz
)
throws
Exception
{
public
<
T
extends
StorageObject
>
StorageMapping
random
(
Class
<
T
>
clz
)
{
StorageType
type
=
this
.
getStorageType
(
clz
);
return
this
.
random
(
type
);
}
private
StorageMapping
random
(
StorageType
type
)
throws
Exception
{
private
StorageMapping
random
(
StorageType
type
)
{
CopyOnWriteArrayList
<
StorageMapping
>
list
=
this
.
get
(
type
);
if
(
ListTools
.
isEmpty
(
list
))
{
throw
new
Exception
(
"can not get storage of "
+
type
);
throw
new
IllegalState
Exception
(
"can not get storage of "
+
type
);
}
int
total
=
0
;
Random
random
=
new
Random
();
for
(
StorageMapping
o
:
list
)
{
total
+=
o
.
getWeight
();
}
...
...
@@ -117,6 +149,6 @@ public class StorageMappings extends ConcurrentHashMap<StorageType, CopyOnWriteA
return
o
;
}
}
throw
new
Exception
(
"randomWithWeight error can not get available storage."
);
throw
new
IllegalState
Exception
(
"randomWithWeight error can not get available storage."
);
}
}
\ No newline at end of file
o2server/x_console/src/main/java/com/x/server/console/action/RestoreData.java
浏览文件 @
c3c715a1
...
...
@@ -265,7 +265,8 @@ public class RestoreData {
if
(
ListTools
.
isNotEmpty
(
list
))
{
em
.
getTransaction
().
begin
();
for
(
T
t
:
list
)
{
if
(
StorageObject
.
class
.
isAssignableFrom
(
cls
))
{
if
(
BooleanUtils
.
isTrue
(
Config
.
dumpRestoreData
().
getAttachStorage
())
&&
StorageObject
.
class
.
isAssignableFrom
(
cls
))
{
StorageObject
so
=
(
StorageObject
)
t
;
@SuppressWarnings
(
"unchecked"
)
StorageMapping
mapping
=
storageMappings
.
get
((
Class
<
StorageObject
>)
cls
,
so
.
getStorage
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录