Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fuyue82
o2oa
提交
45342b5e
o2oa
项目概览
fuyue82
/
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,发现更多精彩内容 >>
提交
45342b5e
编写于
4月 01, 2020
作者:
O
o2null
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/update_remove_password' into 'develop'
升级命令去掉口令验证 See merge request o2oa/o2oa!174
上级
484a5c68
b48bec52
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
16 addition
and
203 deletion
+16
-203
o2server/x_console/src/main/java/com/x/server/console/CommandFactory.java
...le/src/main/java/com/x/server/console/CommandFactory.java
+3
-3
o2server/x_console/src/main/java/com/x/server/console/Main.java
...er/x_console/src/main/java/com/x/server/console/Main.java
+4
-4
o2server/x_console/src/main/java/com/x/server/console/action/ActionUpdate.java
...c/main/java/com/x/server/console/action/ActionUpdate.java
+0
-185
o2server/x_console/src/main/java/com/x/server/console/action/UpdateFile.java
...src/main/java/com/x/server/console/action/UpdateFile.java
+9
-11
未找到文件。
o2server/x_console/src/main/java/com/x/server/console/CommandFactory.java
浏览文件 @
45342b5e
...
...
@@ -48,7 +48,7 @@ public class CommandFactory {
public
static
final
Pattern
exit_pattern
=
Pattern
.
compile
(
"^ {0,}exit {0,}$"
,
Pattern
.
CASE_INSENSITIVE
);
public
static
final
Pattern
updateFile_pattern
=
Pattern
.
compile
(
"^ {0,}update file (.+) (true|false)
(.+)
$"
,
public
static
final
Pattern
updateFile_pattern
=
Pattern
.
compile
(
"^ {0,}update file (.+) (true|false)
{0,}
$"
,
Pattern
.
CASE_INSENSITIVE
);
public
static
final
Pattern
version_pattern
=
Pattern
.
compile
(
"^ {0,}version {0,}$"
,
Pattern
.
CASE_INSENSITIVE
);
...
...
@@ -84,7 +84,7 @@ public class CommandFactory {
public
static
void
printHelpLine
()
{
try
{
String
help
=
""
;
help
+=
" help show us
e
age message."
;
help
+=
" help show usage message."
;
help
+=
StringUtils
.
LF
;
help
+=
" start|stop [all] start stop all enable server."
;
help
+=
StringUtils
.
LF
;
...
...
@@ -110,7 +110,7 @@ public class CommandFactory {
// help += StringUtils.LF;
help
+=
" setPassword (oldpasswd) (newpasswd) change initial manager password."
;
help
+=
StringUtils
.
LF
;
help
+=
" update file (path) (backup)
(passwd)
upgrade to new version from local zip file."
;
help
+=
" update file (path) (backup)
upgrade to new version from local zip file."
;
help
+=
StringUtils
.
LF
;
// help += " compact data (passwd) compact local h2 repository database.";
// help += StringUtils.LF;
...
...
o2server/x_console/src/main/java/com/x/server/console/Main.java
浏览文件 @
45342b5e
...
...
@@ -38,7 +38,7 @@ import com.x.server.console.action.ActionConfig;
import
com.x.server.console.action.ActionCreateEncryptKey
;
import
com.x.server.console.action.ActionDebugDesignDetail
;
import
com.x.server.console.action.ActionSetPassword
;
import
com.x.server.console.action.
Action
UpdateFile
;
import
com.x.server.console.action.UpdateFile
;
import
com.x.server.console.action.ActionVersion
;
import
com.x.server.console.log.LogTools
;
import
com.x.server.console.server.Servers
;
...
...
@@ -260,7 +260,7 @@ public class Main {
matcher
=
CommandFactory
.
updateFile_pattern
.
matcher
(
cmd
);
if
(
matcher
.
find
())
{
if
(
updateFile
(
matcher
.
group
(
1
),
matcher
.
group
(
2
)
,
matcher
.
group
(
3
)
))
{
if
(
updateFile
(
matcher
.
group
(
1
),
matcher
.
group
(
2
)))
{
stopAll
();
System
.
exit
(
0
);
}
else
{
...
...
@@ -329,9 +329,9 @@ public class Main {
return
true
;
}
private
static
boolean
updateFile
(
String
path
,
String
backup
,
String
password
)
{
private
static
boolean
updateFile
(
String
path
,
String
backup
)
{
try
{
return
new
ActionUpdateFile
().
execute
(
path
,
BooleanUtils
.
toBoolean
(
backup
),
password
);
return
new
UpdateFile
().
execute
(
path
,
BooleanUtils
.
toBoolean
(
backup
)
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
o2server/x_console/src/main/java/com/x/server/console/action/ActionUpdate.java
已删除
100644 → 0
浏览文件 @
484a5c68
package
com.x.server.console.action
;
import
java.io.File
;
import
java.io.FileFilter
;
import
java.io.InputStream
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.io.filefilter.RegexFileFilter
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.gson.XGsonBuilder
;
import
com.x.base.core.project.http.HttpMediaType
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.tools.DateTools
;
import
com.x.base.core.project.tools.JarTools
;
public
class
ActionUpdate
extends
ActionBase
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionUpdate
.
class
);
private
Date
start
;
private
void
init
()
throws
Exception
{
this
.
start
=
new
Date
();
}
private
static
final
String
LATEST
=
"latest"
;
public
boolean
execute
(
String
password
,
boolean
backup
,
boolean
latest
)
{
try
{
this
.
init
();
if
(!
StringUtils
.
equals
(
Config
.
token
().
getPassword
(),
password
))
{
logger
.
print
(
"password not mactch."
);
return
false
;
}
WrapUpdateVersion
wrapUpdateVersion
=
this
.
get
(
latest
);
if
(
StringUtils
.
equals
(
LATEST
,
wrapUpdateVersion
.
getVersion
()))
{
logger
.
print
(
"already the latest version."
);
return
false
;
}
else
{
if
(
backup
)
{
this
.
backup
();
}
File
file
=
this
.
getPack
(
wrapUpdateVersion
.
getUrl
());
this
.
unzip
(
file
);
logger
.
print
(
"update completed in {} seconds, restart server to continue update."
,
((
new
Date
()).
getTime
()
-
start
.
getTime
())
/
1000
);
FileUtils
.
forceDelete
(
file
);
return
true
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
private
void
backup
()
throws
Exception
{
File
dir
=
Config
.
dir_local_backup
(
true
);
String
tag
=
DateTools
.
compact
(
new
Date
());
File
dest
=
new
File
(
dir
,
tag
+
".zip"
);
logger
.
print
(
"backup current version to {}."
,
dest
.
getAbsolutePath
());
List
<
File
>
files
=
new
ArrayList
<>();
files
.
add
(
Config
.
dir_commons
());
files
.
add
(
Config
.
dir_config
());
files
.
add
(
Config
.
dir_configSample
());
files
.
add
(
Config
.
dir_localSample
());
files
.
add
(
Config
.
dir_jvm
());
files
.
add
(
Config
.
dir_servers
());
files
.
add
(
Config
.
dir_store
());
files
.
add
(
Config
.
dir_dynamic
());
files
.
add
(
Config
.
dir_custom
());
files
.
add
(
new
File
(
Config
.
base
(),
"console.jar"
));
files
.
add
(
new
File
(
Config
.
base
(),
"index.html"
));
files
.
add
(
new
File
(
Config
.
base
(),
"version.o2"
));
FileFilter
fileFilter
=
new
RegexFileFilter
(
"^(start_|stop_|console_)(aix|windows|linux|macos).(sh|bat)$"
);
for
(
File
_f
:
new
File
(
Config
.
base
()).
listFiles
(
fileFilter
))
{
files
.
add
(
_f
);
}
JarTools
.
jar
(
files
,
dest
);
logger
.
print
(
"backup current version completed."
);
}
private
WrapUpdateVersion
get
(
boolean
toLatest
)
throws
Exception
{
String
address
=
""
;
if
(
toLatest
)
{
address
=
Config
.
collect
().
url
(
"/o2_collect_assemble/jaxrs/update/latest/version"
);
}
else
{
address
=
Config
.
collect
().
url
(
"/o2_collect_assemble/jaxrs/update/next/"
+
Config
.
version
());
}
URL
url
=
new
URL
(
address
);
HttpURLConnection
connection
=
(
HttpURLConnection
)
url
.
openConnection
();
connection
.
setUseCaches
(
false
);
connection
.
setRequestProperty
(
"Content-Type"
,
HttpMediaType
.
APPLICATION_JSON_UTF_8
);
connection
.
setRequestMethod
(
"GET"
);
connection
.
setDoOutput
(
false
);
connection
.
setDoInput
(
true
);
connection
.
connect
();
String
json
=
""
;
try
(
InputStream
input
=
connection
.
getInputStream
())
{
json
=
IOUtils
.
toString
(
input
,
StandardCharsets
.
UTF_8
);
}
connection
.
disconnect
();
Gson
gson
=
XGsonBuilder
.
instance
();
JsonElement
jsonElement
=
gson
.
fromJson
(
json
,
JsonElement
.
class
);
if
(
jsonElement
.
isJsonObject
())
{
JsonObject
jsonObject
=
jsonElement
.
getAsJsonObject
();
if
(
jsonObject
.
has
(
"data"
))
{
return
XGsonBuilder
.
instance
().
fromJson
(
jsonObject
.
get
(
"data"
),
WrapUpdateVersion
.
class
);
}
}
return
null
;
}
public
static
class
WrapUpdateVersion
{
private
String
version
;
private
Long
size
;
private
String
url
;
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
Long
getSize
()
{
return
size
;
}
public
void
setSize
(
Long
size
)
{
this
.
size
=
size
;
}
}
private
File
getPack
(
String
address
)
throws
Exception
{
logger
.
print
(
"download update pack form url: {}."
,
address
);
URL
url
=
new
URL
(
address
);
File
file
=
new
File
(
Config
.
base
(),
"local/update.zip"
);
if
(
file
.
exists
()
&&
file
.
isFile
())
{
FileUtils
.
forceDelete
(
file
);
}
FileUtils
.
copyURLToFile
(
url
,
file
);
logger
.
print
(
"download update pack completed."
);
return
file
;
}
private
void
unzip
(
File
file
)
throws
Exception
{
File
dir
=
Config
.
dir_local_update
(
true
);
FileUtils
.
cleanDirectory
(
dir
);
JarTools
.
unjar
(
file
,
""
,
dir
,
true
);
File
dir_local
=
new
File
(
dir
,
"local"
);
if
(
dir_local
.
exists
())
{
FileUtils
.
forceDelete
(
dir_local
);
}
File
dir_config
=
new
File
(
dir
,
"config"
);
if
(
dir_config
.
exists
())
{
FileUtils
.
forceDelete
(
dir_config
);
}
}
}
\ No newline at end of file
o2server/x_console/src/main/java/com/x/server/console/action/
Action
UpdateFile.java
→
o2server/x_console/src/main/java/com/x/server/console/action/UpdateFile.java
浏览文件 @
45342b5e
...
...
@@ -6,19 +6,21 @@ import java.util.ArrayList;
import
java.util.Date
;
import
java.util.List
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.filefilter.RegexFileFilter
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.tools.DateTools
;
import
com.x.base.core.project.tools.JarTools
;
public
class
ActionUpdateFile
extends
ActionUpdate
{
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.filefilter.RegexFileFilter
;
/**
* @author Zhou Rui
*/
public
class
UpdateFile
extends
ActionBase
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
Action
UpdateFile
.
class
);
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
UpdateFile
.
class
);
private
Date
start
;
...
...
@@ -26,13 +28,9 @@ public class ActionUpdateFile extends ActionUpdate {
this
.
start
=
new
Date
();
}
public
boolean
execute
(
String
path
,
boolean
backup
,
String
password
)
{
public
boolean
execute
(
String
path
,
boolean
backup
)
{
try
{
this
.
init
();
if
(!
StringUtils
.
equals
(
Config
.
token
().
getPassword
(),
password
))
{
logger
.
print
(
"password not mactch."
);
return
false
;
}
File
file
=
new
File
(
path
);
if
(!
file
.
exists
()
||
file
.
isDirectory
())
{
logger
.
print
(
"zip file not exist path:{}."
,
path
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录