Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
20a44c3f
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
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,发现更多精彩内容 >>
提交
20a44c3f
编写于
8月 27, 2020
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新版应用市场优化
上级
be88078e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
103 addition
and
22 deletion
+103
-22
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionInstallOrUpdate.java
.../x/program/center/jaxrs/market/ActionInstallOrUpdate.java
+58
-15
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionUninstall.java
...va/com/x/program/center/jaxrs/market/ActionUninstall.java
+11
-7
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/BaseAction.java
...in/java/com/x/program/center/jaxrs/market/BaseAction.java
+34
-0
未找到文件。
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionInstallOrUpdate.java
浏览文件 @
20a44c3f
...
...
@@ -10,21 +10,20 @@ import com.x.base.core.project.annotation.FieldDescribe;
import
com.x.base.core.project.bean.NameValuePair
;
import
com.x.base.core.project.config.Collect
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.config.Nodes
;
import
com.x.base.core.project.connection.CipherConnectionAction
;
import
com.x.base.core.project.connection.ConnectionAction
;
import
com.x.base.core.project.exception.ExceptionAccessDenied
;
import
com.x.base.core.project.exception.ExceptionEntityNotExist
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
import
com.x.base.core.project.gson.XGsonBuilder
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.WoId
;
import
com.x.base.core.project.jaxrs.WrapBoolean
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.tools.DefaultCharset
;
import
com.x.base.core.project.tools.FileTools
;
import
com.x.base.core.project.tools.JarTools
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.base.core.project.tools.*
;
import
com.x.cms.core.entity.element.wrap.WrapCms
;
import
com.x.portal.core.entity.wrap.WrapPortal
;
import
com.x.processplatform.core.entity.element.wrap.WrapProcessPlatform
;
...
...
@@ -41,11 +40,12 @@ import org.apache.commons.io.FileUtils;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.ByteArrayInputStream
;
import
java.io.DataInputStream
;
import
java.io.DataOutputStream
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.UUID
;
import
java.net.Socket
;
import
java.util.*
;
class
ActionInstallOrUpdate
extends
BaseAction
{
...
...
@@ -71,8 +71,8 @@ class ActionInstallOrUpdate extends BaseAction {
byte
[]
bytes
=
ConnectionAction
.
getFile
(
Config
.
collect
().
url
(
Collect
.
ADDRESS_COLLECT_APPLICATION_DOWN
+
"/"
+
id
),
ListTools
.
toList
(
new
NameValuePair
(
Collect
.
COLLECT_TOKEN
,
token
)));
if
(
bytes
!=
null
){
WrapModule
module
=
this
.
install
(
id
,
bytes
);
if
(
module
!=
null
)
{
InstallData
installData
=
this
.
install
(
id
,
bytes
);
if
(
installData
!=
null
)
{
wo
.
setValue
(
true
);
emc
.
beginTransaction
(
InstallLog
.
class
);
InstallLog
installLog
=
emc
.
find
(
id
,
InstallLog
.
class
);
...
...
@@ -86,7 +86,7 @@ class ActionInstallOrUpdate extends BaseAction {
installLog
.
setVersion
(
app
.
getVersion
());
installLog
.
setCategory
(
app
.
getCategory
());
installLog
.
setStatus
(
CommonStatus
.
VALID
.
getValue
());
installLog
.
setData
(
gson
.
toJson
(
module
));
installLog
.
setData
(
gson
.
toJson
(
installData
));
installLog
.
setInstallPerson
(
effectivePerson
.
getDistinguishedName
());
installLog
.
setInstallTime
(
new
Date
());
installLog
.
setUnInstallPerson
(
null
);
...
...
@@ -105,8 +105,8 @@ class ActionInstallOrUpdate extends BaseAction {
}
}
private
WrapModule
install
(
String
id
,
byte
[]
bytes
)
throws
Exception
{
WrapModule
module
=
null
;
private
InstallData
install
(
String
id
,
byte
[]
bytes
)
throws
Exception
{
InstallData
installData
=
new
InstallData
()
;
File
tempFile
=
new
File
(
Config
.
base
(),
"local/temp/install"
);
FileTools
.
forceMkdir
(
tempFile
);
FileUtils
.
cleanDirectory
(
tempFile
);
...
...
@@ -123,21 +123,30 @@ class ActionInstallOrUpdate extends BaseAction {
String
json
=
FileUtils
.
readFileToString
(
file
,
DefaultCharset
.
charset
);
Gson
gson
=
new
Gson
();
JsonElement
jsonElement
=
gson
.
fromJson
(
json
,
JsonElement
.
class
);
module
=
this
.
convertToWrapIn
(
jsonElement
,
WrapModule
.
class
);
WrapModule
module
=
this
.
convertToWrapIn
(
jsonElement
,
WrapModule
.
class
);
this
.
installModule
(
module
);
installData
.
setWrapModule
(
module
);
}
if
(
file
.
getName
().
toLowerCase
().
endsWith
(
".zip"
)){
logger
.
print
(
"开始安装静态资源"
);
try
{
Business
.
dispatch
(
false
,
file
.
getName
(),
""
,
FileUtils
.
readFileToByteArray
(
file
));
installData
.
setStaticResource
(
file
.
getName
());
}
catch
(
Exception
e
)
{
logger
.
print
(
"模块安装成功但静态资源安装失败:{}"
,
e
.
getMessage
());
}
}
if
(
file
.
getName
().
toLowerCase
().
endsWith
(
".war"
)){
logger
.
print
(
"开始安装自定义应用:{}"
,
file
.
getName
());
this
.
installCustomApp
(
file
.
getName
(),
FileUtils
.
readFileToByteArray
(
file
));
installData
.
setCustomApp
(
file
.
getName
());
logger
.
print
(
"完成自定义应用安装:{}"
,
file
.
getName
());
}
}
}
FileUtils
.
cleanDirectory
(
tempFile
);
return
module
;
return
installData
;
}
private
InstallWo
installModule
(
WrapModule
module
)
throws
Exception
{
...
...
@@ -225,6 +234,40 @@ class ActionInstallOrUpdate extends BaseAction {
return
wo
;
}
private
void
installCustomApp
(
String
fileName
,
byte
[]
bytes
)
throws
Exception
{
Nodes
nodes
=
Config
.
nodes
();
for
(
String
node
:
nodes
.
keySet
()){
if
(
nodes
.
get
(
node
).
getApplication
().
getEnable
())
{
logger
.
print
(
"socket deploy custom app{} to {}:{}"
,
fileName
,
node
,
nodes
.
get
(
node
).
nodeAgentPort
());
try
(
Socket
socket
=
new
Socket
(
node
,
nodes
.
get
(
node
).
nodeAgentPort
()))
{
socket
.
setKeepAlive
(
true
);
socket
.
setSoTimeout
(
10000
);
try
(
DataOutputStream
dos
=
new
DataOutputStream
(
socket
.
getOutputStream
());
DataInputStream
dis
=
new
DataInputStream
(
socket
.
getInputStream
()))
{
Map
<
String
,
Object
>
commandObject
=
new
HashMap
<>();
commandObject
.
put
(
"command"
,
"redeploy:customWar"
);
commandObject
.
put
(
"credential"
,
Crypto
.
rsaEncrypt
(
"o2@"
,
Config
.
publicKey
()));
dos
.
writeUTF
(
XGsonBuilder
.
toJson
(
commandObject
));
dos
.
flush
();
dos
.
writeUTF
(
fileName
);
dos
.
flush
();
try
(
ByteArrayInputStream
bis
=
new
ByteArrayInputStream
(
bytes
))
{
byte
[]
onceBytes
=
new
byte
[
1024
];
int
length
=
0
;
while
((
length
=
bis
.
read
(
onceBytes
,
0
,
onceBytes
.
length
))
!=
-
1
)
{
dos
.
write
(
onceBytes
,
0
,
length
);
dos
.
flush
();
}
}
}
}
}
}
}
public
static
class
Wo
extends
WrapBoolean
{
}
...
...
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionUninstall.java
浏览文件 @
20a44c3f
...
...
@@ -47,13 +47,17 @@ class ActionUninstall extends BaseAction {
}
logger
.
print
(
"{}发起卸载应用:{}"
,
effectivePerson
.
getDistinguishedName
(),
app
.
getName
());
Wo
wo
=
new
Wo
();
WrapModule
module
=
gson
.
fromJson
(
installLog
.
getData
(),
WrapModule
.
class
);
this
.
uninstall
(
module
);
emc
.
beginTransaction
(
InstallLog
.
class
);
installLog
.
setStatus
(
CommonStatus
.
INVALID
.
getValue
());
installLog
.
setUnInstallPerson
(
effectivePerson
.
getDistinguishedName
());
installLog
.
setUnInstallTime
(
new
Date
());
emc
.
commit
();
InstallData
installData
=
gson
.
fromJson
(
installLog
.
getData
(),
InstallData
.
class
);
WrapModule
module
=
installData
.
getWrapModule
();
if
(
module
!=
null
)
{
this
.
uninstall
(
module
);
emc
.
beginTransaction
(
InstallLog
.
class
);
installLog
.
setStatus
(
CommonStatus
.
INVALID
.
getValue
());
installLog
.
setUnInstallPerson
(
effectivePerson
.
getDistinguishedName
());
installLog
.
setUnInstallTime
(
new
Date
());
emc
.
commit
();
}
wo
.
setValue
(
true
);
result
.
setData
(
wo
);
return
result
;
...
...
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/BaseAction.java
浏览文件 @
20a44c3f
package
com.x.program.center.jaxrs.market
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.StandardJaxrsAction
;
import
com.x.program.center.WrapModule
;
abstract
class
BaseAction
extends
StandardJaxrsAction
{
...
...
@@ -15,4 +17,36 @@ abstract class BaseAction extends StandardJaxrsAction {
return
false
;
}
public
static
class
InstallData
extends
GsonPropertyObject
{
private
WrapModule
WrapModule
;
private
String
staticResource
;
private
String
customApp
;
public
com
.
x
.
program
.
center
.
WrapModule
getWrapModule
()
{
return
WrapModule
;
}
public
void
setWrapModule
(
com
.
x
.
program
.
center
.
WrapModule
wrapModule
)
{
WrapModule
=
wrapModule
;
}
public
String
getStaticResource
()
{
return
staticResource
;
}
public
void
setStaticResource
(
String
staticResource
)
{
this
.
staticResource
=
staticResource
;
}
public
String
getCustomApp
()
{
return
customApp
;
}
public
void
setCustomApp
(
String
customApp
)
{
this
.
customApp
=
customApp
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录