Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo-1
Commits
f9ab031e
Unverified
Commit
f9ab031e
authored
Feb 22, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
Fix #12657
parent
b247815b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
32 deletions
+47
-32
pom.xml
pom.xml
+2
-2
src/main/java/org/b3log/solo/SoloServletListener.java
src/main/java/org/b3log/solo/SoloServletListener.java
+2
-0
src/main/java/org/b3log/solo/service/InitService.java
src/main/java/org/b3log/solo/service/InitService.java
+43
-30
No files found.
pom.xml
View file @
f9ab031e
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!--
<!--
Description: Solo POM.
Description: Solo POM.
Version: 3.18.3.4
7, Feb 16
, 2019
Version: 3.18.3.4
8, Feb 22
, 2019
Author: <a href="http://88250.b3log.org">Liang Ding</a>
Author: <a href="http://88250.b3log.org">Liang Ding</a>
Author: <a href="http://www.annpeter.cn">Ann Peter</a>
Author: <a href="http://www.annpeter.cn">Ann Peter</a>
Author: <a href="http://vanessa.b3log.org">Vanessa</a>
Author: <a href="http://vanessa.b3log.org">Vanessa</a>
...
@@ -74,7 +74,7 @@
...
@@ -74,7 +74,7 @@
</scm>
</scm>
<properties>
<properties>
<org.b3log.latke.version>
2.4.4
2
</org.b3log.latke.version>
<org.b3log.latke.version>
2.4.4
3
</org.b3log.latke.version>
<slf4j.version>
1.7.5
</slf4j.version>
<slf4j.version>
1.7.5
</slf4j.version>
<jsoup.version>
1.9.1
</jsoup.version>
<jsoup.version>
1.9.1
</jsoup.version>
...
...
src/main/java/org/b3log/solo/SoloServletListener.java
View file @
f9ab031e
...
@@ -84,6 +84,8 @@ public final class SoloServletListener extends AbstractServletListener {
...
@@ -84,6 +84,8 @@ public final class SoloServletListener extends AbstractServletListener {
validateSkin
();
validateSkin
();
final
InitService
initService
=
beanManager
.
getReference
(
InitService
.
class
);
final
InitService
initService
=
beanManager
.
getReference
(
InitService
.
class
);
initService
.
initTables
();
if
(
initService
.
isInited
())
{
if
(
initService
.
isInited
())
{
// Upgrade check https://github.com/b3log/solo/issues/12040
// Upgrade check https://github.com/b3log/solo/issues/12040
final
UpgradeService
upgradeService
=
beanManager
.
getReference
(
UpgradeService
.
class
);
final
UpgradeService
upgradeService
=
beanManager
.
getReference
(
UpgradeService
.
class
);
...
...
src/main/java/org/b3log/solo/service/InitService.java
View file @
f9ab031e
...
@@ -28,9 +28,9 @@ import org.b3log.latke.logging.Logger;
...
@@ -28,9 +28,9 @@ import org.b3log.latke.logging.Logger;
import
org.b3log.latke.model.Role
;
import
org.b3log.latke.model.Role
;
import
org.b3log.latke.model.User
;
import
org.b3log.latke.model.User
;
import
org.b3log.latke.plugin.PluginManager
;
import
org.b3log.latke.plugin.PluginManager
;
import
org.b3log.latke.repository.Query
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.repository.RepositoryException
;
import
org.b3log.latke.repository.Transaction
;
import
org.b3log.latke.repository.Transaction
;
import
org.b3log.latke.repository.jdbc.util.Connections
;
import
org.b3log.latke.repository.jdbc.util.JdbcRepositories
;
import
org.b3log.latke.repository.jdbc.util.JdbcRepositories
;
import
org.b3log.latke.repository.jdbc.util.JdbcRepositories.CreateTableResult
;
import
org.b3log.latke.repository.jdbc.util.JdbcRepositories.CreateTableResult
;
import
org.b3log.latke.service.LangPropsService
;
import
org.b3log.latke.service.LangPropsService
;
...
@@ -48,9 +48,6 @@ import org.json.JSONArray;
...
@@ -48,9 +48,6 @@ import org.json.JSONArray;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -162,43 +159,40 @@ public class InitService {
...
@@ -162,43 +159,40 @@ public class InitService {
return
true
;
return
true
;
}
}
try
(
final
Connection
connection
=
Connections
.
getConnection
())
{
try
{
final
PreparedStatement
preparedStatement
=
connection
.
prepareStatement
(
"SELECT COUNT(1) AS `c` FROM `"
+
userRepository
.
getName
()
+
"`"
);
inited
=
!
optionRepository
.
getList
(
new
Query
()).
isEmpty
(
);
final
ResultSet
resultSet
=
preparedStatement
.
executeQuery
();
if
(!
inited
&&
!
printedInitMsg
)
{
resultSet
.
next
(
);
LOGGER
.
log
(
Level
.
WARN
,
"Solo has not been initialized, please open your browser and visit ["
+
Latkes
.
getServePath
()
+
"] to init Solo"
);
final
int
c
=
resultSet
.
getInt
(
"c"
)
;
printedInitMsg
=
true
;
inited
=
0
<
c
;
}
return
inited
;
return
inited
;
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
if
(!
printedInitMsg
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Check init failed"
,
e
);
LOGGER
.
log
(
Level
.
WARN
,
"Solo has not been initialized, please open your browser and visit ["
+
Latkes
.
getServePath
()
+
"] to init Solo"
);
}
printedInitMsg
=
true
;
System
.
exit
(-
1
);
return
false
;
return
false
;
}
}
}
}
/**
/**
* Initializes Solo.
* Initializes database tables.
*
* @param requestJSONObject the specified request json object, for example,
* {
* "userName": "",
* "userEmail": "",
* "userAvatar": "", // optional
* "userB3Key": "", // optional
* "userGitHubId": "" // optional
* }
* @throws ServiceException service exception
*/
*/
public
void
init
(
final
JSONObject
requestJSONObject
)
throws
ServiceException
{
public
void
initTables
()
{
if
(
isInited
())
{
try
{
final
String
tablePrefix
=
Latkes
.
getLocalProperty
(
"jdbc.tablePrefix"
)
+
"_"
;
final
boolean
userTableExist
=
JdbcRepositories
.
existTable
(
tablePrefix
+
User
.
USER
);
final
boolean
optionTableExist
=
JdbcRepositories
.
existTable
(
tablePrefix
+
Option
.
OPTION
);
if
(
userTableExist
&&
optionTableExist
)
{
return
;
return
;
}
}
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Check tables failed"
,
e
);
LOGGER
.
log
(
Level
.
DEBUG
,
"Solo is running with database [{0}], creates all tables"
,
Latkes
.
getRuntimeDatabase
());
System
.
exit
(-
1
);
}
LOGGER
.
info
(
"It's your first time setup Solo, initialize tables in database ["
+
Latkes
.
getRuntimeDatabase
()
+
"]"
);
if
(
Latkes
.
RuntimeDatabase
.
H2
==
Latkes
.
getRuntimeDatabase
())
{
if
(
Latkes
.
RuntimeDatabase
.
H2
==
Latkes
.
getRuntimeDatabase
())
{
String
dataDir
=
Latkes
.
getLocalProperty
(
"jdbc.URL"
);
String
dataDir
=
Latkes
.
getLocalProperty
(
"jdbc.URL"
);
...
@@ -209,9 +203,28 @@ public class InitService {
...
@@ -209,9 +203,28 @@ public class InitService {
final
List
<
CreateTableResult
>
createTableResults
=
JdbcRepositories
.
initAllTables
();
final
List
<
CreateTableResult
>
createTableResults
=
JdbcRepositories
.
initAllTables
();
for
(
final
CreateTableResult
createTableResult
:
createTableResults
)
{
for
(
final
CreateTableResult
createTableResult
:
createTableResults
)
{
LOGGER
.
log
(
Level
.
DEBUG
,
"Create table result [tableName={0}, isSuccess={1}]"
,
LOGGER
.
log
(
Level
.
DEBUG
,
"Create
s
table result [tableName={0}, isSuccess={1}]"
,
createTableResult
.
getName
(),
createTableResult
.
isSuccess
());
createTableResult
.
getName
(),
createTableResult
.
isSuccess
());
}
}
}
/**
* Initializes Solo.
*
* @param requestJSONObject the specified request json object, for example,
* {
* "userName": "",
* "userEmail": "",
* "userAvatar": "", // optional
* "userB3Key": "", // optional
* "userGitHubId": "" // optional
* }
* @throws ServiceException service exception
*/
public
void
init
(
final
JSONObject
requestJSONObject
)
throws
ServiceException
{
if
(
isInited
())
{
return
;
}
final
Transaction
transaction
=
userRepository
.
beginTransaction
();
final
Transaction
transaction
=
userRepository
.
beginTransaction
();
try
{
try
{
...
@@ -270,7 +283,7 @@ public class InitService {
...
@@ -270,7 +283,7 @@ public class InitService {
final
JSONObject
comment
=
new
JSONObject
();
final
JSONObject
comment
=
new
JSONObject
();
comment
.
put
(
Keys
.
OBJECT_ID
,
articleId
);
comment
.
put
(
Keys
.
OBJECT_ID
,
articleId
);
comment
.
put
(
Comment
.
COMMENT_NAME
,
"
Daniel
"
);
comment
.
put
(
Comment
.
COMMENT_NAME
,
"
88250
"
);
comment
.
put
(
Comment
.
COMMENT_EMAIL
,
"d@b3log.org"
);
comment
.
put
(
Comment
.
COMMENT_EMAIL
,
"d@b3log.org"
);
comment
.
put
(
Comment
.
COMMENT_URL
,
"https://hacpai.com/member/88250"
);
comment
.
put
(
Comment
.
COMMENT_URL
,
"https://hacpai.com/member/88250"
);
comment
.
put
(
Comment
.
COMMENT_CONTENT
,
langPropsService
.
get
(
"helloWorld.comment.content"
));
comment
.
put
(
Comment
.
COMMENT_CONTENT
,
langPropsService
.
get
(
"helloWorld.comment.content"
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment